Add support for the CENTIPAD board (http://www.harerod.de/centipad/index.html)
	(which is a very cool, very small ARM board)
Add support for KB9202B (it has different memory)
Make BOOT_FLAVOR settable
Minor cleanup nits

Approved by: re@
This commit is contained in:
Warner Losh 2007-07-13 14:27:05 +00:00
parent d2545c13b3
commit 229af622b8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=171426
11 changed files with 197 additions and 34 deletions

View File

@ -5,8 +5,8 @@
__at91_boot_Makefile.inc__:
# tsc, bwct, kb920x are the supported flavors
BOOT_FLAVOR=kb920x
# tsc, bwct, kb920x, centipad are the supported flavors
BOOT_FLAVOR?=kb920x
CFLAGS=-Os -mcpu=arm9 -ffreestanding \
-I${.CURDIR}/../libat91 \

View File

@ -26,3 +26,4 @@
void Update(void);
void board_init(void);
int drvread(void *, unsigned, unsigned);

View File

@ -26,9 +26,7 @@ __FBSDID("$FreeBSD$");
#include <stdarg.h>
#include "emac.h"
#include "lib.h"
#include "sd-card.h"
#include "board.h"
#define RBX_ASKNAME 0x0 /* -a */
@ -84,8 +82,6 @@ static const unsigned char flags[NOPT] = {
RBX_VERBOSE
};
unsigned char mac[6] = { 0x42, 0x53, 0x44, 0, 0, 1 };
unsigned dsk_start;
static char cmd[512];
static char kname[1024];
@ -96,7 +92,6 @@ static void load(void);
static int parse(void);
static int xfsread(ino_t, void *, size_t);
static int dskread(void *, unsigned, unsigned);
static int drvread(void *, unsigned, unsigned);
#include "ufsread.c"
@ -147,10 +142,6 @@ main(void)
ino_t ino;
board_init();
EMAC_Init();
EMAC_SetMACAddress(mac);
while (sdcard_init() == 0)
printf("Looking for SD card\n");
dmadat = (void *)(0x20000000 + (16 << 20));
/* Process configuration file */
@ -179,14 +170,11 @@ main(void)
xputchar('\n');
autoboot = 0;
c = 0;
printf("cmd is '%s'\n", cmd);
if (parse())
xputchar('\a');
#ifdef XMODEM_DL
else if (*cmd == '*')
Update();
else if (*cmd == '#')
reset();
Update();
#endif
else
load();
@ -281,14 +269,14 @@ dskread(void *buf, unsigned lba, unsigned nblk)
dp = (void *)(sec + DOSPARTOFF);
for (i = 0; i < NDOSPART; i++) {
if (dp[i].dp_typ == DOSPTYP_386BSD)
break;
break;
}
if (i == NDOSPART)
return -1;
return -1;
// Although dp_start is aligned within the disk partition structure,
// DOSPARTOFF is 446, which is only word (2) aligned, not longword (4)
// aligned. Cope by using memcpy to fetch the start of this partition.
memcpy(&dsk_start, &dp[i].dp_start, 4);
memcpy(&dsk_start, &dp[1].dp_start, 4);
if (drvread(sec, dsk_start + LABELSECTOR, 1))
return -1;
d = (void *)(sec + LABELOFFSET);
@ -306,12 +294,3 @@ dskread(void *buf, unsigned lba, unsigned nblk)
}
return drvread(buf, dsk_start + lba, nblk);
}
static int
drvread(void *buf, unsigned lba, unsigned nblk)
{
static unsigned c = 0x2d5c7c2f;
printf("%c\b", c = c << 8 | c >> 24);
return (MCI_read((char *)buf, lba << 9, nblk << 9));
}

View File

@ -0,0 +1,87 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include "emac.h"
#include "lib.h"
#include "ee.h"
#include "board.h"
#include "sd-card.h"
unsigned char mac[6];
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]);
}
#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
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);
}
}
void
Update(void)
{
UpdateFlash(FLASH_OFFSET);
}
#else
void
Update(void)
{
}
#endif
void
board_init(void)
{
EEInit();
MacFromEE();
EMAC_Init();
sdcard_init();
EMAC_SetMACAddress(mac);
}
#include "../bootspi/ee.c"
int
drvread(void *buf, unsigned lba, unsigned nblk)
{
return (MCI_read((char *)buf, lba << 9, nblk << 9));
}

View File

