staging/rts_pstor: remove braces {} in sd.c
PATCH 1/1 staging/rts_pstor: remove braces {} in sd.c
fixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks -WARNING: braces {} are not necessary for any arm of this statement
--- drivers/staging/rts_pstor/sd.c | 1112 +++++++++++++++++----------------------- 1 file changed, 469 insertions(+), 643 deletions(-)
drivers/staging/rts_pstor/sd.c +469 -643
@@ -192,9 +192,9 @@ RTY_SEND_CMD: stat_idx =16 ; }else if (rsp_type !=SD_RSP_TYPE_R0 ) { -for (reg_addr =REG_SD_CMD0 ; reg_addr <=REG_SD_CMD4 ; reg_addr++) { +for (reg_addr =REG_SD_CMD0 ; reg_addr <=REG_SD_CMD4 ; reg_addr++)rtsx_add_cmd (chip,READ_REG_CMD , reg_addr,0 ,0 ); - } + stat_idx =5 ; }
@@ -273,9 +273,8 @@ RTY_SEND_CMD:if ((rsp_type ==SD_RSP_TYPE_R1 ) || (rsp_type == SD_RSP_TYPE_R1b)) {if ((cmd_idx !=SEND_RELATIVE_ADDR ) && (cmd_idx !=SEND_IF_COND )) {if (cmd_idx !=STOP_TRANSMISSION ) { -if (ptr[1 ] &0x80 ) { +if (ptr[1 ] &0x80 )TRACE_RET (chip,STATUS_FAIL ); - } }#ifdef SUPPORT_SD_LOCK if (ptr[1 ] &0x7D )
@@ -294,11 +293,10 @@ RTY_SEND_CMD:RTSX_DEBUGP ("ptr[3]: 0x%02x\n" , ptr[3 ]);TRACE_RET (chip,STATUS_FAIL ); } -if (ptr[3 ] &0x01 ) { +if (ptr[3 ] &0x01 ) sd_card->sd_data_buf_ready =1 ; - }else { +else sd_card->sd_data_buf_ready =0 ; - } } }
@@ -322,17 +320,15 @@ static int sd_read_data(struct rtsx_chip *chip,if (!buf) buf_len =0 ; -if (buf_len >512 ) { +if (buf_len >512 )TRACE_RET (chip,STATUS_FAIL ); - }rtsx_init_cmd (chip);if (cmd_len) {RTSX_DEBUGP ("SD/MMC CMD %d\n" , cmd[0 ] -0x40 ); -for (i =0 ; i < (cmd_len <6 ? cmd_len :6 ); i++) { +for (i =0 ; i < (cmd_len <6 ? cmd_len :6 ); i++)rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CMD0 + i,0xFF , cmd[i]); - } }rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_BYTE_CNT_L ,0xFF , (u8 )byte_cnt);rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_BYTE_CNT_H ,0xFF , (u8)(byte_cnt >>8 ));
@@ -344,9 +340,9 @@ static int sd_read_data(struct rtsx_chip *chip,rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CFG2 ,0xFF ,SD_CALCULATE_CRC7 |SD_CHECK_CRC16 |SD_NO_WAIT_BUSY_END |SD_CHECK_CRC7 |SD_RSP_LEN_6 ); -if (trans_mode !=SD_TM_AUTO_TUNING ) { +if (trans_mode !=SD_TM_AUTO_TUNING )rtsx_add_cmd (chip,WRITE_REG_CMD ,CARD_DATA_SOURCE ,0x01 ,PINGPONG_BUFFER ); - } +rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_TRANSFER ,0xFF , trans_mode |SD_TRANSFER_START );rtsx_add_cmd (chip,CHECK_REG_CMD ,REG_SD_TRANSFER ,SD_TRANSFER_END ,SD_TRANSFER_END );
@@ -362,9 +358,8 @@ static int sd_read_data(struct rtsx_chip *chip,if (buf && buf_len) { retval =rtsx_read_ppbuf (chip, buf, buf_len); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } }return STATUS_SUCCESS ;
@@ -390,9 +385,8 @@ static int sd_write_data(struct rtsx_chip *chip, u8 trans_mode,if (buf && buf_len) { retval =rtsx_write_ppbuf (chip, buf, buf_len); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } }rtsx_init_cmd (chip);
@@ -450,15 +444,13 @@ static int sd_check_csd(struct rtsx_chip *chip, char check_wp)break ; } -if (i ==6 ) { +if (i ==6 )TRACE_RET (chip,STATUS_FAIL ); - }memcpy (sd_card->raw_csd, rsp +1 ,15 ); -if (CHECK_PID (chip,0x5209 )) { +if (CHECK_PID (chip,0x5209 ))RTSX_READ_REG (chip,REG_SD_CMD5 , sd_card->raw_csd +15 ); - }RTSX_DEBUGP ("CSD Response:\n" );RTSX_DUMP (sd_card->raw_csd,16 );
@@ -469,35 +461,35 @@ static int sd_check_csd(struct rtsx_chip *chip, char check_wp) trans_speed = rsp[4 ];if ((trans_speed &0x07 ) ==0x02 ) {if ((trans_speed &0xf8 ) >=0x30 ) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock =47 ; - }else { +else sd_card->sd_clock =CLK_50 ; - } + }else if ((trans_speed &0xf8 ) ==0x28 ) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock =39 ; - }else { +else sd_card->sd_clock =CLK_40 ; - } + }else if ((trans_speed &0xf8 ) ==0x20 ) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock =29 ; - }else { +else sd_card->sd_clock =CLK_30 ; - } + }else if ((trans_speed &0xf8 ) >=0x10 ) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock =23 ; - }else { +else sd_card->sd_clock =CLK_20 ; - } + }else if ((trans_speed &0x08 ) >=0x08 ) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock =19 ; - }else { +else sd_card->sd_clock =CLK_20 ; - } + }else {TRACE_RET (chip,STATUS_FAIL ); }
@@ -527,9 +519,9 @@ static int sd_check_csd(struct rtsx_chip *chip, char check_wp) }if (check_wp) { -if (rsp[15 ] &0x30 ) { +if (rsp[15 ] &0x30 ) chip->card_wp |=SD_CARD ; - } +RTSX_DEBUGP ("CSD WP Status: 0x%x\n" , rsp[15 ]); }
@@ -568,22 +560,22 @@ static int sd_set_sample_push_timing(struct rtsx_chip *chip) CRC_FIX_CLK | SD30_VAR_CLK0 | SAMPLE_VAR_CLK1);RTSX_WRITE_REG (chip,CLK_CTL ,CLK_LOW_FREQ ,0 ); -if ((chip->sd_ctl &SD_PUSH_POINT_CTL_MASK ) ==SD_PUSH_POINT_AUTO ) { +if ((chip->sd_ctl &SD_PUSH_POINT_CTL_MASK ) ==SD_PUSH_POINT_AUTO ) val =SD20_TX_NEG_EDGE ; - }else if ((chip->sd_ctl &SD_PUSH_POINT_CTL_MASK ) ==SD_PUSH_POINT_DELAY ) { +else if ((chip->sd_ctl &SD_PUSH_POINT_CTL_MASK ) ==SD_PUSH_POINT_DELAY ) val =SD20_TX_14_AHEAD ; - }else { +else val =SD20_TX_NEG_EDGE ; - } +RTSX_WRITE_REG (chip,SD_PUSH_POINT_CTL ,SD20_TX_SEL_MASK , val);if ((chip->sd_ctl &SD_SAMPLE_POINT_CTL_MASK ) ==SD_SAMPLE_POINT_AUTO ) {if (chip->asic_code) { -if (CHK_SD_HS (sd_card) ||CHK_MMC_52M (sd_card)) { +if (CHK_SD_HS (sd_card) ||CHK_MMC_52M (sd_card)) val =SD20_RX_14_DELAY ; - }else { +else val =SD20_RX_POS_EDGE ; - } + }else { val =SD20_RX_14_DELAY ; }
@@ -597,32 +589,28 @@ static int sd_set_sample_push_timing(struct rtsx_chip *chip) }else {u8 val =0 ; -if ((chip->sd_ctl &SD_PUSH_POINT_CTL_MASK ) ==SD_PUSH_POINT_DELAY ) { +if ((chip->sd_ctl &SD_PUSH_POINT_CTL_MASK ) ==SD_PUSH_POINT_DELAY ) val |=0x10 ; - }if ((chip->sd_ctl &SD_SAMPLE_POINT_CTL_MASK ) ==SD_SAMPLE_POINT_AUTO ) {if (chip->asic_code) {if (CHK_SD_HS (sd_card) ||CHK_MMC_52M (sd_card)) { -if (val &0x10 ) { +if (val &0x10 ) val |=0x04 ; - }else { +else val |=0x08 ; - } } }else { -if (val &0x10 ) { +if (val &0x10 ) val |=0x04 ; - }else { +else val |=0x08 ; - } } }else if ((chip->sd_ctl &SD_SAMPLE_POINT_CTL_MASK ) ==SD_SAMPLE_POINT_DELAY ) { -if (val &0x10 ) { +if (val &0x10 ) val |=0x04 ; - }else { +else val |=0x08 ; - } }RTSX_WRITE_REG (chip,REG_SD_CFG1 ,0x1C , val);
@@ -636,41 +624,41 @@ static void sd_choose_proper_clock(struct rtsx_chip *chip)struct sd_info *sd_card = &(chip->sd_card);if (CHK_SD_SDR104 (sd_card)) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock = chip->asic_sd_sdr104_clk; - }else { +else sd_card->sd_clock = chip->fpga_sd_sdr104_clk; - } + }else if (CHK_SD_DDR50 (sd_card)) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock = chip->asic_sd_ddr50_clk; - }else { +else sd_card->sd_clock = chip->fpga_sd_ddr50_clk; - } + }else if (CHK_SD_SDR50 (sd_card)) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock = chip->asic_sd_sdr50_clk; - }else { +else sd_card->sd_clock = chip->fpga_sd_sdr50_clk; - } + }else if (CHK_SD_HS (sd_card)) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock = chip->asic_sd_hs_clk; - }else { +else sd_card->sd_clock = chip->fpga_sd_hs_clk; - } + }else if (CHK_MMC_52M (sd_card) ||CHK_MMC_DDR52 (sd_card)) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock = chip->asic_mmc_52m_clk; - }else { +else sd_card->sd_clock = chip->fpga_mmc_52m_clk; - } + }else if (CHK_MMC_26M (sd_card)) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock =48 ; - }else { +else sd_card->sd_clock =CLK_50 ; - } + } }
@@ -683,13 +671,12 @@ static int sd_set_clock_divider(struct rtsx_chip *chip, u8 clk_div) val = clk_div; }else { mask =0x60 ; -if (clk_div ==SD_CLK_DIVIDE_0 ) { +if (clk_div ==SD_CLK_DIVIDE_0 ) val =0x00 ; - }else if (clk_div ==SD_CLK_DIVIDE_128 ) { +else if (clk_div ==SD_CLK_DIVIDE_128 ) val =0x40 ; - }else if (clk_div ==SD_CLK_DIVIDE_256 ) { +else if (clk_div ==SD_CLK_DIVIDE_256 ) val =0x20 ; - } }RTSX_WRITE_REG (chip,REG_SD_CFG1 , mask, val);
@@ -703,16 +690,14 @@ static int sd_set_init_para(struct rtsx_chip *chip)int retval; retval =sd_set_sample_push_timing (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }sd_choose_proper_clock (chip); retval =switch_clock (chip, sd_card->sd_clock); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }
@@ -735,9 +720,8 @@ int sd_select_card(struct rtsx_chip *chip, int select) } retval =sd_send_cmd_get_rsp (chip, cmd_idx, addr, cmd_type,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }
@@ -750,21 +734,18 @@ static int sd_update_lock_status(struct rtsx_chip *chip)u8 rsp[5 ]; retval =sd_send_cmd_get_rsp (chip,SEND_STATUS , sd_card->sd_addr,SD_RSP_TYPE_R1 , rsp,5 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } -if (rsp[1 ] &0x02 ) { +if (rsp[1 ] &0x02 ) sd_card->sd_lock_status |=SD_LOCKED ; - }else { +else sd_card->sd_lock_status &= ~SD_LOCKED ; - }RTSX_DEBUGP ("sd_card->sd_lock_status = 0x%x\n" , sd_card->sd_lock_status); -if (rsp[1 ] &0x01 ) { +if (rsp[1 ] &0x01 )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }
@@ -779,13 +760,12 @@ static int sd_wait_state_data_ready(struct rtsx_chip *chip, u8 state, u8 data_refor (i =0 ; i < polling_cnt; i++) { retval =sd_send_cmd_get_rsp (chip,SEND_STATUS , sd_card->sd_addr,SD_RSP_TYPE_R1 , rsp,5 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } -if (((rsp[3 ] &0x1E ) == state) && ((rsp[3 ] &0x01 ) == data_ready)) { +if (((rsp[3 ] &0x1E ) == state) && ((rsp[3 ] &0x01 ) == data_ready))return STATUS_SUCCESS ; - } + }TRACE_RET (chip,STATUS_FAIL );
@@ -798,18 +778,16 @@ static int sd_change_bank_voltage(struct rtsx_chip *chip, u8 voltage)if (voltage ==SD_IO_3V3 ) {if (chip->asic_code) { retval =rtsx_write_phy_register (chip,0x08 ,0x4FC0 | chip->phy_voltage); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } }else {RTSX_WRITE_REG (chip,SD_PAD_CTL ,SD_IO_USING_1V8 ,0 ); } }else if (voltage ==SD_IO_1V8 ) {if (chip->asic_code) { retval =rtsx_write_phy_register (chip,0x08 ,0x4C40 | chip->phy_voltage); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } }else {RTSX_WRITE_REG (chip,SD_PAD_CTL ,SD_IO_USING_1V8 ,SD_IO_USING_1V8 ); }
@@ -828,9 +806,8 @@ static int sd_voltage_switch(struct rtsx_chip *chip)RTSX_WRITE_REG (chip,SD_BUS_STAT ,SD_CLK_TOGGLE_EN |SD_CLK_FORCE_STOP ,SD_CLK_TOGGLE_EN ); retval =sd_send_cmd_get_rsp (chip,VOLTAGE_SWITCH ,0 ,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }udelay (chip->sd_voltage_switch_delay);
@@ -842,9 +819,9 @@ static int sd_voltage_switch(struct rtsx_chip *chip)RTSX_WRITE_REG (chip,SD_BUS_STAT ,0xFF ,SD_CLK_FORCE_STOP ); retval =sd_change_bank_voltage (chip,SD_IO_1V8 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } +wait_timeout (50 );RTSX_WRITE_REG (chip,SD_BUS_STAT ,0xFF ,SD_CLK_TOGGLE_EN );
@@ -893,9 +870,8 @@ static int sd_change_phase(struct rtsx_chip *chip, u8 sample_point, u8 tune_dir)if (tune_dir ==TUNE_RX ) {SD_VP_CTL =SD_VPRX_CTL ;SD_DCMPS_CTL =SD_DCMPS_RX_CTL ; -if (CHK_SD_DDR50 (sd_card)) { +if (CHK_SD_DDR50 (sd_card)) ddr_rx =1 ; - } }else {SD_VP_CTL =SD_VPTX_CTL ;SD_DCMPS_CTL =SD_DCMPS_TX_CTL ;
@@ -932,23 +908,22 @@ static int sd_change_phase(struct rtsx_chip *chip, u8 sample_point, u8 tune_dir)rtsx_add_cmd (chip,WRITE_REG_CMD ,SD_DCMPS_CTL ,DCMPS_CHANGE ,DCMPS_CHANGE );rtsx_add_cmd (chip,CHECK_REG_CMD ,SD_DCMPS_CTL ,DCMPS_CHANGE_DONE ,DCMPS_CHANGE_DONE ); retval =rtsx_send_cmd (chip,SD_CARD ,100 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, Fail); - } val = *rtsx_get_cmd_data (chip); -if (val &DCMPS_ERROR ) { +if (val &DCMPS_ERROR )TRACE_GOTO (chip, Fail); - } -if ((val &DCMPS_CURRENT_PHASE ) != sample_point) { + +if ((val &DCMPS_CURRENT_PHASE ) != sample_point)TRACE_GOTO (chip, Fail); - } +RTSX_WRITE_REG (chip,SD_DCMPS_CTL ,DCMPS_CHANGE ,0 ); -if (ddr_rx) { +if (ddr_rx)RTSX_WRITE_REG (chip,SD_VP_CTL ,PHASE_CHANGE ,0 ); - }else { +else RTSX_WRITE_REG (chip,CLK_CTL ,CHANGE_CLK ,0 ); - } +udelay (50 ); }
@@ -978,9 +953,8 @@ static int sd_check_spec(struct rtsx_chip *chip, u8 bus_width)u8 cmd[5 ], buf[8 ]; retval =sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } cmd[0 ] =0x40 |SEND_SCR ; cmd[1 ] =0 ;
@@ -996,9 +970,8 @@ static int sd_check_spec(struct rtsx_chip *chip, u8 bus_width)memcpy (sd_card->raw_scr, buf,8 ); -if ((buf[0 ] &0x0F ) ==0 ) { +if ((buf[0 ] &0x0F ) ==0 )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }
@@ -1172,13 +1145,12 @@ static int sd_check_switch_mode(struct rtsx_chip *chip, u8 mode,*/ u16 cc = ((u16 )buf[0 ] <<8 ) | buf[1 ];RTSX_DEBUGP ("Maximum current consumption: %dmA\n" , cc); -if ((cc ==0 ) || (cc >800 )) { +if ((cc ==0 ) || (cc >800 ))TRACE_RET (chip,STATUS_FAIL ); - } + retval =sd_query_switch_result (chip, func_group, func_to_switch, buf,64 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if ((cc >400 ) || (func_to_switch >CURRENT_LIMIT_400 )) {RTSX_WRITE_REG (chip,OCPPARA2 ,SD_OCP_THD_MASK , chip->sd_800mA_ocp_thd);
@@ -1192,13 +1164,13 @@ static int sd_check_switch_mode(struct rtsx_chip *chip, u8 mode,static u8 downgrade_switch_mode (u8 func_group,u8 func_to_switch) {if (func_group ==SD_FUNC_GROUP_1 ) { -if (func_to_switch >HS_SUPPORT ) { +if (func_to_switch >HS_SUPPORT ) func_to_switch--; - } + }else if (func_group ==SD_FUNC_GROUP_4 ) { -if (func_to_switch >CURRENT_LIMIT_200 ) { +if (func_to_switch >CURRENT_LIMIT_200 ) func_to_switch--; - } + }return func_to_switch;
@@ -1241,9 +1213,8 @@ static int sd_check_switch(struct rtsx_chip *chip,wait_timeout (20 ); } -if (!switch_good) { +if (!switch_good)TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }
@@ -1258,9 +1229,8 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width)/* Get supported functions */ retval =sd_check_switch_mode (chip,SD_CHECK_MODE ,NO_ARGUMENT ,NO_ARGUMENT , bus_width); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } sd_card->func_group1_mask &= ~(sd_card->sd_switch_fail);
@@ -1289,9 +1259,9 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width)break ;case HS_SUPPORT : -if (sd_card->func_group1_mask &HS_SUPPORT_MASK ) { +if (sd_card->func_group1_mask &HS_SUPPORT_MASK ) func_to_switch =HS_SUPPORT ; - } +break ;default :
@@ -1299,9 +1269,9 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width) } -if (func_to_switch) { +if (func_to_switch)break ; - } + }RTSX_DEBUGP ("SD_FUNC_GROUP_1: func_to_switch = 0x%02x" , func_to_switch);
@@ -1330,23 +1300,22 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width)TRACE_RET (chip,STATUS_FAIL ); } -if (func_to_switch ==SDR104_SUPPORT ) { +if (func_to_switch ==SDR104_SUPPORT )SET_SD_SDR104 (sd_card); - }else if (func_to_switch ==DDR50_SUPPORT ) { +else if (func_to_switch ==DDR50_SUPPORT )SET_SD_DDR50 (sd_card); - }else if (func_to_switch ==SDR50_SUPPORT ) { +else if (func_to_switch ==SDR50_SUPPORT )SET_SD_SDR50 (sd_card); - }else { +else SET_SD_HS (sd_card); - } + }if (CHK_SD_DDR50 (sd_card)) {RTSX_WRITE_REG (chip,SD_PUSH_POINT_CTL ,0x06 ,0x04 ); retval =sd_set_sample_push_timing (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } }if (!func_to_switch || (func_to_switch ==HS_SUPPORT )) {
@@ -1362,36 +1331,36 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width)for (i =0 ; i <4 ; i++) {switch ((u8)(chip->sd_current_prior >> (i*8 ))) {case CURRENT_LIMIT_800 : -if (sd_card->func_group4_mask &CURRENT_LIMIT_800_MASK ) { +if (sd_card->func_group4_mask &CURRENT_LIMIT_800_MASK ) func_to_switch =CURRENT_LIMIT_800 ; - } +break ;case CURRENT_LIMIT_600 : -if (sd_card->func_group4_mask &CURRENT_LIMIT_600_MASK ) { +if (sd_card->func_group4_mask &CURRENT_LIMIT_600_MASK ) func_to_switch =CURRENT_LIMIT_600 ; - } +break ;case CURRENT_LIMIT_400 : -if (sd_card->func_group4_mask &CURRENT_LIMIT_400_MASK ) { +if (sd_card->func_group4_mask &CURRENT_LIMIT_400_MASK ) func_to_switch =CURRENT_LIMIT_400 ; - } +break ;case CURRENT_LIMIT_200 : -if (sd_card->func_group4_mask &CURRENT_LIMIT_200_MASK ) { +if (sd_card->func_group4_mask &CURRENT_LIMIT_200_MASK ) func_to_switch =CURRENT_LIMIT_200 ; - } +break ;default :continue ; } -if (func_to_switch !=0xFF ) { +if (func_to_switch !=0xFF )break ; - } + }RTSX_DEBUGP ("SD_FUNC_GROUP_4: func_to_switch = 0x%02x" , func_to_switch);
@@ -1399,16 +1368,15 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width)if (func_to_switch <=CURRENT_LIMIT_800 ) { retval =sd_check_switch (chip,SD_FUNC_GROUP_4 , func_to_switch, bus_width);if (retval !=STATUS_SUCCESS ) { -if (sd_check_err_code (chip,SD_NO_CARD )) { +if (sd_check_err_code (chip,SD_NO_CARD ))TRACE_RET (chip,STATUS_FAIL ); - } + }RTSX_DEBUGP ("Switch current limit finished! (%d)\n" , retval); } -if (CHK_SD_DDR50 (sd_card)) { +if (CHK_SD_DDR50 (sd_card))RTSX_WRITE_REG (chip,SD_PUSH_POINT_CTL ,0x06 ,0 ); - }return STATUS_SUCCESS ; }
@@ -1438,9 +1406,8 @@ static int sd_sdr_tuning_rx_cmd(struct rtsx_chip *chip, u8 sample_point)u8 cmd[5 ]; retval =sd_change_phase (chip, sample_point,TUNE_RX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } cmd[0 ] =0x40 |SEND_TUNING_PATTERN ; cmd[1 ] =0 ;
@@ -1467,16 +1434,14 @@ static int sd_ddr_tuning_rx_cmd(struct rtsx_chip *chip, u8 sample_point)u8 cmd[5 ]; retval =sd_change_phase (chip, sample_point,TUNE_RX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }RTSX_DEBUGP ("sd ddr tuning rx\n" ); retval =sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } cmd[0 ] =0x40 |SD_STATUS ; cmd[1 ] =0 ;
@@ -1502,18 +1467,16 @@ static int mmc_ddr_tunning_rx_cmd(struct rtsx_chip *chip, u8 sample_point)int retval;u8 cmd[5 ], bus_width; -if (CHK_MMC_8BIT (sd_card)) { +if (CHK_MMC_8BIT (sd_card)) bus_width =SD_BUS_WIDTH_8 ; - }else if (CHK_MMC_4BIT (sd_card)) { +else if (CHK_MMC_4BIT (sd_card)) bus_width =SD_BUS_WIDTH_4 ; - }else { +else bus_width =SD_BUS_WIDTH_1 ; - } retval =sd_change_phase (chip, sample_point,TUNE_RX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }RTSX_DEBUGP ("mmc ddr tuning rx\n" );
@@ -1541,9 +1504,8 @@ static int sd_sdr_tuning_tx_cmd(struct rtsx_chip *chip, u8 sample_point)int retval; retval =sd_change_phase (chip, sample_point,TUNE_TX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }RTSX_WRITE_REG (chip,SD_CFG3 ,SD_RSP_80CLK_TIMEOUT_EN ,SD_RSP_80CLK_TIMEOUT_EN );
@@ -1568,26 +1530,23 @@ static int sd_ddr_tuning_tx_cmd(struct rtsx_chip *chip, u8 sample_point)u8 cmd[5 ], bus_width; retval =sd_change_phase (chip, sample_point,TUNE_TX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (CHK_SD (sd_card)) { bus_width =SD_BUS_WIDTH_4 ; }else { -if (CHK_MMC_8BIT (sd_card)) { +if (CHK_MMC_8BIT (sd_card)) bus_width =SD_BUS_WIDTH_8 ; - }else if (CHK_MMC_4BIT (sd_card)) { +else if (CHK_MMC_4BIT (sd_card)) bus_width =SD_BUS_WIDTH_4 ; - }else { +else bus_width =SD_BUS_WIDTH_1 ; - } } retval =sd_wait_state_data_ready (chip,0x08 ,1 ,1000 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }RTSX_WRITE_REG (chip,SD_CFG3 ,SD_RSP_80CLK_TIMEOUT_EN ,SD_RSP_80CLK_TIMEOUT_EN );
@@ -1621,11 +1580,10 @@ static u8 sd_search_final_phase(struct rtsx_chip *chip, u32 phase_map, u8 tune_du8 final_phase =0xFF ;if (phase_map ==0xFFFFFFFF ) { -if (tune_dir ==TUNE_RX ) { +if (tune_dir ==TUNE_RX ) final_phase = (u8 )chip->sd_default_rx_phase; - }else { +else final_phase = (u8 )chip->sd_default_tx_phase; - } goto Search_Finish; }
@@ -1666,9 +1624,9 @@ static u8 sd_search_final_phase(struct rtsx_chip *chip, u32 phase_map, u8 tune_d path[0 ].start = path[cont_path_cnt -1 ].start -MAX_PHASE -1 ; path[0 ].len += path[cont_path_cnt -1 ].len; path[0 ].mid = path[0 ].start + path[0 ].len /2 ; -if (path[0 ].mid <0 ) { +if (path[0 ].mid <0 ) path[0 ].mid +=MAX_PHASE +1 ; - } + cont_path_cnt--; }
@@ -1696,11 +1654,11 @@ static u8 sd_search_final_phase(struct rtsx_chip *chip, u32 phase_map, u8 tune_dint temp_final_phase = path[final_path_idx].end - (max_len - (6 + temp_mid)); -if (temp_final_phase <0 ) { +if (temp_final_phase <0 ) final_phase = (u8)(temp_final_phase +MAX_PHASE +1 ); - }else { +else final_phase = (u8 )temp_final_phase; - } + } }else if (CHK_SD_SDR50 (sd_card)) {if (max_len >12 ) {
@@ -1708,11 +1666,11 @@ static u8 sd_search_final_phase(struct rtsx_chip *chip, u32 phase_map, u8 tune_dint temp_final_phase = path[final_path_idx].end - (max_len - (3 + temp_mid)); -if (temp_final_phase <0 ) { +if (temp_final_phase <0 ) final_phase = (u8)(temp_final_phase +MAX_PHASE +1 ); - }else { +else final_phase = (u8 )temp_final_phase; - } + } } }
@@ -1732,17 +1690,17 @@ static int sd_tuning_rx(struct rtsx_chip *chip)int (*tuning_cmd)(struct rtsx_chip *chip,u8 sample_point);if (CHK_SD (sd_card)) { -if (CHK_SD_DDR50 (sd_card)) { +if (CHK_SD_DDR50 (sd_card)) tuning_cmd = sd_ddr_tuning_rx_cmd; - }else { +else tuning_cmd = sd_sdr_tuning_rx_cmd; - } + }else { -if (CHK_MMC_DDR52 (sd_card)) { +if (CHK_MMC_DDR52 (sd_card)) tuning_cmd = mmc_ddr_tunning_rx_cmd; - }else { +else TRACE_RET (chip,STATUS_FAIL ); - } + }for (i =0 ; i <3 ; i++) {
@@ -1754,27 +1712,25 @@ static int sd_tuning_rx(struct rtsx_chip *chip) } retval =tuning_cmd (chip, (u8 )j); -if (retval ==STATUS_SUCCESS ) { +if (retval ==STATUS_SUCCESS ) raw_phase_map[i] |=1 << j; - } + } } phase_map = raw_phase_map[0 ] & raw_phase_map[1 ] & raw_phase_map[2 ]; -for (i =0 ; i <3 ; i++) { +for (i =0 ; i <3 ; i++)RTSX_DEBUGP ("RX raw_phase_map[%d] = 0x%08x\n" , i, raw_phase_map[i]); - } +RTSX_DEBUGP ("RX phase_map = 0x%08x\n" , phase_map); final_phase =sd_search_final_phase (chip, phase_map,TUNE_RX ); -if (final_phase ==0xFF ) { +if (final_phase ==0xFF )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_change_phase (chip, final_phase,TUNE_RX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }
@@ -1799,15 +1755,14 @@ static int sd_ddr_pre_tuning_tx(struct rtsx_chip *chip) } retval =sd_change_phase (chip, (u8 )i,TUNE_TX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )continue ; - } retval =sd_send_cmd_get_rsp (chip,SEND_STATUS , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ); -if ((retval ==STATUS_SUCCESS ) || !sd_check_err_code (chip,SD_RSP_TIMEOUT )) { +if ((retval ==STATUS_SUCCESS ) || !sd_check_err_code (chip,SD_RSP_TIMEOUT )) phase_map |=1 << i; - } + }RTSX_WRITE_REG (chip,SD_CFG3 ,SD_RSP_80CLK_TIMEOUT_EN ,0 );
@@ -1815,14 +1770,12 @@ static int sd_ddr_pre_tuning_tx(struct rtsx_chip *chip)RTSX_DEBUGP ("DDR TX pre tune phase_map = 0x%08x\n" , phase_map); final_phase =sd_search_final_phase (chip, phase_map,TUNE_TX ); -if (final_phase ==0xFF ) { +if (final_phase ==0xFF )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_change_phase (chip, final_phase,TUNE_TX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }RTSX_DEBUGP ("DDR TX pre tune phase: %d\n" , (int )final_phase);
@@ -1839,17 +1792,17 @@ static int sd_tuning_tx(struct rtsx_chip *chip)int (*tuning_cmd)(struct rtsx_chip *chip,u8 sample_point);if (CHK_SD (sd_card)) { -if (CHK_SD_DDR50 (sd_card)) { +if (CHK_SD_DDR50 (sd_card)) tuning_cmd = sd_ddr_tuning_tx_cmd; - }else { +else tuning_cmd = sd_sdr_tuning_tx_cmd; - } + }else { -if (CHK_MMC_DDR52 (sd_card)) { +if (CHK_MMC_DDR52 (sd_card)) tuning_cmd = sd_ddr_tuning_tx_cmd; - }else { +else TRACE_RET (chip,STATUS_FAIL ); - } + }for (i =0 ; i <3 ; i++) {
@@ -1863,27 +1816,25 @@ static int sd_tuning_tx(struct rtsx_chip *chip) } retval =tuning_cmd (chip, (u8 )j); -if (retval ==STATUS_SUCCESS ) { +if (retval ==STATUS_SUCCESS ) raw_phase_map[i] |=1 << j; - } + } } phase_map = raw_phase_map[0 ] & raw_phase_map[1 ] & raw_phase_map[2 ]; -for (i =0 ; i <3 ; i++) { +for (i =0 ; i <3 ; i++)RTSX_DEBUGP ("TX raw_phase_map[%d] = 0x%08x\n" , i, raw_phase_map[i]); - } +RTSX_DEBUGP ("TX phase_map = 0x%08x\n" , phase_map); final_phase =sd_search_final_phase (chip, phase_map,TUNE_TX ); -if (final_phase ==0xFF ) { +if (final_phase ==0xFF )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_change_phase (chip, final_phase,TUNE_TX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }
@@ -1893,14 +1844,12 @@ static int sd_sdr_tuning(struct rtsx_chip *chip)int retval; retval =sd_tuning_tx (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_tuning_rx (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }
@@ -1911,26 +1860,25 @@ static int sd_ddr_tuning(struct rtsx_chip *chip)if (!(chip->sd_ctl &SD_DDR_TX_PHASE_SET_BY_USER )) { retval =sd_ddr_pre_tuning_tx (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + }else { retval =sd_change_phase (chip, (u8 )chip->sd_ddr_tx_phase,TUNE_TX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + } retval =sd_tuning_rx (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (!(chip->sd_ctl &SD_DDR_TX_PHASE_SET_BY_USER )) { retval =sd_tuning_tx (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + }return STATUS_SUCCESS ;
@@ -1942,26 +1890,25 @@ static int mmc_ddr_tuning(struct rtsx_chip *chip)if (!(chip->sd_ctl &MMC_DDR_TX_PHASE_SET_BY_USER )) { retval =sd_ddr_pre_tuning_tx (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + }else { retval =sd_change_phase (chip, (u8 )chip->mmc_ddr_tx_phase,TUNE_TX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + } retval =sd_tuning_rx (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (!(chip->sd_ctl &MMC_DDR_TX_PHASE_SET_BY_USER )) { retval =sd_tuning_tx (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + }return STATUS_SUCCESS ;
@@ -1974,9 +1921,8 @@ int sd_switch_clock(struct rtsx_chip *chip)int re_tuning =0 ; retval =select_card (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (CHECK_PID (chip,0x5209 ) && (CHK_SD30_SPEED (sd_card) ||CHK_MMC_DDR52 (sd_card))) {
@@ -1987,26 +1933,25 @@ int sd_switch_clock(struct rtsx_chip *chip) } retval =switch_clock (chip, sd_card->sd_clock); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (re_tuning) {if (CHK_SD (sd_card)) { -if (CHK_SD_DDR50 (sd_card)) { +if (CHK_SD_DDR50 (sd_card)) retval =sd_ddr_tuning (chip); - }else { +else retval =sd_sdr_tuning (chip); - } + }else { -if (CHK_MMC_DDR52 (sd_card)) { +if (CHK_MMC_DDR52 (sd_card)) retval =mmc_ddr_tuning (chip); - } + } -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + }return STATUS_SUCCESS ;
@@ -2017,11 +1962,10 @@ static int sd_prepare_reset(struct rtsx_chip *chip)struct sd_info *sd_card = &(chip->sd_card);int retval; -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock =29 ; - }else { +else sd_card->sd_clock =CLK_30 ; - } sd_card->sd_type =0 ; sd_card->seq_mode =0 ;
@@ -2037,9 +1981,8 @@ static int sd_prepare_reset(struct rtsx_chip *chip) chip->sd_io =0 ; retval =sd_set_init_para (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip, retval); - }if (CHECK_PID (chip,0x5209 )) { RTSX_WRITE_REG(chip, REG_SD_CFG1, 0xFF,
@@ -2053,9 +1996,8 @@ static int sd_prepare_reset(struct rtsx_chip *chip)RTSX_WRITE_REG (chip,CARD_STOP ,SD_STOP |SD_CLR_ERR ,SD_STOP |SD_CLR_ERR ); retval =select_card (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }
@@ -2122,9 +2064,8 @@ int sd_pull_ctl_enable(struct rtsx_chip *chip) } retval =rtsx_send_cmd (chip,SD_CARD ,100 ); -if (retval <0 ) { +if (retval <0 )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }
@@ -2133,42 +2074,38 @@ static int sd_init_power(struct rtsx_chip *chip) {int retval; -if (CHECK_PID (chip,0x5209 )) { +if (CHECK_PID (chip,0x5209 ))RTSX_WRITE_REG (chip,PWR_GATE_CTRL ,LDO3318_PWR_MASK ,LDO_OFF ); - } retval =sd_power_off_card3v3 (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } -if (!chip->ft2_fast_mode) { +if (!chip->ft2_fast_mode)wait_timeout (250 ); - } retval =enable_card_clock (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (chip->asic_code) { retval =sd_pull_ctl_enable (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + }else {RTSX_WRITE_REG (chip,FPGA_PULL_CTL ,FPGA_SD_PULL_CTL_BIT |0x20 ,0 ); }if (chip->ft2_fast_mode) { -if (CHECK_PID (chip,0x5209 )) { +if (CHECK_PID (chip,0x5209 ))RTSX_WRITE_REG (chip,PWR_GATE_CTRL ,LDO3318_PWR_MASK ,LDO_ON ); - } + }else { retval =card_power_on (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } +wait_timeout (260 );#ifdef SUPPORT_OCP
@@ -2214,13 +2151,13 @@ static int sd_read_lba0(struct rtsx_chip *chip)if (CHK_SD (sd_card)) { bus_width =SD_BUS_WIDTH_4 ; }else { -if (CHK_MMC_8BIT (sd_card)) { +if (CHK_MMC_8BIT (sd_card)) bus_width =SD_BUS_WIDTH_8 ; - }else if (CHK_MMC_4BIT (sd_card)) { +else if (CHK_MMC_4BIT (sd_card)) bus_width =SD_BUS_WIDTH_4 ; - }else { +else bus_width =SD_BUS_WIDTH_1 ; - } + } retval = sd_read_data(chip, SD_TM_NORMAL_READ, cmd,
@@ -2243,9 +2180,8 @@ static int sd_check_wp_state(struct rtsx_chip *chip) retval =sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } cmd[0 ] =0x40 |SD_STATUS ; cmd[1 ] =0 ;
@@ -2273,9 +2209,8 @@ static int sd_check_wp_state(struct rtsx_chip *chip)/* Check SD Machanical Write-Protect Switch */ val =rtsx_readl (chip,RTSX_BIPR ); -if (val &SD_WRITE_PROTECT ) { +if (val &SD_WRITE_PROTECT ) chip->card_wp |=SD_CARD ; - }return STATUS_SUCCESS ; }
@@ -2307,14 +2242,12 @@ Switch_Fail:#endif retval =sd_prepare_reset (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_dummy_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (CHK_SDIO_EXIST (chip) && !CHK_SDIO_IGNORED (chip) && try_sdio) {int rty_cnt =0 ;
@@ -2348,9 +2281,8 @@ Switch_Fail:/* Start Initialization Process of SD Card */ RTY_SD_RST: retval =sd_send_cmd_get_rsp (chip,GO_IDLE_STATE ,0 ,SD_RSP_TYPE_R0 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }wait_timeout (20 );
@@ -2377,9 +2309,8 @@ RTY_SD_RST: voltage =SUPPORT_VOLTAGE ; retval =sd_send_cmd_get_rsp (chip,GO_IDLE_STATE ,0 ,SD_RSP_TYPE_R0 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }wait_timeout (20 ); }
@@ -2393,42 +2324,41 @@ RTY_SD_RST: } j++; -if (j <3 ) { +if (j <3 ) goto RTY_SD_RST; - }else { +else TRACE_RET (chip,STATUS_FAIL ); - } + } retval =sd_send_cmd_get_rsp (chip,SD_APP_OP_COND , voltage,SD_RSP_TYPE_R3 , rsp,5 );if (retval !=STATUS_SUCCESS ) { k++; -if (k <3 ) { +if (k <3 ) goto RTY_SD_RST; - }else { +else TRACE_RET (chip,STATUS_FAIL ); - } + } i++;wait_timeout (20 ); }while (!(rsp[1 ] &0x80 ) && (i <255 )); -if (i ==255 ) { +if (i ==255 )TRACE_RET (chip,STATUS_FAIL ); - }if (hi_cap_flow) { -if (rsp[1 ] &0x40 ) { +if (rsp[1 ] &0x40 )SET_SD_HCXC (sd_card); - }else { +else CLR_SD_HCXC (sd_card); - } -if (CHECK_PID (chip,0x5209 ) &&CHK_SD_HCXC (sd_card) && !sd20_mode) { + +if (CHECK_PID (chip,0x5209 ) &&CHK_SD_HCXC (sd_card) && !sd20_mode) support_1v8 = (rsp[1 ] &0x01 ) ?1 :0 ; - }else { +else support_1v8 =0 ; - } + }else {CLR_SD_HCXC (sd_card); support_1v8 =0 ;
@@ -2437,46 +2367,40 @@ RTY_SD_RST:if (support_1v8) { retval =sd_voltage_switch (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } } retval =sd_send_cmd_get_rsp (chip,ALL_SEND_CID ,0 ,SD_RSP_TYPE_R2 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }for (i =0 ; i <3 ; i++) { retval =sd_send_cmd_get_rsp (chip,SEND_RELATIVE_ADDR ,0 ,SD_RSP_TYPE_R6 , rsp,5 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } sd_card->sd_addr = (u32 )rsp[1 ] <<24 ; sd_card->sd_addr += (u32 )rsp[2 ] <<16 ; -if (sd_card->sd_addr) { +if (sd_card->sd_addr)break ; - } + } retval =sd_check_csd (chip,1 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_select_card (chip,1 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }#ifdef SUPPORT_SD_LOCK SD_UNLOCK_ENTRY: retval =sd_update_lock_status (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (sd_card->sd_lock_status &SD_LOCKED ) { sd_card->sd_lock_status |= (SD_LOCK_1BIT_MODE |SD_PWD_EXIST );
@@ -2487,23 +2411,21 @@ SD_UNLOCK_ENTRY:#endif retval =sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + retval =sd_send_cmd_get_rsp (chip,SET_CLR_CARD_DETECT ,0 ,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (support_1v8) { retval =sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + retval =sd_send_cmd_get_rsp (chip,SET_BUS_WIDTH ,2 ,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } switch_bus_width =SD_BUS_WIDTH_4 ; }else {
@@ -2511,14 +2433,12 @@ SD_UNLOCK_ENTRY: } retval =sd_send_cmd_get_rsp (chip,SET_BLOCKLEN ,0x200 ,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_set_clock_divider (chip,SD_CLK_DIVIDE_0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (!(sd_card->raw_csd[4 ] &0x40 )) sd_dont_switch =1 ;
@@ -2537,9 +2457,9 @@ SD_UNLOCK_ENTRY:if (retval ==STATUS_SUCCESS ) { retval =sd_switch_function (chip, switch_bus_width);if (retval !=STATUS_SUCCESS ) { -if (CHECK_PID (chip,0x5209 )) { +if (CHECK_PID (chip,0x5209 ))sd_change_bank_voltage (chip,SD_IO_3V3 ); - } +sd_init_power (chip); sd_dont_switch =1 ; try_sdio =0 ;
@@ -2548,9 +2468,9 @@ SD_UNLOCK_ENTRY: } }else {if (support_1v8) { -if (CHECK_PID (chip,0x5209 )) { +if (CHECK_PID (chip,0x5209 ))sd_change_bank_voltage (chip,SD_IO_3V3 ); - } +sd_init_power (chip); sd_dont_switch =1 ; try_sdio =0 ;
@@ -2562,13 +2482,13 @@ SD_UNLOCK_ENTRY:if (!support_1v8) { retval =sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + retval =sd_send_cmd_get_rsp (chip,SET_BUS_WIDTH ,2 ,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + }#ifdef SUPPORT_SD_LOCK
@@ -2581,24 +2501,22 @@ SD_UNLOCK_ENTRY:RTSX_WRITE_REG (chip,SD30_DRIVE_SEL ,0x07 , chip->sd30_drive_sel_1v8); retval =sd_set_init_para (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } -if (CHK_SD_DDR50 (sd_card)) { +if (CHK_SD_DDR50 (sd_card)) retval =sd_ddr_tuning (chip); - }else { +else retval =sd_sdr_tuning (chip); - }if (retval !=STATUS_SUCCESS ) {if (sd20_mode) {TRACE_RET (chip,STATUS_FAIL ); }else { retval =sd_init_power (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + try_sdio =0 ; sd20_mode =1 ; goto Switch_Fail;
@@ -2609,9 +2527,9 @@ SD_UNLOCK_ENTRY:if (CHK_SD_DDR50 (sd_card)) { retval =sd_wait_state_data_ready (chip,0x08 ,1 ,1000 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS ) read_lba0 =0 ; - } + }if (read_lba0) {
@@ -2621,9 +2539,9 @@ SD_UNLOCK_ENTRY:TRACE_RET (chip,STATUS_FAIL ); }else { retval =sd_init_power (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + try_sdio =0 ; sd20_mode =1 ; goto Switch_Fail;
@@ -2633,9 +2551,8 @@ SD_UNLOCK_ENTRY: } retval =sd_check_wp_state (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } chip->card_bus_width[chip->card2lun[SD_CARD ]] =4 ;
@@ -2659,9 +2576,8 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width)int len; retval =sd_send_cmd_get_rsp (chip,BUSTEST_W ,0 ,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,SWITCH_FAIL ); - }if (width ==MMC_8BIT_BUS ) { buf[0 ] =0x55 ;
@@ -2690,9 +2606,9 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width)rtsx_read_register (chip,REG_SD_STAT1 , &val1);rtsx_read_register (chip,REG_SD_STAT2 , &val2);rtsx_clear_sd_error (chip); -if ((val1 &0xE0 ) || val2) { +if ((val1 &0xE0 ) || val2)TRACE_RET (chip,SWITCH_ERR ); - } + }else {rtsx_clear_sd_error (chip);rtsx_write_register (chip,REG_SD_CFG3 ,0x02 ,0 );
@@ -2712,11 +2628,10 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width)rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CMD0 ,0xFF ,0x40 |BUSTEST_R ); -if (width ==MMC_8BIT_BUS ) { +if (width ==MMC_8BIT_BUS )rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_BYTE_CNT_L ,0xFF ,0x08 ); - }else { +else rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_BYTE_CNT_L ,0xFF ,0x04 ); - }rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_BLOCK_CNT_L ,0xFF ,1 );rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_BLOCK_CNT_H ,0xFF ,0 );
@@ -2729,15 +2644,13 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width)rtsx_add_cmd (chip,CHECK_REG_CMD ,REG_SD_TRANSFER ,SD_TRANSFER_END ,SD_TRANSFER_END );rtsx_add_cmd (chip,READ_REG_CMD ,PPBUF_BASE2 ,0 ,0 ); -if (width ==MMC_8BIT_BUS ) { +if (width ==MMC_8BIT_BUS )rtsx_add_cmd (chip,READ_REG_CMD ,PPBUF_BASE2 +1 ,0 ,0 ); - } retval =rtsx_send_cmd (chip,SD_CARD ,100 ); -if (retval <0 ) { +if (retval <0 )rtsx_clear_sd_error (chip);TRACE_RET (chip,SWITCH_ERR ); - } ptr =rtsx_get_cmd_data (chip) +1 ;
@@ -2747,15 +2660,15 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width)u8 rsp[5 ];u32 arg; -if (CHK_MMC_DDR52 (sd_card)) { +if (CHK_MMC_DDR52 (sd_card)) arg =0x03B70600 ; - }else { +else arg =0x03B70200 ; - } + retval =sd_send_cmd_get_rsp (chip,SWITCH , arg, SD_RSP_TYPE_R1b, rsp,5 ); -if ((retval ==STATUS_SUCCESS ) && !(rsp[4 ] &MMC_SWITCH_ERR )) { +if ((retval ==STATUS_SUCCESS ) && !(rsp[4 ] &MMC_SWITCH_ERR ))return SWITCH_SUCCESS ; - } + } }else {RTSX_DEBUGP ("BUSTEST_R [4bits]: 0x%02x\n" , ptr[0 ]);
@@ -2763,15 +2676,15 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width)u8 rsp[5 ];u32 arg; -if (CHK_MMC_DDR52 (sd_card)) { +if (CHK_MMC_DDR52 (sd_card)) arg =0x03B70500 ; - }else { +else arg =0x03B70100 ; - } + retval =sd_send_cmd_get_rsp (chip,SWITCH , arg, SD_RSP_TYPE_R1b, rsp,5 ); -if ((retval ==STATUS_SUCCESS ) && !(rsp[4 ] &MMC_SWITCH_ERR )) { +if ((retval ==STATUS_SUCCESS ) && !(rsp[4 ] &MMC_SWITCH_ERR ))return SWITCH_SUCCESS ; - } + } }
@@ -2845,11 +2758,10 @@ static int mmc_switch_timing_bus(struct rtsx_chip *chip, int switch_ddr) card_type_mask = 0x03; }#else -if (chip->sd_ctl &SUPPORT_MMC_DDR_MODE ) { +if (chip->sd_ctl &SUPPORT_MMC_DDR_MODE ) card_type_mask =0x07 ; - }else { +else card_type_mask =0x03 ; - }#endif }else { card_type_mask =0x03 ;
@@ -2859,11 +2771,11 @@ static int mmc_switch_timing_bus(struct rtsx_chip *chip, int switch_ddr)u8 rsp[5 ];if (card_type &0x04 ) { -if (switch_ddr) { +if (switch_ddr)SET_MMC_DDR52 (sd_card); - }else { +else SET_MMC_52M (sd_card); - } + }else if (card_type &0x02 ) {SET_MMC_52M (sd_card); }else {
@@ -2872,16 +2784,15 @@ static int mmc_switch_timing_bus(struct rtsx_chip *chip, int switch_ddr) retval =sd_send_cmd_get_rsp (chip,SWITCH ,0x03B90100 , SD_RSP_TYPE_R1b, rsp,5 ); -if ((retval !=STATUS_SUCCESS ) || (rsp[4 ] &MMC_SWITCH_ERR )) { +if ((retval !=STATUS_SUCCESS ) || (rsp[4 ] &MMC_SWITCH_ERR ))CLR_MMC_HS (sd_card); - } + }sd_choose_proper_clock (chip); retval =switch_clock (chip, sd_card->sd_clock); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }/* Test Bus Procedure */ retval =mmc_test_switch_bus (chip,MMC_8BIT_BUS );
@@ -2929,17 +2840,15 @@ static int reset_mmc(struct rtsx_chip *chip) Switch_Fail: retval =sd_prepare_reset (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip, retval); - }SET_MMC (sd_card); RTY_MMC_RST: retval =sd_send_cmd_get_rsp (chip,GO_IDLE_STATE ,0 ,SD_RSP_TYPE_R0 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { -TRACE_RET (chip,STATUS_FAIL ); - } +if (retval !=STATUS_SUCCESS ) +TRACE_RET (chip,STATUS_FAIL ); do { if (detect_card_cd(chip, SD_CARD) != STATUS_SUCCESS) {
@@ -2973,56 +2882,47 @@ RTY_MMC_RST: i++; }while (!(rsp[1 ] &0x80 ) && (i <255 )); -if (i ==255 ) { +if (i ==255 )TRACE_RET (chip,STATUS_FAIL ); - } -if ((rsp[1 ] &0x60 ) ==0x40 ) { +if ((rsp[1 ] &0x60 ) ==0x40 )SET_MMC_SECTOR_MODE (sd_card); - }else { +else CLR_MMC_SECTOR_MODE (sd_card); - } retval =sd_send_cmd_get_rsp (chip,ALL_SEND_CID ,0 ,SD_RSP_TYPE_R2 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } sd_card->sd_addr =0x00100000 ; retval =sd_send_cmd_get_rsp (chip,SET_RELATIVE_ADDR , sd_card->sd_addr,SD_RSP_TYPE_R6 , rsp,5 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_check_csd (chip,1 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } spec_ver = (sd_card->raw_csd[0 ] &0x3C ) >>2 ; retval =sd_select_card (chip,1 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_send_cmd_get_rsp (chip,SET_BLOCKLEN ,0x200 ,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }#ifdef SUPPORT_SD_LOCK MMC_UNLOCK_ENTRY: retval =sd_update_lock_status (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }#endif retval =sd_set_clock_divider (chip,SD_CLK_DIVIDE_0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } chip->card_bus_width[chip->card2lun[SD_CARD ]] =1 ;
@@ -3039,22 +2939,20 @@ MMC_UNLOCK_ENTRY: } } -if (CHK_MMC_SECTOR_MODE (sd_card) && (sd_card->capacity ==0 )) { +if (CHK_MMC_SECTOR_MODE (sd_card) && (sd_card->capacity ==0 ))TRACE_RET (chip,STATUS_FAIL ); - }if (switch_ddr &&CHK_MMC_DDR52 (sd_card)) { retval =sd_set_init_para (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =mmc_ddr_tuning (chip);if (retval !=STATUS_SUCCESS ) { retval =sd_init_power (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + switch_ddr =0 ;TRACE_GOTO (chip, Switch_Fail); }
@@ -3064,9 +2962,9 @@ MMC_UNLOCK_ENTRY: retval =sd_read_lba0 (chip);if (retval !=STATUS_SUCCESS ) { retval =sd_init_power (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + switch_ddr =0 ;TRACE_GOTO (chip, Switch_Fail); }
@@ -3082,9 +2980,8 @@ MMC_UNLOCK_ENTRY:#endif temp =rtsx_readl (chip,RTSX_BIPR ); -if (temp &SD_WRITE_PROTECT ) { +if (temp &SD_WRITE_PROTECT ) chip->card_wp |=SD_CARD ; - }return STATUS_SUCCESS ; }
@@ -3100,36 +2997,33 @@ int reset_sd_card(struct rtsx_chip *chip) chip->capacity[chip->card2lun[SD_CARD ]] =0 ; retval =enable_card_clock (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (chip->ignore_sd &&CHK_SDIO_EXIST (chip) && !CHK_SDIO_IGNORED (chip)) {if (chip->asic_code) { retval =sd_pull_ctl_enable (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + }else { retval =rtsx_write_register (chip,FPGA_PULL_CTL ,FPGA_SD_PULL_CTL_BIT |0x20 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + } retval =card_share_mode (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } chip->sd_io =1 ;TRACE_RET (chip,STATUS_FAIL ); } retval =sd_init_power (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (chip->sd_ctl &RESET_MMC_FIRST ) { retval =reset_mmc (chip);
@@ -3168,18 +3062,17 @@ int reset_sd_card(struct rtsx_chip *chip) } retval =sd_set_clock_divider (chip,SD_CLK_DIVIDE_0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } +RTSX_WRITE_REG (chip,REG_SD_BYTE_CNT_L ,0xFF ,0 );RTSX_WRITE_REG (chip,REG_SD_BYTE_CNT_H ,0xFF ,2 ); chip->capacity[chip->card2lun[SD_CARD ]] = sd_card->capacity; retval =sd_set_init_para (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }RTSX_DEBUGP ("sd_card->sd_type = 0x%x\n" , sd_card->sd_type);
@@ -3205,33 +3098,29 @@ static int reset_mmc_only(struct rtsx_chip *chip) chip->capacity[chip->card2lun[SD_CARD ]] = sd_card->capacity =0 ; retval =enable_card_clock (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_init_power (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =reset_mmc (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_set_clock_divider (chip,SD_CLK_DIVIDE_0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } +RTSX_WRITE_REG (chip,REG_SD_BYTE_CNT_L ,0xFF ,0 );RTSX_WRITE_REG (chip,REG_SD_BYTE_CNT_H ,0xFF ,2 ); chip->capacity[chip->card2lun[SD_CARD ]] = sd_card->capacity; retval =sd_set_init_para (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }RTSX_DEBUGP ("In reset_mmc_only, sd_card->sd_type = 0x%x\n" , sd_card->sd_type);
@@ -3255,9 +3144,8 @@ static int wait_data_buf_ready(struct rtsx_chip *chip) retval =sd_send_cmd_get_rsp (chip,SEND_STATUS , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (sd_card->sd_data_buf_ready) { return sd_send_cmd_get_rsp(chip, SEND_STATUS,
@@ -3277,19 +3165,18 @@ void sd_stop_seq_mode(struct rtsx_chip *chip)if (sd_card->seq_mode) { retval =sd_switch_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )return ; - } retval =sd_send_cmd_get_rsp (chip,STOP_TRANSMISSION ,0 , SD_RSP_TYPE_R1b,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )sd_set_err_code (chip,SD_STS_ERR ); - } + retval =sd_wait_state_data_ready (chip,0x08 ,1 ,1000 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )sd_set_err_code (chip,SD_STS_ERR ); - } + sd_card->seq_mode =0 ;rtsx_write_register (chip,RBCTL ,RB_FLUSH ,RB_FLUSH );
@@ -3302,9 +3189,9 @@ static inline int sd_auto_tune_clock(struct rtsx_chip *chip)int retval;if (chip->asic_code) { -if (sd_card->sd_clock >30 ) { +if (sd_card->sd_clock >30 ) sd_card->sd_clock -=20 ; - } + }else {switch (sd_card->sd_clock) {case CLK_200 :
@@ -3337,9 +3224,8 @@ static inline int sd_auto_tune_clock(struct rtsx_chip *chip) } retval =sd_switch_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }
@@ -3377,11 +3263,10 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, u16 s } } -if (!CHK_SD_HCXC (sd_card) && !CHK_MMC_SECTOR_MODE (sd_card)) { +if (!CHK_SD_HCXC (sd_card) && !CHK_MMC_SECTOR_MODE (sd_card)) data_addr = start_sector <<9 ; - }else { +else data_addr = start_sector; - }sd_clr_err_code (chip);
@@ -3436,21 +3321,20 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, u16 srtsx_add_cmd (chip,WRITE_REG_CMD ,CARD_DATA_SOURCE ,0x01 ,RING_BUFFER ); -if (CHK_MMC_8BIT (sd_card)) { +if (CHK_MMC_8BIT (sd_card))rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_8 ); - }else if (CHK_MMC_4BIT (sd_card) ||CHK_SD (sd_card)) { +else if (CHK_MMC_4BIT (sd_card) ||CHK_SD (sd_card))rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_4 ); - }else { +else rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_1 ); - }if (sd_card->seq_mode) { cfg2 =SD_NO_CALCULATE_CRC7 |SD_CHECK_CRC16 |SD_NO_WAIT_BUSY_END |SD_NO_CHECK_CRC7 |SD_RSP_LEN_0 ;if (CHECK_PID (chip,0x5209 )) { -if (!CHK_SD30_SPEED (sd_card)) { +if (!CHK_SD30_SPEED (sd_card)) cfg2 |=SD_NO_CHECK_WAIT_CRC_TO ; - } + }rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CFG2 ,0xFF , cfg2);
@@ -3480,9 +3364,9 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, u16 s cfg2 =SD_CALCULATE_CRC7 |SD_CHECK_CRC16 |SD_NO_WAIT_BUSY_END |SD_CHECK_CRC7 |SD_RSP_LEN_6 ;if (CHECK_PID (chip,0x5209 )) { -if (!CHK_SD30_SPEED (sd_card)) { +if (!CHK_SD30_SPEED (sd_card)) cfg2 |=SD_NO_CHECK_WAIT_CRC_TO ; - } + }rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CFG2 ,0xFF , cfg2);
@@ -3523,9 +3407,9 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, u16 s cfg2 =SD_NO_CALCULATE_CRC7 |SD_CHECK_CRC16 |SD_NO_WAIT_BUSY_END |SD_NO_CHECK_CRC7 |SD_RSP_LEN_0 ;if (CHECK_PID (chip,0x5209 )) { -if (!CHK_SD30_SPEED (sd_card)) { +if (!CHK_SD30_SPEED (sd_card)) cfg2 |=SD_NO_CHECK_WAIT_CRC_TO ; - } + }rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CFG2 ,0xFF , cfg2);
@@ -3550,11 +3434,10 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, u16 s sd_card->seq_mode =0 ; -if (retval == -ETIMEDOUT ) { +if (retval == -ETIMEDOUT ) err =STATUS_TIMEDOUT ; - }else { +else err =STATUS_FAIL ; - }rtsx_read_register (chip,REG_SD_STAT1 , &stat);rtsx_clear_sd_error (chip);
@@ -3640,9 +3523,8 @@ int ext_sd_send_cmd_get_rsp(struct rtsx_chip *chip, u8 cmd_idx,RTSX_DEBUGP ("EXT SD/MMC CMD %d\n" , cmd_idx); -if (rsp_type == SD_RSP_TYPE_R1b) { +if (rsp_type == SD_RSP_TYPE_R1b) timeout =3000 ; - } RTY_SEND_CMD:
@@ -3662,14 +3544,14 @@ RTY_SEND_CMD:rtsx_add_cmd (chip,CHECK_REG_CMD ,REG_SD_TRANSFER ,SD_TRANSFER_END ,SD_TRANSFER_END );if (rsp_type ==SD_RSP_TYPE_R2 ) { -for (reg_addr =PPBUF_BASE2 ; reg_addr <PPBUF_BASE2 +16 ; reg_addr++) { +for (reg_addr =PPBUF_BASE2 ; reg_addr <PPBUF_BASE2 +16 ; reg_addr++)rtsx_add_cmd (chip,READ_REG_CMD , reg_addr,0 ,0 ); - } + stat_idx =17 ; }else if (rsp_type !=SD_RSP_TYPE_R0 ) { -for (reg_addr =REG_SD_CMD0 ; reg_addr <=REG_SD_CMD4 ; reg_addr++) { +for (reg_addr =REG_SD_CMD0 ; reg_addr <=REG_SD_CMD4 ; reg_addr++)rtsx_add_cmd (chip,READ_REG_CMD , reg_addr,0 ,0 ); - } + stat_idx =6 ; }rtsx_add_cmd (chip,READ_REG_CMD ,REG_SD_CMD5 ,0 ,0 );
@@ -3683,9 +3565,9 @@ RTY_SEND_CMD:if (rsp_type &SD_WAIT_BUSY_END ) { retval =sd_check_data0_status (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip, retval); - } + }else {sd_set_err_code (chip,SD_TO_ERR ); }
@@ -3693,9 +3575,8 @@ RTY_SEND_CMD:TRACE_RET (chip,STATUS_FAIL ); } -if (rsp_type ==SD_RSP_TYPE_R0 ) { +if (rsp_type ==SD_RSP_TYPE_R0 )return STATUS_SUCCESS ; - } ptr =rtsx_get_cmd_data (chip) +1 ;
@@ -3724,9 +3605,9 @@ RTY_SEND_CMD:if ((cmd_idx ==SELECT_CARD ) || (cmd_idx ==APP_CMD ) || (cmd_idx ==SEND_STATUS ) || (cmd_idx ==STOP_TRANSMISSION )) {if ((cmd_idx !=STOP_TRANSMISSION ) && (special_check ==0 )) { -if (ptr[1 ] &0x80 ) { +if (ptr[1 ] &0x80 )TRACE_RET (chip,STATUS_FAIL ); - } + }#ifdef SUPPORT_SD_LOCK if (ptr[1 ] &0x7D )
@@ -3736,26 +3617,24 @@ RTY_SEND_CMD: {TRACE_RET (chip,STATUS_FAIL ); } -if (ptr[2 ] &0xF8 ) { +if (ptr[2 ] &0xF8 )TRACE_RET (chip,STATUS_FAIL ); - }if (cmd_idx ==SELECT_CARD ) {if (rsp_type ==SD_RSP_TYPE_R2 ) { -if ((ptr[3 ] &0x1E ) !=0x04 ) { +if ((ptr[3 ] &0x1E ) !=0x04 )TRACE_RET (chip,STATUS_FAIL ); - } + }else if (rsp_type ==SD_RSP_TYPE_R0 ) { -if ((ptr[3 ] &0x1E ) !=0x03 ) { +if ((ptr[3 ] &0x1E ) !=0x03 )TRACE_RET (chip,STATUS_FAIL ); - } + } } } -if (rsp && rsp_len) { +if (rsp && rsp_len)memcpy (rsp, ptr, rsp_len); - }return STATUS_SUCCESS ; }
@@ -3765,29 +3644,27 @@ int ext_sd_get_rsp(struct rtsx_chip *chip, int len, u8 *rsp, u8 rsp_type)int retval, rsp_len;u16 reg_addr; -if (rsp_type ==SD_RSP_TYPE_R0 ) { +if (rsp_type ==SD_RSP_TYPE_R0 )return STATUS_SUCCESS ; - }rtsx_init_cmd (chip);if (rsp_type ==SD_RSP_TYPE_R2 ) { -for (reg_addr =PPBUF_BASE2 ; reg_addr <PPBUF_BASE2 +16 ; reg_addr++) { +for (reg_addr =PPBUF_BASE2 ; reg_addr <PPBUF_BASE2 +16 ; reg_addr++)rtsx_add_cmd (chip,READ_REG_CMD , reg_addr,0xFF ,0 ); - } + rsp_len =17 ; }else if (rsp_type !=SD_RSP_TYPE_R0 ) { -for (reg_addr =REG_SD_CMD0 ; reg_addr <=REG_SD_CMD4 ; reg_addr++) { +for (reg_addr =REG_SD_CMD0 ; reg_addr <=REG_SD_CMD4 ; reg_addr++)rtsx_add_cmd (chip,READ_REG_CMD , reg_addr,0xFF ,0 ); - } + rsp_len =6 ; }rtsx_add_cmd (chip,READ_REG_CMD ,REG_SD_CMD5 ,0xFF ,0 ); retval =rtsx_send_cmd (chip,SD_CARD ,100 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (rsp) {int min_len = (rsp_len < len) ? rsp_len : len;
@@ -3858,9 +3735,8 @@ int sd_pass_thru_mode(struct scsi_cmnd *srb, struct rtsx_chip *chip) } buf[5 ] = (1 ==CHK_SD (sd_card)) ?0x01 :0x02 ; -if (chip->card_wp &SD_CARD ) { +if (chip->card_wp &SD_CARD ) buf[5 ] |=0x80 ; - } buf[6 ] = (u8)(sd_card->sd_addr >>16 ); buf[7 ] = (u8)(sd_card->sd_addr >>24 );
@@ -3875,9 +3751,8 @@ int sd_pass_thru_mode(struct scsi_cmnd *srb, struct rtsx_chip *chip)static inline int get_rsp_type (struct scsi_cmnd *srb,u8 *rsp_type,int *rsp_len) { -if (!rsp_type || !rsp_len) { +if (!rsp_type || !rsp_len)return STATUS_FAIL ; - }switch (srb->cmnd[10 ]) {case 0x03 :
@@ -3927,9 +3802,8 @@ int sd_execute_no_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) } retval =sd_switch_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - }if (sd_card->pre_cmd_err) { sd_card->pre_cmd_err =0 ;
@@ -3938,12 +3812,11 @@ int sd_execute_no_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) } cmd_idx = srb->cmnd[2 ] &0x3F ; -if (srb->cmnd[1 ] &0x02 ) { +if (srb->cmnd[1 ] &0x02 ) standby =1 ; - } -if (srb->cmnd[1 ] &0x01 ) { + +if (srb->cmnd[1 ] &0x01 ) acmd =1 ; - } arg = ((u32 )srb->cmnd[3 ] <<24 ) | ((u32 )srb->cmnd[4 ] <<16 ) | ((u32 )srb->cmnd[5 ] <<8 ) | srb->cmnd[6 ];
@@ -3956,64 +3829,58 @@ int sd_execute_no_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) sd_card->last_rsp_type = rsp_type; retval =sd_switch_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - }#ifdef SUPPORT_SD_LOCK if ((sd_card->sd_lock_status &SD_LOCK_1BIT_MODE ) ==0 ) {if (CHK_MMC_8BIT (sd_card)) { retval =rtsx_write_register (chip,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_8 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - } + }else if (CHK_SD (sd_card) ||CHK_MMC_4BIT (sd_card)) { retval =rtsx_write_register (chip,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_4 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - } + } }#else retval =rtsx_write_register (chip,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_4 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - } +#endif if (standby) { retval =sd_select_card (chip,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Cmd_Failed); - } }if (acmd) { retval =ext_sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Cmd_Failed); - } } retval =ext_sd_send_cmd_get_rsp (chip, cmd_idx, arg, rsp_type, sd_card->rsp, rsp_len,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Cmd_Failed); - }if (standby) { retval =sd_select_card (chip,1 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Cmd_Failed); - } }#ifdef SUPPORT_SD_LOCK retval =sd_update_lock_status (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Cmd_Failed); - }#endif scsi_set_resid (srb,0 );
@@ -4024,9 +3891,8 @@ SD_Execute_Cmd_Failed:set_sense_type (chip, lun,SENSE_TYPE_NO_SENSE );release_sd_card (chip);do_reset_sd_card (chip); -if (!(chip->card_ready &SD_CARD )) { +if (!(chip->card_ready &SD_CARD ))set_sense_type (chip, lun,SENSE_TYPE_MEDIA_NOT_PRESENT ); - }TRACE_RET (chip,TRANSPORT_FAILED ); }
@@ -4053,20 +3919,18 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) } retval =sd_switch_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - } cmd_idx = srb->cmnd[2 ] &0x3F ; -if (srb->cmnd[1 ] &0x04 ) { +if (srb->cmnd[1 ] &0x04 ) send_cmd12 =1 ; - } -if (srb->cmnd[1 ] &0x02 ) { + +if (srb->cmnd[1 ] &0x02 ) standby =1 ; - } -if (srb->cmnd[1 ] &0x01 ) { + +if (srb->cmnd[1 ] &0x01 ) acmd =1 ; - } data_len = ((u32 )srb->cmnd[7 ] <<16 ) | ((u32 )srb->cmnd[8 ] <<8 ) | srb->cmnd[9 ];
@@ -4078,19 +3942,18 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) sd_card->last_rsp_type = rsp_type; retval =sd_switch_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - }#ifdef SUPPORT_SD_LOCK if ((sd_card->sd_lock_status &SD_LOCK_1BIT_MODE ) ==0 ) { -if (CHK_MMC_8BIT (sd_card)) { +if (CHK_MMC_8BIT (sd_card)) bus_width =SD_BUS_WIDTH_8 ; - }else if (CHK_SD (sd_card) ||CHK_MMC_4BIT (sd_card)) { +else if (CHK_SD (sd_card) ||CHK_MMC_4BIT (sd_card)) bus_width =SD_BUS_WIDTH_4 ; - }else { +else bus_width =SD_BUS_WIDTH_1 ; - } + }else { bus_width =SD_BUS_WIDTH_4 ; }
@@ -4102,24 +3965,21 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)if (data_len <512 ) { retval =ext_sd_send_cmd_get_rsp (chip,SET_BLOCKLEN , data_len,SD_RSP_TYPE_R1 ,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - } }if (standby) { retval =sd_select_card (chip,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - } }if (acmd) { retval =ext_sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - } }if (data_len <=512 ) {
@@ -4138,9 +3998,8 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) cmd[4 ] = srb->cmnd[6 ]; buf =kmalloc (data_len,GFP_KERNEL ); -if (buf ==NULL ) { +if (buf ==NULL )TRACE_RET (chip,TRANSPORT_ERROR ); - } retval =sd_read_data (chip,SD_TM_NORMAL_READ , cmd,5 , byte_cnt, blk_cnt, bus_width, buf, data_len,2000 );
@@ -4195,56 +4054,48 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) } retval =ext_sd_get_rsp (chip, rsp_len, sd_card->rsp, rsp_type); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - }if (standby) { retval =sd_select_card (chip,1 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - } }if (send_cmd12) { retval =ext_sd_send_cmd_get_rsp (chip,STOP_TRANSMISSION ,0 , SD_RSP_TYPE_R1b,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - } }if (data_len <512 ) { retval =ext_sd_send_cmd_get_rsp (chip,SET_BLOCKLEN ,0x200 ,SD_RSP_TYPE_R1 ,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - } retval =rtsx_write_register (chip,SD_BYTE_CNT_H ,0xFF ,0x02 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - } + retval =rtsx_write_register (chip,SD_BYTE_CNT_L ,0xFF ,0x00 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - } } -if ((srb->cmnd[1 ] &0x02 ) || (srb->cmnd[1 ] &0x04 )) { +if ((srb->cmnd[1 ] &0x02 ) || (srb->cmnd[1 ] &0x04 )) cmd13_checkbit =1 ; - }for (i =0 ; i <3 ; i++) { retval =ext_sd_send_cmd_get_rsp (chip,SEND_STATUS , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 , cmd13_checkbit); -if (retval ==STATUS_SUCCESS ) { +if (retval ==STATUS_SUCCESS )break ; - } } -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - }scsi_set_resid (srb,0 );return TRANSPORT_GOOD ;
@@ -4252,14 +4103,13 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) SD_Execute_Read_Cmd_Failed: sd_card->pre_cmd_err =1 ;set_sense_type (chip, lun,SENSE_TYPE_NO_SENSE ); -if (read_err) { +if (read_err)set_sense_type (chip, lun,SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR ); - } +release_sd_card (chip);do_reset_sd_card (chip); -if (!(chip->card_ready &SD_CARD )) { +if (!(chip->card_ready &SD_CARD ))set_sense_type (chip, lun,SENSE_TYPE_MEDIA_NOT_PRESENT ); - }TRACE_RET (chip,TRANSPORT_FAILED ); }
@@ -4291,20 +4141,18 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) } retval =sd_switch_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - } cmd_idx = srb->cmnd[2 ] &0x3F ; -if (srb->cmnd[1 ] &0x04 ) { +if (srb->cmnd[1 ] &0x04 ) send_cmd12 =1 ; - } -if (srb->cmnd[1 ] &0x02 ) { + +if (srb->cmnd[1 ] &0x02 ) standby =1 ; - } -if (srb->cmnd[1 ] &0x01 ) { + +if (srb->cmnd[1 ] &0x01 ) acmd =1 ; - } data_len = ((u32 )srb->cmnd[7 ] <<16 ) | ((u32 )srb->cmnd[8 ] <<8 ) | srb->cmnd[9 ]; arg = ((u32)srb->cmnd[3] << 24) | ((u32)srb->cmnd[4] << 16) |
@@ -4325,75 +4173,68 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) sd_card->last_rsp_type = rsp_type; retval =sd_switch_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - }#ifdef SUPPORT_SD_LOCK if ((sd_card->sd_lock_status &SD_LOCK_1BIT_MODE ) ==0 ) {if (CHK_MMC_8BIT (sd_card)) { retval =rtsx_write_register (chip,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_8 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - } + }else if (CHK_SD (sd_card) ||CHK_MMC_4BIT (sd_card)) { retval =rtsx_write_register (chip,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_4 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - } + } }#else retval =rtsx_write_register (chip,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_4 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - } +#endif if (data_len <512 ) { retval =ext_sd_send_cmd_get_rsp (chip,SET_BLOCKLEN , data_len,SD_RSP_TYPE_R1 ,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - } }if (standby) { retval =sd_select_card (chip,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - } }if (acmd) { retval =ext_sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - } } retval =ext_sd_send_cmd_get_rsp (chip, cmd_idx, arg, rsp_type, sd_card->rsp, rsp_len,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - }if (data_len <=512 ) {u16 i;u8 *buf; buf =kmalloc (data_len,GFP_KERNEL ); -if (buf ==NULL ) { +if (buf ==NULL )TRACE_RET (chip,TRANSPORT_ERROR ); - }rtsx_stor_get_xfer_buf (buf, data_len, srb);#ifdef SUPPORT_SD_LOCK -if (cmd_idx ==LOCK_UNLOCK ) { +if (cmd_idx ==LOCK_UNLOCK ) lock_cmd_type = buf[0 ] &0x0F ; - }#endif if (data_len >256 ) {
@@ -4485,11 +4326,11 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) }rtsx_init_cmd (chip); -if (CHECK_PID (chip,0x5209 )) { +if (CHECK_PID (chip,0x5209 ))rtsx_add_cmd (chip,CHECK_REG_CMD ,SD_BUS_STAT ,SD_DAT0_STATUS ,SD_DAT0_STATUS ); - }else { +else rtsx_add_cmd (chip,CHECK_REG_CMD ,0xFD30 ,0x02 ,0x02 ); - } +rtsx_send_cmd (chip,SD_CARD ,250 ); retval =sd_update_lock_status (chip);
@@ -4502,61 +4343,54 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)if (standby) { retval =sd_select_card (chip,1 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - } }if (send_cmd12) { retval =ext_sd_send_cmd_get_rsp (chip,STOP_TRANSMISSION ,0 , SD_RSP_TYPE_R1b,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - } }if (data_len <512 ) { retval =ext_sd_send_cmd_get_rsp (chip,SET_BLOCKLEN ,0x200 ,SD_RSP_TYPE_R1 ,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - } retval =rtsx_write_register (chip,SD_BYTE_CNT_H ,0xFF ,0x02 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - } +rtsx_write_register (chip,SD_BYTE_CNT_L ,0xFF ,0x00 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - } + } -if ((srb->cmnd[1 ] &0x02 ) || (srb->cmnd[1 ] &0x04 )) { +if ((srb->cmnd[1 ] &0x02 ) || (srb->cmnd[1 ] &0x04 )) cmd13_checkbit =1 ; - }for (i =0 ; i <3 ; i++) { retval =ext_sd_send_cmd_get_rsp (chip,SEND_STATUS , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 , cmd13_checkbit); -if (retval ==STATUS_SUCCESS ) { +if (retval ==STATUS_SUCCESS )break ; - } } -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - }#ifdef SUPPORT_SD_LOCK if (cmd_idx ==LOCK_UNLOCK ) {if (!lock_cmd_fail) {RTSX_DEBUGP ("lock_cmd_type = 0x%x\n" , lock_cmd_type); -if (lock_cmd_type &SD_CLR_PWD ) { +if (lock_cmd_type &SD_CLR_PWD ) sd_card->sd_lock_status &= ~SD_PWD_EXIST ; - } -if (lock_cmd_type &SD_SET_PWD ) { + +if (lock_cmd_type &SD_SET_PWD ) sd_card->sd_lock_status |=SD_PWD_EXIST ; - } } RTSX_DEBUGP("sd_lock_state = 0x%x, sd_card->sd_lock_status = 0x%x\n",
@@ -4593,14 +4427,13 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) SD_Execute_Write_Cmd_Failed: sd_card->pre_cmd_err =1 ;set_sense_type (chip, lun,SENSE_TYPE_NO_SENSE ); -if (write_err) { +if (write_err)set_sense_type (chip, lun,SENSE_TYPE_MEDIA_WRITE_ERR ); - } +release_sd_card (chip);do_reset_sd_card (chip); -if (!(chip->card_ready &SD_CARD )) { +if (!(chip->card_ready &SD_CARD ))set_sense_type (chip, lun,SENSE_TYPE_MEDIA_NOT_PRESENT ); - }TRACE_RET (chip,TRANSPORT_FAILED ); }
@@ -4670,9 +4503,8 @@ int sd_hw_rst(struct scsi_cmnd *srb, struct rtsx_chip *chip)switch (srb->cmnd[1 ] &0x0F ) {case 0 :#ifdef SUPPORT_SD_LOCK -if (0x64 == srb->cmnd[9 ]) { +if (0x64 == srb->cmnd[9 ]) sd_card->sd_lock_status |=SD_SDR_RST ; - }#endif retval =reset_sd_card (chip);if (retval !=STATUS_SUCCESS ) {
@@ -4723,26 +4555,23 @@ int sd_power_off_card3v3(struct rtsx_chip *chip)int retval; retval =disable_card_clock (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }RTSX_WRITE_REG (chip,CARD_OE ,SD_OUTPUT_EN ,0 );if (!chip->ft2_fast_mode) { retval =card_power_off (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }wait_timeout (50 ); }if (chip->asic_code) { retval =sd_pull_ctl_disable (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } }else {RTSX_WRITE_REG (chip,FPGA_PULL_CTL ,FPGA_SD_PULL_CTL_BIT |0x20 ,FPGA_SD_PULL_CTL_BIT );
@@ -4774,19 +4603,16 @@ int release_sd_card(struct rtsx_chip *chip)memset (sd_card->raw_scr,0 ,8 ); retval =sd_power_off_card3v3 (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (CHECK_PID (chip,0x5209 )) { retval =sd_change_bank_voltage (chip,SD_IO_3V3 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } -if (CHK_SD30_SPEED (sd_card)) { +if (CHK_SD30_SPEED (sd_card))RTSX_WRITE_REG (chip,SD30_DRIVE_SEL ,0x07 , chip->sd30_drive_sel_3v3); - }RTSX_WRITE_REG (chip,OCPPARA2 ,SD_OCP_THD_MASK , chip->sd_400mA_ocp_thd); }
Signature · 1 line
1.7.9.5
Hello,
This is a very big patch. It will be difficult for reviewers to review.
i think it will be good if you can split into multiple patches.
Thanks,
Quoted 2,842 lines · Toshiaki Yamane
fixed below checkpatch warnings.
(quoted diff) +0
-2-WARNING: braces {} are not necessary for single statement blocks -WARNING: braces {} are not necessary for any arm of this statementSigned-off-by Toshiaki Yamane <[email protected]>--- drivers/staging/rts_pstor/sd.c | 1112 +++++++++++++++++----------------------- 1 file changed, 469 insertions(+), 643 deletions(-)drivers/staging/rts_pstor/sd.c +469
-644@@ -192,9 +192,9 @@ RTY_SEND_CMD: stat_idx =16 ; }else if (rsp_type !=SD_RSP_TYPE_R0 ) { -for (reg_addr =REG_SD_CMD0 ; reg_addr <=REG_SD_CMD4 ; reg_addr++) { +for (reg_addr =REG_SD_CMD0 ; reg_addr <=REG_SD_CMD4 ; reg_addr++)rtsx_add_cmd (chip,READ_REG_CMD , reg_addr,0 ,0 ); - } + stat_idx =5 ; }@@ -273,9 +273,8 @@ RTY_SEND_CMD:if ((rsp_type ==SD_RSP_TYPE_R1 ) || (rsp_type == SD_RSP_TYPE_R1b)) {if ((cmd_idx !=SEND_RELATIVE_ADDR ) && (cmd_idx !=SEND_IF_COND )) {if (cmd_idx !=STOP_TRANSMISSION ) { -if (ptr[1 ] &0x80 ) { +if (ptr[1 ] &0x80 )TRACE_RET (chip,STATUS_FAIL ); - } }#ifdef SUPPORT_SD_LOCK if (ptr[1 ] &0x7D )@@ -294,11 +293,10 @@ RTY_SEND_CMD:RTSX_DEBUGP ("ptr[3]: 0x%02x\n" , ptr[3 ]);TRACE_RET (chip,STATUS_FAIL ); } -if (ptr[3 ] &0x01 ) { +if (ptr[3 ] &0x01 ) sd_card->sd_data_buf_ready =1 ; - }else { +else sd_card->sd_data_buf_ready =0 ; - } } }@@ -322,17 +320,15 @@ static int sd_read_data(struct rtsx_chip *chip,if (!buf) buf_len =0 ; -if (buf_len >512 ) { +if (buf_len >512 )TRACE_RET (chip,STATUS_FAIL ); - }rtsx_init_cmd (chip);if (cmd_len) {RTSX_DEBUGP ("SD/MMC CMD %d\n" , cmd[0 ] -0x40 ); -for (i =0 ; i < (cmd_len <6 ? cmd_len :6 ); i++) { +for (i =0 ; i < (cmd_len <6 ? cmd_len :6 ); i++)rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CMD0 + i,0xFF , cmd[i]); - } }rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_BYTE_CNT_L ,0xFF , (u8 )byte_cnt);rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_BYTE_CNT_H ,0xFF , (u8)(byte_cnt >>8 ));@@ -344,9 +340,9 @@ static int sd_read_data(struct rtsx_chip *chip,rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CFG2 ,0xFF ,SD_CALCULATE_CRC7 |SD_CHECK_CRC16 |SD_NO_WAIT_BUSY_END |SD_CHECK_CRC7 |SD_RSP_LEN_6 ); -if (trans_mode !=SD_TM_AUTO_TUNING ) { +if (trans_mode !=SD_TM_AUTO_TUNING )rtsx_add_cmd (chip,WRITE_REG_CMD ,CARD_DATA_SOURCE ,0x01 ,PINGPONG_BUFFER ); - } +rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_TRANSFER ,0xFF , trans_mode |SD_TRANSFER_START );rtsx_add_cmd (chip,CHECK_REG_CMD ,REG_SD_TRANSFER ,SD_TRANSFER_END ,SD_TRANSFER_END );@@ -362,9 +358,8 @@ static int sd_read_data(struct rtsx_chip *chip,if (buf && buf_len) { retval =rtsx_read_ppbuf (chip, buf, buf_len); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } }return STATUS_SUCCESS ;@@ -390,9 +385,8 @@ static int sd_write_data(struct rtsx_chip *chip, u8 trans_mode,if (buf && buf_len) { retval =rtsx_write_ppbuf (chip, buf, buf_len); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } }rtsx_init_cmd (chip);@@ -450,15 +444,13 @@ static int sd_check_csd(struct rtsx_chip *chip, char check_wp)break ; } -if (i ==6 ) { +if (i ==6 )TRACE_RET (chip,STATUS_FAIL ); - }memcpy (sd_card->raw_csd, rsp +1 ,15 ); -if (CHECK_PID (chip,0x5209 )) { +if (CHECK_PID (chip,0x5209 ))RTSX_READ_REG (chip,REG_SD_CMD5 , sd_card->raw_csd +15 ); - }RTSX_DEBUGP ("CSD Response:\n" );RTSX_DUMP (sd_card->raw_csd,16 );@@ -469,35 +461,35 @@ static int sd_check_csd(struct rtsx_chip *chip, char check_wp) trans_speed = rsp[4 ];if ((trans_speed &0x07 ) ==0x02 ) {if ((trans_speed &0xf8 ) >=0x30 ) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock =47 ; - }else { +else sd_card->sd_clock =CLK_50 ; - } + }else if ((trans_speed &0xf8 ) ==0x28 ) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock =39 ; - }else { +else sd_card->sd_clock =CLK_40 ; - } + }else if ((trans_speed &0xf8 ) ==0x20 ) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock =29 ; - }else { +else sd_card->sd_clock =CLK_30 ; - } + }else if ((trans_speed &0xf8 ) >=0x10 ) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock =23 ; - }else { +else sd_card->sd_clock =CLK_20 ; - } + }else if ((trans_speed &0x08 ) >=0x08 ) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock =19 ; - }else { +else sd_card->sd_clock =CLK_20 ; - } + }else {TRACE_RET (chip,STATUS_FAIL ); }@@ -527,9 +519,9 @@ static int sd_check_csd(struct rtsx_chip *chip, char check_wp) }if (check_wp) { -if (rsp[15 ] &0x30 ) { +if (rsp[15 ] &0x30 ) chip->card_wp |=SD_CARD ; - } +RTSX_DEBUGP ("CSD WP Status: 0x%x\n" , rsp[15 ]); }@@ -568,22 +560,22 @@ static int sd_set_sample_push_timing(struct rtsx_chip *chip) CRC_FIX_CLK | SD30_VAR_CLK0 | SAMPLE_VAR_CLK1);RTSX_WRITE_REG (chip,CLK_CTL ,CLK_LOW_FREQ ,0 ); -if ((chip->sd_ctl &SD_PUSH_POINT_CTL_MASK ) ==SD_PUSH_POINT_AUTO ) { +if ((chip->sd_ctl &SD_PUSH_POINT_CTL_MASK ) ==SD_PUSH_POINT_AUTO ) val =SD20_TX_NEG_EDGE ; - }else if ((chip->sd_ctl &SD_PUSH_POINT_CTL_MASK ) ==SD_PUSH_POINT_DELAY ) { +else if ((chip->sd_ctl &SD_PUSH_POINT_CTL_MASK ) ==SD_PUSH_POINT_DELAY ) val =SD20_TX_14_AHEAD ; - }else { +else val =SD20_TX_NEG_EDGE ; - } +RTSX_WRITE_REG (chip,SD_PUSH_POINT_CTL ,SD20_TX_SEL_MASK , val);if ((chip->sd_ctl &SD_SAMPLE_POINT_CTL_MASK ) ==SD_SAMPLE_POINT_AUTO ) {if (chip->asic_code) { -if (CHK_SD_HS (sd_card) ||CHK_MMC_52M (sd_card)) { +if (CHK_SD_HS (sd_card) ||CHK_MMC_52M (sd_card)) val =SD20_RX_14_DELAY ; - }else { +else val =SD20_RX_POS_EDGE ; - } + }else { val =SD20_RX_14_DELAY ; }@@ -597,32 +589,28 @@ static int sd_set_sample_push_timing(struct rtsx_chip *chip) }else {u8 val =0 ; -if ((chip->sd_ctl &SD_PUSH_POINT_CTL_MASK ) ==SD_PUSH_POINT_DELAY ) { +if ((chip->sd_ctl &SD_PUSH_POINT_CTL_MASK ) ==SD_PUSH_POINT_DELAY ) val |=0x10 ; - }if ((chip->sd_ctl &SD_SAMPLE_POINT_CTL_MASK ) ==SD_SAMPLE_POINT_AUTO ) {if (chip->asic_code) {if (CHK_SD_HS (sd_card) ||CHK_MMC_52M (sd_card)) { -if (val &0x10 ) { +if (val &0x10 ) val |=0x04 ; - }else { +else val |=0x08 ; - } } }else { -if (val &0x10 ) { +if (val &0x10 ) val |=0x04 ; - }else { +else val |=0x08 ; - } } }else if ((chip->sd_ctl &SD_SAMPLE_POINT_CTL_MASK ) ==SD_SAMPLE_POINT_DELAY ) { -if (val &0x10 ) { +if (val &0x10 ) val |=0x04 ; - }else { +else val |=0x08 ; - } }RTSX_WRITE_REG (chip,REG_SD_CFG1 ,0x1C , val);@@ -636,41 +624,41 @@ static void sd_choose_proper_clock(struct rtsx_chip *chip)struct sd_info *sd_card = &(chip->sd_card);if (CHK_SD_SDR104 (sd_card)) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock = chip->asic_sd_sdr104_clk; - }else { +else sd_card->sd_clock = chip->fpga_sd_sdr104_clk; - } + }else if (CHK_SD_DDR50 (sd_card)) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock = chip->asic_sd_ddr50_clk; - }else { +else sd_card->sd_clock = chip->fpga_sd_ddr50_clk; - } + }else if (CHK_SD_SDR50 (sd_card)) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock = chip->asic_sd_sdr50_clk; - }else { +else sd_card->sd_clock = chip->fpga_sd_sdr50_clk; - } + }else if (CHK_SD_HS (sd_card)) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock = chip->asic_sd_hs_clk; - }else { +else sd_card->sd_clock = chip->fpga_sd_hs_clk; - } + }else if (CHK_MMC_52M (sd_card) ||CHK_MMC_DDR52 (sd_card)) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock = chip->asic_mmc_52m_clk; - }else { +else sd_card->sd_clock = chip->fpga_mmc_52m_clk; - } + }else if (CHK_MMC_26M (sd_card)) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock =48 ; - }else { +else sd_card->sd_clock =CLK_50 ; - } + } }@@ -683,13 +671,12 @@ static int sd_set_clock_divider(struct rtsx_chip *chip, u8 clk_div) val = clk_div; }else { mask =0x60 ; -if (clk_div ==SD_CLK_DIVIDE_0 ) { +if (clk_div ==SD_CLK_DIVIDE_0 ) val =0x00 ; - }else if (clk_div ==SD_CLK_DIVIDE_128 ) { +else if (clk_div ==SD_CLK_DIVIDE_128 ) val =0x40 ; - }else if (clk_div ==SD_CLK_DIVIDE_256 ) { +else if (clk_div ==SD_CLK_DIVIDE_256 ) val =0x20 ; - } }RTSX_WRITE_REG (chip,REG_SD_CFG1 , mask, val);@@ -703,16 +690,14 @@ static int sd_set_init_para(struct rtsx_chip *chip)int retval; retval =sd_set_sample_push_timing (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }sd_choose_proper_clock (chip); retval =switch_clock (chip, sd_card->sd_clock); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }@@ -735,9 +720,8 @@ int sd_select_card(struct rtsx_chip *chip, int select) } retval =sd_send_cmd_get_rsp (chip, cmd_idx, addr, cmd_type,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }@@ -750,21 +734,18 @@ static int sd_update_lock_status(struct rtsx_chip *chip)u8 rsp[5 ]; retval =sd_send_cmd_get_rsp (chip,SEND_STATUS , sd_card->sd_addr,SD_RSP_TYPE_R1 , rsp,5 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } -if (rsp[1 ] &0x02 ) { +if (rsp[1 ] &0x02 ) sd_card->sd_lock_status |=SD_LOCKED ; - }else { +else sd_card->sd_lock_status &= ~SD_LOCKED ; - }RTSX_DEBUGP ("sd_card->sd_lock_status = 0x%x\n" , sd_card->sd_lock_status); -if (rsp[1 ] &0x01 ) { +if (rsp[1 ] &0x01 )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }@@ -779,13 +760,12 @@ static int sd_wait_state_data_ready(struct rtsx_chip *chip, u8 state, u8 data_refor (i =0 ; i < polling_cnt; i++) { retval =sd_send_cmd_get_rsp (chip,SEND_STATUS , sd_card->sd_addr,SD_RSP_TYPE_R1 , rsp,5 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } -if (((rsp[3 ] &0x1E ) == state) && ((rsp[3 ] &0x01 ) == data_ready)) { +if (((rsp[3 ] &0x1E ) == state) && ((rsp[3 ] &0x01 ) == data_ready))return STATUS_SUCCESS ; - } + }TRACE_RET (chip,STATUS_FAIL );@@ -798,18 +778,16 @@ static int sd_change_bank_voltage(struct rtsx_chip *chip, u8 voltage)if (voltage ==SD_IO_3V3 ) {if (chip->asic_code) { retval =rtsx_write_phy_register (chip,0x08 ,0x4FC0 | chip->phy_voltage); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } }else {RTSX_WRITE_REG (chip,SD_PAD_CTL ,SD_IO_USING_1V8 ,0 ); } }else if (voltage ==SD_IO_1V8 ) {if (chip->asic_code) { retval =rtsx_write_phy_register (chip,0x08 ,0x4C40 | chip->phy_voltage); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } }else {RTSX_WRITE_REG (chip,SD_PAD_CTL ,SD_IO_USING_1V8 ,SD_IO_USING_1V8 ); }@@ -828,9 +806,8 @@ static int sd_voltage_switch(struct rtsx_chip *chip)RTSX_WRITE_REG (chip,SD_BUS_STAT ,SD_CLK_TOGGLE_EN |SD_CLK_FORCE_STOP ,SD_CLK_TOGGLE_EN ); retval =sd_send_cmd_get_rsp (chip,VOLTAGE_SWITCH ,0 ,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }udelay (chip->sd_voltage_switch_delay);@@ -842,9 +819,9 @@ static int sd_voltage_switch(struct rtsx_chip *chip)RTSX_WRITE_REG (chip,SD_BUS_STAT ,0xFF ,SD_CLK_FORCE_STOP ); retval =sd_change_bank_voltage (chip,SD_IO_1V8 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } +wait_timeout (50 );RTSX_WRITE_REG (chip,SD_BUS_STAT ,0xFF ,SD_CLK_TOGGLE_EN );@@ -893,9 +870,8 @@ static int sd_change_phase(struct rtsx_chip *chip, u8 sample_point, u8 tune_dir)if (tune_dir ==TUNE_RX ) {SD_VP_CTL =SD_VPRX_CTL ;SD_DCMPS_CTL =SD_DCMPS_RX_CTL ; -if (CHK_SD_DDR50 (sd_card)) { +if (CHK_SD_DDR50 (sd_card)) ddr_rx =1 ; - } }else {SD_VP_CTL =SD_VPTX_CTL ;SD_DCMPS_CTL =SD_DCMPS_TX_CTL ;@@ -932,23 +908,22 @@ static int sd_change_phase(struct rtsx_chip *chip, u8 sample_point, u8 tune_dir)rtsx_add_cmd (chip,WRITE_REG_CMD ,SD_DCMPS_CTL ,DCMPS_CHANGE ,DCMPS_CHANGE );rtsx_add_cmd (chip,CHECK_REG_CMD ,SD_DCMPS_CTL ,DCMPS_CHANGE_DONE ,DCMPS_CHANGE_DONE ); retval =rtsx_send_cmd (chip,SD_CARD ,100 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, Fail); - } val = *rtsx_get_cmd_data (chip); -if (val &DCMPS_ERROR ) { +if (val &DCMPS_ERROR )TRACE_GOTO (chip, Fail); - } -if ((val &DCMPS_CURRENT_PHASE ) != sample_point) { + +if ((val &DCMPS_CURRENT_PHASE ) != sample_point)TRACE_GOTO (chip, Fail); - } +RTSX_WRITE_REG (chip,SD_DCMPS_CTL ,DCMPS_CHANGE ,0 ); -if (ddr_rx) { +if (ddr_rx)RTSX_WRITE_REG (chip,SD_VP_CTL ,PHASE_CHANGE ,0 ); - }else { +else RTSX_WRITE_REG (chip,CLK_CTL ,CHANGE_CLK ,0 ); - } +udelay (50 ); }@@ -978,9 +953,8 @@ static int sd_check_spec(struct rtsx_chip *chip, u8 bus_width)u8 cmd[5 ], buf[8 ]; retval =sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } cmd[0 ] =0x40 |SEND_SCR ; cmd[1 ] =0 ;@@ -996,9 +970,8 @@ static int sd_check_spec(struct rtsx_chip *chip, u8 bus_width)memcpy (sd_card->raw_scr, buf,8 ); -if ((buf[0 ] &0x0F ) ==0 ) { +if ((buf[0 ] &0x0F ) ==0 )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }@@ -1172,13 +1145,12 @@ static int sd_check_switch_mode(struct rtsx_chip *chip, u8 mode,*/ u16 cc = ((u16 )buf[0 ] <<8 ) | buf[1 ];RTSX_DEBUGP ("Maximum current consumption: %dmA\n" , cc); -if ((cc ==0 ) || (cc >800 )) { +if ((cc ==0 ) || (cc >800 ))TRACE_RET (chip,STATUS_FAIL ); - } + retval =sd_query_switch_result (chip, func_group, func_to_switch, buf,64 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if ((cc >400 ) || (func_to_switch >CURRENT_LIMIT_400 )) {RTSX_WRITE_REG (chip,OCPPARA2 ,SD_OCP_THD_MASK , chip->sd_800mA_ocp_thd);@@ -1192,13 +1164,13 @@ static int sd_check_switch_mode(struct rtsx_chip *chip, u8 mode,static u8 downgrade_switch_mode (u8 func_group,u8 func_to_switch) {if (func_group ==SD_FUNC_GROUP_1 ) { -if (func_to_switch >HS_SUPPORT ) { +if (func_to_switch >HS_SUPPORT ) func_to_switch--; - } + }else if (func_group ==SD_FUNC_GROUP_4 ) { -if (func_to_switch >CURRENT_LIMIT_200 ) { +if (func_to_switch >CURRENT_LIMIT_200 ) func_to_switch--; - } + }return func_to_switch;@@ -1241,9 +1213,8 @@ static int sd_check_switch(struct rtsx_chip *chip,wait_timeout (20 ); } -if (!switch_good) { +if (!switch_good)TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }@@ -1258,9 +1229,8 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width)/* Get supported functions */ retval =sd_check_switch_mode (chip,SD_CHECK_MODE ,NO_ARGUMENT ,NO_ARGUMENT , bus_width); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } sd_card->func_group1_mask &= ~(sd_card->sd_switch_fail);@@ -1289,9 +1259,9 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width)break ;case HS_SUPPORT : -if (sd_card->func_group1_mask &HS_SUPPORT_MASK ) { +if (sd_card->func_group1_mask &HS_SUPPORT_MASK ) func_to_switch =HS_SUPPORT ; - } +break ;default :@@ -1299,9 +1269,9 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width) } -if (func_to_switch) { +if (func_to_switch)break ; - } + }RTSX_DEBUGP ("SD_FUNC_GROUP_1: func_to_switch = 0x%02x" , func_to_switch);@@ -1330,23 +1300,22 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width)TRACE_RET (chip,STATUS_FAIL ); } -if (func_to_switch ==SDR104_SUPPORT ) { +if (func_to_switch ==SDR104_SUPPORT )SET_SD_SDR104 (sd_card); - }else if (func_to_switch ==DDR50_SUPPORT ) { +else if (func_to_switch ==DDR50_SUPPORT )SET_SD_DDR50 (sd_card); - }else if (func_to_switch ==SDR50_SUPPORT ) { +else if (func_to_switch ==SDR50_SUPPORT )SET_SD_SDR50 (sd_card); - }else { +else SET_SD_HS (sd_card); - } + }if (CHK_SD_DDR50 (sd_card)) {RTSX_WRITE_REG (chip,SD_PUSH_POINT_CTL ,0x06 ,0x04 ); retval =sd_set_sample_push_timing (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } }if (!func_to_switch || (func_to_switch ==HS_SUPPORT )) {@@ -1362,36 +1331,36 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width)for (i =0 ; i <4 ; i++) {switch ((u8)(chip->sd_current_prior >> (i*8 ))) {case CURRENT_LIMIT_800 : -if (sd_card->func_group4_mask &CURRENT_LIMIT_800_MASK ) { +if (sd_card->func_group4_mask &CURRENT_LIMIT_800_MASK ) func_to_switch =CURRENT_LIMIT_800 ; - } +break ;case CURRENT_LIMIT_600 : -if (sd_card->func_group4_mask &CURRENT_LIMIT_600_MASK ) { +if (sd_card->func_group4_mask &CURRENT_LIMIT_600_MASK ) func_to_switch =CURRENT_LIMIT_600 ; - } +break ;case CURRENT_LIMIT_400 : -if (sd_card->func_group4_mask &CURRENT_LIMIT_400_MASK ) { +if (sd_card->func_group4_mask &CURRENT_LIMIT_400_MASK ) func_to_switch =CURRENT_LIMIT_400 ; - } +break ;case CURRENT_LIMIT_200 : -if (sd_card->func_group4_mask &CURRENT_LIMIT_200_MASK ) { +if (sd_card->func_group4_mask &CURRENT_LIMIT_200_MASK ) func_to_switch =CURRENT_LIMIT_200 ; - } +break ;default :continue ; } -if (func_to_switch !=0xFF ) { +if (func_to_switch !=0xFF )break ; - } + }RTSX_DEBUGP ("SD_FUNC_GROUP_4: func_to_switch = 0x%02x" , func_to_switch);@@ -1399,16 +1368,15 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width)if (func_to_switch <=CURRENT_LIMIT_800 ) { retval =sd_check_switch (chip,SD_FUNC_GROUP_4 , func_to_switch, bus_width);if (retval !=STATUS_SUCCESS ) { -if (sd_check_err_code (chip,SD_NO_CARD )) { +if (sd_check_err_code (chip,SD_NO_CARD ))TRACE_RET (chip,STATUS_FAIL ); - } + }RTSX_DEBUGP ("Switch current limit finished! (%d)\n" , retval); } -if (CHK_SD_DDR50 (sd_card)) { +if (CHK_SD_DDR50 (sd_card))RTSX_WRITE_REG (chip,SD_PUSH_POINT_CTL ,0x06 ,0 ); - }return STATUS_SUCCESS ; }@@ -1438,9 +1406,8 @@ static int sd_sdr_tuning_rx_cmd(struct rtsx_chip *chip, u8 sample_point)u8 cmd[5 ]; retval =sd_change_phase (chip, sample_point,TUNE_RX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } cmd[0 ] =0x40 |SEND_TUNING_PATTERN ; cmd[1 ] =0 ;@@ -1467,16 +1434,14 @@ static int sd_ddr_tuning_rx_cmd(struct rtsx_chip *chip, u8 sample_point)u8 cmd[5 ]; retval =sd_change_phase (chip, sample_point,TUNE_RX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }RTSX_DEBUGP ("sd ddr tuning rx\n" ); retval =sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } cmd[0 ] =0x40 |SD_STATUS ; cmd[1 ] =0 ;@@ -1502,18 +1467,16 @@ static int mmc_ddr_tunning_rx_cmd(struct rtsx_chip *chip, u8 sample_point)int retval;u8 cmd[5 ], bus_width; -if (CHK_MMC_8BIT (sd_card)) { +if (CHK_MMC_8BIT (sd_card)) bus_width =SD_BUS_WIDTH_8 ; - }else if (CHK_MMC_4BIT (sd_card)) { +else if (CHK_MMC_4BIT (sd_card)) bus_width =SD_BUS_WIDTH_4 ; - }else { +else bus_width =SD_BUS_WIDTH_1 ; - } retval =sd_change_phase (chip, sample_point,TUNE_RX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }RTSX_DEBUGP ("mmc ddr tuning rx\n" );@@ -1541,9 +1504,8 @@ static int sd_sdr_tuning_tx_cmd(struct rtsx_chip *chip, u8 sample_point)int retval; retval =sd_change_phase (chip, sample_point,TUNE_TX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }RTSX_WRITE_REG (chip,SD_CFG3 ,SD_RSP_80CLK_TIMEOUT_EN ,SD_RSP_80CLK_TIMEOUT_EN );@@ -1568,26 +1530,23 @@ static int sd_ddr_tuning_tx_cmd(struct rtsx_chip *chip, u8 sample_point)u8 cmd[5 ], bus_width; retval =sd_change_phase (chip, sample_point,TUNE_TX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (CHK_SD (sd_card)) { bus_width =SD_BUS_WIDTH_4 ; }else { -if (CHK_MMC_8BIT (sd_card)) { +if (CHK_MMC_8BIT (sd_card)) bus_width =SD_BUS_WIDTH_8 ; - }else if (CHK_MMC_4BIT (sd_card)) { +else if (CHK_MMC_4BIT (sd_card)) bus_width =SD_BUS_WIDTH_4 ; - }else { +else bus_width =SD_BUS_WIDTH_1 ; - } } retval =sd_wait_state_data_ready (chip,0x08 ,1 ,1000 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }RTSX_WRITE_REG (chip,SD_CFG3 ,SD_RSP_80CLK_TIMEOUT_EN ,SD_RSP_80CLK_TIMEOUT_EN );@@ -1621,11 +1580,10 @@ static u8 sd_search_final_phase(struct rtsx_chip *chip, u32 phase_map, u8 tune_du8 final_phase =0xFF ;if (phase_map ==0xFFFFFFFF ) { -if (tune_dir ==TUNE_RX ) { +if (tune_dir ==TUNE_RX ) final_phase = (u8 )chip->sd_default_rx_phase; - }else { +else final_phase = (u8 )chip->sd_default_tx_phase; - } goto Search_Finish; }@@ -1666,9 +1624,9 @@ static u8 sd_search_final_phase(struct rtsx_chip *chip, u32 phase_map, u8 tune_d path[0 ].start = path[cont_path_cnt -1 ].start -MAX_PHASE -1 ; path[0 ].len += path[cont_path_cnt -1 ].len; path[0 ].mid = path[0 ].start + path[0 ].len /2 ; -if (path[0 ].mid <0 ) { +if (path[0 ].mid <0 ) path[0 ].mid +=MAX_PHASE +1 ; - } + cont_path_cnt--; }@@ -1696,11 +1654,11 @@ static u8 sd_search_final_phase(struct rtsx_chip *chip, u32 phase_map, u8 tune_dint temp_final_phase = path[final_path_idx].end - (max_len - (6 + temp_mid)); -if (temp_final_phase <0 ) { +if (temp_final_phase <0 ) final_phase = (u8)(temp_final_phase +MAX_PHASE +1 ); - }else { +else final_phase = (u8 )temp_final_phase; - } + } }else if (CHK_SD_SDR50 (sd_card)) {if (max_len >12 ) {@@ -1708,11 +1666,11 @@ static u8 sd_search_final_phase(struct rtsx_chip *chip, u32 phase_map, u8 tune_dint temp_final_phase = path[final_path_idx].end - (max_len - (3 + temp_mid)); -if (temp_final_phase <0 ) { +if (temp_final_phase <0 ) final_phase = (u8)(temp_final_phase +MAX_PHASE +1 ); - }else { +else final_phase = (u8 )temp_final_phase; - } + } } }@@ -1732,17 +1690,17 @@ static int sd_tuning_rx(struct rtsx_chip *chip)int (*tuning_cmd)(struct rtsx_chip *chip,u8 sample_point);if (CHK_SD (sd_card)) { -if (CHK_SD_DDR50 (sd_card)) { +if (CHK_SD_DDR50 (sd_card)) tuning_cmd = sd_ddr_tuning_rx_cmd; - }else { +else tuning_cmd = sd_sdr_tuning_rx_cmd; - } + }else { -if (CHK_MMC_DDR52 (sd_card)) { +if (CHK_MMC_DDR52 (sd_card)) tuning_cmd = mmc_ddr_tunning_rx_cmd; - }else { +else TRACE_RET (chip,STATUS_FAIL ); - } + }for (i =0 ; i <3 ; i++) {@@ -1754,27 +1712,25 @@ static int sd_tuning_rx(struct rtsx_chip *chip) } retval =tuning_cmd (chip, (u8 )j); -if (retval ==STATUS_SUCCESS ) { +if (retval ==STATUS_SUCCESS ) raw_phase_map[i] |=1 << j; - } + } } phase_map = raw_phase_map[0 ] & raw_phase_map[1 ] & raw_phase_map[2 ]; -for (i =0 ; i <3 ; i++) { +for (i =0 ; i <3 ; i++)RTSX_DEBUGP ("RX raw_phase_map[%d] = 0x%08x\n" , i, raw_phase_map[i]); - } +RTSX_DEBUGP ("RX phase_map = 0x%08x\n" , phase_map); final_phase =sd_search_final_phase (chip, phase_map,TUNE_RX ); -if (final_phase ==0xFF ) { +if (final_phase ==0xFF )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_change_phase (chip, final_phase,TUNE_RX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }@@ -1799,15 +1755,14 @@ static int sd_ddr_pre_tuning_tx(struct rtsx_chip *chip) } retval =sd_change_phase (chip, (u8 )i,TUNE_TX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )continue ; - } retval =sd_send_cmd_get_rsp (chip,SEND_STATUS , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ); -if ((retval ==STATUS_SUCCESS ) || !sd_check_err_code (chip,SD_RSP_TIMEOUT )) { +if ((retval ==STATUS_SUCCESS ) || !sd_check_err_code (chip,SD_RSP_TIMEOUT )) phase_map |=1 << i; - } + }RTSX_WRITE_REG (chip,SD_CFG3 ,SD_RSP_80CLK_TIMEOUT_EN ,0 );@@ -1815,14 +1770,12 @@ static int sd_ddr_pre_tuning_tx(struct rtsx_chip *chip)RTSX_DEBUGP ("DDR TX pre tune phase_map = 0x%08x\n" , phase_map); final_phase =sd_search_final_phase (chip, phase_map,TUNE_TX ); -if (final_phase ==0xFF ) { +if (final_phase ==0xFF )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_change_phase (chip, final_phase,TUNE_TX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }RTSX_DEBUGP ("DDR TX pre tune phase: %d\n" , (int )final_phase);@@ -1839,17 +1792,17 @@ static int sd_tuning_tx(struct rtsx_chip *chip)int (*tuning_cmd)(struct rtsx_chip *chip,u8 sample_point);if (CHK_SD (sd_card)) { -if (CHK_SD_DDR50 (sd_card)) { +if (CHK_SD_DDR50 (sd_card)) tuning_cmd = sd_ddr_tuning_tx_cmd; - }else { +else tuning_cmd = sd_sdr_tuning_tx_cmd; - } + }else { -if (CHK_MMC_DDR52 (sd_card)) { +if (CHK_MMC_DDR52 (sd_card)) tuning_cmd = sd_ddr_tuning_tx_cmd; - }else { +else TRACE_RET (chip,STATUS_FAIL ); - } + }for (i =0 ; i <3 ; i++) {@@ -1863,27 +1816,25 @@ static int sd_tuning_tx(struct rtsx_chip *chip) } retval =tuning_cmd (chip, (u8 )j); -if (retval ==STATUS_SUCCESS ) { +if (retval ==STATUS_SUCCESS ) raw_phase_map[i] |=1 << j; - } + } } phase_map = raw_phase_map[0 ] & raw_phase_map[1 ] & raw_phase_map[2 ]; -for (i =0 ; i <3 ; i++) { +for (i =0 ; i <3 ; i++)RTSX_DEBUGP ("TX raw_phase_map[%d] = 0x%08x\n" , i, raw_phase_map[i]); - } +RTSX_DEBUGP ("TX phase_map = 0x%08x\n" , phase_map); final_phase =sd_search_final_phase (chip, phase_map,TUNE_TX ); -if (final_phase ==0xFF ) { +if (final_phase ==0xFF )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_change_phase (chip, final_phase,TUNE_TX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }@@ -1893,14 +1844,12 @@ static int sd_sdr_tuning(struct rtsx_chip *chip)int retval; retval =sd_tuning_tx (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_tuning_rx (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }@@ -1911,26 +1860,25 @@ static int sd_ddr_tuning(struct rtsx_chip *chip)if (!(chip->sd_ctl &SD_DDR_TX_PHASE_SET_BY_USER )) { retval =sd_ddr_pre_tuning_tx (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + }else { retval =sd_change_phase (chip, (u8 )chip->sd_ddr_tx_phase,TUNE_TX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + } retval =sd_tuning_rx (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (!(chip->sd_ctl &SD_DDR_TX_PHASE_SET_BY_USER )) { retval =sd_tuning_tx (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + }return STATUS_SUCCESS ;@@ -1942,26 +1890,25 @@ static int mmc_ddr_tuning(struct rtsx_chip *chip)if (!(chip->sd_ctl &MMC_DDR_TX_PHASE_SET_BY_USER )) { retval =sd_ddr_pre_tuning_tx (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + }else { retval =sd_change_phase (chip, (u8 )chip->mmc_ddr_tx_phase,TUNE_TX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + } retval =sd_tuning_rx (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (!(chip->sd_ctl &MMC_DDR_TX_PHASE_SET_BY_USER )) { retval =sd_tuning_tx (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + }return STATUS_SUCCESS ;@@ -1974,9 +1921,8 @@ int sd_switch_clock(struct rtsx_chip *chip)int re_tuning =0 ; retval =select_card (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (CHECK_PID (chip,0x5209 ) && (CHK_SD30_SPEED (sd_card) ||CHK_MMC_DDR52 (sd_card))) {@@ -1987,26 +1933,25 @@ int sd_switch_clock(struct rtsx_chip *chip) } retval =switch_clock (chip, sd_card->sd_clock); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (re_tuning) {if (CHK_SD (sd_card)) { -if (CHK_SD_DDR50 (sd_card)) { +if (CHK_SD_DDR50 (sd_card)) retval =sd_ddr_tuning (chip); - }else { +else retval =sd_sdr_tuning (chip); - } + }else { -if (CHK_MMC_DDR52 (sd_card)) { +if (CHK_MMC_DDR52 (sd_card)) retval =mmc_ddr_tuning (chip); - } + } -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + }return STATUS_SUCCESS ;@@ -2017,11 +1962,10 @@ static int sd_prepare_reset(struct rtsx_chip *chip)struct sd_info *sd_card = &(chip->sd_card);int retval; -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock =29 ; - }else { +else sd_card->sd_clock =CLK_30 ; - } sd_card->sd_type =0 ; sd_card->seq_mode =0 ;@@ -2037,9 +1981,8 @@ static int sd_prepare_reset(struct rtsx_chip *chip) chip->sd_io =0 ; retval =sd_set_init_para (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip, retval); - }if (CHECK_PID (chip,0x5209 )) { RTSX_WRITE_REG(chip, REG_SD_CFG1, 0xFF,@@ -2053,9 +1996,8 @@ static int sd_prepare_reset(struct rtsx_chip *chip)RTSX_WRITE_REG (chip,CARD_STOP ,SD_STOP |SD_CLR_ERR ,SD_STOP |SD_CLR_ERR ); retval =select_card (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }@@ -2122,9 +2064,8 @@ int sd_pull_ctl_enable(struct rtsx_chip *chip) } retval =rtsx_send_cmd (chip,SD_CARD ,100 ); -if (retval <0 ) { +if (retval <0 )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }@@ -2133,42 +2074,38 @@ static int sd_init_power(struct rtsx_chip *chip) {int retval; -if (CHECK_PID (chip,0x5209 )) { +if (CHECK_PID (chip,0x5209 ))RTSX_WRITE_REG (chip,PWR_GATE_CTRL ,LDO3318_PWR_MASK ,LDO_OFF ); - } retval =sd_power_off_card3v3 (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } -if (!chip->ft2_fast_mode) { +if (!chip->ft2_fast_mode)wait_timeout (250 ); - } retval =enable_card_clock (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (chip->asic_code) { retval =sd_pull_ctl_enable (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + }else {RTSX_WRITE_REG (chip,FPGA_PULL_CTL ,FPGA_SD_PULL_CTL_BIT |0x20 ,0 ); }if (chip->ft2_fast_mode) { -if (CHECK_PID (chip,0x5209 )) { +if (CHECK_PID (chip,0x5209 ))RTSX_WRITE_REG (chip,PWR_GATE_CTRL ,LDO3318_PWR_MASK ,LDO_ON ); - } + }else { retval =card_power_on (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } +wait_timeout (260 );#ifdef SUPPORT_OCP @@ -2214,13 +2151,13 @@ static int sd_read_lba0(struct rtsx_chip *chip)if (CHK_SD (sd_card)) { bus_width =SD_BUS_WIDTH_4 ; }else { -if (CHK_MMC_8BIT (sd_card)) { +if (CHK_MMC_8BIT (sd_card)) bus_width =SD_BUS_WIDTH_8 ; - }else if (CHK_MMC_4BIT (sd_card)) { +else if (CHK_MMC_4BIT (sd_card)) bus_width =SD_BUS_WIDTH_4 ; - }else { +else bus_width =SD_BUS_WIDTH_1 ; - } + } retval = sd_read_data(chip, SD_TM_NORMAL_READ, cmd,@@ -2243,9 +2180,8 @@ static int sd_check_wp_state(struct rtsx_chip *chip) retval =sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } cmd[0 ] =0x40 |SD_STATUS ; cmd[1 ] =0 ;@@ -2273,9 +2209,8 @@ static int sd_check_wp_state(struct rtsx_chip *chip)/* Check SD Machanical Write-Protect Switch */ val =rtsx_readl (chip,RTSX_BIPR ); -if (val &SD_WRITE_PROTECT ) { +if (val &SD_WRITE_PROTECT ) chip->card_wp |=SD_CARD ; - }return STATUS_SUCCESS ; }@@ -2307,14 +2242,12 @@ Switch_Fail:#endif retval =sd_prepare_reset (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_dummy_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (CHK_SDIO_EXIST (chip) && !CHK_SDIO_IGNORED (chip) && try_sdio) {int rty_cnt =0 ;@@ -2348,9 +2281,8 @@ Switch_Fail:/* Start Initialization Process of SD Card */ RTY_SD_RST: retval =sd_send_cmd_get_rsp (chip,GO_IDLE_STATE ,0 ,SD_RSP_TYPE_R0 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }wait_timeout (20 );@@ -2377,9 +2309,8 @@ RTY_SD_RST: voltage =SUPPORT_VOLTAGE ; retval =sd_send_cmd_get_rsp (chip,GO_IDLE_STATE ,0 ,SD_RSP_TYPE_R0 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }wait_timeout (20 ); }@@ -2393,42 +2324,41 @@ RTY_SD_RST: } j++; -if (j <3 ) { +if (j <3 ) goto RTY_SD_RST; - }else { +else TRACE_RET (chip,STATUS_FAIL ); - } + } retval =sd_send_cmd_get_rsp (chip,SD_APP_OP_COND , voltage,SD_RSP_TYPE_R3 , rsp,5 );if (retval !=STATUS_SUCCESS ) { k++; -if (k <3 ) { +if (k <3 ) goto RTY_SD_RST; - }else { +else TRACE_RET (chip,STATUS_FAIL ); - } + } i++;wait_timeout (20 ); }while (!(rsp[1 ] &0x80 ) && (i <255 )); -if (i ==255 ) { +if (i ==255 )TRACE_RET (chip,STATUS_FAIL ); - }if (hi_cap_flow) { -if (rsp[1 ] &0x40 ) { +if (rsp[1 ] &0x40 )SET_SD_HCXC (sd_card); - }else { +else CLR_SD_HCXC (sd_card); - } -if (CHECK_PID (chip,0x5209 ) &&CHK_SD_HCXC (sd_card) && !sd20_mode) { + +if (CHECK_PID (chip,0x5209 ) &&CHK_SD_HCXC (sd_card) && !sd20_mode) support_1v8 = (rsp[1 ] &0x01 ) ?1 :0 ; - }else { +else support_1v8 =0 ; - } + }else {CLR_SD_HCXC (sd_card); support_1v8 =0 ;@@ -2437,46 +2367,40 @@ RTY_SD_RST:if (support_1v8) { retval =sd_voltage_switch (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } } retval =sd_send_cmd_get_rsp (chip,ALL_SEND_CID ,0 ,SD_RSP_TYPE_R2 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }for (i =0 ; i <3 ; i++) { retval =sd_send_cmd_get_rsp (chip,SEND_RELATIVE_ADDR ,0 ,SD_RSP_TYPE_R6 , rsp,5 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } sd_card->sd_addr = (u32 )rsp[1 ] <<24 ; sd_card->sd_addr += (u32 )rsp[2 ] <<16 ; -if (sd_card->sd_addr) { +if (sd_card->sd_addr)break ; - } + } retval =sd_check_csd (chip,1 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_select_card (chip,1 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }#ifdef SUPPORT_SD_LOCK SD_UNLOCK_ENTRY: retval =sd_update_lock_status (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (sd_card->sd_lock_status &SD_LOCKED ) { sd_card->sd_lock_status |= (SD_LOCK_1BIT_MODE |SD_PWD_EXIST );@@ -2487,23 +2411,21 @@ SD_UNLOCK_ENTRY:#endif retval =sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + retval =sd_send_cmd_get_rsp (chip,SET_CLR_CARD_DETECT ,0 ,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (support_1v8) { retval =sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + retval =sd_send_cmd_get_rsp (chip,SET_BUS_WIDTH ,2 ,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } switch_bus_width =SD_BUS_WIDTH_4 ; }else {@@ -2511,14 +2433,12 @@ SD_UNLOCK_ENTRY: } retval =sd_send_cmd_get_rsp (chip,SET_BLOCKLEN ,0x200 ,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_set_clock_divider (chip,SD_CLK_DIVIDE_0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (!(sd_card->raw_csd[4 ] &0x40 )) sd_dont_switch =1 ;@@ -2537,9 +2457,9 @@ SD_UNLOCK_ENTRY:if (retval ==STATUS_SUCCESS ) { retval =sd_switch_function (chip, switch_bus_width);if (retval !=STATUS_SUCCESS ) { -if (CHECK_PID (chip,0x5209 )) { +if (CHECK_PID (chip,0x5209 ))sd_change_bank_voltage (chip,SD_IO_3V3 ); - } +sd_init_power (chip); sd_dont_switch =1 ; try_sdio =0 ;@@ -2548,9 +2468,9 @@ SD_UNLOCK_ENTRY: } }else {if (support_1v8) { -if (CHECK_PID (chip,0x5209 )) { +if (CHECK_PID (chip,0x5209 ))sd_change_bank_voltage (chip,SD_IO_3V3 ); - } +sd_init_power (chip); sd_dont_switch =1 ; try_sdio =0 ;@@ -2562,13 +2482,13 @@ SD_UNLOCK_ENTRY:if (!support_1v8) { retval =sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + retval =sd_send_cmd_get_rsp (chip,SET_BUS_WIDTH ,2 ,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + }#ifdef SUPPORT_SD_LOCK @@ -2581,24 +2501,22 @@ SD_UNLOCK_ENTRY:RTSX_WRITE_REG (chip,SD30_DRIVE_SEL ,0x07 , chip->sd30_drive_sel_1v8); retval =sd_set_init_para (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } -if (CHK_SD_DDR50 (sd_card)) { +if (CHK_SD_DDR50 (sd_card)) retval =sd_ddr_tuning (chip); - }else { +else retval =sd_sdr_tuning (chip); - }if (retval !=STATUS_SUCCESS ) {if (sd20_mode) {TRACE_RET (chip,STATUS_FAIL ); }else { retval =sd_init_power (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + try_sdio =0 ; sd20_mode =1 ; goto Switch_Fail;@@ -2609,9 +2527,9 @@ SD_UNLOCK_ENTRY:if (CHK_SD_DDR50 (sd_card)) { retval =sd_wait_state_data_ready (chip,0x08 ,1 ,1000 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS ) read_lba0 =0 ; - } + }if (read_lba0) {@@ -2621,9 +2539,9 @@ SD_UNLOCK_ENTRY:TRACE_RET (chip,STATUS_FAIL ); }else { retval =sd_init_power (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + try_sdio =0 ; sd20_mode =1 ; goto Switch_Fail;@@ -2633,9 +2551,8 @@ SD_UNLOCK_ENTRY: } retval =sd_check_wp_state (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } chip->card_bus_width[chip->card2lun[SD_CARD ]] =4 ;@@ -2659,9 +2576,8 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width)int len; retval =sd_send_cmd_get_rsp (chip,BUSTEST_W ,0 ,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,SWITCH_FAIL ); - }if (width ==MMC_8BIT_BUS ) { buf[0 ] =0x55 ;@@ -2690,9 +2606,9 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width)rtsx_read_register (chip,REG_SD_STAT1 , &val1);rtsx_read_register (chip,REG_SD_STAT2 , &val2);rtsx_clear_sd_error (chip); -if ((val1 &0xE0 ) || val2) { +if ((val1 &0xE0 ) || val2)TRACE_RET (chip,SWITCH_ERR ); - } + }else {rtsx_clear_sd_error (chip);rtsx_write_register (chip,REG_SD_CFG3 ,0x02 ,0 );@@ -2712,11 +2628,10 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width)rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CMD0 ,0xFF ,0x40 |BUSTEST_R ); -if (width ==MMC_8BIT_BUS ) { +if (width ==MMC_8BIT_BUS )rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_BYTE_CNT_L ,0xFF ,0x08 ); - }else { +else rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_BYTE_CNT_L ,0xFF ,0x04 ); - }rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_BLOCK_CNT_L ,0xFF ,1 );rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_BLOCK_CNT_H ,0xFF ,0 );@@ -2729,15 +2644,13 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width)rtsx_add_cmd (chip,CHECK_REG_CMD ,REG_SD_TRANSFER ,SD_TRANSFER_END ,SD_TRANSFER_END );rtsx_add_cmd (chip,READ_REG_CMD ,PPBUF_BASE2 ,0 ,0 ); -if (width ==MMC_8BIT_BUS ) { +if (width ==MMC_8BIT_BUS )rtsx_add_cmd (chip,READ_REG_CMD ,PPBUF_BASE2 +1 ,0 ,0 ); - } retval =rtsx_send_cmd (chip,SD_CARD ,100 ); -if (retval <0 ) { +if (retval <0 )rtsx_clear_sd_error (chip);TRACE_RET (chip,SWITCH_ERR ); - } ptr =rtsx_get_cmd_data (chip) +1 ;@@ -2747,15 +2660,15 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width)u8 rsp[5 ];u32 arg; -if (CHK_MMC_DDR52 (sd_card)) { +if (CHK_MMC_DDR52 (sd_card)) arg =0x03B70600 ; - }else { +else arg =0x03B70200 ; - } + retval =sd_send_cmd_get_rsp (chip,SWITCH , arg, SD_RSP_TYPE_R1b, rsp,5 ); -if ((retval ==STATUS_SUCCESS ) && !(rsp[4 ] &MMC_SWITCH_ERR )) { +if ((retval ==STATUS_SUCCESS ) && !(rsp[4 ] &MMC_SWITCH_ERR ))return SWITCH_SUCCESS ; - } + } }else {RTSX_DEBUGP ("BUSTEST_R [4bits]: 0x%02x\n" , ptr[0 ]);@@ -2763,15 +2676,15 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width)u8 rsp[5 ];u32 arg; -if (CHK_MMC_DDR52 (sd_card)) { +if (CHK_MMC_DDR52 (sd_card)) arg =0x03B70500 ; - }else { +else arg =0x03B70100 ; - } + retval =sd_send_cmd_get_rsp (chip,SWITCH , arg, SD_RSP_TYPE_R1b, rsp,5 ); -if ((retval ==STATUS_SUCCESS ) && !(rsp[4 ] &MMC_SWITCH_ERR )) { +if ((retval ==STATUS_SUCCESS ) && !(rsp[4 ] &MMC_SWITCH_ERR ))return SWITCH_SUCCESS ; - } + } }@@ -2845,11 +2758,10 @@ static int mmc_switch_timing_bus(struct rtsx_chip *chip, int switch_ddr) card_type_mask = 0x03; }#else -if (chip->sd_ctl &SUPPORT_MMC_DDR_MODE ) { +if (chip->sd_ctl &SUPPORT_MMC_DDR_MODE ) card_type_mask =0x07 ; - }else { +else card_type_mask =0x03 ; - }#endif }else { card_type_mask =0x03 ;@@ -2859,11 +2771,11 @@ static int mmc_switch_timing_bus(struct rtsx_chip *chip, int switch_ddr)u8 rsp[5 ];if (card_type &0x04 ) { -if (switch_ddr) { +if (switch_ddr)SET_MMC_DDR52 (sd_card); - }else { +else SET_MMC_52M (sd_card); - } + }else if (card_type &0x02 ) {SET_MMC_52M (sd_card); }else {@@ -2872,16 +2784,15 @@ static int mmc_switch_timing_bus(struct rtsx_chip *chip, int switch_ddr) retval =sd_send_cmd_get_rsp (chip,SWITCH ,0x03B90100 , SD_RSP_TYPE_R1b, rsp,5 ); -if ((retval !=STATUS_SUCCESS ) || (rsp[4 ] &MMC_SWITCH_ERR )) { +if ((retval !=STATUS_SUCCESS ) || (rsp[4 ] &MMC_SWITCH_ERR ))CLR_MMC_HS (sd_card); - } + }sd_choose_proper_clock (chip); retval =switch_clock (chip, sd_card->sd_clock); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }/* Test Bus Procedure */ retval =mmc_test_switch_bus (chip,MMC_8BIT_BUS );@@ -2929,17 +2840,15 @@ static int reset_mmc(struct rtsx_chip *chip) Switch_Fail: retval =sd_prepare_reset (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip, retval); - }SET_MMC (sd_card); RTY_MMC_RST: retval =sd_send_cmd_get_rsp (chip,GO_IDLE_STATE ,0 ,SD_RSP_TYPE_R0 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { -TRACE_RET (chip,STATUS_FAIL ); - } +if (retval !=STATUS_SUCCESS ) +TRACE_RET (chip,STATUS_FAIL ); do { if (detect_card_cd(chip, SD_CARD) != STATUS_SUCCESS) {@@ -2973,56 +2882,47 @@ RTY_MMC_RST: i++; }while (!(rsp[1 ] &0x80 ) && (i <255 )); -if (i ==255 ) { +if (i ==255 )TRACE_RET (chip,STATUS_FAIL ); - } -if ((rsp[1 ] &0x60 ) ==0x40 ) { +if ((rsp[1 ] &0x60 ) ==0x40 )SET_MMC_SECTOR_MODE (sd_card); - }else { +else CLR_MMC_SECTOR_MODE (sd_card); - } retval =sd_send_cmd_get_rsp (chip,ALL_SEND_CID ,0 ,SD_RSP_TYPE_R2 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } sd_card->sd_addr =0x00100000 ; retval =sd_send_cmd_get_rsp (chip,SET_RELATIVE_ADDR , sd_card->sd_addr,SD_RSP_TYPE_R6 , rsp,5 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_check_csd (chip,1 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } spec_ver = (sd_card->raw_csd[0 ] &0x3C ) >>2 ; retval =sd_select_card (chip,1 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_send_cmd_get_rsp (chip,SET_BLOCKLEN ,0x200 ,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }#ifdef SUPPORT_SD_LOCK MMC_UNLOCK_ENTRY: retval =sd_update_lock_status (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }#endif retval =sd_set_clock_divider (chip,SD_CLK_DIVIDE_0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } chip->card_bus_width[chip->card2lun[SD_CARD ]] =1 ;@@ -3039,22 +2939,20 @@ MMC_UNLOCK_ENTRY: } } -if (CHK_MMC_SECTOR_MODE (sd_card) && (sd_card->capacity ==0 )) { +if (CHK_MMC_SECTOR_MODE (sd_card) && (sd_card->capacity ==0 ))TRACE_RET (chip,STATUS_FAIL ); - }if (switch_ddr &&CHK_MMC_DDR52 (sd_card)) { retval =sd_set_init_para (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =mmc_ddr_tuning (chip);if (retval !=STATUS_SUCCESS ) { retval =sd_init_power (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + switch_ddr =0 ;TRACE_GOTO (chip, Switch_Fail); }@@ -3064,9 +2962,9 @@ MMC_UNLOCK_ENTRY: retval =sd_read_lba0 (chip);if (retval !=STATUS_SUCCESS ) { retval =sd_init_power (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + switch_ddr =0 ;TRACE_GOTO (chip, Switch_Fail); }@@ -3082,9 +2980,8 @@ MMC_UNLOCK_ENTRY:#endif temp =rtsx_readl (chip,RTSX_BIPR ); -if (temp &SD_WRITE_PROTECT ) { +if (temp &SD_WRITE_PROTECT ) chip->card_wp |=SD_CARD ; - }return STATUS_SUCCESS ; }@@ -3100,36 +2997,33 @@ int reset_sd_card(struct rtsx_chip *chip) chip->capacity[chip->card2lun[SD_CARD ]] =0 ; retval =enable_card_clock (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (chip->ignore_sd &&CHK_SDIO_EXIST (chip) && !CHK_SDIO_IGNORED (chip)) {if (chip->asic_code) { retval =sd_pull_ctl_enable (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + }else { retval =rtsx_write_register (chip,FPGA_PULL_CTL ,FPGA_SD_PULL_CTL_BIT |0x20 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + } retval =card_share_mode (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } chip->sd_io =1 ;TRACE_RET (chip,STATUS_FAIL ); } retval =sd_init_power (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (chip->sd_ctl &RESET_MMC_FIRST ) { retval =reset_mmc (chip);@@ -3168,18 +3062,17 @@ int reset_sd_card(struct rtsx_chip *chip) } retval =sd_set_clock_divider (chip,SD_CLK_DIVIDE_0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } +RTSX_WRITE_REG (chip,REG_SD_BYTE_CNT_L ,0xFF ,0 );RTSX_WRITE_REG (chip,REG_SD_BYTE_CNT_H ,0xFF ,2 ); chip->capacity[chip->card2lun[SD_CARD ]] = sd_card->capacity; retval =sd_set_init_para (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }RTSX_DEBUGP ("sd_card->sd_type = 0x%x\n" , sd_card->sd_type);@@ -3205,33 +3098,29 @@ static int reset_mmc_only(struct rtsx_chip *chip) chip->capacity[chip->card2lun[SD_CARD ]] = sd_card->capacity =0 ; retval =enable_card_clock (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_init_power (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =reset_mmc (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_set_clock_divider (chip,SD_CLK_DIVIDE_0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } +RTSX_WRITE_REG (chip,REG_SD_BYTE_CNT_L ,0xFF ,0 );RTSX_WRITE_REG (chip,REG_SD_BYTE_CNT_H ,0xFF ,2 ); chip->capacity[chip->card2lun[SD_CARD ]] = sd_card->capacity; retval =sd_set_init_para (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }RTSX_DEBUGP ("In reset_mmc_only, sd_card->sd_type = 0x%x\n" , sd_card->sd_type);@@ -3255,9 +3144,8 @@ static int wait_data_buf_ready(struct rtsx_chip *chip) retval =sd_send_cmd_get_rsp (chip,SEND_STATUS , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (sd_card->sd_data_buf_ready) { return sd_send_cmd_get_rsp(chip, SEND_STATUS,@@ -3277,19 +3165,18 @@ void sd_stop_seq_mode(struct rtsx_chip *chip)if (sd_card->seq_mode) { retval =sd_switch_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )return ; - } retval =sd_send_cmd_get_rsp (chip,STOP_TRANSMISSION ,0 , SD_RSP_TYPE_R1b,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )sd_set_err_code (chip,SD_STS_ERR ); - } + retval =sd_wait_state_data_ready (chip,0x08 ,1 ,1000 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )sd_set_err_code (chip,SD_STS_ERR ); - } + sd_card->seq_mode =0 ;rtsx_write_register (chip,RBCTL ,RB_FLUSH ,RB_FLUSH );@@ -3302,9 +3189,9 @@ static inline int sd_auto_tune_clock(struct rtsx_chip *chip)int retval;if (chip->asic_code) { -if (sd_card->sd_clock >30 ) { +if (sd_card->sd_clock >30 ) sd_card->sd_clock -=20 ; - } + }else {switch (sd_card->sd_clock) {case CLK_200 :@@ -3337,9 +3224,8 @@ static inline int sd_auto_tune_clock(struct rtsx_chip *chip) } retval =sd_switch_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }@@ -3377,11 +3263,10 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, u16 s } } -if (!CHK_SD_HCXC (sd_card) && !CHK_MMC_SECTOR_MODE (sd_card)) { +if (!CHK_SD_HCXC (sd_card) && !CHK_MMC_SECTOR_MODE (sd_card)) data_addr = start_sector <<9 ; - }else { +else data_addr = start_sector; - }sd_clr_err_code (chip);@@ -3436,21 +3321,20 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, u16 srtsx_add_cmd (chip,WRITE_REG_CMD ,CARD_DATA_SOURCE ,0x01 ,RING_BUFFER ); -if (CHK_MMC_8BIT (sd_card)) { +if (CHK_MMC_8BIT (sd_card))rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_8 ); - }else if (CHK_MMC_4BIT (sd_card) ||CHK_SD (sd_card)) { +else if (CHK_MMC_4BIT (sd_card) ||CHK_SD (sd_card))rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_4 ); - }else { +else rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_1 ); - }if (sd_card->seq_mode) { cfg2 =SD_NO_CALCULATE_CRC7 |SD_CHECK_CRC16 |SD_NO_WAIT_BUSY_END |SD_NO_CHECK_CRC7 |SD_RSP_LEN_0 ;if (CHECK_PID (chip,0x5209 )) { -if (!CHK_SD30_SPEED (sd_card)) { +if (!CHK_SD30_SPEED (sd_card)) cfg2 |=SD_NO_CHECK_WAIT_CRC_TO ; - } + }rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CFG2 ,0xFF , cfg2);@@ -3480,9 +3364,9 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, u16 s cfg2 =SD_CALCULATE_CRC7 |SD_CHECK_CRC16 |SD_NO_WAIT_BUSY_END |SD_CHECK_CRC7 |SD_RSP_LEN_6 ;if (CHECK_PID (chip,0x5209 )) { -if (!CHK_SD30_SPEED (sd_card)) { +if (!CHK_SD30_SPEED (sd_card)) cfg2 |=SD_NO_CHECK_WAIT_CRC_TO ; - } + }rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CFG2 ,0xFF , cfg2);@@ -3523,9 +3407,9 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, u16 s cfg2 =SD_NO_CALCULATE_CRC7 |SD_CHECK_CRC16 |SD_NO_WAIT_BUSY_END |SD_NO_CHECK_CRC7 |SD_RSP_LEN_0 ;if (CHECK_PID (chip,0x5209 )) { -if (!CHK_SD30_SPEED (sd_card)) { +if (!CHK_SD30_SPEED (sd_card)) cfg2 |=SD_NO_CHECK_WAIT_CRC_TO ; - } + }rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CFG2 ,0xFF , cfg2);@@ -3550,11 +3434,10 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, u16 s sd_card->seq_mode =0 ; -if (retval == -ETIMEDOUT ) { +if (retval == -ETIMEDOUT ) err =STATUS_TIMEDOUT ; - }else { +else err =STATUS_FAIL ; - }rtsx_read_register (chip,REG_SD_STAT1 , &stat);rtsx_clear_sd_error (chip);@@ -3640,9 +3523,8 @@ int ext_sd_send_cmd_get_rsp(struct rtsx_chip *chip, u8 cmd_idx,RTSX_DEBUGP ("EXT SD/MMC CMD %d\n" , cmd_idx); -if (rsp_type == SD_RSP_TYPE_R1b) { +if (rsp_type == SD_RSP_TYPE_R1b) timeout =3000 ; - } RTY_SEND_CMD:@@ -3662,14 +3544,14 @@ RTY_SEND_CMD:rtsx_add_cmd (chip,CHECK_REG_CMD ,REG_SD_TRANSFER ,SD_TRANSFER_END ,SD_TRANSFER_END );if (rsp_type ==SD_RSP_TYPE_R2 ) { -for (reg_addr =PPBUF_BASE2 ; reg_addr <PPBUF_BASE2 +16 ; reg_addr++) { +for (reg_addr =PPBUF_BASE2 ; reg_addr <PPBUF_BASE2 +16 ; reg_addr++)rtsx_add_cmd (chip,READ_REG_CMD , reg_addr,0 ,0 ); - } + stat_idx =17 ; }else if (rsp_type !=SD_RSP_TYPE_R0 ) { -for (reg_addr =REG_SD_CMD0 ; reg_addr <=REG_SD_CMD4 ; reg_addr++) { +for (reg_addr =REG_SD_CMD0 ; reg_addr <=REG_SD_CMD4 ; reg_addr++)rtsx_add_cmd (chip,READ_REG_CMD , reg_addr,0 ,0 ); - } + stat_idx =6 ; }rtsx_add_cmd (chip,READ_REG_CMD ,REG_SD_CMD5 ,0 ,0 );@@ -3683,9 +3565,9 @@ RTY_SEND_CMD:if (rsp_type &SD_WAIT_BUSY_END ) { retval =sd_check_data0_status (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip, retval); - } + }else {sd_set_err_code (chip,SD_TO_ERR ); }@@ -3693,9 +3575,8 @@ RTY_SEND_CMD:TRACE_RET (chip,STATUS_FAIL ); } -if (rsp_type ==SD_RSP_TYPE_R0 ) { +if (rsp_type ==SD_RSP_TYPE_R0 )return STATUS_SUCCESS ; - } ptr =rtsx_get_cmd_data (chip) +1 ;@@ -3724,9 +3605,9 @@ RTY_SEND_CMD:if ((cmd_idx ==SELECT_CARD ) || (cmd_idx ==APP_CMD ) || (cmd_idx ==SEND_STATUS ) || (cmd_idx ==STOP_TRANSMISSION )) {if ((cmd_idx !=STOP_TRANSMISSION ) && (special_check ==0 )) { -if (ptr[1 ] &0x80 ) { +if (ptr[1 ] &0x80 )TRACE_RET (chip,STATUS_FAIL ); - } + }#ifdef SUPPORT_SD_LOCK if (ptr[1 ] &0x7D )@@ -3736,26 +3617,24 @@ RTY_SEND_CMD: {TRACE_RET (chip,STATUS_FAIL ); } -if (ptr[2 ] &0xF8 ) { +if (ptr[2 ] &0xF8 )TRACE_RET (chip,STATUS_FAIL ); - }if (cmd_idx ==SELECT_CARD ) {if (rsp_type ==SD_RSP_TYPE_R2 ) { -if ((ptr[3 ] &0x1E ) !=0x04 ) { +if ((ptr[3 ] &0x1E ) !=0x04 )TRACE_RET (chip,STATUS_FAIL ); - } + }else if (rsp_type ==SD_RSP_TYPE_R0 ) { -if ((ptr[3 ] &0x1E ) !=0x03 ) { +if ((ptr[3 ] &0x1E ) !=0x03 )TRACE_RET (chip,STATUS_FAIL ); - } + } } } -if (rsp && rsp_len) { +if (rsp && rsp_len)memcpy (rsp, ptr, rsp_len); - }return STATUS_SUCCESS ; }@@ -3765,29 +3644,27 @@ int ext_sd_get_rsp(struct rtsx_chip *chip, int len, u8 *rsp, u8 rsp_type)int retval, rsp_len;u16 reg_addr; -if (rsp_type ==SD_RSP_TYPE_R0 ) { +if (rsp_type ==SD_RSP_TYPE_R0 )return STATUS_SUCCESS ; - }rtsx_init_cmd (chip);if (rsp_type ==SD_RSP_TYPE_R2 ) { -for (reg_addr =PPBUF_BASE2 ; reg_addr <PPBUF_BASE2 +16 ; reg_addr++) { +for (reg_addr =PPBUF_BASE2 ; reg_addr <PPBUF_BASE2 +16 ; reg_addr++)rtsx_add_cmd (chip,READ_REG_CMD , reg_addr,0xFF ,0 ); - } + rsp_len =17 ; }else if (rsp_type !=SD_RSP_TYPE_R0 ) { -for (reg_addr =REG_SD_CMD0 ; reg_addr <=REG_SD_CMD4 ; reg_addr++) { +for (reg_addr =REG_SD_CMD0 ; reg_addr <=REG_SD_CMD4 ; reg_addr++)rtsx_add_cmd (chip,READ_REG_CMD , reg_addr,0xFF ,0 ); - } + rsp_len =6 ; }rtsx_add_cmd (chip,READ_REG_CMD ,REG_SD_CMD5 ,0xFF ,0 ); retval =rtsx_send_cmd (chip,SD_CARD ,100 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (rsp) {int min_len = (rsp_len < len) ? rsp_len : len;@@ -3858,9 +3735,8 @@ int sd_pass_thru_mode(struct scsi_cmnd *srb, struct rtsx_chip *chip) } buf[5 ] = (1 ==CHK_SD (sd_card)) ?0x01 :0x02 ; -if (chip->card_wp &SD_CARD ) { +if (chip->card_wp &SD_CARD ) buf[5 ] |=0x80 ; - } buf[6 ] = (u8)(sd_card->sd_addr >>16 ); buf[7 ] = (u8)(sd_card->sd_addr >>24 );@@ -3875,9 +3751,8 @@ int sd_pass_thru_mode(struct scsi_cmnd *srb, struct rtsx_chip *chip)static inline int get_rsp_type (struct scsi_cmnd *srb,u8 *rsp_type,int *rsp_len) { -if (!rsp_type || !rsp_len) { +if (!rsp_type || !rsp_len)return STATUS_FAIL ; - }switch (srb->cmnd[10 ]) {case 0x03 :@@ -3927,9 +3802,8 @@ int sd_execute_no_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) } retval =sd_switch_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - }if (sd_card->pre_cmd_err) { sd_card->pre_cmd_err =0 ;@@ -3938,12 +3812,11 @@ int sd_execute_no_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) } cmd_idx = srb->cmnd[2 ] &0x3F ; -if (srb->cmnd[1 ] &0x02 ) { +if (srb->cmnd[1 ] &0x02 ) standby =1 ; - } -if (srb->cmnd[1 ] &0x01 ) { + +if (srb->cmnd[1 ] &0x01 ) acmd =1 ; - } arg = ((u32 )srb->cmnd[3 ] <<24 ) | ((u32 )srb->cmnd[4 ] <<16 ) | ((u32 )srb->cmnd[5 ] <<8 ) | srb->cmnd[6 ];@@ -3956,64 +3829,58 @@ int sd_execute_no_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) sd_card->last_rsp_type = rsp_type; retval =sd_switch_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - }#ifdef SUPPORT_SD_LOCK if ((sd_card->sd_lock_status &SD_LOCK_1BIT_MODE ) ==0 ) {if (CHK_MMC_8BIT (sd_card)) { retval =rtsx_write_register (chip,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_8 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - } + }else if (CHK_SD (sd_card) ||CHK_MMC_4BIT (sd_card)) { retval =rtsx_write_register (chip,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_4 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - } + } }#else retval =rtsx_write_register (chip,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_4 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - } +#endif if (standby) { retval =sd_select_card (chip,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Cmd_Failed); - } }if (acmd) { retval =ext_sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Cmd_Failed); - } } retval =ext_sd_send_cmd_get_rsp (chip, cmd_idx, arg, rsp_type, sd_card->rsp, rsp_len,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Cmd_Failed); - }if (standby) { retval =sd_select_card (chip,1 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Cmd_Failed); - } }#ifdef SUPPORT_SD_LOCK retval =sd_update_lock_status (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Cmd_Failed); - }#endif scsi_set_resid (srb,0 );@@ -4024,9 +3891,8 @@ SD_Execute_Cmd_Failed:set_sense_type (chip, lun,SENSE_TYPE_NO_SENSE );release_sd_card (chip);do_reset_sd_card (chip); -if (!(chip->card_ready &SD_CARD )) { +if (!(chip->card_ready &SD_CARD ))set_sense_type (chip, lun,SENSE_TYPE_MEDIA_NOT_PRESENT ); - }TRACE_RET (chip,TRANSPORT_FAILED ); }@@ -4053,20 +3919,18 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) } retval =sd_switch_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - } cmd_idx = srb->cmnd[2 ] &0x3F ; -if (srb->cmnd[1 ] &0x04 ) { +if (srb->cmnd[1 ] &0x04 ) send_cmd12 =1 ; - } -if (srb->cmnd[1 ] &0x02 ) { + +if (srb->cmnd[1 ] &0x02 ) standby =1 ; - } -if (srb->cmnd[1 ] &0x01 ) { + +if (srb->cmnd[1 ] &0x01 ) acmd =1 ; - } data_len = ((u32 )srb->cmnd[7 ] <<16 ) | ((u32 )srb->cmnd[8 ] <<8 ) | srb->cmnd[9 ];@@ -4078,19 +3942,18 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) sd_card->last_rsp_type = rsp_type; retval =sd_switch_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - }#ifdef SUPPORT_SD_LOCK if ((sd_card->sd_lock_status &SD_LOCK_1BIT_MODE ) ==0 ) { -if (CHK_MMC_8BIT (sd_card)) { +if (CHK_MMC_8BIT (sd_card)) bus_width =SD_BUS_WIDTH_8 ; - }else if (CHK_SD (sd_card) ||CHK_MMC_4BIT (sd_card)) { +else if (CHK_SD (sd_card) ||CHK_MMC_4BIT (sd_card)) bus_width =SD_BUS_WIDTH_4 ; - }else { +else bus_width =SD_BUS_WIDTH_1 ; - } + }else { bus_width =SD_BUS_WIDTH_4 ; }@@ -4102,24 +3965,21 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)if (data_len <512 ) { retval =ext_sd_send_cmd_get_rsp (chip,SET_BLOCKLEN , data_len,SD_RSP_TYPE_R1 ,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - } }if (standby) { retval =sd_select_card (chip,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - } }if (acmd) { retval =ext_sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - } }if (data_len <=512 ) {@@ -4138,9 +3998,8 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) cmd[4 ] = srb->cmnd[6 ]; buf =kmalloc (data_len,GFP_KERNEL ); -if (buf ==NULL ) { +if (buf ==NULL )TRACE_RET (chip,TRANSPORT_ERROR ); - } retval =sd_read_data (chip,SD_TM_NORMAL_READ , cmd,5 , byte_cnt, blk_cnt, bus_width, buf, data_len,2000 );@@ -4195,56 +4054,48 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) } retval =ext_sd_get_rsp (chip, rsp_len, sd_card->rsp, rsp_type); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - }if (standby) { retval =sd_select_card (chip,1 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - } }if (send_cmd12) { retval =ext_sd_send_cmd_get_rsp (chip,STOP_TRANSMISSION ,0 , SD_RSP_TYPE_R1b,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - } }if (data_len <512 ) { retval =ext_sd_send_cmd_get_rsp (chip,SET_BLOCKLEN ,0x200 ,SD_RSP_TYPE_R1 ,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - } retval =rtsx_write_register (chip,SD_BYTE_CNT_H ,0xFF ,0x02 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - } + retval =rtsx_write_register (chip,SD_BYTE_CNT_L ,0xFF ,0x00 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - } } -if ((srb->cmnd[1 ] &0x02 ) || (srb->cmnd[1 ] &0x04 )) { +if ((srb->cmnd[1 ] &0x02 ) || (srb->cmnd[1 ] &0x04 )) cmd13_checkbit =1 ; - }for (i =0 ; i <3 ; i++) { retval =ext_sd_send_cmd_get_rsp (chip,SEND_STATUS , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 , cmd13_checkbit); -if (retval ==STATUS_SUCCESS ) { +if (retval ==STATUS_SUCCESS )break ; - } } -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - }scsi_set_resid (srb,0 );return TRANSPORT_GOOD ;@@ -4252,14 +4103,13 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) SD_Execute_Read_Cmd_Failed: sd_card->pre_cmd_err =1 ;set_sense_type (chip, lun,SENSE_TYPE_NO_SENSE ); -if (read_err) { +if (read_err)set_sense_type (chip, lun,SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR ); - } +release_sd_card (chip);do_reset_sd_card (chip); -if (!(chip->card_ready &SD_CARD )) { +if (!(chip->card_ready &SD_CARD ))set_sense_type (chip, lun,SENSE_TYPE_MEDIA_NOT_PRESENT ); - }TRACE_RET (chip,TRANSPORT_FAILED ); }@@ -4291,20 +4141,18 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) } retval =sd_switch_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - } cmd_idx = srb->cmnd[2 ] &0x3F ; -if (srb->cmnd[1 ] &0x04 ) { +if (srb->cmnd[1 ] &0x04 ) send_cmd12 =1 ; - } -if (srb->cmnd[1 ] &0x02 ) { + +if (srb->cmnd[1 ] &0x02 ) standby =1 ; - } -if (srb->cmnd[1 ] &0x01 ) { + +if (srb->cmnd[1 ] &0x01 ) acmd =1 ; - } data_len = ((u32 )srb->cmnd[7 ] <<16 ) | ((u32 )srb->cmnd[8 ] <<8 ) | srb->cmnd[9 ]; arg = ((u32)srb->cmnd[3] << 24) | ((u32)srb->cmnd[4] << 16) |@@ -4325,75 +4173,68 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) sd_card->last_rsp_type = rsp_type; retval =sd_switch_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - }#ifdef SUPPORT_SD_LOCK if ((sd_card->sd_lock_status &SD_LOCK_1BIT_MODE ) ==0 ) {if (CHK_MMC_8BIT (sd_card)) { retval =rtsx_write_register (chip,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_8 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - } + }else if (CHK_SD (sd_card) ||CHK_MMC_4BIT (sd_card)) { retval =rtsx_write_register (chip,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_4 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - } + } }#else retval =rtsx_write_register (chip,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_4 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - } +#endif if (data_len <512 ) { retval =ext_sd_send_cmd_get_rsp (chip,SET_BLOCKLEN , data_len,SD_RSP_TYPE_R1 ,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - } }if (standby) { retval =sd_select_card (chip,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - } }if (acmd) { retval =ext_sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - } } retval =ext_sd_send_cmd_get_rsp (chip, cmd_idx, arg, rsp_type, sd_card->rsp, rsp_len,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - }if (data_len <=512 ) {u16 i;u8 *buf; buf =kmalloc (data_len,GFP_KERNEL ); -if (buf ==NULL ) { +if (buf ==NULL )TRACE_RET (chip,TRANSPORT_ERROR ); - }rtsx_stor_get_xfer_buf (buf, data_len, srb);#ifdef SUPPORT_SD_LOCK -if (cmd_idx ==LOCK_UNLOCK ) { +if (cmd_idx ==LOCK_UNLOCK ) lock_cmd_type = buf[0 ] &0x0F ; - }#endif if (data_len >256 ) {@@ -4485,11 +4326,11 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) }rtsx_init_cmd (chip); -if (CHECK_PID (chip,0x5209 )) { +if (CHECK_PID (chip,0x5209 ))rtsx_add_cmd (chip,CHECK_REG_CMD ,SD_BUS_STAT ,SD_DAT0_STATUS ,SD_DAT0_STATUS ); - }else { +else rtsx_add_cmd (chip,CHECK_REG_CMD ,0xFD30 ,0x02 ,0x02 ); - } +rtsx_send_cmd (chip,SD_CARD ,250 ); retval =sd_update_lock_status (chip);@@ -4502,61 +4343,54 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)if (standby) { retval =sd_select_card (chip,1 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - } }if (send_cmd12) { retval =ext_sd_send_cmd_get_rsp (chip,STOP_TRANSMISSION ,0 , SD_RSP_TYPE_R1b,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - } }if (data_len <512 ) { retval =ext_sd_send_cmd_get_rsp (chip,SET_BLOCKLEN ,0x200 ,SD_RSP_TYPE_R1 ,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - } retval =rtsx_write_register (chip,SD_BYTE_CNT_H ,0xFF ,0x02 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - } +rtsx_write_register (chip,SD_BYTE_CNT_L ,0xFF ,0x00 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - } + } -if ((srb->cmnd[1 ] &0x02 ) || (srb->cmnd[1 ] &0x04 )) { +if ((srb->cmnd[1 ] &0x02 ) || (srb->cmnd[1 ] &0x04 )) cmd13_checkbit =1 ; - }for (i =0 ; i <3 ; i++) { retval =ext_sd_send_cmd_get_rsp (chip,SEND_STATUS , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 , cmd13_checkbit); -if (retval ==STATUS_SUCCESS ) { +if (retval ==STATUS_SUCCESS )break ; - } } -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - }#ifdef SUPPORT_SD_LOCK if (cmd_idx ==LOCK_UNLOCK ) {if (!lock_cmd_fail) {RTSX_DEBUGP ("lock_cmd_type = 0x%x\n" , lock_cmd_type); -if (lock_cmd_type &SD_CLR_PWD ) { +if (lock_cmd_type &SD_CLR_PWD ) sd_card->sd_lock_status &= ~SD_PWD_EXIST ; - } -if (lock_cmd_type &SD_SET_PWD ) { + +if (lock_cmd_type &SD_SET_PWD ) sd_card->sd_lock_status |=SD_PWD_EXIST ; - } } RTSX_DEBUGP("sd_lock_state = 0x%x, sd_card->sd_lock_status = 0x%x\n",@@ -4593,14 +4427,13 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) SD_Execute_Write_Cmd_Failed: sd_card->pre_cmd_err =1 ;set_sense_type (chip, lun,SENSE_TYPE_NO_SENSE ); -if (write_err) { +if (write_err)set_sense_type (chip, lun,SENSE_TYPE_MEDIA_WRITE_ERR ); - } +release_sd_card (chip);do_reset_sd_card (chip); -if (!(chip->card_ready &SD_CARD )) { +if (!(chip->card_ready &SD_CARD ))set_sense_type (chip, lun,SENSE_TYPE_MEDIA_NOT_PRESENT ); - }TRACE_RET (chip,TRANSPORT_FAILED ); }@@ -4670,9 +4503,8 @@ int sd_hw_rst(struct scsi_cmnd *srb, struct rtsx_chip *chip)switch (srb->cmnd[1 ] &0x0F ) {case 0 :#ifdef SUPPORT_SD_LOCK -if (0x64 == srb->cmnd[9 ]) { +if (0x64 == srb->cmnd[9 ]) sd_card->sd_lock_status |=SD_SDR_RST ; - }#endif retval =reset_sd_card (chip);if (retval !=STATUS_SUCCESS ) {@@ -4723,26 +4555,23 @@ int sd_power_off_card3v3(struct rtsx_chip *chip)int retval; retval =disable_card_clock (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }RTSX_WRITE_REG (chip,CARD_OE ,SD_OUTPUT_EN ,0 );if (!chip->ft2_fast_mode) { retval =card_power_off (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }wait_timeout (50 ); }if (chip->asic_code) { retval =sd_pull_ctl_disable (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } }else {RTSX_WRITE_REG (chip,FPGA_PULL_CTL ,FPGA_SD_PULL_CTL_BIT |0x20 ,FPGA_SD_PULL_CTL_BIT );@@ -4774,19 +4603,16 @@ int release_sd_card(struct rtsx_chip *chip)memset (sd_card->raw_scr,0 ,8 ); retval =sd_power_off_card3v3 (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (CHECK_PID (chip,0x5209 )) { retval =sd_change_bank_voltage (chip,SD_IO_3V3 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } -if (CHK_SD30_SPEED (sd_card)) { +if (CHK_SD30_SPEED (sd_card))RTSX_WRITE_REG (chip,SD30_DRIVE_SEL ,0x07 , chip->sd30_drive_sel_3v3); - }RTSX_WRITE_REG (chip,OCPPARA2 ,SD_OCP_THD_MASK , chip->sd_400mA_ocp_thd); } --1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 2 lines · devendra.aaru
Hello,
This is a very big patch. It will be difficult for reviewers to review.
Hello, this is a carelessly large reply quoting all 100K of the original patch for your three sentences. Don't do that.
Thanks
Quoted 9 lines · Joe Perches
Quoted 2 lines · devendra.aaru
Hello,
This is a very big patch. It will be difficult for reviewers to review.Hello, this is a carelessly large reply quoting all 100K of the original patch for your three sentences. Don't do that.
Thanks
Yeah, sorry about that, i realised now,
Thanks
Quoted 1 line
Quoted 5 lines · devendra.aaru
Hello,
This is a very big patch. It will be difficult for reviewers to review.
i think it will be good if you can split into multiple patches.
Thanks for your reply.
Should I do that ?
I have a similar patch some more.
Quoted 8 lines · Toshiaki Yamane
fixed below checkpatch warnings.
(quoted diff) +0
-2-WARNING: braces {} are not necessary for single statement blocks -WARNING: braces {} are not necessary for any arm of this statementSigned-off-by Toshiaki Yamane <[email protected]>--- drivers/staging/rts_pstor/sd.c | 1112 +++++++++++++++++----------------------- 1 file changed, 469 insertions(+), 643 deletions(-)
Why is the object file size changing with this patch applied? That implies that something went wrong with your patch, care to redo it in a format that I can properly review it?
thanks,
greg k-h
Quoted 5 lines · Greg Kroah-Hartman
Quoted 4 lines · Toshiaki Yamane
fixed below checkpatch warnings.
(quoted diff) +0
-2-WARNING: braces {} are not necessary for single statement blocks -WARNING: braces {} are not necessary for any arm of this statement
Quoted 8 lines
Quoted 4 lines
Signed-off-by Toshiaki Yamane <[email protected]>--- drivers/staging/rts_pstor/sd.c | 1112 +++++++++++++++++----------------------- 1 file changed, 469 insertions(+), 643 deletions(-)Why is the object file size changing with this patch applied? That implies that something went wrong with your patch, care to redo it in a format that I can properly review it?
I understand.
I will redo it.
Thanks
Quoted 5 lines · Greg Kroah-Hartman
Quoted 4 lines · Toshiaki Yamane
fixed below checkpatch warnings.
(quoted diff) +0
-2-WARNING: braces {} are not necessary for single statement blocks -WARNING: braces {} are not necessary for any arm of this statement
Quoted 8 lines
Quoted 4 lines
Signed-off-by Toshiaki Yamane <[email protected]>--- drivers/staging/rts_pstor/sd.c | 1112 +++++++++++++++++----------------------- 1 file changed, 469 insertions(+), 643 deletions(-)Why is the object file size changing with this patch applied? That implies that something went wrong with your patch, care to redo it in a format that I can properly review it?
I had to remove the brace that I must not be deleted. I will send a patch later.
@@ -2729,15 +2644,13 @@ static int mmc_test_switch_bus(struct | @@ -2729,9 +2611,8 @@ static int mmc_test_switch_bus(struct r
rtsx_add_cmd(chip, CHECK_REG_CMD, REG_SD_TRANSFER, SD
rtsx_add_cmd(chip, CHECK_REG_CMD, REG_SD_TRANSFER, SD
rtsx_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2, 0, 0);
rtsx_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2, 0, 0);
- if (width == MMC_8BIT_BUS) { -
if (width == MMC_8BIT_BUS) {
+ if (width == MMC_8BIT_BUS) +
if (width == MMC_8BIT_BUS)
rtsx_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2
rtsx_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2
- } - }
retval = rtsx_send_cmd(chip, SD_CARD, 100);
retval = rtsx_send_cmd(chip, SD_CARD, 100);
- if (retval < 0) { |
if (retval < 0) {
+ if (retval < 0) | @@
-2747,15 +2628,14 @@ static int mmc_test_switch_bus(struct
rtsx_clear_sd_error(chip); <
TRACE_RET(chip, SWITCH_ERR); <
- } <
<
ptr = rtsx_get_cmd_data(chip) + 1; <
<@@ -2747,15 +2660,15 @@ static int mmc_test_switch_bus(struct <
PATCH 1/57 staging/rts_pstor: remove braces {} in sd.c (sd_send_cmd_get_rsp)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks -WARNING: braces {} are not necessary for any arm of this statement
--- drivers/staging/rts_pstor/sd.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/staging/rts_pstor/sd.c +5 -7
@@ -192,9 +192,9 @@ RTY_SEND_CMD: stat_idx =16 ; }else if (rsp_type !=SD_RSP_TYPE_R0 ) { -for (reg_addr =REG_SD_CMD0 ; reg_addr <=REG_SD_CMD4 ; reg_addr++) { +for (reg_addr =REG_SD_CMD0 ; reg_addr <=REG_SD_CMD4 ; reg_addr++)rtsx_add_cmd (chip,READ_REG_CMD , reg_addr,0 ,0 ); - } + stat_idx =5 ; }
@@ -273,9 +273,8 @@ RTY_SEND_CMD:if ((rsp_type ==SD_RSP_TYPE_R1 ) || (rsp_type == SD_RSP_TYPE_R1b)) {if ((cmd_idx !=SEND_RELATIVE_ADDR ) && (cmd_idx !=SEND_IF_COND )) {if (cmd_idx !=STOP_TRANSMISSION ) { -if (ptr[1 ] &0x80 ) { +if (ptr[1 ] &0x80 )TRACE_RET (chip,STATUS_FAIL ); - } }#ifdef SUPPORT_SD_LOCK if (ptr[1 ] &0x7D )
@@ -294,11 +293,10 @@ RTY_SEND_CMD:RTSX_DEBUGP ("ptr[3]: 0x%02x\n" , ptr[3 ]);TRACE_RET (chip,STATUS_FAIL ); } -if (ptr[3 ] &0x01 ) { +if (ptr[3 ] &0x01 ) sd_card->sd_data_buf_ready =1 ; - }else { +else sd_card->sd_data_buf_ready =0 ; - } } }
Signature · 1 line
1.7.9.5
PATCH 2/57 staging/rts_pstor: remove braces {} in sd.c (sd_read_data)
fixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/staging/rts_pstor/sd.c +5 -8
@@ -320,17 +320,15 @@ static int sd_read_data(struct rtsx_chip *chip,if (!buf) buf_len =0 ; -if (buf_len >512 ) { +if (buf_len >512 )TRACE_RET (chip,STATUS_FAIL ); - }rtsx_init_cmd (chip);if (cmd_len) {RTSX_DEBUGP ("SD/MMC CMD %d\n" , cmd[0 ] -0x40 ); -for (i =0 ; i < (cmd_len <6 ? cmd_len :6 ); i++) { +for (i =0 ; i < (cmd_len <6 ? cmd_len :6 ); i++)rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CMD0 + i,0xFF , cmd[i]); - } }rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_BYTE_CNT_L ,0xFF , (u8 )byte_cnt);rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_BYTE_CNT_H ,0xFF , (u8)(byte_cnt >>8 ));
@@ -342,9 +340,9 @@ static int sd_read_data(struct rtsx_chip *chip,rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CFG2 ,0xFF ,SD_CALCULATE_CRC7 |SD_CHECK_CRC16 |SD_NO_WAIT_BUSY_END |SD_CHECK_CRC7 |SD_RSP_LEN_6 ); -if (trans_mode !=SD_TM_AUTO_TUNING ) { +if (trans_mode !=SD_TM_AUTO_TUNING )rtsx_add_cmd (chip,WRITE_REG_CMD ,CARD_DATA_SOURCE ,0x01 ,PINGPONG_BUFFER ); - } +rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_TRANSFER ,0xFF , trans_mode |SD_TRANSFER_START );rtsx_add_cmd (chip,CHECK_REG_CMD ,REG_SD_TRANSFER ,SD_TRANSFER_END ,SD_TRANSFER_END );
@@ -360,9 +358,8 @@ static int sd_read_data(struct rtsx_chip *chip,if (buf && buf_len) { retval =rtsx_read_ppbuf (chip, buf, buf_len); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } }return STATUS_SUCCESS ;
Signature · 1 line
1.7.9.5
PATCH 3/57 staging/rts_pstor: remove braces {} in sd.c (sd_write_data)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rts_pstor/sd.c +1 -2
@@ -385,9 +385,8 @@ static int sd_write_data(struct rtsx_chip *chip, u8 trans_mode,if (buf && buf_len) { retval =rtsx_write_ppbuf (chip, buf, buf_len); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } }rtsx_init_cmd (chip);
Signature · 1 line
1.7.9.5
PATCH 4/57 staging/rts_pstor: remove braces {} in sd.c (sd_check_csd)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks -WARNING: braces {} are not necessary for any arm of this statement
--- drivers/staging/rts_pstor/sd.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-)
drivers/staging/rts_pstor/sd.c +18 -21
@@ -444,15 +444,13 @@ static int sd_check_csd(struct rtsx_chip *chip, char check_wp)break ; } -if (i ==6 ) { +if (i ==6 )TRACE_RET (chip,STATUS_FAIL ); - }memcpy (sd_card->raw_csd, rsp +1 ,15 ); -if (CHECK_PID (chip,0x5209 )) { +if (CHECK_PID (chip,0x5209 ))RTSX_READ_REG (chip,REG_SD_CMD5 , sd_card->raw_csd +15 ); - }RTSX_DEBUGP ("CSD Response:\n" );RTSX_DUMP (sd_card->raw_csd,16 );
@@ -463,35 +461,34 @@ static int sd_check_csd(struct rtsx_chip *chip, char check_wp) trans_speed = rsp[4 ];if ((trans_speed &0x07 ) ==0x02 ) {if ((trans_speed &0xf8 ) >=0x30 ) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock =47 ; - }else { +else sd_card->sd_clock =CLK_50 ; - } + }else if ((trans_speed &0xf8 ) ==0x28 ) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock =39 ; - }else { +else sd_card->sd_clock =CLK_40 ; - } + }else if ((trans_speed &0xf8 ) ==0x20 ) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock =29 ; - }else { +else sd_card->sd_clock =CLK_30 ; - } + }else if ((trans_speed &0xf8 ) >=0x10 ) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock =23 ; - }else { +else sd_card->sd_clock =CLK_20 ; - } + }else if ((trans_speed &0x08 ) >=0x08 ) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock =19 ; - }else { +else sd_card->sd_clock =CLK_20 ; - } }else {TRACE_RET (chip,STATUS_FAIL ); }
@@ -521,9 +518,9 @@ static int sd_check_csd(struct rtsx_chip *chip, char check_wp) }if (check_wp) { -if (rsp[15 ] &0x30 ) { +if (rsp[15 ] &0x30 ) chip->card_wp |=SD_CARD ; - } +RTSX_DEBUGP ("CSD WP Status: 0x%x\n" , rsp[15 ]); }
Signature · 1 line
1.7.9.5
PATCH 5/57 staging/rts_pstor: remove braces {} in sd.c (sd_set_sample_push_timing)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks -WARNING: braces {} are not necessary for any arm of this statement
--- drivers/staging/rts_pstor/sd.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-)
drivers/staging/rts_pstor/sd.c +13 -18
@@ -559,22 +559,21 @@ static int sd_set_sample_push_timing(struct rtsx_chip *chip) CRC_FIX_CLK | SD30_VAR_CLK0 | SAMPLE_VAR_CLK1);RTSX_WRITE_REG (chip,CLK_CTL ,CLK_LOW_FREQ ,0 ); -if ((chip->sd_ctl &SD_PUSH_POINT_CTL_MASK ) ==SD_PUSH_POINT_AUTO ) { +if ((chip->sd_ctl &SD_PUSH_POINT_CTL_MASK ) ==SD_PUSH_POINT_AUTO ) val =SD20_TX_NEG_EDGE ; - }else if ((chip->sd_ctl &SD_PUSH_POINT_CTL_MASK ) ==SD_PUSH_POINT_DELAY ) { +else if ((chip->sd_ctl &SD_PUSH_POINT_CTL_MASK ) ==SD_PUSH_POINT_DELAY ) val =SD20_TX_14_AHEAD ; - }else { +else val =SD20_TX_NEG_EDGE ; - } +RTSX_WRITE_REG (chip,SD_PUSH_POINT_CTL ,SD20_TX_SEL_MASK , val);if ((chip->sd_ctl &SD_SAMPLE_POINT_CTL_MASK ) ==SD_SAMPLE_POINT_AUTO ) {if (chip->asic_code) { -if (CHK_SD_HS (sd_card) ||CHK_MMC_52M (sd_card)) { +if (CHK_SD_HS (sd_card) ||CHK_MMC_52M (sd_card)) val =SD20_RX_14_DELAY ; - }else { +else val =SD20_RX_POS_EDGE ; - } }else { val =SD20_RX_14_DELAY ; }
@@ -588,32 +587,28 @@ static int sd_set_sample_push_timing(struct rtsx_chip *chip) }else {u8 val =0 ; -if ((chip->sd_ctl &SD_PUSH_POINT_CTL_MASK ) ==SD_PUSH_POINT_DELAY ) { +if ((chip->sd_ctl &SD_PUSH_POINT_CTL_MASK ) ==SD_PUSH_POINT_DELAY ) val |=0x10 ; - }if ((chip->sd_ctl &SD_SAMPLE_POINT_CTL_MASK ) ==SD_SAMPLE_POINT_AUTO ) {if (chip->asic_code) {if (CHK_SD_HS (sd_card) ||CHK_MMC_52M (sd_card)) { -if (val &0x10 ) { +if (val &0x10 ) val |=0x04 ; - }else { +else val |=0x08 ; - } } }else { -if (val &0x10 ) { +if (val &0x10 ) val |=0x04 ; - }else { +else val |=0x08 ; - } } }else if ((chip->sd_ctl &SD_SAMPLE_POINT_CTL_MASK ) ==SD_SAMPLE_POINT_DELAY ) { -if (val &0x10 ) { +if (val &0x10 ) val |=0x04 ; - }else { +else val |=0x08 ; - } }RTSX_WRITE_REG (chip,REG_SD_CFG1 ,0x1C , val);
Signature · 1 line
1.7.9.5
PATCH 6/57 staging/rts_pstor: remove braces {} in sd.c (sd_choose_proper_clock)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for any arm of this statement
--- drivers/staging/rts_pstor/sd.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-)
drivers/staging/rts_pstor/sd.c +17 -18
@@ -622,41 +622,40 @@ static void sd_choose_proper_clock(struct rtsx_chip *chip)struct sd_info *sd_card = &(chip->sd_card);if (CHK_SD_SDR104 (sd_card)) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock = chip->asic_sd_sdr104_clk; - }else { +else sd_card->sd_clock = chip->fpga_sd_sdr104_clk; - } + }else if (CHK_SD_DDR50 (sd_card)) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock = chip->asic_sd_ddr50_clk; - }else { +else sd_card->sd_clock = chip->fpga_sd_ddr50_clk; - } + }else if (CHK_SD_SDR50 (sd_card)) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock = chip->asic_sd_sdr50_clk; - }else { +else sd_card->sd_clock = chip->fpga_sd_sdr50_clk; - } + }else if (CHK_SD_HS (sd_card)) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock = chip->asic_sd_hs_clk; - }else { +else sd_card->sd_clock = chip->fpga_sd_hs_clk; - } + }else if (CHK_MMC_52M (sd_card) ||CHK_MMC_DDR52 (sd_card)) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock = chip->asic_mmc_52m_clk; - }else { +else sd_card->sd_clock = chip->fpga_mmc_52m_clk; - } + }else if (CHK_MMC_26M (sd_card)) { -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock =48 ; - }else { +else sd_card->sd_clock =CLK_50 ; - } } }
Signature · 1 line
1.7.9.5
PATCH 7/57 staging/rts_pstor: remove braces {} in sd.c (sd_set_clock_divider)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for any arm of this statement
--- drivers/staging/rts_pstor/sd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/staging/rts_pstor/sd.c +3 -4
@@ -668,13 +668,12 @@ static int sd_set_clock_divider(struct rtsx_chip *chip, u8 clk_div) val = clk_div; }else { mask =0x60 ; -if (clk_div ==SD_CLK_DIVIDE_0 ) { +if (clk_div ==SD_CLK_DIVIDE_0 ) val =0x00 ; - }else if (clk_div ==SD_CLK_DIVIDE_128 ) { +else if (clk_div ==SD_CLK_DIVIDE_128 ) val =0x40 ; - }else if (clk_div ==SD_CLK_DIVIDE_256 ) { +else if (clk_div ==SD_CLK_DIVIDE_256 ) val =0x20 ; - } }RTSX_WRITE_REG (chip,REG_SD_CFG1 , mask, val);
Signature · 1 line
1.7.9.5
PATCH 8/57 staging/rts_pstor: remove braces {} in sd.c (sd_set_init_para)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/rts_pstor/sd.c +2 -4
@@ -687,16 +687,14 @@ static int sd_set_init_para(struct rtsx_chip *chip)int retval; retval =sd_set_sample_push_timing (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }sd_choose_proper_clock (chip); retval =switch_clock (chip, sd_card->sd_clock); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }
Signature · 1 line
1.7.9.5
PATCH 9/57 staging/rts_pstor: remove braces {} in sd.c (sd_select_card)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rts_pstor/sd.c +1 -2
@@ -717,9 +717,8 @@ int sd_select_card(struct rtsx_chip *chip, int select) } retval =sd_send_cmd_get_rsp (chip, cmd_idx, addr, cmd_type,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }
Signature · 1 line
1.7.9.5
PATCH 10/57 staging/rts_pstor: remove braces {} in sd.c (sd_update_lock_status)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks -WARNING: braces {} are not necessary for any arm of this statement
--- drivers/staging/rts_pstor/sd.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/staging/rts_pstor/sd.c +4 -7
@@ -731,21 +731,18 @@ static int sd_update_lock_status(struct rtsx_chip *chip)u8 rsp[5 ]; retval =sd_send_cmd_get_rsp (chip,SEND_STATUS , sd_card->sd_addr,SD_RSP_TYPE_R1 , rsp,5 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } -if (rsp[1 ] &0x02 ) { +if (rsp[1 ] &0x02 ) sd_card->sd_lock_status |=SD_LOCKED ; - }else { +else sd_card->sd_lock_status &= ~SD_LOCKED ; - }RTSX_DEBUGP ("sd_card->sd_lock_status = 0x%x\n" , sd_card->sd_lock_status); -if (rsp[1 ] &0x01 ) { +if (rsp[1 ] &0x01 )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }
Signature · 1 line
1.7.9.5
PATCH 11/57 staging/rts_pstor: remove braces {} in sd.c (sd_wait_state_data_ready)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/rts_pstor/sd.c +2 -4
@@ -757,13 +757,11 @@ static int sd_wait_state_data_ready(struct rtsx_chip *chip, u8 state, u8 data_refor (i =0 ; i < polling_cnt; i++) { retval =sd_send_cmd_get_rsp (chip,SEND_STATUS , sd_card->sd_addr,SD_RSP_TYPE_R1 , rsp,5 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } -if (((rsp[3 ] &0x1E ) == state) && ((rsp[3 ] &0x01 ) == data_ready)) { +if (((rsp[3 ] &0x1E ) == state) && ((rsp[3 ] &0x01 ) == data_ready))return STATUS_SUCCESS ; - } }TRACE_RET (chip,STATUS_FAIL );
Signature · 1 line
1.7.9.5
PATCH 12/57 staging/rts_pstor: remove braces {} in sd.c (sd_change_bank_voltage)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/rts_pstor/sd.c +2 -4
@@ -774,18 +774,16 @@ static int sd_change_bank_voltage(struct rtsx_chip *chip, u8 voltage)if (voltage ==SD_IO_3V3 ) {if (chip->asic_code) { retval =rtsx_write_phy_register (chip,0x08 ,0x4FC0 | chip->phy_voltage); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } }else {RTSX_WRITE_REG (chip,SD_PAD_CTL ,SD_IO_USING_1V8 ,0 ); } }else if (voltage ==SD_IO_1V8 ) {if (chip->asic_code) { retval =rtsx_write_phy_register (chip,0x08 ,0x4C40 | chip->phy_voltage); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } }else {RTSX_WRITE_REG (chip,SD_PAD_CTL ,SD_IO_USING_1V8 ,SD_IO_USING_1V8 ); }
Signature · 1 line
1.7.9.5
PATCH 13/57 staging/rts_pstor: remove braces {} in sd.c (sd_voltage_switch)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/staging/rts_pstor/sd.c +3 -4
@@ -802,9 +802,8 @@ static int sd_voltage_switch(struct rtsx_chip *chip)RTSX_WRITE_REG (chip,SD_BUS_STAT ,SD_CLK_TOGGLE_EN |SD_CLK_FORCE_STOP ,SD_CLK_TOGGLE_EN ); retval =sd_send_cmd_get_rsp (chip,VOLTAGE_SWITCH ,0 ,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }udelay (chip->sd_voltage_switch_delay);
@@ -816,9 +815,9 @@ static int sd_voltage_switch(struct rtsx_chip *chip)RTSX_WRITE_REG (chip,SD_BUS_STAT ,0xFF ,SD_CLK_FORCE_STOP ); retval =sd_change_bank_voltage (chip,SD_IO_1V8 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } +wait_timeout (50 );RTSX_WRITE_REG (chip,SD_BUS_STAT ,0xFF ,SD_CLK_TOGGLE_EN );
Signature · 1 line
1.7.9.5
PATCH 14/57 staging/rts_pstor: remove braces {} in sd.c (sd_change_phase)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for any arm of this statement -WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
drivers/staging/rts_pstor/sd.c +9 -11
@@ -866,9 +866,8 @@ static int sd_change_phase(struct rtsx_chip *chip, u8 sample_point, u8 tune_dir)if (tune_dir ==TUNE_RX ) {SD_VP_CTL =SD_VPRX_CTL ;SD_DCMPS_CTL =SD_DCMPS_RX_CTL ; -if (CHK_SD_DDR50 (sd_card)) { +if (CHK_SD_DDR50 (sd_card)) ddr_rx =1 ; - } }else {SD_VP_CTL =SD_VPTX_CTL ;SD_DCMPS_CTL =SD_DCMPS_TX_CTL ;
@@ -905,23 +904,22 @@ static int sd_change_phase(struct rtsx_chip *chip, u8 sample_point, u8 tune_dir)rtsx_add_cmd (chip,WRITE_REG_CMD ,SD_DCMPS_CTL ,DCMPS_CHANGE ,DCMPS_CHANGE );rtsx_add_cmd (chip,CHECK_REG_CMD ,SD_DCMPS_CTL ,DCMPS_CHANGE_DONE ,DCMPS_CHANGE_DONE ); retval =rtsx_send_cmd (chip,SD_CARD ,100 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, Fail); - } val = *rtsx_get_cmd_data (chip); -if (val &DCMPS_ERROR ) { +if (val &DCMPS_ERROR )TRACE_GOTO (chip, Fail); - } -if ((val &DCMPS_CURRENT_PHASE ) != sample_point) { + +if ((val &DCMPS_CURRENT_PHASE ) != sample_point)TRACE_GOTO (chip, Fail); - } +RTSX_WRITE_REG (chip,SD_DCMPS_CTL ,DCMPS_CHANGE ,0 ); -if (ddr_rx) { +if (ddr_rx)RTSX_WRITE_REG (chip,SD_VP_CTL ,PHASE_CHANGE ,0 ); - }else { +else RTSX_WRITE_REG (chip,CLK_CTL ,CHANGE_CLK ,0 ); - } +udelay (50 ); }
Signature · 1 line
1.7.9.5
PATCH 15/57 staging/rts_pstor: remove braces {} in sd.c (sd_check_spec)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/rts_pstor/sd.c +2 -4
@@ -949,9 +949,8 @@ static int sd_check_spec(struct rtsx_chip *chip, u8 bus_width)u8 cmd[5 ], buf[8 ]; retval =sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } cmd[0 ] =0x40 |SEND_SCR ; cmd[1 ] =0 ;
@@ -967,9 +966,8 @@ static int sd_check_spec(struct rtsx_chip *chip, u8 bus_width)memcpy (sd_card->raw_scr, buf,8 ); -if ((buf[0 ] &0x0F ) ==0 ) { +if ((buf[0 ] &0x0F ) ==0 )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }
Signature · 1 line
1.7.9.5
PATCH 16/57 staging/rts_pstor: remove braces {} in sd.c (sd_check_switch_mode)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/staging/rts_pstor/sd.c +3 -4
@@ -1141,13 +1141,12 @@ static int sd_check_switch_mode(struct rtsx_chip *chip, u8 mode,*/ u16 cc = ((u16 )buf[0 ] <<8 ) | buf[1 ];RTSX_DEBUGP ("Maximum current consumption: %dmA\n" , cc); -if ((cc ==0 ) || (cc >800 )) { +if ((cc ==0 ) || (cc >800 ))TRACE_RET (chip,STATUS_FAIL ); - } + retval =sd_query_switch_result (chip, func_group, func_to_switch, buf,64 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if ((cc >400 ) || (func_to_switch >CURRENT_LIMIT_400 )) {RTSX_WRITE_REG (chip,OCPPARA2 ,SD_OCP_THD_MASK , chip->sd_800mA_ocp_thd);
Signature · 1 line
1.7.9.5
PATCH 17/57 staging/rts_pstor: remove braces {} in sd.c (downgrade_switch_mode)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/staging/rts_pstor/sd.c +3 -4
@@ -1160,13 +1160,12 @@ static int sd_check_switch_mode(struct rtsx_chip *chip, u8 mode,static u8 downgrade_switch_mode (u8 func_group,u8 func_to_switch) {if (func_group ==SD_FUNC_GROUP_1 ) { -if (func_to_switch >HS_SUPPORT ) { +if (func_to_switch >HS_SUPPORT ) func_to_switch--; - } + }else if (func_group ==SD_FUNC_GROUP_4 ) { -if (func_to_switch >CURRENT_LIMIT_200 ) { +if (func_to_switch >CURRENT_LIMIT_200 ) func_to_switch--; - } }return func_to_switch;
Signature · 1 line
1.7.9.5
PATCH 18/57 staging/rts_pstor: remove braces {} in sd.c (sd_check_switch)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rts_pstor/sd.c +1 -2
@@ -1208,9 +1208,8 @@ static int sd_check_switch(struct rtsx_chip *chip,wait_timeout (20 ); } -if (!switch_good) { +if (!switch_good)TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }
Signature · 1 line
1.7.9.5
PATCH 19/57 staging/rts_pstor: remove braces {} in sd.c (sd_switch_function)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for any arm of this statement -WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 48 ++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 27 deletions(-)
drivers/staging/rts_pstor/sd.c +21 -27
@@ -1224,9 +1224,8 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width)/* Get supported functions */ retval =sd_check_switch_mode (chip,SD_CHECK_MODE ,NO_ARGUMENT ,NO_ARGUMENT , bus_width); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } sd_card->func_group1_mask &= ~(sd_card->sd_switch_fail);
@@ -1255,9 +1254,9 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width)break ;case HS_SUPPORT : -if (sd_card->func_group1_mask &HS_SUPPORT_MASK ) { +if (sd_card->func_group1_mask &HS_SUPPORT_MASK ) func_to_switch =HS_SUPPORT ; - } +break ;default :
@@ -1265,9 +1264,9 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width) } -if (func_to_switch) { +if (func_to_switch)break ; - } + }RTSX_DEBUGP ("SD_FUNC_GROUP_1: func_to_switch = 0x%02x" , func_to_switch);
@@ -1296,23 +1295,21 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width)TRACE_RET (chip,STATUS_FAIL ); } -if (func_to_switch ==SDR104_SUPPORT ) { +if (func_to_switch ==SDR104_SUPPORT )SET_SD_SDR104 (sd_card); - }else if (func_to_switch ==DDR50_SUPPORT ) { +else if (func_to_switch ==DDR50_SUPPORT )SET_SD_DDR50 (sd_card); - }else if (func_to_switch ==SDR50_SUPPORT ) { +else if (func_to_switch ==SDR50_SUPPORT )SET_SD_SDR50 (sd_card); - }else { +else SET_SD_HS (sd_card); - } }if (CHK_SD_DDR50 (sd_card)) {RTSX_WRITE_REG (chip,SD_PUSH_POINT_CTL ,0x06 ,0x04 ); retval =sd_set_sample_push_timing (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } }if (!func_to_switch || (func_to_switch ==HS_SUPPORT )) {
@@ -1328,36 +1325,35 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width)for (i =0 ; i <4 ; i++) {switch ((u8)(chip->sd_current_prior >> (i*8 ))) {case CURRENT_LIMIT_800 : -if (sd_card->func_group4_mask &CURRENT_LIMIT_800_MASK ) { +if (sd_card->func_group4_mask &CURRENT_LIMIT_800_MASK ) func_to_switch =CURRENT_LIMIT_800 ; - } +break ;case CURRENT_LIMIT_600 : -if (sd_card->func_group4_mask &CURRENT_LIMIT_600_MASK ) { +if (sd_card->func_group4_mask &CURRENT_LIMIT_600_MASK ) func_to_switch =CURRENT_LIMIT_600 ; - } +break ;case CURRENT_LIMIT_400 : -if (sd_card->func_group4_mask &CURRENT_LIMIT_400_MASK ) { +if (sd_card->func_group4_mask &CURRENT_LIMIT_400_MASK ) func_to_switch =CURRENT_LIMIT_400 ; - } +break ;case CURRENT_LIMIT_200 : -if (sd_card->func_group4_mask &CURRENT_LIMIT_200_MASK ) { +if (sd_card->func_group4_mask &CURRENT_LIMIT_200_MASK ) func_to_switch =CURRENT_LIMIT_200 ; - } +break ;default :continue ; } -if (func_to_switch !=0xFF ) { +if (func_to_switch !=0xFF )break ; - } }RTSX_DEBUGP ("SD_FUNC_GROUP_4: func_to_switch = 0x%02x" , func_to_switch);
@@ -1365,16 +1361,14 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width)if (func_to_switch <=CURRENT_LIMIT_800 ) { retval =sd_check_switch (chip,SD_FUNC_GROUP_4 , func_to_switch, bus_width);if (retval !=STATUS_SUCCESS ) { -if (sd_check_err_code (chip,SD_NO_CARD )) { +if (sd_check_err_code (chip,SD_NO_CARD ))TRACE_RET (chip,STATUS_FAIL ); - } }RTSX_DEBUGP ("Switch current limit finished! (%d)\n" , retval); } -if (CHK_SD_DDR50 (sd_card)) { +if (CHK_SD_DDR50 (sd_card))RTSX_WRITE_REG (chip,SD_PUSH_POINT_CTL ,0x06 ,0 ); - }return STATUS_SUCCESS ; }
Signature · 1 line
1.7.9.5
PATCH 20/57 staging/rts_pstor: remove braces {} in sd.c (sd_sdr_tuning_rx_cmd)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rts_pstor/sd.c +1 -2
@@ -1398,9 +1398,8 @@ static int sd_sdr_tuning_rx_cmd(struct rtsx_chip *chip, u8 sample_point)u8 cmd[5 ]; retval =sd_change_phase (chip, sample_point,TUNE_RX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } cmd[0 ] =0x40 |SEND_TUNING_PATTERN ; cmd[1 ] =0 ;
Signature · 1 line
1.7.9.5
PATCH 21/57 staging/rts_pstor: remove braces {} in sd.c (sd_ddr_tuning_rx_cmd)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/rts_pstor/sd.c +2 -4
@@ -1426,16 +1426,14 @@ static int sd_ddr_tuning_rx_cmd(struct rtsx_chip *chip, u8 sample_point)u8 cmd[5 ]; retval =sd_change_phase (chip, sample_point,TUNE_RX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }RTSX_DEBUGP ("sd ddr tuning rx\n" ); retval =sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } cmd[0 ] =0x40 |SD_STATUS ; cmd[1 ] =0 ;
Signature · 1 line
1.7.9.5
PATCH 22/57 staging/rts_pstor: remove braces {} in sd.c (mmc_ddr_tunning_rx_cmd)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for any arm of this statement -WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/staging/rts_pstor/sd.c +4 -6
@@ -1459,18 +1459,16 @@ static int mmc_ddr_tunning_rx_cmd(struct rtsx_chip *chip, u8 sample_point)int retval;u8 cmd[5 ], bus_width; -if (CHK_MMC_8BIT (sd_card)) { +if (CHK_MMC_8BIT (sd_card)) bus_width =SD_BUS_WIDTH_8 ; - }else if (CHK_MMC_4BIT (sd_card)) { +else if (CHK_MMC_4BIT (sd_card)) bus_width =SD_BUS_WIDTH_4 ; - }else { +else bus_width =SD_BUS_WIDTH_1 ; - } retval =sd_change_phase (chip, sample_point,TUNE_RX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }RTSX_DEBUGP ("mmc ddr tuning rx\n" );
Signature · 1 line
1.7.9.5
PATCH 23/57 staging/rts_pstor: remove braces {} in sd.c (sd_sdr_tuning_tx_cmd)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rts_pstor/sd.c +1 -2
@@ -1496,9 +1496,8 @@ static int sd_sdr_tuning_tx_cmd(struct rtsx_chip *chip, u8 sample_point)int retval; retval =sd_change_phase (chip, sample_point,TUNE_TX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }RTSX_WRITE_REG (chip,SD_CFG3 ,SD_RSP_80CLK_TIMEOUT_EN ,SD_RSP_80CLK_TIMEOUT_EN );
Signature · 1 line
1.7.9.5
PATCH 24/57 staging/rts_pstor: remove braces {} in sd.c (sd_ddr_tuning_tx_cmd)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for any arm of this statement -WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/staging/rts_pstor/sd.c +5 -8
@@ -1522,26 +1522,23 @@ static int sd_ddr_tuning_tx_cmd(struct rtsx_chip *chip, u8 sample_point)u8 cmd[5 ], bus_width; retval =sd_change_phase (chip, sample_point,TUNE_TX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (CHK_SD (sd_card)) { bus_width =SD_BUS_WIDTH_4 ; }else { -if (CHK_MMC_8BIT (sd_card)) { +if (CHK_MMC_8BIT (sd_card)) bus_width =SD_BUS_WIDTH_8 ; - }else if (CHK_MMC_4BIT (sd_card)) { +else if (CHK_MMC_4BIT (sd_card)) bus_width =SD_BUS_WIDTH_4 ; - }else { +else bus_width =SD_BUS_WIDTH_1 ; - } } retval =sd_wait_state_data_ready (chip,0x08 ,1 ,1000 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }RTSX_WRITE_REG (chip,SD_CFG3 ,SD_RSP_80CLK_TIMEOUT_EN ,SD_RSP_80CLK_TIMEOUT_EN );
Signature · 1 line
1.7.9.5
PATCH 25/57 staging/rts_pstor: remove braces {} in sd.c (sd_search_final_phase)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for any arm of this statement -WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
drivers/staging/rts_pstor/sd.c +8 -11
@@ -1572,11 +1572,10 @@ static u8 sd_search_final_phase(struct rtsx_chip *chip, u32 phase_map, u8 tune_du8 final_phase =0xFF ;if (phase_map ==0xFFFFFFFF ) { -if (tune_dir ==TUNE_RX ) { +if (tune_dir ==TUNE_RX ) final_phase = (u8 )chip->sd_default_rx_phase; - }else { +else final_phase = (u8 )chip->sd_default_tx_phase; - } goto Search_Finish; }
@@ -1617,9 +1616,9 @@ static u8 sd_search_final_phase(struct rtsx_chip *chip, u32 phase_map, u8 tune_d path[0 ].start = path[cont_path_cnt -1 ].start -MAX_PHASE -1 ; path[0 ].len += path[cont_path_cnt -1 ].len; path[0 ].mid = path[0 ].start + path[0 ].len /2 ; -if (path[0 ].mid <0 ) { +if (path[0 ].mid <0 ) path[0 ].mid +=MAX_PHASE +1 ; - } + cont_path_cnt--; }
@@ -1647,11 +1646,10 @@ static u8 sd_search_final_phase(struct rtsx_chip *chip, u32 phase_map, u8 tune_dint temp_final_phase = path[final_path_idx].end - (max_len - (6 + temp_mid)); -if (temp_final_phase <0 ) { +if (temp_final_phase <0 ) final_phase = (u8)(temp_final_phase +MAX_PHASE +1 ); - }else { +else final_phase = (u8 )temp_final_phase; - } } }else if (CHK_SD_SDR50 (sd_card)) {if (max_len >12 ) {
@@ -1659,11 +1657,10 @@ static u8 sd_search_final_phase(struct rtsx_chip *chip, u32 phase_map, u8 tune_dint temp_final_phase = path[final_path_idx].end - (max_len - (3 + temp_mid)); -if (temp_final_phase <0 ) { +if (temp_final_phase <0 ) final_phase = (u8)(temp_final_phase +MAX_PHASE +1 ); - }else { +else final_phase = (u8 )temp_final_phase; - } } } }
Signature · 1 line
1.7.9.5
PATCH 26/57 staging/rts_pstor: remove braces {} in sd.c (sd_tuning_rx)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for any arm of this statement -WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)
drivers/staging/rts_pstor/sd.c +10 -14
@@ -1680,17 +1680,16 @@ static int sd_tuning_rx(struct rtsx_chip *chip)int (*tuning_cmd)(struct rtsx_chip *chip,u8 sample_point);if (CHK_SD (sd_card)) { -if (CHK_SD_DDR50 (sd_card)) { +if (CHK_SD_DDR50 (sd_card)) tuning_cmd = sd_ddr_tuning_rx_cmd; - }else { +else tuning_cmd = sd_sdr_tuning_rx_cmd; - } + }else { -if (CHK_MMC_DDR52 (sd_card)) { +if (CHK_MMC_DDR52 (sd_card)) tuning_cmd = mmc_ddr_tunning_rx_cmd; - }else { +else TRACE_RET (chip,STATUS_FAIL ); - } }for (i =0 ; i <3 ; i++) {
@@ -1702,27 +1701,24 @@ static int sd_tuning_rx(struct rtsx_chip *chip) } retval =tuning_cmd (chip, (u8 )j); -if (retval ==STATUS_SUCCESS ) { +if (retval ==STATUS_SUCCESS ) raw_phase_map[i] |=1 << j; - } } } phase_map = raw_phase_map[0 ] & raw_phase_map[1 ] & raw_phase_map[2 ]; -for (i =0 ; i <3 ; i++) { +for (i =0 ; i <3 ; i++)RTSX_DEBUGP ("RX raw_phase_map[%d] = 0x%08x\n" , i, raw_phase_map[i]); - } +RTSX_DEBUGP ("RX phase_map = 0x%08x\n" , phase_map); final_phase =sd_search_final_phase (chip, phase_map,TUNE_RX ); -if (final_phase ==0xFF ) { +if (final_phase ==0xFF )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_change_phase (chip, final_phase,TUNE_RX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }
Signature · 1 line
1.7.9.5
PATCH 27/57 staging/rts_pstor: remove braces {} in sd.c (sd_ddr_pre_tuning_tx)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/staging/rts_pstor/sd.c +4 -8
@@ -1743,15 +1743,13 @@ static int sd_ddr_pre_tuning_tx(struct rtsx_chip *chip) } retval =sd_change_phase (chip, (u8 )i,TUNE_TX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )continue ; - } retval =sd_send_cmd_get_rsp (chip,SEND_STATUS , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ); -if ((retval ==STATUS_SUCCESS ) || !sd_check_err_code (chip,SD_RSP_TIMEOUT )) { +if ((retval ==STATUS_SUCCESS ) || !sd_check_err_code (chip,SD_RSP_TIMEOUT )) phase_map |=1 << i; - } }RTSX_WRITE_REG (chip,SD_CFG3 ,SD_RSP_80CLK_TIMEOUT_EN ,0 );
@@ -1759,14 +1757,12 @@ static int sd_ddr_pre_tuning_tx(struct rtsx_chip *chip)RTSX_DEBUGP ("DDR TX pre tune phase_map = 0x%08x\n" , phase_map); final_phase =sd_search_final_phase (chip, phase_map,TUNE_TX ); -if (final_phase ==0xFF ) { +if (final_phase ==0xFF )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_change_phase (chip, final_phase,TUNE_TX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }RTSX_DEBUGP ("DDR TX pre tune phase: %d\n" , (int )final_phase);
Signature · 1 line
1.7.9.5
PATCH 28/57 staging/rts_pstor: remove braces {} in sd.c (sd_tuning_tx)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for any arm of this statement -WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)
drivers/staging/rts_pstor/sd.c +10 -14
@@ -1779,17 +1779,16 @@ static int sd_tuning_tx(struct rtsx_chip *chip)int (*tuning_cmd)(struct rtsx_chip *chip,u8 sample_point);if (CHK_SD (sd_card)) { -if (CHK_SD_DDR50 (sd_card)) { +if (CHK_SD_DDR50 (sd_card)) tuning_cmd = sd_ddr_tuning_tx_cmd; - }else { +else tuning_cmd = sd_sdr_tuning_tx_cmd; - } + }else { -if (CHK_MMC_DDR52 (sd_card)) { +if (CHK_MMC_DDR52 (sd_card)) tuning_cmd = sd_ddr_tuning_tx_cmd; - }else { +else TRACE_RET (chip,STATUS_FAIL ); - } }for (i =0 ; i <3 ; i++) {
@@ -1803,27 +1802,24 @@ static int sd_tuning_tx(struct rtsx_chip *chip) } retval =tuning_cmd (chip, (u8 )j); -if (retval ==STATUS_SUCCESS ) { +if (retval ==STATUS_SUCCESS ) raw_phase_map[i] |=1 << j; - } } } phase_map = raw_phase_map[0 ] & raw_phase_map[1 ] & raw_phase_map[2 ]; -for (i =0 ; i <3 ; i++) { +for (i =0 ; i <3 ; i++)RTSX_DEBUGP ("TX raw_phase_map[%d] = 0x%08x\n" , i, raw_phase_map[i]); - } +RTSX_DEBUGP ("TX phase_map = 0x%08x\n" , phase_map); final_phase =sd_search_final_phase (chip, phase_map,TUNE_TX ); -if (final_phase ==0xFF ) { +if (final_phase ==0xFF )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_change_phase (chip, final_phase,TUNE_TX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }
Signature · 1 line
1.7.9.5
PATCH 29/57 staging/rts_pstor: remove braces {} in sd.c (sd_sdr_tuning)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/rts_pstor/sd.c +2 -4
@@ -1829,14 +1829,12 @@ static int sd_sdr_tuning(struct rtsx_chip *chip)int retval; retval =sd_tuning_tx (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_tuning_rx (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }
Signature · 1 line
1.7.9.5
PATCH 30/57 staging/rts_pstor: remove braces {} in sd.c (sd_ddr_tuning)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/staging/rts_pstor/sd.c +4 -8
@@ -1845,26 +1845,22 @@ static int sd_ddr_tuning(struct rtsx_chip *chip)if (!(chip->sd_ctl &SD_DDR_TX_PHASE_SET_BY_USER )) { retval =sd_ddr_pre_tuning_tx (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } }else { retval =sd_change_phase (chip, (u8 )chip->sd_ddr_tx_phase,TUNE_TX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } } retval =sd_tuning_rx (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (!(chip->sd_ctl &SD_DDR_TX_PHASE_SET_BY_USER )) { retval =sd_tuning_tx (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } }return STATUS_SUCCESS ;
Signature · 1 line
1.7.9.5
PATCH 31/57 staging/rts_pstor: remove braces {} in sd.c (mmc_ddr_tuning)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/staging/rts_pstor/sd.c +4 -8
@@ -1872,26 +1872,22 @@ static int mmc_ddr_tuning(struct rtsx_chip *chip)if (!(chip->sd_ctl &MMC_DDR_TX_PHASE_SET_BY_USER )) { retval =sd_ddr_pre_tuning_tx (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } }else { retval =sd_change_phase (chip, (u8 )chip->mmc_ddr_tx_phase,TUNE_TX ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } } retval =sd_tuning_rx (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (!(chip->sd_ctl &MMC_DDR_TX_PHASE_SET_BY_USER )) { retval =sd_tuning_tx (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } }return STATUS_SUCCESS ;
Signature · 1 line
1.7.9.5
PATCH 32/57 staging/rts_pstor: remove braces {} in sd.c (sd_switch_clock)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for any arm of this statement -WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
drivers/staging/rts_pstor/sd.c +6 -11
@@ -1900,9 +1900,8 @@ int sd_switch_clock(struct rtsx_chip *chip)int re_tuning =0 ; retval =select_card (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (CHECK_PID (chip,0x5209 ) && (CHK_SD30_SPEED (sd_card) ||CHK_MMC_DDR52 (sd_card))) {
@@ -1913,26 +1912,22 @@ int sd_switch_clock(struct rtsx_chip *chip) } retval =switch_clock (chip, sd_card->sd_clock); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (re_tuning) {if (CHK_SD (sd_card)) { -if (CHK_SD_DDR50 (sd_card)) { +if (CHK_SD_DDR50 (sd_card)) retval =sd_ddr_tuning (chip); - }else { +else retval =sd_sdr_tuning (chip); - } }else { -if (CHK_MMC_DDR52 (sd_card)) { +if (CHK_MMC_DDR52 (sd_card)) retval =mmc_ddr_tuning (chip); - } } -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } }return STATUS_SUCCESS ;
Signature · 1 line
1.7.9.5
PATCH 33/57 staging/rts_pstor: remove braces {} in sd.c (sd_prepare_reset)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for any arm of this statement -WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/staging/rts_pstor/sd.c +4 -7
@@ -1938,11 +1938,10 @@ static int sd_prepare_reset(struct rtsx_chip *chip)struct sd_info *sd_card = &(chip->sd_card);int retval; -if (chip->asic_code) { +if (chip->asic_code) sd_card->sd_clock =29 ; - }else { +else sd_card->sd_clock =CLK_30 ; - } sd_card->sd_type =0 ; sd_card->seq_mode =0 ;
@@ -1958,9 +1957,8 @@ static int sd_prepare_reset(struct rtsx_chip *chip) chip->sd_io =0 ; retval =sd_set_init_para (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip, retval); - }if (CHECK_PID (chip,0x5209 )) { RTSX_WRITE_REG(chip, REG_SD_CFG1, 0xFF,
@@ -1974,9 +1972,8 @@ static int sd_prepare_reset(struct rtsx_chip *chip)RTSX_WRITE_REG (chip,CARD_STOP ,SD_STOP |SD_CLR_ERR ,SD_STOP |SD_CLR_ERR ); retval =select_card (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }
Signature · 1 line
1.7.9.5
PATCH 34/57 staging/rts_pstor: remove braces {} in sd.c (sd_pull_ctl_enable)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rts_pstor/sd.c +1 -2
@@ -2040,9 +2040,8 @@ int sd_pull_ctl_enable(struct rtsx_chip *chip) } retval =rtsx_send_cmd (chip,SD_CARD ,100 ); -if (retval <0 ) { +if (retval <0 )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }
Signature · 1 line
1.7.9.5
PATCH 35/57 staging/rts_pstor: remove braces {} in sd.c (sd_init_power)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-)
drivers/staging/rts_pstor/sd.c +9 -14
@@ -2050,42 +2050,37 @@ static int sd_init_power(struct rtsx_chip *chip) {int retval; -if (CHECK_PID (chip,0x5209 )) { +if (CHECK_PID (chip,0x5209 ))RTSX_WRITE_REG (chip,PWR_GATE_CTRL ,LDO3318_PWR_MASK ,LDO_OFF ); - } retval =sd_power_off_card3v3 (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } -if (!chip->ft2_fast_mode) { +if (!chip->ft2_fast_mode)wait_timeout (250 ); - } retval =enable_card_clock (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (chip->asic_code) { retval =sd_pull_ctl_enable (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } }else {RTSX_WRITE_REG (chip,FPGA_PULL_CTL ,FPGA_SD_PULL_CTL_BIT |0x20 ,0 ); }if (chip->ft2_fast_mode) { -if (CHECK_PID (chip,0x5209 )) { +if (CHECK_PID (chip,0x5209 ))RTSX_WRITE_REG (chip,PWR_GATE_CTRL ,LDO3318_PWR_MASK ,LDO_ON ); - } + }else { retval =card_power_on (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } +wait_timeout (260 );#ifdef SUPPORT_OCP
Signature · 1 line
1.7.9.5
PATCH 36/57 staging/rts_pstor: remove braces {} in sd.c (sd_read_lba0)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for any arm of this statement
--- drivers/staging/rts_pstor/sd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/staging/rts_pstor/sd.c +3 -4
@@ -2126,13 +2126,12 @@ static int sd_read_lba0(struct rtsx_chip *chip)if (CHK_SD (sd_card)) { bus_width =SD_BUS_WIDTH_4 ; }else { -if (CHK_MMC_8BIT (sd_card)) { +if (CHK_MMC_8BIT (sd_card)) bus_width =SD_BUS_WIDTH_8 ; - }else if (CHK_MMC_4BIT (sd_card)) { +else if (CHK_MMC_4BIT (sd_card)) bus_width =SD_BUS_WIDTH_4 ; - }else { +else bus_width =SD_BUS_WIDTH_1 ; - } } retval = sd_read_data(chip, SD_TM_NORMAL_READ, cmd,
Signature · 1 line
1.7.9.5
PATCH 37/57 staging/rts_pstor: remove braces {} in sd.c (sd_check_wp_state)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/rts_pstor/sd.c +2 -4
@@ -2154,9 +2154,8 @@ static int sd_check_wp_state(struct rtsx_chip *chip) retval =sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } cmd[0 ] =0x40 |SD_STATUS ; cmd[1 ] =0 ;
@@ -2184,9 +2183,8 @@ static int sd_check_wp_state(struct rtsx_chip *chip)/* Check SD Machanical Write-Protect Switch */ val =rtsx_readl (chip,RTSX_BIPR ); -if (val &SD_WRITE_PROTECT ) { +if (val &SD_WRITE_PROTECT ) chip->card_wp |=SD_CARD ; - }return STATUS_SUCCESS ; }
Signature · 1 line
1.7.9.5
PATCH 38/57 staging/rts_pstor: remove braces {} in sd.c (reset_sd)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for any arm of this statement -WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 114 ++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 69 deletions(-)
drivers/staging/rts_pstor/sd.c +45 -69
@@ -2216,14 +2216,12 @@ Switch_Fail:#endif retval =sd_prepare_reset (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_dummy_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (CHK_SDIO_EXIST (chip) && !CHK_SDIO_IGNORED (chip) && try_sdio) {int rty_cnt =0 ;
@@ -2257,9 +2255,8 @@ Switch_Fail:/* Start Initialization Process of SD Card */ RTY_SD_RST: retval =sd_send_cmd_get_rsp (chip,GO_IDLE_STATE ,0 ,SD_RSP_TYPE_R0 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }wait_timeout (20 );
@@ -2286,9 +2283,8 @@ RTY_SD_RST: voltage =SUPPORT_VOLTAGE ; retval =sd_send_cmd_get_rsp (chip,GO_IDLE_STATE ,0 ,SD_RSP_TYPE_R0 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }wait_timeout (20 ); }
@@ -2302,42 +2298,38 @@ RTY_SD_RST: } j++; -if (j <3 ) { +if (j <3 ) goto RTY_SD_RST; - }else { +else TRACE_RET (chip,STATUS_FAIL ); - } } retval =sd_send_cmd_get_rsp (chip,SD_APP_OP_COND , voltage,SD_RSP_TYPE_R3 , rsp,5 );if (retval !=STATUS_SUCCESS ) { k++; -if (k <3 ) { +if (k <3 ) goto RTY_SD_RST; - }else { +else TRACE_RET (chip,STATUS_FAIL ); - } } i++;wait_timeout (20 ); }while (!(rsp[1 ] &0x80 ) && (i <255 )); -if (i ==255 ) { +if (i ==255 )TRACE_RET (chip,STATUS_FAIL ); - }if (hi_cap_flow) { -if (rsp[1 ] &0x40 ) { +if (rsp[1 ] &0x40 )SET_SD_HCXC (sd_card); - }else { +else CLR_SD_HCXC (sd_card); - } -if (CHECK_PID (chip,0x5209 ) &&CHK_SD_HCXC (sd_card) && !sd20_mode) { + +if (CHECK_PID (chip,0x5209 ) &&CHK_SD_HCXC (sd_card) && !sd20_mode) support_1v8 = (rsp[1 ] &0x01 ) ?1 :0 ; - }else { +else support_1v8 =0 ; - } }else {CLR_SD_HCXC (sd_card); support_1v8 =0 ;
@@ -2346,46 +2338,39 @@ RTY_SD_RST:if (support_1v8) { retval =sd_voltage_switch (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } } retval =sd_send_cmd_get_rsp (chip,ALL_SEND_CID ,0 ,SD_RSP_TYPE_R2 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }for (i =0 ; i <3 ; i++) { retval =sd_send_cmd_get_rsp (chip,SEND_RELATIVE_ADDR ,0 ,SD_RSP_TYPE_R6 , rsp,5 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } sd_card->sd_addr = (u32 )rsp[1 ] <<24 ; sd_card->sd_addr += (u32 )rsp[2 ] <<16 ; -if (sd_card->sd_addr) { +if (sd_card->sd_addr)break ; - } } retval =sd_check_csd (chip,1 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_select_card (chip,1 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }#ifdef SUPPORT_SD_LOCK SD_UNLOCK_ENTRY: retval =sd_update_lock_status (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (sd_card->sd_lock_status &SD_LOCKED ) { sd_card->sd_lock_status |= (SD_LOCK_1BIT_MODE |SD_PWD_EXIST );
@@ -2396,23 +2381,21 @@ SD_UNLOCK_ENTRY:#endif retval =sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + retval =sd_send_cmd_get_rsp (chip,SET_CLR_CARD_DETECT ,0 ,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (support_1v8) { retval =sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + retval =sd_send_cmd_get_rsp (chip,SET_BUS_WIDTH ,2 ,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } switch_bus_width =SD_BUS_WIDTH_4 ; }else {
@@ -2420,14 +2403,12 @@ SD_UNLOCK_ENTRY: } retval =sd_send_cmd_get_rsp (chip,SET_BLOCKLEN ,0x200 ,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_set_clock_divider (chip,SD_CLK_DIVIDE_0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (!(sd_card->raw_csd[4 ] &0x40 )) sd_dont_switch =1 ;
@@ -2446,9 +2427,9 @@ SD_UNLOCK_ENTRY:if (retval ==STATUS_SUCCESS ) { retval =sd_switch_function (chip, switch_bus_width);if (retval !=STATUS_SUCCESS ) { -if (CHECK_PID (chip,0x5209 )) { +if (CHECK_PID (chip,0x5209 ))sd_change_bank_voltage (chip,SD_IO_3V3 ); - } +sd_init_power (chip); sd_dont_switch =1 ; try_sdio =0 ;
@@ -2457,9 +2438,9 @@ SD_UNLOCK_ENTRY: } }else {if (support_1v8) { -if (CHECK_PID (chip,0x5209 )) { +if (CHECK_PID (chip,0x5209 ))sd_change_bank_voltage (chip,SD_IO_3V3 ); - } +sd_init_power (chip); sd_dont_switch =1 ; try_sdio =0 ;
@@ -2471,13 +2452,12 @@ SD_UNLOCK_ENTRY:if (!support_1v8) { retval =sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + retval =sd_send_cmd_get_rsp (chip,SET_BUS_WIDTH ,2 ,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } }#ifdef SUPPORT_SD_LOCK
@@ -2490,24 +2470,22 @@ SD_UNLOCK_ENTRY:RTSX_WRITE_REG (chip,SD30_DRIVE_SEL ,0x07 , chip->sd30_drive_sel_1v8); retval =sd_set_init_para (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } -if (CHK_SD_DDR50 (sd_card)) { +if (CHK_SD_DDR50 (sd_card)) retval =sd_ddr_tuning (chip); - }else { +else retval =sd_sdr_tuning (chip); - }if (retval !=STATUS_SUCCESS ) {if (sd20_mode) {TRACE_RET (chip,STATUS_FAIL ); }else { retval =sd_init_power (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + try_sdio =0 ; sd20_mode =1 ; goto Switch_Fail;
@@ -2518,9 +2496,8 @@ SD_UNLOCK_ENTRY:if (CHK_SD_DDR50 (sd_card)) { retval =sd_wait_state_data_ready (chip,0x08 ,1 ,1000 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS ) read_lba0 =0 ; - } }if (read_lba0) {
@@ -2530,9 +2507,9 @@ SD_UNLOCK_ENTRY:TRACE_RET (chip,STATUS_FAIL ); }else { retval =sd_init_power (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + try_sdio =0 ; sd20_mode =1 ; goto Switch_Fail;
@@ -2542,9 +2519,8 @@ SD_UNLOCK_ENTRY: } retval =sd_check_wp_state (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } chip->card_bus_width[chip->card2lun[SD_CARD ]] =4 ;
Signature · 1 line
1.7.9.5
PATCH 39/57 staging/rts_pstor: remove braces {} in sd.c (mmc_test_switch_bus)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for any arm of this statement -WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-)
drivers/staging/rts_pstor/sd.c +13 -19
@@ -2544,9 +2544,8 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width)int len; retval =sd_send_cmd_get_rsp (chip,BUSTEST_W ,0 ,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,SWITCH_FAIL ); - }if (width ==MMC_8BIT_BUS ) { buf[0 ] =0x55 ;
@@ -2575,9 +2574,8 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width)rtsx_read_register (chip,REG_SD_STAT1 , &val1);rtsx_read_register (chip,REG_SD_STAT2 , &val2);rtsx_clear_sd_error (chip); -if ((val1 &0xE0 ) || val2) { +if ((val1 &0xE0 ) || val2)TRACE_RET (chip,SWITCH_ERR ); - } }else {rtsx_clear_sd_error (chip);rtsx_write_register (chip,REG_SD_CFG3 ,0x02 ,0 );
@@ -2597,11 +2595,10 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width)rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CMD0 ,0xFF ,0x40 |BUSTEST_R ); -if (width ==MMC_8BIT_BUS ) { +if (width ==MMC_8BIT_BUS )rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_BYTE_CNT_L ,0xFF ,0x08 ); - }else { +else rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_BYTE_CNT_L ,0xFF ,0x04 ); - }rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_BLOCK_CNT_L ,0xFF ,1 );rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_BLOCK_CNT_H ,0xFF ,0 );
@@ -2614,9 +2611,8 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width)rtsx_add_cmd (chip,CHECK_REG_CMD ,REG_SD_TRANSFER ,SD_TRANSFER_END ,SD_TRANSFER_END );rtsx_add_cmd (chip,READ_REG_CMD ,PPBUF_BASE2 ,0 ,0 ); -if (width ==MMC_8BIT_BUS ) { +if (width ==MMC_8BIT_BUS )rtsx_add_cmd (chip,READ_REG_CMD ,PPBUF_BASE2 +1 ,0 ,0 ); - } retval =rtsx_send_cmd (chip,SD_CARD ,100 );if (retval <0 ) {
@@ -2632,15 +2628,14 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width)u8 rsp[5 ];u32 arg; -if (CHK_MMC_DDR52 (sd_card)) { +if (CHK_MMC_DDR52 (sd_card)) arg =0x03B70600 ; - }else { +else arg =0x03B70200 ; - } + retval =sd_send_cmd_get_rsp (chip,SWITCH , arg, SD_RSP_TYPE_R1b, rsp,5 ); -if ((retval ==STATUS_SUCCESS ) && !(rsp[4 ] &MMC_SWITCH_ERR )) { +if ((retval ==STATUS_SUCCESS ) && !(rsp[4 ] &MMC_SWITCH_ERR ))return SWITCH_SUCCESS ; - } } }else {RTSX_DEBUGP ("BUSTEST_R [4bits]: 0x%02x\n" , ptr[0 ]);
@@ -2648,15 +2643,14 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width)u8 rsp[5 ];u32 arg; -if (CHK_MMC_DDR52 (sd_card)) { +if (CHK_MMC_DDR52 (sd_card)) arg =0x03B70500 ; - }else { +else arg =0x03B70100 ; - } + retval =sd_send_cmd_get_rsp (chip,SWITCH , arg, SD_RSP_TYPE_R1b, rsp,5 ); -if ((retval ==STATUS_SUCCESS ) && !(rsp[4 ] &MMC_SWITCH_ERR )) { +if ((retval ==STATUS_SUCCESS ) && !(rsp[4 ] &MMC_SWITCH_ERR ))return SWITCH_SUCCESS ; - } } }
Signature · 1 line
1.7.9.5
PATCH 40/57 staging/rts_pstor: remove braces {} in sd.c (mmc_switch_timing_bus)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for any arm of this statement -WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
drivers/staging/rts_pstor/sd.c +6 -10
@@ -2724,11 +2724,10 @@ static int mmc_switch_timing_bus(struct rtsx_chip *chip, int switch_ddr) card_type_mask = 0x03; }#else -if (chip->sd_ctl &SUPPORT_MMC_DDR_MODE ) { +if (chip->sd_ctl &SUPPORT_MMC_DDR_MODE ) card_type_mask =0x07 ; - }else { +else card_type_mask =0x03 ; - }#endif }else { card_type_mask =0x03 ;
@@ -2738,11 +2737,10 @@ static int mmc_switch_timing_bus(struct rtsx_chip *chip, int switch_ddr)u8 rsp[5 ];if (card_type &0x04 ) { -if (switch_ddr) { +if (switch_ddr)SET_MMC_DDR52 (sd_card); - }else { +else SET_MMC_52M (sd_card); - } }else if (card_type &0x02 ) {SET_MMC_52M (sd_card); }else {
@@ -2751,16 +2749,14 @@ static int mmc_switch_timing_bus(struct rtsx_chip *chip, int switch_ddr) retval =sd_send_cmd_get_rsp (chip,SWITCH ,0x03B90100 , SD_RSP_TYPE_R1b, rsp,5 ); -if ((retval !=STATUS_SUCCESS ) || (rsp[4 ] &MMC_SWITCH_ERR )) { +if ((retval !=STATUS_SUCCESS ) || (rsp[4 ] &MMC_SWITCH_ERR ))CLR_MMC_HS (sd_card); - } }sd_choose_proper_clock (chip); retval =switch_clock (chip, sd_card->sd_clock); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }/* Test Bus Procedure */ retval =mmc_test_switch_bus (chip,MMC_8BIT_BUS );
Signature · 1 line
1.7.9.5
PATCH 41/57 staging/rts_pstor: remove braces {} in sd.c (reset_mmc)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for any arm of this statement -WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 52 +++++++++++++++------------------------- 1 file changed, 19 insertions(+), 33 deletions(-)
drivers/staging/rts_pstor/sd.c +19 -33
@@ -2804,17 +2804,15 @@ static int reset_mmc(struct rtsx_chip *chip) Switch_Fail: retval =sd_prepare_reset (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip, retval); - }SET_MMC (sd_card); RTY_MMC_RST: retval =sd_send_cmd_get_rsp (chip,GO_IDLE_STATE ,0 ,SD_RSP_TYPE_R0 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } do { if (detect_card_cd(chip, SD_CARD) != STATUS_SUCCESS) {
@@ -2848,56 +2846,47 @@ RTY_MMC_RST: i++; }while (!(rsp[1 ] &0x80 ) && (i <255 )); -if (i ==255 ) { +if (i ==255 )TRACE_RET (chip,STATUS_FAIL ); - } -if ((rsp[1 ] &0x60 ) ==0x40 ) { +if ((rsp[1 ] &0x60 ) ==0x40 )SET_MMC_SECTOR_MODE (sd_card); - }else { +else CLR_MMC_SECTOR_MODE (sd_card); - } retval =sd_send_cmd_get_rsp (chip,ALL_SEND_CID ,0 ,SD_RSP_TYPE_R2 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } sd_card->sd_addr =0x00100000 ; retval =sd_send_cmd_get_rsp (chip,SET_RELATIVE_ADDR , sd_card->sd_addr,SD_RSP_TYPE_R6 , rsp,5 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_check_csd (chip,1 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } spec_ver = (sd_card->raw_csd[0 ] &0x3C ) >>2 ; retval =sd_select_card (chip,1 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_send_cmd_get_rsp (chip,SET_BLOCKLEN ,0x200 ,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }#ifdef SUPPORT_SD_LOCK MMC_UNLOCK_ENTRY: retval =sd_update_lock_status (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }#endif retval =sd_set_clock_divider (chip,SD_CLK_DIVIDE_0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } chip->card_bus_width[chip->card2lun[SD_CARD ]] =1 ;
@@ -2914,22 +2903,20 @@ MMC_UNLOCK_ENTRY: } } -if (CHK_MMC_SECTOR_MODE (sd_card) && (sd_card->capacity ==0 )) { +if (CHK_MMC_SECTOR_MODE (sd_card) && (sd_card->capacity ==0 ))TRACE_RET (chip,STATUS_FAIL ); - }if (switch_ddr &&CHK_MMC_DDR52 (sd_card)) { retval =sd_set_init_para (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =mmc_ddr_tuning (chip);if (retval !=STATUS_SUCCESS ) { retval =sd_init_power (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + switch_ddr =0 ;TRACE_GOTO (chip, Switch_Fail); }
@@ -2939,9 +2926,9 @@ MMC_UNLOCK_ENTRY: retval =sd_read_lba0 (chip);if (retval !=STATUS_SUCCESS ) { retval =sd_init_power (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } + switch_ddr =0 ;TRACE_GOTO (chip, Switch_Fail); }
@@ -2957,9 +2944,8 @@ MMC_UNLOCK_ENTRY:#endif temp =rtsx_readl (chip,RTSX_BIPR ); -if (temp &SD_WRITE_PROTECT ) { +if (temp &SD_WRITE_PROTECT ) chip->card_wp |=SD_CARD ; - }return STATUS_SUCCESS ; }
Signature · 1 line
1.7.9.5
PATCH 42/57 staging/rts_pstor: remove braces {} in sd.c (reset_sd_card)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-)
drivers/staging/rts_pstor/sd.c +8 -14
@@ -2961,36 +2961,31 @@ int reset_sd_card(struct rtsx_chip *chip) chip->capacity[chip->card2lun[SD_CARD ]] =0 ; retval =enable_card_clock (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (chip->ignore_sd &&CHK_SDIO_EXIST (chip) && !CHK_SDIO_IGNORED (chip)) {if (chip->asic_code) { retval =sd_pull_ctl_enable (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } }else { retval =rtsx_write_register (chip,FPGA_PULL_CTL ,FPGA_SD_PULL_CTL_BIT |0x20 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } } retval =card_share_mode (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } chip->sd_io =1 ;TRACE_RET (chip,STATUS_FAIL ); } retval =sd_init_power (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (chip->sd_ctl &RESET_MMC_FIRST ) { retval =reset_mmc (chip);
@@ -3029,18 +3024,17 @@ int reset_sd_card(struct rtsx_chip *chip) } retval =sd_set_clock_divider (chip,SD_CLK_DIVIDE_0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } +RTSX_WRITE_REG (chip,REG_SD_BYTE_CNT_L ,0xFF ,0 );RTSX_WRITE_REG (chip,REG_SD_BYTE_CNT_H ,0xFF ,2 ); chip->capacity[chip->card2lun[SD_CARD ]] = sd_card->capacity; retval =sd_set_init_para (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }RTSX_DEBUGP ("sd_card->sd_type = 0x%x\n" , sd_card->sd_type);
Signature · 1 line
1.7.9.5
PATCH 43/57 staging/rts_pstor: remove braces {} in sd.c (reset_mmc_only)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
drivers/staging/rts_pstor/sd.c +6 -10
@@ -3060,33 +3060,29 @@ static int reset_mmc_only(struct rtsx_chip *chip) chip->capacity[chip->card2lun[SD_CARD ]] = sd_card->capacity =0 ; retval =enable_card_clock (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_init_power (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =reset_mmc (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } retval =sd_set_clock_divider (chip,SD_CLK_DIVIDE_0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } +RTSX_WRITE_REG (chip,REG_SD_BYTE_CNT_L ,0xFF ,0 );RTSX_WRITE_REG (chip,REG_SD_BYTE_CNT_H ,0xFF ,2 ); chip->capacity[chip->card2lun[SD_CARD ]] = sd_card->capacity; retval =sd_set_init_para (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }RTSX_DEBUGP ("In reset_mmc_only, sd_card->sd_type = 0x%x\n" , sd_card->sd_type);
Signature · 1 line
1.7.9.5
PATCH 44/57 staging/rts_pstor: remove braces {} in sd.c (wait_data_buf_ready)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rts_pstor/sd.c +1 -2
@@ -3106,9 +3106,8 @@ static int wait_data_buf_ready(struct rtsx_chip *chip) retval =sd_send_cmd_get_rsp (chip,SEND_STATUS , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (sd_card->sd_data_buf_ready) { return sd_send_cmd_get_rsp(chip, SEND_STATUS,
Signature · 1 line
1.7.9.5
PATCH 45/57 staging/rts_pstor: remove braces {} in sd.c (sd_stop_seq_mode)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/staging/rts_pstor/sd.c +5 -6
@@ -3127,19 +3127,18 @@ void sd_stop_seq_mode(struct rtsx_chip *chip)if (sd_card->seq_mode) { retval =sd_switch_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )return ; - } retval =sd_send_cmd_get_rsp (chip,STOP_TRANSMISSION ,0 , SD_RSP_TYPE_R1b,NULL ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )sd_set_err_code (chip,SD_STS_ERR ); - } + retval =sd_wait_state_data_ready (chip,0x08 ,1 ,1000 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )sd_set_err_code (chip,SD_STS_ERR ); - } + sd_card->seq_mode =0 ;rtsx_write_register (chip,RBCTL ,RB_FLUSH ,RB_FLUSH );
Signature · 1 line
1.7.9.5
PATCH 46/57 staging/rts_pstor: remove braces {} in sd.c (sd_auto_tune_clock)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/rts_pstor/sd.c +2 -4
@@ -3151,9 +3151,8 @@ static inline int sd_auto_tune_clock(struct rtsx_chip *chip)int retval;if (chip->asic_code) { -if (sd_card->sd_clock >30 ) { +if (sd_card->sd_clock >30 ) sd_card->sd_clock -=20 ; - } }else {switch (sd_card->sd_clock) {case CLK_200 :
@@ -3186,9 +3185,8 @@ static inline int sd_auto_tune_clock(struct rtsx_chip *chip) } retval =sd_switch_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }return STATUS_SUCCESS ; }
Signature · 1 line
1.7.9.5
PATCH 47/57 staging/rts_pstor: remove braces {} in sd.c (sd_rw)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for any arm of this statement -WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-)
drivers/staging/rts_pstor/sd.c +10 -16
@@ -3224,11 +3224,10 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, u16 s } } -if (!CHK_SD_HCXC (sd_card) && !CHK_MMC_SECTOR_MODE (sd_card)) { +if (!CHK_SD_HCXC (sd_card) && !CHK_MMC_SECTOR_MODE (sd_card)) data_addr = start_sector <<9 ; - }else { +else data_addr = start_sector; - }sd_clr_err_code (chip);
@@ -3283,21 +3282,19 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, u16 srtsx_add_cmd (chip,WRITE_REG_CMD ,CARD_DATA_SOURCE ,0x01 ,RING_BUFFER ); -if (CHK_MMC_8BIT (sd_card)) { +if (CHK_MMC_8BIT (sd_card))rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_8 ); - }else if (CHK_MMC_4BIT (sd_card) ||CHK_SD (sd_card)) { +else if (CHK_MMC_4BIT (sd_card) ||CHK_SD (sd_card))rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_4 ); - }else { +else rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_1 ); - }if (sd_card->seq_mode) { cfg2 =SD_NO_CALCULATE_CRC7 |SD_CHECK_CRC16 |SD_NO_WAIT_BUSY_END |SD_NO_CHECK_CRC7 |SD_RSP_LEN_0 ;if (CHECK_PID (chip,0x5209 )) { -if (!CHK_SD30_SPEED (sd_card)) { +if (!CHK_SD30_SPEED (sd_card)) cfg2 |=SD_NO_CHECK_WAIT_CRC_TO ; - } }rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CFG2 ,0xFF , cfg2);
@@ -3327,9 +3324,8 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, u16 s cfg2 =SD_CALCULATE_CRC7 |SD_CHECK_CRC16 |SD_NO_WAIT_BUSY_END |SD_CHECK_CRC7 |SD_RSP_LEN_6 ;if (CHECK_PID (chip,0x5209 )) { -if (!CHK_SD30_SPEED (sd_card)) { +if (!CHK_SD30_SPEED (sd_card)) cfg2 |=SD_NO_CHECK_WAIT_CRC_TO ; - } }rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CFG2 ,0xFF , cfg2);
@@ -3370,9 +3366,8 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, u16 s cfg2 =SD_NO_CALCULATE_CRC7 |SD_CHECK_CRC16 |SD_NO_WAIT_BUSY_END |SD_NO_CHECK_CRC7 |SD_RSP_LEN_0 ;if (CHECK_PID (chip,0x5209 )) { -if (!CHK_SD30_SPEED (sd_card)) { +if (!CHK_SD30_SPEED (sd_card)) cfg2 |=SD_NO_CHECK_WAIT_CRC_TO ; - } }rtsx_add_cmd (chip,WRITE_REG_CMD ,REG_SD_CFG2 ,0xFF , cfg2);
@@ -3397,11 +3392,10 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, u16 s sd_card->seq_mode =0 ; -if (retval == -ETIMEDOUT ) { +if (retval == -ETIMEDOUT ) err =STATUS_TIMEDOUT ; - }else { +else err =STATUS_FAIL ; - }rtsx_read_register (chip,REG_SD_STAT1 , &stat);rtsx_clear_sd_error (chip);
Signature · 1 line
1.7.9.5
PATCH 48/57 staging/rts_pstor: remove braces {} in sd.c (ext_sd_send_cmd_get_rsp)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-)
drivers/staging/rts_pstor/sd.c +13 -20
@@ -3481,9 +3481,8 @@ int ext_sd_send_cmd_get_rsp(struct rtsx_chip *chip, u8 cmd_idx,RTSX_DEBUGP ("EXT SD/MMC CMD %d\n" , cmd_idx); -if (rsp_type == SD_RSP_TYPE_R1b) { +if (rsp_type == SD_RSP_TYPE_R1b) timeout =3000 ; - } RTY_SEND_CMD:
@@ -3503,14 +3502,14 @@ RTY_SEND_CMD:rtsx_add_cmd (chip,CHECK_REG_CMD ,REG_SD_TRANSFER ,SD_TRANSFER_END ,SD_TRANSFER_END );if (rsp_type ==SD_RSP_TYPE_R2 ) { -for (reg_addr =PPBUF_BASE2 ; reg_addr <PPBUF_BASE2 +16 ; reg_addr++) { +for (reg_addr =PPBUF_BASE2 ; reg_addr <PPBUF_BASE2 +16 ; reg_addr++)rtsx_add_cmd (chip,READ_REG_CMD , reg_addr,0 ,0 ); - } + stat_idx =17 ; }else if (rsp_type !=SD_RSP_TYPE_R0 ) { -for (reg_addr =REG_SD_CMD0 ; reg_addr <=REG_SD_CMD4 ; reg_addr++) { +for (reg_addr =REG_SD_CMD0 ; reg_addr <=REG_SD_CMD4 ; reg_addr++)rtsx_add_cmd (chip,READ_REG_CMD , reg_addr,0 ,0 ); - } + stat_idx =6 ; }rtsx_add_cmd (chip,READ_REG_CMD ,REG_SD_CMD5 ,0 ,0 );
@@ -3524,9 +3523,8 @@ RTY_SEND_CMD:if (rsp_type &SD_WAIT_BUSY_END ) { retval =sd_check_data0_status (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip, retval); - } }else {sd_set_err_code (chip,SD_TO_ERR ); }
@@ -3534,9 +3532,8 @@ RTY_SEND_CMD:TRACE_RET (chip,STATUS_FAIL ); } -if (rsp_type ==SD_RSP_TYPE_R0 ) { +if (rsp_type ==SD_RSP_TYPE_R0 )return STATUS_SUCCESS ; - } ptr =rtsx_get_cmd_data (chip) +1 ;
@@ -3565,9 +3562,8 @@ RTY_SEND_CMD:if ((cmd_idx ==SELECT_CARD ) || (cmd_idx ==APP_CMD ) || (cmd_idx ==SEND_STATUS ) || (cmd_idx ==STOP_TRANSMISSION )) {if ((cmd_idx !=STOP_TRANSMISSION ) && (special_check ==0 )) { -if (ptr[1 ] &0x80 ) { +if (ptr[1 ] &0x80 )TRACE_RET (chip,STATUS_FAIL ); - } }#ifdef SUPPORT_SD_LOCK if (ptr[1 ] &0x7D )
@@ -3577,26 +3573,23 @@ RTY_SEND_CMD: {TRACE_RET (chip,STATUS_FAIL ); } -if (ptr[2 ] &0xF8 ) { +if (ptr[2 ] &0xF8 )TRACE_RET (chip,STATUS_FAIL ); - }if (cmd_idx ==SELECT_CARD ) {if (rsp_type ==SD_RSP_TYPE_R2 ) { -if ((ptr[3 ] &0x1E ) !=0x04 ) { +if ((ptr[3 ] &0x1E ) !=0x04 )TRACE_RET (chip,STATUS_FAIL ); - } + }else if (rsp_type ==SD_RSP_TYPE_R0 ) { -if ((ptr[3 ] &0x1E ) !=0x03 ) { +if ((ptr[3 ] &0x1E ) !=0x03 )TRACE_RET (chip,STATUS_FAIL ); - } } } } -if (rsp && rsp_len) { +if (rsp && rsp_len)memcpy (rsp, ptr, rsp_len); - }return STATUS_SUCCESS ; }
Signature · 1 line
1.7.9.5
PATCH 49/57 staging/rts_pstor: remove braces {} in sd.c (ext_sd_get_rsp)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/staging/rts_pstor/sd.c +6 -8
@@ -3599,29 +3599,27 @@ int ext_sd_get_rsp(struct rtsx_chip *chip, int len, u8 *rsp, u8 rsp_type)int retval, rsp_len;u16 reg_addr; -if (rsp_type ==SD_RSP_TYPE_R0 ) { +if (rsp_type ==SD_RSP_TYPE_R0 )return STATUS_SUCCESS ; - }rtsx_init_cmd (chip);if (rsp_type ==SD_RSP_TYPE_R2 ) { -for (reg_addr =PPBUF_BASE2 ; reg_addr <PPBUF_BASE2 +16 ; reg_addr++) { +for (reg_addr =PPBUF_BASE2 ; reg_addr <PPBUF_BASE2 +16 ; reg_addr++)rtsx_add_cmd (chip,READ_REG_CMD , reg_addr,0xFF ,0 ); - } + rsp_len =17 ; }else if (rsp_type !=SD_RSP_TYPE_R0 ) { -for (reg_addr =REG_SD_CMD0 ; reg_addr <=REG_SD_CMD4 ; reg_addr++) { +for (reg_addr =REG_SD_CMD0 ; reg_addr <=REG_SD_CMD4 ; reg_addr++)rtsx_add_cmd (chip,READ_REG_CMD , reg_addr,0xFF ,0 ); - } + rsp_len =6 ; }rtsx_add_cmd (chip,READ_REG_CMD ,REG_SD_CMD5 ,0xFF ,0 ); retval =rtsx_send_cmd (chip,SD_CARD ,100 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (rsp) {int min_len = (rsp_len < len) ? rsp_len : len;
Signature · 1 line
1.7.9.5
PATCH 50/57 staging/rts_pstor: remove braces {} in sd.c (sd_pass_thru_mode)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rts_pstor/sd.c +1 -2
@@ -3690,9 +3690,8 @@ int sd_pass_thru_mode(struct scsi_cmnd *srb, struct rtsx_chip *chip) } buf[5 ] = (1 ==CHK_SD (sd_card)) ?0x01 :0x02 ; -if (chip->card_wp &SD_CARD ) { +if (chip->card_wp &SD_CARD ) buf[5 ] |=0x80 ; - } buf[6 ] = (u8)(sd_card->sd_addr >>16 ); buf[7 ] = (u8)(sd_card->sd_addr >>24 );
Signature · 1 line
1.7.9.5
PATCH 51/57 staging/rts_pstor: remove braces {} in sd.c (get_rsp_type)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rts_pstor/sd.c +1 -2
@@ -3706,9 +3706,8 @@ int sd_pass_thru_mode(struct scsi_cmnd *srb, struct rtsx_chip *chip)static inline int get_rsp_type (struct scsi_cmnd *srb,u8 *rsp_type,int *rsp_len) { -if (!rsp_type || !rsp_len) { +if (!rsp_type || !rsp_len)return STATUS_FAIL ; - }switch (srb->cmnd[10 ]) {case 0x03 :
Signature · 1 line
1.7.9.5
PATCH 52/57 staging/rts_pstor: remove braces {} in sd.c (sd_execute_no_data)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 41 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 26 deletions(-)
drivers/staging/rts_pstor/sd.c +15 -26
@@ -3757,9 +3757,8 @@ int sd_execute_no_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) } retval =sd_switch_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - }if (sd_card->pre_cmd_err) { sd_card->pre_cmd_err =0 ;
@@ -3768,12 +3767,11 @@ int sd_execute_no_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) } cmd_idx = srb->cmnd[2 ] &0x3F ; -if (srb->cmnd[1 ] &0x02 ) { +if (srb->cmnd[1 ] &0x02 ) standby =1 ; - } -if (srb->cmnd[1 ] &0x01 ) { + +if (srb->cmnd[1 ] &0x01 ) acmd =1 ; - } arg = ((u32 )srb->cmnd[3 ] <<24 ) | ((u32 )srb->cmnd[4 ] <<16 ) | ((u32 )srb->cmnd[5 ] <<8 ) | srb->cmnd[6 ];
@@ -3786,64 +3784,56 @@ int sd_execute_no_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) sd_card->last_rsp_type = rsp_type; retval =sd_switch_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - }#ifdef SUPPORT_SD_LOCK if ((sd_card->sd_lock_status &SD_LOCK_1BIT_MODE ) ==0 ) {if (CHK_MMC_8BIT (sd_card)) { retval =rtsx_write_register (chip,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_8 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - } + }else if (CHK_SD (sd_card) ||CHK_MMC_4BIT (sd_card)) { retval =rtsx_write_register (chip,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_4 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - } } }#else retval =rtsx_write_register (chip,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_4 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - }#endif if (standby) { retval =sd_select_card (chip,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Cmd_Failed); - } }if (acmd) { retval =ext_sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Cmd_Failed); - } } retval =ext_sd_send_cmd_get_rsp (chip, cmd_idx, arg, rsp_type, sd_card->rsp, rsp_len,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Cmd_Failed); - }if (standby) { retval =sd_select_card (chip,1 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Cmd_Failed); - } }#ifdef SUPPORT_SD_LOCK retval =sd_update_lock_status (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Cmd_Failed); - }#endif scsi_set_resid (srb,0 );
@@ -3854,9 +3844,8 @@ SD_Execute_Cmd_Failed:set_sense_type (chip, lun,SENSE_TYPE_NO_SENSE );release_sd_card (chip);do_reset_sd_card (chip); -if (!(chip->card_ready &SD_CARD )) { +if (!(chip->card_ready &SD_CARD ))set_sense_type (chip, lun,SENSE_TYPE_MEDIA_NOT_PRESENT ); - }TRACE_RET (chip,TRANSPORT_FAILED ); }
Signature · 1 line
1.7.9.5
PATCH 53/57 staging/rts_pstor: remove braces {} in sd.c (sd_execute_read_data)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for any arm of this statement -WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 71 +++++++++++++++------------------------- 1 file changed, 27 insertions(+), 44 deletions(-)
drivers/staging/rts_pstor/sd.c +27 -44
@@ -3872,20 +3872,18 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) } retval =sd_switch_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - } cmd_idx = srb->cmnd[2 ] &0x3F ; -if (srb->cmnd[1 ] &0x04 ) { +if (srb->cmnd[1 ] &0x04 ) send_cmd12 =1 ; - } -if (srb->cmnd[1 ] &0x02 ) { + +if (srb->cmnd[1 ] &0x02 ) standby =1 ; - } -if (srb->cmnd[1 ] &0x01 ) { + +if (srb->cmnd[1 ] &0x01 ) acmd =1 ; - } data_len = ((u32 )srb->cmnd[7 ] <<16 ) | ((u32 )srb->cmnd[8 ] <<8 ) | srb->cmnd[9 ];
@@ -3897,19 +3895,17 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) sd_card->last_rsp_type = rsp_type; retval =sd_switch_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - }#ifdef SUPPORT_SD_LOCK if ((sd_card->sd_lock_status &SD_LOCK_1BIT_MODE ) ==0 ) { -if (CHK_MMC_8BIT (sd_card)) { +if (CHK_MMC_8BIT (sd_card)) bus_width =SD_BUS_WIDTH_8 ; - }else if (CHK_SD (sd_card) ||CHK_MMC_4BIT (sd_card)) { +else if (CHK_SD (sd_card) ||CHK_MMC_4BIT (sd_card)) bus_width =SD_BUS_WIDTH_4 ; - }else { +else bus_width =SD_BUS_WIDTH_1 ; - } }else { bus_width =SD_BUS_WIDTH_4 ; }
@@ -3921,24 +3917,21 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)if (data_len <512 ) { retval =ext_sd_send_cmd_get_rsp (chip,SET_BLOCKLEN , data_len,SD_RSP_TYPE_R1 ,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - } }if (standby) { retval =sd_select_card (chip,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - } }if (acmd) { retval =ext_sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - } }if (data_len <=512 ) {
@@ -3957,9 +3950,8 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) cmd[4 ] = srb->cmnd[6 ]; buf =kmalloc (data_len,GFP_KERNEL ); -if (buf ==NULL ) { +if (buf ==NULL )TRACE_RET (chip,TRANSPORT_ERROR ); - } retval =sd_read_data (chip,SD_TM_NORMAL_READ , cmd,5 , byte_cnt, blk_cnt, bus_width, buf, data_len,2000 );
@@ -4014,56 +4006,48 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) } retval =ext_sd_get_rsp (chip, rsp_len, sd_card->rsp, rsp_type); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - }if (standby) { retval =sd_select_card (chip,1 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - } }if (send_cmd12) { retval =ext_sd_send_cmd_get_rsp (chip,STOP_TRANSMISSION ,0 , SD_RSP_TYPE_R1b,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - } }if (data_len <512 ) { retval =ext_sd_send_cmd_get_rsp (chip,SET_BLOCKLEN ,0x200 ,SD_RSP_TYPE_R1 ,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - } retval =rtsx_write_register (chip,SD_BYTE_CNT_H ,0xFF ,0x02 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - } + retval =rtsx_write_register (chip,SD_BYTE_CNT_L ,0xFF ,0x00 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - } } -if ((srb->cmnd[1 ] &0x02 ) || (srb->cmnd[1 ] &0x04 )) { +if ((srb->cmnd[1 ] &0x02 ) || (srb->cmnd[1 ] &0x04 )) cmd13_checkbit =1 ; - }for (i =0 ; i <3 ; i++) { retval =ext_sd_send_cmd_get_rsp (chip,SEND_STATUS , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 , cmd13_checkbit); -if (retval ==STATUS_SUCCESS ) { +if (retval ==STATUS_SUCCESS )break ; - } } -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Read_Cmd_Failed); - }scsi_set_resid (srb,0 );return TRANSPORT_GOOD ;
@@ -4071,14 +4055,13 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) SD_Execute_Read_Cmd_Failed: sd_card->pre_cmd_err =1 ;set_sense_type (chip, lun,SENSE_TYPE_NO_SENSE ); -if (read_err) { +if (read_err)set_sense_type (chip, lun,SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR ); - } +release_sd_card (chip);do_reset_sd_card (chip); -if (!(chip->card_ready &SD_CARD )) { +if (!(chip->card_ready &SD_CARD ))set_sense_type (chip, lun,SENSE_TYPE_MEDIA_NOT_PRESENT ); - }TRACE_RET (chip,TRANSPORT_FAILED ); }
Signature · 1 line
1.7.9.5
PATCH 54/57 staging/rts_pstor: remove braces {} in sd.c (sd_execute_write_data)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for any arm of this statement -WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 90 ++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 55 deletions(-)
drivers/staging/rts_pstor/sd.c +35 -55
@@ -4093,20 +4093,18 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) } retval =sd_switch_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - } cmd_idx = srb->cmnd[2 ] &0x3F ; -if (srb->cmnd[1 ] &0x04 ) { +if (srb->cmnd[1 ] &0x04 ) send_cmd12 =1 ; - } -if (srb->cmnd[1 ] &0x02 ) { + +if (srb->cmnd[1 ] &0x02 ) standby =1 ; - } -if (srb->cmnd[1 ] &0x01 ) { + +if (srb->cmnd[1 ] &0x01 ) acmd =1 ; - } data_len = ((u32 )srb->cmnd[7 ] <<16 ) | ((u32 )srb->cmnd[8 ] <<8 ) | srb->cmnd[9 ]; arg = ((u32)srb->cmnd[3] << 24) | ((u32)srb->cmnd[4] << 16) |
@@ -4127,75 +4125,66 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) sd_card->last_rsp_type = rsp_type; retval =sd_switch_clock (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - }#ifdef SUPPORT_SD_LOCK if ((sd_card->sd_lock_status &SD_LOCK_1BIT_MODE ) ==0 ) {if (CHK_MMC_8BIT (sd_card)) { retval =rtsx_write_register (chip,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_8 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - } + }else if (CHK_SD (sd_card) ||CHK_MMC_4BIT (sd_card)) { retval =rtsx_write_register (chip,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_4 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - } } }#else retval =rtsx_write_register (chip,REG_SD_CFG1 ,0x03 ,SD_BUS_WIDTH_4 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,TRANSPORT_FAILED ); - }#endif if (data_len <512 ) { retval =ext_sd_send_cmd_get_rsp (chip,SET_BLOCKLEN , data_len,SD_RSP_TYPE_R1 ,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - } }if (standby) { retval =sd_select_card (chip,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - } }if (acmd) { retval =ext_sd_send_cmd_get_rsp (chip,APP_CMD , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - } } retval =ext_sd_send_cmd_get_rsp (chip, cmd_idx, arg, rsp_type, sd_card->rsp, rsp_len,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - }if (data_len <=512 ) {u16 i;u8 *buf; buf =kmalloc (data_len,GFP_KERNEL ); -if (buf ==NULL ) { +if (buf ==NULL )TRACE_RET (chip,TRANSPORT_ERROR ); - }rtsx_stor_get_xfer_buf (buf, data_len, srb);#ifdef SUPPORT_SD_LOCK -if (cmd_idx ==LOCK_UNLOCK ) { +if (cmd_idx ==LOCK_UNLOCK ) lock_cmd_type = buf[0 ] &0x0F ; - }#endif if (data_len >256 ) {
@@ -4287,11 +4276,11 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) }rtsx_init_cmd (chip); -if (CHECK_PID (chip,0x5209 )) { +if (CHECK_PID (chip,0x5209 ))rtsx_add_cmd (chip,CHECK_REG_CMD ,SD_BUS_STAT ,SD_DAT0_STATUS ,SD_DAT0_STATUS ); - }else { +else rtsx_add_cmd (chip,CHECK_REG_CMD ,0xFD30 ,0x02 ,0x02 ); - } +rtsx_send_cmd (chip,SD_CARD ,250 ); retval =sd_update_lock_status (chip);
@@ -4304,61 +4293,53 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)if (standby) { retval =sd_select_card (chip,1 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - } }if (send_cmd12) { retval =ext_sd_send_cmd_get_rsp (chip,STOP_TRANSMISSION ,0 , SD_RSP_TYPE_R1b,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - } }if (data_len <512 ) { retval =ext_sd_send_cmd_get_rsp (chip,SET_BLOCKLEN ,0x200 ,SD_RSP_TYPE_R1 ,NULL ,0 ,0 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - } retval =rtsx_write_register (chip,SD_BYTE_CNT_H ,0xFF ,0x02 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - } +rtsx_write_register (chip,SD_BYTE_CNT_L ,0xFF ,0x00 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - } } -if ((srb->cmnd[1 ] &0x02 ) || (srb->cmnd[1 ] &0x04 )) { +if ((srb->cmnd[1 ] &0x02 ) || (srb->cmnd[1 ] &0x04 )) cmd13_checkbit =1 ; - }for (i =0 ; i <3 ; i++) { retval =ext_sd_send_cmd_get_rsp (chip,SEND_STATUS , sd_card->sd_addr,SD_RSP_TYPE_R1 ,NULL ,0 , cmd13_checkbit); -if (retval ==STATUS_SUCCESS ) { +if (retval ==STATUS_SUCCESS )break ; - } } -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_GOTO (chip, SD_Execute_Write_Cmd_Failed); - }#ifdef SUPPORT_SD_LOCK if (cmd_idx ==LOCK_UNLOCK ) {if (!lock_cmd_fail) {RTSX_DEBUGP ("lock_cmd_type = 0x%x\n" , lock_cmd_type); -if (lock_cmd_type &SD_CLR_PWD ) { +if (lock_cmd_type &SD_CLR_PWD ) sd_card->sd_lock_status &= ~SD_PWD_EXIST ; - } -if (lock_cmd_type &SD_SET_PWD ) { + +if (lock_cmd_type &SD_SET_PWD ) sd_card->sd_lock_status |=SD_PWD_EXIST ; - } } RTSX_DEBUGP("sd_lock_state = 0x%x, sd_card->sd_lock_status = 0x%x\n",
@@ -4395,14 +4376,13 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) SD_Execute_Write_Cmd_Failed: sd_card->pre_cmd_err =1 ;set_sense_type (chip, lun,SENSE_TYPE_NO_SENSE ); -if (write_err) { +if (write_err)set_sense_type (chip, lun,SENSE_TYPE_MEDIA_WRITE_ERR ); - } +release_sd_card (chip);do_reset_sd_card (chip); -if (!(chip->card_ready &SD_CARD )) { +if (!(chip->card_ready &SD_CARD ))set_sense_type (chip, lun,SENSE_TYPE_MEDIA_NOT_PRESENT ); - }TRACE_RET (chip,TRANSPORT_FAILED ); }
Signature · 1 line
1.7.9.5
PATCH 55/57 staging/rts_pstor: remove braces {} in sd.c (sd_hw_rst)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rts_pstor/sd.c +1 -2
@@ -4452,9 +4452,8 @@ int sd_hw_rst(struct scsi_cmnd *srb, struct rtsx_chip *chip)switch (srb->cmnd[1 ] &0x0F ) {case 0 :#ifdef SUPPORT_SD_LOCK -if (0x64 == srb->cmnd[9 ]) { +if (0x64 == srb->cmnd[9 ]) sd_card->sd_lock_status |=SD_SDR_RST ; - }#endif retval =reset_sd_card (chip);if (retval !=STATUS_SUCCESS ) {
Signature · 1 line
1.7.9.5
PATCH 56/57 staging/rts_pstor: remove braces {} in sd.c (sd_power_off_card3v3)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/staging/rts_pstor/sd.c +3 -6
@@ -4504,26 +4504,23 @@ int sd_power_off_card3v3(struct rtsx_chip *chip)int retval; retval =disable_card_clock (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }RTSX_WRITE_REG (chip,CARD_OE ,SD_OUTPUT_EN ,0 );if (!chip->ft2_fast_mode) { retval =card_power_off (chip,SD_CARD ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }wait_timeout (50 ); }if (chip->asic_code) { retval =sd_pull_ctl_disable (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } }else {RTSX_WRITE_REG (chip,FPGA_PULL_CTL ,FPGA_SD_PULL_CTL_BIT |0x20 ,FPGA_SD_PULL_CTL_BIT );
Signature · 1 line
1.7.9.5
PATCH 57/57 staging/rts_pstor: remove braces {} in sd.c (release_sd_card)
In reply to Toshiaki Yamanefixed below checkpatch warnings.
-WARNING: braces {} are not necessary for single statement blocks
--- drivers/staging/rts_pstor/sd.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/staging/rts_pstor/sd.c +3 -6
@@ -4552,19 +4552,16 @@ int release_sd_card(struct rtsx_chip *chip)memset (sd_card->raw_scr,0 ,8 ); retval =sd_power_off_card3v3 (chip); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - }if (CHECK_PID (chip,0x5209 )) { retval =sd_change_bank_voltage (chip,SD_IO_3V3 ); -if (retval !=STATUS_SUCCESS ) { +if (retval !=STATUS_SUCCESS )TRACE_RET (chip,STATUS_FAIL ); - } -if (CHK_SD30_SPEED (sd_card)) { +if (CHK_SD30_SPEED (sd_card))RTSX_WRITE_REG (chip,SD30_DRIVE_SEL ,0x07 , chip->sd30_drive_sel_3v3); - }RTSX_WRITE_REG (chip,OCPPARA2 ,SD_OCP_THD_MASK , chip->sd_400mA_ocp_thd); }
Signature · 1 line
1.7.9.5