Loading drivers/staging/rts5139/rts51x_chip.c +0 −51 Original line number Diff line number Diff line Loading @@ -300,33 +300,6 @@ static void rts51x_auto_delink(struct rts51x_chip *chip) void rts51x_polling_func(struct rts51x_chip *chip) { #ifdef SUPPORT_SD_LOCK struct sd_info *sd_card = &(chip->sd_card); if (sd_card->sd_erase_status) { if (chip->card_exist & SD_CARD) { u8 val; rts51x_read_register(chip, SD_BUS_STAT, &val); if (val & SD_DAT0_STATUS) { /* Erase completed */ sd_card->sd_erase_status = SD_NOT_ERASE; sd_card->sd_lock_notify = 1; /* SD card should be reinited, * so we release it here. */ sd_cleanup_work(chip); release_sd_card(chip); chip->card_ready &= ~SD_CARD; chip->card_exist &= ~SD_CARD; chip->rw_card[chip->card2lun[SD_CARD]] = NULL; clear_bit(chip->card2lun[SD_CARD], &(chip->lun_mc)); } } else { sd_card->sd_erase_status = SD_NOT_ERASE; } } #endif rts51x_init_cards(chip); Loading Loading @@ -923,24 +896,6 @@ void rts51x_pp_status(struct rts51x_chip *chip, unsigned int lun, u8 *status, status[0x0F] = 0x00; } } #ifdef SUPPORT_SD_LOCK /* SD Lock/Unlock */ if (card == SD_CARD) { status[0x17] = 0x80; if (sd_card->sd_erase_status) status[0x17] |= 0x01; /* Under erasing */ if (sd_card->sd_lock_status & SD_LOCKED) { status[0x17] |= 0x02; /* Locked */ status[0x07] |= 0x40; /* Read protected */ } if (sd_card->sd_lock_status & SD_PWD_EXIST) status[0x17] |= 0x04; /* Contain PWD */ } else { status[0x17] = 0x00; } RTS51X_DEBUGP("status[0x17] = 0x%x\n", status[0x17]); #endif /* Function 0 * Support Magic Gate, CPRM and PhyRegister R/W */ Loading @@ -950,12 +905,6 @@ void rts51x_pp_status(struct rts51x_chip *chip, unsigned int lun, u8 *status, * Support OC LUN status & WP LUN status */ status[0x1A] = 0x28; /* Function 7 */ #ifdef SUPPORT_SD_LOCK /* Support SD Lock/Unlock */ status[0x1F] = 0x01; #endif /* Function 2 * Support OC LUN status & WP LUN status */ status[0x1A] = 0x28; Loading drivers/staging/rts5139/rts51x_chip.h +0 −13 Original line number Diff line number Diff line Loading @@ -39,10 +39,6 @@ #define SUPPORT_CPRM #define SUPPORT_MAGIC_GATE #define SUPPORT_MSXC /* { wwang, 2010-07-26 * Add support for SD lock/unlock */ /* #define SUPPORT_SD_LOCK */ /* } wwang, 2010-07-26 */ #ifdef SUPPORT_MAGIC_GA /* Using NORMAL_WRITE instead of AUTO_WRITE to set ICVTE */ Loading Loading @@ -205,10 +201,6 @@ struct trace_msg_t { /* WRITE ERROR */ #define SENSE_TYPE_MG_WRITE_ERR 0x0e #endif #ifdef SUPPORT_SD_LOCK /* FOR Locked SD card */ #define SENSE_TYPE_MEDIA_READ_FORBIDDEN 0x10 #endif /*---- sense key ----*/ #define ILI 0x20 /* ILI bit is on */ Loading Loading @@ -612,11 +604,6 @@ struct sd_info { u8 sd_reset_fail; /* sangdy2010-07-01 */ u8 sd_send_status_en; #ifdef SUPPORT_SD_LOCK u8 sd_lock_status; u8 sd_erase_status; u8 sd_lock_notify; #endif }; #define MODE_512_SEQ 0x01 Loading drivers/staging/rts5139/rts51x_scsi.c +0 −62 Original line number Diff line number Diff line Loading @@ -396,12 +396,6 @@ void set_sense_type(struct rts51x_chip *chip, unsigned int lun, int sense_type) break; #endif #ifdef SUPPORT_SD_LOCK case SENSE_TYPE_MEDIA_READ_FORBIDDEN: set_sense_data(chip, lun, CUR_ERR, 0x07, 0, 0x11, 0x13, 0, 0); break; #endif case SENSE_TYPE_NO_SENSE: default: set_sense_data(chip, lun, CUR_ERR, 0, 0, 0, 0, 0, 0); Loading Loading @@ -448,20 +442,6 @@ static int test_unit_ready(struct scsi_cmnd *srb, struct rts51x_chip *chip) set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); return TRANSPORT_FAILED; } #ifdef SUPPORT_SD_LOCK if (get_lun_card(chip, SCSI_LUN(srb)) == SD_CARD) { struct sd_info *sd_card = &(chip->sd_card); if (sd_card->sd_lock_notify) { sd_card->sd_lock_notify = 0; set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); return TRANSPORT_FAILED; } else if (sd_card->sd_lock_status & SD_LOCKED) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_READ_FORBIDDEN); return TRANSPORT_FAILED; } } #endif return TRANSPORT_GOOD; } Loading Loading @@ -797,9 +777,6 @@ static int request_sense(struct scsi_cmnd *srb, struct rts51x_chip *chip) static int read_write(struct scsi_cmnd *srb, struct rts51x_chip *chip) { #ifdef SUPPORT_SD_LOCK struct sd_info *sd_card = &(chip->sd_card); #endif unsigned int lun = SCSI_LUN(srb); int retval; u32 start_sec; Loading @@ -819,25 +796,6 @@ static int read_write(struct scsi_cmnd *srb, struct rts51x_chip *chip) rts51x_prepare_run(chip); RTS51X_SET_STAT(chip, STAT_RUN); #ifdef SUPPORT_SD_LOCK if (sd_card->sd_erase_status) { /* Accessing to any card is forbidden * until the erase procedure of SD is completed */ RTS51X_DEBUGP("SD card being erased!\n"); set_sense_type(chip, lun, SENSE_TYPE_MEDIA_READ_FORBIDDEN); TRACE_RET(chip, TRANSPORT_FAILED); } if (get_lun_card(chip, lun) == SD_CARD) { if (sd_card->sd_lock_status & SD_LOCKED) { RTS51X_DEBUGP("SD card locked!\n"); set_sense_type(chip, lun, SENSE_TYPE_MEDIA_READ_FORBIDDEN); TRACE_RET(chip, TRANSPORT_FAILED); } } #endif if ((srb->cmnd[0] == READ_10) || (srb->cmnd[0] == WRITE_10)) { start_sec = ((u32) srb->cmnd[2] << 24) | Loading Loading @@ -1863,30 +1821,10 @@ int mg_send_key(struct scsi_cmnd *srb, struct rts51x_chip *chip) int rts51x_scsi_handler(struct scsi_cmnd *srb, struct rts51x_chip *chip) { #ifdef SUPPORT_SD_LOCK struct sd_info *sd_card = &(chip->sd_card); #endif struct ms_info *ms_card = &(chip->ms_card); unsigned int lun = SCSI_LUN(srb); int result = TRANSPORT_GOOD; #ifdef SUPPORT_SD_LOCK if (sd_card->sd_erase_status) { /* Block all SCSI command except for REQUEST_SENSE * and rs_ppstatus */ if (! ((srb->cmnd[0] == VENDOR_CMND) && (srb->cmnd[1] == SCSI_APP_CMD) && (srb->cmnd[2] == GET_DEV_STATUS)) && (srb->cmnd[0] != REQUEST_SENSE)) { /* Logical Unit Not Ready Format in Progress */ set_sense_data(chip, lun, CUR_ERR, 0x02, 0, 0x04, 0x04, 0, 0); TRACE_RET(chip, TRANSPORT_FAILED); } } #endif if ((get_lun_card(chip, lun) == MS_CARD) && (ms_card->format_status == FORMAT_IN_PROGRESS)) { if ((srb->cmnd[0] != REQUEST_SENSE) Loading drivers/staging/rts5139/sd.c +0 −126 Original line number Diff line number Diff line Loading @@ -246,12 +246,7 @@ static int sd_send_cmd_get_rsp(struct rts51x_chip *chip, u8 cmd_idx, if (buf[1] & 0x80) TRACE_RET(chip, STATUS_FAIL); } #ifdef SUPPORT_SD_LOCK /* exclude bit25 CARD_IS_LOCKED */ if (buf[1] & 0x7D) { #else if (buf[1] & 0x7F) { #endif RTS51X_DEBUGP("buf[1]: 0x%02x\n", buf[1]); TRACE_RET(chip, STATUS_FAIL); } Loading Loading @@ -709,36 +704,6 @@ int sd_select_card(struct rts51x_chip *chip, int select) return STATUS_SUCCESS; } #ifdef SUPPORT_SD_LOCK int sd_update_lock_status(struct rts51x_chip *chip) { struct sd_info *sd_card = &(chip->sd_card); int retval; 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) TRACE_RET(chip, STATUS_FAIL); if (rsp[1] & 0x02) sd_card->sd_lock_status |= SD_LOCKED; else sd_card->sd_lock_status &= ~SD_LOCKED; RTS51X_DEBUGP("sd_card->sd_lock_status = 0x%x\n", sd_card->sd_lock_status); if (rsp[1] & 0x01) { /* LOCK_UNLOCK_FAILED */ TRACE_RET(chip, STATUS_FAIL); } return STATUS_SUCCESS; } #endif int sd_wait_currentstate_dataready(struct rts51x_chip *chip, u8 statechk, u8 rdychk, u16 pollingcnt) { Loading Loading @@ -1197,15 +1162,6 @@ static int sd_switch_function(struct rts51x_chip *chip, u8 bus_width) RTS51X_DEBUGP("SD_FUNC_GROUP_1: func_to_switch = 0x%02x", func_to_switch); #ifdef SUPPORT_SD_LOCK if ((sd_card->sd_lock_status & SD_SDR_RST) && (DDR50_SUPPORT == func_to_switch) && (sd_card->func_group1_mask & SDR50_SUPPORT_MASK)) { func_to_switch = SDR50_SUPPORT; RTS51X_DEBUGP("Using SDR50 instead of DDR50 for SD Lock\n"); } #endif if (func_to_switch) { retval = sd_check_switch(chip, SD_FUNC_GROUP_1, func_to_switch, Loading Loading @@ -2024,10 +1980,6 @@ int reset_sd(struct rts51x_chip *chip) k = 0; hi_cap_flow = 0; support_1v8 = 0; #ifdef SUPPORT_SD_LOCK if (sd_card->sd_lock_status & SD_UNLOCK_POW_ON) goto SD_UNLOCK_ENTRY; #endif retval = sd_prepare_reset(chip); if (retval != STATUS_SUCCESS) Loading Loading @@ -2190,20 +2142,6 @@ int reset_sd(struct rts51x_chip *chip) retval = sd_select_card(chip, 1); if (retval != STATUS_SUCCESS) TRACE_RET(chip, retval); #ifdef SUPPORT_SD_LOCK SD_UNLOCK_ENTRY: /* Get SD lock status */ retval = sd_update_lock_status(chip); 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); return STATUS_SUCCESS; } else if (!(sd_card->sd_lock_status & SD_UNLOCK_POW_ON)) { sd_card->sd_lock_status &= ~SD_PWD_EXIST; } #endif /* ACMD42 */ retval = Loading Loading @@ -2294,10 +2232,6 @@ int reset_sd(struct rts51x_chip *chip) if (retval != STATUS_SUCCESS) TRACE_RET(chip, retval); } #ifdef SUPPORT_SD_LOCK /* clear 1 bit mode status */ sd_card->sd_lock_status &= ~SD_LOCK_1BIT_MODE; #endif if (CHK_SD30_SPEED(sd_card)) { rts51x_write_register(chip, SD30_DRIVE_SEL, SD30_DRIVE_MASK, Loading Loading @@ -2380,19 +2314,6 @@ int reset_sd(struct rts51x_chip *chip) chip->card_bus_width[chip->card2lun[SD_CARD]] = 4; #ifdef SUPPORT_SD_LOCK if (sd_card->sd_lock_status & SD_UNLOCK_POW_ON) { rts51x_init_cmd(chip); rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_H, 0xFF, 0x02); rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_L, 0xFF, 0x00); retval = rts51x_send_cmd(chip, MODE_C, 100); if (retval != STATUS_SUCCESS) TRACE_RET(chip, retval); } #endif return STATUS_SUCCESS; } Loading Loading @@ -2587,17 +2508,10 @@ static int mmc_switch_timing_bus(struct rts51x_chip *chip) sd_card->capacity = ((u32) buf[5] << 24) | ((u32) buf[4] << 16) | ((u32) buf[3] << 8) | ((u32) buf[2]); #ifdef SUPPORT_SD_LOCK if (!(sd_card->sd_lock_status & SD_SDR_RST) && CHECK_UHS50(chip)) card_type_mask = 0x07; else card_type_mask = 0x03; #else if (CHECK_UHS50(chip)) card_type_mask = 0x07; else card_type_mask = 0x03; #endif card_type = buf[1] & card_type_mask; if (card_type) { Loading Loading @@ -2626,15 +2540,9 @@ static int mmc_switch_timing_bus(struct rts51x_chip *chip) if (mmc_test_switch_bus(chip, MMC_8BIT_BUS) == STATUS_SUCCESS) { SET_MMC_8BIT(sd_card); chip->card_bus_width[chip->card2lun[SD_CARD]] = 8; #ifdef SUPPORT_SD_LOCK sd_card->sd_lock_status &= ~SD_LOCK_1BIT_MODE; #endif } else if (mmc_test_switch_bus(chip, MMC_4BIT_BUS) == STATUS_SUCCESS) { SET_MMC_4BIT(sd_card); chip->card_bus_width[chip->card2lun[SD_CARD]] = 4; #ifdef SUPPORT_SD_LOCK sd_card->sd_lock_status &= ~SD_LOCK_1BIT_MODE; #endif } else { CLR_MMC_8BIT(sd_card); CLR_MMC_4BIT(sd_card); Loading @@ -2652,11 +2560,6 @@ static int reset_mmc(struct rts51x_chip *chip) u8 change_to_ddr52 = 1; u8 cmd[5]; #ifdef SUPPORT_SD_LOCK if (sd_card->sd_lock_status & SD_UNLOCK_POW_ON) goto MMC_UNLOCK_ENTRY; #endif MMC_DDR_FAIL: retval = sd_prepare_reset(chip); Loading Loading @@ -2763,13 +2666,6 @@ static int reset_mmc(struct rts51x_chip *chip) 0); if (retval != STATUS_SUCCESS) TRACE_RET(chip, retval); #ifdef SUPPORT_SD_LOCK MMC_UNLOCK_ENTRY: /* Get SD lock status */ retval = sd_update_lock_status(chip); if (retval != STATUS_SUCCESS) TRACE_RET(chip, STATUS_FAIL); #endif RTS51X_WRITE_REG(chip, SD_CFG1, SD_CLK_DIVIDE_MASK, SD_CLK_DIVIDE_0); Loading Loading @@ -2842,18 +2738,6 @@ static int reset_mmc(struct rts51x_chip *chip) } } } #ifdef SUPPORT_SD_LOCK if (sd_card->sd_lock_status & SD_UNLOCK_POW_ON) { rts51x_init_cmd(chip); rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_H, 0xFF, 0x02); rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_L, 0xFF, 0x00); retval = rts51x_send_cmd(chip, MODE_C, 100); if (retval != STATUS_SUCCESS) TRACE_RET(chip, retval); } #endif retval = rts51x_get_card_status(chip, &(chip->card_status)); if (retval != STATUS_SUCCESS) Loading @@ -2879,11 +2763,6 @@ int reset_sd_card(struct rts51x_chip *chip) sd_card->capacity = 0; sd_card->sd_switch_fail = 0; #ifdef SUPPORT_SD_LOCK sd_card->sd_lock_status = 0; sd_card->sd_erase_status = 0; #endif sd_clear_reset_fail(chip); enable_card_clock(chip, SD_CARD); Loading Loading @@ -3352,11 +3231,6 @@ int release_sd_card(struct rts51x_chip *chip) chip->card_fail &= ~SD_CARD; chip->card_wp &= ~SD_CARD; #ifdef SUPPORT_SD_LOCK sd_card->sd_lock_status = 0; sd_card->sd_erase_status = 0; #endif memset(sd_card->raw_csd, 0, 16); memset(sd_card->raw_scr, 0, 8); Loading drivers/staging/rts5139/sd.h +0 −27 Original line number Diff line number Diff line Loading @@ -141,29 +141,6 @@ #define SWITCH_MODE_ERR 0x06 #define SWITCH_PASS 0x07 #ifdef SUPPORT_SD_LOCK /* CMD42 Parameter */ #define SD_ERASE 0x08 #define SD_LOCK 0x04 #define SD_UNLOCK 0x00 #define SD_CLR_PWD 0x02 #define SD_SET_PWD 0x01 #define SD_PWD_LEN 0x10 /* SD lock unlock Status */ #define SD_LOCKED 0x80 /* Global lock status */ #define SD_LOCK_1BIT_MODE 0x40 /**/ #define SD_PWD_EXIST 0x20 #define SD_UNLOCK_POW_ON 0x01 /**/ #define SD_SDR_RST 0x02 /* Reset SD30 card with current DDR mode to SDR mode. */ /* g_bySDEraseStatus */ #define SD_NOT_ERASE 0x00 #define SD_UNDER_ERASING 0x01 #define SD_COMPLETE_ERASE 0x02 /* SD_RW FAIL status */ #define SD_RW_FORBIDDEN 0x0F /* read/write is forbidden (SD card) */ #endif /* Function Group Definition */ /* Function Group 1 */ #define HS_SUPPORT 0x01 Loading Loading @@ -289,10 +266,6 @@ void sd_cleanup_work(struct rts51x_chip *chip); int sd_power_off_card3v3(struct rts51x_chip *chip); int release_sd_card(struct rts51x_chip *chip); #ifdef SUPPORT_SD_LOCK int sd_update_lock_status(struct rts51x_chip *chip); #endif #ifdef SUPPORT_CPRM extern int reset_sd(struct rts51x_chip *chip); extern int sd_check_data0_status(struct rts51x_chip *chip); Loading Loading
drivers/staging/rts5139/rts51x_chip.c +0 −51 Original line number Diff line number Diff line Loading @@ -300,33 +300,6 @@ static void rts51x_auto_delink(struct rts51x_chip *chip) void rts51x_polling_func(struct rts51x_chip *chip) { #ifdef SUPPORT_SD_LOCK struct sd_info *sd_card = &(chip->sd_card); if (sd_card->sd_erase_status) { if (chip->card_exist & SD_CARD) { u8 val; rts51x_read_register(chip, SD_BUS_STAT, &val); if (val & SD_DAT0_STATUS) { /* Erase completed */ sd_card->sd_erase_status = SD_NOT_ERASE; sd_card->sd_lock_notify = 1; /* SD card should be reinited, * so we release it here. */ sd_cleanup_work(chip); release_sd_card(chip); chip->card_ready &= ~SD_CARD; chip->card_exist &= ~SD_CARD; chip->rw_card[chip->card2lun[SD_CARD]] = NULL; clear_bit(chip->card2lun[SD_CARD], &(chip->lun_mc)); } } else { sd_card->sd_erase_status = SD_NOT_ERASE; } } #endif rts51x_init_cards(chip); Loading Loading @@ -923,24 +896,6 @@ void rts51x_pp_status(struct rts51x_chip *chip, unsigned int lun, u8 *status, status[0x0F] = 0x00; } } #ifdef SUPPORT_SD_LOCK /* SD Lock/Unlock */ if (card == SD_CARD) { status[0x17] = 0x80; if (sd_card->sd_erase_status) status[0x17] |= 0x01; /* Under erasing */ if (sd_card->sd_lock_status & SD_LOCKED) { status[0x17] |= 0x02; /* Locked */ status[0x07] |= 0x40; /* Read protected */ } if (sd_card->sd_lock_status & SD_PWD_EXIST) status[0x17] |= 0x04; /* Contain PWD */ } else { status[0x17] = 0x00; } RTS51X_DEBUGP("status[0x17] = 0x%x\n", status[0x17]); #endif /* Function 0 * Support Magic Gate, CPRM and PhyRegister R/W */ Loading @@ -950,12 +905,6 @@ void rts51x_pp_status(struct rts51x_chip *chip, unsigned int lun, u8 *status, * Support OC LUN status & WP LUN status */ status[0x1A] = 0x28; /* Function 7 */ #ifdef SUPPORT_SD_LOCK /* Support SD Lock/Unlock */ status[0x1F] = 0x01; #endif /* Function 2 * Support OC LUN status & WP LUN status */ status[0x1A] = 0x28; Loading
drivers/staging/rts5139/rts51x_chip.h +0 −13 Original line number Diff line number Diff line Loading @@ -39,10 +39,6 @@ #define SUPPORT_CPRM #define SUPPORT_MAGIC_GATE #define SUPPORT_MSXC /* { wwang, 2010-07-26 * Add support for SD lock/unlock */ /* #define SUPPORT_SD_LOCK */ /* } wwang, 2010-07-26 */ #ifdef SUPPORT_MAGIC_GA /* Using NORMAL_WRITE instead of AUTO_WRITE to set ICVTE */ Loading Loading @@ -205,10 +201,6 @@ struct trace_msg_t { /* WRITE ERROR */ #define SENSE_TYPE_MG_WRITE_ERR 0x0e #endif #ifdef SUPPORT_SD_LOCK /* FOR Locked SD card */ #define SENSE_TYPE_MEDIA_READ_FORBIDDEN 0x10 #endif /*---- sense key ----*/ #define ILI 0x20 /* ILI bit is on */ Loading Loading @@ -612,11 +604,6 @@ struct sd_info { u8 sd_reset_fail; /* sangdy2010-07-01 */ u8 sd_send_status_en; #ifdef SUPPORT_SD_LOCK u8 sd_lock_status; u8 sd_erase_status; u8 sd_lock_notify; #endif }; #define MODE_512_SEQ 0x01 Loading
drivers/staging/rts5139/rts51x_scsi.c +0 −62 Original line number Diff line number Diff line Loading @@ -396,12 +396,6 @@ void set_sense_type(struct rts51x_chip *chip, unsigned int lun, int sense_type) break; #endif #ifdef SUPPORT_SD_LOCK case SENSE_TYPE_MEDIA_READ_FORBIDDEN: set_sense_data(chip, lun, CUR_ERR, 0x07, 0, 0x11, 0x13, 0, 0); break; #endif case SENSE_TYPE_NO_SENSE: default: set_sense_data(chip, lun, CUR_ERR, 0, 0, 0, 0, 0, 0); Loading Loading @@ -448,20 +442,6 @@ static int test_unit_ready(struct scsi_cmnd *srb, struct rts51x_chip *chip) set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); return TRANSPORT_FAILED; } #ifdef SUPPORT_SD_LOCK if (get_lun_card(chip, SCSI_LUN(srb)) == SD_CARD) { struct sd_info *sd_card = &(chip->sd_card); if (sd_card->sd_lock_notify) { sd_card->sd_lock_notify = 0; set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); return TRANSPORT_FAILED; } else if (sd_card->sd_lock_status & SD_LOCKED) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_READ_FORBIDDEN); return TRANSPORT_FAILED; } } #endif return TRANSPORT_GOOD; } Loading Loading @@ -797,9 +777,6 @@ static int request_sense(struct scsi_cmnd *srb, struct rts51x_chip *chip) static int read_write(struct scsi_cmnd *srb, struct rts51x_chip *chip) { #ifdef SUPPORT_SD_LOCK struct sd_info *sd_card = &(chip->sd_card); #endif unsigned int lun = SCSI_LUN(srb); int retval; u32 start_sec; Loading @@ -819,25 +796,6 @@ static int read_write(struct scsi_cmnd *srb, struct rts51x_chip *chip) rts51x_prepare_run(chip); RTS51X_SET_STAT(chip, STAT_RUN); #ifdef SUPPORT_SD_LOCK if (sd_card->sd_erase_status) { /* Accessing to any card is forbidden * until the erase procedure of SD is completed */ RTS51X_DEBUGP("SD card being erased!\n"); set_sense_type(chip, lun, SENSE_TYPE_MEDIA_READ_FORBIDDEN); TRACE_RET(chip, TRANSPORT_FAILED); } if (get_lun_card(chip, lun) == SD_CARD) { if (sd_card->sd_lock_status & SD_LOCKED) { RTS51X_DEBUGP("SD card locked!\n"); set_sense_type(chip, lun, SENSE_TYPE_MEDIA_READ_FORBIDDEN); TRACE_RET(chip, TRANSPORT_FAILED); } } #endif if ((srb->cmnd[0] == READ_10) || (srb->cmnd[0] == WRITE_10)) { start_sec = ((u32) srb->cmnd[2] << 24) | Loading Loading @@ -1863,30 +1821,10 @@ int mg_send_key(struct scsi_cmnd *srb, struct rts51x_chip *chip) int rts51x_scsi_handler(struct scsi_cmnd *srb, struct rts51x_chip *chip) { #ifdef SUPPORT_SD_LOCK struct sd_info *sd_card = &(chip->sd_card); #endif struct ms_info *ms_card = &(chip->ms_card); unsigned int lun = SCSI_LUN(srb); int result = TRANSPORT_GOOD; #ifdef SUPPORT_SD_LOCK if (sd_card->sd_erase_status) { /* Block all SCSI command except for REQUEST_SENSE * and rs_ppstatus */ if (! ((srb->cmnd[0] == VENDOR_CMND) && (srb->cmnd[1] == SCSI_APP_CMD) && (srb->cmnd[2] == GET_DEV_STATUS)) && (srb->cmnd[0] != REQUEST_SENSE)) { /* Logical Unit Not Ready Format in Progress */ set_sense_data(chip, lun, CUR_ERR, 0x02, 0, 0x04, 0x04, 0, 0); TRACE_RET(chip, TRANSPORT_FAILED); } } #endif if ((get_lun_card(chip, lun) == MS_CARD) && (ms_card->format_status == FORMAT_IN_PROGRESS)) { if ((srb->cmnd[0] != REQUEST_SENSE) Loading
drivers/staging/rts5139/sd.c +0 −126 Original line number Diff line number Diff line Loading @@ -246,12 +246,7 @@ static int sd_send_cmd_get_rsp(struct rts51x_chip *chip, u8 cmd_idx, if (buf[1] & 0x80) TRACE_RET(chip, STATUS_FAIL); } #ifdef SUPPORT_SD_LOCK /* exclude bit25 CARD_IS_LOCKED */ if (buf[1] & 0x7D) { #else if (buf[1] & 0x7F) { #endif RTS51X_DEBUGP("buf[1]: 0x%02x\n", buf[1]); TRACE_RET(chip, STATUS_FAIL); } Loading Loading @@ -709,36 +704,6 @@ int sd_select_card(struct rts51x_chip *chip, int select) return STATUS_SUCCESS; } #ifdef SUPPORT_SD_LOCK int sd_update_lock_status(struct rts51x_chip *chip) { struct sd_info *sd_card = &(chip->sd_card); int retval; 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) TRACE_RET(chip, STATUS_FAIL); if (rsp[1] & 0x02) sd_card->sd_lock_status |= SD_LOCKED; else sd_card->sd_lock_status &= ~SD_LOCKED; RTS51X_DEBUGP("sd_card->sd_lock_status = 0x%x\n", sd_card->sd_lock_status); if (rsp[1] & 0x01) { /* LOCK_UNLOCK_FAILED */ TRACE_RET(chip, STATUS_FAIL); } return STATUS_SUCCESS; } #endif int sd_wait_currentstate_dataready(struct rts51x_chip *chip, u8 statechk, u8 rdychk, u16 pollingcnt) { Loading Loading @@ -1197,15 +1162,6 @@ static int sd_switch_function(struct rts51x_chip *chip, u8 bus_width) RTS51X_DEBUGP("SD_FUNC_GROUP_1: func_to_switch = 0x%02x", func_to_switch); #ifdef SUPPORT_SD_LOCK if ((sd_card->sd_lock_status & SD_SDR_RST) && (DDR50_SUPPORT == func_to_switch) && (sd_card->func_group1_mask & SDR50_SUPPORT_MASK)) { func_to_switch = SDR50_SUPPORT; RTS51X_DEBUGP("Using SDR50 instead of DDR50 for SD Lock\n"); } #endif if (func_to_switch) { retval = sd_check_switch(chip, SD_FUNC_GROUP_1, func_to_switch, Loading Loading @@ -2024,10 +1980,6 @@ int reset_sd(struct rts51x_chip *chip) k = 0; hi_cap_flow = 0; support_1v8 = 0; #ifdef SUPPORT_SD_LOCK if (sd_card->sd_lock_status & SD_UNLOCK_POW_ON) goto SD_UNLOCK_ENTRY; #endif retval = sd_prepare_reset(chip); if (retval != STATUS_SUCCESS) Loading Loading @@ -2190,20 +2142,6 @@ int reset_sd(struct rts51x_chip *chip) retval = sd_select_card(chip, 1); if (retval != STATUS_SUCCESS) TRACE_RET(chip, retval); #ifdef SUPPORT_SD_LOCK SD_UNLOCK_ENTRY: /* Get SD lock status */ retval = sd_update_lock_status(chip); 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); return STATUS_SUCCESS; } else if (!(sd_card->sd_lock_status & SD_UNLOCK_POW_ON)) { sd_card->sd_lock_status &= ~SD_PWD_EXIST; } #endif /* ACMD42 */ retval = Loading Loading @@ -2294,10 +2232,6 @@ int reset_sd(struct rts51x_chip *chip) if (retval != STATUS_SUCCESS) TRACE_RET(chip, retval); } #ifdef SUPPORT_SD_LOCK /* clear 1 bit mode status */ sd_card->sd_lock_status &= ~SD_LOCK_1BIT_MODE; #endif if (CHK_SD30_SPEED(sd_card)) { rts51x_write_register(chip, SD30_DRIVE_SEL, SD30_DRIVE_MASK, Loading Loading @@ -2380,19 +2314,6 @@ int reset_sd(struct rts51x_chip *chip) chip->card_bus_width[chip->card2lun[SD_CARD]] = 4; #ifdef SUPPORT_SD_LOCK if (sd_card->sd_lock_status & SD_UNLOCK_POW_ON) { rts51x_init_cmd(chip); rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_H, 0xFF, 0x02); rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_L, 0xFF, 0x00); retval = rts51x_send_cmd(chip, MODE_C, 100); if (retval != STATUS_SUCCESS) TRACE_RET(chip, retval); } #endif return STATUS_SUCCESS; } Loading Loading @@ -2587,17 +2508,10 @@ static int mmc_switch_timing_bus(struct rts51x_chip *chip) sd_card->capacity = ((u32) buf[5] << 24) | ((u32) buf[4] << 16) | ((u32) buf[3] << 8) | ((u32) buf[2]); #ifdef SUPPORT_SD_LOCK if (!(sd_card->sd_lock_status & SD_SDR_RST) && CHECK_UHS50(chip)) card_type_mask = 0x07; else card_type_mask = 0x03; #else if (CHECK_UHS50(chip)) card_type_mask = 0x07; else card_type_mask = 0x03; #endif card_type = buf[1] & card_type_mask; if (card_type) { Loading Loading @@ -2626,15 +2540,9 @@ static int mmc_switch_timing_bus(struct rts51x_chip *chip) if (mmc_test_switch_bus(chip, MMC_8BIT_BUS) == STATUS_SUCCESS) { SET_MMC_8BIT(sd_card); chip->card_bus_width[chip->card2lun[SD_CARD]] = 8; #ifdef SUPPORT_SD_LOCK sd_card->sd_lock_status &= ~SD_LOCK_1BIT_MODE; #endif } else if (mmc_test_switch_bus(chip, MMC_4BIT_BUS) == STATUS_SUCCESS) { SET_MMC_4BIT(sd_card); chip->card_bus_width[chip->card2lun[SD_CARD]] = 4; #ifdef SUPPORT_SD_LOCK sd_card->sd_lock_status &= ~SD_LOCK_1BIT_MODE; #endif } else { CLR_MMC_8BIT(sd_card); CLR_MMC_4BIT(sd_card); Loading @@ -2652,11 +2560,6 @@ static int reset_mmc(struct rts51x_chip *chip) u8 change_to_ddr52 = 1; u8 cmd[5]; #ifdef SUPPORT_SD_LOCK if (sd_card->sd_lock_status & SD_UNLOCK_POW_ON) goto MMC_UNLOCK_ENTRY; #endif MMC_DDR_FAIL: retval = sd_prepare_reset(chip); Loading Loading @@ -2763,13 +2666,6 @@ static int reset_mmc(struct rts51x_chip *chip) 0); if (retval != STATUS_SUCCESS) TRACE_RET(chip, retval); #ifdef SUPPORT_SD_LOCK MMC_UNLOCK_ENTRY: /* Get SD lock status */ retval = sd_update_lock_status(chip); if (retval != STATUS_SUCCESS) TRACE_RET(chip, STATUS_FAIL); #endif RTS51X_WRITE_REG(chip, SD_CFG1, SD_CLK_DIVIDE_MASK, SD_CLK_DIVIDE_0); Loading Loading @@ -2842,18 +2738,6 @@ static int reset_mmc(struct rts51x_chip *chip) } } } #ifdef SUPPORT_SD_LOCK if (sd_card->sd_lock_status & SD_UNLOCK_POW_ON) { rts51x_init_cmd(chip); rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_H, 0xFF, 0x02); rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_L, 0xFF, 0x00); retval = rts51x_send_cmd(chip, MODE_C, 100); if (retval != STATUS_SUCCESS) TRACE_RET(chip, retval); } #endif retval = rts51x_get_card_status(chip, &(chip->card_status)); if (retval != STATUS_SUCCESS) Loading @@ -2879,11 +2763,6 @@ int reset_sd_card(struct rts51x_chip *chip) sd_card->capacity = 0; sd_card->sd_switch_fail = 0; #ifdef SUPPORT_SD_LOCK sd_card->sd_lock_status = 0; sd_card->sd_erase_status = 0; #endif sd_clear_reset_fail(chip); enable_card_clock(chip, SD_CARD); Loading Loading @@ -3352,11 +3231,6 @@ int release_sd_card(struct rts51x_chip *chip) chip->card_fail &= ~SD_CARD; chip->card_wp &= ~SD_CARD; #ifdef SUPPORT_SD_LOCK sd_card->sd_lock_status = 0; sd_card->sd_erase_status = 0; #endif memset(sd_card->raw_csd, 0, 16); memset(sd_card->raw_scr, 0, 8); Loading
drivers/staging/rts5139/sd.h +0 −27 Original line number Diff line number Diff line Loading @@ -141,29 +141,6 @@ #define SWITCH_MODE_ERR 0x06 #define SWITCH_PASS 0x07 #ifdef SUPPORT_SD_LOCK /* CMD42 Parameter */ #define SD_ERASE 0x08 #define SD_LOCK 0x04 #define SD_UNLOCK 0x00 #define SD_CLR_PWD 0x02 #define SD_SET_PWD 0x01 #define SD_PWD_LEN 0x10 /* SD lock unlock Status */ #define SD_LOCKED 0x80 /* Global lock status */ #define SD_LOCK_1BIT_MODE 0x40 /**/ #define SD_PWD_EXIST 0x20 #define SD_UNLOCK_POW_ON 0x01 /**/ #define SD_SDR_RST 0x02 /* Reset SD30 card with current DDR mode to SDR mode. */ /* g_bySDEraseStatus */ #define SD_NOT_ERASE 0x00 #define SD_UNDER_ERASING 0x01 #define SD_COMPLETE_ERASE 0x02 /* SD_RW FAIL status */ #define SD_RW_FORBIDDEN 0x0F /* read/write is forbidden (SD card) */ #endif /* Function Group Definition */ /* Function Group 1 */ #define HS_SUPPORT 0x01 Loading Loading @@ -289,10 +266,6 @@ void sd_cleanup_work(struct rts51x_chip *chip); int sd_power_off_card3v3(struct rts51x_chip *chip); int release_sd_card(struct rts51x_chip *chip); #ifdef SUPPORT_SD_LOCK int sd_update_lock_status(struct rts51x_chip *chip); #endif #ifdef SUPPORT_CPRM extern int reset_sd(struct rts51x_chip *chip); extern int sd_check_data0_status(struct rts51x_chip *chip); Loading