From b2c5310d4da56237571bb8ea8d24b030c941030f Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 5 Jul 2007 18:02:14 +0200 Subject: svn_rev_653 restructure tree, add reginfo command --- Makefile | 2 +- arch/ppc/Kconfig | 4 + arch/ppc/configs/phycore_mpc5200b_tiny_defconfig | 27 +- arch/ppc/lib/Makefile | 2 +- .../phycore_mpc5200b_tiny/phycore_mpc5200b_tiny.c | 2 +- commands/Kconfig | 56 + commands/Makefile | 13 +- commands/bootm.c | 18 - commands/cat.c | 64 + commands/cd.c | 32 + commands/cp.c | 68 + commands/environment.c | 17 +- commands/flash.c | 125 ++ commands/fs.c | 391 ---- commands/ls.c | 122 ++ commands/mem.c | 103 - commands/mkdir.c | 35 + commands/mount.c | 53 + commands/pwd.c | 15 + commands/reginfo.c | 14 + commands/rm.c | 30 + commands/rmdir.c | 35 + commands/umount.c | 31 + common/Kconfig | 8 +- common/Makefile | 1 - common/cmd_ext2.c | 297 --- common/cmd_fat.c | 362 ---- common/cmd_flash.c | 125 -- common/cmd_jffs2.c | 2195 -------------------- common/cmd_misc.c | 50 - common/cmd_reginfo.c | 350 ---- common/cmd_reiser.c | 277 --- common/dlmalloc.c | 4 +- common/misc.c | 6 +- common/partition.c | 185 -- common/startup.c | 8 +- cpu/mpc5xx/reginfo.c | 37 + cpu/mpc5xxx/Makefile | 22 +- cpu/mpc5xxx/cpu.c | 2 +- cpu/mpc5xxx/cpu_init.c | 2 +- cpu/mpc5xxx/loadtask.c | 2 +- cpu/mpc5xxx/reginfo.c | 59 + cpu/mpc5xxx/speed.c | 2 +- cpu/mpc5xxx/start.S | 2 +- cpu/ppc4xx/reginfo_405ep.c | 68 + cpu/ppc4xx/reginfo_405gp.c | 91 + drivers/serial/serial_mpc5xxx.c | 2 +- fs/fs.c | 54 +- include/asm-ppc/arch-mpc5200/mpc5xxx.h | 781 +++++++ include/common.h | 9 +- include/mpc5xxx.h | 781 ------- lib/Kconfig | 8 - lib/Makefile | 1 - lib/global.c | 35 - lib/misc.c | 28 - lib/parameter.c | 2 + 56 files changed, 1854 insertions(+), 5261 deletions(-) create mode 100644 commands/cat.c create mode 100644 commands/cd.c create mode 100644 commands/cp.c create mode 100644 commands/flash.c delete mode 100644 commands/fs.c create mode 100644 commands/ls.c create mode 100644 commands/mkdir.c create mode 100644 commands/mount.c create mode 100644 commands/pwd.c create mode 100644 commands/reginfo.c create mode 100644 commands/rm.c create mode 100644 commands/rmdir.c create mode 100644 commands/umount.c delete mode 100644 common/cmd_ext2.c delete mode 100644 common/cmd_fat.c delete mode 100644 common/cmd_flash.c delete mode 100644 common/cmd_jffs2.c delete mode 100644 common/cmd_misc.c delete mode 100644 common/cmd_reginfo.c delete mode 100644 common/cmd_reiser.c create mode 100644 cpu/mpc5xx/reginfo.c create mode 100644 cpu/mpc5xxx/reginfo.c create mode 100644 cpu/ppc4xx/reginfo_405ep.c create mode 100644 cpu/ppc4xx/reginfo_405gp.c create mode 100644 include/asm-ppc/arch-mpc5200/mpc5xxx.h delete mode 100644 include/mpc5xxx.h delete mode 100644 lib/global.c diff --git a/Makefile b/Makefile index 594436c75a..c51d6372ec 100644 --- a/Makefile +++ b/Makefile @@ -880,7 +880,7 @@ depend dep: CLEAN_DIRS += $(MODVERDIR) CLEAN_FILES += uboot System.map \ .tmp_kallsyms* .tmp_version .tmp_uboot* .tmp_System.map \ - uboot.bin uboot.S + uboot.bin uboot.S $(uboot-lds) # Directories & files removed with 'make mrproper' MRPROPER_DIRS += include/config include2 usr/include diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig index 0a77d9110b..36d2890942 100644 --- a/arch/ppc/Kconfig +++ b/arch/ppc/Kconfig @@ -13,6 +13,10 @@ config CACHELINE_SIZE int default 32 if MPC5200 +config HAS_REGINFO + bool + default y if MPC5200 + choice prompt "Select your board" diff --git a/arch/ppc/configs/phycore_mpc5200b_tiny_defconfig b/arch/ppc/configs/phycore_mpc5200b_tiny_defconfig index d1e8524ded..65f2073aaf 100644 --- a/arch/ppc/configs/phycore_mpc5200b_tiny_defconfig +++ b/arch/ppc/configs/phycore_mpc5200b_tiny_defconfig @@ -1,15 +1,14 @@ # # Automatically generated make config: don't edit # U-Boot version: 2.0.0-trunk -# Fri Jun 29 15:39:05 2007 +# Sun Jul 1 14:40:26 2007 # -CONFIG_TEXT_BASE="0x0" +CONFIG_TEXT_BASE="0x1000000" CONFIG_ARCH_MPC5200=y CONFIG_MPC5200=y CONFIG_CACHELINE_SIZE=32 CONFIG_MACH_PHYCORE_MPC5200B_TINY=y CONFIG_MACH_PHYCORE_MPC5200B_TINY_REV_1=y -CONFIG_ZLIB=y CONFIG_GREGORIAN_CALENDER=y # @@ -25,13 +24,15 @@ CONFIG_MAXARGS=16 CONFIG_HUSH_PARSER=y CONFIG_PROMPT_HUSH_PS2="> " CONFIG_ZERO_BOOTDELAY_CHECK=y -CONFIG_DYNAMIC_CRC_TABLE=y CONFIG_ERRNO_MESSAGES=y CONFIG_TIMESTAMP=y -# CONFIG_CONSOLE_ACTIVATE_FIRST is not set -CONFIG_CONSOLE_ACTIVATE_ALL=y +CONFIG_CONSOLE_ACTIVATE_FIRST=y CONFIG_OF_FLAT_TREE=y +# +# Debugging +# + # # Commands # @@ -82,11 +83,9 @@ CONFIG_CMD_FLASH=y # CONFIG_CMD_BOOTM=y CONFIG_CMD_BOOTM_ZLIB=y -# CONFIG_CMD_BOOTM_BZLIB is not set - -# -# Debugging -# +CONFIG_CMD_BOOTM_BZLIB=y +CONFIG_CMD_RESET=y +CONFIG_CMD_GO=y CONFIG_NET=y CONFIG_NET_BOOTP=y CONFIG_NET_DHCP=y @@ -130,9 +129,13 @@ CONFIG_DRIVER_NET_MPC5200=y CONFIG_HAS_CFI=y CONFIG_DRIVER_CFI=y # CONFIG_DRIVER_CFI_NEW is not set -CONFIG_CFI_BUFFER_WRITE=y +# CONFIG_CFI_BUFFER_WRITE is not set # # Filesystem support # CONFIG_FS_CRAMFS=y +CONFIG_ZLIB=y +CONFIG_BZLIB=y +CONFIG_CRC32=y +CONFIG_DYNAMIC_CRC_TABLE=y diff --git a/arch/ppc/lib/Makefile b/arch/ppc/lib/Makefile index bf39df463c..6e79266960 100644 --- a/arch/ppc/lib/Makefile +++ b/arch/ppc/lib/Makefile @@ -8,6 +8,6 @@ obj-y += ppcstring.o obj-y += ticks.o obj-y += time.o obj-y += misc.o -obj-y += ppclinux.o +obj-$(CONFIG_CMD_BOOTM) += ppclinux.o obj-y += board_data.o diff --git a/board/phycore_mpc5200b_tiny/phycore_mpc5200b_tiny.c b/board/phycore_mpc5200b_tiny/phycore_mpc5200b_tiny.c index 4e622422e6..98f02221db 100644 --- a/board/phycore_mpc5200b_tiny/phycore_mpc5200b_tiny.c +++ b/board/phycore_mpc5200b_tiny/phycore_mpc5200b_tiny.c @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/commands/Kconfig b/commands/Kconfig index 530c9e4f83..61ee8c549e 100644 --- a/commands/Kconfig +++ b/commands/Kconfig @@ -1,3 +1,6 @@ +config REGINFO + bool + menu "Commands " menu "scripting " @@ -25,6 +28,49 @@ config CMD_HELP endmenu +menu "file commands " + +config CMD_LS + bool + prompt "ls" + +config CMD_RM + bool + prompt "rm" + +config CMD_CAT + bool + prompt "cat" + +config CMD_MKDIR + bool + prompt "mkdir" + +config CMD_RMDIR + bool + prompt "rmdir" + +config CMD_CP + bool + prompt "cp" + +config CMD_PWD + bool + prompt "pwd" + +config CMD_CD + bool + prompt "cd" + +config CMD_MOUNT + bool + prompt "mount" + +config CMD_UMOUNT + bool + prompt "umount" + +endmenu menu "console " @@ -151,4 +197,14 @@ config CMD_GO endmenu +config CMD_PARTITION + bool + prompt "addpart/delpart" + +config CMD_REGINFO + depends on HAS_REGINFO + select REGINFO + bool + prompt "reginfo" + endmenu diff --git a/commands/Makefile b/commands/Makefile index 776a2019ea..e4c38c12ec 100644 --- a/commands/Makefile +++ b/commands/Makefile @@ -2,7 +2,6 @@ obj-$(CONFIG_CMD_BOOTM) += bootm.o obj-$(CONFIG_CMD_LOADB) += loadb.o xyzModem.o obj-$(CONFIG_CMD_LOADS) += loads.o obj-$(CONFIG_CMD_ECHO) += echo.o -#obj-$(CONFIG_CMD_FLASH) += flash.o obj-$(CONFIG_CMD_MEMORY) += mem.o obj-$(CONFIG_CMD_MII) += mii.o obj-$(CONFIG_CMD_I2C) += i2c.o @@ -15,6 +14,16 @@ obj-$(CONFIG_CMD_SLEEP) += sleep.o obj-$(CONFIG_CMD_RESET) += reset.o obj-$(CONFIG_CMD_GO) += go.o obj-$(CONFIG_CMD_ENVIRONMENT) += environment.o -obj-y += fs.o obj-$(CONFIG_NET) += net.o obj-$(CONFIG_CMD_PARTITION) += partition.o +obj-$(CONFIG_CMD_LS) += ls.o +obj-$(CONFIG_CMD_CD) += cd.o +obj-$(CONFIG_CMD_PWD) += pwd.o +obj-$(CONFIG_CMD_MKDIR) += mkdir.o +obj-$(CONFIG_CMD_RMDIR) += rmdir.o +obj-$(CONFIG_CMD_CP) += cp.o +obj-$(CONFIG_CMD_RM) += rm.o +obj-$(CONFIG_CMD_CAT) += cat.o +obj-$(CONFIG_CMD_MOUNT) += mount.o +obj-$(CONFIG_CMD_UMOUNT) += umount.o +obj-$(CONFIG_CMD_REGINFO) += reginfo.o diff --git a/commands/bootm.c b/commands/bootm.c index 02ddf20fdb..a929986fbd 100644 --- a/commands/bootm.c +++ b/commands/bootm.c @@ -632,24 +632,6 @@ do_bootm_artos (cmd_tbl_t *cmdtp, int flag, } #endif -int do_bootd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ - int rcode = 0; -#ifndef CONFIG_HUSH_PARSER - if (run_command (getenv ("bootcmd"), flag) < 0) rcode = 1; -#else - if (parse_string_outer(getenv("bootcmd"), - FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP) != 0 ) rcode = 1; -#endif - return rcode; -} - -U_BOOT_CMD_START(boot) - .maxargs = 1, - .cmd = do_bootd, - .usage = "boot default, i.e., run 'bootcmd'", -U_BOOT_CMD_END - #if 0 int do_iminfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { diff --git a/commands/cat.c b/commands/cat.c new file mode 100644 index 0000000000..72baae2e5e --- /dev/null +++ b/commands/cat.c @@ -0,0 +1,64 @@ +#include +#include +#include +#include +#include +#include +#include + +static int do_cat(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + int ret; + int fd, i; + char *buf; + int err = 0; + int args = 1; + + if (argc < 2) { + perror("cat"); + return 1; + } + + buf = xmalloc(1024); + + while (args < argc) { + fd = open(argv[args], 0); + if (fd < 0) { + printf("could not open %s: %s\n", argv[args], errno_str()); + goto out; + } + + while((ret = read(fd, buf, 1024)) > 0) { + for(i = 0; i < ret; i++) { + if (isprint(buf[i]) || buf[i] == '\n' || buf[i] == '\t') + putc(buf[i]); + else + putc('.'); + } + if(ctrlc()) { + err = 1; + close(fd); + goto out; + } + } + close(fd); + args++; + } + +out: + free(buf); + + return err; +} + +static __maybe_unused char cmd_cat_help[] = +"Usage: cat [FILES]\n" +"Concatenate files on stdout. Currently only printable characters\n" +"and \\n and \\t are printed, but this should be optional\n"; + +U_BOOT_CMD_START(cat) + .maxargs = CONFIG_MAXARGS, + .cmd = do_cat, + .usage = "concatenate file(s)", + U_BOOT_CMD_HELP(cmd_cat_help) +U_BOOT_CMD_END diff --git a/commands/cd.c b/commands/cd.c new file mode 100644 index 0000000000..0a45cbb63d --- /dev/null +++ b/commands/cd.c @@ -0,0 +1,32 @@ +#include +#include +#include +#include + +static int do_cd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + int ret; + + if (argc == 1) + ret = chdir("/"); + else + ret = chdir(argv[1]); + + if (ret) { + perror("chdir"); + return 1; + } + + return 0; +} + +static __maybe_unused char cmd_cd_help[] = +"Usage: cd [directory]\n" +"change to directory. If called without argument, change to /\n"; + +U_BOOT_CMD_START(cd) + .maxargs = 2, + .cmd = do_cd, + .usage = "change working directory", + U_BOOT_CMD_HELP(cmd_cd_help) +U_BOOT_CMD_END diff --git a/commands/cp.c b/commands/cp.c new file mode 100644 index 0000000000..d014cd4a0b --- /dev/null +++ b/commands/cp.c @@ -0,0 +1,68 @@ +#include +#include +#include +#include +#include +#include +#include + +#define RW_BUF_SIZE (ulong)4096 + +int do_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + int r, w, ret = 1; + int src = 0, dst = 0; + char *rw_buf = NULL; + + rw_buf = xmalloc(RW_BUF_SIZE); + + src = open(argv[1], O_RDONLY); + if (src < 0) { + printf("could not open %s: %s\n", src, errno_str()); + goto out; + } + + dst = open(argv[2], O_WRONLY | O_CREAT); + if ( dst < 0) { + printf("could not open %s: %s\n", dst, errno_str()); + goto out; + } + + while(1) { + r = read(src, rw_buf, RW_BUF_SIZE); + if (read < 0) { + perror("read"); + goto out; + } + if (!r) + break; + w = write(dst, rw_buf, r); + if (w < 0) { + perror("write"); + goto out; + } + } + ret = 0; +out: + free(rw_buf); + if (src) + close(src); + if (dst) + close(dst); + return ret; +} + +static __maybe_unused char cmd_cp_help[] = +"Usage: cp \n" +"cp copies file to .\n" +"Currently only this form is supported and you have to specify the exact target\n" +"filename (not a target directory).\n" +"Note: This command was previously used as memory copy. Currently there is no\n" +"equivalent command for this. This must be fixed of course.\n"; + +U_BOOT_CMD_START(cp) + .maxargs = CONFIG_MAXARGS, + .cmd = do_cp, + .usage = "copy files", + U_BOOT_CMD_HELP(cmd_cp_help) +U_BOOT_CMD_END diff --git a/commands/environment.c b/commands/environment.c index 148b6e9d6e..aef52c4f43 100644 --- a/commands/environment.c +++ b/commands/environment.c @@ -97,7 +97,7 @@ out: #ifdef __U_BOOT__ int do_saveenv(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { - int ret; + int ret, fd; char *filename, *dirname; printf("saving environment\n"); @@ -110,9 +110,24 @@ int do_saveenv(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) else filename = argv[1]; + fd = open(filename, O_WRONLY); + if (fd < 0) { + printf("could not open %s: %s", filename, errno_str()); + return 1; + } + + ret = erase(fd, ~0, 0); + if (ret && errno != -EINVAL) { + printf("could not erase %s: %s\n", filename, errno_str()); + close(fd); + return 1; + } + ret = envfs_save(filename, dirname); if (ret) printf("saveenv failed\n"); + + close(fd); return ret; } diff --git a/commands/flash.c b/commands/flash.c new file mode 100644 index 0000000000..db059dba58 --- /dev/null +++ b/commands/flash.c @@ -0,0 +1,125 @@ +/* + * (C) Copyright 2000 + * 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 + */ + +/* + * FLASH support + */ +#include +#include +#include +#include +#include +#include +#include +#include + +int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + int opt, fd; + char *filename = NULL; + struct stat s; + unsigned long start = 0, size = ~0; + + getopt_reset(); + + while((opt = getopt(argc, argv, "f:")) > 0) { + switch(opt) { + case 'f': + filename = optarg; + break; + } + } + + if (stat(filename, &s)) { + printf("stat %s:", filename, errno_str()); + return 1; + } + + size = s.st_size; + + if (!filename) { + printf("missing filename\n"); + return 1; + } + + fd = open(filename, O_WRONLY); + if (fd < 0) { + printf("open %s:", filename, errno_str()); + return 1; + } + + if (optind < argc) + parse_area_spec(argv[optind], &start, &size); + + if(erase(fd, size, start)) { + perror("erase"); + return 1; + } + + close(fd); + + return 0; +} + +U_BOOT_CMD_START(erase) + .maxargs = CONFIG_MAXARGS, + .cmd = do_flerase, + .usage = "erase FLASH memory", + U_BOOT_CMD_HELP("write me\n") +U_BOOT_CMD_END + +int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + int p; + int rcode = 0; + struct memarea_info mem_info; + + if (argc < 3) { + printf ("Usage:\n%s\n", cmdtp->usage); + return 1; + } + + if (strcmp(argv[1], "off") == 0) { + p = 0; + } else if (strcmp(argv[1], "on") == 0) { + p = 1; + } else { + printf ("Usage:\n%s\n", cmdtp->usage); + return 1; + } + + if (spec_str_to_info(argv[2], &mem_info)) { + printf ("-EPARSE\n"); + return 1; + } + +// rcode = flash_sect_protect (p, addr_first, addr_last); + return rcode; +} + +U_BOOT_CMD_START(protect) + .maxargs = 4, + .cmd = do_protect, + .usage = "enable or disable FLASH write protection", + U_BOOT_CMD_HELP("write me\n") +U_BOOT_CMD_END diff --git a/commands/fs.c b/commands/fs.c deleted file mode 100644 index 2eca365016..0000000000 --- a/commands/fs.c +++ /dev/null @@ -1,391 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static void ls_one(const char *path, struct stat *s) -{ - char modestr[11]; - unsigned long namelen = strlen(path); - - mkmodestr(s->st_mode, modestr); - printf("%s %8d %*.*s\n",modestr, s->st_size, namelen, namelen, path); -} - -int ls(const char *path, ulong flags) -{ - DIR *dir; - struct dirent *d; - char tmp[PATH_MAX]; - struct stat s; - - if (flags & LS_SHOWARG) - printf("%s:\n", path); - - if (stat(path, &s)) { - perror("stat"); - return errno; - } - - if (!(s.st_mode & S_IFDIR)) { - ls_one(path, &s); - return 0; - } - - dir = opendir(path); - if (!dir) - return errno; - - while ((d = readdir(dir))) { - sprintf(tmp, "%s/%s", path, d->d_name); - if (stat(tmp, &s)) - goto out; - ls_one(d->d_name, &s); - } - - closedir(dir); - - if (!(flags & LS_RECURSIVE)) - return 0; - - dir = opendir(path); - if (!dir) { - errno = -ENOENT; - return -ENOENT; - } - - while ((d = readdir(dir))) { - sprintf(tmp, "%s/%s", path, d->d_name); - normalise_path(tmp); - if (stat(tmp, &s)) - goto out; - if (!strcmp(d->d_name, ".")) - continue; - if (!strcmp(d->d_name, "..")) - continue; - if (s.st_mode & S_IFDIR) - ls(tmp, flags); - } -out: - closedir(dir); - - return 0; -} - -static int do_ls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ - int ret, opt; - ulong flags = 0; - - getopt_reset(); - - while((opt = getopt(argc, argv, "R")) > 0) { - switch(opt) { - case 'R': - flags |= LS_RECURSIVE | LS_SHOWARG; - break; - } - } - - if (argc - optind > 1) - flags |= LS_SHOWARG; - - if (optind == argc) { - ret = ls(getcwd(), flags); - return ret ? 1 : 0; - } - - while (optind < argc) { - ret = ls(argv[optind], flags); - if (ret) { - perror("ls"); - return 1; - } - optind++; - } - - return 0; -} - -static __maybe_unused char cmd_ls_help[] = -"Usage: ls [OPTION]... [FILE]...\n" -"List information about the FILEs (the current directory by default).\n" -" -R list subdirectories recursively\n"; - -U_BOOT_CMD_START(ls) - .maxargs = CONFIG_MAXARGS, - .cmd = do_ls, - .usage = "list a file or directory", - U_BOOT_CMD_HELP(cmd_ls_help) -U_BOOT_CMD_END - -static int do_cd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ - int ret; - - if (argc == 1) - ret = chdir("/"); - else - ret = chdir(argv[1]); - - if (ret) { - perror("chdir"); - return 1; - } - - return 0; -} - -static __maybe_unused char cmd_cd_help[] = -"Usage: cd [directory]\n" -"change to directory. If called without argument, change to /\n"; - -U_BOOT_CMD_START(cd) - .maxargs = 2, - .cmd = do_cd, - .usage = "change working directory", - U_BOOT_CMD_HELP(cmd_cd_help) -U_BOOT_CMD_END - -static int do_pwd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ - printf("%s\n", getcwd()); - return 0; -} - -U_BOOT_CMD_START(pwd) - .maxargs = 2, - .cmd = do_pwd, - .usage = "print working directory", -U_BOOT_CMD_END - -static int do_mkdir (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ - int i = 1; - - if (argc < 2) { - u_boot_cmd_usage(cmdtp); - return 1; - } - - while (i < argc) { - if (mkdir(argv[i])) { - printf("could not create %s: %s\n", argv[i], errno_str()); - return 1; - } - i++; - } - - return 0; -} - -static __maybe_unused char cmd_mkdir_help[] = -"Usage: mkdir [directories]\n" -"Create new directories\n"; - -U_BOOT_CMD_START(mkdir) - .maxargs = CONFIG_MAXARGS, - .cmd = do_mkdir, - .usage = "make directories", - U_BOOT_CMD_HELP(cmd_mkdir_help) -U_BOOT_CMD_END - -static int do_rm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ - int i = 1; - - if (argc < 2) { - u_boot_cmd_usage(cmdtp); - return 1; - } - - while (i < argc) { - if (unlink(argv[i])) { - printf("could not remove %s: %s\n", argv[i], errno_str()); - return 1; - } - i++; - } - - return 0; -} - -static __maybe_unused char cmd_rm_help[] = -"Usage: rm [FILES]\n" -"Remove files\n"; - -U_BOOT_CMD_START(rm) - .maxargs = CONFIG_MAXARGS, - .cmd = do_rm, - .usage = "remove files", - U_BOOT_CMD_HELP(cmd_rm_help) -U_BOOT_CMD_END - -static int do_rmdir (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ - int i = 1; - - if (argc < 2) { - u_boot_cmd_usage(cmdtp); - return 1; - } - - while (i < argc) { - if (rmdir(argv[i])) { - printf("could not remove %s: %s\n", argv[i], errno_str()); - return 1; - } - i++; - } - - return 0; -} - -static __maybe_unused char cmd_rmdir_help[] = -"Usage: rmdir [directories]\n" -"Remove directories. The directories have to be empty.\n"; - -U_BOOT_CMD_START(rmdir) - .maxargs = CONFIG_MAXARGS, - .cmd = do_rmdir, - .usage = "remove directorie(s)", - U_BOOT_CMD_HELP(cmd_rmdir_help) -U_BOOT_CMD_END - -static int do_mount (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ - int ret = 0; - struct mtab_entry *entry = NULL; - - if (argc == 1) { - do { - entry = mtab_next_entry(entry); - if (entry) { - printf("%s on %s type %s\n", - entry->parent_device ? entry->parent_device->id : "none", - entry->path, - entry->dev->name); - } - } while (entry); - return 0; - } - - if (argc != 4) { - u_boot_cmd_usage(cmdtp); - return 1; - } - - if ((ret = mount(argv[1], argv[2], argv[3]))) { - perror("mount"); - return 1; - } - return 0; -} - -static __maybe_unused char cmd_mount_help[] = -"Usage: mount: list mounted filesystems\n" -"or: mount \n" -"\n" -"Mount a filesystem of a given type to a mountpoint.\n" -" can be one of /dev/* or some arbitrary string if no\n" -"device is needed for this driver (for example ramfs).\n" -" is the filesystem driver to use. Try the 'devinfo' command\n" -"for a list of available drivers.\n" -" must be an empty directory descending directly from the\n" -"root directory.\n"; - -U_BOOT_CMD_START(mount) - .maxargs = 4, - .cmd = do_mount, - .usage = "mount a filesystem to a device", - U_BOOT_CMD_HELP(cmd_mount_help) -U_BOOT_CMD_END - -static int do_umount (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ - int ret = 0; - - if (argc != 2) { - u_boot_cmd_usage(cmdtp); - return 1; - } - - if ((ret = umount(argv[1]))) { - perror("umount"); - return 1; - } - return 0; -} - -static __maybe_unused char cmd_umount_help[] = -"Usage: umount \n" -"umount a filesystem mounted on a specific mountpoint\n"; - -U_BOOT_CMD_START(umount) - .maxargs = 2, - .cmd = do_umount, - .usage = "umount a filesystem", - U_BOOT_CMD_HELP(cmd_umount_help) -U_BOOT_CMD_END - -static int do_cat(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ - int ret; - int fd, i; - char *buf; - int err = 0; - int args = 1; - - if (argc < 2) { - perror("cat"); - return 1; - } - - buf = xmalloc(1024); - - while (args < argc) { - fd = open(argv[args], 0); - if (fd < 0) { - printf("could not open %s: %s\n", argv[args], errno_str()); - goto out; - } - - while((ret = read(fd, buf, 1024)) > 0) { - for(i = 0; i < ret; i++) { - if (isprint(buf[i]) || buf[i] == '\n' || buf[i] == '\t') - putc(buf[i]); - else - putc('.'); - } - if(ctrlc()) { - err = 1; - close(fd); - goto out; - } - } - close(fd); - args++; - } - -out: - free(buf); - - return err; -} - -static __maybe_unused char cmd_cat_help[] = -"Usage: cat [FILES]\n" -"Concatenate files on stdout. Currently only printable characters\n" -"and \\n and \\t are printed, but this should be optional\n"; - -U_BOOT_CMD_START(cat) - .maxargs = CONFIG_MAXARGS, - .cmd = do_cat, - .usage = "concatenate file(s)", - U_BOOT_CMD_HELP(cmd_cat_help) -U_BOOT_CMD_END diff --git a/commands/ls.c b/commands/ls.c new file mode 100644 index 0000000000..7cdbbb790e --- /dev/null +++ b/commands/ls.c @@ -0,0 +1,122 @@ +#include +#include +#include +#include +#include +#include + +static void ls_one(const char *path, struct stat *s) +{ + char modestr[11]; + unsigned long namelen = strlen(path); + + mkmodestr(s->st_mode, modestr); + printf("%s %8d %*.*s\n",modestr, s->st_size, namelen, namelen, path); +} + +int ls(const char *path, ulong flags) +{ + DIR *dir; + struct dirent *d; + char tmp[PATH_MAX]; + struct stat s; + + if (flags & LS_SHOWARG) + printf("%s:\n", path); + + if (stat(path, &s)) { + perror("stat"); + return errno; + } + + if (!(s.st_mode & S_IFDIR)) { + ls_one(path, &s); + return 0; + } + + dir = opendir(path); + if (!dir) + return errno; + + while ((d = readdir(dir))) { + sprintf(tmp, "%s/%s", path, d->d_name); + if (stat(tmp, &s)) + goto out; + ls_one(d->d_name, &s); + } + + closedir(dir); + + if (!(flags & LS_RECURSIVE)) + return 0; + + dir = opendir(path); + if (!dir) { + errno = -ENOENT; + return -ENOENT; + } + + while ((d = readdir(dir))) { + sprintf(tmp, "%s/%s", path, d->d_name); + normalise_path(tmp); + if (stat(tmp, &s)) + goto out; + if (!strcmp(d->d_name, ".")) + continue; + if (!strcmp(d->d_name, "..")) + continue; + if (s.st_mode & S_IFDIR) + ls(tmp, flags); + } +out: + closedir(dir); + + return 0; +} + +static int do_ls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + int ret, opt; + ulong flags = 0; + + getopt_reset(); + + while((opt = getopt(argc, argv, "R")) > 0) { + switch(opt) { + case 'R': + flags |= LS_RECURSIVE | LS_SHOWARG; + break; + } + } + + if (argc - optind > 1) + flags |= LS_SHOWARG; + + if (optind == argc) { + ret = ls(getcwd(), flags); + return ret ? 1 : 0; + } + + while (optind < argc) { + ret = ls(argv[optind], flags); + if (ret) { + perror("ls"); + return 1; + } + optind++; + } + + return 0; +} + +static __maybe_unused char cmd_ls_help[] = +"Usage: ls [OPTION]... [FILE]...\n" +"List information about the FILEs (the current directory by default).\n" +" -R list subdirectories recursively\n"; + +U_BOOT_CMD_START(ls) + .maxargs = CONFIG_MAXARGS, + .cmd = do_ls, + .usage = "list a file or directory", + U_BOOT_CMD_HELP(cmd_ls_help) +U_BOOT_CMD_END diff --git a/commands/mem.c b/commands/mem.c index d7cd7fb96d..e0f83608d3 100644 --- a/commands/mem.c +++ b/commands/mem.c @@ -427,60 +427,6 @@ U_BOOT_CMD( ); #endif -int do_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ - int r, w, ret = 1; - int src, dst; - - src = open(argv[1], O_RDONLY); - if (src < 0) { - perror("open"); - return 1; - } - - dst = open(argv[2], O_WRONLY | O_CREAT); - if ( dst < 0) { - perror("open"); - close(src); - return 1; - } - - while(1) { - r = read(src, rw_buf, RW_BUF_SIZE); - if (read < 0) { - perror("read"); - goto out; - } - if (!r) - break; - w = write(dst, rw_buf, r); - if (w < 0) { - perror("write"); - goto out; - } - } - ret = 0; -out: - close(src); - close(dst); - return ret; -} - -static __maybe_unused char cmd_cp_help[] = -"Usage: cp \n" -"cp copies file to .\n" -"Currently only this form is supported and you have to specify the exact target\n" -"filename (not a target directory).\n" -"Note: This command was previously used as memory copy. Currently there is no\n" -"equivalent command for this. This must be fixed of course.\n"; - -U_BOOT_CMD_START(cp) - .maxargs = CONFIG_MAXARGS, - .cmd = do_cp, - .usage = "copy files", - U_BOOT_CMD_HELP(cmd_cp_help) -U_BOOT_CMD_END - #ifndef CONFIG_CRC32_VERIFY int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) @@ -566,55 +512,6 @@ int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } #endif /* CONFIG_CRC32_VERIFY */ -static void memcpy_sz(void *_dst, const void *_src, ulong count, ulong rwsize) -{ - ulong dst = (ulong)_dst; - ulong src = (ulong)_src; - - /* no rwsize specification given. Do whatever memcpy likes best */ - if (!rwsize) { - memcpy(_dst, _src, count); - return; - } - - rwsize = rwsize >> O_RWSIZE_SHIFT; - - count /= rwsize; - - while (count-- > 0) { - switch (rwsize) { - case 1: - *((u_char *)dst) = *((u_char *)src); - break; - case 2: - *((ushort *)dst) = *((ushort *)src); - break; - case 4: - *((ulong *)dst) = *((ulong *)src); - break; - } - dst += rwsize; - src += rwsize; - } -} - -ssize_t mem_read(struct device_d *dev, void *buf, size_t count, ulong offset, ulong flags) -{ - ulong size; - size = min(count, dev->size - offset); - printf("mem_read: dev->map_base: %p size: %d offset: %d\n",dev->map_base, size, offset); - memcpy_sz(buf, (void *)(dev->map_base + offset), size, flags & O_RWSIZE_MASK); - return size; -} - -ssize_t mem_write(struct device_d *dev, const void *buf, size_t count, ulong offset, ulong flags) -{ - ulong size; - size = min(count, dev->size - offset); - memcpy_sz((void *)(dev->map_base + offset), buf, size, flags & O_RWSIZE_MASK); - return size; -} - static struct device_d mem_dev = { .name = "mem", .id = "mem", diff --git a/commands/mkdir.c b/commands/mkdir.c new file mode 100644 index 0000000000..3be742a942 --- /dev/null +++ b/commands/mkdir.c @@ -0,0 +1,35 @@ +#include +#include +#include +#include + +static int do_mkdir (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + int i = 1; + + if (argc < 2) { + u_boot_cmd_usage(cmdtp); + return 1; + } + + while (i < argc) { + if (mkdir(argv[i])) { + printf("could not create %s: %s\n", argv[i], errno_str()); + return 1; + } + i++; + } + + return 0; +} + +static __maybe_unused char cmd_mkdir_help[] = +"Usage: mkdir [directories]\n" +"Create new directories\n"; + +U_BOOT_CMD_START(mkdir) + .maxargs = CONFIG_MAXARGS, + .cmd = do_mkdir, + .usage = "make directories", + U_BOOT_CMD_HELP(cmd_mkdir_help) +U_BOOT_CMD_END diff --git a/commands/mount.c b/commands/mount.c new file mode 100644 index 0000000000..e4c567357b --- /dev/null +++ b/commands/mount.c @@ -0,0 +1,53 @@ +#include +#include +#include +#include + +static int do_mount (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + int ret = 0; + struct mtab_entry *entry = NULL; + + if (argc == 1) { + do { + entry = mtab_next_entry(entry); + if (entry) { + printf("%s on %s type %s\n", + entry->parent_device ? entry->parent_device->id : "none", + entry->path, + entry->dev->name); + } + } while (entry); + return 0; + } + + if (argc != 4) { + u_boot_cmd_usage(cmdtp); + return 1; + } + + if ((ret = mount(argv[1], argv[2], argv[3]))) { + perror("mount"); + return 1; + } + return 0; +} + +static __maybe_unused char cmd_mount_help[] = +"Usage: mount: list mounted filesystems\n" +"or: mount \n" +"\n" +"Mount a filesystem of a given type to a mountpoint.\n" +" can be one of /dev/* or some arbitrary string if no\n" +"device is needed for this driver (for example ramfs).\n" +" is the filesystem driver to use. Try the 'devinfo' command\n" +"for a list of available drivers.\n" +" must be an empty directory descending directly from the\n" +"root directory.\n"; + +U_BOOT_CMD_START(mount) + .maxargs = 4, + .cmd = do_mount, + .usage = "mount a filesystem to a device", + U_BOOT_CMD_HELP(cmd_mount_help) +U_BOOT_CMD_END diff --git a/commands/pwd.c b/commands/pwd.c new file mode 100644 index 0000000000..a0aa4b70f6 --- /dev/null +++ b/commands/pwd.c @@ -0,0 +1,15 @@ +#include +#include +#include + +static int do_pwd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + printf("%s\n", getcwd()); + return 0; +} + +U_BOOT_CMD_START(pwd) + .maxargs = 2, + .cmd = do_pwd, + .usage = "print working directory", +U_BOOT_CMD_END diff --git a/commands/reginfo.c b/commands/reginfo.c new file mode 100644 index 0000000000..856beaed9f --- /dev/null +++ b/commands/reginfo.c @@ -0,0 +1,14 @@ +#include +#include + +int do_reginfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + reginfo(); + return 0; +} + +U_BOOT_CMD_START(reginfo) + .maxargs = 1, + .cmd = do_reginfo, + .usage = "print register information", +U_BOOT_CMD_END diff --git a/commands/rm.c b/commands/rm.c new file mode 100644 index 0000000000..7199580485 --- /dev/null +++ b/commands/rm.c @@ -0,0 +1,30 @@ +static int do_rm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + int i = 1; + + if (argc < 2) { + u_boot_cmd_usage(cmdtp); + return 1; + } + + while (i < argc) { + if (unlink(argv[i])) { + printf("could not remove %s: %s\n", argv[i], errno_str()); + return 1; + } + i++; + } + + return 0; +} + +static __maybe_unused char cmd_rm_help[] = +"Usage: rm [FILES]\n" +"Remove files\n"; + +U_BOOT_CMD_START(rm) + .maxargs = CONFIG_MAXARGS, + .cmd = do_rm, + .usage = "remove files", + U_BOOT_CMD_HELP(cmd_rm_help) +U_BOOT_CMD_END diff --git a/commands/rmdir.c b/commands/rmdir.c new file mode 100644 index 0000000000..cad0862d86 --- /dev/null +++ b/commands/rmdir.c @@ -0,0 +1,35 @@ +#include +#include +#include +#include + +static int do_rmdir (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + int i = 1; + + if (argc < 2) { + u_boot_cmd_usage(cmdtp); + return 1; + } + + while (i < argc) { + if (rmdir(argv[i])) { + printf("could not remove %s: %s\n", argv[i], errno_str()); + return 1; + } + i++; + } + + return 0; +} + +static __maybe_unused char cmd_rmdir_help[] = +"Usage: rmdir [directories]\n" +"Remove directories. The directories have to be empty.\n"; + +U_BOOT_CMD_START(rmdir) + .maxargs = CONFIG_MAXARGS, + .cmd = do_rmdir, + .usage = "remove directorie(s)", + U_BOOT_CMD_HELP(cmd_rmdir_help) +U_BOOT_CMD_END diff --git a/commands/umount.c b/commands/umount.c new file mode 100644 index 0000000000..8f4a4b445e --- /dev/null +++ b/commands/umount.c @@ -0,0 +1,31 @@ +#include +#include +#include +#include + +static int do_umount (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + int ret = 0; + + if (argc != 2) { + u_boot_cmd_usage(cmdtp); + return 1; + } + + if ((ret = umount(argv[1]))) { + perror("umount"); + return 1; + } + return 0; +} + +static __maybe_unused char cmd_umount_help[] = +"Usage: umount \n" +"umount a filesystem mounted on a specific mountpoint\n"; + +U_BOOT_CMD_START(umount) + .maxargs = 2, + .cmd = do_umount, + .usage = "umount a filesystem", + U_BOOT_CMD_HELP(cmd_umount_help) +U_BOOT_CMD_END diff --git a/common/Kconfig b/common/Kconfig index be6b31d5c3..124dd88f07 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -56,10 +56,14 @@ config PROMPT_HUSH_PS2 prompt "hush PS2" default "> " -config ZERO_BOOTDELAY_CHECK +config DYNAMIC_CRC_TABLE bool - prompt "Enable stop boot process with bootdelay = 0" + depends on CRC32 + prompt "Generate the crc32 table dynamically" default y + help + Saying yes to this option saves around 800 bytes of binary size. + If unsure say yes. config ERRNO_MESSAGES bool diff --git a/common/Makefile b/common/Makefile index 3167589123..2d46c1f484 100644 --- a/common/Makefile +++ b/common/Makefile @@ -6,7 +6,6 @@ obj-$(CONFIG_OF_FLAT_TREE) += ft_build.o obj-y += main.o obj-y += dlmalloc.o obj-y += clock.o -# obj-y += flash.o obj-y += command.o obj-y += console.o obj-y += partition.o diff --git a/common/cmd_ext2.c b/common/cmd_ext2.c deleted file mode 100644 index 5db42f2b0d..0000000000 --- a/common/cmd_ext2.c +++ /dev/null @@ -1,297 +0,0 @@ -/* - * (C) Copyright 2004 - * esd gmbh - * Reinhard Arlt - * - * made from cmd_reiserfs by - * - * (C) Copyright 2003 - 2004 - * Sysgo Real-Time Solutions, AG - * Pavel Bartusek - * - * 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 - * - */ - -/* - * Ext2fs support - */ -#include - -#if (CONFIG_COMMANDS & CFG_CMD_EXT2) -#include -#include -#include -#include -#include -#include -#if ((CONFIG_COMMANDS & CFG_CMD_USB) && defined(CONFIG_USB_STORAGE)) -#include -#endif - -#ifndef CONFIG_DOS_PARTITION -#error DOS partition support must be selected -#endif - -/* #define EXT2_DEBUG */ - -#ifdef EXT2_DEBUG -#define PRINTF(fmt,args...) printf (fmt ,##args) -#else -#define PRINTF(fmt,args...) -#endif - -static block_dev_desc_t *get_dev (char* ifname, int dev) -{ -#if (CONFIG_COMMANDS & CFG_CMD_IDE) - if (strncmp(ifname,"ide",3)==0) { - extern block_dev_desc_t * ide_get_dev(int dev); - return((dev >= CFG_IDE_MAXDEVICE) ? NULL : ide_get_dev(dev)); - } -#endif -#if (CONFIG_COMMANDS & CFG_CMD_SCSI) - if (strncmp(ifname,"scsi",4)==0) { - extern block_dev_desc_t * scsi_get_dev(int dev); - return((dev >= CFG_SCSI_MAXDEVICE) ? NULL : scsi_get_dev(dev)); - } -#endif -#if ((CONFIG_COMMANDS & CFG_CMD_USB) && defined(CONFIG_USB_STORAGE)) - if (strncmp(ifname,"usb",3)==0) { - extern block_dev_desc_t * usb_stor_get_dev(int dev); - return((dev >= USB_MAX_STOR_DEV) ? NULL : usb_stor_get_dev(dev)); - } -#endif -#if defined(CONFIG_MMC) - if (strncmp(ifname,"mmc",3)==0) { - extern block_dev_desc_t * mmc_get_dev(int dev); - return((dev >= 1) ? NULL : mmc_get_dev(dev)); - } -#endif -#if defined(CONFIG_SYSTEMACE) - if (strcmp(ifname,"ace")==0) { - extern block_dev_desc_t * systemace_get_dev(int dev); - return((dev >= 1) ? NULL : systemace_get_dev(dev)); - } -#endif - return(NULL); -} - -int do_ext2ls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ - char *filename = "/"; - int dev=0; - int part=1; - char *ep; - block_dev_desc_t *dev_desc=NULL; - int part_length; - - if (argc < 3) { - printf ("Usage:\n%s\n", cmdtp->usage); - return(1); - } - dev = (int)simple_strtoul (argv[2], &ep, 16); - dev_desc=get_dev(argv[1],dev); - - if (dev_desc == NULL) { - printf ("\n** Block device %s %d not supported\n", argv[1], dev); - return(1); - } - - if (*ep) { - if (*ep != ':') { - puts ("\n** Invalid boot device, use `dev[:part]' **\n"); - return(1); - } - part = (int)simple_strtoul(++ep, NULL, 16); - } - - if (argc == 4) { - filename = argv[3]; - } - - PRINTF("Using device %s %d:%d, directory: %s\n", argv[1], dev, part, filename); - - if ((part_length = ext2fs_set_blk_dev(dev_desc, part)) == 0) { - printf ("** Bad partition - %s %d:%d **\n", argv[1], dev, part); - ext2fs_close(); - return(1); - } - - if (!ext2fs_mount(part_length)) { - printf ("** Bad ext2 partition or disk - %s %d:%d **\n", argv[1], dev, part); - ext2fs_close(); - return(1); - } - - if (ext2fs_ls (filename)) { - printf ("** Error ext2fs_ls() **\n"); - ext2fs_close(); - return(1); - }; - - ext2fs_close(); - - return(0); -} - -U_BOOT_CMD( - ext2ls, 4, 1, do_ext2ls, - "ext2ls - list files in a directory (default /)\n", - " [directory]\n" - " - list files from 'dev' on 'interface' in a 'directory'\n" -); - -/****************************************************************************** - * Ext2fs boot command intepreter. Derived from diskboot - */ -int do_ext2load (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ - char *filename = NULL; - char *ep; - int dev, part = 1; - ulong addr = 0, part_length, filelen; - disk_partition_t info; - block_dev_desc_t *dev_desc = NULL; - char buf [12]; - unsigned long count; - char *addr_str; - - switch (argc) { - case 3: - addr_str = getenv("loadaddr"); - if (addr_str != NULL) { - addr = simple_strtoul (addr_str, NULL, 16); - } else { - addr = CFG_LOAD_ADDR; - } - filename = getenv ("bootfile"); - count = 0; - break; - case 4: - addr = simple_strtoul (argv[3], NULL, 16); - filename = getenv ("bootfile"); - count = 0; - break; - case 5: - addr = simple_strtoul (argv[3], NULL, 16); - filename = argv[4]; - count = 0; - break; - case 6: - addr = simple_strtoul (argv[3], NULL, 16); - filename = argv[4]; - count = simple_strtoul (argv[5], NULL, 16); - break; - - default: - printf ("Usage:\n%s\n", cmdtp->usage); - return(1); - } - - if (!filename) { - puts ("\n** No boot file defined **\n"); - return(1); - } - - dev = (int)simple_strtoul (argv[2], &ep, 16); - dev_desc=get_dev(argv[1],dev); - if (dev_desc==NULL) { - printf ("\n** Block device %s %d not supported\n", argv[1], dev); - return(1); - } - if (*ep) { - if (*ep != ':') { - puts ("\n** Invalid boot device, use `dev[:part]' **\n"); - return(1); - } - part = (int)simple_strtoul(++ep, NULL, 16); - } - - PRINTF("Using device %s%d, partition %d\n", argv[1], dev, part); - - if (part != 0) { - if (get_partition_info (dev_desc, part, &info)) { - printf ("** Bad partition %d **\n", part); - return(1); - } - - if (strncmp((char *)info.type, BOOT_PART_TYPE, sizeof(info.type)) != 0) { - printf ("\n** Invalid partition type \"%.32s\"" - " (expect \"" BOOT_PART_TYPE "\")\n", - info.type); - return(1); - } - PRINTF ("\nLoading from block device %s device %d, partition %d: " - "Name: %.32s Type: %.32s File:%s\n", - argv[1], dev, part, info.name, info.type, filename); - } else { - PRINTF ("\nLoading from block device %s device %d, File:%s\n", - argv[1], dev, filename); - } - - - if ((part_length = ext2fs_set_blk_dev(dev_desc, part)) == 0) { - printf ("** Bad partition - %s %d:%d **\n", argv[1], dev, part); - ext2fs_close(); - return(1); - } - - if (!ext2fs_mount(part_length)) { - printf ("** Bad ext2 partition or disk - %s %d:%d **\n", argv[1], dev, part); - ext2fs_close(); - return(1); - } - - filelen = ext2fs_open(filename); - if (filelen < 0) { - printf("** File not found %s\n", filename); - ext2fs_close(); - return(1); - } - if ((count < filelen) && (count != 0)) { - filelen = count; - } - - if (ext2fs_read((char *)addr, filelen) != filelen) { - printf("\n** Unable to read \"%s\" from %s %d:%d **\n", filename, argv[1], dev, part); - ext2fs_close(); - return(1); - } - - ext2fs_close(); - - /* Loading ok, update default load address */ - load_addr = addr; - - printf ("\n%ld bytes read\n", filelen); - sprintf(buf, "%lX", filelen); - setenv("filesize", buf); - - return(filelen); -} - -U_BOOT_CMD( - ext2load, 6, 0, do_ext2load, - "ext2load- load binary file from a Ext2 filesystem\n", - " [addr] [filename] [bytes]\n" - " - load binary file 'filename' from 'dev' on 'interface'\n" - " to address 'addr' from ext2 filesystem\n" -); - -#endif /* CONFIG_COMMANDS & CFG_CMD_EXT2 */ diff --git a/common/cmd_fat.c b/common/cmd_fat.c deleted file mode 100644 index 6844c103f2..0000000000 --- a/common/cmd_fat.c +++ /dev/null @@ -1,362 +0,0 @@ -/* - * (C) Copyright 2002 - * Richard Jones, rjones@nexus-tech.net - * - * 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 - */ - -/* - * Boot support - */ -#include -#include -#include -#include -#include - -#if (CONFIG_COMMANDS & CFG_CMD_FAT) - -#undef DEBUG - -#include - - -block_dev_desc_t *get_dev (char* ifname, int dev) -{ -#if (CONFIG_COMMANDS & CFG_CMD_IDE) - if (strncmp(ifname,"ide",3)==0) { - extern block_dev_desc_t * ide_get_dev(int dev); - return(ide_get_dev(dev)); - } -#endif -#if (CONFIG_COMMANDS & CFG_CMD_SCSI) - if (strncmp(ifname,"scsi",4)==0) { - extern block_dev_desc_t * scsi_get_dev(int dev); - return(scsi_get_dev(dev)); - } -#endif -#if ((CONFIG_COMMANDS & CFG_CMD_USB) && defined(CONFIG_USB_STORAGE)) - if (strncmp(ifname,"usb",3)==0) { - extern block_dev_desc_t * usb_stor_get_dev(int dev); - return(usb_stor_get_dev(dev)); - } -#endif -#if defined(CONFIG_MMC) - if (strncmp(ifname,"mmc",3)==0) { - extern block_dev_desc_t * mmc_get_dev(int dev); - return(mmc_get_dev(dev)); - } -#endif -#if defined(CONFIG_SYSTEMACE) - if (strcmp(ifname,"ace")==0) { - extern block_dev_desc_t * systemace_get_dev(int dev); - return(systemace_get_dev(dev)); - } -#endif - return NULL; -} - - -int do_fat_fsload (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ - long size; - unsigned long offset; - unsigned long count; - char buf [12]; - block_dev_desc_t *dev_desc=NULL; - int dev=0; - int part=1; - char *ep; - - if (argc < 5) { - printf ("usage: fatload [bytes]\n"); - return 1; - } - dev = (int)simple_strtoul (argv[2], &ep, 16); - dev_desc=get_dev(argv[1],dev); - if (dev_desc==NULL) { - puts ("\n** Invalid boot device **\n"); - return 1; - } - if (*ep) { - if (*ep != ':') { - puts ("\n** Invalid boot device, use `dev[:part]' **\n"); - return 1; - } - part = (int)simple_strtoul(++ep, NULL, 16); - } - if (fat_register_device(dev_desc,part)!=0) { - printf ("\n** Unable to use %s %d:%d for fatload **\n",argv[1],dev,part); - return 1; - } - offset = simple_strtoul (argv[3], NULL, 16); - if (argc == 6) - count = simple_strtoul (argv[5], NULL, 16); - else - count = 0; - size = file_fat_read (argv[4], (unsigned char *) offset, count); - - if(size==-1) { - printf("\n** Unable to read \"%s\" from %s %d:%d **\n",argv[4],argv[1],dev,part); - return 1; - } - - printf ("\n%ld bytes read\n", size); - - sprintf(buf, "%lX", size); - setenv("filesize", buf); - - return 0; -} - - -U_BOOT_CMD( - fatload, 6, 0, do_fat_fsload, - "fatload - load binary file from a dos filesystem\n", - " [bytes]\n" - " - load binary file 'filename' from 'dev' on 'interface'\n" - " to address 'addr' from dos filesystem\n" -); - -int do_fat_ls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ - char *filename = "/"; - int ret; - int dev=0; - int part=1; - char *ep; - block_dev_desc_t *dev_desc=NULL; - - if (argc < 3) { - printf ("usage: fatls [directory]\n"); - return (0); - } - dev = (int)simple_strtoul (argv[2], &ep, 16); - dev_desc=get_dev(argv[1],dev); - if (dev_desc==NULL) { - puts ("\n** Invalid boot device **\n"); - return 1; - } - if (*ep) { - if (*ep != ':') { - puts ("\n** Invalid boot device, use `dev[:part]' **\n"); - return 1; - } - part = (int)simple_strtoul(++ep, NULL, 16); - } - if (fat_register_device(dev_desc,part)!=0) { - printf ("\n** Unable to use %s %d:%d for fatls **\n",argv[1],dev,part); - return 1; - } - if (argc == 4) - ret = file_fat_ls (argv[3]); - else - ret = file_fat_ls (filename); - - if(ret!=0) - printf("No Fat FS detected\n"); - return (ret); -} - -U_BOOT_CMD( - fatls, 4, 1, do_fat_ls, - "fatls - list files in a directory (default /)\n", - " [directory]\n" - " - list files from 'dev' on 'interface' in a 'directory'\n" -); - -int do_fat_fsinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ - int dev=0; - int part=1; - char *ep; - block_dev_desc_t *dev_desc=NULL; - - if (argc < 2) { - printf ("usage: fatinfo \n"); - return (0); - } - dev = (int)simple_strtoul (argv[2], &ep, 16); - dev_desc=get_dev(argv[1],dev); - if (dev_desc==NULL) { - puts ("\n** Invalid boot device **\n"); - return 1; - } - if (*ep) { - if (*ep != ':') { - puts ("\n** Invalid boot device, use `dev[:part]' **\n"); - return 1; - } - part = (int)simple_strtoul(++ep, NULL, 16); - } - if (fat_register_device(dev_desc,part)!=0) { - printf ("\n** Unable to use %s %d:%d for fatinfo **\n",argv[1],dev,part); - return 1; - } - return (file_fat_detectfs ()); -} - -U_BOOT_CMD( - fatinfo, 3, 1, do_fat_fsinfo, - "fatinfo - print information about filesystem\n", - " \n" - " - print information about filesystem from 'dev' on 'interface'\n" -); - -#ifdef NOT_IMPLEMENTED_YET -/* find first device whose first partition is a DOS filesystem */ -int find_fat_partition (void) -{ - int i, j; - block_dev_desc_t *dev_desc; - unsigned char *part_table; - unsigned char buffer[ATA_BLOCKSIZE]; - - for (i = 0; i < CFG_IDE_MAXDEVICE; i++) { - dev_desc = ide_get_dev (i); - if (!dev_desc) { - debug ("couldn't get ide device!\n"); - return (-1); - } - if (dev_desc->part_type == PART_TYPE_DOS) { - if (dev_desc-> - block_read (dev_desc->dev, 0, 1, (ulong *) buffer) != 1) { - debug ("can't perform block_read!\n"); - return (-1); - } - part_table = &buffer[0x1be]; /* start with partition #4 */ - for (j = 0; j < 4; j++) { - if ((part_table[4] == 1 || /* 12-bit FAT */ - part_table[4] == 4 || /* 16-bit FAT */ - part_table[4] == 6) && /* > 32Meg part */ - part_table[0] == 0x80) { /* bootable? */ - curr_dev = i; - part_offset = part_table[11]; - part_offset <<= 8; - part_offset |= part_table[10]; - part_offset <<= 8; - part_offset |= part_table[9]; - part_offset <<= 8; - part_offset |= part_table[8]; - debug ("found partition start at %ld\n", part_offset); - return (0); - } - part_table += 16; - } - } - } - - debug ("no valid devices found!\n"); - return (-1); -} - -int -do_fat_dump (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) -{ - __u8 block[1024]; - int ret; - int bknum; - - ret = 0; - - if (argc != 2) { - printf ("needs an argument!\n"); - return (0); - } - - bknum = simple_strtoul (argv[1], NULL, 10); - - if (disk_read (0, bknum, block) != 0) { - printf ("Error: reading block\n"); - return -1; - } - printf ("FAT dump: %d\n", bknum); - hexdump (512, block); - - return (ret); -} - -int disk_read (__u32 startblock, __u32 getsize, __u8 *bufptr) -{ - ulong tot; - block_dev_desc_t *dev_desc; - - if (curr_dev < 0) { - if (find_fat_partition () != 0) - return (-1); - } - - dev_desc = ide_get_dev (curr_dev); - if (!dev_desc) { - debug ("couldn't get ide device\n"); - return (-1); - } - - tot = dev_desc->block_read (0, startblock + part_offset, - getsize, (ulong *) bufptr); - - /* should we do this here? - flush_cache ((ulong)buf, cnt*ide_dev_desc[device].blksz); - */ - - if (tot == getsize) - return (0); - - debug ("unable to read from device!\n"); - - return (-1); -} - - -static int isprint (unsigned char ch) -{ - if (ch >= 32 && ch < 127) - return (1); - - return (0); -} - - -void hexdump (int cnt, unsigned char *data) -{ - int i; - int run; - int offset; - - offset = 0; - while (cnt) { - printf ("%04X : ", offset); - if (cnt >= 16) - run = 16; - else - run = cnt; - cnt -= run; - for (i = 0; i < run; i++) - printf ("%02X ", (unsigned int) data[i]); - printf (": "); - for (i = 0; i < run; i++) - printf ("%c", isprint (data[i]) ? data[i] : '.'); - printf ("\n"); - data = &data[16]; - offset += run; - } -} -#endif /* NOT_IMPLEMENTED_YET */ - -#endif /* CFG_CMD_FAT */ diff --git a/common/cmd_flash.c b/common/cmd_flash.c deleted file mode 100644 index db059dba58..0000000000 --- a/common/cmd_flash.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * (C) Copyright 2000 - * 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 - */ - -/* - * FLASH support - */ -#include -#include -#include -#include -#include -#include -#include -#include - -int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ - int opt, fd; - char *filename = NULL; - struct stat s; - unsigned long start = 0, size = ~0; - - getopt_reset(); - - while((opt = getopt(argc, argv, "f:")) > 0) { - switch(opt) { - case 'f': - filename = optarg; - break; - } - } - - if (stat(filename, &s)) { - printf("stat %s:", filename, errno_str()); - return 1; - } - - size = s.st_size; - - if (!filename) { - printf("missing filename\n"); - return 1; - } - - fd = open(filename, O_WRONLY); - if (fd < 0) { - printf("open %s:", filename, errno_str()); - return 1; - } - - if (optind < argc) - parse_area_spec(argv[optind], &start, &size); - - if(erase(fd, size, start)) { - perror("erase"); - return 1; - } - - close(fd); - - return 0; -} - -U_BOOT_CMD_START(erase) - .maxargs = CONFIG_MAXARGS, - .cmd = do_flerase, - .usage = "erase FLASH memory", - U_BOOT_CMD_HELP("write me\n") -U_BOOT_CMD_END - -int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ - int p; - int rcode = 0; - struct memarea_info mem_info; - - if (argc < 3) { - printf ("Usage:\n%s\n", cmdtp->usage); - return 1; - } - - if (strcmp(argv[1], "off") == 0) { - p = 0; - } else if (strcmp(argv[1], "on") == 0) { - p = 1; - } else { - printf ("Usage:\n%s\n", cmdtp->usage); - return 1; - } - - if (spec_str_to_info(argv[2], &mem_info)) { - printf ("-EPARSE\n"); - return 1; - } - -// rcode = flash_sect_protect (p, addr_first, addr_last); - return rcode; -} - -U_BOOT_CMD_START(protect) - .maxargs = 4, - .cmd = do_protect, - .usage = "enable or disable FLASH write protection", - U_BOOT_CMD_HELP("write me\n") -U_BOOT_CMD_END diff --git a/common/cmd_jffs2.c b/common/cmd_jffs2.c deleted file mode 100644 index 7fd1fa33da..0000000000 --- a/common/cmd_jffs2.c +++ /dev/null @@ -1,2195 +0,0 @@ -/* - * (C) Copyright 2002 - * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - * - * (C) Copyright 2002 - * Robert Schwebel, Pengutronix, - * - * (C) Copyright 2003 - * Kai-Uwe Bloem, Auerswald GmbH & Co KG, - * - * (C) Copyright 2005 - * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - * - * Added support for reading flash partition table from environment. - * Parsing routines are based on driver/mtd/cmdline.c from the linux 2.4 - * kernel tree. - * - * $Id: cmdlinepart.c,v 1.17 2004/11/26 11:18:47 lavinen Exp $ - * Copyright 2002 SYSGO Real-Time Solutions GmbH - * - * 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 - */ - -/* - * Three environment variables are used by the parsing routines: - * - * 'partition' - keeps current partition identifier - * - * partition := - * := ,part_num - * - * - * 'mtdids' - linux kernel mtd device id <-> u-boot device id mapping - * - * mtdids=[,,...] - * - * := = - * := 'nand'|'nor' - * := mtd device number, 0... - * := unique device tag used by linux kernel to find mtd device (mtd->name) - * - * - * 'mtdparts' - partition list - * - * mtdparts=mtdparts=[;...] - * - * := :[,...] - * := unique device tag used by linux kernel to find mtd device (mtd->name) - * := [@][][] - * := standard linux memsize OR '-' to denote all remaining space - * := partition start offset within the device - * := '(' NAME ')' - * := when set to 'ro' makes partition read-only (not used, passed to kernel) - * - * Notes: - * - each used in mtdparts must albo exist in 'mtddis' mapping - * - if the above variables are not set defaults for a given target are used - * - * Examples: - * - * 1 NOR Flash, with 1 single writable partition: - * mtdids=nor0=edb7312-nor - * mtdparts=mtdparts=edb7312-nor:- - * - * 1 NOR Flash with 2 partitions, 1 NAND with one - * mtdids=nor0=edb7312-nor,nand0=edb7312-nand - * mtdparts=mtdparts=edb7312-nor:256k(ARMboot)ro,-(root);edb7312-nand:-(home) - * - */ - -/* - * JFFS2/CRAMFS support - */ -#include -#include -#include -#include -#include -#include - -#if (CONFIG_COMMANDS & CFG_CMD_JFFS2) - -#include - -#if (CONFIG_COMMANDS & CFG_CMD_NAND) -#ifdef CFG_NAND_LEGACY -#include -#else /* !CFG_NAND_LEGACY */ -#include -#include -#endif /* !CFG_NAND_LEGACY */ -#endif /* (CONFIG_COMMANDS & CFG_CMD_NAND) */ -/* enable/disable debugging messages */ -#define DEBUG_JFFS -#undef DEBUG_JFFS - -#ifdef DEBUG_JFFS -# define DEBUGF(fmt, args...) printf(fmt ,##args) -#else -# define DEBUGF(fmt, args...) -#endif - -/* special size referring to all the remaining space in a partition */ -#define SIZE_REMAINING 0xFFFFFFFF - -/* special offset value, it is used when not provided by user - * - * this value is used temporarily during parsing, later such offests - * are recalculated */ -#define OFFSET_NOT_SPECIFIED 0xFFFFFFFF - -/* minimum partition size */ -#define MIN_PART_SIZE 4096 - -/* this flag needs to be set in part_info struct mask_flags - * field for read-only partitions */ -#define MTD_WRITEABLE_CMD 1 - -#ifdef CONFIG_JFFS2_CMDLINE -/* default values for mtdids and mtdparts variables */ -#if defined(MTDIDS_DEFAULT) -static const char *const mtdids_default = MTDIDS_DEFAULT; -#else -#warning "MTDIDS_DEFAULT not defined!" -static const char *const mtdids_default = NULL; -#endif - -#if defined(MTDPARTS_DEFAULT) -static const char *const mtdparts_default = MTDPARTS_DEFAULT; -#else -#warning "MTDPARTS_DEFAULT not defined!" -static const char *const mtdparts_default = NULL; -#endif - -/* copies of last seen 'mtdids', 'mtdparts' and 'partition' env variables */ -#define MTDIDS_MAXLEN 128 -#define MTDPARTS_MAXLEN 512 -#define PARTITION_MAXLEN 16 -static char last_ids[MTDIDS_MAXLEN]; -static char last_parts[MTDPARTS_MAXLEN]; -static char last_partition[PARTITION_MAXLEN]; - -/* low level jffs2 cache cleaning routine */ -extern void jffs2_free_cache(struct part_info *part); - -/* mtdids mapping list, filled by parse_ids() */ -struct list_head mtdids; - -/* device/partition list, parse_cmdline() parses into here */ -struct list_head devices; -#endif /* #ifdef CONFIG_JFFS2_CMDLINE */ - -/* current active device and partition number */ -static struct mtd_device *current_dev = NULL; -static u8 current_partnum = 0; - -extern int cramfs_check (struct part_info *info); -extern int cramfs_load (char *loadoffset, struct part_info *info, char *filename); -extern int cramfs_ls (struct part_info *info, char *filename); -extern int cramfs_info (struct part_info *info); - -static struct part_info* jffs2_part_info(struct mtd_device *dev, unsigned int part_num); - -/* command line only routines */ -#ifdef CONFIG_JFFS2_CMDLINE - -static struct mtdids* id_find_by_mtd_id(const char *mtd_id, unsigned int mtd_id_len); -static int device_del(struct mtd_device *dev); - -/** - * Parses a string into a number. The number stored at ptr is - * potentially suffixed with K (for kilobytes, or 1024 bytes), - * M (for megabytes, or 1048576 bytes), or G (for gigabytes, or - * 1073741824). If the number is suffixed with K, M, or G, then - * the return value is the number multiplied by one kilobyte, one - * megabyte, or one gigabyte, respectively. - * - * @param ptr where parse begins - * @param retptr output pointer to next char after parse completes (output) - * @return resulting unsigned int - */ -static unsigned long memsize_parse (const char *const ptr, const char **retptr) -{ - unsigned long ret = simple_strtoul(ptr, (char **)retptr, 0); - - switch (**retptr) { - case 'G': - case 'g': - ret <<= 10; - case 'M': - case 'm': - ret <<= 10; - case 'K': - case 'k': - ret <<= 10; - (*retptr)++; - default: - break; - } - - return ret; -} - -/** - * Format string describing supplied size. This routine does the opposite job - * to memsize_parse(). Size in bytes is converted to string and if possible - * shortened by using k (kilobytes), m (megabytes) or g (gigabytes) suffix. - * - * Note, that this routine does not check for buffer overflow, it's the caller - * who must assure enough space. - * - * @param buf output buffer - * @param size size to be converted to string - */ -static void memsize_format(char *buf, u32 size) -{ -#define SIZE_GB ((u32)1024*1024*1024) -#define SIZE_MB ((u32)1024*1024) -#define SIZE_KB ((u32)1024) - - if ((size % SIZE_GB) == 0) - sprintf(buf, "%lug", size/SIZE_GB); - else if ((size % SIZE_MB) == 0) - sprintf(buf, "%lum", size/SIZE_MB); - else if (size % SIZE_KB == 0) - sprintf(buf, "%luk", size/SIZE_KB); - else - sprintf(buf, "%lu", size); -} - -/** - * This routine does global indexing of all partitions. Resulting index for - * current partition is saved in 'mtddevnum'. Current partition name in - * 'mtddevname'. - */ -static void index_partitions(void) -{ - char buf[16]; - u16 mtddevnum; - struct part_info *part; - struct list_head *dentry; - struct mtd_device *dev; - - DEBUGF("--- index partitions ---\n"); - - if (current_dev) { - mtddevnum = 0; - list_for_each(dentry, &devices) { - dev = list_entry(dentry, struct mtd_device, link); - if (dev == current_dev) { - mtddevnum += current_partnum; - sprintf(buf, "%d", mtddevnum); - setenv("mtddevnum", buf); - break; - } - mtddevnum += dev->num_parts; - } - - part = jffs2_part_info(current_dev, current_partnum); - setenv("mtddevname", part->name); - - DEBUGF("=> mtddevnum %d,\n=> mtddevname %s\n", mtddevnum, part->name); - } else { - setenv("mtddevnum", NULL); - setenv("mtddevname", NULL); - - DEBUGF("=> mtddevnum NULL\n=> mtddevname NULL\n"); - } -} - -/** - * Save current device and partition in environment variable 'partition'. - */ -static void current_save(void) -{ - char buf[16]; - - DEBUGF("--- current_save ---\n"); - - if (current_dev) { - sprintf(buf, "%s%d,%d", MTD_DEV_TYPE(current_dev->id->type), - current_dev->id->num, current_partnum); - - setenv("partition", buf); - strncpy(last_partition, buf, 16); - - DEBUGF("=> partition %s\n", buf); - } else { - setenv("partition", NULL); - last_partition[0] = '\0'; - - DEBUGF("=> partition NULL\n"); - } - index_partitions(); -} - -/** - * Performs sanity check for supplied NOR flash partition. Table of existing - * NOR flash devices is searched and partition device is located. Alignment - * with the granularity of NOR flash sectors is verified. - * - * @param id of the parent device - * @param part partition to validate - * @return 0 if partition is valid, 1 otherwise - */ -static int part_validate_nor(struct mtdids *id, struct part_info *part) -{ -#if (CONFIG_COMMANDS & CFG_CMD_FLASH) - /* info for FLASH chips */ - extern flash_info_t flash_info[]; - flash_info_t *flash; - int offset_aligned; - u32 end_offset; - int i; - - flash = &flash_info[id->num]; - - offset_aligned = 0; - for (i = 0; i < flash->sector_count; i++) { - if ((flash->start[i] - flash->start[0]) == part->offset) { - offset_aligned = 1; - break; - } - } - if (offset_aligned == 0) { - printf("%s%d: partition (%s) start offset alignment incorrect\n", - MTD_DEV_TYPE(id->type), id->num, part->name); - return 1; - } - - end_offset = part->offset + part->size; - for (i = 0; i < flash->sector_count; i++) { - if ((flash->start[i] - flash->start[0]) == end_offset) - return 0; - } - - if (flash->size == end_offset) - return 0; - - printf("%s%d: partition (%s) size alignment incorrect\n", - MTD_DEV_TYPE(id->type), id->num, part->name); -#endif - return 1; -} - -/** - * Performs sanity check for supplied NAND flash partition. Table of existing - * NAND flash devices is searched and partition device is located. Alignment - * with the granularity of nand erasesize is verified. - * - * @param id of the parent device - * @param part partition to validate - * @return 0 if partition is valid, 1 otherwise - */ -static int part_validate_nand(struct mtdids *id, struct part_info *part) -{ -#if defined(CONFIG_JFFS2_NAND) && (CONFIG_COMMANDS & CFG_CMD_NAND) - /* info for NAND chips */ - nand_info_t *nand; - - nand = &nand_info[id->num]; - - if ((unsigned long)(part->offset) % nand->erasesize) { - printf("%s%d: partition (%s) start offset alignment incorrect\n", - MTD_DEV_TYPE(id->type), id->num, part->name); - return 1; - } - - if (part->size % nand->erasesize) { - printf("%s%d: partition (%s) size alignment incorrect\n", - MTD_DEV_TYPE(id->type), id->num, part->name); - return 1; - } - - return 0; -#else - return 1; -#endif -} - -/** - * Performs sanity check for supplied partition. Offset and size are verified - * to be within valid range. Partition type is checked and either - * parts_validate_nor() or parts_validate_nand() is called with the argument - * of part. - * - * @param id of the parent device - * @param part partition to validate - * @return 0 if partition is valid, 1 otherwise - */ -static int part_validate(struct mtdids *id, struct part_info *part) -{ - if (part->size == SIZE_REMAINING) - part->size = id->size - part->offset; - - if (part->offset > id->size) { - printf("%s: offset %08lx beyond flash size %08lx\n", - id->mtd_id, part->offset, id->size); - return 1; - } - - if ((part->offset + part->size) <= part->offset) { - printf("%s%d: partition (%s) size too big\n", - MTD_DEV_TYPE(id->type), id->num, part->name); - return 1; - } - - if (part->offset + part->size > id->size) { - printf("%s: partitioning exceeds flash size\n", id->mtd_id); - return 1; - } - - if (id->type == MTD_DEV_TYPE_NAND) - return part_validate_nand(id, part); - else if (id->type == MTD_DEV_TYPE_NOR) - return part_validate_nor(id, part); - else - DEBUGF("part_validate: invalid dev type\n"); - - return 1; -} - -/** - * Delete selected partition from the partion list of the specified device. - * - * @param dev device to delete partition from - * @param part partition to delete - * @return 0 on success, 1 otherwise - */ -static int part_del(struct mtd_device *dev, struct part_info *part) -{ - u8 current_save_needed = 0; - - /* if there is only one partition, remove whole device */ - if (dev->num_parts == 1) - return device_del(dev); - - /* otherwise just delete this partition */ - - if (dev == current_dev) { - /* we are modyfing partitions for the current device, - * update current */ - struct part_info *curr_pi; - curr_pi = jffs2_part_info(current_dev, current_partnum); - - if (curr_pi) { - if (curr_pi == part) { - printf("current partition deleted, resetting current to 0\n"); - current_partnum = 0; - } else if (part->offset <= curr_pi->offset) { - current_partnum--; - } - current_save_needed = 1; - } - } - -#ifdef CFG_NAND_LEGACY - jffs2_free_cache(part); -#endif - list_del(&part->link); - free(part); - dev->num_parts--; - - if (current_save_needed > 0) - current_save(); - else - index_partitions(); - - return 0; -} - -/** - * Delete all partitions from parts head list, free memory. - * - * @param head list of partitions to delete - */ -static void part_delall(struct list_head *head) -{ - struct list_head *entry, *n; - struct part_info *part_tmp; - - /* clean tmp_list and free allocated memory */ - list_for_each_safe(entry, n, head) { - part_tmp = list_entry(entry, struct part_info, link); - -#ifdef CFG_NAND_LEGACY - jffs2_free_cache(part_tmp); -#endif - list_del(entry); - free(part_tmp); - } -} - -/** - * Add new partition to the supplied partition list. Make sure partitions are - * sorted by offset in ascending order. - * - * @param head list this partition is to be added to - * @param new partition to be added - */ -static int part_sort_add(struct mtd_device *dev, struct part_info *part) -{ - struct list_head *entry; - struct part_info *new_pi, *curr_pi; - - /* link partition to parrent dev */ - part->dev = dev; - - if (list_empty(&dev->parts)) { - DEBUGF("part_sort_add: list empty\n"); - list_add(&part->link, &dev->parts); - dev->num_parts++; - index_partitions(); - return 0; - } - - new_pi = list_entry(&part->link, struct part_info, link); - - /* get current partition info if we are updating current device */ - curr_pi = NULL; - if (dev == current_dev) - curr_pi = jffs2_part_info(current_dev, current_partnum); - - list_for_each(entry, &dev->parts) { - struct part_info *pi; - - pi = list_entry(entry, struct part_info, link); - - /* be compliant with kernel cmdline, allow only one partition at offset zero */ - if ((new_pi->offset == pi->offset) && (pi->offset == 0)) { - printf("cannot add second partition at offset 0\n"); - return 1; - } - - if (new_pi->offset <= pi->offset) { - list_add_tail(&part->link, entry); - dev->num_parts++; - - if (curr_pi && (pi->offset <= curr_pi->offset)) { - /* we are modyfing partitions for the current - * device, update current */ - current_partnum++; - current_save(); - } else { - index_partitions(); - } - return 0; - } - } - - list_add_tail(&part->link, &dev->parts); - dev->num_parts++; - index_partitions(); - return 0; -} - -/** - * Add provided partition to the partition list of a given device. - * - * @param dev device to which partition is added - * @param part partition to be added - * @return 0 on success, 1 otherwise - */ -static int part_add(struct mtd_device *dev, struct part_info *part) -{ - /* verify alignment and size */ - if (part_validate(dev->id, part) != 0) - return 1; - - /* partition is ok, add it to the list */ - if (part_sort_add(dev, part) != 0) - return 1; - - return 0; -} - -/** - * Parse one partition definition, allocate memory and return pointer to this - * location in retpart. - * - * @param partdef pointer to the partition definition string i.e. - * @param ret output pointer to next char after parse completes (output) - * @param retpart pointer to the allocated partition (output) - * @return 0 on success, 1 otherwise - */ -static int part_parse(const char *const partdef, const char **ret, struct part_info **retpart) -{ - struct part_info *part; - unsigned long size; - unsigned long offset; - const char *name; - int name_len; - unsigned int mask_flags; - const char *p; - - p = partdef; - *retpart = NULL; - *ret = NULL; - - /* fetch the partition size */ - if (*p == '-') { - /* assign all remaining space to this partition */ - DEBUGF("'-': remaining size assigned\n"); - size = SIZE_REMAINING; - p++; - } else { - size = memsize_parse(p, &p); - if (size < MIN_PART_SIZE) { - printf("partition size too small (%lx)\n", size); - return 1; - } - } - - /* check for offset */ - offset = OFFSET_NOT_SPECIFIED; - if (*p == '@') { - p++; - offset = memsize_parse(p, &p); - } - - /* now look for the name */ - if (*p == '(') { - name = ++p; - if ((p = strchr(name, ')')) == NULL) { - printf("no closing ) found in partition name\n"); - return 1; - } - name_len = p - name + 1; - if ((name_len - 1) == 0) { - printf("empty partition name\n"); - return 1; - } - p++; - } else { - /* 0x00000000@0x00000000 */ - name_len = 22; - name = NULL; - } - - /* test for options */ - mask_flags = 0; - if (strncmp(p, "ro", 2) == 0) { - mask_flags |= MTD_WRITEABLE_CMD; - p += 2; - } - - /* check for next partition definition */ - if (*p == ',') { - if (size == SIZE_REMAINING) { - *ret = NULL; - printf("no partitions allowed after a fill-up partition\n"); - return 1; - } - *ret = ++p; - } else if ((*p == ';') || (*p == '\0')) { - *ret = p; - } else { - printf("unexpected character '%c' at the end of partition\n", *p); - *ret = NULL; - return 1; - } - - /* allocate memory */ - part = (struct part_info *)malloc(sizeof(struct part_info) + name_len); - if (!part) { - printf("out of memory\n"); - return 1; - } - memset(part, 0, sizeof(struct part_info) + name_len); - part->size = size; - part->offset = offset; - part->mask_flags = mask_flags; - part->name = (char *)(part + 1); - - if (name) { - /* copy user provided name */ - strncpy(part->name, name, name_len - 1); - part->auto_name = 0; - } else { - /* auto generated name in form of size@offset */ - sprintf(part->name, "0x%08lx@0x%08lx", size, offset); - part->auto_name = 1; - } - - part->name[name_len - 1] = '\0'; - INIT_LIST_HEAD(&part->link); - - DEBUGF("+ partition: name %-22s size 0x%08x offset 0x%08x mask flags %d\n", - part->name, part->size, - part->offset, part->mask_flags); - - *retpart = part; - return 0; -} -#endif/* #ifdef CONFIG_JFFS2_CMDLINE */ - -/** - * Check device number to be within valid range for given device type. - * - * @param dev device to validate - * @return 0 if device is valid, 1 otherwise - */ -static int device_validate(u8 type, u8 num, u32 *size) -{ - if (type == MTD_DEV_TYPE_NOR) { -#if (CONFIG_COMMANDS & CFG_CMD_FLASH) - if (num < CFG_MAX_FLASH_BANKS) { - extern flash_info_t flash_info[]; - *size = flash_info[num].size; - - return 0; - } - - printf("no such FLASH device: %s%d (valid range 0 ... %d\n", - MTD_DEV_TYPE(type), num, CFG_MAX_FLASH_BANKS - 1); -#else - printf("support for FLASH devices not present\n"); -#endif - } else if (type == MTD_DEV_TYPE_NAND) { -#if defined(CONFIG_JFFS2_NAND) && (CONFIG_COMMANDS & CFG_CMD_NAND) - if (num < CFG_MAX_NAND_DEVICE) { -#ifndef CFG_NAND_LEGACY - *size = nand_info[num].size; -#else - extern struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE]; - *size = nand_dev_desc[num].totlen; -#endif - return 0; - } - - printf("no such NAND device: %s%d (valid range 0 ... %d)\n", - MTD_DEV_TYPE(type), num, CFG_MAX_NAND_DEVICE - 1); -#else - printf("support for NAND devices not present\n"); -#endif - } - - return 1; -} - -#ifdef CONFIG_JFFS2_CMDLINE -/** - * Delete all mtd devices from a supplied devices list, free memory allocated for - * each device and delete all device partitions. - * - * @return 0 on success, 1 otherwise - */ -static int device_delall(struct list_head *head) -{ - struct list_head *entry, *n; - struct mtd_device *dev_tmp; - - /* clean devices list */ - list_for_each_safe(entry, n, head) { - dev_tmp = list_entry(entry, struct mtd_device, link); - list_del(entry); - part_delall(&dev_tmp->parts); - free(dev_tmp); - } - INIT_LIST_HEAD(&devices); - - return 0; -} - -/** - * If provided device exists it's partitions are deleted, device is removed - * from device list and device memory is freed. - * - * @param dev device to be deleted - * @return 0 on success, 1 otherwise - */ -static int device_del(struct mtd_device *dev) -{ - part_delall(&dev->parts); - list_del(&dev->link); - free(dev); - - if (dev == current_dev) { - /* we just deleted current device */ - if (list_empty(&devices)) { - current_dev = NULL; - } else { - /* reset first partition from first dev from the - * devices list as current */ - current_dev = list_entry(devices.next, struct mtd_device, link); - current_partnum = 0; - } - current_save(); - return 0; - } - - index_partitions(); - return 0; -} - -/** - * Search global device list and return pointer to the device of type and num - * specified. - * - * @param type device type - * @param num device number - * @return NULL if requested device does not exist - */ -static struct mtd_device* device_find(u8 type, u8 num) -{ - struct list_head *entry; - struct mtd_device *dev_tmp; - - list_for_each(entry, &devices) { - dev_tmp = list_entry(entry, struct mtd_device, link); - - if ((dev_tmp->id->type == type) && (dev_tmp->id->num == num)) - return dev_tmp; - } - - return NULL; -} - -/** - * Add specified device to the global device list. - * - * @param dev device to be added - */ -static void device_add(struct mtd_device *dev) -{ - u8 current_save_needed = 0; - - if (list_empty(&devices)) { - current_dev = dev; - current_partnum = 0; - current_save_needed = 1; - } - - list_add_tail(&dev->link, &devices); - - if (current_save_needed > 0) - current_save(); - else - index_partitions(); -} - -/** - * Parse device type, name and mtd-id. If syntax is ok allocate memory and - * return pointer to the device structure. - * - * @param mtd_dev pointer to the device definition string i.e. - * @param ret output pointer to next char after parse completes (output) - * @param retdev pointer to the allocated device (output) - * @return 0 on success, 1 otherwise - */ -static int device_parse(const char *const mtd_dev, const char **ret, struct mtd_device **retdev) -{ - struct mtd_device *dev; - struct part_info *part; - struct mtdids *id; - const char *mtd_id; - unsigned int mtd_id_len; - const char *p, *pend; - LIST_HEAD(tmp_list); - struct list_head *entry, *n; - u16 num_parts; - u32 offset; - int err = 1; - - p = mtd_dev; - *retdev = NULL; - *ret = NULL; - - DEBUGF("===device_parse===\n"); - - /* fetch */ - mtd_id = p; - if (!(p = strchr(mtd_id, ':'))) { - printf("no identifier\n"); - return 1; - } - mtd_id_len = p - mtd_id + 1; - p++; - - /* verify if we have a valid device specified */ - if ((id = id_find_by_mtd_id(mtd_id, mtd_id_len - 1)) == NULL) { - printf("invalid mtd device '%.*s'\n", mtd_id_len - 1, mtd_id); - return 1; - } - - DEBUGF("dev type = %d (%s), dev num = %d, mtd-id = %s\n", - id->type, MTD_DEV_TYPE(id->type), - id->num, id->mtd_id); - pend = strchr(p, ';'); - DEBUGF("parsing partitions %.*s\n", (pend ? pend - p : strlen(p)), p); - - - /* parse partitions */ - num_parts = 0; - - offset = 0; - if ((dev = device_find(id->type, id->num)) != NULL) { - /* if device already exists start at the end of the last partition */ - part = list_entry(dev->parts.prev, struct part_info, link); - offset = part->offset + part->size; - } - - while (p && (*p != '\0') && (*p != ';')) { - err = 1; - if ((part_parse(p, &p, &part) != 0) || (!part)) - break; - - /* calculate offset when not specified */ - if (part->offset == OFFSET_NOT_SPECIFIED) - part->offset = offset; - else - offset = part->offset; - - /* verify alignment and size */ - if (part_validate(id, part) != 0) - break; - - offset += part->size; - - /* partition is ok, add it to the list */ - list_add_tail(&part->link, &tmp_list); - num_parts++; - err = 0; - } - if (err == 1) { - part_delall(&tmp_list); - return 1; - } - - if (num_parts == 0) { - printf("no partitions for device %s%d (%s)\n", - MTD_DEV_TYPE(id->type), id->num, id->mtd_id); - return 1; - } - - DEBUGF("\ntotal partitions: %d\n", num_parts); - - /* check for next device presence */ - if (p) { - if (*p == ';') { - *ret = ++p; - } else if (*p == '\0') { - *ret = p; - } else { - printf("unexpected character '%c' at the end of device\n", *p); - *ret = NULL; - return 1; - } - } - - /* allocate memory for mtd_device structure */ - if ((dev = (struct mtd_device *)malloc(sizeof(struct mtd_device))) == NULL) { - printf("out of memory\n"); - return 1; - } - memset(dev, 0, sizeof(struct mtd_device)); - dev->id = id; - dev->num_parts = 0; /* part_sort_add increments num_parts */ - INIT_LIST_HEAD(&dev->parts); - INIT_LIST_HEAD(&dev->link); - - /* move partitions from tmp_list to dev->parts */ - list_for_each_safe(entry, n, &tmp_list) { - part = list_entry(entry, struct part_info, link); - list_del(entry); - if (part_sort_add(dev, part) != 0) { - device_del(dev); - return 1; - } - } - - *retdev = dev; - - DEBUGF("===\n\n"); - return 0; -} - -/** - * Initialize global device list. - * - * @return 0 on success, 1 otherwise - */ -static int devices_init(void) -{ - last_parts[0] = '\0'; - current_dev = NULL; - current_save(); - - return device_delall(&devices); -} - -/* - * Search global mtdids list and find id of requested type and number. - * - * @return pointer to the id if it exists, NULL otherwise - */ -static struct mtdids* id_find(u8 type, u8 num) -{ - struct list_head *entry; - struct mtdids *id; - - list_for_each(entry, &mtdids) { - id = list_entry(entry, struct mtdids, link); - - if ((id->type == type) && (id->num == num)) - return id; - } - - return NULL; -} - -/** - * Search global mtdids list and find id of a requested mtd_id. - * - * Note: first argument is not null terminated. - * - * @param mtd_id string containing requested mtd_id - * @param mtd_id_len length of supplied mtd_id - * @return pointer to the id if it exists, NULL otherwise - */ -static struct mtdids* id_find_by_mtd_id(const char *mtd_id, unsigned int mtd_id_len) -{ - struct list_head *entry; - struct mtdids *id; - - DEBUGF("--- id_find_by_mtd_id: '%.*s' (len = %d)\n", - mtd_id_len, mtd_id, mtd_id_len); - - list_for_each(entry, &mtdids) { - id = list_entry(entry, struct mtdids, link); - - DEBUGF("entry: '%s' (len = %d)\n", - id->mtd_id, strlen(id->mtd_id)); - - if (mtd_id_len != strlen(id->mtd_id)) - continue; - if (strncmp(id->mtd_id, mtd_id, mtd_id_len) == 0) - return id; - } - - return NULL; -} -#endif /* #ifdef CONFIG_JFFS2_CMDLINE */ - -/** - * Parse device id string := 'nand'|'nor', return device - * type and number. - * - * @param id string describing device id - * @param ret_id output pointer to next char after parse completes (output) - * @param dev_type parsed device type (output) - * @param dev_num parsed device number (output) - * @return 0 on success, 1 otherwise - */ -int id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *dev_num) -{ - const char *p = id; - - *dev_type = 0; - if (strncmp(p, "nand", 4) == 0) { - *dev_type = MTD_DEV_TYPE_NAND; - p += 4; - } else if (strncmp(p, "nor", 3) == 0) { - *dev_type = MTD_DEV_TYPE_NOR; - p += 3; - } else { - printf("incorrect device type in %s\n", id); - return 1; - } - - if (!isdigit(*p)) { - printf("incorrect device number in %s\n", id); - return 1; - } - - *dev_num = simple_strtoul(p, (char **)&p, 0); - if (ret_id) - *ret_id = p; - return 0; -} - -#ifdef CONFIG_JFFS2_CMDLINE -/** - * Process all devices and generate corresponding mtdparts string describing - * all partitions on all devices. - * - * @param buf output buffer holding generated mtdparts string (output) - * @param buflen buffer size - * @return 0 on success, 1 otherwise - */ -static int generate_mtdparts(char *buf, u32 buflen) -{ - struct list_head *pentry, *dentry; - struct mtd_device *dev; - struct part_info *part, *prev_part; - char *p = buf; - char tmpbuf[32]; - u32 size, offset, len, part_cnt; - u32 maxlen = buflen - 1; - - DEBUGF("--- generate_mtdparts ---\n"); - - if (list_empty(&devices)) { - buf[0] = '\0'; - return 0; - } - - sprintf(p, "mtdparts="); - p += 9; - - list_for_each(dentry, &devices) { - dev = list_entry(dentry, struct mtd_device, link); - - /* copy mtd_id */ - len = strlen(dev->id->mtd_id) + 1; - if (len > maxlen) - goto cleanup; - memcpy(p, dev->id->mtd_id, len - 1); - p += len - 1; - *(p++) = ':'; - maxlen -= len; - - /* format partitions */ - prev_part = NULL; - part_cnt = 0; - list_for_each(pentry, &dev->parts) { - part = list_entry(pentry, struct part_info, link); - size = part->size; - offset = part->offset; - part_cnt++; - - /* partition size */ - memsize_format(tmpbuf, size); - len = strlen(tmpbuf); - if (len > maxlen) - goto cleanup; - memcpy(p, tmpbuf, len); - p += len; - maxlen -= len; - - - /* add offset only when there is a gap between - * partitions */ - if ((!prev_part && (offset != 0)) || - (prev_part && ((prev_part->offset + prev_part->size) != part->offset))) { - - memsize_format(tmpbuf, offset); - len = strlen(tmpbuf) + 1; - if (len > maxlen) - goto cleanup; - *(p++) = '@'; - memcpy(p, tmpbuf, len - 1); - p += len - 1; - maxlen -= len; - } - - /* copy name only if user supplied */ - if(!part->auto_name) { - len = strlen(part->name) + 2; - if (len > maxlen) - goto cleanup; - - *(p++) = '('; - memcpy(p, part->name, len - 2); - p += len - 2; - *(p++) = ')'; - maxlen -= len; - } - - /* ro mask flag */ - if (part->mask_flags && MTD_WRITEABLE_CMD) { - len = 2; - if (len > maxlen) - goto cleanup; - *(p++) = 'r'; - *(p++) = 'o'; - maxlen -= 2; - } - - /* print ',' separator if there are other partitions - * following */ - if (dev->num_parts > part_cnt) { - if (1 > maxlen) - goto cleanup; - *(p++) = ','; - maxlen--; - } - prev_part = part; - } - /* print ';' separator if there are other devices following */ - if (dentry->next != &devices) { - if (1 > maxlen) - goto cleanup; - *(p++) = ';'; - maxlen--; - } - } - - /* we still have at least one char left, as we decremented maxlen at - * the begining */ - *p = '\0'; - - return 0; - -cleanup: - last_parts[0] = '\0'; - return 1; -} - -/** - * Call generate_mtdparts to process all devices and generate corresponding - * mtdparts string, save it in mtdparts environment variable. - * - * @param buf output buffer holding generated mtdparts string (output) - * @param buflen buffer size - * @return 0 on success, 1 otherwise - */ -static int generate_mtdparts_save(char *buf, u32 buflen) -{ - int ret; - - ret = generate_mtdparts(buf, buflen); - - if ((buf[0] != '\0') && (ret == 0)) - setenv("mtdparts", buf); - else - setenv("mtdparts", NULL); - - return ret; -} - -/** - * Format and print out a partition list for each device from global device - * list. - */ -static void list_partitions(void) -{ - struct list_head *dentry, *pentry; - struct part_info *part; - struct mtd_device *dev; - int part_num; - - DEBUGF("\n---list_partitions---\n"); - list_for_each(dentry, &devices) { - dev = list_entry(dentry, struct mtd_device, link); - printf("\ndevice %s%d <%s>, # parts = %d\n", - MTD_DEV_TYPE(dev->id->type), dev->id->num, - dev->id->mtd_id, dev->num_parts); - printf(" #: name\t\t\tsize\t\toffset\t\tmask_flags\n"); - - /* list partitions for given device */ - part_num = 0; - list_for_each(pentry, &dev->parts) { - part = list_entry(pentry, struct part_info, link); - printf("%2d: %-20s0x%08x\t0x%08x\t%d\n", - part_num, part->name, part->size, - part->offset, part->mask_flags); - - part_num++; - } - } - if (list_empty(&devices)) - printf("no partitions defined\n"); - - /* current_dev is not NULL only when we have non empty device list */ - if (current_dev) { - part = jffs2_part_info(current_dev, current_partnum); - if (part) { - printf("\nactive partition: %s%d,%d - (%s) 0x%08lx @ 0x%08lx\n", - MTD_DEV_TYPE(current_dev->id->type), - current_dev->id->num, current_partnum, - part->name, part->size, part->offset); - } else { - printf("could not get current partition info\n\n"); - } - } - - printf("\ndefaults:\n"); - printf("mtdids : %s\n", mtdids_default); - printf("mtdparts: %s\n", mtdparts_default); -} - -/** - * Given partition identifier in form of , find - * corresponding device and verify partition number. - * - * @param id string describing device and partition or partition name - * @param dev pointer to the requested device (output) - * @param part_num verified partition number (output) - * @param part pointer to requested partition (output) - * @return 0 on success, 1 otherwise - */ -int find_dev_and_part(const char *id, struct mtd_device **dev, - u8 *part_num, struct part_info **part) -{ - struct list_head *dentry, *pentry; - u8 type, dnum, pnum; - const char *p; - - DEBUGF("--- find_dev_and_part ---\nid = %s\n", id); - - list_for_each(dentry, &devices) { - *part_num = 0; - *dev = list_entry(dentry, struct mtd_device, link); - list_for_each(pentry, &(*dev)->parts) { - *part = list_entry(pentry, struct part_info, link); - if (strcmp((*part)->name, id) == 0) - return 0; - (*part_num)++; - } - } - - p = id; - *dev = NULL; - *part = NULL; - *part_num = 0; - - if (id_parse(p, &p, &type, &dnum) != 0) - return 1; - - if ((*p++ != ',') || (*p == '\0')) { - printf("no partition number specified\n"); - return 1; - } - pnum = simple_strtoul(p, (char **)&p, 0); - if (*p != '\0') { - printf("unexpected trailing character '%c'\n", *p); - return 1; - } - - if ((*dev = device_find(type, dnum)) == NULL) { - printf("no such device %s%d\n", MTD_DEV_TYPE(type), dnum); - return 1; - } - - if ((*part = jffs2_part_info(*dev, pnum)) == NULL) { - printf("no such partition\n"); - *dev = NULL; - return 1; - } - - *part_num = pnum; - - return 0; -} - -/** - * Find and delete partition. For partition id format see find_dev_and_part(). - * - * @param id string describing device and partition - * @return 0 on success, 1 otherwise - */ -static int delete_partition(const char *id) -{ - u8 pnum; - struct mtd_device *dev; - struct part_info *part; - - if (find_dev_and_part(id, &dev, &pnum, &part) == 0) { - - DEBUGF("delete_partition: device = %s%d, partition %d = (%s) 0x%08lx@0x%08lx\n", - MTD_DEV_TYPE(dev->id->type), dev->id->num, pnum, - part->name, part->size, part->offset); - - if (part_del(dev, part) != 0) - return 1; - - if (generate_mtdparts_save(last_parts, MTDPARTS_MAXLEN) != 0) { - printf("generated mtdparts too long, reseting to null\n"); - return 1; - } - return 0; - } - - printf("partition %s not found\n", id); - return 1; -} - -/** - * Accept character string describing mtd partitions and call device_parse() - * for each entry. Add created devices to the global devices list. - * - * @param mtdparts string specifing mtd partitions - * @return 0 on success, 1 otherwise - */ -static int parse_mtdparts(const char *const mtdparts) -{ - const char *p = mtdparts; - struct mtd_device *dev; - int err = 1; - - DEBUGF("\n---parse_mtdparts---\nmtdparts = %s\n\n", p); - - /* delete all devices and partitions */ - if (devices_init() != 0) { - printf("could not initialise device list\n"); - return err; - } - - /* re-read 'mtdparts' variable, devices_init may be updating env */ - p = getenv("mtdparts"); - - if (strncmp(p, "mtdparts=", 9) != 0) { - printf("mtdparts variable doesn't start with 'mtdparts='\n"); - return err; - } - p += 9; - - while (p && (*p != '\0')) { - err = 1; - if ((device_parse(p, &p, &dev) != 0) || (!dev)) - break; - - DEBUGF("+ device: %s\t%d\t%s\n", MTD_DEV_TYPE(dev->id->type), - dev->id->num, dev->id->mtd_id); - - /* check if parsed device is already on the list */ - if (device_find(dev->id->type, dev->id->num) != NULL) { - printf("device %s%d redefined, please correct mtdparts variable\n", - MTD_DEV_TYPE(dev->id->type), dev->id->num); - break; - } - - list_add_tail(&dev->link, &devices); - err = 0; - } - if (err == 1) { - device_delall(&devices); - return 1; - } - - return 0; -} - -/** - * Parse provided string describing mtdids mapping (see file header for mtdids - * variable format). Allocate memory for each entry and add all found entries - * to the global mtdids list. - * - * @param ids mapping string - * @return 0 on success, 1 otherwise - */ -static int parse_mtdids(const char *const ids) -{ - const char *p = ids; - const char *mtd_id; - int mtd_id_len; - struct mtdids *id; - struct list_head *entry, *n; - struct mtdids *id_tmp; - u8 type, num; - u32 size; - int ret = 1; - - DEBUGF("\n---parse_mtdids---\nmtdids = %s\n\n", ids); - - /* clean global mtdids list */ - list_for_each_safe(entry, n, &mtdids) { - id_tmp = list_entry(entry, struct mtdids, link); - DEBUGF("mtdids del: %d %d\n", id_tmp->type, id_tmp->num); - list_del(entry); - free(id_tmp); - } - last_ids[0] = '\0'; - INIT_LIST_HEAD(&mtdids); - - while(p && (*p != '\0')) { - - ret = 1; - /* parse 'nor'|'nand' */ - if (id_parse(p, &p, &type, &num) != 0) - break; - - if (*p != '=') { - printf("mtdids: incorrect \n"); - break; - } - p++; - - /* check if requested device exists */ - if (device_validate(type, num, &size) != 0) - return 1; - - /* locate */ - mtd_id = p; - if ((p = strchr(mtd_id, ',')) != NULL) { - mtd_id_len = p - mtd_id + 1; - p++; - } else { - mtd_id_len = strlen(mtd_id) + 1; - } - if (mtd_id_len == 0) { - printf("mtdids: no identifier\n"); - break; - } - - /* check if this id is already on the list */ - int double_entry = 0; - list_for_each(entry, &mtdids) { - id_tmp = list_entry(entry, struct mtdids, link); - if ((id_tmp->type == type) && (id_tmp->num == num)) { - double_entry = 1; - break; - } - } - if (double_entry) { - printf("device id %s%d redefined, please correct mtdids variable\n", - MTD_DEV_TYPE(type), num); - break; - } - - /* allocate mtdids structure */ - if (!(id = (struct mtdids *)malloc(sizeof(struct mtdids) + mtd_id_len))) { - printf("out of memory\n"); - break; - } - memset(id, 0, sizeof(struct mtdids) + mtd_id_len); - id->num = num; - id->type = type; - id->size = size; - id->mtd_id = (char *)(id + 1); - strncpy(id->mtd_id, mtd_id, mtd_id_len - 1); - id->mtd_id[mtd_id_len - 1] = '\0'; - INIT_LIST_HEAD(&id->link); - - DEBUGF("+ id %s%d\t%16d bytes\t%s\n", - MTD_DEV_TYPE(id->type), id->num, - id->size, id->mtd_id); - - list_add_tail(&id->link, &mtdids); - ret = 0; - } - if (ret == 1) { - /* clean mtdids list and free allocated memory */ - list_for_each_safe(entry, n, &mtdids) { - id_tmp = list_entry(entry, struct mtdids, link); - list_del(entry); - free(id_tmp); - } - return 1; - } - - return 0; -} - -/** - * Parse and initialize global mtdids mapping and create global - * device/partition list. - * - * @return 0 on success, 1 otherwise - */ -int mtdparts_init(void) -{ - static int initialized = 0; - const char *ids, *parts; - const char *current_partition; - int ids_changed; - char tmp_ep[PARTITION_MAXLEN]; - - DEBUGF("\n---mtdparts_init---\n"); - if (!initialized) { - INIT_LIST_HEAD(&mtdids); - INIT_LIST_HEAD(&devices); - memset(last_ids, 0, MTDIDS_MAXLEN); - memset(last_parts, 0, MTDPARTS_MAXLEN); - memset(last_partition, 0, PARTITION_MAXLEN); - initialized = 1; - } - - /* get variables */ - ids = getenv("mtdids"); - parts = getenv("mtdparts"); - current_partition = getenv("partition"); - - /* save it for later parsing, cannot rely on current partition pointer - * as 'partition' variable may be updated during init */ - tmp_ep[0] = '\0'; - if (current_partition) - strncpy(tmp_ep, current_partition, PARTITION_MAXLEN); - - DEBUGF("last_ids : %s\n", last_ids); - DEBUGF("env_ids : %s\n", ids); - DEBUGF("last_parts: %s\n", last_parts); - DEBUGF("env_parts : %s\n\n", parts); - - DEBUGF("last_partition : %s\n", last_partition); - DEBUGF("env_partition : %s\n", current_partition); - - /* if mtdids varible is empty try to use defaults */ - if (!ids) { - if (mtdids_default) { - DEBUGF("mtdids variable not defined, using default\n"); - ids = mtdids_default; - setenv("mtdids", (char *)ids); - } else { - printf("mtdids not defined, no default present\n"); - return 1; - } - } - if (strlen(ids) > MTDIDS_MAXLEN - 1) { - printf("mtdids too long (> %d)\n", MTDIDS_MAXLEN); - return 1; - } - - /* do no try to use defaults when mtdparts variable is not defined, - * just check the length */ - if (!parts) - printf("mtdparts variable not set, see 'help mtdparts'\n"); - - if (parts && (strlen(parts) > MTDPARTS_MAXLEN - 1)) { - printf("mtdparts too long (> %d)\n", MTDPARTS_MAXLEN); - return 1; - } - - /* check if we have already parsed those mtdids */ - if ((last_ids[0] != '\0') && (strcmp(last_ids, ids) == 0)) { - ids_changed = 0; - } else { - ids_changed = 1; - - if (parse_mtdids(ids) != 0) { - devices_init(); - return 1; - } - - /* ok it's good, save new ids */ - strncpy(last_ids, ids, MTDIDS_MAXLEN); - } - - /* parse partitions if either mtdparts or mtdids were updated */ - if (parts && ((last_parts[0] == '\0') || ((strcmp(last_parts, parts) != 0)) || ids_changed)) { - if (parse_mtdparts(parts) != 0) - return 1; - - if (list_empty(&devices)) { - printf("mtdparts_init: no valid partitions\n"); - return 1; - } - - /* ok it's good, save new parts */ - strncpy(last_parts, parts, MTDPARTS_MAXLEN); - - /* reset first partition from first dev from the list as current */ - current_dev = list_entry(devices.next, struct mtd_device, link); - current_partnum = 0; - current_save(); - - DEBUGF("mtdparts_init: current_dev = %s%d, current_partnum = %d\n", - MTD_DEV_TYPE(current_dev->id->type), - current_dev->id->num, current_partnum); - } - - /* mtdparts variable was reset to NULL, delete all devices/partitions */ - if (!parts && (last_parts[0] != '\0')) - return devices_init(); - - /* do not process current partition if mtdparts variable is null */ - if (!parts) - return 0; - - /* is current partition set in environment? if so, use it */ - if ((tmp_ep[0] != '\0') && (strcmp(tmp_ep, last_partition) != 0)) { - struct part_info *p; - struct mtd_device *cdev; - u8 pnum; - - DEBUGF("--- getting current partition: %s\n", tmp_ep); - - if (find_dev_and_part(tmp_ep, &cdev, &pnum, &p) == 0) { - current_dev = cdev; - current_partnum = pnum; - current_save(); - } - } else if (getenv("partition") == NULL) { - DEBUGF("no partition variable set, setting...\n"); - current_save(); - } - - return 0; -} -#else /* #ifdef CONFIG_JFFS2_CMDLINE */ -/* - * 'Static' version of command line mtdparts_init() routine. Single partition on - * a single device configuration. - */ - -/** - * Parse and initialize global mtdids mapping and create global - * device/partition list. - * - * @return 0 on success, 1 otherwise - */ -int mtdparts_init(void) -{ - static int initialized = 0; - u32 size; - char *dev_name; - - DEBUGF("\n---mtdparts_init---\n"); - if (!initialized) { - struct mtdids *id; - struct part_info *part; - - initialized = 1; - current_dev = (struct mtd_device *) - malloc(sizeof(struct mtd_device) + - sizeof(struct part_info) + - sizeof(struct mtdids)); - if (!current_dev) { - printf("out of memory\n"); - return 1; - } - memset(current_dev, 0, sizeof(struct mtd_device) + - sizeof(struct part_info) + sizeof(struct mtdids)); - - id = (struct mtdids *)(current_dev + 1); - part = (struct part_info *)(id + 1); - - /* id */ - id->mtd_id = "single part"; - -#if defined(CONFIG_JFFS2_DEV) - dev_name = CONFIG_JFFS2_DEV; -#else - dev_name = "nor0"; -#endif - - if ((id_parse(dev_name, NULL, &id->type, &id->num) != 0) || - (device_validate(id->type, id->num, &size) != 0)) { - printf("incorrect device: %s%d\n", MTD_DEV_TYPE(id->type), id->num); - free(current_dev); - return 1; - } - id->size = size; - INIT_LIST_HEAD(&id->link); - - DEBUGF("dev id: type = %d, num = %d, size = 0x%08lx, mtd_id = %s\n", - id->type, id->num, id->size, id->mtd_id); - - /* partition */ - part->name = "static"; - part->auto_name = 0; - -#if defined(CONFIG_JFFS2_PART_SIZE) - part->size = CONFIG_JFFS2_PART_SIZE; -#else - part->size = SIZE_REMAINING; -#endif - -#if defined(CONFIG_JFFS2_PART_OFFSET) - part->offset = CONFIG_JFFS2_PART_OFFSET; -#else - part->offset = 0x00000000; -#endif - - part->dev = current_dev; - INIT_LIST_HEAD(&part->link); - - /* recalculate size if needed */ - if (part->size == SIZE_REMAINING) - part->size = id->size - part->offset; - - DEBUGF("part : name = %s, size = 0x%08lx, offset = 0x%08lx\n", - part->name, part->size, part->offset); - - /* device */ - current_dev->id = id; - INIT_LIST_HEAD(¤t_dev->link); - current_dev->num_parts = 1; - INIT_LIST_HEAD(¤t_dev->parts); - list_add(&part->link, ¤t_dev->parts); - } - - return 0; -} -#endif /* #ifdef CONFIG_JFFS2_CMDLINE */ - -/** - * Return pointer to the partition of a requested number from a requested - * device. - * - * @param dev device that is to be searched for a partition - * @param part_num requested partition number - * @return pointer to the part_info, NULL otherwise - */ -static struct part_info* jffs2_part_info(struct mtd_device *dev, unsigned int part_num) -{ - struct list_head *entry; - struct part_info *part; - int num; - - if (!dev) - return NULL; - - DEBUGF("\n--- jffs2_part_info: partition number %d for device %s%d (%s)\n", - part_num, MTD_DEV_TYPE(dev->id->type), - dev->id->num, dev->id->mtd_id); - - if (part_num >= dev->num_parts) { - printf("invalid partition number %d for device %s%d (%s)\n", - part_num, MTD_DEV_TYPE(dev->id->type), - dev->id->num, dev->id->mtd_id); - return NULL; - } - - /* locate partition number, return it */ - num = 0; - list_for_each(entry, &dev->parts) { - part = list_entry(entry, struct part_info, link); - - if (part_num == num++) { - return part; - } - } - - return NULL; -} - -/***************************************************/ -/* U-boot commands */ -/***************************************************/ - -/** - * Routine implementing fsload u-boot command. This routine tries to load - * a requested file from jffs2/cramfs filesystem on a current partition. - * - * @param cmdtp command internal data - * @param flag command flag - * @param argc number of arguments supplied to the command - * @param argv arguments list - * @return 0 on success, 1 otherwise - */ -int do_jffs2_fsload(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ - char *fsname; - char *filename; - int size; - struct part_info *part; - ulong offset = load_addr; - - /* pre-set Boot file name */ - if ((filename = getenv("bootfile")) == NULL) { - filename = "uImage"; - } - - if (argc == 2) { - filename = argv[1]; - } - if (argc == 3) { - offset = simple_strtoul(argv[1], NULL, 16); - load_addr = offset; - filename = argv[2]; - } - - /* make sure we are in sync with env variables */ - if (mtdparts_init() !=0) - return 1; - - if ((part = jffs2_part_info(current_dev, current_partnum))){ - - /* check partition type for cramfs */ - fsname = (cramfs_check(part) ? "CRAMFS" : "JFFS2"); - printf("### %s loading '%s' to 0x%lx\n", fsname, filename, offset); - - if (cramfs_check(part)) { - size = cramfs_load ((char *) offset, part, filename); - } else { - /* if this is not cramfs assume jffs2 */ - size = jffs2_1pass_load((char *)offset, part, filename); - } - - if (size > 0) { - char buf[10]; - printf("### %s load complete: %d bytes loaded to 0x%lx\n", - fsname, size, offset); - sprintf(buf, "%x", size); - setenv("filesize", buf); - } else { - printf("### %s LOAD ERROR<%x> for %s!\n", fsname, size, filename); - } - - return !(size > 0); - } - return 1; -} - -/** - * Routine implementing u-boot ls command which lists content of a given - * directory on a current partition. - * - * @param cmdtp command internal data - * @param flag command flag - * @param argc number of arguments supplied to the command - * @param argv arguments list - * @return 0 on success, 1 otherwise - */ -int do_jffs2_ls(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ - char *filename = "/"; - int ret; - struct part_info *part; - - if (argc == 2) - filename = argv[1]; - - /* make sure we are in sync with env variables */ - if (mtdparts_init() !=0) - return 1; - - if ((part = jffs2_part_info(current_dev, current_partnum))){ - - /* check partition type for cramfs */ - if (cramfs_check(part)) { - ret = cramfs_ls (part, filename); - } else { - /* if this is not cramfs assume jffs2 */ - ret = jffs2_1pass_ls(part, filename); - } - - return ret ? 0 : 1; - } - return 1; -} - -/** - * Routine implementing u-boot fsinfo command. This routine prints out - * miscellaneous filesystem informations/statistics. - * - * @param cmdtp command internal data - * @param flag command flag - * @param argc number of arguments supplied to the command - * @param argv arguments list - * @return 0 on success, 1 otherwise - */ -int do_jffs2_fsinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ - struct part_info *part; - char *fsname; - int ret; - - /* make sure we are in sync with env variables */ - if (mtdparts_init() !=0) - return 1; - - if ((part = jffs2_part_info(current_dev, current_partnum))){ - - /* check partition type for cramfs */ - fsname = (cramfs_check(part) ? "CRAMFS" : "JFFS2"); - printf("### filesystem type is %s\n", fsname); - - if (cramfs_check(part)) { - ret = cramfs_info (part); - } else { - /* if this is not cramfs assume jffs2 */ - ret = jffs2_1pass_info(part); - } - - return ret ? 0 : 1; - } - return 1; -} - -/* command line only */ -#ifdef CONFIG_JFFS2_CMDLINE -/** - * Routine implementing u-boot chpart command. Sets new current partition based - * on the user supplied partition id. For partition id format see find_dev_and_part(). - * - * @param cmdtp command internal data - * @param flag command flag - * @param argc number of arguments supplied to the command - * @param argv arguments list - * @return 0 on success, 1 otherwise - */ -int do_jffs2_chpart(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ -/* command line only */ - struct mtd_device *dev; - struct part_info *part; - u8 pnum; - - if (mtdparts_init() !=0) - return 1; - - if (argc < 2) { - printf("no partition id specified\n"); - return 1; - } - - if (find_dev_and_part(argv[1], &dev, &pnum, &part) != 0) - return 1; - - current_dev = dev; - current_partnum = pnum; - current_save(); - - printf("partition changed to %s%d,%d\n", - MTD_DEV_TYPE(dev->id->type), dev->id->num, pnum); - - return 0; -} - -/** - * Routine implementing u-boot mtdparts command. Initialize/update default global - * partition list and process user partition request (list, add, del). - * - * @param cmdtp command internal data - * @param flag command flag - * @param argc number of arguments supplied to the command - * @param argv arguments list - * @return 0 on success, 1 otherwise - */ -int do_jffs2_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ - if (argc == 2) { - if (strcmp(argv[1], "default") == 0) { - setenv("mtdids", (char *)mtdids_default); - setenv("mtdparts", (char *)mtdparts_default); - setenv("partition", NULL); - - mtdparts_init(); - return 0; - } else if (strcmp(argv[1], "delall") == 0) { - /* this may be the first run, initialize lists if needed */ - mtdparts_init(); - - setenv("mtdparts", NULL); - - /* devices_init() calls current_save() */ - return devices_init(); - } - } - - /* make sure we are in sync with env variables */ - if (mtdparts_init() != 0) - return 1; - - if (argc == 1) { - list_partitions(); - return 0; - } - - /* mtdparts add [@] [ro] */ - if (((argc == 5) || (argc == 6)) && (strcmp(argv[1], "add") == 0)) { -#define PART_ADD_DESC_MAXLEN 64 - char tmpbuf[PART_ADD_DESC_MAXLEN]; - u8 type, num, len; - struct mtd_device *dev; - struct mtd_device *dev_tmp; - struct mtdids *id; - struct part_info *p; - - if (id_parse(argv[2], NULL, &type, &num) != 0) - return 1; - - if ((id = id_find(type, num)) == NULL) { - printf("no such device %s defined in mtdids variable\n", argv[2]); - return 1; - } - - len = strlen(id->mtd_id) + 1; /* 'mtd_id:' */ - len += strlen(argv[3]); /* size@offset */ - len += strlen(argv[4]) + 2; /* '(' name ')' */ - if (argv[5] && (strlen(argv[5]) == 2)) - len += 2; /* 'ro' */ - - if (len >= PART_ADD_DESC_MAXLEN) { - printf("too long partition description\n"); - return 1; - } - sprintf(tmpbuf, "%s:%s(%s)%s", - id->mtd_id, argv[3], argv[4], argv[5] ? argv[5] : ""); - DEBUGF("add tmpbuf: %s\n", tmpbuf); - - if ((device_parse(tmpbuf, NULL, &dev) != 0) || (!dev)) - return 1; - - DEBUGF("+ %s\t%d\t%s\n", MTD_DEV_TYPE(dev->id->type), - dev->id->num, dev->id->mtd_id); - - if ((dev_tmp = device_find(dev->id->type, dev->id->num)) == NULL) { - device_add(dev); - } else { - /* merge new partition with existing ones*/ - p = list_entry(dev->parts.next, struct part_info, link); - if (part_add(dev_tmp, p) != 0) { - device_del(dev); - return 1; - } - } - - if (generate_mtdparts_save(last_parts, MTDPARTS_MAXLEN) != 0) { - printf("generated mtdparts too long, reseting to null\n"); - return 1; - } - - return 0; - } - - /* mtdparts del part-id */ - if ((argc == 3) && (strcmp(argv[1], "del") == 0)) { - DEBUGF("del: part-id = %s\n", argv[2]); - - return delete_partition(argv[2]); - } - - printf ("Usage:\n%s\n", cmdtp->usage); - return 1; -} -#endif /* #ifdef CONFIG_JFFS2_CMDLINE */ - -/***************************************************/ -U_BOOT_CMD( - fsload, 3, 0, do_jffs2_fsload, - "fsload\t- load binary file from a filesystem image\n", - "[ off ] [ filename ]\n" - " - load binary file from flash bank\n" - " with offset 'off'\n" -); -U_BOOT_CMD( - ls, 2, 1, do_jffs2_ls, - "ls\t- list files in a directory (default /)\n", - "[ directory ]\n" - " - list files in a directory.\n" -); - -U_BOOT_CMD( - fsinfo, 1, 1, do_jffs2_fsinfo, - "fsinfo\t- print information about filesystems\n", - " - print information about filesystems\n" -); - -#ifdef CONFIG_JFFS2_CMDLINE -U_BOOT_CMD( - chpart, 2, 0, do_jffs2_chpart, - "chpart\t- change active partition\n", - "part-id\n" - " - change active partition (e.g. part-id = nand0,1)\n" -); - -U_BOOT_CMD( - mtdparts, 6, 0, do_jffs2_mtdparts, - "mtdparts- define flash/nand partitions\n", - "\n" - " - list partition table\n" - "mtdparts delall\n" - " - delete all partitions\n" - "mtdparts del part-id\n" - " - delete partition (e.g. part-id = nand0,1)\n" - "mtdparts add [@] [] [ro]\n" - " - add partition\n" - "mtdparts default\n" - " - reset partition table to defaults\n\n" - "-----\n\n" - "this command uses three environment variables:\n\n" - "'partition' - keeps current partition identifier\n\n" - "partition := \n" - " := ,part_num\n\n" - "'mtdids' - linux kernel mtd device id <-> u-boot device id mapping\n\n" - "mtdids=[,,...]\n\n" - " := =\n" - " := 'nand'|'nor'\n" - " := mtd device number, 0...\n" - " := unique device tag used by linux kernel to find mtd device (mtd->name)\n\n" - "'mtdparts' - partition list\n\n" - "mtdparts=mtdparts=[;...]\n\n" - " := :[,...]\n" - " := unique device tag used by linux kernel to find mtd device (mtd->name)\n" - " := [@][][]\n" - " := standard linux memsize OR '-' to denote all remaining space\n" - " := partition start offset within the device\n" - " := '(' NAME ')'\n" - " := when set to 'ro' makes partition read-only (not used, passed to kernel)\n" -); -#endif /* #ifdef CONFIG_JFFS2_CMDLINE */ - -/***************************************************/ - -#endif /* CFG_CMD_JFFS2 */ diff --git a/common/cmd_misc.c b/common/cmd_misc.c deleted file mode 100644 index e73e614c74..0000000000 --- a/common/cmd_misc.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * (C) Copyright 2001 - * 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 - */ - -/* - * Misc functions - */ -#include -#include - -#ifdef CONFIG_CMD_SLEEP - -#endif - -#ifdef CONFIG_CMD_CLEAR -#endif - -#ifdef CONFIG_CMD_MEMINFO -#endif - -/* Implemented in $(CPU)/interrupts.c */ -#if (CONFIG_COMMANDS & CFG_CMD_IRQ) -int do_irqinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); - -U_BOOT_CMD_START(irqinfo) - .maxargs = 1, - .cmd = do_irqinfo, - .usage = "print information about IRQs", -U_BOOT_CMD_END -#endif /* CONFIG_COMMANDS & CFG_CMD_IRQ */ - diff --git a/common/cmd_reginfo.c b/common/cmd_reginfo.c deleted file mode 100644 index f428f7e9aa..0000000000 --- a/common/cmd_reginfo.c +++ /dev/null @@ -1,350 +0,0 @@ -/* - * (C) Copyright 2000 - * Subodh Nijsure, SkyStream Networks, snijsure@skystream.com - * - * 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 -#include -#if defined(CONFIG_8xx) -#include -#elif defined (CONFIG_405GP) || defined(CONFIG_405EP) -#include -#elif defined (CONFIG_5xx) -#include -#elif defined (CONFIG_MPC5200) -#include -#endif -#if (CONFIG_COMMANDS & CFG_CMD_REGINFO) - -int do_reginfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ -#if defined(CONFIG_8xx) - volatile immap_t *immap = (immap_t *)CFG_IMMR; - volatile memctl8xx_t *memctl = &immap->im_memctl; - volatile sysconf8xx_t *sysconf = &immap->im_siu_conf; - volatile sit8xx_t *timers = &immap->im_sit; - - /* Hopefully more PowerPC knowledgable people will add code to display - * other useful registers - */ - - printf ("\nSystem Configuration registers\n" - - "\tIMMR\t0x%08X\n", get_immr(0)); - - printf("\tSIUMCR\t0x%08X", sysconf->sc_siumcr); - printf("\tSYPCR\t0x%08X\n",sysconf->sc_sypcr); - - printf("\tSWT\t0x%08X", sysconf->sc_swt); - printf("\tSWSR\t0x%04X\n", sysconf->sc_swsr); - - printf("\tSIPEND\t0x%08X\tSIMASK\t0x%08X\n", - sysconf->sc_sipend, sysconf->sc_simask); - printf("\tSIEL\t0x%08X\tSIVEC\t0x%08X\n", - sysconf->sc_siel, sysconf->sc_sivec); - printf("\tTESR\t0x%08X\tSDCR\t0x%08X\n", - sysconf->sc_tesr, sysconf->sc_sdcr); - - printf ("Memory Controller Registers\n" - - "\tBR0\t0x%08X\tOR0\t0x%08X \n", memctl->memc_br0, memctl->memc_or0); - printf("\tBR1\t0x%08X\tOR1\t0x%08X \n", memctl->memc_br1, memctl->memc_or1); - printf("\tBR2\t0x%08X\tOR2\t0x%08X \n", memctl->memc_br2, memctl->memc_or2); - printf("\tBR3\t0x%08X\tOR3\t0x%08X \n", memctl->memc_br3, memctl->memc_or3); - printf("\tBR4\t0x%08X\tOR4\t0x%08X \n", memctl->memc_br4, memctl->memc_or4); - printf("\tBR5\t0x%08X\tOR5\t0x%08X \n", memctl->memc_br5, memctl->memc_or5); - printf("\tBR6\t0x%08X\tOR6\t0x%08X \n", memctl->memc_br6, memctl->memc_or6); - printf("\tBR7\t0x%08X\tOR7\t0x%08X \n", memctl->memc_br7, memctl->memc_or7); - printf ("\n" - "\tmamr\t0x%08X\tmbmr\t0x%08X \n", - memctl->memc_mamr, memctl->memc_mbmr ); - printf("\tmstat\t0x%08X\tmptpr\t0x%08X \n", - memctl->memc_mstat, memctl->memc_mptpr ); - printf("\tmdr\t0x%08X \n", memctl->memc_mdr); - - printf ("\nSystem Integration Timers\n" - "\tTBSCR\t0x%08X\tRTCSC\t0x%08X \n", - timers->sit_tbscr, timers->sit_rtcsc); - printf("\tPISCR\t0x%08X \n", timers->sit_piscr); - - /* - * May be some CPM info here? - */ - -#elif defined (CONFIG_405GP) - printf ("\n405GP registers; MSR=%08x\n",mfmsr()); - printf ("\nUniversal Interrupt Controller Regs\n" - "uicsr uicsrs uicer uiccr uicpr uictr uicmsr uicvr uicvcr" - "\n" - "%08x %08x %08x %08x %08x %08x %08x %08x %08x\n", - mfdcr(uicsr), - mfdcr(uicsrs), - mfdcr(uicer), - mfdcr(uiccr), - mfdcr(uicpr), - mfdcr(uictr), - mfdcr(uicmsr), - mfdcr(uicvr), - mfdcr(uicvcr)); - - puts ("\nMemory (SDRAM) Configuration\n" - "besra besrsa besrb besrsb bear mcopt1 rtr pmit\n"); - - mtdcr(memcfga,mem_besra); printf ("%08x ", mfdcr(memcfgd)); - mtdcr(memcfga,mem_besrsa); printf ("%08x ", mfdcr(memcfgd)); - mtdcr(memcfga,mem_besrb); printf ("%08x ", mfdcr(memcfgd)); - mtdcr(memcfga,mem_besrsb); printf ("%08x ", mfdcr(memcfgd)); - mtdcr(memcfga,mem_bear); printf ("%08x ", mfdcr(memcfgd)); - mtdcr(memcfga,mem_mcopt1); printf ("%08x ", mfdcr(memcfgd)); - mtdcr(memcfga,mem_rtr); printf ("%08x ", mfdcr(memcfgd)); - mtdcr(memcfga,mem_pmit); printf ("%08x ", mfdcr(memcfgd)); - - puts ("\n" - "mb0cf mb1cf mb2cf mb3cf sdtr1 ecccf eccerr\n"); - mtdcr(memcfga,mem_mb0cf); printf ("%08x ", mfdcr(memcfgd)); - mtdcr(memcfga,mem_mb1cf); printf ("%08x ", mfdcr(memcfgd)); - mtdcr(memcfga,mem_mb2cf); printf ("%08x ", mfdcr(memcfgd)); - mtdcr(memcfga,mem_mb3cf); printf ("%08x ", mfdcr(memcfgd)); - mtdcr(memcfga,mem_sdtr1); printf ("%08x ", mfdcr(memcfgd)); - mtdcr(memcfga,mem_ecccf); printf ("%08x ", mfdcr(memcfgd)); - mtdcr(memcfga,mem_eccerr); printf ("%08x ", mfdcr(memcfgd)); - - printf ("\n\n" - "DMA Channels\n" - "dmasr dmasgc dmaadr\n" - "%08x %08x %08x\n" - "dmacr_0 dmact_0 dmada_0 dmasa_0 dmasb_0\n" - "%08x %08x %08x %08x %08x\n" - "dmacr_1 dmact_1 dmada_1 dmasa_1 dmasb_1\n" - "%08x %08x %08x %08x %08x\n", - mfdcr(dmasr), mfdcr(dmasgc),mfdcr(dmaadr), - mfdcr(dmacr0), mfdcr(dmact0),mfdcr(dmada0), mfdcr(dmasa0), mfdcr(dmasb0), - mfdcr(dmacr1), mfdcr(dmact1),mfdcr(dmada1), mfdcr(dmasa1), mfdcr(dmasb1)); - - printf ( - "dmacr_2 dmact_2 dmada_2 dmasa_2 dmasb_2\n" "%08x %08x %08x %08x %08x\n" - "dmacr_3 dmact_3 dmada_3 dmasa_3 dmasb_3\n" "%08x %08x %08x %08x %08x\n", - mfdcr(dmacr2), mfdcr(dmact2),mfdcr(dmada2), mfdcr(dmasa2), mfdcr(dmasb2), - mfdcr(dmacr3), mfdcr(dmact3),mfdcr(dmada3), mfdcr(dmasa3), mfdcr(dmasb3) ); - - puts ("\n" - "External Bus\n" - "pbear pbesr0 pbesr1 epcr\n"); - mtdcr(ebccfga,pbear); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,pbesr0); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,pbesr1); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,epcr); printf ("%08x ", mfdcr(ebccfgd)); - - puts ("\n" - "pb0cr pb0ap pb1cr pb1ap pb2cr pb2ap pb3cr pb3ap\n"); - mtdcr(ebccfga,pb0cr); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,pb0ap); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,pb1cr); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,pb1ap); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,pb2cr); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,pb2ap); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,pb3cr); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,pb3ap); printf ("%08x ", mfdcr(ebccfgd)); - - puts ("\n" - "pb4cr pb4ap pb5cr bp5ap pb6cr pb6ap pb7cr pb7ap\n"); - mtdcr(ebccfga,pb4cr); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,pb4ap); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,pb5cr); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,pb5ap); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,pb6cr); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,pb6ap); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,pb7cr); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,pb7ap); printf ("%08x ", mfdcr(ebccfgd)); - - puts ("\n\n"); - -#elif defined(CONFIG_405EP) - printf ("\n405EP registers; MSR=%08x\n",mfmsr()); - printf ("\nUniversal Interrupt Controller Regs\n" - "uicsr uicer uiccr uicpr uictr uicmsr uicvr uicvcr" - "\n" - "%08x %08x %08x %08x %08x %08x %08x %08x\n", - mfdcr(uicsr), - mfdcr(uicer), - mfdcr(uiccr), - mfdcr(uicpr), - mfdcr(uictr), - mfdcr(uicmsr), - mfdcr(uicvr), - mfdcr(uicvcr)); - - puts ("\nMemory (SDRAM) Configuration\n" - "mcopt1 rtr pmit mb0cf mb1cf sdtr1\n"); - - mtdcr(memcfga,mem_mcopt1); printf ("%08x ", mfdcr(memcfgd)); - mtdcr(memcfga,mem_rtr); printf ("%08x ", mfdcr(memcfgd)); - mtdcr(memcfga,mem_pmit); printf ("%08x ", mfdcr(memcfgd)); - mtdcr(memcfga,mem_mb0cf); printf ("%08x ", mfdcr(memcfgd)); - mtdcr(memcfga,mem_mb1cf); printf ("%08x ", mfdcr(memcfgd)); - mtdcr(memcfga,mem_sdtr1); printf ("%08x ", mfdcr(memcfgd)); - - printf ("\n\n" - "DMA Channels\n" - "dmasr dmasgc dmaadr\n" "%08x %08x %08x\n" - "dmacr_0 dmact_0 dmada_0 dmasa_0 dmasb_0\n" "%08x %08x %08x %08x %08x\n" - "dmacr_1 dmact_1 dmada_1 dmasa_1 dmasb_1\n" "%08x %08x %08x %08x %08x\n", - mfdcr(dmasr), mfdcr(dmasgc),mfdcr(dmaadr), - mfdcr(dmacr0), mfdcr(dmact0),mfdcr(dmada0), mfdcr(dmasa0), mfdcr(dmasb0), - mfdcr(dmacr1), mfdcr(dmact1),mfdcr(dmada1), mfdcr(dmasa1), mfdcr(dmasb1)); - - printf ( - "dmacr_2 dmact_2 dmada_2 dmasa_2 dmasb_2\n" "%08x %08x %08x %08x %08x\n" - "dmacr_3 dmact_3 dmada_3 dmasa_3 dmasb_3\n" "%08x %08x %08x %08x %08x\n", - mfdcr(dmacr2), mfdcr(dmact2),mfdcr(dmada2), mfdcr(dmasa2), mfdcr(dmasb2), - mfdcr(dmacr3), mfdcr(dmact3),mfdcr(dmada3), mfdcr(dmasa3), mfdcr(dmasb3) ); - - puts ("\n" - "External Bus\n" - "pbear pbesr0 pbesr1 epcr\n"); - mtdcr(ebccfga,pbear); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,pbesr0); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,pbesr1); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,epcr); printf ("%08x ", mfdcr(ebccfgd)); - - puts ("\n" - "pb0cr pb0ap pb1cr pb1ap pb2cr pb2ap pb3cr pb3ap\n"); - mtdcr(ebccfga,pb0cr); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,pb0ap); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,pb1cr); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,pb1ap); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,pb2cr); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,pb2ap); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,pb3cr); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,pb3ap); printf ("%08x ", mfdcr(ebccfgd)); - - puts ("\n" - "pb4cr pb4ap\n"); - mtdcr(ebccfga,pb4cr); printf ("%08x ", mfdcr(ebccfgd)); - mtdcr(ebccfga,pb4ap); printf ("%08x ", mfdcr(ebccfgd)); - - puts ("\n\n"); -#elif defined(CONFIG_5xx) - - volatile immap_t *immap = (immap_t *)CFG_IMMR; - volatile memctl5xx_t *memctl = &immap->im_memctl; - volatile sysconf5xx_t *sysconf = &immap->im_siu_conf; - volatile sit5xx_t *timers = &immap->im_sit; - volatile car5xx_t *car = &immap->im_clkrst; - volatile uimb5xx_t *uimb = &immap->im_uimb; - - puts ("\nSystem Configuration registers\n"); - printf("\tIMMR\t0x%08X\tSIUMCR\t0x%08X \n", get_immr(0), sysconf->sc_siumcr); - printf("\tSYPCR\t0x%08X\tSWSR\t0x%04X \n" ,sysconf->sc_sypcr, sysconf->sc_swsr); - printf("\tSIPEND\t0x%08X\tSIMASK\t0x%08X \n", sysconf->sc_sipend, sysconf->sc_simask); - printf("\tSIEL\t0x%08X\tSIVEC\t0x%08X \n", sysconf->sc_siel, sysconf->sc_sivec); - printf("\tTESR\t0x%08X\n", sysconf->sc_tesr); - - puts ("\nMemory Controller Registers\n"); - printf("\tBR0\t0x%08X\tOR0\t0x%08X \n", memctl->memc_br0, memctl->memc_or0); - printf("\tBR1\t0x%08X\tOR1\t0x%08X \n", memctl->memc_br1, memctl->memc_or1); - printf("\tBR2\t0x%08X\tOR2\t0x%08X \n", memctl->memc_br2, memctl->memc_or2); - printf("\tBR3\t0x%08X\tOR3\t0x%08X \n", memctl->memc_br3, memctl->memc_or3); - printf("\tDMBR\t0x%08X\tDMOR\t0x%08X \n", memctl->memc_dmbr, memctl->memc_dmor ); - printf("\tMSTAT\t0x%08X\n", memctl->memc_mstat); - - puts ("\nSystem Integration Timers\n"); - printf("\tTBSCR\t0x%08X\tRTCSC\t0x%08X \n", timers->sit_tbscr, timers->sit_rtcsc); - printf("\tPISCR\t0x%08X \n", timers->sit_piscr); - - puts ("\nClocks and Reset\n"); - printf("\tSCCR\t0x%08X\tPLPRCR\t0x%08X \n", car->car_sccr, car->car_plprcr); - - puts ("\nU-Bus to IMB3 Bus Interface\n"); - printf("\tUMCR\t0x%08X\tUIPEND\t0x%08X \n", uimb->uimb_umcr, uimb->uimb_uipend); - puts ("\n\n"); - -#elif defined(CONFIG_MPC5200) - puts ("\nMPC5200 registers\n"); - printf ("MBAR=%08x\n", CFG_MBAR); - puts ("Memory map registers\n"); - printf ("\tCS0: start %08X\tstop %08X\tconfig %08X\ten %d\n", - *(volatile ulong*)MPC5XXX_CS0_START, - *(volatile ulong*)MPC5XXX_CS0_STOP, - *(volatile ulong*)MPC5XXX_CS0_CFG, - (*(volatile ulong*)MPC5XXX_ADDECR & 0x00010000) ? 1 : 0); - printf ("\tCS1: start %08X\tstop %08X\tconfig %08X\ten %d\n", - *(volatile ulong*)MPC5XXX_CS1_START, - *(volatile ulong*)MPC5XXX_CS1_STOP, - *(volatile ulong*)MPC5XXX_CS1_CFG, - (*(volatile ulong*)MPC5XXX_ADDECR & 0x00020000) ? 1 : 0); - printf ("\tCS2: start %08X\tstop %08X\tconfig %08X\ten %d\n", - *(volatile ulong*)MPC5XXX_CS2_START, - *(volatile ulong*)MPC5XXX_CS2_STOP, - *(volatile ulong*)MPC5XXX_CS2_CFG, - (*(volatile ulong*)MPC5XXX_ADDECR & 0x00040000) ? 1 : 0); - printf ("\tCS3: start %08X\tstop %08X\tconfig %08X\ten %d\n", - *(volatile ulong*)MPC5XXX_CS3_START, - *(volatile ulong*)MPC5XXX_CS3_STOP, - *(volatile ulong*)MPC5XXX_CS3_CFG, - (*(volatile ulong*)MPC5XXX_ADDECR & 0x00080000) ? 1 : 0); - printf ("\tCS4: start %08X\tstop %08X\tconfig %08X\ten %d\n", - *(volatile ulong*)MPC5XXX_CS4_START, - *(volatile ulong*)MPC5XXX_CS4_STOP, - *(volatile ulong*)MPC5XXX_CS4_CFG, - (*(volatile ulong*)MPC5XXX_ADDECR & 0x00100000) ? 1 : 0); - printf ("\tCS5: start %08X\tstop %08X\tconfig %08X\ten %d\n", - *(volatile ulong*)MPC5XXX_CS5_START, - *(volatile ulong*)MPC5XXX_CS5_STOP, - *(volatile ulong*)MPC5XXX_CS5_CFG, - (*(volatile ulong*)MPC5XXX_ADDECR & 0x00200000) ? 1 : 0); - printf ("\tCS6: start %08X\tstop %08X\tconfig %08X\ten %d\n", - *(volatile ulong*)MPC5XXX_CS6_START, - *(volatile ulong*)MPC5XXX_CS6_STOP, - *(volatile ulong*)MPC5XXX_CS6_CFG, - (*(volatile ulong*)MPC5XXX_ADDECR & 0x04000000) ? 1 : 0); - printf ("\tCS7: start %08X\tstop %08X\tconfig %08X\ten %d\n", - *(volatile ulong*)MPC5XXX_CS7_START, - *(volatile ulong*)MPC5XXX_CS7_STOP, - *(volatile ulong*)MPC5XXX_CS7_CFG, - (*(volatile ulong*)MPC5XXX_ADDECR & 0x08000000) ? 1 : 0); - printf ("\tBOOTCS: start %08X\tstop %08X\tconfig %08X\ten %d\n", - *(volatile ulong*)MPC5XXX_BOOTCS_START, - *(volatile ulong*)MPC5XXX_BOOTCS_STOP, - *(volatile ulong*)MPC5XXX_BOOTCS_CFG, - (*(volatile ulong*)MPC5XXX_ADDECR & 0x02000000) ? 1 : 0); - printf ("\tSDRAMCS0: %08X\n", - *(volatile ulong*)MPC5XXX_SDRAM_CS0CFG); - printf ("\tSDRAMCS1: %08X\n", - *(volatile ulong*)MPC5XXX_SDRAM_CS1CFG); -#endif /* CONFIG_MPC5200 */ - return 0; -} - -#endif /* CONFIG_COMMANDS & CFG_CMD_REGINFO */ - - - /**************************************************/ - -#if ( defined(CONFIG_8xx) || defined(CONFIG_405GP) || \ - defined(CONFIG_405EP) || defined(CONFIG_MPC5200) ) && \ - (CONFIG_COMMANDS & CFG_CMD_REGINFO) - -U_BOOT_CMD( - reginfo, 2, 1, do_reginfo, - "reginfo - print register information\n", -); -#endif diff --git a/common/cmd_reiser.c b/common/cmd_reiser.c deleted file mode 100644 index 508ffcbdac..0000000000 --- a/common/cmd_reiser.c +++ /dev/null @@ -1,277 +0,0 @@ -/* - * (C) Copyright 2003 - 2004 - * Sysgo Real-Time Solutions, AG - * Pavel Bartusek - * - * 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 - * - */ - -/* - * Reiserfs support - */ -#include - -#if (CONFIG_COMMANDS & CFG_CMD_REISER) -#include -#include -#include -#include -#include -#include - -#ifndef CONFIG_DOS_PARTITION -#error DOS partition support must be selected -#endif - -/* #define REISER_DEBUG */ - -#ifdef REISER_DEBUG -#define PRINTF(fmt,args...) printf (fmt ,##args) -#else -#define PRINTF(fmt,args...) -#endif - -static block_dev_desc_t *get_dev (char* ifname, int dev) -{ -#if (CONFIG_COMMANDS & CFG_CMD_IDE) - if (strncmp(ifname,"ide",3)==0) { - extern block_dev_desc_t * ide_get_dev(int dev); - return((dev >= CFG_IDE_MAXDEVICE) ? NULL : ide_get_dev(dev)); - } -#endif -#if (CONFIG_COMMANDS & CFG_CMD_SCSI) - if (strncmp(ifname,"scsi",4)==0) { - extern block_dev_desc_t * scsi_get_dev(int dev); - return((dev >= CFG_SCSI_MAXDEVICE) ? NULL : scsi_get_dev(dev)); - } -#endif -#if ((CONFIG_COMMANDS & CFG_CMD_USB) && defined(CONFIG_USB_STORAGE)) - if (strncmp(ifname,"usb",3)==0) { - extern block_dev_desc_t * usb_stor_get_dev(int dev); - return((dev >= USB_MAX_STOR_DEV) ? NULL : usb_stor_get_dev(dev)); - } -#endif -#if defined(CONFIG_MMC) - if (strncmp(ifname,"mmc",3)==0) { - extern block_dev_desc_t * mmc_get_dev(int dev); - return((dev >= 1) ? NULL : mmc_get_dev(dev)); - } -#endif -#if defined(CONFIG_SYSTEMACE) - if (strcmp(ifname,"ace")==0) { - extern block_dev_desc_t * systemace_get_dev(int dev); - return((dev >= 1) ? NULL : systemace_get_dev(dev)); - } -#endif - return NULL; -} - -int do_reiserls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ - char *filename = "/"; - int dev=0; - int part=1; - char *ep; - block_dev_desc_t *dev_desc=NULL; - int part_length; - - if (argc < 3) { - printf ("Usage:\n%s\n", cmdtp->usage); - return 1; - } - dev = (int)simple_strtoul (argv[2], &ep, 16); - dev_desc=get_dev(argv[1],dev); - - if (dev_desc == NULL) { - printf ("\n** Block device %s %d not supported\n", argv[1], dev); - return 1; - } - - if (*ep) { - if (*ep != ':') { - puts ("\n** Invalid boot device, use `dev[:part]' **\n"); - return 1; - } - part = (int)simple_strtoul(++ep, NULL, 16); - } - - if (argc == 4) { - filename = argv[3]; - } - - PRINTF("Using device %s %d:%d, directory: %s\n", argv[1], dev, part, filename); - - if ((part_length = reiserfs_set_blk_dev(dev_desc, part)) == 0) { - printf ("** Bad partition - %s %d:%d **\n", argv[1], dev, part); - return 1; - } - - if (!reiserfs_mount(part_length)) { - printf ("** Bad Reisefs partition or disk - %s %d:%d **\n", argv[1], dev, part); - return 1; - } - - if (reiserfs_ls (filename)) { - printf ("** Error reiserfs_ls() **\n"); - return 1; - }; - - return 0; -} - -U_BOOT_CMD( - reiserls, 4, 1, do_reiserls, - "reiserls- list files in a directory (default /)\n", - " [directory]\n" - " - list files from 'dev' on 'interface' in a 'directory'\n" -); - -/****************************************************************************** - * Reiserfs boot command intepreter. Derived from diskboot - */ -int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ - char *filename = NULL; - char *ep; - int dev, part = 0; - ulong addr = 0, part_length, filelen; - disk_partition_t info; - block_dev_desc_t *dev_desc = NULL; - char buf [12]; - unsigned long count; - char *addr_str; - - switch (argc) { - case 3: - addr_str = getenv("loadaddr"); - if (addr_str != NULL) { - addr = simple_strtoul (addr_str, NULL, 16); - } else { - addr = CFG_LOAD_ADDR; - } - filename = getenv ("bootfile"); - count = 0; - break; - case 4: - addr = simple_strtoul (argv[3], NULL, 16); - filename = getenv ("bootfile"); - count = 0; - break; - case 5: - addr = simple_strtoul (argv[3], NULL, 16); - filename = argv[4]; - count = 0; - break; - case 6: - addr = simple_strtoul (argv[3], NULL, 16); - filename = argv[4]; - count = simple_strtoul (argv[5], NULL, 16); - break; - - default: - printf ("Usage:\n%s\n", cmdtp->usage); - return 1; - } - - if (!filename) { - puts ("\n** No boot file defined **\n"); - return 1; - } - - dev = (int)simple_strtoul (argv[2], &ep, 16); - dev_desc=get_dev(argv[1],dev); - if (dev_desc==NULL) { - printf ("\n** Block device %s %d not supported\n", argv[1], dev); - return 1; - } - if (*ep) { - if (*ep != ':') { - puts ("\n** Invalid boot device, use `dev[:part]' **\n"); - return 1; - } - part = (int)simple_strtoul(++ep, NULL, 16); - } - - PRINTF("Using device %s%d, partition %d\n", argv[1], dev, part); - - if (part != 0) { - if (get_partition_info (dev_desc, part, &info)) { - printf ("** Bad partition %d **\n", part); - return 1; - } - - if (strncmp(info.type, BOOT_PART_TYPE, sizeof(info.type)) != 0) { - printf ("\n** Invalid partition type \"%.32s\"" - " (expect \"" BOOT_PART_TYPE "\")\n", - info.type); - return 1; - } - PRINTF ("\nLoading from block device %s device %d, partition %d: " - "Name: %.32s Type: %.32s File:%s\n", - argv[1], dev, part, info.name, info.type, filename); - } else { - PRINTF ("\nLoading from block device %s device %d, File:%s\n", - argv[1], dev, filename); - } - - - if ((part_length = reiserfs_set_blk_dev(dev_desc, part)) == 0) { - printf ("** Bad partition - %s %d:%d **\n", argv[1], dev, part); - return 1; - } - - if (!reiserfs_mount(part_length)) { - printf ("** Bad Reisefs partition or disk - %s %d:%d **\n", argv[1], dev, part); - return 1; - } - - filelen = reiserfs_open(filename); - if (filelen < 0) { - printf("** File not found %s\n", filename); - return 1; - } - if ((count < filelen) && (count != 0)) { - filelen = count; - } - - if (reiserfs_read((char *)addr, filelen) != filelen) { - printf("\n** Unable to read \"%s\" from %s %d:%d **\n", filename, argv[1], dev, part); - return 1; - } - - /* Loading ok, update default load address */ - load_addr = addr; - - printf ("\n%ld bytes read\n", filelen); - sprintf(buf, "%lX", filelen); - setenv("filesize", buf); - - return filelen; -} - -U_BOOT_CMD( - reiserload, 6, 0, do_reiserload, - "reiserload- load binary file from a Reiser filesystem\n", - " [addr] [filename] [bytes]\n" - " - load binary file 'filename' from 'dev' on 'interface'\n" - " to address 'addr' from dos filesystem\n" -); - -#endif /* CONFIG_COMMANDS & CFG_CMD_REISER */ diff --git a/common/dlmalloc.c b/common/dlmalloc.c index 4d86101aac..fe3b86da42 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -2019,7 +2019,7 @@ void malloc_stats() See descriptions of tunable parameters above. */ - +#ifndef __U_BOOT__ #if __STD_C int mALLOPt(int param_number, int value) #else @@ -2041,7 +2041,7 @@ int mALLOPt(param_number, value) int param_number; int value; return 0; } } - +#endif /* History: diff --git a/common/misc.c b/common/misc.c index ac6a43df58..9485b17ec5 100644 --- a/common/misc.c +++ b/common/misc.c @@ -41,7 +41,7 @@ void *sbrk (ptrdiff_t increment) int errno; #ifndef CONFIG_ERRNO_MESSAGES -static char errno_str[5]; +static char errno_string[5]; #endif const char *errno_str(void) @@ -116,8 +116,8 @@ const char *errno_str(void) return str; #else - sprintf(errno_str, "%d", errno); - return errno_str; + sprintf(errno_string, "%d", errno); + return errno_string; #endif } diff --git a/common/partition.c b/common/partition.c index 919e2e2e08..0da359d078 100644 --- a/common/partition.c +++ b/common/partition.c @@ -1,6 +1,5 @@ #include -#include #include #include #include @@ -35,190 +34,6 @@ struct device_d *dev_add_partition(struct device_d *dev, unsigned long offset, s return 0; } -static void dev_del_partitions(struct device_d *physdev) -{ - struct device_d *dev; - char buf[MAX_DRIVER_NAME]; - int i = 0; - - /* This is lame. Devices should to able to have children */ - while (1) { - sprintf(buf, "%s.%d", physdev->id, i); - dev = device_from_spec_str(buf, NULL); - if (dev) { - struct partition *part = dev->type_data; - unregister_device(dev); - free(part); - } - else - break; - i++; - } -} - -int mtd_part_do_parse_one (struct partition *part, const char *str, char **endp) -{ - ulong size; - char *end; - char buf[MAX_DRIVER_NAME]; - - memset(buf, 0, MAX_DRIVER_NAME); - - if (*str == '-') { - size = part->physdev->size - part->offset; - end = (char *)str + 1; - } else { - size = strtoul_suffix(str, &end, 0); - } - - if (size + part->offset > part->physdev->size) { - printf("partition end is beyond device\n"); - return -EINVAL; - } - - str = end; - - if (*str == '(') { - str++; - end = strchr(str, ')'); - if (!end) { - printf("could not find matching ')'\n"); - return -EINVAL; - } - if (end - str >= MAX_DRIVER_NAME) { - printf("device name too long\n"); - return -EINVAL; - } - - memcpy(part->name, str, end - str); - end++; - } - - str = end; - - if (*str == 'r' && *(str + 1) == 'o') { - part->readonly = 1; - end = (char *)(str + 2); - } - - if (endp) - *endp = end; - - strcpy(part->device.name, "partition"); - part->device.size = size; - - return 0; -} - -int do_addpart ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ - struct partition *part; - struct device_d *dev; - char *endp; - int num = 0; - unsigned long offset; - - if (argc != 2) { - printf ("Usage:\n%s\n", cmdtp->usage); - return 1; - } - - dev = device_from_spec_str(argv[1], &endp); - if (!dev) { - printf("no such device: %s\n",argv[1]); - return 1; - } - - dev_del_partitions(dev); - - offset = 0; - - while (1) { - part = xzalloc(sizeof(struct partition)); - - part->offset = offset; - part->physdev = dev; - part->num = num; - part->device.map_base = dev->map_base + offset; - - if(mtd_part_do_parse_one(part, endp, &endp)) { - dev_del_partitions(dev); - free(part); - return 1; - } - - offset += part->device.size; - - part->device.type_data = part; - - sprintf(part->device.id, "%s.%d", dev->id, num); - register_device(&part->device); - num++; - - if(!*endp) - break; - if(*endp != ',') { - printf("parse error\n"); - return 1; - } - endp++; - } - - return 0; -} - -static __maybe_unused char cmd_addpart_help[] = -"Usage: addpart \n" -"addpart adds a partition description to a device. The partition description\n" -"has the form\n" -"dev:size1(name1)[ro],size2(name2)[ro],...\n" -" is the device name under /dev. Size can be given in decimal or if\n" -"prefixed with 0x in hex. Sizes can have an optional suffix K,M,G. The size\n" -"of the last partition can be specified as '-' for the remaining space of the\n" -"device.\n" -"This format is the same as used in the Linux kernel for cmdline mtd partitions.\n" -"Note That this command has to be reworked and will probably change it's API."; - -U_BOOT_CMD_START(addpart) - .maxargs = 2, - .cmd = do_addpart, - .usage = "add a partition table to a device", - U_BOOT_CMD_HELP(cmd_addpart_help) -U_BOOT_CMD_END - -int do_delpart ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) -{ - struct device_d *dev; - - if (argc != 2) { - printf ("Usage:\n%s\n", cmdtp->usage); - return 1; - } - - dev = device_from_spec_str(argv[1], NULL); - if (!dev) { - printf("no such device: %s\n",argv[1]); - return 1; - } - - dev_del_partitions(dev); - - return 0; -} - -static __maybe_unused char cmd_delpart_help[] = -"Usage: delpart \n" -"Delete partitions previously added to a device with addpart.\n" -"Note: You have to specify the device as 'devid', _not_ as '/dev/devid'. This\n" -"will likely change soon.\n"; - -U_BOOT_CMD_START(delpart) - .maxargs = 2, - .cmd = do_delpart, - .usage = "delete a partition table from a device", - U_BOOT_CMD_HELP(cmd_delpart_help) -U_BOOT_CMD_END - static int part_erase(struct device_d *dev, size_t count, unsigned long offset) { struct partition *part = dev->type_data; diff --git a/common/startup.c b/common/startup.c index 0052ed4462..5813f37c88 100644 --- a/common/startup.c +++ b/common/startup.c @@ -123,10 +123,10 @@ void start_uboot (void) display_banner(); - run_command("mount none ramfs /", 0); - run_command("mkdir /dev", 0); - run_command("mkdir /env", 0); - run_command("mount none devfs /dev", 0); + mount("none", "ramfs", "/"); + mkdir("/dev"); + mkdir("/env"); + mount("none", "devfs", "/dev"); run_command("loadenv", 0); if (!stat("/env/init", &s)) { diff --git a/cpu/mpc5xx/reginfo.c b/cpu/mpc5xx/reginfo.c new file mode 100644 index 0000000000..e4765fe2b3 --- /dev/null +++ b/cpu/mpc5xx/reginfo.c @@ -0,0 +1,37 @@ +#include + +void reginfo(void) +{ + volatile immap_t *immap = (immap_t *)CFG_IMMR; + volatile memctl5xx_t *memctl = &immap->im_memctl; + volatile sysconf5xx_t *sysconf = &immap->im_siu_conf; + volatile sit5xx_t *timers = &immap->im_sit; + volatile car5xx_t *car = &immap->im_clkrst; + volatile uimb5xx_t *uimb = &immap->im_uimb; + + puts ("\nSystem Configuration registers\n"); + printf("\tIMMR\t0x%08X\tSIUMCR\t0x%08X \n", get_immr(0), sysconf->sc_siumcr); + printf("\tSYPCR\t0x%08X\tSWSR\t0x%04X \n" ,sysconf->sc_sypcr, sysconf->sc_swsr); + printf("\tSIPEND\t0x%08X\tSIMASK\t0x%08X \n", sysconf->sc_sipend, sysconf->sc_simask); + printf("\tSIEL\t0x%08X\tSIVEC\t0x%08X \n", sysconf->sc_siel, sysconf->sc_sivec); + printf("\tTESR\t0x%08X\n", sysconf->sc_tesr); + + puts ("\nMemory Controller Registers\n"); + printf("\tBR0\t0x%08X\tOR0\t0x%08X \n", memctl->memc_br0, memctl->memc_or0); + printf("\tBR1\t0x%08X\tOR1\t0x%08X \n", memctl->memc_br1, memctl->memc_or1); + printf("\tBR2\t0x%08X\tOR2\t0x%08X \n", memctl->memc_br2, memctl->memc_or2); + printf("\tBR3\t0x%08X\tOR3\t0x%08X \n", memctl->memc_br3, memctl->memc_or3); + printf("\tDMBR\t0x%08X\tDMOR\t0x%08X \n", memctl->memc_dmbr, memctl->memc_dmor ); + printf("\tMSTAT\t0x%08X\n", memctl->memc_mstat); + + puts ("\nSystem Integration Timers\n"); + printf("\tTBSCR\t0x%08X\tRTCSC\t0x%08X \n", timers->sit_tbscr, timers->sit_rtcsc); + printf("\tPISCR\t0x%08X \n", timers->sit_piscr); + + puts ("\nClocks and Reset\n"); + printf("\tSCCR\t0x%08X\tPLPRCR\t0x%08X \n", car->car_sccr, car->car_plprcr); + + puts ("\nU-Bus to IMB3 Bus Interface\n"); + printf("\tUMCR\t0x%08X\tUIPEND\t0x%08X \n", uimb->uimb_umcr, uimb->uimb_uipend); + puts ("\n\n"); +} diff --git a/cpu/mpc5xxx/Makefile b/cpu/mpc5xxx/Makefile index dde8ace473..c78ddf71de 100644 --- a/cpu/mpc5xxx/Makefile +++ b/cpu/mpc5xxx/Makefile @@ -1,12 +1,14 @@ -obj-y += cpu.o -obj-y += cpu_init.o -obj-$(CONFIG_DRIVER_NET_MPC5200) += firmware_sc_task_bestcomm.impl.o +obj-y += cpu.o +obj-y += cpu_init.o +obj-y += ide.o +obj-y += loadtask.o +obj-y += pci_mpc5200.o +obj-y += speed.o +obj-y += traps.o +extra-y += start.o +obj-$(CONFIG_MPC5200) += firmware_sc_task_bestcomm.impl.o +obj-$(CONFIG_INTERRUPTS) += interrupts.o +obj-$(CONFIG_REGINFO) += reginfo.o + #obj-y += firmware_sc_task.impl.o -obj-y += ide.o -obj-$(CONFIG_INTERRUPTS) += interrupts.o #obj-y += io.o -obj-y += loadtask.o -obj-y += pci_mpc5200.o -obj-y += speed.o -extra-y += start.o -obj-y += traps.o diff --git a/cpu/mpc5xxx/cpu.c b/cpu/mpc5xxx/cpu.c index 86a7e1965e..1bb340dedb 100644 --- a/cpu/mpc5xxx/cpu.c +++ b/cpu/mpc5xxx/cpu.c @@ -27,7 +27,7 @@ #include #include -#include +#include #include #include #include diff --git a/cpu/mpc5xxx/cpu_init.c b/cpu/mpc5xxx/cpu_init.c index 2001566d2a..b8c069f3a0 100644 --- a/cpu/mpc5xxx/cpu_init.c +++ b/cpu/mpc5xxx/cpu_init.c @@ -22,7 +22,7 @@ */ #include -#include +#include #include /* diff --git a/cpu/mpc5xxx/loadtask.c b/cpu/mpc5xxx/loadtask.c index 559d8b5c5e..77ba8c89d2 100644 --- a/cpu/mpc5xxx/loadtask.c +++ b/cpu/mpc5xxx/loadtask.c @@ -7,7 +7,7 @@ */ #include -#include +#include #include /* BestComm/SmartComm microcode */ diff --git a/cpu/mpc5xxx/reginfo.c b/cpu/mpc5xxx/reginfo.c new file mode 100644 index 0000000000..130e0357d6 --- /dev/null +++ b/cpu/mpc5xxx/reginfo.c @@ -0,0 +1,59 @@ +#include +#include +#include + +void reginfo(void) +{ + puts ("\nMPC5200 registers\n"); + printf ("MBAR=%08x\n", CFG_MBAR); + puts ("Memory map registers\n"); + printf ("\tCS0: start %08X\tstop %08X\tconfig %08X\ten %d\n", + *(volatile ulong*)MPC5XXX_CS0_START, + *(volatile ulong*)MPC5XXX_CS0_STOP, + *(volatile ulong*)MPC5XXX_CS0_CFG, + (*(volatile ulong*)MPC5XXX_ADDECR & 0x00010000) ? 1 : 0); + printf ("\tCS1: start %08X\tstop %08X\tconfig %08X\ten %d\n", + *(volatile ulong*)MPC5XXX_CS1_START, + *(volatile ulong*)MPC5XXX_CS1_STOP, + *(volatile ulong*)MPC5XXX_CS1_CFG, + (*(volatile ulong*)MPC5XXX_ADDECR & 0x00020000) ? 1 : 0); + printf ("\tCS2: start %08X\tstop %08X\tconfig %08X\ten %d\n", + *(volatile ulong*)MPC5XXX_CS2_START, + *(volatile ulong*)MPC5XXX_CS2_STOP, + *(volatile ulong*)MPC5XXX_CS2_CFG, + (*(volatile ulong*)MPC5XXX_ADDECR & 0x00040000) ? 1 : 0); + printf ("\tCS3: start %08X\tstop %08X\tconfig %08X\ten %d\n", + *(volatile ulong*)MPC5XXX_CS3_START, + *(volatile ulong*)MPC5XXX_CS3_STOP, + *(volatile ulong*)MPC5XXX_CS3_CFG, + (*(volatile ulong*)MPC5XXX_ADDECR & 0x00080000) ? 1 : 0); + printf ("\tCS4: start %08X\tstop %08X\tconfig %08X\ten %d\n", + *(volatile ulong*)MPC5XXX_CS4_START, + *(volatile ulong*)MPC5XXX_CS4_STOP, + *(volatile ulong*)MPC5XXX_CS4_CFG, + (*(volatile ulong*)MPC5XXX_ADDECR & 0x00100000) ? 1 : 0); + printf ("\tCS5: start %08X\tstop %08X\tconfig %08X\ten %d\n", + *(volatile ulong*)MPC5XXX_CS5_START, + *(volatile ulong*)MPC5XXX_CS5_STOP, + *(volatile ulong*)MPC5XXX_CS5_CFG, + (*(volatile ulong*)MPC5XXX_ADDECR & 0x00200000) ? 1 : 0); + printf ("\tCS6: start %08X\tstop %08X\tconfig %08X\ten %d\n", + *(volatile ulong*)MPC5XXX_CS6_START, + *(volatile ulong*)MPC5XXX_CS6_STOP, + *(volatile ulong*)MPC5XXX_CS6_CFG, + (*(volatile ulong*)MPC5XXX_ADDECR & 0x04000000) ? 1 : 0); + printf ("\tCS7: start %08X\tstop %08X\tconfig %08X\ten %d\n", + *(volatile ulong*)MPC5XXX_CS7_START, + *(volatile ulong*)MPC5XXX_CS7_STOP, + *(volatile ulong*)MPC5XXX_CS7_CFG, + (*(volatile ulong*)MPC5XXX_ADDECR & 0x08000000) ? 1 : 0); + printf ("\tBOOTCS: start %08X\tstop %08X\tconfig %08X\ten %d\n", + *(volatile ulong*)MPC5XXX_BOOTCS_START, + *(volatile ulong*)MPC5XXX_BOOTCS_STOP, + *(volatile ulong*)MPC5XXX_BOOTCS_CFG, + (*(volatile ulong*)MPC5XXX_ADDECR & 0x02000000) ? 1 : 0); + printf ("\tSDRAMCS0: %08X\n", + *(volatile ulong*)MPC5XXX_SDRAM_CS0CFG); + printf ("\tSDRAMCS1: %08X\n", + *(volatile ulong*)MPC5XXX_SDRAM_CS1CFG); +} diff --git a/cpu/mpc5xxx/speed.c b/cpu/mpc5xxx/speed.c index 3283fa81e0..7207016831 100644 --- a/cpu/mpc5xxx/speed.c +++ b/cpu/mpc5xxx/speed.c @@ -22,7 +22,7 @@ */ #include -#include +#include #include #include #include diff --git a/cpu/mpc5xxx/start.S b/cpu/mpc5xxx/start.S index 795fdd4ff6..887ca956a4 100644 --- a/cpu/mpc5xxx/start.S +++ b/cpu/mpc5xxx/start.S @@ -26,7 +26,7 @@ * U-Boot - Startup Code for MPC5xxx CPUs */ #include -#include +#include #include #include diff --git a/cpu/ppc4xx/reginfo_405ep.c b/cpu/ppc4xx/reginfo_405ep.c new file mode 100644 index 0000000000..19fb649123 --- /dev/null +++ b/cpu/ppc4xx/reginfo_405ep.c @@ -0,0 +1,68 @@ +#include + +void reginfo(void) + printf ("\n405EP registers; MSR=%08x\n",mfmsr()); + printf ("\nUniversal Interrupt Controller Regs\n" + "uicsr uicer uiccr uicpr uictr uicmsr uicvr uicvcr" + "\n" + "%08x %08x %08x %08x %08x %08x %08x %08x\n", + mfdcr(uicsr), + mfdcr(uicer), + mfdcr(uiccr), + mfdcr(uicpr), + mfdcr(uictr), + mfdcr(uicmsr), + mfdcr(uicvr), + mfdcr(uicvcr)); + + puts ("\nMemory (SDRAM) Configuration\n" + "mcopt1 rtr pmit mb0cf mb1cf sdtr1\n"); + + mtdcr(memcfga,mem_mcopt1); printf ("%08x ", mfdcr(memcfgd)); + mtdcr(memcfga,mem_rtr); printf ("%08x ", mfdcr(memcfgd)); + mtdcr(memcfga,mem_pmit); printf ("%08x ", mfdcr(memcfgd)); + mtdcr(memcfga,mem_mb0cf); printf ("%08x ", mfdcr(memcfgd)); + mtdcr(memcfga,mem_mb1cf); printf ("%08x ", mfdcr(memcfgd)); + mtdcr(memcfga,mem_sdtr1); printf ("%08x ", mfdcr(memcfgd)); + + printf ("\n\n" + "DMA Channels\n" + "dmasr dmasgc dmaadr\n" "%08x %08x %08x\n" + "dmacr_0 dmact_0 dmada_0 dmasa_0 dmasb_0\n" "%08x %08x %08x %08x %08x\n" + "dmacr_1 dmact_1 dmada_1 dmasa_1 dmasb_1\n" "%08x %08x %08x %08x %08x\n", + mfdcr(dmasr), mfdcr(dmasgc),mfdcr(dmaadr), + mfdcr(dmacr0), mfdcr(dmact0),mfdcr(dmada0), mfdcr(dmasa0), mfdcr(dmasb0), + mfdcr(dmacr1), mfdcr(dmact1),mfdcr(dmada1), mfdcr(dmasa1), mfdcr(dmasb1)); + + printf ( + "dmacr_2 dmact_2 dmada_2 dmasa_2 dmasb_2\n" "%08x %08x %08x %08x %08x\n" + "dmacr_3 dmact_3 dmada_3 dmasa_3 dmasb_3\n" "%08x %08x %08x %08x %08x\n", + mfdcr(dmacr2), mfdcr(dmact2),mfdcr(dmada2), mfdcr(dmasa2), mfdcr(dmasb2), + mfdcr(dmacr3), mfdcr(dmact3),mfdcr(dmada3), mfdcr(dmasa3), mfdcr(dmasb3) ); + + puts ("\n" + "External Bus\n" + "pbear pbesr0 pbesr1 epcr\n"); + mtdcr(ebccfga,pbear); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,pbesr0); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,pbesr1); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,epcr); printf ("%08x ", mfdcr(ebccfgd)); + + puts ("\n" + "pb0cr pb0ap pb1cr pb1ap pb2cr pb2ap pb3cr pb3ap\n"); + mtdcr(ebccfga,pb0cr); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,pb0ap); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,pb1cr); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,pb1ap); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,pb2cr); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,pb2ap); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,pb3cr); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,pb3ap); printf ("%08x ", mfdcr(ebccfgd)); + + puts ("\n" + "pb4cr pb4ap\n"); + mtdcr(ebccfga,pb4cr); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,pb4ap); printf ("%08x ", mfdcr(ebccfgd)); + + puts ("\n\n"); +} diff --git a/cpu/ppc4xx/reginfo_405gp.c b/cpu/ppc4xx/reginfo_405gp.c new file mode 100644 index 0000000000..c220ad8a6b --- /dev/null +++ b/cpu/ppc4xx/reginfo_405gp.c @@ -0,0 +1,91 @@ +#include + +void reginfo(void) +{ + printf ("\n405GP registers; MSR=%08x\n",mfmsr()); + printf ("\nUniversal Interrupt Controller Regs\n" + "uicsr uicsrs uicer uiccr uicpr uictr uicmsr uicvr uicvcr" + "\n" + "%08x %08x %08x %08x %08x %08x %08x %08x %08x\n", + mfdcr(uicsr), + mfdcr(uicsrs), + mfdcr(uicer), + mfdcr(uiccr), + mfdcr(uicpr), + mfdcr(uictr), + mfdcr(uicmsr), + mfdcr(uicvr), + mfdcr(uicvcr)); + + puts ("\nMemory (SDRAM) Configuration\n" + "besra besrsa besrb besrsb bear mcopt1 rtr pmit\n"); + + mtdcr(memcfga,mem_besra); printf ("%08x ", mfdcr(memcfgd)); + mtdcr(memcfga,mem_besrsa); printf ("%08x ", mfdcr(memcfgd)); + mtdcr(memcfga,mem_besrb); printf ("%08x ", mfdcr(memcfgd)); + mtdcr(memcfga,mem_besrsb); printf ("%08x ", mfdcr(memcfgd)); + mtdcr(memcfga,mem_bear); printf ("%08x ", mfdcr(memcfgd)); + mtdcr(memcfga,mem_mcopt1); printf ("%08x ", mfdcr(memcfgd)); + mtdcr(memcfga,mem_rtr); printf ("%08x ", mfdcr(memcfgd)); + mtdcr(memcfga,mem_pmit); printf ("%08x ", mfdcr(memcfgd)); + + puts ("\n" + "mb0cf mb1cf mb2cf mb3cf sdtr1 ecccf eccerr\n"); + mtdcr(memcfga,mem_mb0cf); printf ("%08x ", mfdcr(memcfgd)); + mtdcr(memcfga,mem_mb1cf); printf ("%08x ", mfdcr(memcfgd)); + mtdcr(memcfga,mem_mb2cf); printf ("%08x ", mfdcr(memcfgd)); + mtdcr(memcfga,mem_mb3cf); printf ("%08x ", mfdcr(memcfgd)); + mtdcr(memcfga,mem_sdtr1); printf ("%08x ", mfdcr(memcfgd)); + mtdcr(memcfga,mem_ecccf); printf ("%08x ", mfdcr(memcfgd)); + mtdcr(memcfga,mem_eccerr); printf ("%08x ", mfdcr(memcfgd)); + + printf ("\n\n" + "DMA Channels\n" + "dmasr dmasgc dmaadr\n" + "%08x %08x %08x\n" + "dmacr_0 dmact_0 dmada_0 dmasa_0 dmasb_0\n" + "%08x %08x %08x %08x %08x\n" + "dmacr_1 dmact_1 dmada_1 dmasa_1 dmasb_1\n" + "%08x %08x %08x %08x %08x\n", + mfdcr(dmasr), mfdcr(dmasgc),mfdcr(dmaadr), + mfdcr(dmacr0), mfdcr(dmact0),mfdcr(dmada0), mfdcr(dmasa0), mfdcr(dmasb0), + mfdcr(dmacr1), mfdcr(dmact1),mfdcr(dmada1), mfdcr(dmasa1), mfdcr(dmasb1)); + + printf ( + "dmacr_2 dmact_2 dmada_2 dmasa_2 dmasb_2\n" "%08x %08x %08x %08x %08x\n" + "dmacr_3 dmact_3 dmada_3 dmasa_3 dmasb_3\n" "%08x %08x %08x %08x %08x\n", + mfdcr(dmacr2), mfdcr(dmact2),mfdcr(dmada2), mfdcr(dmasa2), mfdcr(dmasb2), + mfdcr(dmacr3), mfdcr(dmact3),mfdcr(dmada3), mfdcr(dmasa3), mfdcr(dmasb3) ); + + puts ("\n" + "External Bus\n" + "pbear pbesr0 pbesr1 epcr\n"); + mtdcr(ebccfga,pbear); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,pbesr0); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,pbesr1); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,epcr); printf ("%08x ", mfdcr(ebccfgd)); + + puts ("\n" + "pb0cr pb0ap pb1cr pb1ap pb2cr pb2ap pb3cr pb3ap\n"); + mtdcr(ebccfga,pb0cr); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,pb0ap); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,pb1cr); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,pb1ap); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,pb2cr); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,pb2ap); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,pb3cr); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,pb3ap); printf ("%08x ", mfdcr(ebccfgd)); + + puts ("\n" + "pb4cr pb4ap pb5cr bp5ap pb6cr pb6ap pb7cr pb7ap\n"); + mtdcr(ebccfga,pb4cr); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,pb4ap); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,pb5cr); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,pb5ap); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,pb6cr); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,pb6ap); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,pb7cr); printf ("%08x ", mfdcr(ebccfgd)); + mtdcr(ebccfga,pb7ap); printf ("%08x ", mfdcr(ebccfgd)); + + puts ("\n\n"); +} \ No newline at end of file diff --git a/drivers/serial/serial_mpc5xxx.c b/drivers/serial/serial_mpc5xxx.c index 8a7ef8d4f4..54c2d02ba6 100644 --- a/drivers/serial/serial_mpc5xxx.c +++ b/drivers/serial/serial_mpc5xxx.c @@ -34,7 +34,7 @@ */ #include -#include +#include #include #include #include diff --git a/fs/fs.c b/fs/fs.c index d86894e5b2..2472649617 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -485,7 +485,11 @@ int erase(int fd, size_t count, unsigned long offset) if (f->pos + count > f->size) count = f->size - f->pos; - errno = fsdrv->erase(dev, f, count, offset); + + if (fsdrv->erase) + errno = fsdrv->erase(dev, f, count, offset); + else + errno = -EINVAL; return errno; } @@ -749,3 +753,51 @@ out: return errno; } +static void memcpy_sz(void *_dst, const void *_src, ulong count, ulong rwsize) +{ + ulong dst = (ulong)_dst; + ulong src = (ulong)_src; + + /* no rwsize specification given. Do whatever memcpy likes best */ + if (!rwsize) { + memcpy(_dst, _src, count); + return; + } + + rwsize = rwsize >> O_RWSIZE_SHIFT; + + count /= rwsize; + + while (count-- > 0) { + switch (rwsize) { + case 1: + *((u_char *)dst) = *((u_char *)src); + break; + case 2: + *((ushort *)dst) = *((ushort *)src); + break; + case 4: + *((ulong *)dst) = *((ulong *)src); + break; + } + dst += rwsize; + src += rwsize; + } +} + +ssize_t mem_read(struct device_d *dev, void *buf, size_t count, ulong offset, ulong flags) +{ + ulong size; + size = min(count, dev->size - offset); + debug("mem_read: dev->map_base: %p size: %d offset: %d\n",dev->map_base, size, offset); + memcpy_sz(buf, (void *)(dev->map_base + offset), size, flags & O_RWSIZE_MASK); + return size; +} + +ssize_t mem_write(struct device_d *dev, const void *buf, size_t count, ulong offset, ulong flags) +{ + ulong size; + size = min(count, dev->size - offset); + memcpy_sz((void *)(dev->map_base + offset), buf, size, flags & O_RWSIZE_MASK); + return size; +} diff --git a/include/asm-ppc/arch-mpc5200/mpc5xxx.h b/include/asm-ppc/arch-mpc5200/mpc5xxx.h new file mode 100644 index 0000000000..089aa1322b --- /dev/null +++ b/include/asm-ppc/arch-mpc5200/mpc5xxx.h @@ -0,0 +1,781 @@ +/* + * include/asm-ppc/mpc5xxx.h + * + * Prototypes, etc. for the Motorola MGT5xxx/MPC5xxx + * embedded cpu chips + * + * 2003 (c) MontaVista, Software, Inc. + * Author: Dale Farnsworth + * + * 2003 (C) 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 + */ +#ifndef __ASMPPC_MPC5XXX_H +#define __ASMPPC_MPC5XXX_H + +/* Processor name */ +#if defined(CONFIG_MPC5200) +#define CPU_ID_STR "MPC5200" +#elif defined(CONFIG_MGT5100) +#define CPU_ID_STR "MGT5100" +#endif + +/* Exception offsets (PowerPC standard) */ +#define EXC_OFF_SYS_RESET 0x0100 + +/* useful macros for manipulating CSx_START/STOP */ +#if defined(CONFIG_MGT5100) +#define START_REG(start) ((start) >> 15) +#define STOP_REG(start, size) (((start) + (size) - 1) >> 15) +#elif defined(CONFIG_MPC5200) +#define START_REG(start) ((start) >> 16) +#define STOP_REG(start, size) (((start) + (size) - 1) >> 16) +#endif + +/* Internal memory map */ + +#define MPC5XXX_CS0_START (CFG_MBAR + 0x0004) +#define MPC5XXX_CS0_STOP (CFG_MBAR + 0x0008) +#define MPC5XXX_CS1_START (CFG_MBAR + 0x000c) +#define MPC5XXX_CS1_STOP (CFG_MBAR + 0x0010) +#define MPC5XXX_CS2_START (CFG_MBAR + 0x0014) +#define MPC5XXX_CS2_STOP (CFG_MBAR + 0x0018) +#define MPC5XXX_CS3_START (CFG_MBAR + 0x001c) +#define MPC5XXX_CS3_STOP (CFG_MBAR + 0x0020) +#define MPC5XXX_CS4_START (CFG_MBAR + 0x0024) +#define MPC5XXX_CS4_STOP (CFG_MBAR + 0x0028) +#define MPC5XXX_CS5_START (CFG_MBAR + 0x002c) +#define MPC5XXX_CS5_STOP (CFG_MBAR + 0x0030) +#define MPC5XXX_BOOTCS_START (CFG_MBAR + 0x004c) +#define MPC5XXX_BOOTCS_STOP (CFG_MBAR + 0x0050) +#define MPC5XXX_ADDECR (CFG_MBAR + 0x0054) + +#if defined(CONFIG_MGT5100) +#define MPC5XXX_SDRAM_START (CFG_MBAR + 0x0034) +#define MPC5XXX_SDRAM_STOP (CFG_MBAR + 0x0038) +#define MPC5XXX_PCI1_START (CFG_MBAR + 0x003c) +#define MPC5XXX_PCI1_STOP (CFG_MBAR + 0x0040) +#define MPC5XXX_PCI2_START (CFG_MBAR + 0x0044) +#define MPC5XXX_PCI2_STOP (CFG_MBAR + 0x0048) +#elif defined(CONFIG_MPC5200) +#define MPC5XXX_CS6_START (CFG_MBAR + 0x0058) +#define MPC5XXX_CS6_STOP (CFG_MBAR + 0x005c) +#define MPC5XXX_CS7_START (CFG_MBAR + 0x0060) +#define MPC5XXX_CS7_STOP (CFG_MBAR + 0x0064) +#define MPC5XXX_SDRAM_CS0CFG (CFG_MBAR + 0x0034) +#define MPC5XXX_SDRAM_CS1CFG (CFG_MBAR + 0x0038) +#endif + +#define MPC5XXX_SDRAM (CFG_MBAR + 0x0100) +#define MPC5XXX_CDM (CFG_MBAR + 0x0200) +#define MPC5XXX_LPB (CFG_MBAR + 0x0300) +#define MPC5XXX_ICTL (CFG_MBAR + 0x0500) +#define MPC5XXX_GPT (CFG_MBAR + 0x0600) +#define MPC5XXX_GPIO (CFG_MBAR + 0x0b00) +#define MPC5XXX_WU_GPIO (CFG_MBAR + 0x0c00) +#define MPC5XXX_PCI (CFG_MBAR + 0x0d00) +#define MPC5XXX_SPI (CFG_MBAR + 0x0f00) +#define MPC5XXX_USB (CFG_MBAR + 0x1000) +#define MPC5XXX_SDMA (CFG_MBAR + 0x1200) +#define MPC5XXX_XLBARB (CFG_MBAR + 0x1f00) + +#if defined(CONFIG_MGT5100) +#define MPC5XXX_PSC1 (CFG_MBAR + 0x2000) +#define MPC5XXX_PSC2 (CFG_MBAR + 0x2400) +#define MPC5XXX_PSC3 (CFG_MBAR + 0x2800) +#elif defined(CONFIG_MPC5200) +#define MPC5XXX_PSC1 (CFG_MBAR + 0x2000) +#define MPC5XXX_PSC2 (CFG_MBAR + 0x2200) +#define MPC5XXX_PSC3 (CFG_MBAR + 0x2400) +#define MPC5XXX_PSC4 (CFG_MBAR + 0x2600) +#define MPC5XXX_PSC5 (CFG_MBAR + 0x2800) +#define MPC5XXX_PSC6 (CFG_MBAR + 0x2c00) +#endif + +#define MPC5XXX_FEC (CFG_MBAR + 0x3000) +#define MPC5XXX_ATA (CFG_MBAR + 0x3A00) + +#define MPC5XXX_I2C1 (CFG_MBAR + 0x3D00) +#define MPC5XXX_I2C2 (CFG_MBAR + 0x3D40) + +#if defined(CONFIG_MGT5100) +#define MPC5XXX_SRAM (CFG_MBAR + 0x4000) +#define MPC5XXX_SRAM_SIZE (8*1024) +#elif defined(CONFIG_MPC5200) +#define MPC5XXX_SRAM (CFG_MBAR + 0x8000) +#define MPC5XXX_SRAM_SIZE (16*1024) +#endif + +/* SDRAM Controller */ +#define MPC5XXX_SDRAM_MODE (MPC5XXX_SDRAM + 0x0000) +#define MPC5XXX_SDRAM_CTRL (MPC5XXX_SDRAM + 0x0004) +#define MPC5XXX_SDRAM_CONFIG1 (MPC5XXX_SDRAM + 0x0008) +#define MPC5XXX_SDRAM_CONFIG2 (MPC5XXX_SDRAM + 0x000c) +#if defined(CONFIG_MGT5100) +#define MPC5XXX_SDRAM_XLBSEL (MPC5XXX_SDRAM + 0x0010) +#endif +#define MPC5XXX_SDRAM_SDELAY (MPC5XXX_SDRAM + 0x0090) + +/* Clock Distribution Module */ +#define MPC5XXX_CDM_JTAGID (MPC5XXX_CDM + 0x0000) +#define MPC5XXX_CDM_PORCFG (MPC5XXX_CDM + 0x0004) +#define MPC5XXX_CDM_CFG (MPC5XXX_CDM + 0x000c) +#define MPC5XXX_CDM_48_FDC (MPC5XXX_CDM + 0x0010) +#define MPC5XXX_CDM_SRESET (MPC5XXX_CDM + 0x0020) + +/* Local Plus Bus interface */ +#define MPC5XXX_CS0_CFG (MPC5XXX_LPB + 0x0000) +#define MPC5XXX_CS1_CFG (MPC5XXX_LPB + 0x0004) +#define MPC5XXX_CS2_CFG (MPC5XXX_LPB + 0x0008) +#define MPC5XXX_CS3_CFG (MPC5XXX_LPB + 0x000c) +#define MPC5XXX_CS4_CFG (MPC5XXX_LPB + 0x0010) +#define MPC5XXX_CS5_CFG (MPC5XXX_LPB + 0x0014) +#define MPC5XXX_BOOTCS_CFG MPC5XXX_CS0_CFG +#define MPC5XXX_CS_CTRL (MPC5XXX_LPB + 0x0018) +#define MPC5XXX_CS_STATUS (MPC5XXX_LPB + 0x001c) +#if defined(CONFIG_MPC5200) +#define MPC5XXX_CS6_CFG (MPC5XXX_LPB + 0x0020) +#define MPC5XXX_CS7_CFG (MPC5XXX_LPB + 0x0024) +#define MPC5XXX_CS_BURST (MPC5XXX_LPB + 0x0028) +#define MPC5XXX_CS_DEADCYCLE (MPC5XXX_LPB + 0x002c) +#endif + +#if defined(CONFIG_MPC5200) +/* XLB Arbiter registers */ +#define MPC5XXX_XLBARB_CFG (MPC5XXX_XLBARB + 0x40) +#define MPC5XXX_XLBARB_MPRIEN (MPC5XXX_XLBARB + 0x64) +#define MPC5XXX_XLBARB_MPRIVAL (MPC5XXX_XLBARB + 0x68) +#endif + +/* GPIO registers */ +#define MPC5XXX_GPS_PORT_CONFIG (MPC5XXX_GPIO + 0x0000) + +/* Standard GPIO registers (simple, output only and simple interrupt */ +#define MPC5XXX_GPIO_ENABLE (MPC5XXX_GPIO + 0x0004) +#define MPC5XXX_GPIO_ODE (MPC5XXX_GPIO + 0x0008) +#define MPC5XXX_GPIO_DIR (MPC5XXX_GPIO + 0x000c) +#define MPC5XXX_GPIO_DATA_O (MPC5XXX_GPIO + 0x0010) +#define MPC5XXX_GPIO_DATA_I (MPC5XXX_GPIO + 0x0014) +#define MPC5XXX_GPIO_OO_ENABLE (MPC5XXX_GPIO + 0x0018) +#define MPC5XXX_GPIO_OO_DATA (MPC5XXX_GPIO + 0x001C) +#define MPC5XXX_GPIO_SI_ENABLE (MPC5XXX_GPIO + 0x0020) +#define MPC5XXX_GPIO_SI_ODE (MPC5XXX_GPIO + 0x0024) +#define MPC5XXX_GPIO_SI_DIR (MPC5XXX_GPIO + 0x0028) +#define MPC5XXX_GPIO_SI_DATA (MPC5XXX_GPIO + 0x002C) +#define MPC5XXX_GPIO_SI_IEN (MPC5XXX_GPIO + 0x0030) +#define MPC5XXX_GPIO_SI_ITYPE (MPC5XXX_GPIO + 0x0034) +#define MPC5XXX_GPIO_SI_MEN (MPC5XXX_GPIO + 0x0038) +#define MPC5XXX_GPIO_SI_STATUS (MPC5XXX_GPIO + 0x003C) + +/* WakeUp GPIO registers */ +#define MPC5XXX_WU_GPIO_ENABLE (MPC5XXX_WU_GPIO + 0x0000) +#define MPC5XXX_WU_GPIO_ODE (MPC5XXX_WU_GPIO + 0x0004) +#define MPC5XXX_WU_GPIO_DIR (MPC5XXX_WU_GPIO + 0x0008) +#define MPC5XXX_WU_GPIO_DATA_O (MPC5XXX_WU_GPIO + 0x000c) +#define MPC5XXX_WU_GPIO_DATA_I (MPC5XXX_WU_GPIO + 0x0020) + +/* GPIO pins */ +#define GPIO_WKUP_7 0x80000000UL +#define GPIO_PSC6_0 0x10000000UL +#define GPIO_PSC3_9 0x04000000UL +#define GPIO_PSC1_4 0x01000000UL + +/* PCI registers */ +#define MPC5XXX_PCI_CMD (MPC5XXX_PCI + 0x04) +#define MPC5XXX_PCI_CFG (MPC5XXX_PCI + 0x0c) +#define MPC5XXX_PCI_BAR0 (MPC5XXX_PCI + 0x10) +#define MPC5XXX_PCI_BAR1 (MPC5XXX_PCI + 0x14) +#if defined(CONFIG_MGT5100) +#define MPC5XXX_PCI_CTRL (MPC5XXX_PCI + 0x68) +#define MPC5XXX_PCI_VALMSKR (MPC5XXX_PCI + 0x6c) +#define MPC5XXX_PCI_VALMSKW (MPC5XXX_PCI + 0x70) +#define MPC5XXX_PCI_SUBW1 (MPC5XXX_PCI + 0x74) +#define MPC5XXX_PCI_SUBW2 (MPC5XXX_PCI + 0x78) +#define MPC5XXX_PCI_WINCOMMAND (MPC5XXX_PCI + 0x7c) +#elif defined(CONFIG_MPC5200) +#define MPC5XXX_PCI_GSCR (MPC5XXX_PCI + 0x60) +#define MPC5XXX_PCI_TBATR0 (MPC5XXX_PCI + 0x64) +#define MPC5XXX_PCI_TBATR1 (MPC5XXX_PCI + 0x68) +#define MPC5XXX_PCI_TCR (MPC5XXX_PCI + 0x6c) +#define MPC5XXX_PCI_IW0BTAR (MPC5XXX_PCI + 0x70) +#define MPC5XXX_PCI_IW1BTAR (MPC5XXX_PCI + 0x74) +#define MPC5XXX_PCI_IW2BTAR (MPC5XXX_PCI + 0x78) +#define MPC5XXX_PCI_IWCR (MPC5XXX_PCI + 0x80) +#define MPC5XXX_PCI_ICR (MPC5XXX_PCI + 0x84) +#define MPC5XXX_PCI_ISR (MPC5XXX_PCI + 0x88) +#define MPC5XXX_PCI_ARB (MPC5XXX_PCI + 0x8c) +#define MPC5XXX_PCI_CAR (MPC5XXX_PCI + 0xf8) +#endif + +/* Interrupt Controller registers */ +#define MPC5XXX_ICTL_PER_MASK (MPC5XXX_ICTL + 0x0000) +#define MPC5XXX_ICTL_PER_PRIO1 (MPC5XXX_ICTL + 0x0004) +#define MPC5XXX_ICTL_PER_PRIO2 (MPC5XXX_ICTL + 0x0008) +#define MPC5XXX_ICTL_PER_PRIO3 (MPC5XXX_ICTL + 0x000c) +#define MPC5XXX_ICTL_EXT (MPC5XXX_ICTL + 0x0010) +#define MPC5XXX_ICTL_CRIT (MPC5XXX_ICTL + 0x0014) +#define MPC5XXX_ICTL_MAIN_PRIO1 (MPC5XXX_ICTL + 0x0018) +#define MPC5XXX_ICTL_MAIN_PRIO2 (MPC5XXX_ICTL + 0x001c) +#define MPC5XXX_ICTL_STS (MPC5XXX_ICTL + 0x0024) +#define MPC5XXX_ICTL_CRIT_STS (MPC5XXX_ICTL + 0x0028) +#define MPC5XXX_ICTL_MAIN_STS (MPC5XXX_ICTL + 0x002c) +#define MPC5XXX_ICTL_PER_STS (MPC5XXX_ICTL + 0x0030) +#define MPC5XXX_ICTL_BUS_STS (MPC5XXX_ICTL + 0x0038) + +#define NR_IRQS 64 + +/* IRQ mapping - these are our logical IRQ numbers */ +#define MPC5XXX_CRIT_IRQ_NUM 4 +#define MPC5XXX_MAIN_IRQ_NUM 17 +#define MPC5XXX_SDMA_IRQ_NUM 17 +#define MPC5XXX_PERP_IRQ_NUM 23 + +#define MPC5XXX_CRIT_IRQ_BASE 1 +#define MPC5XXX_MAIN_IRQ_BASE (MPC5XXX_CRIT_IRQ_BASE + MPC5XXX_CRIT_IRQ_NUM) +#define MPC5XXX_SDMA_IRQ_BASE (MPC5XXX_MAIN_IRQ_BASE + MPC5XXX_MAIN_IRQ_NUM) +#define MPC5XXX_PERP_IRQ_BASE (MPC5XXX_SDMA_IRQ_BASE + MPC5XXX_SDMA_IRQ_NUM) + +#define MPC5XXX_IRQ0 (MPC5XXX_CRIT_IRQ_BASE + 0) +#define MPC5XXX_SLICE_TIMER_0_IRQ (MPC5XXX_CRIT_IRQ_BASE + 1) +#define MPC5XXX_HI_INT_IRQ (MPC5XXX_CRIT_IRQ_BASE + 2) +#define MPC5XXX_CCS_IRQ (MPC5XXX_CRIT_IRQ_BASE + 3) + +#define MPC5XXX_IRQ1 (MPC5XXX_MAIN_IRQ_BASE + 1) +#define MPC5XXX_IRQ2 (MPC5XXX_MAIN_IRQ_BASE + 2) +#define MPC5XXX_IRQ3 (MPC5XXX_MAIN_IRQ_BASE + 3) +#define MPC5XXX_RTC_PINT_IRQ (MPC5XXX_MAIN_IRQ_BASE + 5) +#define MPC5XXX_RTC_SINT_IRQ (MPC5XXX_MAIN_IRQ_BASE + 6) +#define MPC5XXX_RTC_GPIO_STD_IRQ (MPC5XXX_MAIN_IRQ_BASE + 7) +#define MPC5XXX_RTC_GPIO_WKUP_IRQ (MPC5XXX_MAIN_IRQ_BASE + 8) +#define MPC5XXX_TMR0_IRQ (MPC5XXX_MAIN_IRQ_BASE + 9) +#define MPC5XXX_TMR1_IRQ (MPC5XXX_MAIN_IRQ_BASE + 10) +#define MPC5XXX_TMR2_IRQ (MPC5XXX_MAIN_IRQ_BASE + 11) +#define MPC5XXX_TMR3_IRQ (MPC5XXX_MAIN_IRQ_BASE + 12) +#define MPC5XXX_TMR4_IRQ (MPC5XXX_MAIN_IRQ_BASE + 13) +#define MPC5XXX_TMR5_IRQ (MPC5XXX_MAIN_IRQ_BASE + 14) +#define MPC5XXX_TMR6_IRQ (MPC5XXX_MAIN_IRQ_BASE + 15) +#define MPC5XXX_TMR7_IRQ (MPC5XXX_MAIN_IRQ_BASE + 16) + +#define MPC5XXX_SDMA_IRQ (MPC5XXX_PERP_IRQ_BASE + 0) +#define MPC5XXX_PSC1_IRQ (MPC5XXX_PERP_IRQ_BASE + 1) +#define MPC5XXX_PSC2_IRQ (MPC5XXX_PERP_IRQ_BASE + 2) +#define MPC5XXX_PSC3_IRQ (MPC5XXX_PERP_IRQ_BASE + 3) +#define MPC5XXX_PSC6_IRQ (MPC5XXX_PERP_IRQ_BASE + 4) +#define MPC5XXX_IRDA_IRQ (MPC5XXX_PERP_IRQ_BASE + 4) +#define MPC5XXX_FEC_IRQ (MPC5XXX_PERP_IRQ_BASE + 5) +#define MPC5XXX_USB_IRQ (MPC5XXX_PERP_IRQ_BASE + 6) +#define MPC5XXX_ATA_IRQ (MPC5XXX_PERP_IRQ_BASE + 7) +#define MPC5XXX_PCI_CNTRL_IRQ (MPC5XXX_PERP_IRQ_BASE + 8) +#define MPC5XXX_PCI_SCIRX_IRQ (MPC5XXX_PERP_IRQ_BASE + 9) +#define MPC5XXX_PCI_SCITX_IRQ (MPC5XXX_PERP_IRQ_BASE + 10) +#define MPC5XXX_PSC4_IRQ (MPC5XXX_PERP_IRQ_BASE + 11) +#define MPC5XXX_PSC5_IRQ (MPC5XXX_PERP_IRQ_BASE + 12) +#define MPC5XXX_SPI_MODF_IRQ (MPC5XXX_PERP_IRQ_BASE + 13) +#define MPC5XXX_SPI_SPIF_IRQ (MPC5XXX_PERP_IRQ_BASE + 14) +#define MPC5XXX_I2C1_IRQ (MPC5XXX_PERP_IRQ_BASE + 15) +#define MPC5XXX_I2C2_IRQ (MPC5XXX_PERP_IRQ_BASE + 16) +#define MPC5XXX_MSCAN1_IRQ (MPC5XXX_PERP_IRQ_BASE + 17) +#define MPC5XXX_MSCAN2_IRQ (MPC5XXX_PERP_IRQ_BASE + 18) +#define MPC5XXX_IR_RX_IRQ (MPC5XXX_PERP_IRQ_BASE + 19) +#define MPC5XXX_IR_TX_IRQ (MPC5XXX_PERP_IRQ_BASE + 20) +#define MPC5XXX_XLB_ARB_IRQ (MPC5XXX_PERP_IRQ_BASE + 21) +#define MPC5XXX_BDLC_IRQ (MPC5XXX_PERP_IRQ_BASE + 22) + +/* General Purpose Timers registers */ +#define MPC5XXX_GPT0_ENABLE (MPC5XXX_GPT + 0x0) +#define MPC5XXX_GPT0_COUNTER (MPC5XXX_GPT + 0x4) +#define MPC5XXX_GPT0_STATUS (MPC5XXX_GPT + 0x0C) +#define MPC5XXX_GPT1_ENABLE (MPC5XXX_GPT + 0x10) +#define MPC5XXX_GPT1_COUNTER (MPC5XXX_GPT + 0x14) +#define MPC5XXX_GPT1_STATUS (MPC5XXX_GPT + 0x1C) +#define MPC5XXX_GPT2_ENABLE (MPC5XXX_GPT + 0x20) +#define MPC5XXX_GPT2_COUNTER (MPC5XXX_GPT + 0x24) +#define MPC5XXX_GPT2_STATUS (MPC5XXX_GPT + 0x2C) +#define MPC5XXX_GPT3_ENABLE (MPC5XXX_GPT + 0x30) +#define MPC5XXX_GPT3_COUNTER (MPC5XXX_GPT + 0x34) +#define MPC5XXX_GPT3_STATUS (MPC5XXX_GPT + 0x3C) +#define MPC5XXX_GPT4_ENABLE (MPC5XXX_GPT + 0x40) +#define MPC5XXX_GPT4_COUNTER (MPC5XXX_GPT + 0x44) +#define MPC5XXX_GPT4_STATUS (MPC5XXX_GPT + 0x4C) +#define MPC5XXX_GPT5_ENABLE (MPC5XXX_GPT + 0x50) +#define MPC5XXX_GPT5_STATUS (MPC5XXX_GPT + 0x5C) +#define MPC5XXX_GPT5_COUNTER (MPC5XXX_GPT + 0x54) +#define MPC5XXX_GPT6_ENABLE (MPC5XXX_GPT + 0x60) +#define MPC5XXX_GPT6_COUNTER (MPC5XXX_GPT + 0x64) +#define MPC5XXX_GPT6_STATUS (MPC5XXX_GPT + 0x6C) +#define MPC5XXX_GPT7_ENABLE (MPC5XXX_GPT + 0x70) +#define MPC5XXX_GPT7_COUNTER (MPC5XXX_GPT + 0x74) +#define MPC5XXX_GPT7_STATUS (MPC5XXX_GPT + 0x7C) + +#define MPC5XXX_GPT_GPIO_PIN(status) ((0x00000100 & (status)) >> 8) + +#define MPC5XXX_GPT7_PWMCFG (MPC5XXX_GPT + 0x78) + +/* ATA registers */ +#define MPC5XXX_ATA_HOST_CONFIG (MPC5XXX_ATA + 0x0000) +#define MPC5XXX_ATA_PIO1 (MPC5XXX_ATA + 0x0008) +#define MPC5XXX_ATA_PIO2 (MPC5XXX_ATA + 0x000C) +#define MPC5XXX_ATA_SHARE_COUNT (MPC5XXX_ATA + 0x002C) + +/* I2Cn control register bits */ +#define I2C_EN 0x80 +#define I2C_IEN 0x40 +#define I2C_STA 0x20 +#define I2C_TX 0x10 +#define I2C_TXAK 0x08 +#define I2C_RSTA 0x04 +#define I2C_INIT_MASK (I2C_EN | I2C_STA | I2C_TX | I2C_RSTA) + +/* I2Cn status register bits */ +#define I2C_CF 0x80 +#define I2C_AAS 0x40 +#define I2C_BB 0x20 +#define I2C_AL 0x10 +#define I2C_SRW 0x04 +#define I2C_IF 0x02 +#define I2C_RXAK 0x01 + +/* Programmable Serial Controller (PSC) status register bits */ +#define PSC_SR_CDE 0x0080 +#define PSC_SR_RXRDY 0x0100 +#define PSC_SR_RXFULL 0x0200 +#define PSC_SR_TXRDY 0x0400 +#define PSC_SR_TXEMP 0x0800 +#define PSC_SR_OE 0x1000 +#define PSC_SR_PE 0x2000 +#define PSC_SR_FE 0x4000 +#define PSC_SR_RB 0x8000 + +/* PSC Command values */ +#define PSC_RX_ENABLE 0x0001 +#define PSC_RX_DISABLE 0x0002 +#define PSC_TX_ENABLE 0x0004 +#define PSC_TX_DISABLE 0x0008 +#define PSC_SEL_MODE_REG_1 0x0010 +#define PSC_RST_RX 0x0020 +#define PSC_RST_TX 0x0030 +#define PSC_RST_ERR_STAT 0x0040 +#define PSC_RST_BRK_CHG_INT 0x0050 +#define PSC_START_BRK 0x0060 +#define PSC_STOP_BRK 0x0070 + +/* PSC Rx FIFO status bits */ +#define PSC_RX_FIFO_ERR 0x0040 +#define PSC_RX_FIFO_UF 0x0020 +#define PSC_RX_FIFO_OF 0x0010 +#define PSC_RX_FIFO_FR 0x0008 +#define PSC_RX_FIFO_FULL 0x0004 +#define PSC_RX_FIFO_ALARM 0x0002 +#define PSC_RX_FIFO_EMPTY 0x0001 + +/* PSC interrupt mask bits */ +#define PSC_IMR_TXRDY 0x0100 +#define PSC_IMR_RXRDY 0x0200 +#define PSC_IMR_DB 0x0400 +#define PSC_IMR_IPC 0x8000 + +/* PSC input port change bits */ +#define PSC_IPCR_CTS 0x01 +#define PSC_IPCR_DCD 0x02 + +/* PSC mode fields */ +#define PSC_MODE_5_BITS 0x00 +#define PSC_MODE_6_BITS 0x01 +#define PSC_MODE_7_BITS 0x02 +#define PSC_MODE_8_BITS 0x03 +#define PSC_MODE_PAREVEN 0x00 +#define PSC_MODE_PARODD 0x04 +#define PSC_MODE_PARFORCE 0x08 +#define PSC_MODE_PARNONE 0x10 +#define PSC_MODE_ERR 0x20 +#define PSC_MODE_FFULL 0x40 +#define PSC_MODE_RXRTS 0x80 + +#define PSC_MODE_ONE_STOP_5_BITS 0x00 +#define PSC_MODE_ONE_STOP 0x07 +#define PSC_MODE_TWO_STOP 0x0f + +/* ATA config fields */ +#define MPC5xxx_ATA_HOSTCONF_SMR 0x80000000UL /* State machine + reset */ +#define MPC5xxx_ATA_HOSTCONF_FR 0x40000000UL /* FIFO Reset */ +#define MPC5xxx_ATA_HOSTCONF_IE 0x02000000UL /* Enable interrupt + in PIO */ +#define MPC5xxx_ATA_HOSTCONF_IORDY 0x01000000UL /* Drive supports + IORDY protocol */ + +#ifndef __ASSEMBLY__ +struct mpc5xxx_psc { + volatile u8 mode; /* PSC + 0x00 */ + volatile u8 reserved0[3]; + union { /* PSC + 0x04 */ + volatile u16 status; + volatile u16 clock_select; + } sr_csr; +#define psc_status sr_csr.status +#define psc_clock_select sr_csr.clock_select + volatile u16 reserved1; + volatile u8 command; /* PSC + 0x08 */ + volatile u8 reserved2[3]; + union { /* PSC + 0x0c */ + volatile u8 buffer_8; + volatile u16 buffer_16; + volatile u32 buffer_32; + } buffer; +#define psc_buffer_8 buffer.buffer_8 +#define psc_buffer_16 buffer.buffer_16 +#define psc_buffer_32 buffer.buffer_32 + union { /* PSC + 0x10 */ + volatile u8 ipcr; + volatile u8 acr; + } ipcr_acr; +#define psc_ipcr ipcr_acr.ipcr +#define psc_acr ipcr_acr.acr + volatile u8 reserved3[3]; + union { /* PSC + 0x14 */ + volatile u16 isr; + volatile u16 imr; + } isr_imr; +#define psc_isr isr_imr.isr +#define psc_imr isr_imr.imr + volatile u16 reserved4; + volatile u8 ctur; /* PSC + 0x18 */ + volatile u8 reserved5[3]; + volatile u8 ctlr; /* PSC + 0x1c */ + volatile u8 reserved6[3]; + volatile u16 ccr; /* PSC + 0x20 */ + volatile u8 reserved7[14]; + volatile u8 ivr; /* PSC + 0x30 */ + volatile u8 reserved8[3]; + volatile u8 ip; /* PSC + 0x34 */ + volatile u8 reserved9[3]; + volatile u8 op1; /* PSC + 0x38 */ + volatile u8 reserved10[3]; + volatile u8 op0; /* PSC + 0x3c */ + volatile u8 reserved11[3]; + volatile u32 sicr; /* PSC + 0x40 */ + volatile u8 ircr1; /* PSC + 0x44 */ + volatile u8 reserved12[3]; + volatile u8 ircr2; /* PSC + 0x44 */ + volatile u8 reserved13[3]; + volatile u8 irsdr; /* PSC + 0x4c */ + volatile u8 reserved14[3]; + volatile u8 irmdr; /* PSC + 0x50 */ + volatile u8 reserved15[3]; + volatile u8 irfdr; /* PSC + 0x54 */ + volatile u8 reserved16[3]; + volatile u16 rfnum; /* PSC + 0x58 */ + volatile u16 reserved17; + volatile u16 tfnum; /* PSC + 0x5c */ + volatile u16 reserved18; + volatile u32 rfdata; /* PSC + 0x60 */ + volatile u16 rfstat; /* PSC + 0x64 */ + volatile u16 reserved20; + volatile u8 rfcntl; /* PSC + 0x68 */ + volatile u8 reserved21[5]; + volatile u16 rfalarm; /* PSC + 0x6e */ + volatile u16 reserved22; + volatile u16 rfrptr; /* PSC + 0x72 */ + volatile u16 reserved23; + volatile u16 rfwptr; /* PSC + 0x76 */ + volatile u16 reserved24; + volatile u16 rflrfptr; /* PSC + 0x7a */ + volatile u16 reserved25; + volatile u16 rflwfptr; /* PSC + 0x7e */ + volatile u32 tfdata; /* PSC + 0x80 */ + volatile u16 tfstat; /* PSC + 0x84 */ + volatile u16 reserved26; + volatile u8 tfcntl; /* PSC + 0x88 */ + volatile u8 reserved27[5]; + volatile u16 tfalarm; /* PSC + 0x8e */ + volatile u16 reserved28; + volatile u16 tfrptr; /* PSC + 0x92 */ + volatile u16 reserved29; + volatile u16 tfwptr; /* PSC + 0x96 */ + volatile u16 reserved30; + volatile u16 tflrfptr; /* PSC + 0x9a */ + volatile u16 reserved31; + volatile u16 tflwfptr; /* PSC + 0x9e */ +}; + +struct mpc5xxx_intr { + volatile u32 per_mask; /* INTR + 0x00 */ + volatile u32 per_pri1; /* INTR + 0x04 */ + volatile u32 per_pri2; /* INTR + 0x08 */ + volatile u32 per_pri3; /* INTR + 0x0c */ + volatile u32 ctrl; /* INTR + 0x10 */ + volatile u32 main_mask; /* INTR + 0x14 */ + volatile u32 main_pri1; /* INTR + 0x18 */ + volatile u32 main_pri2; /* INTR + 0x1c */ + volatile u32 reserved1; /* INTR + 0x20 */ + volatile u32 enc_status; /* INTR + 0x24 */ + volatile u32 crit_status; /* INTR + 0x28 */ + volatile u32 main_status; /* INTR + 0x2c */ + volatile u32 per_status; /* INTR + 0x30 */ + volatile u32 reserved2; /* INTR + 0x34 */ + volatile u32 per_error; /* INTR + 0x38 */ +}; + +struct mpc5xxx_gpio { + volatile u32 port_config; /* GPIO + 0x00 */ + volatile u32 simple_gpioe; /* GPIO + 0x04 */ + volatile u32 simple_ode; /* GPIO + 0x08 */ + volatile u32 simple_ddr; /* GPIO + 0x0c */ + volatile u32 simple_dvo; /* GPIO + 0x10 */ + volatile u32 simple_ival; /* GPIO + 0x14 */ + volatile u8 outo_gpioe; /* GPIO + 0x18 */ + volatile u8 reserved1[3]; /* GPIO + 0x19 */ + volatile u8 outo_dvo; /* GPIO + 0x1c */ + volatile u8 reserved2[3]; /* GPIO + 0x1d */ + volatile u8 sint_gpioe; /* GPIO + 0x20 */ + volatile u8 reserved3[3]; /* GPIO + 0x21 */ + volatile u8 sint_ode; /* GPIO + 0x24 */ + volatile u8 reserved4[3]; /* GPIO + 0x25 */ + volatile u8 sint_ddr; /* GPIO + 0x28 */ + volatile u8 reserved5[3]; /* GPIO + 0x29 */ + volatile u8 sint_dvo; /* GPIO + 0x2c */ + volatile u8 reserved6[3]; /* GPIO + 0x2d */ + volatile u8 sint_inten; /* GPIO + 0x30 */ + volatile u8 reserved7[3]; /* GPIO + 0x31 */ + volatile u16 sint_itype; /* GPIO + 0x34 */ + volatile u16 reserved8; /* GPIO + 0x36 */ + volatile u8 gpio_control; /* GPIO + 0x38 */ + volatile u8 reserved9[3]; /* GPIO + 0x39 */ + volatile u8 sint_istat; /* GPIO + 0x3c */ + volatile u8 sint_ival; /* GPIO + 0x3d */ + volatile u8 bus_errs; /* GPIO + 0x3e */ + volatile u8 reserved10; /* GPIO + 0x3f */ +}; + +struct mpc5xxx_sdma { + volatile u32 taskBar; /* SDMA + 0x00 */ + volatile u32 currentPointer; /* SDMA + 0x04 */ + volatile u32 endPointer; /* SDMA + 0x08 */ + volatile u32 variablePointer; /* SDMA + 0x0c */ + + volatile u8 IntVect1; /* SDMA + 0x10 */ + volatile u8 IntVect2; /* SDMA + 0x11 */ + volatile u16 PtdCntrl; /* SDMA + 0x12 */ + + volatile u32 IntPend; /* SDMA + 0x14 */ + volatile u32 IntMask; /* SDMA + 0x18 */ + + volatile u16 tcr_0; /* SDMA + 0x1c */ + volatile u16 tcr_1; /* SDMA + 0x1e */ + volatile u16 tcr_2; /* SDMA + 0x20 */ + volatile u16 tcr_3; /* SDMA + 0x22 */ + volatile u16 tcr_4; /* SDMA + 0x24 */ + volatile u16 tcr_5; /* SDMA + 0x26 */ + volatile u16 tcr_6; /* SDMA + 0x28 */ + volatile u16 tcr_7; /* SDMA + 0x2a */ + volatile u16 tcr_8; /* SDMA + 0x2c */ + volatile u16 tcr_9; /* SDMA + 0x2e */ + volatile u16 tcr_a; /* SDMA + 0x30 */ + volatile u16 tcr_b; /* SDMA + 0x32 */ + volatile u16 tcr_c; /* SDMA + 0x34 */ + volatile u16 tcr_d; /* SDMA + 0x36 */ + volatile u16 tcr_e; /* SDMA + 0x38 */ + volatile u16 tcr_f; /* SDMA + 0x3a */ + + volatile u8 IPR0; /* SDMA + 0x3c */ + volatile u8 IPR1; /* SDMA + 0x3d */ + volatile u8 IPR2; /* SDMA + 0x3e */ + volatile u8 IPR3; /* SDMA + 0x3f */ + volatile u8 IPR4; /* SDMA + 0x40 */ + volatile u8 IPR5; /* SDMA + 0x41 */ + volatile u8 IPR6; /* SDMA + 0x42 */ + volatile u8 IPR7; /* SDMA + 0x43 */ + volatile u8 IPR8; /* SDMA + 0x44 */ + volatile u8 IPR9; /* SDMA + 0x45 */ + volatile u8 IPR10; /* SDMA + 0x46 */ + volatile u8 IPR11; /* SDMA + 0x47 */ + volatile u8 IPR12; /* SDMA + 0x48 */ + volatile u8 IPR13; /* SDMA + 0x49 */ + volatile u8 IPR14; /* SDMA + 0x4a */ + volatile u8 IPR15; /* SDMA + 0x4b */ + volatile u8 IPR16; /* SDMA + 0x4c */ + volatile u8 IPR17; /* SDMA + 0x4d */ + volatile u8 IPR18; /* SDMA + 0x4e */ + volatile u8 IPR19; /* SDMA + 0x4f */ + volatile u8 IPR20; /* SDMA + 0x50 */ + volatile u8 IPR21; /* SDMA + 0x51 */ + volatile u8 IPR22; /* SDMA + 0x52 */ + volatile u8 IPR23; /* SDMA + 0x53 */ + volatile u8 IPR24; /* SDMA + 0x54 */ + volatile u8 IPR25; /* SDMA + 0x55 */ + volatile u8 IPR26; /* SDMA + 0x56 */ + volatile u8 IPR27; /* SDMA + 0x57 */ + volatile u8 IPR28; /* SDMA + 0x58 */ + volatile u8 IPR29; /* SDMA + 0x59 */ + volatile u8 IPR30; /* SDMA + 0x5a */ + volatile u8 IPR31; /* SDMA + 0x5b */ + + volatile u32 res1; /* SDMA + 0x5c */ + volatile u32 res2; /* SDMA + 0x60 */ + volatile u32 res3; /* SDMA + 0x64 */ + volatile u32 MDEDebug; /* SDMA + 0x68 */ + volatile u32 ADSDebug; /* SDMA + 0x6c */ + volatile u32 Value1; /* SDMA + 0x70 */ + volatile u32 Value2; /* SDMA + 0x74 */ + volatile u32 Control; /* SDMA + 0x78 */ + volatile u32 Status; /* SDMA + 0x7c */ + volatile u32 EU00; /* SDMA + 0x80 */ + volatile u32 EU01; /* SDMA + 0x84 */ + volatile u32 EU02; /* SDMA + 0x88 */ + volatile u32 EU03; /* SDMA + 0x8c */ + volatile u32 EU04; /* SDMA + 0x90 */ + volatile u32 EU05; /* SDMA + 0x94 */ + volatile u32 EU06; /* SDMA + 0x98 */ + volatile u32 EU07; /* SDMA + 0x9c */ + volatile u32 EU10; /* SDMA + 0xa0 */ + volatile u32 EU11; /* SDMA + 0xa4 */ + volatile u32 EU12; /* SDMA + 0xa8 */ + volatile u32 EU13; /* SDMA + 0xac */ + volatile u32 EU14; /* SDMA + 0xb0 */ + volatile u32 EU15; /* SDMA + 0xb4 */ + volatile u32 EU16; /* SDMA + 0xb8 */ + volatile u32 EU17; /* SDMA + 0xbc */ + volatile u32 EU20; /* SDMA + 0xc0 */ + volatile u32 EU21; /* SDMA + 0xc4 */ + volatile u32 EU22; /* SDMA + 0xc8 */ + volatile u32 EU23; /* SDMA + 0xcc */ + volatile u32 EU24; /* SDMA + 0xd0 */ + volatile u32 EU25; /* SDMA + 0xd4 */ + volatile u32 EU26; /* SDMA + 0xd8 */ + volatile u32 EU27; /* SDMA + 0xdc */ + volatile u32 EU30; /* SDMA + 0xe0 */ + volatile u32 EU31; /* SDMA + 0xe4 */ + volatile u32 EU32; /* SDMA + 0xe8 */ + volatile u32 EU33; /* SDMA + 0xec */ + volatile u32 EU34; /* SDMA + 0xf0 */ + volatile u32 EU35; /* SDMA + 0xf4 */ + volatile u32 EU36; /* SDMA + 0xf8 */ + volatile u32 EU37; /* SDMA + 0xfc */ +}; + +struct mpc5xxx_i2c { + volatile u32 madr; /* I2Cn + 0x00 */ + volatile u32 mfdr; /* I2Cn + 0x04 */ + volatile u32 mcr; /* I2Cn + 0x08 */ + volatile u32 msr; /* I2Cn + 0x0C */ + volatile u32 mdr; /* I2Cn + 0x10 */ +}; + +struct mpc5xxx_spi { + volatile u8 cr1; /* SPI + 0x0F00 */ + volatile u8 cr2; /* SPI + 0x0F01 */ + volatile u8 reserved1[2]; + volatile u8 brr; /* SPI + 0x0F04 */ + volatile u8 sr; /* SPI + 0x0F05 */ + volatile u8 reserved2[3]; + volatile u8 dr; /* SPI + 0x0F09 */ + volatile u8 reserved3[3]; + volatile u8 pdr; /* SPI + 0x0F0D */ + volatile u8 reserved4[2]; + volatile u8 ddr; /* SPI + 0x0F10 */ +}; + + +struct mpc5xxx_gpt { + volatile u32 emsr; /* GPT + Timer# * 0x10 + 0x00 */ + volatile u32 cir; /* GPT + Timer# * 0x10 + 0x04 */ + volatile u32 pwmcr; /* GPT + Timer# * 0x10 + 0x08 */ + volatile u32 sr; /* GPT + Timer# * 0x10 + 0x0c */ +}; + +struct mpc5xxx_gpt_0_7 { + struct mpc5xxx_gpt gpt0; + struct mpc5xxx_gpt gpt1; + struct mpc5xxx_gpt gpt2; + struct mpc5xxx_gpt gpt3; + struct mpc5xxx_gpt gpt4; + struct mpc5xxx_gpt gpt5; + struct mpc5xxx_gpt gpt6; + struct mpc5xxx_gpt gpt7; +}; + +struct mscan_buffer { + volatile u8 idr[0x8]; /* 0x00 */ + volatile u8 dsr[0x10]; /* 0x08 */ + volatile u8 dlr; /* 0x18 */ + volatile u8 tbpr; /* 0x19 */ /* This register is not applicable for receive buffers */ + volatile u16 rsrv1; /* 0x1A */ + volatile u8 tsrh; /* 0x1C */ + volatile u8 tsrl; /* 0x1D */ + volatile u16 rsrv2; /* 0x1E */ +}; + +struct mpc5xxx_mscan { + volatile u8 canctl0; /* MSCAN + 0x00 */ + volatile u8 canctl1; /* MSCAN + 0x01 */ + volatile u16 rsrv1; /* MSCAN + 0x02 */ + volatile u8 canbtr0; /* MSCAN + 0x04 */ + volatile u8 canbtr1; /* MSCAN + 0x05 */ + volatile u16 rsrv2; /* MSCAN + 0x06 */ + volatile u8 canrflg; /* MSCAN + 0x08 */ + volatile u8 canrier; /* MSCAN + 0x09 */ + volatile u16 rsrv3; /* MSCAN + 0x0A */ + volatile u8 cantflg; /* MSCAN + 0x0C */ + volatile u8 cantier; /* MSCAN + 0x0D */ + volatile u16 rsrv4; /* MSCAN + 0x0E */ + volatile u8 cantarq; /* MSCAN + 0x10 */ + volatile u8 cantaak; /* MSCAN + 0x11 */ + volatile u16 rsrv5; /* MSCAN + 0x12 */ + volatile u8 cantbsel; /* MSCAN + 0x14 */ + volatile u8 canidac; /* MSCAN + 0x15 */ + volatile u16 rsrv6[3]; /* MSCAN + 0x16 */ + volatile u8 canrxerr; /* MSCAN + 0x1C */ + volatile u8 cantxerr; /* MSCAN + 0x1D */ + volatile u16 rsrv7; /* MSCAN + 0x1E */ + volatile u8 canidar0; /* MSCAN + 0x20 */ + volatile u8 canidar1; /* MSCAN + 0x21 */ + volatile u16 rsrv8; /* MSCAN + 0x22 */ + volatile u8 canidar2; /* MSCAN + 0x24 */ + volatile u8 canidar3; /* MSCAN + 0x25 */ + volatile u16 rsrv9; /* MSCAN + 0x26 */ + volatile u8 canidmr0; /* MSCAN + 0x28 */ + volatile u8 canidmr1; /* MSCAN + 0x29 */ + volatile u16 rsrv10; /* MSCAN + 0x2A */ + volatile u8 canidmr2; /* MSCAN + 0x2C */ + volatile u8 canidmr3; /* MSCAN + 0x2D */ + volatile u16 rsrv11; /* MSCAN + 0x2E */ + volatile u8 canidar4; /* MSCAN + 0x30 */ + volatile u8 canidar5; /* MSCAN + 0x31 */ + volatile u16 rsrv12; /* MSCAN + 0x32 */ + volatile u8 canidar6; /* MSCAN + 0x34 */ + volatile u8 canidar7; /* MSCAN + 0x35 */ + volatile u16 rsrv13; /* MSCAN + 0x36 */ + volatile u8 canidmr4; /* MSCAN + 0x38 */ + volatile u8 canidmr5; /* MSCAN + 0x39 */ + volatile u16 rsrv14; /* MSCAN + 0x3A */ + volatile u8 canidmr6; /* MSCAN + 0x3C */ + volatile u8 canidmr7; /* MSCAN + 0x3D */ + volatile u16 rsrv15; /* MSCAN + 0x3E */ + + struct mscan_buffer canrxfg; /* MSCAN + 0x40 */ /* Foreground receive buffer */ + struct mscan_buffer cantxfg; /* MSCAN + 0x60 */ /* Foreground transmit buffer */ + }; + +/* function prototypes */ +void loadtask(int basetask, int tasks); + +#endif /* __ASSEMBLY__ */ + +#endif /* __ASMPPC_MPC5XXX_H */ diff --git a/include/common.h b/include/common.h index 402f8e852f..0e91cbe43b 100644 --- a/include/common.h +++ b/include/common.h @@ -74,14 +74,7 @@ typedef void (interrupt_handler_t)(void *); * Function Prototypes */ void do_reset(void); - -#ifdef CONFIG_SERIAL_SOFTWARE_FIFO -void serial_buffered_init (void); -void serial_buffered_putc (const char); -void serial_buffered_puts (const char *); -int serial_buffered_getc (void); -int serial_buffered_tstc (void); -#endif /* CONFIG_SERIAL_SOFTWARE_FIFO */ +void reginfo(void); void hang (void) __attribute__ ((noreturn)); diff --git a/include/mpc5xxx.h b/include/mpc5xxx.h deleted file mode 100644 index 089aa1322b..0000000000 --- a/include/mpc5xxx.h +++ /dev/null @@ -1,781 +0,0 @@ -/* - * include/asm-ppc/mpc5xxx.h - * - * Prototypes, etc. for the Motorola MGT5xxx/MPC5xxx - * embedded cpu chips - * - * 2003 (c) MontaVista, Software, Inc. - * Author: Dale Farnsworth - * - * 2003 (C) 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 - */ -#ifndef __ASMPPC_MPC5XXX_H -#define __ASMPPC_MPC5XXX_H - -/* Processor name */ -#if defined(CONFIG_MPC5200) -#define CPU_ID_STR "MPC5200" -#elif defined(CONFIG_MGT5100) -#define CPU_ID_STR "MGT5100" -#endif - -/* Exception offsets (PowerPC standard) */ -#define EXC_OFF_SYS_RESET 0x0100 - -/* useful macros for manipulating CSx_START/STOP */ -#if defined(CONFIG_MGT5100) -#define START_REG(start) ((start) >> 15) -#define STOP_REG(start, size) (((start) + (size) - 1) >> 15) -#elif defined(CONFIG_MPC5200) -#define START_REG(start) ((start) >> 16) -#define STOP_REG(start, size) (((start) + (size) - 1) >> 16) -#endif - -/* Internal memory map */ - -#define MPC5XXX_CS0_START (CFG_MBAR + 0x0004) -#define MPC5XXX_CS0_STOP (CFG_MBAR + 0x0008) -#define MPC5XXX_CS1_START (CFG_MBAR + 0x000c) -#define MPC5XXX_CS1_STOP (CFG_MBAR + 0x0010) -#define MPC5XXX_CS2_START (CFG_MBAR + 0x0014) -#define MPC5XXX_CS2_STOP (CFG_MBAR + 0x0018) -#define MPC5XXX_CS3_START (CFG_MBAR + 0x001c) -#define MPC5XXX_CS3_STOP (CFG_MBAR + 0x0020) -#define MPC5XXX_CS4_START (CFG_MBAR + 0x0024) -#define MPC5XXX_CS4_STOP (CFG_MBAR + 0x0028) -#define MPC5XXX_CS5_START (CFG_MBAR + 0x002c) -#define MPC5XXX_CS5_STOP (CFG_MBAR + 0x0030) -#define MPC5XXX_BOOTCS_START (CFG_MBAR + 0x004c) -#define MPC5XXX_BOOTCS_STOP (CFG_MBAR + 0x0050) -#define MPC5XXX_ADDECR (CFG_MBAR + 0x0054) - -#if defined(CONFIG_MGT5100) -#define MPC5XXX_SDRAM_START (CFG_MBAR + 0x0034) -#define MPC5XXX_SDRAM_STOP (CFG_MBAR + 0x0038) -#define MPC5XXX_PCI1_START (CFG_MBAR + 0x003c) -#define MPC5XXX_PCI1_STOP (CFG_MBAR + 0x0040) -#define MPC5XXX_PCI2_START (CFG_MBAR + 0x0044) -#define MPC5XXX_PCI2_STOP (CFG_MBAR + 0x0048) -#elif defined(CONFIG_MPC5200) -#define MPC5XXX_CS6_START (CFG_MBAR + 0x0058) -#define MPC5XXX_CS6_STOP (CFG_MBAR + 0x005c) -#define MPC5XXX_CS7_START (CFG_MBAR + 0x0060) -#define MPC5XXX_CS7_STOP (CFG_MBAR + 0x0064) -#define MPC5XXX_SDRAM_CS0CFG (CFG_MBAR + 0x0034) -#define MPC5XXX_SDRAM_CS1CFG (CFG_MBAR + 0x0038) -#endif - -#define MPC5XXX_SDRAM (CFG_MBAR + 0x0100) -#define MPC5XXX_CDM (CFG_MBAR + 0x0200) -#define MPC5XXX_LPB (CFG_MBAR + 0x0300) -#define MPC5XXX_ICTL (CFG_MBAR + 0x0500) -#define MPC5XXX_GPT (CFG_MBAR + 0x0600) -#define MPC5XXX_GPIO (CFG_MBAR + 0x0b00) -#define MPC5XXX_WU_GPIO (CFG_MBAR + 0x0c00) -#define MPC5XXX_PCI (CFG_MBAR + 0x0d00) -#define MPC5XXX_SPI (CFG_MBAR + 0x0f00) -#define MPC5XXX_USB (CFG_MBAR + 0x1000) -#define MPC5XXX_SDMA (CFG_MBAR + 0x1200) -#define MPC5XXX_XLBARB (CFG_MBAR + 0x1f00) - -#if defined(CONFIG_MGT5100) -#define MPC5XXX_PSC1 (CFG_MBAR + 0x2000) -#define MPC5XXX_PSC2 (CFG_MBAR + 0x2400) -#define MPC5XXX_PSC3 (CFG_MBAR + 0x2800) -#elif defined(CONFIG_MPC5200) -#define MPC5XXX_PSC1 (CFG_MBAR + 0x2000) -#define MPC5XXX_PSC2 (CFG_MBAR + 0x2200) -#define MPC5XXX_PSC3 (CFG_MBAR + 0x2400) -#define MPC5XXX_PSC4 (CFG_MBAR + 0x2600) -#define MPC5XXX_PSC5 (CFG_MBAR + 0x2800) -#define MPC5XXX_PSC6 (CFG_MBAR + 0x2c00) -#endif - -#define MPC5XXX_FEC (CFG_MBAR + 0x3000) -#define MPC5XXX_ATA (CFG_MBAR + 0x3A00) - -#define MPC5XXX_I2C1 (CFG_MBAR + 0x3D00) -#define MPC5XXX_I2C2 (CFG_MBAR + 0x3D40) - -#if defined(CONFIG_MGT5100) -#define MPC5XXX_SRAM (CFG_MBAR + 0x4000) -#define MPC5XXX_SRAM_SIZE (8*1024) -#elif defined(CONFIG_MPC5200) -#define MPC5XXX_SRAM (CFG_MBAR + 0x8000) -#define MPC5XXX_SRAM_SIZE (16*1024) -#endif - -/* SDRAM Controller */ -#define MPC5XXX_SDRAM_MODE (MPC5XXX_SDRAM + 0x0000) -#define MPC5XXX_SDRAM_CTRL (MPC5XXX_SDRAM + 0x0004) -#define MPC5XXX_SDRAM_CONFIG1 (MPC5XXX_SDRAM + 0x0008) -#define MPC5XXX_SDRAM_CONFIG2 (MPC5XXX_SDRAM + 0x000c) -#if defined(CONFIG_MGT5100) -#define MPC5XXX_SDRAM_XLBSEL (MPC5XXX_SDRAM + 0x0010) -#endif -#define MPC5XXX_SDRAM_SDELAY (MPC5XXX_SDRAM + 0x0090) - -/* Clock Distribution Module */ -#define MPC5XXX_CDM_JTAGID (MPC5XXX_CDM + 0x0000) -#define MPC5XXX_CDM_PORCFG (MPC5XXX_CDM + 0x0004) -#define MPC5XXX_CDM_CFG (MPC5XXX_CDM + 0x000c) -#define MPC5XXX_CDM_48_FDC (MPC5XXX_CDM + 0x0010) -#define MPC5XXX_CDM_SRESET (MPC5XXX_CDM + 0x0020) - -/* Local Plus Bus interface */ -#define MPC5XXX_CS0_CFG (MPC5XXX_LPB + 0x0000) -#define MPC5XXX_CS1_CFG (MPC5XXX_LPB + 0x0004) -#define MPC5XXX_CS2_CFG (MPC5XXX_LPB + 0x0008) -#define MPC5XXX_CS3_CFG (MPC5XXX_LPB + 0x000c) -#define MPC5XXX_CS4_CFG (MPC5XXX_LPB + 0x0010) -#define MPC5XXX_CS5_CFG (MPC5XXX_LPB + 0x0014) -#define MPC5XXX_BOOTCS_CFG MPC5XXX_CS0_CFG -#define MPC5XXX_CS_CTRL (MPC5XXX_LPB + 0x0018) -#define MPC5XXX_CS_STATUS (MPC5XXX_LPB + 0x001c) -#if defined(CONFIG_MPC5200) -#define MPC5XXX_CS6_CFG (MPC5XXX_LPB + 0x0020) -#define MPC5XXX_CS7_CFG (MPC5XXX_LPB + 0x0024) -#define MPC5XXX_CS_BURST (MPC5XXX_LPB + 0x0028) -#define MPC5XXX_CS_DEADCYCLE (MPC5XXX_LPB + 0x002c) -#endif - -#if defined(CONFIG_MPC5200) -/* XLB Arbiter registers */ -#define MPC5XXX_XLBARB_CFG (MPC5XXX_XLBARB + 0x40) -#define MPC5XXX_XLBARB_MPRIEN (MPC5XXX_XLBARB + 0x64) -#define MPC5XXX_XLBARB_MPRIVAL (MPC5XXX_XLBARB + 0x68) -#endif - -/* GPIO registers */ -#define MPC5XXX_GPS_PORT_CONFIG (MPC5XXX_GPIO + 0x0000) - -/* Standard GPIO registers (simple, output only and simple interrupt */ -#define MPC5XXX_GPIO_ENABLE (MPC5XXX_GPIO + 0x0004) -#define MPC5XXX_GPIO_ODE (MPC5XXX_GPIO + 0x0008) -#define MPC5XXX_GPIO_DIR (MPC5XXX_GPIO + 0x000c) -#define MPC5XXX_GPIO_DATA_O (MPC5XXX_GPIO + 0x0010) -#define MPC5XXX_GPIO_DATA_I (MPC5XXX_GPIO + 0x0014) -#define MPC5XXX_GPIO_OO_ENABLE (MPC5XXX_GPIO + 0x0018) -#define MPC5XXX_GPIO_OO_DATA (MPC5XXX_GPIO + 0x001C) -#define MPC5XXX_GPIO_SI_ENABLE (MPC5XXX_GPIO + 0x0020) -#define MPC5XXX_GPIO_SI_ODE (MPC5XXX_GPIO + 0x0024) -#define MPC5XXX_GPIO_SI_DIR (MPC5XXX_GPIO + 0x0028) -#define MPC5XXX_GPIO_SI_DATA (MPC5XXX_GPIO + 0x002C) -#define MPC5XXX_GPIO_SI_IEN (MPC5XXX_GPIO + 0x0030) -#define MPC5XXX_GPIO_SI_ITYPE (MPC5XXX_GPIO + 0x0034) -#define MPC5XXX_GPIO_SI_MEN (MPC5XXX_GPIO + 0x0038) -#define MPC5XXX_GPIO_SI_STATUS (MPC5XXX_GPIO + 0x003C) - -/* WakeUp GPIO registers */ -#define MPC5XXX_WU_GPIO_ENABLE (MPC5XXX_WU_GPIO + 0x0000) -#define MPC5XXX_WU_GPIO_ODE (MPC5XXX_WU_GPIO + 0x0004) -#define MPC5XXX_WU_GPIO_DIR (MPC5XXX_WU_GPIO + 0x0008) -#define MPC5XXX_WU_GPIO_DATA_O (MPC5XXX_WU_GPIO + 0x000c) -#define MPC5XXX_WU_GPIO_DATA_I (MPC5XXX_WU_GPIO + 0x0020) - -/* GPIO pins */ -#define GPIO_WKUP_7 0x80000000UL -#define GPIO_PSC6_0 0x10000000UL -#define GPIO_PSC3_9 0x04000000UL -#define GPIO_PSC1_4 0x01000000UL - -/* PCI registers */ -#define MPC5XXX_PCI_CMD (MPC5XXX_PCI + 0x04) -#define MPC5XXX_PCI_CFG (MPC5XXX_PCI + 0x0c) -#define MPC5XXX_PCI_BAR0 (MPC5XXX_PCI + 0x10) -#define MPC5XXX_PCI_BAR1 (MPC5XXX_PCI + 0x14) -#if defined(CONFIG_MGT5100) -#define MPC5XXX_PCI_CTRL (MPC5XXX_PCI + 0x68) -#define MPC5XXX_PCI_VALMSKR (MPC5XXX_PCI + 0x6c) -#define MPC5XXX_PCI_VALMSKW (MPC5XXX_PCI + 0x70) -#define MPC5XXX_PCI_SUBW1 (MPC5XXX_PCI + 0x74) -#define MPC5XXX_PCI_SUBW2 (MPC5XXX_PCI + 0x78) -#define MPC5XXX_PCI_WINCOMMAND (MPC5XXX_PCI + 0x7c) -#elif defined(CONFIG_MPC5200) -#define MPC5XXX_PCI_GSCR (MPC5XXX_PCI + 0x60) -#define MPC5XXX_PCI_TBATR0 (MPC5XXX_PCI + 0x64) -#define MPC5XXX_PCI_TBATR1 (MPC5XXX_PCI + 0x68) -#define MPC5XXX_PCI_TCR (MPC5XXX_PCI + 0x6c) -#define MPC5XXX_PCI_IW0BTAR (MPC5XXX_PCI + 0x70) -#define MPC5XXX_PCI_IW1BTAR (MPC5XXX_PCI + 0x74) -#define MPC5XXX_PCI_IW2BTAR (MPC5XXX_PCI + 0x78) -#define MPC5XXX_PCI_IWCR (MPC5XXX_PCI + 0x80) -#define MPC5XXX_PCI_ICR (MPC5XXX_PCI + 0x84) -#define MPC5XXX_PCI_ISR (MPC5XXX_PCI + 0x88) -#define MPC5XXX_PCI_ARB (MPC5XXX_PCI + 0x8c) -#define MPC5XXX_PCI_CAR (MPC5XXX_PCI + 0xf8) -#endif - -/* Interrupt Controller registers */ -#define MPC5XXX_ICTL_PER_MASK (MPC5XXX_ICTL + 0x0000) -#define MPC5XXX_ICTL_PER_PRIO1 (MPC5XXX_ICTL + 0x0004) -#define MPC5XXX_ICTL_PER_PRIO2 (MPC5XXX_ICTL + 0x0008) -#define MPC5XXX_ICTL_PER_PRIO3 (MPC5XXX_ICTL + 0x000c) -#define MPC5XXX_ICTL_EXT (MPC5XXX_ICTL + 0x0010) -#define MPC5XXX_ICTL_CRIT (MPC5XXX_ICTL + 0x0014) -#define MPC5XXX_ICTL_MAIN_PRIO1 (MPC5XXX_ICTL + 0x0018) -#define MPC5XXX_ICTL_MAIN_PRIO2 (MPC5XXX_ICTL + 0x001c) -#define MPC5XXX_ICTL_STS (MPC5XXX_ICTL + 0x0024) -#define MPC5XXX_ICTL_CRIT_STS (MPC5XXX_ICTL + 0x0028) -#define MPC5XXX_ICTL_MAIN_STS (MPC5XXX_ICTL + 0x002c) -#define MPC5XXX_ICTL_PER_STS (MPC5XXX_ICTL + 0x0030) -#define MPC5XXX_ICTL_BUS_STS (MPC5XXX_ICTL + 0x0038) - -#define NR_IRQS 64 - -/* IRQ mapping - these are our logical IRQ numbers */ -#define MPC5XXX_CRIT_IRQ_NUM 4 -#define MPC5XXX_MAIN_IRQ_NUM 17 -#define MPC5XXX_SDMA_IRQ_NUM 17 -#define MPC5XXX_PERP_IRQ_NUM 23 - -#define MPC5XXX_CRIT_IRQ_BASE 1 -#define MPC5XXX_MAIN_IRQ_BASE (MPC5XXX_CRIT_IRQ_BASE + MPC5XXX_CRIT_IRQ_NUM) -#define MPC5XXX_SDMA_IRQ_BASE (MPC5XXX_MAIN_IRQ_BASE + MPC5XXX_MAIN_IRQ_NUM) -#define MPC5XXX_PERP_IRQ_BASE (MPC5XXX_SDMA_IRQ_BASE + MPC5XXX_SDMA_IRQ_NUM) - -#define MPC5XXX_IRQ0 (MPC5XXX_CRIT_IRQ_BASE + 0) -#define MPC5XXX_SLICE_TIMER_0_IRQ (MPC5XXX_CRIT_IRQ_BASE + 1) -#define MPC5XXX_HI_INT_IRQ (MPC5XXX_CRIT_IRQ_BASE + 2) -#define MPC5XXX_CCS_IRQ (MPC5XXX_CRIT_IRQ_BASE + 3) - -#define MPC5XXX_IRQ1 (MPC5XXX_MAIN_IRQ_BASE + 1) -#define MPC5XXX_IRQ2 (MPC5XXX_MAIN_IRQ_BASE + 2) -#define MPC5XXX_IRQ3 (MPC5XXX_MAIN_IRQ_BASE + 3) -#define MPC5XXX_RTC_PINT_IRQ (MPC5XXX_MAIN_IRQ_BASE + 5) -#define MPC5XXX_RTC_SINT_IRQ (MPC5XXX_MAIN_IRQ_BASE + 6) -#define MPC5XXX_RTC_GPIO_STD_IRQ (MPC5XXX_MAIN_IRQ_BASE + 7) -#define MPC5XXX_RTC_GPIO_WKUP_IRQ (MPC5XXX_MAIN_IRQ_BASE + 8) -#define MPC5XXX_TMR0_IRQ (MPC5XXX_MAIN_IRQ_BASE + 9) -#define MPC5XXX_TMR1_IRQ (MPC5XXX_MAIN_IRQ_BASE + 10) -#define MPC5XXX_TMR2_IRQ (MPC5XXX_MAIN_IRQ_BASE + 11) -#define MPC5XXX_TMR3_IRQ (MPC5XXX_MAIN_IRQ_BASE + 12) -#define MPC5XXX_TMR4_IRQ (MPC5XXX_MAIN_IRQ_BASE + 13) -#define MPC5XXX_TMR5_IRQ (MPC5XXX_MAIN_IRQ_BASE + 14) -#define MPC5XXX_TMR6_IRQ (MPC5XXX_MAIN_IRQ_BASE + 15) -#define MPC5XXX_TMR7_IRQ (MPC5XXX_MAIN_IRQ_BASE + 16) - -#define MPC5XXX_SDMA_IRQ (MPC5XXX_PERP_IRQ_BASE + 0) -#define MPC5XXX_PSC1_IRQ (MPC5XXX_PERP_IRQ_BASE + 1) -#define MPC5XXX_PSC2_IRQ (MPC5XXX_PERP_IRQ_BASE + 2) -#define MPC5XXX_PSC3_IRQ (MPC5XXX_PERP_IRQ_BASE + 3) -#define MPC5XXX_PSC6_IRQ (MPC5XXX_PERP_IRQ_BASE + 4) -#define MPC5XXX_IRDA_IRQ (MPC5XXX_PERP_IRQ_BASE + 4) -#define MPC5XXX_FEC_IRQ (MPC5XXX_PERP_IRQ_BASE + 5) -#define MPC5XXX_USB_IRQ (MPC5XXX_PERP_IRQ_BASE + 6) -#define MPC5XXX_ATA_IRQ (MPC5XXX_PERP_IRQ_BASE + 7) -#define MPC5XXX_PCI_CNTRL_IRQ (MPC5XXX_PERP_IRQ_BASE + 8) -#define MPC5XXX_PCI_SCIRX_IRQ (MPC5XXX_PERP_IRQ_BASE + 9) -#define MPC5XXX_PCI_SCITX_IRQ (MPC5XXX_PERP_IRQ_BASE + 10) -#define MPC5XXX_PSC4_IRQ (MPC5XXX_PERP_IRQ_BASE + 11) -#define MPC5XXX_PSC5_IRQ (MPC5XXX_PERP_IRQ_BASE + 12) -#define MPC5XXX_SPI_MODF_IRQ (MPC5XXX_PERP_IRQ_BASE + 13) -#define MPC5XXX_SPI_SPIF_IRQ (MPC5XXX_PERP_IRQ_BASE + 14) -#define MPC5XXX_I2C1_IRQ (MPC5XXX_PERP_IRQ_BASE + 15) -#define MPC5XXX_I2C2_IRQ (MPC5XXX_PERP_IRQ_BASE + 16) -#define MPC5XXX_MSCAN1_IRQ (MPC5XXX_PERP_IRQ_BASE + 17) -#define MPC5XXX_MSCAN2_IRQ (MPC5XXX_PERP_IRQ_BASE + 18) -#define MPC5XXX_IR_RX_IRQ (MPC5XXX_PERP_IRQ_BASE + 19) -#define MPC5XXX_IR_TX_IRQ (MPC5XXX_PERP_IRQ_BASE + 20) -#define MPC5XXX_XLB_ARB_IRQ (MPC5XXX_PERP_IRQ_BASE + 21) -#define MPC5XXX_BDLC_IRQ (MPC5XXX_PERP_IRQ_BASE + 22) - -/* General Purpose Timers registers */ -#define MPC5XXX_GPT0_ENABLE (MPC5XXX_GPT + 0x0) -#define MPC5XXX_GPT0_COUNTER (MPC5XXX_GPT + 0x4) -#define MPC5XXX_GPT0_STATUS (MPC5XXX_GPT + 0x0C) -#define MPC5XXX_GPT1_ENABLE (MPC5XXX_GPT + 0x10) -#define MPC5XXX_GPT1_COUNTER (MPC5XXX_GPT + 0x14) -#define MPC5XXX_GPT1_STATUS (MPC5XXX_GPT + 0x1C) -#define MPC5XXX_GPT2_ENABLE (MPC5XXX_GPT + 0x20) -#define MPC5XXX_GPT2_COUNTER (MPC5XXX_GPT + 0x24) -#define MPC5XXX_GPT2_STATUS (MPC5XXX_GPT + 0x2C) -#define MPC5XXX_GPT3_ENABLE (MPC5XXX_GPT + 0x30) -#define MPC5XXX_GPT3_COUNTER (MPC5XXX_GPT + 0x34) -#define MPC5XXX_GPT3_STATUS (MPC5XXX_GPT + 0x3C) -#define MPC5XXX_GPT4_ENABLE (MPC5XXX_GPT + 0x40) -#define MPC5XXX_GPT4_COUNTER (MPC5XXX_GPT + 0x44) -#define MPC5XXX_GPT4_STATUS (MPC5XXX_GPT + 0x4C) -#define MPC5XXX_GPT5_ENABLE (MPC5XXX_GPT + 0x50) -#define MPC5XXX_GPT5_STATUS (MPC5XXX_GPT + 0x5C) -#define MPC5XXX_GPT5_COUNTER (MPC5XXX_GPT + 0x54) -#define MPC5XXX_GPT6_ENABLE (MPC5XXX_GPT + 0x60) -#define MPC5XXX_GPT6_COUNTER (MPC5XXX_GPT + 0x64) -#define MPC5XXX_GPT6_STATUS (MPC5XXX_GPT + 0x6C) -#define MPC5XXX_GPT7_ENABLE (MPC5XXX_GPT + 0x70) -#define MPC5XXX_GPT7_COUNTER (MPC5XXX_GPT + 0x74) -#define MPC5XXX_GPT7_STATUS (MPC5XXX_GPT + 0x7C) - -#define MPC5XXX_GPT_GPIO_PIN(status) ((0x00000100 & (status)) >> 8) - -#define MPC5XXX_GPT7_PWMCFG (MPC5XXX_GPT + 0x78) - -/* ATA registers */ -#define MPC5XXX_ATA_HOST_CONFIG (MPC5XXX_ATA + 0x0000) -#define MPC5XXX_ATA_PIO1 (MPC5XXX_ATA + 0x0008) -#define MPC5XXX_ATA_PIO2 (MPC5XXX_ATA + 0x000C) -#define MPC5XXX_ATA_SHARE_COUNT (MPC5XXX_ATA + 0x002C) - -/* I2Cn control register bits */ -#define I2C_EN 0x80 -#define I2C_IEN 0x40 -#define I2C_STA 0x20 -#define I2C_TX 0x10 -#define I2C_TXAK 0x08 -#define I2C_RSTA 0x04 -#define I2C_INIT_MASK (I2C_EN | I2C_STA | I2C_TX | I2C_RSTA) - -/* I2Cn status register bits */ -#define I2C_CF 0x80 -#define I2C_AAS 0x40 -#define I2C_BB 0x20 -#define I2C_AL 0x10 -#define I2C_SRW 0x04 -#define I2C_IF 0x02 -#define I2C_RXAK 0x01 - -/* Programmable Serial Controller (PSC) status register bits */ -#define PSC_SR_CDE 0x0080 -#define PSC_SR_RXRDY 0x0100 -#define PSC_SR_RXFULL 0x0200 -#define PSC_SR_TXRDY 0x0400 -#define PSC_SR_TXEMP 0x0800 -#define PSC_SR_OE 0x1000 -#define PSC_SR_PE 0x2000 -#define PSC_SR_FE 0x4000 -#define PSC_SR_RB 0x8000 - -/* PSC Command values */ -#define PSC_RX_ENABLE 0x0001 -#define PSC_RX_DISABLE 0x0002 -#define PSC_TX_ENABLE 0x0004 -#define PSC_TX_DISABLE 0x0008 -#define PSC_SEL_MODE_REG_1 0x0010 -#define PSC_RST_RX 0x0020 -#define PSC_RST_TX 0x0030 -#define PSC_RST_ERR_STAT 0x0040 -#define PSC_RST_BRK_CHG_INT 0x0050 -#define PSC_START_BRK 0x0060 -#define PSC_STOP_BRK 0x0070 - -/* PSC Rx FIFO status bits */ -#define PSC_RX_FIFO_ERR 0x0040 -#define PSC_RX_FIFO_UF 0x0020 -#define PSC_RX_FIFO_OF 0x0010 -#define PSC_RX_FIFO_FR 0x0008 -#define PSC_RX_FIFO_FULL 0x0004 -#define PSC_RX_FIFO_ALARM 0x0002 -#define PSC_RX_FIFO_EMPTY 0x0001 - -/* PSC interrupt mask bits */ -#define PSC_IMR_TXRDY 0x0100 -#define PSC_IMR_RXRDY 0x0200 -#define PSC_IMR_DB 0x0400 -#define PSC_IMR_IPC 0x8000 - -/* PSC input port change bits */ -#define PSC_IPCR_CTS 0x01 -#define PSC_IPCR_DCD 0x02 - -/* PSC mode fields */ -#define PSC_MODE_5_BITS 0x00 -#define PSC_MODE_6_BITS 0x01 -#define PSC_MODE_7_BITS 0x02 -#define PSC_MODE_8_BITS 0x03 -#define PSC_MODE_PAREVEN 0x00 -#define PSC_MODE_PARODD 0x04 -#define PSC_MODE_PARFORCE 0x08 -#define PSC_MODE_PARNONE 0x10 -#define PSC_MODE_ERR 0x20 -#define PSC_MODE_FFULL 0x40 -#define PSC_MODE_RXRTS 0x80 - -#define PSC_MODE_ONE_STOP_5_BITS 0x00 -#define PSC_MODE_ONE_STOP 0x07 -#define PSC_MODE_TWO_STOP 0x0f - -/* ATA config fields */ -#define MPC5xxx_ATA_HOSTCONF_SMR 0x80000000UL /* State machine - reset */ -#define MPC5xxx_ATA_HOSTCONF_FR 0x40000000UL /* FIFO Reset */ -#define MPC5xxx_ATA_HOSTCONF_IE 0x02000000UL /* Enable interrupt - in PIO */ -#define MPC5xxx_ATA_HOSTCONF_IORDY 0x01000000UL /* Drive supports - IORDY protocol */ - -#ifndef __ASSEMBLY__ -struct mpc5xxx_psc { - volatile u8 mode; /* PSC + 0x00 */ - volatile u8 reserved0[3]; - union { /* PSC + 0x04 */ - volatile u16 status; - volatile u16 clock_select; - } sr_csr; -#define psc_status sr_csr.status -#define psc_clock_select sr_csr.clock_select - volatile u16 reserved1; - volatile u8 command; /* PSC + 0x08 */ - volatile u8 reserved2[3]; - union { /* PSC + 0x0c */ - volatile u8 buffer_8; - volatile u16 buffer_16; - volatile u32 buffer_32; - } buffer; -#define psc_buffer_8 buffer.buffer_8 -#define psc_buffer_16 buffer.buffer_16 -#define psc_buffer_32 buffer.buffer_32 - union { /* PSC + 0x10 */ - volatile u8 ipcr; - volatile u8 acr; - } ipcr_acr; -#define psc_ipcr ipcr_acr.ipcr -#define psc_acr ipcr_acr.acr - volatile u8 reserved3[3]; - union { /* PSC + 0x14 */ - volatile u16 isr; - volatile u16 imr; - } isr_imr; -#define psc_isr isr_imr.isr -#define psc_imr isr_imr.imr - volatile u16 reserved4; - volatile u8 ctur; /* PSC + 0x18 */ - volatile u8 reserved5[3]; - volatile u8 ctlr; /* PSC + 0x1c */ - volatile u8 reserved6[3]; - volatile u16 ccr; /* PSC + 0x20 */ - volatile u8 reserved7[14]; - volatile u8 ivr; /* PSC + 0x30 */ - volatile u8 reserved8[3]; - volatile u8 ip; /* PSC + 0x34 */ - volatile u8 reserved9[3]; - volatile u8 op1; /* PSC + 0x38 */ - volatile u8 reserved10[3]; - volatile u8 op0; /* PSC + 0x3c */ - volatile u8 reserved11[3]; - volatile u32 sicr; /* PSC + 0x40 */ - volatile u8 ircr1; /* PSC + 0x44 */ - volatile u8 reserved12[3]; - volatile u8 ircr2; /* PSC + 0x44 */ - volatile u8 reserved13[3]; - volatile u8 irsdr; /* PSC + 0x4c */ - volatile u8 reserved14[3]; - volatile u8 irmdr; /* PSC + 0x50 */ - volatile u8 reserved15[3]; - volatile u8 irfdr; /* PSC + 0x54 */ - volatile u8 reserved16[3]; - volatile u16 rfnum; /* PSC + 0x58 */ - volatile u16 reserved17; - volatile u16 tfnum; /* PSC + 0x5c */ - volatile u16 reserved18; - volatile u32 rfdata; /* PSC + 0x60 */ - volatile u16 rfstat; /* PSC + 0x64 */ - volatile u16 reserved20; - volatile u8 rfcntl; /* PSC + 0x68 */ - volatile u8 reserved21[5]; - volatile u16 rfalarm; /* PSC + 0x6e */ - volatile u16 reserved22; - volatile u16 rfrptr; /* PSC + 0x72 */ - volatile u16 reserved23; - volatile u16 rfwptr; /* PSC + 0x76 */ - volatile u16 reserved24; - volatile u16 rflrfptr; /* PSC + 0x7a */ - volatile u16 reserved25; - volatile u16 rflwfptr; /* PSC + 0x7e */ - volatile u32 tfdata; /* PSC + 0x80 */ - volatile u16 tfstat; /* PSC + 0x84 */ - volatile u16 reserved26; - volatile u8 tfcntl; /* PSC + 0x88 */ - volatile u8 reserved27[5]; - volatile u16 tfalarm; /* PSC + 0x8e */ - volatile u16 reserved28; - volatile u16 tfrptr; /* PSC + 0x92 */ - volatile u16 reserved29; - volatile u16 tfwptr; /* PSC + 0x96 */ - volatile u16 reserved30; - volatile u16 tflrfptr; /* PSC + 0x9a */ - volatile u16 reserved31; - volatile u16 tflwfptr; /* PSC + 0x9e */ -}; - -struct mpc5xxx_intr { - volatile u32 per_mask; /* INTR + 0x00 */ - volatile u32 per_pri1; /* INTR + 0x04 */ - volatile u32 per_pri2; /* INTR + 0x08 */ - volatile u32 per_pri3; /* INTR + 0x0c */ - volatile u32 ctrl; /* INTR + 0x10 */ - volatile u32 main_mask; /* INTR + 0x14 */ - volatile u32 main_pri1; /* INTR + 0x18 */ - volatile u32 main_pri2; /* INTR + 0x1c */ - volatile u32 reserved1; /* INTR + 0x20 */ - volatile u32 enc_status; /* INTR + 0x24 */ - volatile u32 crit_status; /* INTR + 0x28 */ - volatile u32 main_status; /* INTR + 0x2c */ - volatile u32 per_status; /* INTR + 0x30 */ - volatile u32 reserved2; /* INTR + 0x34 */ - volatile u32 per_error; /* INTR + 0x38 */ -}; - -struct mpc5xxx_gpio { - volatile u32 port_config; /* GPIO + 0x00 */ - volatile u32 simple_gpioe; /* GPIO + 0x04 */ - volatile u32 simple_ode; /* GPIO + 0x08 */ - volatile u32 simple_ddr; /* GPIO + 0x0c */ - volatile u32 simple_dvo; /* GPIO + 0x10 */ - volatile u32 simple_ival; /* GPIO + 0x14 */ - volatile u8 outo_gpioe; /* GPIO + 0x18 */ - volatile u8 reserved1[3]; /* GPIO + 0x19 */ - volatile u8 outo_dvo; /* GPIO + 0x1c */ - volatile u8 reserved2[3]; /* GPIO + 0x1d */ - volatile u8 sint_gpioe; /* GPIO + 0x20 */ - volatile u8 reserved3[3]; /* GPIO + 0x21 */ - volatile u8 sint_ode; /* GPIO + 0x24 */ - volatile u8 reserved4[3]; /* GPIO + 0x25 */ - volatile u8 sint_ddr; /* GPIO + 0x28 */ - volatile u8 reserved5[3]; /* GPIO + 0x29 */ - volatile u8 sint_dvo; /* GPIO + 0x2c */ - volatile u8 reserved6[3]; /* GPIO + 0x2d */ - volatile u8 sint_inten; /* GPIO + 0x30 */ - volatile u8 reserved7[3]; /* GPIO + 0x31 */ - volatile u16 sint_itype; /* GPIO + 0x34 */ - volatile u16 reserved8; /* GPIO + 0x36 */ - volatile u8 gpio_control; /* GPIO + 0x38 */ - volatile u8 reserved9[3]; /* GPIO + 0x39 */ - volatile u8 sint_istat; /* GPIO + 0x3c */ - volatile u8 sint_ival; /* GPIO + 0x3d */ - volatile u8 bus_errs; /* GPIO + 0x3e */ - volatile u8 reserved10; /* GPIO + 0x3f */ -}; - -struct mpc5xxx_sdma { - volatile u32 taskBar; /* SDMA + 0x00 */ - volatile u32 currentPointer; /* SDMA + 0x04 */ - volatile u32 endPointer; /* SDMA + 0x08 */ - volatile u32 variablePointer; /* SDMA + 0x0c */ - - volatile u8 IntVect1; /* SDMA + 0x10 */ - volatile u8 IntVect2; /* SDMA + 0x11 */ - volatile u16 PtdCntrl; /* SDMA + 0x12 */ - - volatile u32 IntPend; /* SDMA + 0x14 */ - volatile u32 IntMask; /* SDMA + 0x18 */ - - volatile u16 tcr_0; /* SDMA + 0x1c */ - volatile u16 tcr_1; /* SDMA + 0x1e */ - volatile u16 tcr_2; /* SDMA + 0x20 */ - volatile u16 tcr_3; /* SDMA + 0x22 */ - volatile u16 tcr_4; /* SDMA + 0x24 */ - volatile u16 tcr_5; /* SDMA + 0x26 */ - volatile u16 tcr_6; /* SDMA + 0x28 */ - volatile u16 tcr_7; /* SDMA + 0x2a */ - volatile u16 tcr_8; /* SDMA + 0x2c */ - volatile u16 tcr_9; /* SDMA + 0x2e */ - volatile u16 tcr_a; /* SDMA + 0x30 */ - volatile u16 tcr_b; /* SDMA + 0x32 */ - volatile u16 tcr_c; /* SDMA + 0x34 */ - volatile u16 tcr_d; /* SDMA + 0x36 */ - volatile u16 tcr_e; /* SDMA + 0x38 */ - volatile u16 tcr_f; /* SDMA + 0x3a */ - - volatile u8 IPR0; /* SDMA + 0x3c */ - volatile u8 IPR1; /* SDMA + 0x3d */ - volatile u8 IPR2; /* SDMA + 0x3e */ - volatile u8 IPR3; /* SDMA + 0x3f */ - volatile u8 IPR4; /* SDMA + 0x40 */ - volatile u8 IPR5; /* SDMA + 0x41 */ - volatile u8 IPR6; /* SDMA + 0x42 */ - volatile u8 IPR7; /* SDMA + 0x43 */ - volatile u8 IPR8; /* SDMA + 0x44 */ - volatile u8 IPR9; /* SDMA + 0x45 */ - volatile u8 IPR10; /* SDMA + 0x46 */ - volatile u8 IPR11; /* SDMA + 0x47 */ - volatile u8 IPR12; /* SDMA + 0x48 */ - volatile u8 IPR13; /* SDMA + 0x49 */ - volatile u8 IPR14; /* SDMA + 0x4a */ - volatile u8 IPR15; /* SDMA + 0x4b */ - volatile u8 IPR16; /* SDMA + 0x4c */ - volatile u8 IPR17; /* SDMA + 0x4d */ - volatile u8 IPR18; /* SDMA + 0x4e */ - volatile u8 IPR19; /* SDMA + 0x4f */ - volatile u8 IPR20; /* SDMA + 0x50 */ - volatile u8 IPR21; /* SDMA + 0x51 */ - volatile u8 IPR22; /* SDMA + 0x52 */ - volatile u8 IPR23; /* SDMA + 0x53 */ - volatile u8 IPR24; /* SDMA + 0x54 */ - volatile u8 IPR25; /* SDMA + 0x55 */ - volatile u8 IPR26; /* SDMA + 0x56 */ - volatile u8 IPR27; /* SDMA + 0x57 */ - volatile u8 IPR28; /* SDMA + 0x58 */ - volatile u8 IPR29; /* SDMA + 0x59 */ - volatile u8 IPR30; /* SDMA + 0x5a */ - volatile u8 IPR31; /* SDMA + 0x5b */ - - volatile u32 res1; /* SDMA + 0x5c */ - volatile u32 res2; /* SDMA + 0x60 */ - volatile u32 res3; /* SDMA + 0x64 */ - volatile u32 MDEDebug; /* SDMA + 0x68 */ - volatile u32 ADSDebug; /* SDMA + 0x6c */ - volatile u32 Value1; /* SDMA + 0x70 */ - volatile u32 Value2; /* SDMA + 0x74 */ - volatile u32 Control; /* SDMA + 0x78 */ - volatile u32 Status; /* SDMA + 0x7c */ - volatile u32 EU00; /* SDMA + 0x80 */ - volatile u32 EU01; /* SDMA + 0x84 */ - volatile u32 EU02; /* SDMA + 0x88 */ - volatile u32 EU03; /* SDMA + 0x8c */ - volatile u32 EU04; /* SDMA + 0x90 */ - volatile u32 EU05; /* SDMA + 0x94 */ - volatile u32 EU06; /* SDMA + 0x98 */ - volatile u32 EU07; /* SDMA + 0x9c */ - volatile u32 EU10; /* SDMA + 0xa0 */ - volatile u32 EU11; /* SDMA + 0xa4 */ - volatile u32 EU12; /* SDMA + 0xa8 */ - volatile u32 EU13; /* SDMA + 0xac */ - volatile u32 EU14; /* SDMA + 0xb0 */ - volatile u32 EU15; /* SDMA + 0xb4 */ - volatile u32 EU16; /* SDMA + 0xb8 */ - volatile u32 EU17; /* SDMA + 0xbc */ - volatile u32 EU20; /* SDMA + 0xc0 */ - volatile u32 EU21; /* SDMA + 0xc4 */ - volatile u32 EU22; /* SDMA + 0xc8 */ - volatile u32 EU23; /* SDMA + 0xcc */ - volatile u32 EU24; /* SDMA + 0xd0 */ - volatile u32 EU25; /* SDMA + 0xd4 */ - volatile u32 EU26; /* SDMA + 0xd8 */ - volatile u32 EU27; /* SDMA + 0xdc */ - volatile u32 EU30; /* SDMA + 0xe0 */ - volatile u32 EU31; /* SDMA + 0xe4 */ - volatile u32 EU32; /* SDMA + 0xe8 */ - volatile u32 EU33; /* SDMA + 0xec */ - volatile u32 EU34; /* SDMA + 0xf0 */ - volatile u32 EU35; /* SDMA + 0xf4 */ - volatile u32 EU36; /* SDMA + 0xf8 */ - volatile u32 EU37; /* SDMA + 0xfc */ -}; - -struct mpc5xxx_i2c { - volatile u32 madr; /* I2Cn + 0x00 */ - volatile u32 mfdr; /* I2Cn + 0x04 */ - volatile u32 mcr; /* I2Cn + 0x08 */ - volatile u32 msr; /* I2Cn + 0x0C */ - volatile u32 mdr; /* I2Cn + 0x10 */ -}; - -struct mpc5xxx_spi { - volatile u8 cr1; /* SPI + 0x0F00 */ - volatile u8 cr2; /* SPI + 0x0F01 */ - volatile u8 reserved1[2]; - volatile u8 brr; /* SPI + 0x0F04 */ - volatile u8 sr; /* SPI + 0x0F05 */ - volatile u8 reserved2[3]; - volatile u8 dr; /* SPI + 0x0F09 */ - volatile u8 reserved3[3]; - volatile u8 pdr; /* SPI + 0x0F0D */ - volatile u8 reserved4[2]; - volatile u8 ddr; /* SPI + 0x0F10 */ -}; - - -struct mpc5xxx_gpt { - volatile u32 emsr; /* GPT + Timer# * 0x10 + 0x00 */ - volatile u32 cir; /* GPT + Timer# * 0x10 + 0x04 */ - volatile u32 pwmcr; /* GPT + Timer# * 0x10 + 0x08 */ - volatile u32 sr; /* GPT + Timer# * 0x10 + 0x0c */ -}; - -struct mpc5xxx_gpt_0_7 { - struct mpc5xxx_gpt gpt0; - struct mpc5xxx_gpt gpt1; - struct mpc5xxx_gpt gpt2; - struct mpc5xxx_gpt gpt3; - struct mpc5xxx_gpt gpt4; - struct mpc5xxx_gpt gpt5; - struct mpc5xxx_gpt gpt6; - struct mpc5xxx_gpt gpt7; -}; - -struct mscan_buffer { - volatile u8 idr[0x8]; /* 0x00 */ - volatile u8 dsr[0x10]; /* 0x08 */ - volatile u8 dlr; /* 0x18 */ - volatile u8 tbpr; /* 0x19 */ /* This register is not applicable for receive buffers */ - volatile u16 rsrv1; /* 0x1A */ - volatile u8 tsrh; /* 0x1C */ - volatile u8 tsrl; /* 0x1D */ - volatile u16 rsrv2; /* 0x1E */ -}; - -struct mpc5xxx_mscan { - volatile u8 canctl0; /* MSCAN + 0x00 */ - volatile u8 canctl1; /* MSCAN + 0x01 */ - volatile u16 rsrv1; /* MSCAN + 0x02 */ - volatile u8 canbtr0; /* MSCAN + 0x04 */ - volatile u8 canbtr1; /* MSCAN + 0x05 */ - volatile u16 rsrv2; /* MSCAN + 0x06 */ - volatile u8 canrflg; /* MSCAN + 0x08 */ - volatile u8 canrier; /* MSCAN + 0x09 */ - volatile u16 rsrv3; /* MSCAN + 0x0A */ - volatile u8 cantflg; /* MSCAN + 0x0C */ - volatile u8 cantier; /* MSCAN + 0x0D */ - volatile u16 rsrv4; /* MSCAN + 0x0E */ - volatile u8 cantarq; /* MSCAN + 0x10 */ - volatile u8 cantaak; /* MSCAN + 0x11 */ - volatile u16 rsrv5; /* MSCAN + 0x12 */ - volatile u8 cantbsel; /* MSCAN + 0x14 */ - volatile u8 canidac; /* MSCAN + 0x15 */ - volatile u16 rsrv6[3]; /* MSCAN + 0x16 */ - volatile u8 canrxerr; /* MSCAN + 0x1C */ - volatile u8 cantxerr; /* MSCAN + 0x1D */ - volatile u16 rsrv7; /* MSCAN + 0x1E */ - volatile u8 canidar0; /* MSCAN + 0x20 */ - volatile u8 canidar1; /* MSCAN + 0x21 */ - volatile u16 rsrv8; /* MSCAN + 0x22 */ - volatile u8 canidar2; /* MSCAN + 0x24 */ - volatile u8 canidar3; /* MSCAN + 0x25 */ - volatile u16 rsrv9; /* MSCAN + 0x26 */ - volatile u8 canidmr0; /* MSCAN + 0x28 */ - volatile u8 canidmr1; /* MSCAN + 0x29 */ - volatile u16 rsrv10; /* MSCAN + 0x2A */ - volatile u8 canidmr2; /* MSCAN + 0x2C */ - volatile u8 canidmr3; /* MSCAN + 0x2D */ - volatile u16 rsrv11; /* MSCAN + 0x2E */ - volatile u8 canidar4; /* MSCAN + 0x30 */ - volatile u8 canidar5; /* MSCAN + 0x31 */ - volatile u16 rsrv12; /* MSCAN + 0x32 */ - volatile u8 canidar6; /* MSCAN + 0x34 */ - volatile u8 canidar7; /* MSCAN + 0x35 */ - volatile u16 rsrv13; /* MSCAN + 0x36 */ - volatile u8 canidmr4; /* MSCAN + 0x38 */ - volatile u8 canidmr5; /* MSCAN + 0x39 */ - volatile u16 rsrv14; /* MSCAN + 0x3A */ - volatile u8 canidmr6; /* MSCAN + 0x3C */ - volatile u8 canidmr7; /* MSCAN + 0x3D */ - volatile u16 rsrv15; /* MSCAN + 0x3E */ - - struct mscan_buffer canrxfg; /* MSCAN + 0x40 */ /* Foreground receive buffer */ - struct mscan_buffer cantxfg; /* MSCAN + 0x60 */ /* Foreground transmit buffer */ - }; - -/* function prototypes */ -void loadtask(int basetask, int tasks); - -#endif /* __ASSEMBLY__ */ - -#endif /* __ASMPPC_MPC5XXX_H */ diff --git a/lib/Kconfig b/lib/Kconfig index ac86758786..2cbef7b7d0 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -7,13 +7,5 @@ config BZLIB config CRC32 bool -config DYNAMIC_CRC_TABLE - bool - prompt "Generate the crc32 table dynamically" - default y - help - Saying yes to this option saves around 800 bytes of binary size. - If unsure say yes. - config CRC16 bool diff --git a/lib/Makefile b/lib/Makefile index 3e11016668..13aa1ce8d9 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -7,7 +7,6 @@ obj-y += div64.o obj-y += misc.o obj-y += driver.o obj-y += parameter.o -obj-y += global.o obj-y += xfuncs.o obj-y += getopt.o obj-y += readkey.o diff --git a/lib/global.c b/lib/global.c deleted file mode 100644 index 2d7544b8fd..0000000000 --- a/lib/global.c +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include -#include -#include -#include -#include - -static struct device_d global_dev; - -int global_add_param(struct param_d *param) -{ - return dev_add_param(&global_dev, param); -} - -static struct device_d global_dev = { - .name = "global", - .id = "env", - .map_base = 0, - .size = 0, -}; - -static struct driver_d global_driver = { - .name = "global", - .probe = dummy_probe, -}; - -static int global_init(void) -{ - register_device(&global_dev); - register_driver(&global_driver); - return 0; -} - -coredevice_initcall(global_init); - diff --git a/lib/misc.c b/lib/misc.c index 5a7a72cd58..5ba9a0bbfa 100644 --- a/lib/misc.c +++ b/lib/misc.c @@ -1,36 +1,8 @@ #include -#include -#include -#include #include -#include #include #include -#include - -int cmd_get_data_size(char* arg, int default_size) -{ - /* Check for a size specification .b, .w or .l. - */ - int len = strlen(arg); - if (len > 2 && arg[len-2] == '.') { - switch(arg[len-1]) { - case 'b': - return 1; - case 'w': - return 2; - case 'l': - return 4; - case 's': - return -2; - default: - return -1; - } - } - return default_size; -} - unsigned long strtoul_suffix(const char *str, char **endp, int base) { diff --git a/lib/parameter.c b/lib/parameter.c index a2490d4ac2..bf5d87ecf5 100644 --- a/lib/parameter.c +++ b/lib/parameter.c @@ -33,6 +33,7 @@ const char *dev_get_param(struct device_d *dev, const char *name) return param->value; } +#ifdef CONFIG_NET IPaddr_t dev_get_param_ip(struct device_d *dev, char *name) { return string_to_ip(dev_get_param(dev, name)); @@ -45,6 +46,7 @@ int dev_set_param_ip(struct device_d *dev, char *name, IPaddr_t ip) return dev_set_param(dev, name, ipstr); } +#endif int dev_set_param(struct device_d *dev, const char *name, const char *val) { -- cgit v1.2.3