]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - sys/boot/arm/at91/boot2/bwct_board.c
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / sys / boot / arm / at91 / boot2 / bwct_board.c
1 #include <sys/cdefs.h>
2 __FBSDID("$FreeBSD$");
3
4 #include <sys/param.h>
5
6 #include "emac.h"
7 #include "lib.h"
8 #include "ee.h"
9 #include "board.h"
10 #include "sd-card.h"
11
12 unsigned char mac[6];
13
14 static void
15 MacFromEE()
16 {       
17 #if 0
18         uint32_t sig;
19
20         sig = 0;
21         EERead(0, (uint8_t *)&sig, sizeof(sig));
22         if (sig != 0xaa55aa55)
23                 return;
24         EERead(48, mac, 3);
25         EERead(48+5, mac+3, 3);
26 #else
27         mac[0] = 0x00;
28         mac[1] = 0x0e;
29         mac[2] = 0x42;
30         mac[3] = 0x02;
31         mac[4] = 0x00;
32         mac[5] = 0x21;
33 #endif
34         printf("MAC %x:%x:%x:%x:%x:%x\n", mac[0],
35           mac[1], mac[2], mac[3], mac[4], mac[5]);
36 }
37
38 #ifdef XMODEM_DL
39 #define FLASH_OFFSET (0 * FLASH_PAGE_SIZE)
40 #define KERNEL_OFFSET (220 * FLASH_PAGE_SIZE)
41 #define KERNEL_LEN (6 * 1024 * FLASH_PAGE_SIZE)
42
43 static void
44 UpdateFlash(int offset)
45 {
46         char *addr = (char *)0x20000000 + (1 << 20); /* Load to base + 1MB */
47         int len, i, off;
48
49         while ((len = xmodem_rx(addr)) == -1)
50                 continue;
51         printf("\nDownloaded %u bytes.\n", len);
52         for (i = 0; i < len; i+= FLASH_PAGE_SIZE) {
53                 off = i + offset;
54                 SPI_WriteFlash(off, addr + i, FLASH_PAGE_SIZE);
55         }
56 }
57 void
58 Update(void)
59 {
60         UpdateFlash(FLASH_OFFSET);
61 }
62
63 #else
64 void
65 Update(void)
66 {
67 }
68 #endif
69
70 void
71 board_init(void)
72 {
73     EEInit();
74     MacFromEE();
75     EMAC_Init();
76     sdcard_init();
77     EMAC_SetMACAddress(mac);
78
79 }
80
81 #include "../bootspi/ee.c"
82
83 int
84 drvread(void *buf, unsigned lba, unsigned nblk)
85 {
86     return (MCI_read((char *)buf, lba << 9, nblk << 9));
87 }