wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 |
| 3 | * Wolfgang Grandegger, DENX Software Engineering, wg@denx.de. |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #include <common.h> |
| 25 | #include <malloc.h> |
| 26 | #include <net.h> |
| 27 | #include <asm/io.h> |
| 28 | #include <pci.h> |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 29 | #include <command.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 30 | #include "pn62.h" |
| 31 | |
Jon Loeliger | 145318c | 2007-07-09 18:38:39 -0500 | [diff] [blame] | 32 | #if defined(CONFIG_CMD_BSP) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 33 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 34 | /* |
| 35 | * Command led: controls the various LEDs 0..11 on the PN62 card. |
| 36 | */ |
Wolfgang Denk | 3b68311 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 37 | int do_led(cmd_tbl_t * cmdtp, int flag, int argc, char *const argv[]) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 38 | { |
Wolfgang Denk | 3b68311 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 39 | unsigned int number, function; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 40 | |
Wolfgang Denk | 3b68311 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 41 | if (argc != 3) |
| 42 | return cmd_usage(cmdtp); |
| 43 | |
| 44 | number = simple_strtoul(argv[1], NULL, 10); |
| 45 | if (number > PN62_LED_MAX) |
| 46 | return 1; |
| 47 | |
| 48 | function = simple_strtoul(argv[2], NULL, 16); |
| 49 | set_led(number, function); |
| 50 | return 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 51 | } |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 52 | U_BOOT_CMD( |
| 53 | led , 3, 1, do_led, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 54 | "set LED 0..11 on the PN62 board", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 55 | "i fun" |
| 56 | " - set 'i'th LED to function 'fun'" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 57 | ); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 58 | |
| 59 | /* |
| 60 | * Command loadpci: loads a image over PCI. |
| 61 | */ |
| 62 | #define CMD_MOVE_WINDOW 0x1 |
| 63 | #define CMD_BOOT_IMAGE 0x2 |
| 64 | |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 65 | int do_loadpci (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 66 | { |
| 67 | char *s; |
| 68 | ulong addr = 0, count = 0; |
| 69 | u32 off; |
| 70 | int cmd, rcode = 0; |
| 71 | |
| 72 | /* pre-set load_addr */ |
| 73 | if ((s = getenv("loadaddr")) != NULL) { |
| 74 | addr = simple_strtoul(s, NULL, 16); |
| 75 | } |
| 76 | |
| 77 | switch (argc) { |
| 78 | case 1: |
| 79 | break; |
| 80 | case 2: |
| 81 | addr = simple_strtoul(argv[1], NULL, 16); |
| 82 | break; |
| 83 | default: |
Wolfgang Denk | e9e8bab | 2010-09-10 00:16:19 +0200 | [diff] [blame] | 84 | return cmd_usage(cmdtp); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | printf ("## Ready for image download ...\n"); |
| 88 | |
| 89 | show_startup_phase(12); |
| 90 | |
| 91 | while (1) { |
| 92 | /* Alive indicator */ |
| 93 | i2155x_write_scrapad(BOOT_PROTO, BOOT_PROTO_READY); |
| 94 | |
| 95 | /* Toggle status LEDs */ |
| 96 | cmd = (count / 200) % 4; /* downscale */ |
| 97 | set_led(4, cmd == 0 ? LED_1 : LED_0); |
| 98 | set_led(5, cmd == 1 ? LED_1 : LED_0); |
| 99 | set_led(6, cmd == 2 ? LED_1 : LED_0); |
| 100 | set_led(7, cmd == 3 ? LED_1 : LED_0); |
| 101 | udelay(1000); |
| 102 | count++; |
| 103 | |
| 104 | cmd = i2155x_read_scrapad(BOOT_CMD); |
| 105 | |
| 106 | if (cmd == BOOT_CMD_MOVE) { |
| 107 | off = i2155x_read_scrapad(BOOT_DATA); |
| 108 | off += addr; |
| 109 | i2155x_set_bar_base(3, off); |
| 110 | printf ("## BAR3 Addr moved = 0x%08x\n", off); |
| 111 | i2155x_write_scrapad(BOOT_CMD, ~cmd); |
| 112 | show_startup_phase(13); |
| 113 | } |
| 114 | else if (cmd == BOOT_CMD_BOOT) { |
| 115 | set_led(4, LED_1); |
| 116 | set_led(5, LED_1); |
| 117 | set_led(6, LED_1); |
| 118 | set_led(7, LED_1); |
| 119 | |
| 120 | i2155x_write_scrapad(BOOT_CMD, ~cmd); |
| 121 | show_startup_phase(14); |
| 122 | break; |
| 123 | } |
| 124 | |
| 125 | /* Abort if ctrl-c was pressed */ |
| 126 | if (ctrlc()) { |
| 127 | printf("\nAbort\n"); |
| 128 | return 0; |
| 129 | } |
| 130 | |
| 131 | } |
| 132 | |
| 133 | /* Repoint to the default shared memory */ |
| 134 | i2155x_set_bar_base(3, PN62_SMEM_DEFAULT); |
| 135 | |
| 136 | load_addr = addr; |
| 137 | printf ("## Start Addr = 0x%08lx\n", addr); |
| 138 | |
| 139 | show_startup_phase(15); |
| 140 | |
| 141 | /* Loading ok, check if we should attempt an auto-start */ |
| 142 | if (((s = getenv("autostart")) != NULL) && (strcmp(s,"yes") == 0)) { |
| 143 | char *local_args[2]; |
| 144 | local_args[0] = argv[0]; |
| 145 | local_args[1] = NULL; |
| 146 | |
| 147 | printf ("Automatic boot of image at addr 0x%08lX ...\n", |
| 148 | load_addr); |
| 149 | rcode = do_bootm (cmdtp, 0, 1, local_args); |
| 150 | } |
| 151 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 152 | return rcode; |
| 153 | } |
| 154 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 155 | U_BOOT_CMD( |
| 156 | loadpci, 2, 1, do_loadpci, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 157 | "load binary file over PCI", |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 158 | "[addr]\n" |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 159 | " - load binary file over PCI to address 'addr'" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 160 | ); |
| 161 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 162 | #endif |