@ -0,0 +1,73 @@
/*-
* Copyright (c) 2006 M. Warner Losh. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include "emac.h"
#include "lib.h"
#include "board.h"
#include "sd-card.h"
unsigned char mac[6] = { 0x42, 0x53, 0x44, 0, 1, 1 };
static void
MacFromEE()
{
#if 0
uint32_t sig;
sig = 0;
ReadEEPROM(12 * 1024, (uint8_t *)&sig, sizeof(sig));
if (sig != 0x92021054)
return;
ReadEEPROM(12 * 1024 + 4, mac, 6);
#endif
printf("MAC %x:%x:%x:%x:%x:%x\n", mac[0],
mac[1], mac[2], mac[3], mac[4], mac[5]);
}
void
Update(void)
{
}
void
board_init(void)
{
InitEEPROM();
MacFromEE();
EMAC_Init();
EMAC_SetMACAddress(mac);
while (sdcard_init() == 0)
printf("Looking for SD card\n");
}
int
drvread(void *buf, unsigned lba, unsigned nblk)
{
return (MCI_read((char *)buf, lba << 9, nblk << 9));
}

View File

@ -31,8 +31,9 @@ __FBSDID("$FreeBSD$");
#include "emac.h"
#include "lib.h"
#include "board.h"
#include "sd-card.h"
extern unsigned char mac[];
unsigned char mac[6] = { 0x42, 0x53, 0x44, 0, 0, 1 };
static void
MacFromEE()
@ -40,7 +41,7 @@ MacFromEE()
uint32_t sig;
sig = 0;
ReadEEPROM(12 * 1024, (uint8_t *)&sig, sizeof(sig));
if (sig != 0xaa55aa55)
if (sig != 0x92021054)
return;
ReadEEPROM(12 * 1024 + 4, mac, 6);
printf("MAC %x:%x:%x:%x:%x:%x\n", mac[0],
@ -57,4 +58,14 @@ board_init(void)
{
InitEEPROM();
MacFromEE();
EMAC_Init();
EMAC_SetMACAddress(mac);
while (sdcard_init() == 0)
printf("Looking for SD card\n");
}
int
drvread(void *buf, unsigned lba, unsigned nblk)
{
return (MCI_read((char *)buf, lba << 9, nblk << 9));
}

View File

@ -8,7 +8,7 @@ SRCS=at91rm9200_lowlevel.c delay.c eeprom.c emac.c emac_init.c getc.c \
putchar.c printf.c reset.c spi_flash.c xmodem.c \
sd-card.c strcvt.c strlen.c strcmp.c memcpy.c strcpy.c \
memset.c memcmp.c
SRCS+=ashldi3.c divsi3.S
SRCS+=ashldi3.c divsi3.c
NO_MAN=
.if ${MK_TAG_LIST} != "no"

View File

@ -62,7 +62,7 @@ _init(void)
AT91C_BASE_PIOC->PIO_CODR = AT91C_PIO_PC10;
#endif
#ifdef BOOT_KB920X
#if defined(BOOT_KB920X)
AT91C_BASE_PIOC->PIO_PER = AT91C_PIO_PC18 | AT91C_PIO_PC19 |
AT91C_PIO_PC20;
AT91C_BASE_PIOC->PIO_OER = AT91C_PIO_PC18 | AT91C_PIO_PC19 |
@ -136,7 +136,11 @@ _init(void)
AT91C_BASE_EBI->EBI_CSA = value;
AT91C_BASE_SDRC->SDRC_CR =
#ifdef KB9202_B
AT91C_SDRC_NC_10 |
#else
AT91C_SDRC_NC_9 |
#endif
AT91C_SDRC_NR_13 |
AT91C_SDRC_NB_4_BANKS |
AT91C_SDRC_CAS_2 |

View File

@ -39,6 +39,14 @@ typedef unsigned short sdram_size_t;
#define OSC_MAIN_MULT 90
#endif
#ifdef BOOT_CENTIPAD
/* The following divisor sets PLLA frequency: e.g. 10/5 * 90 = 180MHz */
#define OSC_MAIN_FREQ_DIV 5 /* for 10MHz osc */
#define SDRAM_WIDTH AT91C_SDRC_DBW_16_BITS
typedef unsigned short sdram_size_t;
#define OSC_MAIN_MULT 90
#endif
#ifdef BOOT_BWCT
/* The following divisor sets PLLA frequency: e.g. 16/4 * 45 = 180MHz */
#define OSC_MAIN_FREQ_DIV 4 /* for 16MHz osc */

View File

@ -380,7 +380,7 @@ AT91F_MII_WritePhy (AT91PS_EMAC pEmac, unsigned char addr, unsigned short s)
static void
MII_GetLinkSpeed(AT91PS_EMAC pEmac)
{
#if defined(BOOT_TSC) | defined(BOOT_KB920X)
#if defined(BOOT_TSC) || defined(BOOT_KB920X) || defined(BOOT_CENTIPAD)
unsigned short stat2;
#endif
unsigned update;
@ -394,7 +394,7 @@ MII_GetLinkSpeed(AT91PS_EMAC pEmac)
update |= AT91C_EMAC_SPD;
update |= AT91C_EMAC_FD;
#endif
#ifdef BOOT_KB920X
#if defined(BOOT_KB920X) || defined(BOOT_CENTIPAD)
stat2 = AT91F_MII_ReadPhy(pEmac, MII_STS2_REG);
if (!(stat2 & MII_STS2_LINK))
return ;

View File

@ -114,7 +114,7 @@ typedef struct {
/* MII registers definition */
#define MII_STS_REG 0x01
#define MII_STS_LINK_STAT 0x04
#ifdef BOOT_KB920X
#if defined(BOOT_KB920X) || defined(BOOT_CENTIPAD)
#define MII_STS2_REG 0x11
#define MII_STS2_LINK 0x400
#define MII_STS2_100TX 0x4000