diff options
author | ticso <ticso@FreeBSD.org> | 2007-12-23 14:57:35 +0000 |
---|---|---|
committer | ticso <ticso@FreeBSD.org> | 2007-12-23 14:57:35 +0000 |
commit | 2d76c8dccf04b510ffd25f126563b44fc019c518 (patch) | |
tree | 0a37a81bcc49b2e12e0b848e74937f73e41c6985 /sys/boot | |
parent | be62f6be4e3edc66289ba8cf8264b6312b937279 (diff) | |
download | FreeBSD-src-2d76c8dccf04b510ffd25f126563b44fc019c518.zip FreeBSD-src-2d76c8dccf04b510ffd25f126563b44fc019c518.tar.gz |
- remove code from oroginal file, which is not required on BWCT boards
- Be more chatty on startup, since we have enough code space on
AT91RM9200
- init DS1672 charging
- init USART GPIO
Diffstat (limited to 'sys/boot')
-rw-r--r-- | sys/boot/arm/at91/boot2/bwct_board.c | 138 |
1 files changed, 86 insertions, 52 deletions
diff --git a/sys/boot/arm/at91/boot2/bwct_board.c b/sys/boot/arm/at91/boot2/bwct_board.c index 2a7940e..20f4140 100644 --- a/sys/boot/arm/at91/boot2/bwct_board.c +++ b/sys/boot/arm/at91/boot2/bwct_board.c @@ -3,79 +3,113 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> +#include "at91rm9200_lowlevel.h" +#include "at91rm9200.h" #include "emac.h" #include "lib.h" #include "ee.h" #include "board.h" #include "sd-card.h" -unsigned char mac[6]; +unsigned char mac[6] = { 0x00, 0x0e, 0x42, 0x02, 0x00, 0x28 }; + +static void USART0_Init(); +static void USART1_Init(); +static void USART2_Init(); +static void USART3_Init(); +static void DS1672_Init(); static void -MacFromEE() -{ -#if 0 - uint32_t sig; - - sig = 0; - EERead(0, (uint8_t *)&sig, sizeof(sig)); - if (sig != 0xaa55aa55) - return; - EERead(48, mac, 3); - EERead(48+5, mac+3, 3); -#else - mac[0] = 0x00; - mac[1] = 0x0e; - mac[2] = 0x42; - mac[3] = 0x02; - mac[4] = 0x00; - mac[5] = 0x21; -#endif - printf("MAC %x:%x:%x:%x:%x:%x\n", mac[0], - mac[1], mac[2], mac[3], mac[4], mac[5]); +DS1672_Init() { + uint8_t buf[] = {0x00, 0xa9}; + + EEWrite(0xd0, buf, sizeof(buf)); } -#ifdef XMODEM_DL -#define FLASH_OFFSET (0 * FLASH_PAGE_SIZE) -#define KERNEL_OFFSET (220 * FLASH_PAGE_SIZE) -#define KERNEL_LEN (6 * 1024 * FLASH_PAGE_SIZE) +static void +USART0_Init() { + + AT91PS_PIO pPio = (AT91PS_PIO)AT91C_BASE_PIOA; + AT91PS_PMC pPMC = (AT91PS_PMC)AT91C_BASE_PMC; + + // setup GPIO + pPio->PIO_ASR = AT91C_PA17_TXD0 | AT91C_PA18_RXD0; + pPio->PIO_PDR = AT91C_PA17_TXD0 | AT91C_PA18_RXD0; + + // enable power + pPMC->PMC_PCER = 1u << AT91C_ID_US0; +} static void -UpdateFlash(int offset) -{ - char *addr = (char *)0x20000000 + (1 << 20); /* Load to base + 1MB */ - int len, i, off; - - while ((len = xmodem_rx(addr)) == -1) - continue; - printf("\nDownloaded %u bytes.\n", len); - for (i = 0; i < len; i+= FLASH_PAGE_SIZE) { - off = i + offset; - SPI_WriteFlash(off, addr + i, FLASH_PAGE_SIZE); - } +USART1_Init() { + + AT91PS_PIO pPio = (AT91PS_PIO)AT91C_BASE_PIOA; + AT91PS_PMC pPMC = (AT91PS_PMC)AT91C_BASE_PMC; + + // setup GPIO + pPio->PIO_ASR = AT91C_PB20_TXD1 | AT91C_PB21_RXD1; + pPio->PIO_PDR = AT91C_PB20_TXD1 | AT91C_PB21_RXD1; + + // enable power + pPMC->PMC_PCER = 1u << AT91C_ID_US1; } -void -Update(void) -{ - UpdateFlash(FLASH_OFFSET); + +static void +USART2_Init() { + + AT91PS_PIO pPio = (AT91PS_PIO)AT91C_BASE_PIOA; + AT91PS_PMC pPMC = (AT91PS_PMC)AT91C_BASE_PMC; + + // setup GPIO + pPio->PIO_ASR = AT91C_PA23_TXD2 | AT91C_PA22_RXD2; + pPio->PIO_PDR = AT91C_PA23_TXD2 | AT91C_PA22_RXD2; + + // enable power + pPMC->PMC_PCER = 1u << AT91C_ID_US2; } -#else -void -Update(void) -{ +static void +USART3_Init() { + + AT91PS_PIO pPio = (AT91PS_PIO)AT91C_BASE_PIOA; + AT91PS_PMC pPMC = (AT91PS_PMC)AT91C_BASE_PMC; + + // setup GPIO + pPio->PIO_BSR = AT91C_PA5_TXD3 | AT91C_PA6_RXD3; + pPio->PIO_PDR = AT91C_PA5_TXD3 | AT91C_PA6_RXD3; + + // enable power + pPMC->PMC_PCER = 1u << AT91C_ID_US3; } -#endif void board_init(void) { - EEInit(); - MacFromEE(); - EMAC_Init(); - sdcard_init(); - EMAC_SetMACAddress(mac); + printf("\n\n"); + printf("BWCT FSB-A920-1\n"); + printf("http://www.bwct.de\n"); + printf("\n"); + printf("AT92RM9200 180MHz\n"); + printf("Initialising USART0\n"); + USART0_Init(); + printf("Initialising USART1\n"); + USART1_Init(); + printf("Initialising USART2\n"); + USART2_Init(); + printf("Initialising USART3\n"); + USART3_Init(); + printf("Initialising TWI\n"); + EEInit(); + printf("Initialising DS1672\n"); + DS1672_Init(); + printf("Initialising Ethernet\n"); + printf("MAC %x:%x:%x:%x:%x:%x\n", mac[0], + mac[1], mac[2], mac[3], mac[4], mac[5]); + EMAC_Init(); + EMAC_SetMACAddress(mac); + printf("Initialising SD-card\n"); + sdcard_init(); } #include "../bootspi/ee.c" |