if (chip->chip_insert_with_sdio) {
chip->chip_insert_with_sdio = 0;
- if (CHECK_PID(chip, 0x5288)) {
+ if (CHECK_PID(chip, 0x5288))
rtsx_write_register(chip, 0xFE5A, 0x08, 0x00);
- } else {
+ else
rtsx_write_register(chip, 0xFE70, 0x80, 0x00);
- }
}
rtsx_write_register(chip, SDIO_CTRL, SDIO_CD_CTRL, 0);
if (chip->need_reset & XD_CARD) {
chip->card_exist |= XD_CARD;
- if (chip->xd_show_cnt >= MAX_SHOW_CNT) {
+ if (chip->xd_show_cnt >= MAX_SHOW_CNT)
do_reset_xd_card(chip);
- } else {
+ else
chip->xd_show_cnt++;
- }
}
if (CHECK_PID(chip, 0x5288) && CHECK_BARO_PKG(chip, QFN)) {
if (chip->card_exist & XD_CARD) {
if (chip->need_reset & MS_CARD) {
chip->card_exist |= MS_CARD;
- if (chip->ms_show_cnt >= MAX_SHOW_CNT) {
+ if (chip->ms_show_cnt >= MAX_SHOW_CNT)
do_reset_ms_card(chip);
- } else {
+ else
chip->ms_show_cnt++;
- }
}
}
release_map |= MS_CARD;
}
} else {
- if (chip->int_reg & XD_EXIST) {
+ if (chip->int_reg & XD_EXIST)
reset_map |= XD_CARD;
- } else if (chip->int_reg & SD_EXIST) {
+ else if (chip->int_reg & SD_EXIST)
reset_map |= SD_CARD;
- } else if (chip->int_reg & MS_EXIST) {
+ else if (chip->int_reg & MS_EXIST)
reset_map |= MS_CARD;
- }
}
if (reset_map) {
for (i = 0; i < (DEBOUNCE_CNT); i++) {
chip->int_reg = rtsx_readl(chip, RTSX_BIPR);
- if (chip->int_reg & XD_EXIST) {
+ if (chip->int_reg & XD_EXIST)
xd_cnt++;
- } else {
+ else
xd_cnt = 0;
- }
- if (chip->int_reg & SD_EXIST) {
+
+ if (chip->int_reg & SD_EXIST)
sd_cnt++;
- } else {
+ else
sd_cnt = 0;
- }
- if (chip->int_reg & MS_EXIST) {
+
+ if (chip->int_reg & MS_EXIST)
ms_cnt++;
- } else {
+ else
ms_cnt = 0;
- }
+
wait_timeout(30);
}
RTSX_DEBUGP("Switch SSC clock to %dMHz (cur_clk = %d)\n", clk, chip->cur_clk);
- if ((clk <= 2) || (N > max_N)) {
+ if ((clk <= 2) || (N > max_N))
TRACE_RET(chip, STATUS_FAIL);
- }
mcu_cnt = (u8)(125/clk + 3);
if (CHECK_PID(chip, 0x5209)) {
if (chip->ssc_en) {
if (CHECK_PID(chip, 0x5209)) {
if (chip->cur_card == SD_CARD) {
- if (CHK_SD_SDR104(sd_card)) {
+ if (CHK_SD_SDR104(sd_card))
ssc_depth = chip->ssc_depth_sd_sdr104;
- } else if (CHK_SD_SDR50(sd_card)) {
+ else if (CHK_SD_SDR50(sd_card))
ssc_depth = chip->ssc_depth_sd_sdr50;
- } else if (CHK_SD_DDR50(sd_card)) {
+ else if (CHK_SD_DDR50(sd_card))
ssc_depth = double_depth(chip->ssc_depth_sd_ddr50);
- } else if (CHK_SD_HS(sd_card)) {
+ else if (CHK_SD_HS(sd_card))
ssc_depth = double_depth(chip->ssc_depth_sd_hs);
- } else if (CHK_MMC_52M(sd_card) || CHK_MMC_DDR52(sd_card)) {
+ else if (CHK_MMC_52M(sd_card) || CHK_MMC_DDR52(sd_card))
ssc_depth = double_depth(chip->ssc_depth_mmc_52m);
- } else {
+ else
ssc_depth = double_depth(chip->ssc_depth_low_speed);
- }
} else if (chip->cur_card == MS_CARD) {
if (CHK_MSPRO(ms_card)) {
- if (CHK_HG8BIT(ms_card)) {
+ if (CHK_HG8BIT(ms_card))
ssc_depth = double_depth(chip->ssc_depth_ms_hg);
- } else {
+ else
ssc_depth = double_depth(chip->ssc_depth_ms_4bit);
- }
} else {
- if (CHK_MS4BIT(ms_card)) {
+ if (CHK_MS4BIT(ms_card))
ssc_depth = double_depth(chip->ssc_depth_ms_4bit);
- } else {
+ else
ssc_depth = double_depth(chip->ssc_depth_low_speed);
- }
}
} else {
ssc_depth = double_depth(chip->ssc_depth_low_speed);
if (ssc_depth) {
if (div == CLK_DIV_2) {
- if (ssc_depth > 1) {
+ if (ssc_depth > 1)
ssc_depth -= 1;
- } else {
+ else
ssc_depth = SSC_DEPTH_4M;
- }
+
} else if (div == CLK_DIV_4) {
- if (ssc_depth > 2) {
+ if (ssc_depth > 2)
ssc_depth -= 2;
- } else {
+ else
ssc_depth = SSC_DEPTH_4M;
- }
+
} else if (div == CLK_DIV_8) {
- if (ssc_depth > 3) {
+ if (ssc_depth > 3)
ssc_depth -= 3;
- } else {
+ else
ssc_depth = SSC_DEPTH_4M;
- }
+
}
}
} else {
ssc_depth = 0;
}
- if (CHECK_PID(chip, 0x5209)) {
+ if (CHECK_PID(chip, 0x5209))
ssc_depth_mask = SSC_DEPTH_MASK;
- } else {
+ else
ssc_depth_mask = 0x03;
- }
RTSX_DEBUGP("ssc_depth = %d\n", ssc_depth);
}
retval = rtsx_send_cmd(chip, 0, WAIT_TIME);
- if (retval < 0) {
+ if (retval < 0)
TRACE_RET(chip, STATUS_ERROR);
- }
udelay(10);
RTSX_WRITE_REG(chip, CLK_CTL, CLK_LOW_FREQ, 0);
rtsx_init_cmd(chip);
rtsx_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, mask, val1);
- if (CHECK_PID(chip, 0x5209) && (card == SD_CARD)) {
+ if (CHECK_PID(chip, 0x5209) && (card == SD_CARD))
rtsx_add_cmd(chip, WRITE_REG_CMD, PWR_GATE_CTRL, LDO3318_PWR_MASK, LDO_SUSPEND);
- }
+
retval = rtsx_send_cmd(chip, 0, 100);
- if (retval != STATUS_SUCCESS) {
+ if (retval != STATUS_SUCCESS)
TRACE_RET(chip, STATUS_FAIL);
- }
udelay(chip->pmos_pwr_on_interval);
rtsx_init_cmd(chip);
rtsx_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, mask, val2);
- if (CHECK_PID(chip, 0x5209) && (card == SD_CARD)) {
+ if (CHECK_PID(chip, 0x5209) && (card == SD_CARD))
rtsx_add_cmd(chip, WRITE_REG_CMD, PWR_GATE_CTRL, LDO3318_PWR_MASK, LDO_ON);
- }
+
retval = rtsx_send_cmd(chip, 0, 100);
- if (retval != STATUS_SUCCESS) {
+ if (retval != STATUS_SUCCESS)
TRACE_RET(chip, STATUS_FAIL);
- }
return STATUS_SUCCESS;
}
}
RTSX_WRITE_REG(chip, CARD_PWR_CTL, mask, val);
- if (CHECK_PID(chip, 0x5209) && (card == SD_CARD)) {
+ if (CHECK_PID(chip, 0x5209) && (card == SD_CARD))
RTSX_WRITE_REG(chip, PWR_GATE_CTRL, LDO3318_PWR_MASK, LDO_OFF);
- }
return STATUS_SUCCESS;
}
unsigned int lun = SCSI_LUN(srb);
int i;
- if (chip->rw_card[lun] == NULL) {
+ if (chip->rw_card[lun] == NULL)
TRACE_RET(chip, STATUS_FAIL);
- }
for (i = 0; i < 3; i++) {
chip->rw_need_retry = 0;
rtsx_release_chip(chip);
TRACE_RET(chip, STATUS_FAIL);
}
- if (detect_card_cd(chip, chip->cur_card) != STATUS_SUCCESS) {
+ if (detect_card_cd(chip, chip->cur_card) != STATUS_SUCCESS)
TRACE_RET(chip, STATUS_FAIL);
- }
+
if (!chip->rw_need_retry) {
RTSX_DEBUGP("RW fail, but no need to retry\n");
break;
if (CHECK_PID(chip, 0x5209) || CHECK_PID(chip, 0x5208)) {
mask = CARD_SHARE_MASK;
- if (card == SD_CARD) {
+ if (card == SD_CARD)
value = CARD_SHARE_48_SD;
- } else if (card == MS_CARD) {
+ else if (card == MS_CARD)
value = CARD_SHARE_48_MS;
- } else if (card == XD_CARD) {
+ else if (card == XD_CARD)
value = CARD_SHARE_48_XD;
- } else {
+ else
TRACE_RET(chip, STATUS_FAIL);
- }
+
} else if (CHECK_PID(chip, 0x5288)) {
mask = 0x03;
- if (card == SD_CARD) {
+ if (card == SD_CARD)
value = CARD_SHARE_BAROSSA_SD;
- } else if (card == MS_CARD) {
+ else if (card == MS_CARD)
value = CARD_SHARE_BAROSSA_MS;
- } else if (card == XD_CARD) {
+ else if (card == XD_CARD)
value = CARD_SHARE_BAROSSA_XD;
- } else {
+ else
TRACE_RET(chip, STATUS_FAIL);
- }
+
} else {
TRACE_RET(chip, STATUS_FAIL);
}
if (chip->cur_card != card) {
u8 mod;
- if (card == SD_CARD) {
+ if (card == SD_CARD)
mod = SD_MOD_SEL;
- } else if (card == MS_CARD) {
+ else if (card == MS_CARD)
mod = MS_MOD_SEL;
- } else if (card == XD_CARD) {
+ else if (card == XD_CARD)
mod = XD_MOD_SEL;
- } else if (card == SPI_CARD) {
+ else if (card == SPI_CARD)
mod = SPI_MOD_SEL;
- } else {
+ else
TRACE_RET(chip, STATUS_FAIL);
- }
+
RTSX_WRITE_REG(chip, CARD_SELECT, 0x07, mod);
chip->cur_card = card;
retval = card_share_mode(chip, card);
- if (retval != STATUS_SUCCESS) {
+ if (retval != STATUS_SUCCESS)
TRACE_RET(chip, STATUS_FAIL);
- }
}
return STATUS_SUCCESS;
void turn_on_led(struct rtsx_chip *chip, u8 gpio)
{
- if (CHECK_PID(chip, 0x5288)) {
+ if (CHECK_PID(chip, 0x5288))
rtsx_write_register(chip, CARD_GPIO, (u8)(1 << gpio), (u8)(1 << gpio));
- } else {
+ else
rtsx_write_register(chip, CARD_GPIO, (u8)(1 << gpio), 0);
- }
}
void turn_off_led(struct rtsx_chip *chip, u8 gpio)
{
- if (CHECK_PID(chip, 0x5288)) {
+ if (CHECK_PID(chip, 0x5288))
rtsx_write_register(chip, CARD_GPIO, (u8)(1 << gpio), 0);
- } else {
+ else
rtsx_write_register(chip, CARD_GPIO, (u8)(1 << gpio), (u8)(1 << gpio));
- }
}
int detect_card_cd(struct rtsx_chip *chip, int card)
}
status = rtsx_readl(chip, RTSX_BIPR);
- if (!(status & card_cd)) {
+ if (!(status & card_cd))
TRACE_RET(chip, STATUS_FAIL);
- }
return STATUS_SUCCESS;
}
int check_card_exist(struct rtsx_chip *chip, unsigned int lun)
{
- if (chip->card_exist & chip->lun2card[lun]) {
+ if (chip->card_exist & chip->lun2card[lun])
return 1;
- }
return 0;
}
int check_card_ready(struct rtsx_chip *chip, unsigned int lun)
{
- if (chip->card_ready & chip->lun2card[lun]) {
+ if (chip->card_ready & chip->lun2card[lun])
return 1;
- }
return 0;
}
int check_card_wp(struct rtsx_chip *chip, unsigned int lun)
{
- if (chip->card_wp & chip->lun2card[lun]) {
+ if (chip->card_wp & chip->lun2card[lun])
return 1;
- }
return 0;
}
int check_card_fail(struct rtsx_chip *chip, unsigned int lun)
{
- if (chip->card_fail & chip->lun2card[lun]) {
+ if (chip->card_fail & chip->lun2card[lun])
return 1;
- }
return 0;
}
int check_card_ejected(struct rtsx_chip *chip, unsigned int lun)
{
- if (chip->card_ejected & chip->lun2card[lun]) {
+ if (chip->card_ejected & chip->lun2card[lun])
return 1;
- }
return 0;
}
u8 get_lun_card(struct rtsx_chip *chip, unsigned int lun)
{
- if ((chip->card_ready & chip->lun2card[lun]) == XD_CARD) {
+ if ((chip->card_ready & chip->lun2card[lun]) == XD_CARD)
return (u8)XD_CARD;
- } else if ((chip->card_ready & chip->lun2card[lun]) == SD_CARD) {
+ else if ((chip->card_ready & chip->lun2card[lun]) == SD_CARD)
return (u8)SD_CARD;
- } else if ((chip->card_ready & chip->lun2card[lun]) == MS_CARD) {
+ else if ((chip->card_ready & chip->lun2card[lun]) == MS_CARD)
return (u8)MS_CARD;
- }
return 0;
}