]> git.sur5r.net Git - openocd/blobdiff - src/flash/str9xpec.c
- Eleminated leading tabs/white space
[openocd] / src / flash / str9xpec.c
index f26a7632dcaef0b6523b378dbb9005dfe165413a..eb08eb244eeefdbb7705e7ed5f3ba68fced25804 100644 (file)
@@ -125,6 +125,12 @@ int str9xpec_register_commands(struct command_context_s *cmd_ctx)
 int str9xpec_set_instr(int chain_pos, u32 new_instr, enum tap_state end_state)
 {
        jtag_device_t *device = jtag_get_device(chain_pos);
+       
+       if (device == NULL)
+       {
+               DEBUG("Invalid Target");
+               return ERROR_TARGET_INVALID;
+       }
                
        if (buf_get_u32(device->cur_instr, 0, device->ir_length) != new_instr)
        {
@@ -154,7 +160,8 @@ u8 str9xpec_isc_status(int chain_pos)
        scan_field_t field;
        u8 status;
        
-       str9xpec_set_instr(chain_pos, ISC_NOOP, TAP_PI);
+       if (str9xpec_set_instr(chain_pos, ISC_NOOP, TAP_PI) != ERROR_OK)
+               return ISC_STATUS_ERROR;
        
        field.device = chain_pos;
        field.num_bits = 8;
@@ -189,7 +196,8 @@ int str9xpec_isc_enable(struct flash_bank_s *bank)
                return ERROR_OK;
        
        /* enter isc mode */
-       str9xpec_set_instr(chain_pos, ISC_ENABLE, TAP_RTI);
+       if (str9xpec_set_instr(chain_pos, ISC_ENABLE, TAP_RTI) != ERROR_OK)
+               return ERROR_TARGET_INVALID;
        
        /* check ISC status */
        status = str9xpec_isc_status(chain_pos);
@@ -214,7 +222,8 @@ int str9xpec_isc_disable(struct flash_bank_s *bank)
        if (!str9xpec_info->isc_enable)
                return ERROR_OK;
        
-       str9xpec_set_instr(chain_pos, ISC_DISABLE, TAP_RTI);
+       if (str9xpec_set_instr(chain_pos, ISC_DISABLE, TAP_RTI) != ERROR_OK)
+               return ERROR_TARGET_INVALID;
        
        /* delay to handle aborts */
        jtag_add_sleep(50);
@@ -273,10 +282,10 @@ int str9xpec_build_block_list(struct flash_bank_s *bank)
                
        switch (bank->size)
        {
-               case 256 * 1024:
+               case (256 * 1024):
                        b0_sectors = 4;
                        break;
-               case 512 * 1024:
+               case (512 * 1024):
                        b0_sectors = 8;
                        break;
                default:
@@ -284,7 +293,9 @@ int str9xpec_build_block_list(struct flash_bank_s *bank)
                        exit(-1);
        }
        
+       /* include bank 1 sectors */
        num_sectors = b0_sectors + 4;
+       bank->size += (32 * 1024);
        
        bank->num_sectors = num_sectors;
        bank->sectors = malloc(sizeof(flash_sector_t) * num_sectors);
@@ -336,18 +347,11 @@ int str9xpec_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, ch
                WARNING("overriding flash base address for STR91x device with 0x00000000");
                bank->base = 0x00000000;
        }
-       
-       str9xpec_info->target = get_target_by_num(strtoul(args[5], NULL, 0));
-       if (!str9xpec_info->target)
-       {
-               ERROR("no target '%s' configured", args[5]);
-               exit(-1);
-       }
 
        /* find out jtag position of flash controller
         * it is always after the arm966 core */
        
-       armv4_5 = str9xpec_info->target->arch_info;
+       armv4_5 = bank->target->arch_info;
        arm7_9 = armv4_5->arch_info;
        jtag_info = &arm7_9->jtag_info;
        
@@ -599,37 +603,9 @@ int str9xpec_lock_device(struct flash_bank_s *bank)
 int str9xpec_unlock_device(struct flash_bank_s *bank)
 {
        u8 status;
-       //u32 chain_pos;
-       //jtag_device_t* dev0;
-       //jtag_device_t* dev1;
-       //jtag_device_t* dev2;
-       
-       //str9xpec_flash_controller_t *str9xpec_info = bank->driver_priv;
-       
-       //chain_pos = str9xpec_info->chain_pos;
-       
-       /* remove arm core from chain - enter turbo mode */
-       
-       //str9xpec_set_instr(chain_pos+2, 0xD, TAP_RTI);
-       //jtag_execute_queue();
-       
-       /* modify scan chain - arm9 has been removed */
-       //dev0 = jtag_get_device(chain_pos);
-       //dev1 = jtag_get_device(chain_pos+1);
-       //dev2 = jtag_get_device(chain_pos+2);
-       //dev0->next = dev2;
-       //jtag_num_devices--;
        
        status = str9xpec_erase_area(bank, 0, 255);
        
-       /* exit turbo mode via TLR */
-       //str9xpec_set_instr(chain_pos, ISC_NOOP, TAP_TLR);
-       //jtag_execute_queue();
-       
-       /* restore previous scan chain */
-       //dev0->next = dev1;
-       //jtag_num_devices++;
-       
        return status;
 }
 
@@ -815,10 +791,10 @@ int str9xpec_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
                        } while(!(status & ISC_STATUS_BUSY));
                        
                        if ((status & ISC_STATUS_ERROR) != STR9XPEC_ISC_SUCCESS)
