1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35#include <common.h>
36#include <mpc8xx.h>
37#include <commproc.h>
38#include <i2c.h>
39#include <command.h>
40#include <malloc.h>
41#include <post.h>
42#include <serial.h>
43
44#include <linux/types.h>
45#include <linux/string.h>
46
47DECLARE_GLOBAL_DATA_PTR;
48
49
50static long int dram_size (long int, long int *, long int);
51static void kbd_init (void);
52static int compare_magic (uchar *kbd_data, uchar *str);
53
54
55
56#define _NOT_USED_ 0xFFFFFFFF
57
58#ifdef CONFIG_MODEM_SUPPORT
59static int key_pressed(void);
60extern void disable_putc(void);
61#endif
62
63
64
65
66const uint sdram_table[] =
67{
68#if defined(CONFIG_SYS_MEMORY_75) || defined(CONFIG_SYS_MEMORY_8E)
69
70
71
72 0x1F0DFC04, 0xEEAFBC04, 0x11AF7C04, 0xEFBAFC00,
73 0x1FF5FC47,
74
75
76
77
78
79
80
81
82 0x1FF5FC34, 0xEFEABC34, 0x1FB57C35,
83
84
85
86 0x1F0DFC04, 0xEEAFBC04, 0x10AF7C04, 0xF0AFFC00,
87 0xF0AFFC00, 0xF1AFFC00, 0xEFBAFC00, 0x1FF5FC47,
88 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
89 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
90
91
92
93 0x1F2DFC04, 0xEEABBC00, 0x01B27C04, 0x1FF5FC47,
94 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
95
96
97
98 0x1F0DFC04, 0xEEABBC00, 0x10A77C00, 0xF0AFFC00,
99 0xF0AFFC00, 0xE1BAFC04, 0x01FF5FC47,
100 _NOT_USED_,
101 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
102 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
103
104
105
106 0x1FFD7C84, 0xFFFFFC04, 0xFFFFFC04, 0xFFFFFC04,
107 0xFFFFFC84, 0xFFFFFC07,
108 _NOT_USED_, _NOT_USED_,
109 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
110
111
112
113 0x7FFFFC07,
114 0xFFFFFCFF, 0xFFFFFCFF, 0xFFFFFCFF,
115#endif
116#ifdef CONFIG_SYS_MEMORY_7E
117
118
119
120 0x0E2DBC04, 0x11AF7C04, 0xEFBAFC00, 0x1FF5FC47,
121 _NOT_USED_,
122
123
124
125
126
127
128
129
130 0x1FF5FC34, 0xEFEABC34, 0x1FB57C35,
131
132
133
134 0x0E2DBC04, 0x10AF7C04, 0xF0AFFC00, 0xF0AFFC00,
135 0xF1AFFC00, 0xEFBAFC00, 0x1FF5FC47,
136 _NOT_USED_,
137 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
138 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
139
140
141
142 0x0E29BC04, 0x01B27C04, 0x1FF5FC47,
143 _NOT_USED_,
144 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
145
146
147
148 0x0E29BC04, 0x10A77C00, 0xF0AFFC00, 0xF0AFFC00,
149 0xE1BAFC04, 0x1FF5FC47,
150 _NOT_USED_, _NOT_USED_,
151 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
152 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
153
154
155
156 0x1FFD7C84, 0xFFFFFC04, 0xFFFFFC04, 0xFFFFFC04,
157 0xFFFFFC84, 0xFFFFFC07,
158 _NOT_USED_, _NOT_USED_,
159 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
160
161
162
163 0x7FFFFC07,
164 0xFFFFFCFF, 0xFFFFFCFF, 0xFFFFFCFF,
165#endif
166};
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187int checkboard (void)
188{
189 puts ("Board: LICCON Konsole LCD3\n");
190 return (0);
191}
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211phys_size_t initdram (int board_type)
212{
213 volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
214 volatile memctl8xx_t *memctl = &immr->im_memctl;
215 long int size_b0;
216 long int size8, size9;
217 int i;
218
219
220
221
222 upmconfig (UPMA, (uint *)sdram_table, sizeof(sdram_table)/sizeof(uint));
223
224 memctl->memc_mptpr = CONFIG_SYS_MPTPR;
225
226
227 memctl->memc_mar = CONFIG_SYS_MAR;
228
229
230
231
232 memctl->memc_or3 = CONFIG_SYS_OR3_PRELIM;
233 memctl->memc_br3 = CONFIG_SYS_BR3_PRELIM;
234
235
236 memctl->memc_mamr = CONFIG_SYS_MAMR_8COL;
237
238
239 udelay (200);
240 memctl->memc_mcr = MCR_OP_RUN | MCR_MB_CS3 | MCR_MLCF (1) | MCR_MAD (0x05);
241
242
243 udelay (1);
244 memctl->memc_mcr = MCR_OP_RUN | MCR_MB_CS3 | MCR_MLCF (1) | MCR_MAD (0x30);
245 udelay (1);
246 memctl->memc_mcr = MCR_OP_RUN | MCR_MB_CS3 | MCR_MLCF (1) | MCR_MAD (0x30);
247
248 udelay (1);
249 memctl->memc_mcr = MCR_OP_RUN | MCR_MB_CS3 | MCR_MLCF (1) | MCR_MAD (0x06);
250
251 memctl->memc_mamr |= MAMR_PTAE;
252
253 udelay (200);
254
255
256 for (i = 0; i < 10; ++i) {
257 volatile unsigned long *addr =
258 (volatile unsigned long *) SDRAM_BASE3_PRELIM;
259 unsigned long val;
260
261 val = *(addr + i);
262 *(addr + i) = val;
263 }
264
265
266
267
268
269
270 size8 = dram_size (CONFIG_SYS_MAMR_8COL, (long *)SDRAM_BASE3_PRELIM, SDRAM_MAX_SIZE);
271
272 udelay (1000);
273
274
275
276
277 size9 = dram_size (CONFIG_SYS_MAMR_9COL, (long *)SDRAM_BASE3_PRELIM, SDRAM_MAX_SIZE);
278
279 if (size8 < size9) {
280 size_b0 = size9;
281 memctl->memc_mamr = CONFIG_SYS_MAMR_9COL | MAMR_PTAE;
282 udelay (500);
283 } else {
284 size_b0 = size8;
285 memctl->memc_mamr = CONFIG_SYS_MAMR_8COL | MAMR_PTAE;
286 udelay (500);
287 }
288
289
290
291
292
293 memctl->memc_or3 = ((-size_b0) & 0xFFFF0000) |
294 OR_CSNT_SAM | OR_G5LS | SDRAM_TIMING;
295 memctl->memc_br3 = (CONFIG_SYS_SDRAM_BASE & BR_BA_MSK) | BR_MS_UPMA | BR_V;
296 udelay (1000);
297
298 return (size_b0);
299}
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327static long int dram_size (long int mamr_value, long int *base, long int maxsize)
328{
329 volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
330 volatile memctl8xx_t *memctl = &immr->im_memctl;
331
332 memctl->memc_mamr = mamr_value;
333
334 return (get_ram_size(base, maxsize));
335}
336
337
338
339#ifndef PB_ENET_TENA
340# define PB_ENET_TENA ((uint)0x00002000)
341#endif
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359int board_early_init_f (void)
360{
361 volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
362
363
364
365
366
367
368
369
370
371 immr->im_cpm.cp_pbpar &= ~PB_ENET_TENA;
372 immr->im_cpm.cp_pbodr &= ~PB_ENET_TENA;
373 immr->im_cpm.cp_pbdat &= ~PB_ENET_TENA;
374 immr->im_cpm.cp_pbdir |= PB_ENET_TENA;
375
376 return (0);
377}
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395void reset_phy (void)
396{
397 uchar c;
398
399#ifdef DEBUG
400 printf ("### Switch on Ethernet for SCC2 ###\n");
401#endif
402 c = pic_read (0x61);
403#ifdef DEBUG
404 printf ("Old PIC read: reg_61 = 0x%02x\n", c);
405#endif
406 c |= 0x40;
407 c &= ~0x80;
408 pic_write (0x61, c);
409#ifdef DEBUG
410 c = pic_read (0x61);
411 printf ("New PIC read: reg_61 = 0x%02x\n", c);
412#endif
413 udelay (1000);
414}
415
416
417
418
419#define KEYBD_CMD_READ_KEYS 0x01
420#define KEYBD_CMD_READ_VERSION 0x02
421#define KEYBD_CMD_READ_STATUS 0x03
422#define KEYBD_CMD_RESET_ERRORS 0x10
423
424
425#define KEYBD_STATUS_MASK 0x3F
426#define KEYBD_STATUS_H_RESET 0x20
427#define KEYBD_STATUS_BROWNOUT 0x10
428#define KEYBD_STATUS_WD_RESET 0x08
429#define KEYBD_STATUS_OVERLOAD 0x04
430#define KEYBD_STATUS_ILLEGAL_WR 0x02
431#define KEYBD_STATUS_ILLEGAL_RD 0x01
432
433
434#define KEYBD_VERSIONLEN 2
435#define KEYBD_DATALEN 9
436
437
438
439static uchar kbd_addr = CONFIG_SYS_I2C_KEYBD_ADDR;
440
441static uchar *key_match (uchar *);
442
443#define KEYBD_SET_DEBUGMODE '#'
444
445
446
447
448
449
450
451
452
453
454
455
456
457int board_postclk_init (void)
458{
459 kbd_init();
460
461#ifdef CONFIG_MODEM_SUPPORT
462 if (key_pressed()) {
463 disable_putc();
464 gd->do_mdm_init = 1;
465 }
466#endif
467
468 return (0);
469}
470
471struct serial_device * default_serial_console (void)
472{
473 return gd->do_mdm_init ? &serial_scc_device : &serial_smc_device;
474}
475
476static void kbd_init (void)
477{
478 uchar kbd_data[KEYBD_DATALEN];
479 uchar tmp_data[KEYBD_DATALEN];
480 uchar val, errcd;
481 int i;
482
483 i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
484
485 gd->kbd_status = 0;
486
487
488 udelay(1000);
489
490
491 val = KEYBD_CMD_READ_STATUS;
492 i2c_write (kbd_addr, 0, 0, &val, 1);
493 i2c_read (kbd_addr, 0, 0, &errcd, 1);
494
495 errcd &= KEYBD_STATUS_MASK;
496
497 errcd &= ~(KEYBD_STATUS_H_RESET|KEYBD_STATUS_BROWNOUT);
498 if (errcd) {
499 gd->kbd_status |= errcd << 8;
500 }
501
502 val = KEYBD_CMD_RESET_ERRORS;
503 i2c_write (kbd_addr, 0, 0, &val, 1);
504 udelay(1000);
505
506 val = KEYBD_CMD_READ_STATUS;
507 i2c_write (kbd_addr, 0, 0, &val, 1);
508 i2c_read (kbd_addr, 0, 0, &val, 1);
509
510 val &= KEYBD_STATUS_MASK;
511 if (val) {
512 gd->kbd_status |= val;
513 return;
514 }
515
516
517
518
519
520
521
522
523
524
525
526
527
528 memset (tmp_data, 0xFF, KEYBD_DATALEN);
529 for (i=0; i<10; ++i) {
530 val = KEYBD_CMD_READ_KEYS;
531 i2c_write (kbd_addr, 0, 0, &val, 1);
532 i2c_read (kbd_addr, 0, 0, kbd_data, KEYBD_DATALEN);
533
534 if (memcmp(kbd_data, tmp_data, KEYBD_DATALEN) == 0) {
535
536 break;
537 }
538
539 memcpy (tmp_data, kbd_data, KEYBD_DATALEN);
540 udelay (5000);
541 }
542}
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567int misc_init_r (void)
568{
569 uchar kbd_data[KEYBD_DATALEN];
570 char keybd_env[2 * KEYBD_DATALEN + 1];
571 uchar kbd_init_status = gd->kbd_status >> 8;
572 uchar kbd_status = gd->kbd_status;
573 uchar val;
574 char *str;
575 int i;
576
577 if (kbd_init_status) {
578 printf ("KEYBD: Error %02X\n", kbd_init_status);
579 }
580 if (kbd_status) {
581 printf ("*** Keyboard error code %02X ***\n", kbd_status);
582 sprintf (keybd_env, "%02X", kbd_status);
583 setenv ("keybd", keybd_env);
584 return 0;
585 }
586
587
588
589
590
591
592 if ((console_assign (stdout, "serial") < 0) ||
593 (console_assign (stderr, "serial") < 0)) {
594 printf ("Can't assign serial port as output device\n");
595 }
596
597
598 val = KEYBD_CMD_READ_VERSION;
599 i2c_write (kbd_addr, 0, 0, &val, 1);
600 i2c_read (kbd_addr, 0, 0, kbd_data, KEYBD_VERSIONLEN);
601 printf ("KEYBD: Version %d.%d\n", kbd_data[0], kbd_data[1]);
602
603
604 val = KEYBD_CMD_READ_KEYS;
605 i2c_write (kbd_addr, 0, 0, &val, 1);
606 i2c_read (kbd_addr, 0, 0, kbd_data, KEYBD_DATALEN);
607
608 for (i = 0; i < KEYBD_DATALEN; ++i) {
609 sprintf (keybd_env + i + i, "%02X", kbd_data[i]);
610 }
611 setenv ("keybd", keybd_env);
612
613 str = strdup ((char *)key_match (kbd_data));
614#ifdef KEYBD_SET_DEBUGMODE
615 if (kbd_data[0] == KEYBD_SET_DEBUGMODE) {
616 if ((console_assign (stdout, "lcd") < 0) ||
617 (console_assign (stderr, "lcd") < 0)) {
618 printf ("Can't assign LCD display as output device\n");
619 }
620 }
621#endif
622#ifdef CONFIG_PREBOOT
623 setenv ("preboot", str);
624#endif
625 if (str != NULL) {
626 free (str);
627 }
628 return (0);
629}
630
631#ifdef CONFIG_PREBOOT
632
633static uchar kbd_magic_prefix[] = "key_magic";
634static uchar kbd_command_prefix[] = "key_cmd";
635
636static int compare_magic (uchar *kbd_data, uchar *str)
637{
638 uchar compare[KEYBD_DATALEN-1];
639 char *nxt;
640 int i;
641
642
643 memcpy (compare, kbd_data+1, KEYBD_DATALEN-1);
644
645 for (; str != NULL; str = (*nxt) ? (uchar *)(nxt+1) : (uchar *)nxt) {
646 uchar c;
647 int k;
648
649 c = (uchar) simple_strtoul ((char *)str, (char **) (&nxt), 16);
650
651 if (str == (uchar *)nxt) {
652 break;
653 }
654
655
656
657
658
659
660 for (k = 0; k < sizeof(compare); ++k) {
661 if (compare[k] == '\0')
662 continue;
663 if (c == compare[k]) {
664 compare[k] = '\0';
665 break;
666 }
667 }
668 if (k == sizeof(compare)) {
669 return -1;
670 }
671 }
672
673
674
675
676 for (i = 0; i < sizeof(compare); ++i) {
677 if (compare[i])
678 {
679 return -1;
680 }
681 }
682
683 return 0;
684}
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713static uchar *key_match (uchar *kbd_data)
714{
715 char magic[sizeof (kbd_magic_prefix) + 1];
716 uchar *suffix;
717 char *kbd_magic_keys;
718
719
720
721
722
723
724
725
726
727 if ((kbd_magic_keys = getenv ("magic_keys")) == NULL)
728 kbd_magic_keys = "";
729
730
731
732
733 for (suffix=(uchar *)kbd_magic_keys; *suffix || suffix==(uchar *)kbd_magic_keys; ++suffix) {
734 sprintf (magic, "%s%c", kbd_magic_prefix, *suffix);
735#if 0
736 printf ("### Check magic \"%s\"\n", magic);
737#endif
738 if (compare_magic(kbd_data, (uchar *)getenv(magic)) == 0) {
739 char cmd_name[sizeof (kbd_command_prefix) + 1];
740 char *cmd;
741
742 sprintf (cmd_name, "%s%c", kbd_command_prefix, *suffix);
743
744 cmd = getenv (cmd_name);
745#if 0
746 printf ("### Set PREBOOT to $(%s): \"%s\"\n",
747 cmd_name, cmd ? cmd : "<<NULL>>");
748#endif
749 *kbd_data = *suffix;
750 return ((uchar *)cmd);
751 }
752 }
753#if 0
754 printf ("### Delete PREBOOT\n");
755#endif
756 *kbd_data = '\0';
757 return (NULL);
758}
759#endif
760
761#ifdef CONFIG_LCD_INFO
762#include <lcd.h>
763#include <version.h>
764#include <timestamp.h>
765
766void lcd_show_board_info(void)
767{
768 char temp[32];
769
770 lcd_printf ("%s (%s - %s)\n", U_BOOT_VERSION, U_BOOT_DATE, U_BOOT_TIME);
771 lcd_printf ("(C) 2008 DENX Software Engineering GmbH\n");
772 lcd_printf (" Wolfgang DENK, wd@denx.de\n");
773#ifdef CONFIG_LCD_INFO_BELOW_LOGO
774 lcd_printf ("MPC823 CPU at %s MHz\n",
775 strmhz(temp, gd->cpu_clk));
776 lcd_printf (" %ld MB RAM, %ld MB Flash\n",
777 gd->ram_size >> 20,
778 gd->bd->bi_flashsize >> 20 );
779#else
780
781 lcd_printf ("\nMPC823 CPU at %s MHz, %ld MB RAM, %ld MB Flash\n",
782 strmhz(temp, gd->cpu_clk),
783 gd->ram_size >> 20,
784 gd->bd->bi_flashsize >> 20 );
785#endif
786}
787#endif
788
789
790
791#if defined(CONFIG_CMD_BSP)
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819int do_pic (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
820{
821 uchar reg, val;
822
823 switch (argc) {
824 case 3:
825 if (strcmp (argv[1], "read") != 0)
826 break;
827
828 reg = simple_strtoul (argv[2], NULL, 16);
829
830 printf ("PIC read: reg %02x: %02x\n\n", reg, pic_read (reg));
831
832 return 0;
833 case 4:
834 if (strcmp (argv[1], "write") != 0)
835 break;
836
837 reg = simple_strtoul (argv[2], NULL, 16);
838 val = simple_strtoul (argv[3], NULL, 16);
839
840 printf ("PIC write: reg %02x val 0x%02x: %02x => ",
841 reg, val, pic_read (reg));
842 pic_write (reg, val);
843 printf ("%02x\n\n", pic_read (reg));
844 return 0;
845 default:
846 break;
847 }
848 return cmd_usage(cmdtp);
849}
850U_BOOT_CMD(
851 pic, 4, 1, do_pic,
852 "read and write PIC registers",
853 "read reg - read PIC register `reg'\n"
854 "pic write reg val - write value `val' to PIC register `reg'"
855);
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883int do_kbd (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
884{
885 uchar kbd_data[KEYBD_DATALEN];
886 char keybd_env[2 * KEYBD_DATALEN + 1];
887 uchar val;
888 int i;
889
890#if 0
891 i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
892#endif
893
894
895 val = KEYBD_CMD_READ_KEYS;
896 i2c_write (kbd_addr, 0, 0, &val, 1);
897 i2c_read (kbd_addr, 0, 0, kbd_data, KEYBD_DATALEN);
898
899 puts ("Keys:");
900 for (i = 0; i < KEYBD_DATALEN; ++i) {
901 sprintf (keybd_env + i + i, "%02X", kbd_data[i]);
902 printf (" %02x", kbd_data[i]);
903 }
904 putc ('\n');
905 setenv ("keybd", keybd_env);
906 return 0;
907}
908
909U_BOOT_CMD(
910 kbd, 1, 1, do_kbd,
911 "read keyboard status",
912 ""
913);
914
915
916#define CONFIG_SYS_PC_TXD1_ENA 0x0008
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946int do_lsb (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
947{
948 uchar val;
949 immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
950
951 switch (argc) {
952 case 1:
953 val = pic_read (0x60);
954 printf ("LSB is o%s\n", (val & 0x20) ? "n" : "ff");
955 return 0;
956 case 2:
957 val = pic_read (0x60);
958
959 if (strcmp (argv[1], "on") == 0) {
960 val |= 0x20;
961 immr->im_ioport.iop_pcpar &= ~(CONFIG_SYS_PC_TXD1_ENA);
962 immr->im_ioport.iop_pcdat |= CONFIG_SYS_PC_TXD1_ENA;
963 immr->im_ioport.iop_pcdir |= CONFIG_SYS_PC_TXD1_ENA;
964 } else if (strcmp (argv[1], "off") == 0) {
965 val &= ~0x20;
966 immr->im_ioport.iop_pcpar &= ~(CONFIG_SYS_PC_TXD1_ENA);
967 immr->im_ioport.iop_pcdat &= ~(CONFIG_SYS_PC_TXD1_ENA);
968 immr->im_ioport.iop_pcdir |= CONFIG_SYS_PC_TXD1_ENA;
969 } else {
970 break;
971 }
972 pic_write (0x60, val);
973 return 0;
974 default:
975 break;
976 }
977 return cmd_usage(cmdtp);
978}
979
980U_BOOT_CMD(
981 lsb, 2, 1, do_lsb,
982 "check and set LSB switch",
983 "on - switch LSB on\n"
984 "lsb off - switch LSB off\n"
985 "lsb - print current setting"
986);
987
988#endif
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006uchar pic_read (uchar reg)
1007{
1008 return (i2c_reg_read (CONFIG_SYS_I2C_PICIO_ADDR, reg));
1009}
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027void pic_write (uchar reg, uchar val)
1028{
1029 i2c_reg_write (CONFIG_SYS_I2C_PICIO_ADDR, reg, val);
1030}
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047void board_poweroff (void)
1048{
1049
1050 ((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdat &= ~(1 << (31 - 13));
1051
1052 while (1);
1053}
1054
1055#ifdef CONFIG_MODEM_SUPPORT
1056static int key_pressed(void)
1057{
1058 uchar kbd_data[KEYBD_DATALEN];
1059 uchar val;
1060
1061
1062 val = KEYBD_CMD_READ_KEYS;
1063 i2c_write (kbd_addr, 0, 0, &val, 1);
1064 i2c_read (kbd_addr, 0, 0, kbd_data, KEYBD_DATALEN);
1065
1066 return (compare_magic(kbd_data, (uchar *)CONFIG_MODEM_KEY_MAGIC) == 0);
1067}
1068#endif
1069
1070#ifdef CONFIG_POST
1071
1072
1073
1074
1075int post_hotkeys_pressed(void)
1076{
1077 uchar kbd_data[KEYBD_DATALEN];
1078 uchar val;
1079
1080
1081 val = KEYBD_CMD_READ_KEYS;
1082 i2c_write (kbd_addr, 0, 0, &val, 1);
1083 i2c_read (kbd_addr, 0, 0, kbd_data, KEYBD_DATALEN);
1084
1085 return (compare_magic(kbd_data, (uchar *)CONFIG_POST_KEY_MAGIC) == 0);
1086}
1087#endif
1088