]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/pn62/cmd_pn62.c
arm: mx5: Add fuse supply enable in fsl_iim
[karo-tx-uboot.git] / board / pn62 / cmd_pn62.c
1 /*
2  * (C) Copyright 2002
3  * Wolfgang Grandegger, DENX Software Engineering, wg@denx.de.
4  *
5  * SPDX-License-Identifier:     GPL-2.0+
6  */
7
8 #include <common.h>
9 #include <malloc.h>
10 #include <net.h>
11 #include <asm/io.h>
12 #include <pci.h>
13 #include <command.h>
14 #include "pn62.h"
15
16 #if defined(CONFIG_CMD_BSP)
17
18 /*
19  * Command led: controls the various LEDs 0..11 on the PN62 card.
20  */
21 int do_led(cmd_tbl_t * cmdtp, int flag, int argc, char *const argv[])
22 {
23         unsigned int number, function;
24
25         if (argc != 3)
26                 return cmd_usage(cmdtp);
27
28         number = simple_strtoul(argv[1], NULL, 10);
29         if (number > PN62_LED_MAX)
30                 return 1;
31
32         function = simple_strtoul(argv[2], NULL, 16);
33         set_led(number, function);
34         return 0;
35 }
36 U_BOOT_CMD(
37         led    ,        3,      1,      do_led,
38         "set LED 0..11 on the PN62 board",
39         "i fun"
40         "    - set 'i'th LED to function 'fun'"
41 );
42
43 /*
44  * Command loadpci: loads a image over PCI.
45  */
46 #define CMD_MOVE_WINDOW 0x1
47 #define CMD_BOOT_IMAGE  0x2
48
49 int do_loadpci (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
50 {
51     char *s;
52     ulong addr = 0, count = 0;
53     u32 off;
54     int cmd, rcode = 0;
55
56     /* pre-set load_addr */
57     if ((s = getenv("loadaddr")) != NULL) {
58         addr = simple_strtoul(s, NULL, 16);
59     }
60
61     switch (argc) {
62     case 1:
63         break;
64     case 2:
65         addr = simple_strtoul(argv[1], NULL, 16);
66         break;
67     default:
68         return cmd_usage(cmdtp);
69     }
70
71     printf ("## Ready for image download ...\n");
72
73     show_startup_phase(12);
74
75     while (1) {
76         /* Alive indicator */
77         i2155x_write_scrapad(BOOT_PROTO, BOOT_PROTO_READY);
78
79         /* Toggle status LEDs */
80         cmd = (count / 200) % 4; /* downscale */
81         set_led(4, cmd == 0 ? LED_1 : LED_0);
82         set_led(5, cmd == 1 ? LED_1 : LED_0);
83         set_led(6, cmd == 2 ? LED_1 : LED_0);
84         set_led(7, cmd == 3 ? LED_1 : LED_0);
85         udelay(1000);
86         count++;
87
88         cmd = i2155x_read_scrapad(BOOT_CMD);
89
90         if (cmd == BOOT_CMD_MOVE) {
91             off = i2155x_read_scrapad(BOOT_DATA);
92             off += addr;
93             i2155x_set_bar_base(3, off);
94             printf ("## BAR3 Addr moved = 0x%08x\n", off);
95             i2155x_write_scrapad(BOOT_CMD, ~cmd);
96             show_startup_phase(13);
97         }
98         else if (cmd == BOOT_CMD_BOOT) {
99             set_led(4, LED_1);
100             set_led(5, LED_1);
101             set_led(6, LED_1);
102             set_led(7, LED_1);
103
104             i2155x_write_scrapad(BOOT_CMD, ~cmd);
105             show_startup_phase(14);
106             break;
107         }
108
109         /* Abort if ctrl-c was pressed */
110         if (ctrlc()) {
111             printf("\nAbort\n");
112             return 0;
113         }
114
115     }
116
117     /* Repoint to the default shared memory */
118     i2155x_set_bar_base(3, PN62_SMEM_DEFAULT);
119
120     load_addr = addr;
121     printf ("## Start Addr      = 0x%08lx\n", addr);
122
123     show_startup_phase(15);
124
125     /* Loading ok, check if we should attempt an auto-start */
126     if (((s = getenv("autostart")) != NULL) && (strcmp(s,"yes") == 0)) {
127         char *local_args[2];
128         local_args[0] = argv[0];
129         local_args[1] = NULL;
130
131         printf ("Automatic boot of image at addr 0x%08lX ...\n",
132                 load_addr);
133         rcode = do_bootm (cmdtp, 0, 1, local_args);
134     }
135
136     return rcode;
137 }
138
139 U_BOOT_CMD(
140         loadpci,        2,      1,      do_loadpci,
141         "load binary file over PCI",
142         "[addr]\n"
143         "    - load binary file over PCI to address 'addr'"
144 );
145
146 #endif