-                               return ERROR_FLASH_OPERATION_FAILED; 
+                               return ERROR_FLASH_OPERATION_FAILED;
                        
                        //if ((status & ISC_STATUS_INT_ERROR) != STR9XPEC_ISC_INTFAIL)
-                       //      return ERROR_FLASH_OPERATION_FAILED; 
+                       //      return ERROR_FLASH_OPERATION_FAILED;
                
                        dwords_remaining--;
                        bytes_written += 8;
@@ -878,7 +854,7 @@ int str9xpec_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
                        return ERROR_FLASH_OPERATION_FAILED;
                
                //if ((status & ISC_STATUS_INT_ERROR) != STR9XPEC_ISC_INTFAIL)
-               //      return ERROR_FLASH_OPERATION_FAILED; 
+               //      return ERROR_FLASH_OPERATION_FAILED;
        }
 
        free(scanbuf);
@@ -1025,7 +1001,10 @@ int str9xpec_write_options(struct flash_bank_s *bank)
        chain_pos = str9xpec_info->chain_pos;
        
        /* erase config options first */
-       str9xpec_erase_area( bank, 0xFE, 0xFE );
+       status = str9xpec_erase_area( bank, 0xFE, 0xFE );
+       
+       if ((status & ISC_STATUS_ERROR) != STR9XPEC_ISC_SUCCESS)
+               return status; 
        
        if (!str9xpec_info->isc_enable) {
                str9xpec_isc_enable( bank );
@@ -1128,7 +1107,7 @@ int str9xpec_handle_flash_options_cmap_command(struct command_context_s *cmd_ctx
        
        str9xpec_info = bank->driver_priv;
        
-       if (stricmp(args[1], "bank1") == 0)
+       if (strcmp(args[1], "bank1") == 0)
        {
                buf_set_u32(str9xpec_info->options, STR9XPEC_OPT_CSMAPBIT, 1, 1);
        }
@@ -1160,7 +1139,7 @@ int str9xpec_handle_flash_options_lvdthd_command(struct command_context_s *cmd_c
        
        str9xpec_info = bank->driver_priv;
        
-       if (stricmp(args[1], "2.7v") == 0)
+       if (strcmp(args[1], "2.7v") == 0)
        {
                buf_set_u32(str9xpec_info->options, STR9XPEC_OPT_LVDTHRESBIT, 1, 1);
        }
@@ -1192,7 +1171,7 @@ int str9xpec_handle_flash_options_lvdsel_command(struct command_context_s *cmd_c
        
        str9xpec_info = bank->driver_priv;
        
-       if (stricmp(args[1], "vdd_vddq") == 0)
+       if (strcmp(args[1], "vdd_vddq") == 0)
        {
                buf_set_u32(str9xpec_info->options, STR9XPEC_OPT_LVDSELBIT, 1, 1);
        }
@@ -1224,7 +1203,7 @@ int str9xpec_handle_flash_options_lvdwarn_command(struct command_context_s *cmd_
        
        str9xpec_info = bank->driver_priv;
        
-       if (stricmp(args[1], "vdd_vddq") == 0)
+       if (strcmp(args[1], "vdd_vddq") == 0)
        {
                buf_set_u32(str9xpec_info->options, STR9XPEC_OPT_LVDWARNBIT, 1, 1);
        }
@@ -1362,6 +1341,7 @@ int str9xpec_handle_flash_disable_turbo_command(struct command_context_s *cmd_ct
        if( str9xpec_info->devarm ) {
                dev0->next = str9xpec_info->devarm;
                jtag_num_devices++;
+               str9xpec_info->devarm = NULL;
        }
        
        return ERROR_OK;