|
From: Stefan E. <se...@us...> - 2003-04-03 15:03:33
|
Update of /cvsroot/blob/blob/src/blob
In directory sc8-pr-cvs1:/tmp/cvs-serv26874/src/blob
Modified Files:
Makefile.am
Added Files:
dafit.c
Log Message:
- add PT VibXpert (DAFIT) support
--- NEW FILE: dafit.c ---
/*
* dafit.c: PT VibXpert specific tweaks
*
* Copyright (C) 2001 Erik Mouw (J.A...@it...)
* Copyright (C) 2001,2002,2003 Stefan Eletzhofer
* (ste...@el...)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ident "$Id: dafit.c,v 1.1 2003/04/03 15:02:58 seletz Exp $"
/**********************************************************************
* includes
*/
#ifdef HAVE_CONFIG_H
# include <blob/config.h>
#endif
#include <blob/main.h>
#include <blob/arch.h>
#include <blob/errno.h>
#include <blob/error.h>
#include <blob/util.h>
#include <blob/reboot.h>
#include <blob/serial.h>
#include <blob/flash.h>
#include <blob/init.h>
#include <blob/command.h>
#include <blob/uucodec.h>
#include <blob/time.h>
#include <blob/partition.h>
#include <blob/led.h>
#include <blob/sa1100.h>
#include <blob/sa1111.h>
#include <blob/generic_io.h>
#include <blob/pcmcia.h>
#include <blob/cf.h>
#include <blob/ide.h>
#include <blob/tar.h>
#include <net/smc9196.h>
/**********************************************************************
* defines
*/
#if 0
#define CONFIG_PCMCIA_SUPPORT
#define CONFIG_BLOB_PARTITION
#define CONFIG_GIO_RAM
#define CONFIG_GIO_FLASH
#define CONFIG_GIO_BLOB_PARTITION
#define CONFIG_CMD_SYSUPDATE
#endif
/* more readable IMHO */
#define MEM( x ) (*((u32 *)(x)))
#define SET(reg,bit) ((reg) |= (1<<(bit)))
#define RST(reg,bit) ((reg) &= ~(1<<(bit)))
#define DAFIT_DEBUG 1
#if DAFIT_DEBUG
# define DBG( x, args... ) if ( dbg>=x ) printf( args )
#else
# define DBG( x, args... )
#endif
/**********************************************************************
* globals
*/
extern blob_status_t blob_status;
/**********************************************************************
* module globals
*/
#if SYSTEM3_DEBUG
static int dbg = 1;
#else
static int sys3_dbg = 0;
#endif
/* flash descriptor for System3 flash. */
/* System 3 uses 2xINTEL e28F640 Chips */
static const flash_descriptor_t system3_flash_descriptors[] =
{
{
size: 2 * 128 * 1024,
num: 64,
lockable: 1
},
{
/* NULL block */
},
};
#if defined(CONFIG_BLOB_PARTITION)
/* default partition table for SYSTEM3
System3 flash layout
~~~~~~~~~~~~~~~~~~~~
16Mb Flash
256k erase size
0x00000000 BLOB 256k
0x00040000 CONFIG 256k
0x00080000 KERNEL 1024k
0x00180000 INITRD 1536k
0x00300000 ROOT 6M
0x00900000 DATA 7M
0x01000000 total 16M
Note:
- system3 partitions are named like the files they're flashed
with. This is to keep updating easy: Just loop through all
files that are on our update media and flash them on the partition
named like the file.
*/
static const blob_partition_t system3_default_partition_table[] = {
{
/* start of table */
magic: BLOB_DEFAULT_PART_TABLE_MAGIC,
next: sizeof(blob_partition_t),
offset: 0x00000000, /* absolute base address */
size: 16 * 1024 * 1024 /* total size of the flash */
},
{
/* blob itself */
magic: BLOB_PART_VALID_MAGIC,
next: sizeof(blob_partition_t),
offset: BLOB_FLASH_BASE,
size: BLOB_FLASH_LEN,
name: "blob",
mem_base: BLOB_RAM_BASE
},
{
/* system config area */
magic: BLOB_PART_VALID_MAGIC,
next: sizeof(blob_partition_t),
offset: CONFIG_FLASH_BASE,
size: CONFIG_FLASH_LEN,
name: "config.tar",
flags: 0
},
{
/* kernel */
magic: BLOB_PART_VALID_MAGIC,
next: sizeof(blob_partition_t),
offset: KERNEL_FLASH_BASE,
size: KERNEL_FLASH_LEN,
name: "zImage",
flags: BLOB_PART_FLAG_LOAD | BLOB_PART_FLAG_EXEC,
mem_base: KERNEL_RAM_BASE,
entry_point: KERNEL_RAM_BASE
},
{
/* ramdisk */
magic: BLOB_PART_VALID_MAGIC,
next: sizeof(blob_partition_t),
offset: RAMDISK_FLASH_BASE,
size: RAMDISK_FLASH_LEN,
name: "initrd.gz",
flags: BLOB_PART_FLAG_LOAD,
mem_base: RAMDISK_RAM_BASE
},
{
/* root (cramfs) */
magic: BLOB_PART_VALID_MAGIC,
next: sizeof(blob_partition_t),
offset: ROOTFS_FLASH_BASE,
size: ROOTFS_FLASH_LEN,
name: "cramfs",
flags: BLOB_PART_FLAG_CRAMFS,
},
{
/* data (cramfs) */
magic: BLOB_PART_VALID_MAGIC,
next: sizeof(blob_partition_t),
offset: DATAFS_FLASH_BASE,
size: DATAFS_FLASH_LEN,
name: "data.img",
flags: BLOB_PART_FLAG_CRAMFS,
},
{
/* last entry */
magic: BLOB_PART_LAST_MAGIC
}
};
#endif
/**********************************************************************
* static functions
*/
static char module_version[] = "$Id: dafit.c,v 1.1 2003/04/03 15:02:58 seletz Exp $";
/*********************************************************************
* init_system3_flash - inits system 3 flash driver
*/
static void init_system3_flash_driver(void)
{
flash_descriptors = system3_flash_descriptors;
flash_driver = &intel32_flash_driver;
}
__initlist(init_system3_flash_driver, INIT_LEVEL_DRIVER_SELECTION);
/*********************************************************************
* system3_init_hardware - inits system 3 LL hardware stuff
*/
static void system3_init_hardware(void)
{
/* init on-board CPLD */
MEM(SYSTEM3_CTRL_0) = 0x03;
MEM(SYSTEM3_CTRL_1) = 0x00;
MEM(SYSTEM3_CTRL_2) = 0x00;
/* initialize GPIO states */
GPDR = 0x0f35a7fc;
GPSR |= GPIO_GPIO15 | GPIO_GPIO20; /* 15: core fast, 20: SCL */
GPCR |= 0x070527fc;
/* activate SYSCLCK for keyboard controller */
RST( MEM(TUCR), 31 );
GAFR |= GPIO_32_768kHz;
GPDR |= GPIO_32_768kHz;
/* 3.6864 MHz SYSCLK */
TUCR = TUCR_3_6864MHz;
msleep( 1 );
MEM(SYSTEM3_CTRL_1) = 0x04;
/* tweak blob config */
blob_status.boot_delay = 1;
/* select drivers */
reboot_driver = &sa11x0_reboot_driver;
serial_driver = &sa11x0_serial_driver;
led_driver = &sa11x0_gpio_led_driver;
}
__initlist(system3_init_hardware, INIT_LEVEL_DRIVER_SELECTION);
#if defined(CONFIG_BLOB_PARTITION)
/**********************************************************************
* system3 default partition table
*/
static void system3_set_partition_table(void)
{
/* the default partition table */
default_partition_table = system3_default_partition_table;
/* we don't know where the flash partition table will live, so
* put the pointer at 0x0000000 and let the partition table
* parser figure out.
*/
flash_partition_table = (blob_partition_t*)0x00000000;
}
__initlist(system3_set_partition_table, INIT_LEVEL_OTHER_STUFF);
/* FIXME: need to think if this is the correct init level, we might
* want to have this before the param list stuff starts running */
#endif
/*****************************************************************
* sysver - print system version
*/
static int sysver_cmd( int argc, char *argv[] )
{
printf( "version: '%s'\n", module_version );
switch ( PT_ID_BOARDID ) {
case PT_BOARD_ALPHA:
printf( "ALPHA Board" );
break;
case PT_BOARD_SYS3:
printf( "SYSTEM 3 Board" );
break;
case PT_BOARD_DAFIT:
printf( "DAFIT Board" );
break;
default:
printf( "UNKNOWN Board (ID 0x%X)", PT_ID_BOARDID );
break;
}
printf( " revision 0x%02X.\n", PT_ID_REVISION );
return 0;
}
static char sysver_help[] = "print BLOB and system3 version number\n";
__commandlist(sysver_cmd, "sysver", sysver_help);
/**********************************************************************
* setdbg - set debug level
*/
int setdbg_cmd( int argc, char *argv[] )
{
extern int cf_dbg_set(int);
int ret;
u32 lvl;
if ( argc < 2 ) return -EINVAL;
ret = strtou32(argv[1], &lvl);
if ( ret < 0 ) return -EINVAL;
dbg = lvl;
#if defined(CONFIG_PCMCIA_SUPPORT)
if ( lvl>5 ) {
cf_dbg_set( 5 );
tar_dbg_set( 5 );
} else {
cf_dbg_set( 0 );
tar_dbg_set( 0 );
}
if ( lvl>10 ) {
io_dbg_set( 5 );
pcmcia_dbg_set( 5 );
} else {
io_dbg_set( 0 );
pcmcia_dbg_set( 0 );
}
#endif
printf( "setdbg: debug level set to %d\n", dbg );
return 0;
}
static char setdbg_help[] = "setdbg level\n";
__commandlist(setdbg_cmd, "setdbg", setdbg_help);
#if defined(CONFIG_PCMCIA_SUPPORT)
/*****************************************************************
* pcmcia_init - initialize PCMCIA
*/
int pcmcia_init()
{
printf( "PT Digital Board PCMCIA init\n" );
return 0;
}
#endif
/*****************************************************************
* misc utility funcs
*/
/*****************************************************************
* manually reference flash and download commands until they
* are in libblob.
*/
#if 0
extern int cf_test_module( int argc, char *argv[] );
extern char cf_help[];
__commandlist(cf_test_module, "cftest", cf_help);
#endif
#if 1
extern int fwrite_cmd(int argc, char *argv[]);
extern char fwrite_help[];
__commandlist(fwrite_cmd, "fwrite", fwrite_help);
extern int ferase_cmd(int argc, char *argv[]);
extern char ferase_help[];
__commandlist(ferase_cmd, "ferase", ferase_help);
#endif
extern int dlfile_cmd(int argc, char *argv[]);
extern char dlfile_help[];
__commandlist(dlfile_cmd, "dlfile", dlfile_help);
int bootp_cmd(int argc, char *argv[])
{
int ret = 0;
char *file;
extern char *do_bootp(void);
ret = smc_init( 0x18000000 );
if ( ret ) {
printf( "smc_init failed: %d\n", ret );
return ret;
}
file = do_bootp();
if ( file )
printf( "TFTP File: '%s'\n", file );
return 0;
}
char bootp_help[] = "bootp test command. No args.\n";;
__commandlist(bootp_cmd, "net_bootp", bootp_help);
int arp_cmd(int argc, char *argv[])
{
int ret = 0;
extern int do_arp( u8 *, u8 *);
u8 serverip[4] = { 192, 168, 1, 11 };
u8 servereth[6];
ret = smc_init( 0x18000000 );
if ( ret ) {
printf( "smc_init failed: %d\n", ret );
return ret;
}
ret = do_arp( servereth, serverip );
printf( "%s: got eth addr %02x:%02x:%02x:%02x:%02x:%02x\n", __FUNCTION__,
servereth[0], servereth[1], servereth[2], servereth[3], servereth[4],
servereth[5] );
return 0;
}
char arp_help[] = "arp test command. No args.\n";;
__commandlist(arp_cmd, "arp", arp_help);
int setip_cmd( int argc, char *argv[] )
{
extern u8 clientipaddress[4];
extern u8 serveripaddress[4];
u8 *ip;
char *ptr, *num;
int i, fini;
if ( argc < 3 )
return -EINVAL;
switch ( argv[1][0] ) {
case 'c':
case 'C':
ip = clientipaddress;
break;
case 's':
case 'S':
ip = serveripaddress;
break;
default:
return -EINVAL;
break;
}
num = ptr = argv[2];
fini=0;
for ( i=0; i<4 || !fini; i++ ) {
u32 n;
while ( *ptr != '\0' && *ptr != '.' )
ptr++;
if ( *ptr == '\0' )
fini = 1;
*ptr = 0;
strtou32( num, &n );
ip[i]=n;
num = ++ptr;
}
if ( fini && i<4 ) {
printf( "error parsing ip.\n" );
return -EINVAL;
}
printf( "Set IP to %d.%d.%d.%d\n",
ip[0], ip[1], ip[2], ip[3] );
return 0;
}
char setip_help[] = "setip command. Set IP addresses for tftp.\n"
"usage: setip {client|server} ip\n"
"\tip in usual dotted-quad format please.\n";;
__commandlist(setip_cmd, "setip", setip_help);
int tftp_cmd(int argc, char *argv[])
{
int ret = 0;
extern int do_tftp(char *file, unsigned long addr, unsigned long *size);
unsigned long size = 0;
char *tftp_file = "update.tar";
if ( argc>1 ) {
tftp_file = argv[1];
} else {
printf( "No filename given, using '%s'\n",
tftp_file );
}
ret = smc_init( 0x18000000 );
if ( ret ) {
printf( "smc_init failed: %d\n", ret );
return ret;
}
ret = do_tftp( tftp_file, RAM_START, &size );
if ( ret ) {
return -EINVAL;
}
printf( "%s: file '%s' loaded via tftp to address 0x%08x.\n",
__FUNCTION__, tftp_file, RAM_START );
return 0;
}
char tftp_help[] = "tftp command.\n"
"usage: tftp filename\n"
"\tdownloads file over TFTP to RAM.\n"
"\tUse setip to set client and server IP addresses\n";
__commandlist(tftp_cmd, "tftp", tftp_help);
Index: Makefile.am
===================================================================
RCS file: /cvsroot/blob/blob/src/blob/Makefile.am,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- Makefile.am 18 Mar 2003 17:38:15 -0000 1.38
+++ Makefile.am 3 Apr 2003 15:02:57 -0000 1.39
@@ -86,7 +86,7 @@
uucodec.c \
xmodem.c \
smc9196.c \
- accelent_sa.c assabet.c brutus.c badge4.c cep.c clart.c frodo.c \
+ accelent_sa.c assabet.c brutus.c badge4.c cep.c clart.c dafit.c frodo.c \
hackkit.c h3600.c idr.c jornada720.c lart.c miniprint.c nesa.c pleb.c \
shannon.c system3.c trizeps.c pxa_idp.c
|