mirror of
https://github.com/AsahiLinux/u-boot
synced 2025-02-26 04:17:09 +00:00
* Patch by Nicolas Lacressonnire, 12 Nov 2003:
update for for Atmel AT91RM9200DK development kit: - support for environment variables in DataFlash - Atmel DataFlash AT45DB1282 support * Patch by Jeff Carr, 11 Nov 2003: add support for new version of 8270 processors * Patches by George G. Davis, 05 Nov 2003: - only pass the ARM linux initrd tag to the kernel when an initrd is actually present - update omap1510inn configuration file
This commit is contained in:
parent
8bf3b005dd
commit
5779d8d985
16 changed files with 662 additions and 281 deletions
13
CHANGELOG
13
CHANGELOG
|
@ -2,6 +2,19 @@
|
||||||
Changes since U-Boot 1.0.0:
|
Changes since U-Boot 1.0.0:
|
||||||
======================================================================
|
======================================================================
|
||||||
|
|
||||||
|
* Patch by Nicolas Lacressonnière, 12 Nov 2003:
|
||||||
|
update for for Atmel AT91RM9200DK development kit:
|
||||||
|
- support for environment variables in DataFlash
|
||||||
|
- Atmel DataFlash AT45DB1282 support
|
||||||
|
|
||||||
|
* Patch by Jeff Carr, 11 Nov 2003:
|
||||||
|
add support for new version of 8270 processors
|
||||||
|
|
||||||
|
* Patches by George G. Davis, 05 Nov 2003:
|
||||||
|
- only pass the ARM linux initrd tag to the kernel when an initrd
|
||||||
|
is actually present
|
||||||
|
- update omap1510inn configuration file
|
||||||
|
|
||||||
* Patches by Stephan Linz, 3 Nov 2003:
|
* Patches by Stephan Linz, 3 Nov 2003:
|
||||||
- more endianess fixes for LAN91C111 driver
|
- more endianess fixes for LAN91C111 driver
|
||||||
- CFG_HZ configuration patch for NIOS Cyclone board
|
- CFG_HZ configuration patch for NIOS Cyclone board
|
||||||
|
|
14
README
14
README
|
@ -1760,6 +1760,20 @@ to save the current settings.
|
||||||
The size in bytes of the EEPROM device.
|
The size in bytes of the EEPROM device.
|
||||||
|
|
||||||
|
|
||||||
|
- CFG_ENV_IS_IN_DATAFLASH:
|
||||||
|
|
||||||
|
Define this if you have a DataFlash memory device which you
|
||||||
|
want to use for the environment.
|
||||||
|
|
||||||
|
- CFG_ENV_OFFSET:
|
||||||
|
- CFG_ENV_ADDR:
|
||||||
|
- CFG_ENV_SIZE:
|
||||||
|
|
||||||
|
These three #defines specify the offset and size of the
|
||||||
|
environment area within the total memory of your DataFlash placed
|
||||||
|
at the specified address.
|
||||||
|
|
||||||
|
|
||||||
- CFG_SPI_INIT_OFFSET
|
- CFG_SPI_INIT_OFFSET
|
||||||
|
|
||||||
Defines offset to the initial SPI buffer area in DPRAM. The
|
Defines offset to the initial SPI buffer area in DPRAM. The
|
||||||
|
|
|
@ -42,7 +42,7 @@ COBJS = main.o ACEX1K.o altera.o bedbug.o \
|
||||||
cmd_reginfo.o cmd_scsi.o cmd_spi.o cmd_usb.o cmd_vfd.o \
|
cmd_reginfo.o cmd_scsi.o cmd_spi.o cmd_usb.o cmd_vfd.o \
|
||||||
command.o console.o devices.o dlmalloc.o docecc.o \
|
command.o console.o devices.o dlmalloc.o docecc.o \
|
||||||
environment.o env_common.o \
|
environment.o env_common.o \
|
||||||
env_flash.o env_eeprom.o env_nvram.o env_nowhere.o exports.o \
|
env_dataflash.o env_flash.o env_eeprom.o env_nvram.o env_nowhere.o exports.o \
|
||||||
flash.o fpga.o \
|
flash.o fpga.o \
|
||||||
hush.o kgdb.o lists.o lynxkdi.o miiphybb.o miiphyutil.o \
|
hush.o kgdb.o lists.o lynxkdi.o miiphybb.o miiphyutil.o \
|
||||||
s_record.o soft_i2c.o soft_spi.o spartan2.o \
|
s_record.o soft_i2c.o soft_spi.o spartan2.o \
|
||||||
|
|
|
@ -307,7 +307,9 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||||
ulong bank, addr_first, addr_last;
|
ulong bank, addr_first, addr_last;
|
||||||
int i, p, n, sect_first, sect_last;
|
int i, p, n, sect_first, sect_last;
|
||||||
int rcode = 0;
|
int rcode = 0;
|
||||||
|
#ifdef CONFIG_HAS_DATAFLASH
|
||||||
|
int status;
|
||||||
|
#endif
|
||||||
if (argc < 3) {
|
if (argc < 3) {
|
||||||
printf ("Usage:\n%s\n", cmdtp->usage);
|
printf ("Usage:\n%s\n", cmdtp->usage);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -322,6 +324,24 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_HAS_DATAFLASH
|
||||||
|
if ((strcmp(argv[2], "all") != 0) && (strcmp(argv[2], "bank") != 0)) {
|
||||||
|
addr_first = simple_strtoul(argv[2], NULL, 16);
|
||||||
|
addr_last = simple_strtoul(argv[3], NULL, 16);
|
||||||
|
|
||||||
|
if (addr_dataflash(addr_first) && addr_dataflash(addr_last)) {
|
||||||
|
status = dataflash_real_protect(p,addr_first,addr_last);
|
||||||
|
if (status < 0){
|
||||||
|
printf("Bad DataFlash sector specification\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
printf("%sProtect %d DataFlash Sectors\n",
|
||||||
|
p ? "" : "Un-", status);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (strcmp(argv[2], "all") == 0) {
|
if (strcmp(argv[2], "all") == 0) {
|
||||||
for (bank=1; bank<=CFG_MAX_FLASH_BANKS; ++bank) {
|
for (bank=1; bank<=CFG_MAX_FLASH_BANKS; ++bank) {
|
||||||
info = &flash_info[bank-1];
|
info = &flash_info[bank-1];
|
||||||
|
|
|
@ -136,13 +136,19 @@ int do_mem_md ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||||
uint *uip = (uint *)linebuf;
|
uint *uip = (uint *)linebuf;
|
||||||
ushort *usp = (ushort *)linebuf;
|
ushort *usp = (ushort *)linebuf;
|
||||||
u_char *ucp = (u_char *)linebuf;
|
u_char *ucp = (u_char *)linebuf;
|
||||||
|
#ifdef CONFIG_HAS_DATAFLASH
|
||||||
|
int rc;
|
||||||
|
#endif
|
||||||
printf("%08lx:", addr);
|
printf("%08lx:", addr);
|
||||||
linebytes = (nbytes>DISP_LINE_LEN)?DISP_LINE_LEN:nbytes;
|
linebytes = (nbytes>DISP_LINE_LEN)?DISP_LINE_LEN:nbytes;
|
||||||
|
|
||||||
#ifdef CONFIG_HAS_DATAFLASH
|
#ifdef CONFIG_HAS_DATAFLASH
|
||||||
if (read_dataflash(addr, (linebytes/size)*size, linebuf) != -1){
|
if ((rc = read_dataflash(addr, (linebytes/size)*size, linebuf)) == DATAFLASH_OK){
|
||||||
|
/* if outside dataflash */
|
||||||
|
/*if (rc != 1) {
|
||||||
|
dataflash_perror (rc);
|
||||||
|
return (1);
|
||||||
|
}*/
|
||||||
for (i=0; i<linebytes; i+= size) {
|
for (i=0; i<linebytes; i+= size) {
|
||||||
if (size == 4) {
|
if (size == 4) {
|
||||||
printf(" %08x", *uip++);
|
printf(" %08x", *uip++);
|
||||||
|
@ -430,7 +436,12 @@ int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||||
|
|
||||||
/* Check if we are copying from DataFlash to RAM */
|
/* Check if we are copying from DataFlash to RAM */
|
||||||
if (addr_dataflash(addr) && !addr_dataflash(dest) && (addr2info(dest)==NULL) ){
|
if (addr_dataflash(addr) && !addr_dataflash(dest) && (addr2info(dest)==NULL) ){
|
||||||
read_dataflash(addr, count * size, (char *) dest);
|
int rc;
|
||||||
|
rc = read_dataflash(addr, count * size, (char *) dest);
|
||||||
|
if (rc != 1) {
|
||||||
|
dataflash_perror (rc);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,8 +49,12 @@
|
||||||
#include <net.h>
|
#include <net.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(CFG_ENV_IS_IN_NVRAM) && !defined(CFG_ENV_IS_IN_EEPROM) && !defined(CFG_ENV_IS_IN_FLASH) && !defined(CFG_ENV_IS_NOWHERE)
|
#if !defined(CFG_ENV_IS_IN_NVRAM) && \
|
||||||
# error Define one of CFG_ENV_IS_IN_NVRAM, CFG_ENV_IS_IN_EEPROM, CFG_ENV_IS_IN_FLASH, CFG_ENV_IS_NOWHERE
|
!defined(CFG_ENV_IS_IN_EEPROM) && \
|
||||||
|
!defined(CFG_ENV_IS_IN_FLASH) && \
|
||||||
|
!defined(CFG_ENV_IS_IN_DATAFLASH) && \
|
||||||
|
!defined(CFG_ENV_IS_NOWHERE)
|
||||||
|
# error Define one of CFG_ENV_IS_IN_{NVRAM|EEPROM|FLASH|DATAFLASH|NOWHERE}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define XMK_STR(x) #x
|
#define XMK_STR(x) #x
|
||||||
|
|
104
common/env_dataflash.c
Normal file
104
common/env_dataflash.c
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
/* LowLevel function for DataFlash environment support
|
||||||
|
* Author : Gilles Gastaldi (Atmel)
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include <common.h>
|
||||||
|
|
||||||
|
#if defined(CFG_ENV_IS_IN_DATAFLASH) /* Environment is in DataFlash */
|
||||||
|
|
||||||
|
#include <command.h>
|
||||||
|
#include <environment.h>
|
||||||
|
#include <linux/stddef.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <dataflash.h>
|
||||||
|
|
||||||
|
env_t *env_ptr = NULL;
|
||||||
|
|
||||||
|
char * env_name_spec = "dataflash";
|
||||||
|
|
||||||
|
extern int read_dataflash (unsigned long addr, unsigned long size, char
|
||||||
|
*result);
|
||||||
|
extern int write_dataflash (unsigned long addr_dest, unsigned long addr_src,
|
||||||
|
unsigned long size);
|
||||||
|
extern int AT91F_DataflashInit (void);
|
||||||
|
extern uchar default_environment[];
|
||||||
|
/* extern int default_environment_size; */
|
||||||
|
|
||||||
|
|
||||||
|
uchar env_get_char_spec (int index)
|
||||||
|
{
|
||||||
|
uchar c;
|
||||||
|
read_dataflash (CFG_ENV_ADDR+index+offsetof(env_t,data),1,&c);
|
||||||
|
return (c);
|
||||||
|
}
|
||||||
|
|
||||||
|
void env_relocate_spec (void)
|
||||||
|
{
|
||||||
|
read_dataflash (CFG_ENV_ADDR,CFG_ENV_SIZE,(uchar *)env_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int saveenv(void)
|
||||||
|
{
|
||||||
|
/* env must be copied to do not alter env structure in memory*/
|
||||||
|
unsigned char temp[CFG_ENV_SIZE];
|
||||||
|
int i;
|
||||||
|
memcpy(temp, env_ptr, CFG_ENV_SIZE);
|
||||||
|
return write_dataflash (CFG_ENV_ADDR, (unsigned long)temp, CFG_ENV_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* Initialize Environment use
|
||||||
|
*
|
||||||
|
* We are still running from ROM, so data use is limited
|
||||||
|
* Use a (moderately small) buffer on the stack
|
||||||
|
*/
|
||||||
|
int env_init(void)
|
||||||
|
{
|
||||||
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
|
ulong crc, len, new;
|
||||||
|
unsigned off;
|
||||||
|
uchar buf[64];
|
||||||
|
if (gd->env_valid == 0){
|
||||||
|
AT91F_DataflashInit(); /* prepare for DATAFLASH read/write */
|
||||||
|
|
||||||
|
/* read old CRC */
|
||||||
|
read_dataflash (CFG_ENV_ADDR+offsetof(env_t,crc),sizeof(ulong),&crc);
|
||||||
|
new = 0;
|
||||||
|
len = ENV_SIZE;
|
||||||
|
off = offsetof(env_t,data);
|
||||||
|
while (len > 0) {
|
||||||
|
int n = (len > sizeof(buf)) ? sizeof(buf) : len;
|
||||||
|
read_dataflash (CFG_ENV_ADDR+off,n , buf);
|
||||||
|
new = crc32 (new, buf, n);
|
||||||
|
len -= n;
|
||||||
|
off += n;
|
||||||
|
}
|
||||||
|
if (crc == new) {
|
||||||
|
gd->env_addr = offsetof(env_t,data);
|
||||||
|
gd->env_valid = 1;
|
||||||
|
} else {
|
||||||
|
gd->env_addr = (ulong)&default_environment[0];
|
||||||
|
gd->env_valid = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CFG_ENV_IS_IN_DATAFLASH */
|
|
@ -26,6 +26,7 @@
|
||||||
#include <dataflash.h>
|
#include <dataflash.h>
|
||||||
|
|
||||||
#define SPI_CLK 5000000
|
#define SPI_CLK 5000000
|
||||||
|
#define AT91C_TIMEOUT_WRDY 200000
|
||||||
#define AT91C_SPI_PCS0_SERIAL_DATAFLASH 0xE /* Chip Select 0 : NPCS0 %1110 */
|
#define AT91C_SPI_PCS0_SERIAL_DATAFLASH 0xE /* Chip Select 0 : NPCS0 %1110 */
|
||||||
#define AT91C_SPI_PCS3_DATAFLASH_CARD 0x7 /* Chip Select 3 : NPCS3 %0111 */
|
#define AT91C_SPI_PCS3_DATAFLASH_CARD 0x7 /* Chip Select 3 : NPCS3 %0111 */
|
||||||
|
|
||||||
|
@ -145,10 +146,17 @@ AT91S_DataFlashStatus AT91F_DataFlashSendCommand(
|
||||||
|
|
||||||
/* fill the command buffer */
|
/* fill the command buffer */
|
||||||
pDataFlash->pDataFlashDesc->command[0] = OpCode;
|
pDataFlash->pDataFlashDesc->command[0] = OpCode;
|
||||||
pDataFlash->pDataFlashDesc->command[1] = (unsigned char)((adr & 0x00FF0000) >> 16);
|
if (pDataFlash->pDevice->pages_number >= 16384) {
|
||||||
pDataFlash->pDataFlashDesc->command[2] = (unsigned char)((adr & 0x0000FF00) >> 8);
|
pDataFlash->pDataFlashDesc->command[1] = (unsigned char)((adr & 0x0F000000) >> 24);
|
||||||
pDataFlash->pDataFlashDesc->command[3] = (unsigned char)(adr & 0x000000FF) ;
|
pDataFlash->pDataFlashDesc->command[2] = (unsigned char)((adr & 0x00FF0000) >> 16);
|
||||||
pDataFlash->pDataFlashDesc->command[4] = 0;
|
pDataFlash->pDataFlashDesc->command[3] = (unsigned char)((adr & 0x0000FF00) >> 8);
|
||||||
|
pDataFlash->pDataFlashDesc->command[4] = (unsigned char)(adr & 0x000000FF);
|
||||||
|
} else {
|
||||||
|
pDataFlash->pDataFlashDesc->command[1] = (unsigned char)((adr & 0x00FF0000) >> 16);
|
||||||
|
pDataFlash->pDataFlashDesc->command[2] = (unsigned char)((adr & 0x0000FF00) >> 8);
|
||||||
|
pDataFlash->pDataFlashDesc->command[3] = (unsigned char)(adr & 0x000000FF) ;
|
||||||
|
pDataFlash->pDataFlashDesc->command[4] = 0;
|
||||||
|
}
|
||||||
pDataFlash->pDataFlashDesc->command[5] = 0;
|
pDataFlash->pDataFlashDesc->command[5] = 0;
|
||||||
pDataFlash->pDataFlashDesc->command[6] = 0;
|
pDataFlash->pDataFlashDesc->command[6] = 0;
|
||||||
pDataFlash->pDataFlashDesc->command[7] = 0;
|
pDataFlash->pDataFlashDesc->command[7] = 0;
|
||||||
|
@ -205,8 +213,7 @@ AT91S_DataFlashStatus AT91F_DataFlashWaitReady(AT91PS_DataflashDesc pDataFlashDe
|
||||||
do {
|
do {
|
||||||
AT91F_DataFlashGetStatus(pDataFlashDesc);
|
AT91F_DataFlashGetStatus(pDataFlashDesc);
|
||||||
timeout--;
|
timeout--;
|
||||||
}
|
} while( ((pDataFlashDesc->DataFlash_state & 0x80) != 0x80) && (timeout > 0) );
|
||||||
while( ((pDataFlashDesc->DataFlash_state & 0x80) != 0x80) && (timeout > 0) );
|
|
||||||
|
|
||||||
if((pDataFlashDesc->DataFlash_state & 0x80) != 0x80)
|
if((pDataFlashDesc->DataFlash_state & 0x80) != 0x80)
|
||||||
return DATAFLASH_ERROR;
|
return DATAFLASH_ERROR;
|
||||||
|
@ -230,6 +237,7 @@ AT91S_DataFlashStatus AT91F_DataFlashContinuousRead (
|
||||||
unsigned char *dataBuffer,
|
unsigned char *dataBuffer,
|
||||||
int sizeToRead )
|
int sizeToRead )
|
||||||
{
|
{
|
||||||
|
AT91S_DataFlashStatus status;
|
||||||
/* Test the size to read in the device */
|
/* Test the size to read in the device */
|
||||||
if ( (src + sizeToRead) > (pDataFlash->pDevice->pages_size * (pDataFlash->pDevice->pages_number)))
|
if ( (src + sizeToRead) > (pDataFlash->pDevice->pages_size * (pDataFlash->pDevice->pages_number)))
|
||||||
return DATAFLASH_MEMORY_OVERFLOW;
|
return DATAFLASH_MEMORY_OVERFLOW;
|
||||||
|
@ -239,8 +247,9 @@ AT91S_DataFlashStatus AT91F_DataFlashContinuousRead (
|
||||||
pDataFlash->pDataFlashDesc->tx_data_pt = dataBuffer;
|
pDataFlash->pDataFlashDesc->tx_data_pt = dataBuffer;
|
||||||
pDataFlash->pDataFlashDesc->tx_data_size = sizeToRead;
|
pDataFlash->pDataFlashDesc->tx_data_size = sizeToRead;
|
||||||
|
|
||||||
|
status = AT91F_DataFlashSendCommand (pDataFlash, DB_CONTINUOUS_ARRAY_READ, 8, src);
|
||||||
/* Send the command to the dataflash */
|
/* Send the command to the dataflash */
|
||||||
return(AT91F_DataFlashSendCommand (pDataFlash, DB_CONTINUOUS_ARRAY_READ, 8, src));
|
return(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -259,13 +268,17 @@ AT91S_DataFlashStatus AT91F_DataFlashPagePgmBuf(
|
||||||
unsigned int dest,
|
unsigned int dest,
|
||||||
unsigned int SizeToWrite)
|
unsigned int SizeToWrite)
|
||||||
{
|
{
|
||||||
|
int cmdsize;
|
||||||
pDataFlash->pDataFlashDesc->tx_data_pt = src ;
|
pDataFlash->pDataFlashDesc->tx_data_pt = src ;
|
||||||
pDataFlash->pDataFlashDesc->tx_data_size = SizeToWrite ;
|
pDataFlash->pDataFlashDesc->tx_data_size = SizeToWrite ;
|
||||||
pDataFlash->pDataFlashDesc->rx_data_pt = src;
|
pDataFlash->pDataFlashDesc->rx_data_pt = src;
|
||||||
pDataFlash->pDataFlashDesc->rx_data_size = SizeToWrite;
|
pDataFlash->pDataFlashDesc->rx_data_size = SizeToWrite;
|
||||||
|
|
||||||
|
cmdsize = 4;
|
||||||
/* Send the command to the dataflash */
|
/* Send the command to the dataflash */
|
||||||
return(AT91F_DataFlashSendCommand (pDataFlash, DB_PAGE_PGM_BUF1, 4, dest));
|
if (pDataFlash->pDevice->pages_number >= 16384)
|
||||||
|
cmdsize = 5;
|
||||||
|
return(AT91F_DataFlashSendCommand (pDataFlash, DB_PAGE_PGM_BUF1, cmdsize, dest));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -282,14 +295,17 @@ AT91S_DataFlashStatus AT91F_MainMemoryToBufferTransfert(
|
||||||
unsigned char BufferCommand,
|
unsigned char BufferCommand,
|
||||||
unsigned int page)
|
unsigned int page)
|
||||||
{
|
{
|
||||||
|
int cmdsize;
|
||||||
/* Test if the buffer command is legal */
|
/* Test if the buffer command is legal */
|
||||||
if ((BufferCommand != DB_PAGE_2_BUF1_TRF) && (BufferCommand != DB_PAGE_2_BUF2_TRF))
|
if ((BufferCommand != DB_PAGE_2_BUF1_TRF) && (BufferCommand != DB_PAGE_2_BUF2_TRF))
|
||||||
return DATAFLASH_BAD_COMMAND;
|
return DATAFLASH_BAD_COMMAND;
|
||||||
|
|
||||||
/* no data to transmit or receive */
|
/* no data to transmit or receive */
|
||||||
pDataFlash->pDataFlashDesc->tx_data_size = 0;
|
pDataFlash->pDataFlashDesc->tx_data_size = 0;
|
||||||
|
cmdsize = 4;
|
||||||
return(AT91F_DataFlashSendCommand (pDataFlash, BufferCommand, 4, page*pDataFlash->pDevice->pages_size));
|
if (pDataFlash->pDevice->pages_number >= 16384)
|
||||||
|
cmdsize = 5;
|
||||||
|
return(AT91F_DataFlashSendCommand (pDataFlash, BufferCommand, cmdsize, page*pDataFlash->pDevice->pages_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -310,6 +326,7 @@ AT91S_DataFlashStatus AT91F_DataFlashWriteBuffer (
|
||||||
unsigned int bufferAddress,
|
unsigned int bufferAddress,
|
||||||
int SizeToWrite )
|
int SizeToWrite )
|
||||||
{
|
{
|
||||||
|
int cmdsize;
|
||||||
/* Test if the buffer command is legal */
|
/* Test if the buffer command is legal */
|
||||||
if ((BufferCommand != DB_BUF1_WRITE) && (BufferCommand != DB_BUF2_WRITE))
|
if ((BufferCommand != DB_BUF1_WRITE) && (BufferCommand != DB_BUF2_WRITE))
|
||||||
return DATAFLASH_BAD_COMMAND;
|
return DATAFLASH_BAD_COMMAND;
|
||||||
|
@ -324,14 +341,22 @@ AT91S_DataFlashStatus AT91F_DataFlashWriteBuffer (
|
||||||
/* Send first Write Command */
|
/* Send first Write Command */
|
||||||
pDataFlash->pDataFlashDesc->command[0] = BufferCommand;
|
pDataFlash->pDataFlashDesc->command[0] = BufferCommand;
|
||||||
pDataFlash->pDataFlashDesc->command[1] = 0;
|
pDataFlash->pDataFlashDesc->command[1] = 0;
|
||||||
pDataFlash->pDataFlashDesc->command[2] = (unsigned char)(((unsigned int)(bufferAddress & pDataFlash->pDevice->byte_mask)) >> 8) ;
|
if (pDataFlash->pDevice->pages_number >= 16384) {
|
||||||
pDataFlash->pDataFlashDesc->command[3] = (unsigned char)((unsigned int)bufferAddress & 0x00FF) ;
|
pDataFlash->pDataFlashDesc->command[2] = 0;
|
||||||
|
pDataFlash->pDataFlashDesc->command[3] = (unsigned char)(((unsigned int)(bufferAddress & pDataFlash->pDevice->byte_mask)) >> 8) ;
|
||||||
|
pDataFlash->pDataFlashDesc->command[4] = (unsigned char)((unsigned int)bufferAddress & 0x00FF) ;
|
||||||
|
cmdsize = 5;
|
||||||
|
} else {
|
||||||
|
pDataFlash->pDataFlashDesc->command[2] = (unsigned char)(((unsigned int)(bufferAddress & pDataFlash->pDevice->byte_mask)) >> 8) ;
|
||||||
|
pDataFlash->pDataFlashDesc->command[3] = (unsigned char)((unsigned int)bufferAddress & 0x00FF) ;
|
||||||
|
pDataFlash->pDataFlashDesc->command[4] = 0;
|
||||||
|
cmdsize = 4;
|
||||||
|
}
|
||||||
|
|
||||||
pDataFlash->pDataFlashDesc->tx_cmd_pt = pDataFlash->pDataFlashDesc->command ;
|
pDataFlash->pDataFlashDesc->tx_cmd_pt = pDataFlash->pDataFlashDesc->command ;
|
||||||
pDataFlash->pDataFlashDesc->tx_cmd_size = 4 ;
|
pDataFlash->pDataFlashDesc->tx_cmd_size = cmdsize ;
|
||||||
pDataFlash->pDataFlashDesc->rx_cmd_pt = pDataFlash->pDataFlashDesc->command ;
|
pDataFlash->pDataFlashDesc->rx_cmd_pt = pDataFlash->pDataFlashDesc->command ;
|
||||||
pDataFlash->pDataFlashDesc->rx_cmd_size = 4 ;
|
pDataFlash->pDataFlashDesc->rx_cmd_size = cmdsize ;
|
||||||
|
|
||||||
pDataFlash->pDataFlashDesc->rx_data_pt = dataBuffer ;
|
pDataFlash->pDataFlashDesc->rx_data_pt = dataBuffer ;
|
||||||
pDataFlash->pDataFlashDesc->tx_data_pt = dataBuffer ;
|
pDataFlash->pDataFlashDesc->tx_data_pt = dataBuffer ;
|
||||||
|
@ -341,6 +366,51 @@ AT91S_DataFlashStatus AT91F_DataFlashWriteBuffer (
|
||||||
return AT91F_SpiWrite(pDataFlash->pDataFlashDesc);
|
return AT91F_SpiWrite(pDataFlash->pDataFlashDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------*/
|
||||||
|
/* Function Name : AT91F_PageErase */
|
||||||
|
/* Object : Erase a page */
|
||||||
|
/* Input Parameters : DataFlash Service */
|
||||||
|
/* : Page concerned */
|
||||||
|
/* : */
|
||||||
|
/* Return value : State of the dataflash */
|
||||||
|
/*------------------------------------------------------------------------------*/
|
||||||
|
AT91S_DataFlashStatus AT91F_PageErase(
|
||||||
|
AT91PS_DataFlash pDataFlash,
|
||||||
|
unsigned int page)
|
||||||
|
{
|
||||||
|
int cmdsize;
|
||||||
|
/* Test if the buffer command is legal */
|
||||||
|
/* no data to transmit or receive */
|
||||||
|
pDataFlash->pDataFlashDesc->tx_data_size = 0;
|
||||||
|
|
||||||
|
cmdsize = 4;
|
||||||
|
if (pDataFlash->pDevice->pages_number >= 16384)
|
||||||
|
cmdsize = 5;
|
||||||
|
return(AT91F_DataFlashSendCommand (pDataFlash, DB_PAGE_ERASE, cmdsize, page*pDataFlash->pDevice->pages_size));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------*/
|
||||||
|
/* Function Name : AT91F_BlockErase */
|
||||||
|
/* Object : Erase a Block */
|
||||||
|
/* Input Parameters : DataFlash Service */
|
||||||
|
/* : Page concerned */
|
||||||
|
/* : */
|
||||||
|
/* Return value : State of the dataflash */
|
||||||
|
/*------------------------------------------------------------------------------*/
|
||||||
|
AT91S_DataFlashStatus AT91F_BlockErase(
|
||||||
|
AT91PS_DataFlash pDataFlash,
|
||||||
|
unsigned int block)
|
||||||
|
{
|
||||||
|
int cmdsize;
|
||||||
|
/* Test if the buffer command is legal */
|
||||||
|
/* no data to transmit or receive */
|
||||||
|
pDataFlash->pDataFlashDesc->tx_data_size = 0;
|
||||||
|
cmdsize = 4;
|
||||||
|
if (pDataFlash->pDevice->pages_number >= 16384)
|
||||||
|
cmdsize = 5;
|
||||||
|
return(AT91F_DataFlashSendCommand (pDataFlash, DB_BLOCK_ERASE,cmdsize, block*8*pDataFlash->pDevice->pages_size));
|
||||||
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------------*/
|
||||||
/* Function Name : AT91F_WriteBufferToMain */
|
/* Function Name : AT91F_WriteBufferToMain */
|
||||||
|
@ -355,6 +425,7 @@ AT91S_DataFlashStatus AT91F_WriteBufferToMain (
|
||||||
unsigned char BufferCommand,
|
unsigned char BufferCommand,
|
||||||
unsigned int dest )
|
unsigned int dest )
|
||||||
{
|
{
|
||||||
|
int cmdsize;
|
||||||
/* Test if the buffer command is correct */
|
/* Test if the buffer command is correct */
|
||||||
if ((BufferCommand != DB_BUF1_PAGE_PGM) &&
|
if ((BufferCommand != DB_BUF1_PAGE_PGM) &&
|
||||||
(BufferCommand != DB_BUF1_PAGE_ERASE_PGM) &&
|
(BufferCommand != DB_BUF1_PAGE_ERASE_PGM) &&
|
||||||
|
@ -365,8 +436,11 @@ AT91S_DataFlashStatus AT91F_WriteBufferToMain (
|
||||||
/* no data to transmit or receive */
|
/* no data to transmit or receive */
|
||||||
pDataFlash->pDataFlashDesc->tx_data_size = 0;
|
pDataFlash->pDataFlashDesc->tx_data_size = 0;
|
||||||
|
|
||||||
|
cmdsize = 4;
|
||||||
|
if (pDataFlash->pDevice->pages_number >= 16384)
|
||||||
|
cmdsize = 5;
|
||||||
/* Send the command to the dataflash */
|
/* Send the command to the dataflash */
|
||||||
return(AT91F_DataFlashSendCommand (pDataFlash, BufferCommand, 4, dest));
|
return(AT91F_DataFlashSendCommand (pDataFlash, BufferCommand, cmdsize, dest));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -391,10 +465,18 @@ AT91S_DataFlashStatus AT91F_PartialPageWrite (
|
||||||
|
|
||||||
/* Read the contents of the page in the Sram Buffer */
|
/* Read the contents of the page in the Sram Buffer */
|
||||||
AT91F_MainMemoryToBufferTransfert(pDataFlash, DB_PAGE_2_BUF1_TRF, page);
|
AT91F_MainMemoryToBufferTransfert(pDataFlash, DB_PAGE_2_BUF1_TRF, page);
|
||||||
AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, 1000);
|
AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, AT91C_TIMEOUT_WRDY);
|
||||||
/*Update the SRAM buffer */
|
/*Update the SRAM buffer */
|
||||||
AT91F_DataFlashWriteBuffer(pDataFlash, DB_BUF1_WRITE, src, AdrInPage, size);
|
AT91F_DataFlashWriteBuffer(pDataFlash, DB_BUF1_WRITE, src, AdrInPage, size);
|
||||||
AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, 1000);
|
|
||||||
|
AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, AT91C_TIMEOUT_WRDY);
|
||||||
|
|
||||||
|
/* Erase page if a 128 Mbits device */
|
||||||
|
if (pDataFlash->pDevice->pages_number >= 16384) {
|
||||||
|
AT91F_PageErase(pDataFlash, page);
|
||||||
|
/* Rewrite the modified Sram Buffer in the main memory */
|
||||||
|
AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, AT91C_TIMEOUT_WRDY);
|
||||||
|
}
|
||||||
|
|
||||||
/* Rewrite the modified Sram Buffer in the main memory */
|
/* Rewrite the modified Sram Buffer in the main memory */
|
||||||
return(AT91F_WriteBufferToMain(pDataFlash, DB_BUF1_PAGE_ERASE_PGM, (page*pDataFlash->pDevice->pages_size)));
|
return(AT91F_WriteBufferToMain(pDataFlash, DB_BUF1_PAGE_ERASE_PGM, (page*pDataFlash->pDevice->pages_size)));
|
||||||
|
@ -402,7 +484,7 @@ AT91S_DataFlashStatus AT91F_PartialPageWrite (
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------------*/
|
||||||
/* Function Name : AT91F_DataFlashWrite_Overloaded */
|
/* Function Name : AT91F_DataFlashWrite */
|
||||||
/* Object : */
|
/* Object : */
|
||||||
/* Input Parameters : <*src> = Source buffer */
|
/* Input Parameters : <*src> = Source buffer */
|
||||||
/* : <dest> = dataflash adress */
|
/* : <dest> = dataflash adress */
|
||||||
|
@ -415,6 +497,8 @@ AT91S_DataFlashStatus AT91F_DataFlashWrite(
|
||||||
int size )
|
int size )
|
||||||
{
|
{
|
||||||
unsigned int length;
|
unsigned int length;
|
||||||
|
unsigned int page;
|
||||||
|
unsigned int status;
|
||||||
|
|
||||||
AT91F_SpiEnable(pDataFlash->pDevice->cs);
|
AT91F_SpiEnable(pDataFlash->pDevice->cs);
|
||||||
|
|
||||||
|
@ -431,7 +515,7 @@ AT91S_DataFlashStatus AT91F_DataFlashWrite(
|
||||||
if(!AT91F_PartialPageWrite(pDataFlash,src, dest, length))
|
if(!AT91F_PartialPageWrite(pDataFlash,src, dest, length))
|
||||||
return DATAFLASH_ERROR;
|
return DATAFLASH_ERROR;
|
||||||
|
|
||||||
AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, 1000);
|
AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, AT91C_TIMEOUT_WRDY);
|
||||||
|
|
||||||
/* Update size, source and destination pointers */
|
/* Update size, source and destination pointers */
|
||||||
size -= length;
|
size -= length;
|
||||||
|
@ -441,10 +525,21 @@ AT91S_DataFlashStatus AT91F_DataFlashWrite(
|
||||||
|
|
||||||
while (( size - pDataFlash->pDevice->pages_size ) >= 0 ) {
|
while (( size - pDataFlash->pDevice->pages_size ) >= 0 ) {
|
||||||
/* program dataflash page */
|
/* program dataflash page */
|
||||||
if(!AT91F_DataFlashPagePgmBuf(pDataFlash, src, dest, pDataFlash->pDevice->pages_size ))
|
page = (unsigned int)dest / (pDataFlash->pDevice->pages_size);
|
||||||
|
|
||||||
|
status = AT91F_DataFlashWriteBuffer(pDataFlash, DB_BUF1_WRITE, src, 0, pDataFlash->pDevice->pages_size);
|
||||||
|
AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, AT91C_TIMEOUT_WRDY);
|
||||||
|
|
||||||
|
status = AT91F_PageErase(pDataFlash, page);
|
||||||
|
AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, AT91C_TIMEOUT_WRDY);
|
||||||
|
if (!status)
|
||||||
return DATAFLASH_ERROR;
|
return DATAFLASH_ERROR;
|
||||||
|
|
||||||
AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, 1000);
|
status = AT91F_WriteBufferToMain (pDataFlash, DB_BUF1_PAGE_PGM, dest);
|
||||||
|
if(!status)
|
||||||
|
return DATAFLASH_ERROR;
|
||||||
|
|
||||||
|
AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, AT91C_TIMEOUT_WRDY);
|
||||||
|
|
||||||
/* Update size, source and destination pointers */
|
/* Update size, source and destination pointers */
|
||||||
size -= pDataFlash->pDevice->pages_size ;
|
size -= pDataFlash->pDevice->pages_size ;
|
||||||
|
@ -458,7 +553,7 @@ AT91S_DataFlashStatus AT91F_DataFlashWrite(
|
||||||
if(!AT91F_PartialPageWrite(pDataFlash, src, dest, size) )
|
if(!AT91F_PartialPageWrite(pDataFlash, src, dest, size) )
|
||||||
return DATAFLASH_ERROR;
|
return DATAFLASH_ERROR;
|
||||||
|
|
||||||
AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, 1000);
|
AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, AT91C_TIMEOUT_WRDY);
|
||||||
}
|
}
|
||||||
return DATAFLASH_OK;
|
return DATAFLASH_OK;
|
||||||
}
|
}
|
||||||
|
@ -480,13 +575,13 @@ int AT91F_DataFlashRead(
|
||||||
|
|
||||||
AT91F_SpiEnable(pDataFlash->pDevice->cs);
|
AT91F_SpiEnable(pDataFlash->pDevice->cs);
|
||||||
|
|
||||||
if(AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, 1000) != DATAFLASH_OK)
|
if(AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, AT91C_TIMEOUT_WRDY) != DATAFLASH_OK)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
while (size) {
|
while (size) {
|
||||||
SizeToRead = (size < 0x8000)? size:0x8000;
|
SizeToRead = (size < 0x8000)? size:0x8000;
|
||||||
|
|
||||||
if (AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, 1000) != DATAFLASH_OK)
|
if (AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, AT91C_TIMEOUT_WRDY) != DATAFLASH_OK)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (AT91F_DataFlashContinuousRead (pDataFlash, addr, buffer, SizeToRead) != DATAFLASH_OK)
|
if (AT91F_DataFlashContinuousRead (pDataFlash, addr, buffer, SizeToRead) != DATAFLASH_OK)
|
||||||
|
|
|
@ -67,6 +67,7 @@ int checkcpu (void)
|
||||||
case PVR_8260_HIP4:
|
case PVR_8260_HIP4:
|
||||||
k = 4;
|
k = 4;
|
||||||
break;
|
break;
|
||||||
|
case PVR_8260_HIP7R1:
|
||||||
case PVR_8260_HIP7:
|
case PVR_8260_HIP7:
|
||||||
k = 7;
|
k = 7;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -125,7 +125,7 @@ int get_clocks (void)
|
||||||
busdf = (scmr & SCMR_BUSDF_MSK) >> SCMR_BUSDF_SHIFT;
|
busdf = (scmr & SCMR_BUSDF_MSK) >> SCMR_BUSDF_SHIFT;
|
||||||
cpmdf = (scmr & SCMR_CPMDF_MSK) >> SCMR_CPMDF_SHIFT;
|
cpmdf = (scmr & SCMR_CPMDF_MSK) >> SCMR_CPMDF_SHIFT;
|
||||||
|
|
||||||
if (get_pvr () == PVR_8260_HIP7) { /* HiP7 */
|
if ((get_pvr () == PVR_8260_HIP7) || (get_pvr () == PVR_8260_HIP7R1)) { /* HiP7 */
|
||||||
pllmf = (scmr & SCMR_PLLMF_MSKH7) >> SCMR_PLLMF_SHIFT;
|
pllmf = (scmr & SCMR_PLLMF_MSKH7) >> SCMR_PLLMF_SHIFT;
|
||||||
gd->vco_out = clkin * (pllmf + 1);
|
gd->vco_out = clkin * (pllmf + 1);
|
||||||
} else { /* HiP3, HiP4 */
|
} else { /* HiP3, HiP4 */
|
||||||
|
|
|
@ -31,12 +31,23 @@ int cs[][CFG_MAX_DATAFLASH_BANKS] = {
|
||||||
{CFG_DATAFLASH_LOGIC_ADDR_CS3, 3}
|
{CFG_DATAFLASH_LOGIC_ADDR_CS3, 3}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*define the area offsets*/
|
||||||
|
dataflash_protect_t area_list[NB_DATAFLASH_AREA] = {
|
||||||
|
{0, 0x7fff, FLAG_PROTECT_SET}, /* ROM code */
|
||||||
|
{0x8000, 0x1ffff, FLAG_PROTECT_SET}, /* u-boot code */
|
||||||
|
{0x20000, 0x27fff, FLAG_PROTECT_CLEAR}, /* u-boot environment */
|
||||||
|
{0x28000, 0x1fffff, FLAG_PROTECT_CLEAR}, /* data area size to tune */
|
||||||
|
};
|
||||||
|
|
||||||
extern void AT91F_SpiInit (void);
|
extern void AT91F_SpiInit (void);
|
||||||
extern int AT91F_DataflashProbe (int i, AT91PS_DataflashDesc pDesc);
|
extern int AT91F_DataflashProbe (int i, AT91PS_DataflashDesc pDesc);
|
||||||
extern int AT91F_DataFlashRead (AT91PS_DataFlash pDataFlash,
|
extern int AT91F_DataFlashRead (AT91PS_DataFlash pDataFlash,
|
||||||
unsigned long addr,
|
unsigned long addr,
|
||||||
unsigned long size, char *buffer);
|
unsigned long size, char *buffer);
|
||||||
|
extern int AT91F_DataFlashWrite( AT91PS_DataFlash pDataFlash,
|
||||||
|
unsigned char *src,
|
||||||
|
int dest,
|
||||||
|
int size );
|
||||||
|
|
||||||
int AT91F_DataflashInit (void)
|
int AT91F_DataflashInit (void)
|
||||||
{
|
{
|
||||||
|
@ -46,7 +57,7 @@ int AT91F_DataflashInit (void)
|
||||||
AT91F_SpiInit ();
|
AT91F_SpiInit ();
|
||||||
|
|
||||||
for (i = 0; i < CFG_MAX_DATAFLASH_BANKS; i++) {
|
for (i = 0; i < CFG_MAX_DATAFLASH_BANKS; i++) {
|
||||||
|
dataflash_info[i].Desc.state = IDLE;
|
||||||
dataflash_info[i].id = 0;
|
dataflash_info[i].id = 0;
|
||||||
dataflash_info[i].Device.pages_number = 0;
|
dataflash_info[i].Device.pages_number = 0;
|
||||||
dfcode = AT91F_DataflashProbe (cs[i][1], &dataflash_info[i].Desc);
|
dfcode = AT91F_DataflashProbe (cs[i][1], &dataflash_info[i].Desc);
|
||||||
|
@ -84,14 +95,31 @@ int AT91F_DataflashInit (void)
|
||||||
dataflash_info[i].logical_address = cs[i][0];
|
dataflash_info[i].logical_address = cs[i][0];
|
||||||
dataflash_info[i].id = dfcode;
|
dataflash_info[i].id = dfcode;
|
||||||
break;
|
break;
|
||||||
|
case AT45DB128:
|
||||||
|
dataflash_info[i].Device.pages_number = 16384;
|
||||||
|
dataflash_info[i].Device.pages_size = 1056;
|
||||||
|
dataflash_info[i].Device.page_offset = 11;
|
||||||
|
dataflash_info[i].Device.byte_mask = 0x700;
|
||||||
|
dataflash_info[i].Device.cs = cs[i][1];
|
||||||
|
dataflash_info[i].Desc.DataFlash_state = IDLE;
|
||||||
|
dataflash_info[i].logical_address = cs[i][0];
|
||||||
|
dataflash_info[i].id = dfcode;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
/* set the last area end to the dataflash size*/
|
||||||
|
area_list[NB_DATAFLASH_AREA -1].end =
|
||||||
|
(dataflash_info[i].Device.pages_number *
|
||||||
|
dataflash_info[i].Device.pages_size)-1;
|
||||||
|
|
||||||
for (j = 0; j < dataflash_info[i].Device.pages_number; j++)
|
/* set the area addresses */
|
||||||
dataflash_info[i].protect[j] = FLAG_PROTECT_SET;
|
for(j = 0; j<NB_DATAFLASH_AREA; j++) {
|
||||||
|
dataflash_info[i].Device.area_list[j].start = area_list[j].start + dataflash_info[i].logical_address;
|
||||||
|
dataflash_info[i].Device.area_list[j].end = area_list[j].end + dataflash_info[i].logical_address;
|
||||||
|
dataflash_info[i].Device.area_list[j].protected = area_list[j].protected;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
@ -99,7 +127,7 @@ int AT91F_DataflashInit (void)
|
||||||
|
|
||||||
void dataflash_print_info (void)
|
void dataflash_print_info (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i, j;
|
||||||
|
|
||||||
for (i = 0; i < CFG_MAX_DATAFLASH_BANKS; i++) {
|
for (i = 0; i < CFG_MAX_DATAFLASH_BANKS; i++) {
|
||||||
if (dataflash_info[i].id != 0) {
|
if (dataflash_info[i].id != 0) {
|
||||||
|
@ -116,6 +144,9 @@ void dataflash_print_info (void)
|
||||||
case AT45DB642:
|
case AT45DB642:
|
||||||
printf ("AT45DB642\n");
|
printf ("AT45DB642\n");
|
||||||
break;
|
break;
|
||||||
|
case AT45DB128:
|
||||||
|
printf ("AT45DB128\n");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf ("Nb pages: %6d\n"
|
printf ("Nb pages: %6d\n"
|
||||||
|
@ -127,6 +158,13 @@ void dataflash_print_info (void)
|
||||||
(unsigned int) dataflash_info[i].Device.pages_number *
|
(unsigned int) dataflash_info[i].Device.pages_number *
|
||||||
dataflash_info[i].Device.pages_size,
|
dataflash_info[i].Device.pages_size,
|
||||||
(unsigned int) dataflash_info[i].logical_address);
|
(unsigned int) dataflash_info[i].logical_address);
|
||||||
|
for (j=0; j< NB_DATAFLASH_AREA; j++) {
|
||||||
|
printf ("Area %i:\t%08X to %08X %s\n", j,
|
||||||
|
dataflash_info[i].Device.area_list[j].start,
|
||||||
|
dataflash_info[i].Device.area_list[j].end,
|
||||||
|
(dataflash_info[i].Device.area_list[j].protected ==
|
||||||
|
FLAG_PROTECT_SET) ? "(RO)" : "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,6 +214,76 @@ int addr_dataflash (unsigned long addr)
|
||||||
|
|
||||||
return addr_valid;
|
return addr_valid;
|
||||||
}
|
}
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Function Name : size_dataflash */
|
||||||
|
/* Object : Test if address is valid regarding the size */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
int size_dataflash (AT91PS_DataFlash pdataFlash, unsigned long addr, unsigned long size)
|
||||||
|
{
|
||||||
|
/* is outside the dataflash */
|
||||||
|
if (((int)addr & 0x0FFFFFFF) > (pdataFlash->pDevice->pages_size *
|
||||||
|
pdataFlash->pDevice->pages_number)) return 0;
|
||||||
|
/* is too large for the dataflash */
|
||||||
|
if (size > ((pdataFlash->pDevice->pages_size *
|
||||||
|
pdataFlash->pDevice->pages_number) - ((int)addr & 0x0FFFFFFF))) return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Function Name : prot_dataflash */
|
||||||
|
/* Object : Test if destination area is protected */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
int prot_dataflash (AT91PS_DataFlash pdataFlash, unsigned long addr)
|
||||||
|
{
|
||||||
|
int area;
|
||||||
|
/* find area */
|
||||||
|
for (area=0; area < NB_DATAFLASH_AREA; area++) {
|
||||||
|
if ((addr >= pdataFlash->pDevice->area_list[area].start) &&
|
||||||
|
(addr < pdataFlash->pDevice->area_list[area].end))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (area == NB_DATAFLASH_AREA) return -1;
|
||||||
|
/*test protection value*/
|
||||||
|
if (pdataFlash->pDevice->area_list[area].protected == FLAG_PROTECT_SET) return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Function Name : dataflash_real_protect */
|
||||||
|
/* Object : protect/unprotect area */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
int dataflash_real_protect (int flag, unsigned long start_addr, unsigned long end_addr)
|
||||||
|
{
|
||||||
|
int i,j, area1, area2, addr_valid = 0;
|
||||||
|
/* find dataflash */
|
||||||
|
for (i = 0; i < CFG_MAX_DATAFLASH_BANKS; i++) {
|
||||||
|
if ((((int) start_addr) & 0xF0000000) ==
|
||||||
|
dataflash_info[i].logical_address) {
|
||||||
|
addr_valid = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!addr_valid) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
/* find start area */
|
||||||
|
for (area1=0; area1 < NB_DATAFLASH_AREA; area1++) {
|
||||||
|
if (start_addr == dataflash_info[i].Device.area_list[area1].start) break;
|
||||||
|
}
|
||||||
|
if (area1 == NB_DATAFLASH_AREA) return -1;
|
||||||
|
/* find end area */
|
||||||
|
for (area2=0; area2 < NB_DATAFLASH_AREA; area2++) {
|
||||||
|
if (end_addr == dataflash_info[i].Device.area_list[area2].end) break;
|
||||||
|
}
|
||||||
|
if (area2 == NB_DATAFLASH_AREA) return -1;
|
||||||
|
|
||||||
|
/*set protection value*/
|
||||||
|
for(j = area1; j < area2+1 ; j++)
|
||||||
|
if (flag == 0) dataflash_info[i].Device.area_list[j].protected = FLAG_PROTECT_CLEAR;
|
||||||
|
else dataflash_info[i].Device.area_list[j].protected = FLAG_PROTECT_SET;
|
||||||
|
|
||||||
|
return (area2-area1+1);
|
||||||
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------------*/
|
||||||
/* Function Name : read_dataflash */
|
/* Function Name : read_dataflash */
|
||||||
|
@ -187,8 +295,12 @@ int read_dataflash (unsigned long addr, unsigned long size, char *result)
|
||||||
AT91PS_DataFlash pFlash = &DataFlashInst;
|
AT91PS_DataFlash pFlash = &DataFlashInst;
|
||||||
|
|
||||||
pFlash = AT91F_DataflashSelect (pFlash, &AddrToRead);
|
pFlash = AT91F_DataflashSelect (pFlash, &AddrToRead);
|
||||||
|
|
||||||
if (pFlash == 0)
|
if (pFlash == 0)
|
||||||
return -1;
|
return ERR_UNKNOWN_FLASH_TYPE;
|
||||||
|
|
||||||
|
if (size_dataflash(pFlash,addr,size) == 0)
|
||||||
|
return ERR_INVAL;
|
||||||
|
|
||||||
return (AT91F_DataFlashRead (pFlash, AddrToRead, size, result));
|
return (AT91F_DataFlashRead (pFlash, AddrToRead, size, result));
|
||||||
}
|
}
|
||||||
|
@ -201,17 +313,24 @@ int read_dataflash (unsigned long addr, unsigned long size, char *result)
|
||||||
int write_dataflash (unsigned long addr_dest, unsigned long addr_src,
|
int write_dataflash (unsigned long addr_dest, unsigned long addr_src,
|
||||||
unsigned long size)
|
unsigned long size)
|
||||||
{
|
{
|
||||||
extern AT91S_DataFlashStatus AT91F_DataFlashWrite(
|
|
||||||
AT91PS_DataFlash, uchar *, int, int);
|
|
||||||
int AddrToWrite = addr_dest;
|
int AddrToWrite = addr_dest;
|
||||||
AT91PS_DataFlash pFlash = &DataFlashInst;
|
AT91PS_DataFlash pFlash = &DataFlashInst;
|
||||||
|
|
||||||
pFlash = AT91F_DataflashSelect (pFlash, &AddrToWrite);
|
pFlash = AT91F_DataflashSelect (pFlash, &AddrToWrite);
|
||||||
|
|
||||||
|
if (pFlash == 0)
|
||||||
|
return ERR_UNKNOWN_FLASH_TYPE;
|
||||||
|
|
||||||
|
if (size_dataflash(pFlash,addr_dest,size) == 0)
|
||||||
|
return ERR_INVAL;
|
||||||
|
|
||||||
|
if (prot_dataflash(pFlash,addr_dest) == 0)
|
||||||
|
return ERR_PROTECTED;
|
||||||
|
|
||||||
if (AddrToWrite == -1)
|
if (AddrToWrite == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return AT91F_DataFlashWrite (pFlash, (char *) addr_src, AddrToWrite,
|
return AT91F_DataFlashWrite (pFlash, (char *) addr_src, AddrToWrite, size);
|
||||||
size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -732,6 +732,7 @@
|
||||||
#define PVR_8260_HIP3 0x00810101
|
#define PVR_8260_HIP3 0x00810101
|
||||||
#define PVR_8260_HIP4 0x80811014
|
#define PVR_8260_HIP4 0x80811014
|
||||||
#define PVR_8260_HIP7 0x80822011
|
#define PVR_8260_HIP7 0x80822011
|
||||||
|
#define PVR_8260_HIP7R1 0x80822013
|
||||||
|
|
||||||
/* I am just adding a single entry for 8260 boards. I think we may be
|
/* I am just adding a single entry for 8260 boards. I think we may be
|
||||||
* able to combine mbx, fads, rpxlite, bseip, and classic into a single
|
* able to combine mbx, fads, rpxlite, bseip, and classic into a single
|
||||||
|
|
|
@ -114,7 +114,7 @@
|
||||||
#define CONFIG_NET_RETRY_COUNT 20
|
#define CONFIG_NET_RETRY_COUNT 20
|
||||||
|
|
||||||
#define CONFIG_HAS_DATAFLASH 1
|
#define CONFIG_HAS_DATAFLASH 1
|
||||||
#define CFG_SPI_WRITE_TOUT CFG_HZ
|
#define CFG_SPI_WRITE_TOUT (5*CFG_HZ)
|
||||||
#define CFG_MAX_DATAFLASH_BANKS 2
|
#define CFG_MAX_DATAFLASH_BANKS 2
|
||||||
#define CFG_MAX_DATAFLASH_PAGES 16384
|
#define CFG_MAX_DATAFLASH_PAGES 16384
|
||||||
#define CFG_DATAFLASH_LOGIC_ADDR_CS0 0xC0000000 /* Logical adress for CS0 */
|
#define CFG_DATAFLASH_LOGIC_ADDR_CS0 0xC0000000 /* Logical adress for CS0 */
|
||||||
|
@ -127,9 +127,20 @@
|
||||||
#define CFG_MAX_FLASH_SECT 40
|
#define CFG_MAX_FLASH_SECT 40
|
||||||
#define CFG_FLASH_ERASE_TOUT (2*CFG_HZ) /* Timeout for Flash Erase */
|
#define CFG_FLASH_ERASE_TOUT (2*CFG_HZ) /* Timeout for Flash Erase */
|
||||||
#define CFG_FLASH_WRITE_TOUT (2*CFG_HZ) /* Timeout for Flash Write */
|
#define CFG_FLASH_WRITE_TOUT (2*CFG_HZ) /* Timeout for Flash Write */
|
||||||
|
|
||||||
|
#undef CFG_ENV_IS_IN_DATAFLASH
|
||||||
|
|
||||||
|
#ifdef CFG_ENV_IS_IN_DATAFLASH
|
||||||
|
#define CFG_ENV_OFFSET 0x20000
|
||||||
|
#define CFG_ENV_ADDR (CFG_DATAFLASH_LOGIC_ADDR_CS0 + CFG_ENV_OFFSET)
|
||||||
|
#define CFG_ENV_SIZE 0x2000 /* 0x8000 */
|
||||||
|
#else
|
||||||
#define CFG_ENV_IS_IN_FLASH 1
|
#define CFG_ENV_IS_IN_FLASH 1
|
||||||
#define CFG_ENV_ADDR (PHYS_FLASH_1 + 0xe000) /* 0x10000 */
|
#define CFG_ENV_ADDR (PHYS_FLASH_1 + 0xe000) /* 0x10000 */
|
||||||
#define CFG_ENV_SIZE 0x2000 /* 0x8000 */
|
#define CFG_ENV_SIZE 0x2000 /* 0x8000 */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define CFG_LOAD_ADDR 0x21000000 /* default load address */
|
#define CFG_LOAD_ADDR 0x21000000 /* default load address */
|
||||||
|
|
||||||
#define CFG_BOOT_SIZE 0x6000 /* 24 KBytes */
|
#define CFG_BOOT_SIZE 0x6000 /* 24 KBytes */
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
|
|
||||||
#define CONFIG_CMDLINE_TAG 1 /* enable passing of ATAGs */
|
#define CONFIG_CMDLINE_TAG 1 /* enable passing of ATAGs */
|
||||||
#define CONFIG_SETUP_MEMORY_TAGS 1
|
#define CONFIG_SETUP_MEMORY_TAGS 1
|
||||||
|
#define CONFIG_INITRD_TAG 1
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Size of malloc() pool
|
* Size of malloc() pool
|
||||||
|
@ -99,12 +100,9 @@
|
||||||
#include <configs/omap1510.h>
|
#include <configs/omap1510.h>
|
||||||
|
|
||||||
#define CONFIG_BOOTDELAY 3
|
#define CONFIG_BOOTDELAY 3
|
||||||
#define CONFIG_BOOTARGS "mem=32M console=ttyS0,115200n8 noinitrd root=/dev/nfs rw nfsroot=157.87.82.48:/home/a0875451/mwd/myfs/target ip=dhcp"
|
#define CONFIG_BOOTARGS "console=ttyS0,115200n8 noinitrd root=/dev/nfs ip=bootp"
|
||||||
/*#define CONFIG_ETHADDR 00:0B:36:00:05:25 */
|
#define CONFIG_BOOTCOMMAND "bootp;tftp;bootm"
|
||||||
#define CONFIG_NETMASK 255.255.254.0 /* talk on MY local net */
|
#define CFG_AUTOLOAD "n" /* No autoload */
|
||||||
#define CONFIG_IPADDR 156.117.97.156 /* static IP I currently own */
|
|
||||||
#define CONFIG_SERVERIP 156.117.97.139 /* current IP of my dev pc */
|
|
||||||
#define CONFIG_BOOTFILE "/tftpboot/uImage" /* file to load */
|
|
||||||
|
|
||||||
#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
|
#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
|
||||||
#define CONFIG_KGDB_BAUDRATE 115200 /* speed to run kgdb serial port */
|
#define CONFIG_KGDB_BAUDRATE 115200 /* speed to run kgdb serial port */
|
||||||
|
|
|
@ -37,16 +37,15 @@
|
||||||
#include <asm/arch/hardware.h>
|
#include <asm/arch/hardware.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
/*number of protected area*/
|
||||||
|
#define NB_DATAFLASH_AREA 4
|
||||||
|
|
||||||
|
/*define the area structure*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned long base; /* logical base address for a bank */
|
unsigned long start;
|
||||||
unsigned long size; /* total bank size */
|
unsigned long end;
|
||||||
unsigned long page_count;
|
unsigned char protected;
|
||||||
unsigned long page_size;
|
} dataflash_protect_t;
|
||||||
unsigned long id; /* device id */
|
|
||||||
unsigned char protect[CFG_MAX_DATAFLASH_PAGES]; /* page protection status */
|
|
||||||
} dataflash_info_t;
|
|
||||||
|
|
||||||
|
|
||||||
typedef unsigned int AT91S_DataFlashStatus;
|
typedef unsigned int AT91S_DataFlashStatus;
|
||||||
|
|
||||||
|
@ -80,6 +79,7 @@ typedef struct _AT91S_Dataflash {
|
||||||
int page_offset; /* page offset in command */
|
int page_offset; /* page offset in command */
|
||||||
int byte_mask; /* byte mask in command */
|
int byte_mask; /* byte mask in command */
|
||||||
int cs;
|
int cs;
|
||||||
|
dataflash_protect_t area_list[NB_DATAFLASH_AREA]; /* area protection status */
|
||||||
} AT91S_DataflashFeatures, *AT91PS_DataflashFeatures;
|
} AT91S_DataflashFeatures, *AT91PS_DataflashFeatures;
|
||||||
|
|
||||||
/*---------------------------------------------*/
|
/*---------------------------------------------*/
|
||||||
|
@ -91,13 +91,13 @@ typedef struct _AT91S_DataFlash {
|
||||||
} AT91S_DataFlash, *AT91PS_DataFlash;
|
} AT91S_DataFlash, *AT91PS_DataFlash;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _AT91S_DATAFLASH_INFO {
|
typedef struct _AT91S_DATAFLASH_INFO {
|
||||||
|
|
||||||
AT91S_DataflashDesc Desc;
|
AT91S_DataflashDesc Desc;
|
||||||
AT91S_DataflashFeatures Device; /* Pointer on a dataflash features array */
|
AT91S_DataflashFeatures Device; /* Pointer on a dataflash features array */
|
||||||
unsigned long logical_address;
|
unsigned long logical_address;
|
||||||
unsigned int id; /* device id */
|
unsigned int id; /* device id */
|
||||||
unsigned char protect[CFG_MAX_DATAFLASH_PAGES]; /* page protection status */
|
|
||||||
} AT91S_DATAFLASH_INFO, *AT91PS_DATAFLASH_INFO;
|
} AT91S_DATAFLASH_INFO, *AT91PS_DATAFLASH_INFO;
|
||||||
|
|
||||||
|
|
||||||
|
@ -106,6 +106,7 @@ typedef struct _AT91S_DATAFLASH_INFO {
|
||||||
#define AT45DB161 0x2c
|
#define AT45DB161 0x2c
|
||||||
#define AT45DB321 0x34
|
#define AT45DB321 0x34
|
||||||
#define AT45DB642 0x3c
|
#define AT45DB642 0x3c
|
||||||
|
#define AT45DB128 0x10
|
||||||
|
|
||||||
#define AT91C_DATAFLASH_TIMEOUT 10000 /* For AT91F_DataFlashWaitReady */
|
#define AT91C_DATAFLASH_TIMEOUT 10000 /* For AT91F_DataFlashWaitReady */
|
||||||
|
|
||||||
|
@ -166,6 +167,9 @@ typedef struct _AT91S_DATAFLASH_INFO {
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
extern int size_dataflash (AT91PS_DataFlash pdataFlash, unsigned long addr, unsigned long size);
|
||||||
|
extern int prot_dataflash (AT91PS_DataFlash pdataFlash, unsigned long addr);
|
||||||
|
extern int dataflash_real_protect (int flag, unsigned long start_addr, unsigned long end_addr);
|
||||||
extern int addr_dataflash (unsigned long addr);
|
extern int addr_dataflash (unsigned long addr);
|
||||||
extern int read_dataflash (unsigned long addr, unsigned long size, char *result);
|
extern int read_dataflash (unsigned long addr, unsigned long size, char *result);
|
||||||
extern int write_dataflash (unsigned long addr, unsigned long dest, unsigned long size);
|
extern int write_dataflash (unsigned long addr, unsigned long dest, unsigned long size);
|
||||||
|
|
|
@ -41,20 +41,24 @@ extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
|
||||||
defined (CONFIG_CMDLINE_TAG) || \
|
defined (CONFIG_CMDLINE_TAG) || \
|
||||||
defined (CONFIG_INITRD_TAG) || \
|
defined (CONFIG_INITRD_TAG) || \
|
||||||
defined (CONFIG_VFD)
|
defined (CONFIG_VFD)
|
||||||
static void setup_start_tag(bd_t *bd);
|
static void setup_start_tag (bd_t *bd);
|
||||||
|
|
||||||
# ifdef CONFIG_SETUP_MEMORY_TAGS
|
# ifdef CONFIG_SETUP_MEMORY_TAGS
|
||||||
static void setup_memory_tags(bd_t *bd);
|
static void setup_memory_tags (bd_t *bd);
|
||||||
# endif
|
# endif
|
||||||
static void setup_commandline_tag(bd_t *bd, char *commandline);
|
static void setup_commandline_tag (bd_t *bd, char *commandline);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static void setup_ramdisk_tag(bd_t *bd);
|
static void setup_ramdisk_tag (bd_t *bd);
|
||||||
#endif
|
#endif
|
||||||
# ifdef CONFIG_INITRD_TAG
|
# ifdef CONFIG_INITRD_TAG
|
||||||
static void setup_initrd_tag(bd_t *bd, ulong initrd_start, ulong initrd_end);
|
static void setup_initrd_tag (bd_t *bd, ulong initrd_start,
|
||||||
|
ulong initrd_end);
|
||||||
# endif
|
# endif
|
||||||
static void setup_end_tag(bd_t *bd);
|
static void setup_end_tag (bd_t *bd);
|
||||||
|
|
||||||
# if defined (CONFIG_VFD)
|
# if defined (CONFIG_VFD)
|
||||||
static void setup_videolfb_tag(gd_t *gd);
|
static void setup_videolfb_tag (gd_t *gd);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,180 +72,179 @@ static struct tag *params;
|
||||||
# define SHOW_BOOT_PROGRESS(arg)
|
# define SHOW_BOOT_PROGRESS(arg)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern image_header_t header; /* from cmd_bootm.c */
|
extern image_header_t header; /* from cmd_bootm.c */
|
||||||
|
|
||||||
|
|
||||||
void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
|
void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
|
||||||
ulong addr, ulong *len_ptr, int verify)
|
ulong addr, ulong *len_ptr, int verify)
|
||||||
{
|
{
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
ulong len = 0, checksum;
|
ulong len = 0, checksum;
|
||||||
ulong initrd_start, initrd_end;
|
ulong initrd_start, initrd_end;
|
||||||
ulong data;
|
ulong data;
|
||||||
void (*theKernel)(int zero, int arch);
|
void (*theKernel) (int zero, int arch);
|
||||||
image_header_t *hdr = &header;
|
image_header_t *hdr = &header;
|
||||||
bd_t *bd = gd->bd;
|
bd_t *bd = gd->bd;
|
||||||
|
|
||||||
#ifdef CONFIG_CMDLINE_TAG
|
#ifdef CONFIG_CMDLINE_TAG
|
||||||
char *commandline = getenv("bootargs");
|
char *commandline = getenv ("bootargs");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
theKernel = (void (*)(int, int))ntohl(hdr->ih_ep);
|
theKernel = (void (*)(int, int)) ntohl (hdr->ih_ep);
|
||||||
|
|
||||||
/*
|
|
||||||
* Check if there is an initrd image
|
|
||||||
*/
|
|
||||||
if (argc >= 3) {
|
|
||||||
SHOW_BOOT_PROGRESS (9);
|
|
||||||
|
|
||||||
addr = simple_strtoul(argv[2], NULL, 16);
|
|
||||||
|
|
||||||
printf ("## Loading Ramdisk Image at %08lx ...\n", addr);
|
|
||||||
|
|
||||||
/* Copy header so we can blank CRC field for re-calculation */
|
|
||||||
#ifdef CONFIG_HAS_DATAFLASH
|
|
||||||
if (addr_dataflash(addr)){
|
|
||||||
read_dataflash(addr, sizeof(image_header_t), (char *)&header);
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
memcpy (&header, (char *)addr, sizeof(image_header_t));
|
|
||||||
|
|
||||||
if (ntohl(hdr->ih_magic) != IH_MAGIC) {
|
|
||||||
printf ("Bad Magic Number\n");
|
|
||||||
SHOW_BOOT_PROGRESS (-10);
|
|
||||||
do_reset (cmdtp, flag, argc, argv);
|
|
||||||
}
|
|
||||||
|
|
||||||
data = (ulong)&header;
|
|
||||||
len = sizeof(image_header_t);
|
|
||||||
|
|
||||||
checksum = ntohl(hdr->ih_hcrc);
|
|
||||||
hdr->ih_hcrc = 0;
|
|
||||||
|
|
||||||
if (crc32 (0, (char *)data, len) != checksum) {
|
|
||||||
printf ("Bad Header Checksum\n");
|
|
||||||
SHOW_BOOT_PROGRESS (-11);
|
|
||||||
do_reset (cmdtp, flag, argc, argv);
|
|
||||||
}
|
|
||||||
|
|
||||||
SHOW_BOOT_PROGRESS (10);
|
|
||||||
|
|
||||||
print_image_hdr (hdr);
|
|
||||||
|
|
||||||
data = addr + sizeof(image_header_t);
|
|
||||||
len = ntohl(hdr->ih_size);
|
|
||||||
|
|
||||||
#ifdef CONFIG_HAS_DATAFLASH
|
|
||||||
if (addr_dataflash(addr)){
|
|
||||||
read_dataflash(data, len, (char *)CFG_LOAD_ADDR);
|
|
||||||
data = CFG_LOAD_ADDR;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (verify) {
|
|
||||||
ulong csum = 0;
|
|
||||||
|
|
||||||
printf (" Verifying Checksum ... ");
|
|
||||||
csum = crc32 (0, (char *)data, len);
|
|
||||||
if (csum != ntohl(hdr->ih_dcrc)) {
|
|
||||||
printf ("Bad Data CRC\n");
|
|
||||||
SHOW_BOOT_PROGRESS (-12);
|
|
||||||
do_reset (cmdtp, flag, argc, argv);
|
|
||||||
}
|
|
||||||
printf ("OK\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
SHOW_BOOT_PROGRESS (11);
|
|
||||||
|
|
||||||
if ((hdr->ih_os != IH_OS_LINUX) ||
|
|
||||||
(hdr->ih_arch != IH_CPU_ARM) ||
|
|
||||||
(hdr->ih_type != IH_TYPE_RAMDISK) ) {
|
|
||||||
printf ("No Linux ARM Ramdisk Image\n");
|
|
||||||
SHOW_BOOT_PROGRESS (-13);
|
|
||||||
do_reset (cmdtp, flag, argc, argv);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now check if we have a multifile image
|
* Check if there is an initrd image
|
||||||
*/
|
*/
|
||||||
} else if ((hdr->ih_type==IH_TYPE_MULTI) && (len_ptr[1])) {
|
if (argc >= 3) {
|
||||||
ulong tail = ntohl(len_ptr[0]) % 4;
|
SHOW_BOOT_PROGRESS (9);
|
||||||
int i;
|
|
||||||
|
|
||||||
SHOW_BOOT_PROGRESS (13);
|
addr = simple_strtoul (argv[2], NULL, 16);
|
||||||
|
|
||||||
/* skip kernel length and terminator */
|
printf ("## Loading Ramdisk Image at %08lx ...\n", addr);
|
||||||
data = (ulong)(&len_ptr[2]);
|
|
||||||
/* skip any additional image length fields */
|
/* Copy header so we can blank CRC field for re-calculation */
|
||||||
for (i=1; len_ptr[i]; ++i)
|
#ifdef CONFIG_HAS_DATAFLASH
|
||||||
data += 4;
|
if (addr_dataflash (addr)) {
|
||||||
/* add kernel length, and align */
|
read_dataflash (addr, sizeof (image_header_t),
|
||||||
data += ntohl(len_ptr[0]);
|
(char *) &header);
|
||||||
if (tail) {
|
} else
|
||||||
data += 4 - tail;
|
#endif
|
||||||
|
memcpy (&header, (char *) addr,
|
||||||
|
sizeof (image_header_t));
|
||||||
|
|
||||||
|
if (ntohl (hdr->ih_magic) != IH_MAGIC) {
|
||||||
|
printf ("Bad Magic Number\n");
|
||||||
|
SHOW_BOOT_PROGRESS (-10);
|
||||||
|
do_reset (cmdtp, flag, argc, argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
data = (ulong) & header;
|
||||||
|
len = sizeof (image_header_t);
|
||||||
|
|
||||||
|
checksum = ntohl (hdr->ih_hcrc);
|
||||||
|
hdr->ih_hcrc = 0;
|
||||||
|
|
||||||
|
if (crc32 (0, (char *) data, len) != checksum) {
|
||||||
|
printf ("Bad Header Checksum\n");
|
||||||
|
SHOW_BOOT_PROGRESS (-11);
|
||||||
|
do_reset (cmdtp, flag, argc, argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
SHOW_BOOT_PROGRESS (10);
|
||||||
|
|
||||||
|
print_image_hdr (hdr);
|
||||||
|
|
||||||
|
data = addr + sizeof (image_header_t);
|
||||||
|
len = ntohl (hdr->ih_size);
|
||||||
|
|
||||||
|
#ifdef CONFIG_HAS_DATAFLASH
|
||||||
|
if (addr_dataflash (addr)) {
|
||||||
|
read_dataflash (data, len, (char *) CFG_LOAD_ADDR);
|
||||||
|
data = CFG_LOAD_ADDR;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (verify) {
|
||||||
|
ulong csum = 0;
|
||||||
|
|
||||||
|
printf (" Verifying Checksum ... ");
|
||||||
|
csum = crc32 (0, (char *) data, len);
|
||||||
|
if (csum != ntohl (hdr->ih_dcrc)) {
|
||||||
|
printf ("Bad Data CRC\n");
|
||||||
|
SHOW_BOOT_PROGRESS (-12);
|
||||||
|
do_reset (cmdtp, flag, argc, argv);
|
||||||
|
}
|
||||||
|
printf ("OK\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
SHOW_BOOT_PROGRESS (11);
|
||||||
|
|
||||||
|
if ((hdr->ih_os != IH_OS_LINUX) ||
|
||||||
|
(hdr->ih_arch != IH_CPU_ARM) ||
|
||||||
|
(hdr->ih_type != IH_TYPE_RAMDISK)) {
|
||||||
|
printf ("No Linux ARM Ramdisk Image\n");
|
||||||
|
SHOW_BOOT_PROGRESS (-13);
|
||||||
|
do_reset (cmdtp, flag, argc, argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now check if we have a multifile image
|
||||||
|
*/
|
||||||
|
} else if ((hdr->ih_type == IH_TYPE_MULTI) && (len_ptr[1])) {
|
||||||
|
ulong tail = ntohl (len_ptr[0]) % 4;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
SHOW_BOOT_PROGRESS (13);
|
||||||
|
|
||||||
|
/* skip kernel length and terminator */
|
||||||
|
data = (ulong) (&len_ptr[2]);
|
||||||
|
/* skip any additional image length fields */
|
||||||
|
for (i = 1; len_ptr[i]; ++i)
|
||||||
|
data += 4;
|
||||||
|
/* add kernel length, and align */
|
||||||
|
data += ntohl (len_ptr[0]);
|
||||||
|
if (tail) {
|
||||||
|
data += 4 - tail;
|
||||||
|
}
|
||||||
|
|
||||||
|
len = ntohl (len_ptr[1]);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* no initrd image
|
||||||
|
*/
|
||||||
|
SHOW_BOOT_PROGRESS (14);
|
||||||
|
|
||||||
|
len = data = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = ntohl(len_ptr[1]);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* no initrd image
|
|
||||||
*/
|
|
||||||
SHOW_BOOT_PROGRESS (14);
|
|
||||||
|
|
||||||
data = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (!data) {
|
if (!data) {
|
||||||
printf ("No initrd\n");
|
printf ("No initrd\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
initrd_start = data;
|
initrd_start = data;
|
||||||
initrd_end = initrd_start + len;
|
initrd_end = initrd_start + len;
|
||||||
} else {
|
} else {
|
||||||
initrd_start = 0;
|
initrd_start = 0;
|
||||||
initrd_end = 0;
|
initrd_end = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SHOW_BOOT_PROGRESS (15);
|
SHOW_BOOT_PROGRESS (15);
|
||||||
|
|
||||||
#ifdef DEBUG
|
debug ("## Transferring control to Linux (at address %08lx) ...\n",
|
||||||
printf ("## Transferring control to Linux (at address %08lx) ...\n",
|
(ulong) theKernel);
|
||||||
(ulong)theKernel);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (CONFIG_SETUP_MEMORY_TAGS) || \
|
#if defined (CONFIG_SETUP_MEMORY_TAGS) || \
|
||||||
defined (CONFIG_CMDLINE_TAG) || \
|
defined (CONFIG_CMDLINE_TAG) || \
|
||||||
defined (CONFIG_INITRD_TAG) || \
|
defined (CONFIG_INITRD_TAG) || \
|
||||||
defined (CONFIG_VFD)
|
defined (CONFIG_VFD)
|
||||||
setup_start_tag(bd);
|
setup_start_tag (bd);
|
||||||
#ifdef CONFIG_SETUP_MEMORY_TAGS
|
#ifdef CONFIG_SETUP_MEMORY_TAGS
|
||||||
setup_memory_tags(bd);
|
setup_memory_tags (bd);
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_CMDLINE_TAG
|
#ifdef CONFIG_CMDLINE_TAG
|
||||||
setup_commandline_tag(bd, commandline);
|
setup_commandline_tag (bd, commandline);
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_INITRD_TAG
|
#ifdef CONFIG_INITRD_TAG
|
||||||
setup_initrd_tag(bd, initrd_start, initrd_end);
|
if (initrd_start && initrd_end)
|
||||||
#endif
|
setup_initrd_tag (bd, initrd_start, initrd_end);
|
||||||
#if 0
|
|
||||||
setup_ramdisk_tag(bd);
|
|
||||||
#endif
|
#endif
|
||||||
#if defined (CONFIG_VFD)
|
#if defined (CONFIG_VFD)
|
||||||
setup_videolfb_tag((gd_t *)gd);
|
setup_videolfb_tag ((gd_t *) gd);
|
||||||
#endif
|
#endif
|
||||||
setup_end_tag(bd);
|
setup_end_tag (bd);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* we assume that the kernel is in place */
|
/* we assume that the kernel is in place */
|
||||||
printf("\nStarting kernel ...\n\n");
|
printf ("\nStarting kernel ...\n\n");
|
||||||
|
|
||||||
cleanup_before_linux();
|
cleanup_before_linux ();
|
||||||
|
|
||||||
theKernel(0, bd->bi_arch_number);
|
theKernel (0, bd->bi_arch_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -249,59 +252,59 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
|
||||||
defined (CONFIG_CMDLINE_TAG) || \
|
defined (CONFIG_CMDLINE_TAG) || \
|
||||||
defined (CONFIG_INITRD_TAG) || \
|
defined (CONFIG_INITRD_TAG) || \
|
||||||
defined (CONFIG_VFD)
|
defined (CONFIG_VFD)
|
||||||
static void setup_start_tag(bd_t *bd)
|
static void setup_start_tag (bd_t *bd)
|
||||||
{
|
{
|
||||||
params = (struct tag *)bd->bi_boot_params;
|
params = (struct tag *) bd->bi_boot_params;
|
||||||
|
|
||||||
params->hdr.tag = ATAG_CORE;
|
params->hdr.tag = ATAG_CORE;
|
||||||
params->hdr.size = tag_size(tag_core);
|
params->hdr.size = tag_size (tag_core);
|
||||||
|
|
||||||
params->u.core.flags = 0;
|
params->u.core.flags = 0;
|
||||||
params->u.core.pagesize = 0;
|
params->u.core.pagesize = 0;
|
||||||
params->u.core.rootdev = 0;
|
params->u.core.rootdev = 0;
|
||||||
|
|
||||||
params = tag_next(params);
|
params = tag_next (params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef CONFIG_SETUP_MEMORY_TAGS
|
#ifdef CONFIG_SETUP_MEMORY_TAGS
|
||||||
static void setup_memory_tags(bd_t *bd)
|
static void setup_memory_tags (bd_t *bd)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
|
for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
|
||||||
params->hdr.tag = ATAG_MEM;
|
params->hdr.tag = ATAG_MEM;
|
||||||
params->hdr.size = tag_size(tag_mem32);
|
params->hdr.size = tag_size (tag_mem32);
|
||||||
|
|
||||||
params->u.mem.start = bd->bi_dram[i].start;
|
params->u.mem.start = bd->bi_dram[i].start;
|
||||||
params->u.mem.size = bd->bi_dram[i].size;
|
params->u.mem.size = bd->bi_dram[i].size;
|
||||||
|
|
||||||
params = tag_next(params);
|
params = tag_next (params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_SETUP_MEMORY_TAGS */
|
#endif /* CONFIG_SETUP_MEMORY_TAGS */
|
||||||
|
|
||||||
|
|
||||||
static void setup_commandline_tag(bd_t *bd, char *commandline)
|
static void setup_commandline_tag (bd_t *bd, char *commandline)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
/* eat leading white space */
|
/* eat leading white space */
|
||||||
for(p = commandline; *p == ' '; p++)
|
for (p = commandline; *p == ' '; p++);
|
||||||
;
|
|
||||||
|
|
||||||
/* skip non-existent command lines so the kernel will still
|
/* skip non-existent command lines so the kernel will still
|
||||||
* use its default command line.
|
* use its default command line.
|
||||||
*/
|
*/
|
||||||
if(*p == '\0')
|
if (*p == '\0')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
params->hdr.tag = ATAG_CMDLINE;
|
params->hdr.tag = ATAG_CMDLINE;
|
||||||
params->hdr.size = (sizeof(struct tag_header) + strlen(p) + 1 + 4) >> 2;
|
params->hdr.size =
|
||||||
|
(sizeof (struct tag_header) + strlen (p) + 1 + 4) >> 2;
|
||||||
|
|
||||||
strcpy(params->u.cmdline.cmdline, p);
|
strcpy (params->u.cmdline.cmdline, p);
|
||||||
|
|
||||||
params = tag_next(params);
|
params = tag_next (params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -310,64 +313,47 @@ static void setup_commandline_tag(bd_t *bd, char *commandline)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_INITRD_TAG
|
#ifdef CONFIG_INITRD_TAG
|
||||||
static void setup_initrd_tag(bd_t *bd, ulong initrd_start, ulong initrd_end)
|
static void setup_initrd_tag (bd_t *bd, ulong initrd_start, ulong initrd_end)
|
||||||
{
|
{
|
||||||
/* an ATAG_INITRD node tells the kernel where the compressed
|
/* an ATAG_INITRD node tells the kernel where the compressed
|
||||||
* ramdisk can be found. ATAG_RDIMG is a better name, actually.
|
* ramdisk can be found. ATAG_RDIMG is a better name, actually.
|
||||||
*/
|
*/
|
||||||
params->hdr.tag = ATAG_INITRD2;
|
params->hdr.tag = ATAG_INITRD2;
|
||||||
params->hdr.size = tag_size(tag_initrd);
|
params->hdr.size = tag_size (tag_initrd);
|
||||||
|
|
||||||
params->u.initrd.start = initrd_start;
|
params->u.initrd.start = initrd_start;
|
||||||
params->u.initrd.size = initrd_end - initrd_start;
|
params->u.initrd.size = initrd_end - initrd_start;
|
||||||
|
|
||||||
params = tag_next(params);
|
params = tag_next (params);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_INITRD_TAG */
|
#endif /* CONFIG_INITRD_TAG */
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
static void setup_ramdisk_tag(bd_t *bd)
|
|
||||||
{
|
|
||||||
/* an ATAG_RAMDISK node tells the kernel how large the
|
|
||||||
* decompressed ramdisk will become.
|
|
||||||
*/
|
|
||||||
params->hdr.tag = ATAG_RAMDISK;
|
|
||||||
params->hdr.size = tag_size(tag_ramdisk);
|
|
||||||
|
|
||||||
params->u.ramdisk.start = 0;
|
|
||||||
/*params->u.ramdisk.size = RAMDISK_SIZE; */
|
|
||||||
params->u.ramdisk.flags = 1; /* automatically load ramdisk */
|
|
||||||
|
|
||||||
params = tag_next(params);
|
|
||||||
}
|
|
||||||
#endif /* 0 */
|
|
||||||
|
|
||||||
#if defined (CONFIG_VFD)
|
#if defined (CONFIG_VFD)
|
||||||
static void setup_videolfb_tag(gd_t *gd)
|
static void setup_videolfb_tag (gd_t *gd)
|
||||||
{
|
{
|
||||||
/* An ATAG_VIDEOLFB node tells the kernel where and how large
|
/* An ATAG_VIDEOLFB node tells the kernel where and how large
|
||||||
* the framebuffer for video was allocated (among other things).
|
* the framebuffer for video was allocated (among other things).
|
||||||
* Note that a _physical_ address is passed !
|
* Note that a _physical_ address is passed !
|
||||||
*
|
*
|
||||||
* We only use it to pass the address and size, the other entries
|
* We only use it to pass the address and size, the other entries
|
||||||
* in the tag_videolfb are not of interest.
|
* in the tag_videolfb are not of interest.
|
||||||
*/
|
*/
|
||||||
params->hdr.tag = ATAG_VIDEOLFB;
|
params->hdr.tag = ATAG_VIDEOLFB;
|
||||||
params->hdr.size = tag_size(tag_videolfb);
|
params->hdr.size = tag_size (tag_videolfb);
|
||||||
|
|
||||||
params->u.videolfb.lfb_base = (u32)gd->fb_base;
|
params->u.videolfb.lfb_base = (u32) gd->fb_base;
|
||||||
/* 7168 = 256*4*56/8 - actually 2 pages (8192 bytes) are allocated */
|
/* 7168 = 256*4*56/8 - actually 2 pages (8192 bytes) are allocated */
|
||||||
params->u.videolfb.lfb_size = 7168;
|
params->u.videolfb.lfb_size = 7168;
|
||||||
|
|
||||||
params = tag_next(params);
|
params = tag_next (params);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void setup_end_tag(bd_t *bd)
|
static void setup_end_tag (bd_t *bd)
|
||||||
{
|
{
|
||||||
params->hdr.tag = ATAG_NONE;
|
params->hdr.tag = ATAG_NONE;
|
||||||
params->hdr.size = 0;
|
params->hdr.size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */
|
#endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */
|
||||||
|
|
Loading…
Add table
Reference in a new issue