@ -59,7 +59,7 @@ intel_flash_autodetect32( cfi_array_t *cfi_array )
{
bus_area_t area ;
if ( bus_area ( cfi_array - > bus , 0 , & area ) ! = 0 )
if ( bus_area ( cfi_array - > bus , cfi_array - > address , & area ) ! = 0 )
return 0 ;
return ( ( cfi_array - > cfi_chips [ 0 ] - > cfi . identification_string . pri_id_code = = CFI_VENDOR_INTEL_ECS )
@ -72,7 +72,7 @@ intel_flash_autodetect( cfi_array_t *cfi_array )
{
bus_area_t area ;
if ( bus_area ( cfi_array - > bus , 0 , & area ) ! = 0 )
if ( bus_area ( cfi_array - > bus , cfi_array - > address , & area ) ! = 0 )
return 0 ;
return ( ( cfi_array - > cfi_chips [ 0 ] - > cfi . identification_string . pri_id_code = = CFI_VENDOR_INTEL_ECS )
@ -85,7 +85,7 @@ intel_flash_autodetect8( cfi_array_t *cfi_array )
{
bus_area_t area ;
if ( bus_area ( cfi_array - > bus , 0 , & area ) ! = 0 )
if ( bus_area ( cfi_array - > bus , cfi_array - > address , & area ) ! = 0 )
return 0 ;
return ( ( cfi_array - > cfi_chips [ 0 ] - > cfi . identification_string . pri_id_code = = CFI_VENDOR_INTEL_ECS )
@ -94,11 +94,12 @@ intel_flash_autodetect8( cfi_array_t *cfi_array )
}
static void
_intel_flash_print_info ( bus_t * bus , int o )
_intel_flash_print_info ( cfi_array_t * cfi_array , int o )
{
uint32_t mid , cid ;
bus_t * bus = cfi_array - > bus ;
mid = ( bus_read ( bus , 0x00 < < o ) & 0xFF ) ;
mid = ( bus_read ( bus , cfi_array - > address + ( 0x00 < < o ) ) & 0xFF ) ;
switch ( mid ) {
case STD_MIC_INTEL :
printf ( _ ( " Manufacturer: %s \n " ) , STD_MICN_INTEL ) ;
@ -109,7 +110,7 @@ _intel_flash_print_info( bus_t *bus, int o )
}
printf ( _ ( " Chip: " ) ) ;
cid = ( bus_read ( bus , 0x01 < < o ) & 0xFFFF ) ;
cid = ( bus_read ( bus , cfi_array - > address + ( 0x01 < < o ) ) & 0xFFFF ) ;
switch ( cid ) {
case 0x0016 :
printf ( " 28F320J3A \n " ) ;
@ -144,7 +145,7 @@ _intel_flash_print_info( bus_t *bus, int o )
}
/* Read Array */
bus_write ( bus , 0 < < o , 0x00FF00FF ) ;
bus_write ( bus , cfi_array - > address + ( 0 < < o ) , 0x00FF00FF ) ;
}
static void
@ -157,12 +158,12 @@ intel_flash_print_info( cfi_array_t *cfi_array )
/* TODO */
/* Clear Status Register */
bus_write ( bus , 0 < < o , 0x0050 ) ;
bus_write ( bus , cfi_array - > address + ( 0 < < o ) , 0x0050 ) ;
/* Read Identifier Command */
bus_write ( bus , 0 < < 0 , 0x0090 ) ;
bus_write ( bus , cfi_array - > address + ( 0 < < 0 ) , 0x0090 ) ;
_intel_flash_print_info ( bus , o ) ;
_intel_flash_print_info ( cfi_array , o ) ;
}
static void
@ -174,12 +175,12 @@ intel_flash_print_info32( cfi_array_t *cfi_array )
/* TODO */
/* Clear Status Register */
bus_write ( bus , 0 < < o , 0x00500050 ) ;
bus_write ( bus , cfi_array - > address + ( 0 < < o ) , 0x00500050 ) ;
/* Read Identifier Command */
bus_write ( bus , 0 < < 0 , 0x00900090 ) ;
bus_write ( bus , cfi_array - > address + ( 0 < < 0 ) , 0x00900090 ) ;
_intel_flash_print_info ( bus , o ) ;
_intel_flash_print_info ( cfi_array , o ) ;
}
static int
@ -188,11 +189,11 @@ intel_flash_erase_block( cfi_array_t *cfi_array, uint32_t adr )
uint16_t sr ;
bus_t * bus = cfi_array - > bus ;
bus_write ( bus , 0 , CFI_INTEL_CMD_CLEAR_STATUS_REGISTER ) ;
bus_write ( bus , cfi_array - > address , CFI_INTEL_CMD_CLEAR_STATUS_REGISTER ) ;
bus_write ( bus , adr , CFI_INTEL_CMD_BLOCK_ERASE ) ;
bus_write ( bus , adr , CFI_INTEL_CMD_CONFIRM ) ;
while ( ! ( ( sr = bus_read ( bus , 0 ) & 0xFE ) & CFI_INTEL_SR_READY ) ) ; /* TODO: add timeout */
while ( ! ( ( sr = bus_read ( bus , cfi_array - > address ) & 0xFE ) & CFI_INTEL_SR_READY ) ) ; /* TODO: add timeout */
switch ( sr & ~ CFI_INTEL_SR_READY ) {
case 0 :
@ -219,11 +220,11 @@ intel_flash_unlock_block( cfi_array_t *cfi_array, uint32_t adr )
uint16_t sr ;
bus_t * bus = cfi_array - > bus ;
bus_write ( bus , 0 , CFI_INTEL_CMD_CLEAR_STATUS_REGISTER ) ;
bus_write ( bus , cfi_array - > address , CFI_INTEL_CMD_CLEAR_STATUS_REGISTER ) ;
bus_write ( bus , adr , CFI_INTEL_CMD_LOCK_SETUP ) ;
bus_write ( bus , adr , CFI_INTEL_CMD_UNLOCK_BLOCK ) ;
while ( ! ( ( sr = bus_read ( bus , 0 ) & 0xFE ) & CFI_INTEL_SR_READY ) ) ; /* TODO: add timeout */
while ( ! ( ( sr = bus_read ( bus , cfi_array - > address ) & 0xFE ) & CFI_INTEL_SR_READY ) ) ; /* TODO: add timeout */
if ( sr ! = CFI_INTEL_SR_READY ) {
printf ( _ ( " flash: unknown error while unblocking \n " ) ) ;
@ -238,11 +239,11 @@ intel_flash_program( cfi_array_t *cfi_array, uint32_t adr, uint32_t data )
uint16_t sr ;
bus_t * bus = cfi_array - > bus ;
bus_write ( bus , 0 , CFI_INTEL_CMD_CLEAR_STATUS_REGISTER ) ;
bus_write ( bus , cfi_array - > address , CFI_INTEL_CMD_CLEAR_STATUS_REGISTER ) ;
bus_write ( bus , adr , CFI_INTEL_CMD_PROGRAM1 ) ;
bus_write ( bus , adr , data ) ;
while ( ! ( ( sr = bus_read ( bus , 0 ) & 0xFE ) & CFI_INTEL_SR_READY ) ) ; /* TODO: add timeout */
while ( ! ( ( sr = bus_read ( bus , cfi_array - > address ) & 0xFE ) & CFI_INTEL_SR_READY ) ) ; /* TODO: add timeout */
if ( sr ! = CFI_INTEL_SR_READY ) {
printf ( _ ( " flash: unknown error while programming \n " ) ) ;
@ -257,11 +258,11 @@ intel_flash_erase_block32( cfi_array_t *cfi_array, uint32_t adr )
uint32_t sr ;
bus_t * bus = cfi_array - > bus ;
bus_write ( bus , 0 , ( CFI_INTEL_CMD_CLEAR_STATUS_REGISTER < < 16 ) | CFI_INTEL_CMD_CLEAR_STATUS_REGISTER ) ;
bus_write ( bus , cfi_array - > address , ( CFI_INTEL_CMD_CLEAR_STATUS_REGISTER < < 16 ) | CFI_INTEL_CMD_CLEAR_STATUS_REGISTER ) ;
bus_write ( bus , adr , ( CFI_INTEL_CMD_BLOCK_ERASE < < 16 ) | CFI_INTEL_CMD_BLOCK_ERASE ) ;
bus_write ( bus , adr , ( CFI_INTEL_CMD_CONFIRM < < 16 ) | CFI_INTEL_CMD_CONFIRM ) ;
while ( ( ( sr = bus_read ( bus , 0 ) & 0x00FE00FE ) & ( ( CFI_INTEL_SR_READY < < 16 ) | CFI_INTEL_SR_READY ) ) ! = ( ( CFI_INTEL_SR_READY < < 16 ) | CFI_INTEL_SR_READY ) ) ; /* TODO: add timeout */
while ( ( ( sr = bus_read ( bus , cfi_array - > address ) & 0x00FE00FE ) & ( ( CFI_INTEL_SR_READY < < 16 ) | CFI_INTEL_SR_READY ) ) ! = ( ( CFI_INTEL_SR_READY < < 16 ) | CFI_INTEL_SR_READY ) ) ; /* TODO: add timeout */
if ( sr ! = ( ( CFI_INTEL_SR_READY < < 16 ) | CFI_INTEL_SR_READY ) ) {
printf ( " \n sr = 0x%08X \n " , sr ) ;
@ -276,11 +277,11 @@ intel_flash_unlock_block32( cfi_array_t *cfi_array, uint32_t adr )
uint32_t sr ;
bus_t * bus = cfi_array - > bus ;
bus_write ( bus , 0 , ( CFI_INTEL_CMD_CLEAR_STATUS_REGISTER < < 16 ) | CFI_INTEL_CMD_CLEAR_STATUS_REGISTER ) ;
bus_write ( bus , cfi_array - > address , ( CFI_INTEL_CMD_CLEAR_STATUS_REGISTER < < 16 ) | CFI_INTEL_CMD_CLEAR_STATUS_REGISTER ) ;
bus_write ( bus , adr , ( CFI_INTEL_CMD_LOCK_SETUP < < 16 ) | CFI_INTEL_CMD_LOCK_SETUP ) ;
bus_write ( bus , adr , ( CFI_INTEL_CMD_UNLOCK_BLOCK < < 16 ) | CFI_INTEL_CMD_UNLOCK_BLOCK ) ;
while ( ( ( sr = bus_read ( bus , 0 ) & 0x00FE00FE ) & ( ( CFI_INTEL_SR_READY < < 16 ) | CFI_INTEL_SR_READY ) ) ! = ( ( CFI_INTEL_SR_READY < < 16 ) | CFI_INTEL_SR_READY ) ) ; /* TODO: add timeout */
while ( ( ( sr = bus_read ( bus , cfi_array - > address ) & 0x00FE00FE ) & ( ( CFI_INTEL_SR_READY < < 16 ) | CFI_INTEL_SR_READY ) ) ! = ( ( CFI_INTEL_SR_READY < < 16 ) | CFI_INTEL_SR_READY ) ) ; /* TODO: add timeout */
if ( sr ! = ( ( CFI_INTEL_SR_READY < < 16 ) | CFI_INTEL_SR_READY ) ) {
printf ( " \n sr = 0x%08X \n " , sr ) ;
@ -295,11 +296,11 @@ intel_flash_program32( cfi_array_t *cfi_array, uint32_t adr, uint32_t data )
uint32_t sr ;
bus_t * bus = cfi_array - > bus ;
bus_write ( bus , 0 , ( CFI_INTEL_CMD_CLEAR_STATUS_REGISTER < < 16 ) | CFI_INTEL_CMD_CLEAR_STATUS_REGISTER ) ;
bus_write ( bus , cfi_array - > address , ( CFI_INTEL_CMD_CLEAR_STATUS_REGISTER < < 16 ) | CFI_INTEL_CMD_CLEAR_STATUS_REGISTER ) ;
bus_write ( bus , adr , ( CFI_INTEL_CMD_PROGRAM1 < < 16 ) | CFI_INTEL_CMD_PROGRAM1 ) ;
bus_write ( bus , adr , data ) ;
while ( ( ( sr = bus_read ( bus , 0 ) & 0x00FE00FE ) & ( ( CFI_INTEL_SR_READY < < 16 ) | CFI_INTEL_SR_READY ) ) ! = ( ( CFI_INTEL_SR_READY < < 16 ) | CFI_INTEL_SR_READY ) ) ; /* TODO: add timeout */
while ( ( ( sr = bus_read ( bus , cfi_array - > address ) & 0x00FE00FE ) & ( ( CFI_INTEL_SR_READY < < 16 ) | CFI_INTEL_SR_READY ) ) ! = ( ( CFI_INTEL_SR_READY < < 16 ) | CFI_INTEL_SR_READY ) ) ; /* TODO: add timeout */
if ( sr ! = ( ( CFI_INTEL_SR_READY < < 16 ) | CFI_INTEL_SR_READY ) ) {
printf ( " \n sr = 0x%08X \n " , sr ) ;
@ -312,14 +313,14 @@ static void
intel_flash_readarray32 ( cfi_array_t * cfi_array )
{
/* Read Array */
bus_write ( cfi_array - > bus , 0 , 0x00FF00FF ) ;
bus_write ( cfi_array - > bus , cfi_array - > address , 0x00FF00FF ) ;
}
static void
intel_flash_readarray ( cfi_array_t * cfi_array )
{
/* Read Array */
bus_write ( cfi_array - > bus , 0 , 0x00FF00FF ) ;
bus_write ( cfi_array - > bus , cfi_array - > address , 0x00FF00FF ) ;
}
flash_driver_t intel_32_flash_driver = {