Commit 8ee775f9 authored by Joe Perches's avatar Joe Perches Committed by Greg Kroah-Hartman

staging: rts5208: Remove RTSX_READ_REG and RTSX_WRITE_REG macros

Macros with hidden flow control are bad form as the code path
taken can be unexpected for the reader.

Expand these in-place and remove the macros.

Done with coccinelle script:

@@
expression chip;
expression arg1;
expression arg2;
expression arg3;
@@

-	RTSX_WRITE_REG(chip, arg1, arg2, arg3);
+	retval = rtsx_write_register(chip, arg1, arg2, arg3);
+	if (retval) {
+		rtsx_trace(chip);
+		return retval;
+	}

@@
expression chip;
expression arg1;
expression arg2;
@@

-	RTSX_READ_REG(chip, arg1, arg2);
+	retval = rtsx_read_register(chip, arg1, arg2);
+	if (retval) {
+		rtsx_trace(chip);
+		return retval;
+	}
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 031366ea
This diff is collapsed.
...@@ -698,7 +698,11 @@ int switch_ssc_clock(struct rtsx_chip *chip, int clk) ...@@ -698,7 +698,11 @@ int switch_ssc_clock(struct rtsx_chip *chip, int clk)
} }
udelay(10); udelay(10);
RTSX_WRITE_REG(chip, CLK_CTL, CLK_LOW_FREQ, 0); retval = rtsx_write_register(chip, CLK_CTL, CLK_LOW_FREQ, 0);
if (retval) {
rtsx_trace(chip);
return retval;
}
chip->cur_clk = clk; chip->cur_clk = clk;
...@@ -707,6 +711,7 @@ int switch_ssc_clock(struct rtsx_chip *chip, int clk) ...@@ -707,6 +711,7 @@ int switch_ssc_clock(struct rtsx_chip *chip, int clk)
int switch_normal_clock(struct rtsx_chip *chip, int clk) int switch_normal_clock(struct rtsx_chip *chip, int clk)
{ {
int retval;
u8 sel, div, mcu_cnt; u8 sel, div, mcu_cnt;
int sd_vpclk_phase_reset = 0; int sd_vpclk_phase_reset = 0;
...@@ -791,23 +796,58 @@ int switch_normal_clock(struct rtsx_chip *chip, int clk) ...@@ -791,23 +796,58 @@ int switch_normal_clock(struct rtsx_chip *chip, int clk)
return STATUS_FAIL; return STATUS_FAIL;
} }
RTSX_WRITE_REG(chip, CLK_CTL, 0xFF, CLK_LOW_FREQ); retval = rtsx_write_register(chip, CLK_CTL, 0xFF, CLK_LOW_FREQ);
if (retval) {
rtsx_trace(chip);
return retval;
}
if (sd_vpclk_phase_reset) { if (sd_vpclk_phase_reset) {
RTSX_WRITE_REG(chip, SD_VPCLK0_CTL, PHASE_NOT_RESET, 0); retval = rtsx_write_register(chip, SD_VPCLK0_CTL,
RTSX_WRITE_REG(chip, SD_VPCLK1_CTL, PHASE_NOT_RESET, 0); PHASE_NOT_RESET, 0);
if (retval) {
rtsx_trace(chip);
return retval;
}
retval = rtsx_write_register(chip, SD_VPCLK1_CTL,
PHASE_NOT_RESET, 0);
if (retval) {
rtsx_trace(chip);
return retval;
}
}
retval = rtsx_write_register(chip, CLK_DIV, 0xFF,
(div << 4) | mcu_cnt);
if (retval) {
rtsx_trace(chip);
return retval;
}
retval = rtsx_write_register(chip, CLK_SEL, 0xFF, sel);
if (retval) {
rtsx_trace(chip);
return retval;
} }
RTSX_WRITE_REG(chip, CLK_DIV, 0xFF, (div << 4) | mcu_cnt);
RTSX_WRITE_REG(chip, CLK_SEL, 0xFF, sel);
if (sd_vpclk_phase_reset) { if (sd_vpclk_phase_reset) {
udelay(200); udelay(200);
RTSX_WRITE_REG(chip, SD_VPCLK0_CTL, PHASE_NOT_RESET, retval = rtsx_write_register(chip, SD_VPCLK0_CTL,
PHASE_NOT_RESET); PHASE_NOT_RESET, PHASE_NOT_RESET);
RTSX_WRITE_REG(chip, SD_VPCLK1_CTL, PHASE_NOT_RESET, if (retval) {
PHASE_NOT_RESET); rtsx_trace(chip);
return retval;
}
retval = rtsx_write_register(chip, SD_VPCLK1_CTL,
PHASE_NOT_RESET, PHASE_NOT_RESET);
if (retval) {
rtsx_trace(chip);
return retval;
}
udelay(200); udelay(200);
} }
RTSX_WRITE_REG(chip, CLK_CTL, 0xFF, 0); retval = rtsx_write_register(chip, CLK_CTL, 0xFF, 0);
if (retval) {
rtsx_trace(chip);
return retval;
}
chip->cur_clk = clk; chip->cur_clk = clk;
...@@ -842,6 +882,7 @@ void trans_dma_enable(enum dma_data_direction dir, struct rtsx_chip *chip, ...@@ -842,6 +882,7 @@ void trans_dma_enable(enum dma_data_direction dir, struct rtsx_chip *chip,
int enable_card_clock(struct rtsx_chip *chip, u8 card) int enable_card_clock(struct rtsx_chip *chip, u8 card)
{ {
int retval;
u8 clk_en = 0; u8 clk_en = 0;
if (card & XD_CARD) if (card & XD_CARD)
...@@ -851,13 +892,18 @@ int enable_card_clock(struct rtsx_chip *chip, u8 card) ...@@ -851,13 +892,18 @@ int enable_card_clock(struct rtsx_chip *chip, u8 card)
if (card & MS_CARD) if (card & MS_CARD)
clk_en |= MS_CLK_EN; clk_en |= MS_CLK_EN;
RTSX_WRITE_REG(chip, CARD_CLK_EN, clk_en, clk_en); retval = rtsx_write_register(chip, CARD_CLK_EN, clk_en, clk_en);
if (retval) {
rtsx_trace(chip);
return retval;
}
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
int disable_card_clock(struct rtsx_chip *chip, u8 card) int disable_card_clock(struct rtsx_chip *chip, u8 card)
{ {
int retval;
u8 clk_en = 0; u8 clk_en = 0;
if (card & XD_CARD) if (card & XD_CARD)
...@@ -867,7 +913,11 @@ int disable_card_clock(struct rtsx_chip *chip, u8 card) ...@@ -867,7 +913,11 @@ int disable_card_clock(struct rtsx_chip *chip, u8 card)
if (card & MS_CARD) if (card & MS_CARD)
clk_en |= MS_CLK_EN; clk_en |= MS_CLK_EN;
RTSX_WRITE_REG(chip, CARD_CLK_EN, clk_en, 0); retval = rtsx_write_register(chip, CARD_CLK_EN, clk_en, 0);
if (retval) {
rtsx_trace(chip);
return retval;
}
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
...@@ -912,6 +962,7 @@ int card_power_on(struct rtsx_chip *chip, u8 card) ...@@ -912,6 +962,7 @@ int card_power_on(struct rtsx_chip *chip, u8 card)
int card_power_off(struct rtsx_chip *chip, u8 card) int card_power_off(struct rtsx_chip *chip, u8 card)
{ {
int retval;
u8 mask, val; u8 mask, val;
if (CHECK_LUN_MODE(chip, SD_MS_2LUN) && (card == MS_CARD)) { if (CHECK_LUN_MODE(chip, SD_MS_2LUN) && (card == MS_CARD)) {
...@@ -922,7 +973,11 @@ int card_power_off(struct rtsx_chip *chip, u8 card) ...@@ -922,7 +973,11 @@ int card_power_off(struct rtsx_chip *chip, u8 card)
val = SD_POWER_OFF; val = SD_POWER_OFF;
} }
RTSX_WRITE_REG(chip, CARD_PWR_CTL, mask, val); retval = rtsx_write_register(chip, CARD_PWR_CTL, mask, val);
if (retval) {
rtsx_trace(chip);
return retval;
}
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
...@@ -972,6 +1027,7 @@ int card_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, ...@@ -972,6 +1027,7 @@ int card_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
int card_share_mode(struct rtsx_chip *chip, int card) int card_share_mode(struct rtsx_chip *chip, int card)
{ {
int retval;
u8 mask, value; u8 mask, value;
if (CHECK_PID(chip, 0x5208)) { if (CHECK_PID(chip, 0x5208)) {
...@@ -1005,7 +1061,11 @@ int card_share_mode(struct rtsx_chip *chip, int card) ...@@ -1005,7 +1061,11 @@ int card_share_mode(struct rtsx_chip *chip, int card)
return STATUS_FAIL; return STATUS_FAIL;
} }
RTSX_WRITE_REG(chip, CARD_SHARE_MODE, mask, value); retval = rtsx_write_register(chip, CARD_SHARE_MODE, mask, value);
if (retval) {
rtsx_trace(chip);
return retval;
}
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
...@@ -1031,7 +1091,11 @@ int select_card(struct rtsx_chip *chip, int card) ...@@ -1031,7 +1091,11 @@ int select_card(struct rtsx_chip *chip, int card)
return STATUS_FAIL; return STATUS_FAIL;
} }
RTSX_WRITE_REG(chip, CARD_SELECT, 0x07, mod); retval = rtsx_write_register(chip, CARD_SELECT, 0x07, mod);
if (retval) {
rtsx_trace(chip);
return retval;
}
chip->cur_card = card; chip->cur_card = card;
retval = card_share_mode(chip, card); retval = card_share_mode(chip, card);
......
...@@ -1061,7 +1061,13 @@ int card_power_off(struct rtsx_chip *chip, u8 card); ...@@ -1061,7 +1061,13 @@ int card_power_off(struct rtsx_chip *chip, u8 card);
static inline int card_power_off_all(struct rtsx_chip *chip) static inline int card_power_off_all(struct rtsx_chip *chip)
{ {
RTSX_WRITE_REG(chip, CARD_PWR_CTL, 0x0F, 0x0F); int retval;
retval = rtsx_write_register(chip, CARD_PWR_CTL, 0x0F, 0x0F);
if (retval) {
rtsx_trace(chip);
return retval;
}
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
......
This diff is collapsed.
...@@ -988,22 +988,4 @@ int rtsx_read_ppbuf(struct rtsx_chip *chip, u8 *buf, int buf_len); ...@@ -988,22 +988,4 @@ int rtsx_read_ppbuf(struct rtsx_chip *chip, u8 *buf, int buf_len);
int rtsx_write_ppbuf(struct rtsx_chip *chip, u8 *buf, int buf_len); int rtsx_write_ppbuf(struct rtsx_chip *chip, u8 *buf, int buf_len);
int rtsx_check_chip_exist(struct rtsx_chip *chip); int rtsx_check_chip_exist(struct rtsx_chip *chip);
#define RTSX_WRITE_REG(chip, addr, mask, data) \
do { \
int retval = rtsx_write_register(chip, addr, mask, data); \
if (retval != STATUS_SUCCESS) { \
rtsx_trace(chip); \
return retval; \
} \
} while (0)
#define RTSX_READ_REG(chip, addr, data) \
do { \
int retval = rtsx_read_register(chip, addr, data); \
if (retval != STATUS_SUCCESS) { \
rtsx_trace(chip); \
return retval; \
} \
} while (0)
#endif /* __REALTEK_RTSX_CHIP_H */ #endif /* __REALTEK_RTSX_CHIP_H */
This diff is collapsed.
...@@ -36,10 +36,20 @@ static inline void spi_set_err_code(struct rtsx_chip *chip, u8 err_code) ...@@ -36,10 +36,20 @@ static inline void spi_set_err_code(struct rtsx_chip *chip, u8 err_code)
static int spi_init(struct rtsx_chip *chip) static int spi_init(struct rtsx_chip *chip)
{ {
RTSX_WRITE_REG(chip, SPI_CONTROL, 0xFF, int retval;
CS_POLARITY_LOW | DTO_MSB_FIRST | SPI_MASTER | SPI_MODE0 |
SPI_AUTO); retval = rtsx_write_register(chip, SPI_CONTROL, 0xFF,
RTSX_WRITE_REG(chip, SPI_TCTL, EDO_TIMING_MASK, SAMPLE_DELAY_HALF); CS_POLARITY_LOW | DTO_MSB_FIRST | SPI_MASTER | SPI_MODE0 | SPI_AUTO);
if (retval) {
rtsx_trace(chip);
return retval;
}
retval = rtsx_write_register(chip, SPI_TCTL, EDO_TIMING_MASK,
SAMPLE_DELAY_HALF);
if (retval) {
rtsx_trace(chip);
return retval;
}
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
...@@ -49,8 +59,18 @@ static int spi_set_init_para(struct rtsx_chip *chip) ...@@ -49,8 +59,18 @@ static int spi_set_init_para(struct rtsx_chip *chip)
struct spi_info *spi = &(chip->spi); struct spi_info *spi = &(chip->spi);
int retval; int retval;
RTSX_WRITE_REG(chip, SPI_CLK_DIVIDER1, 0xFF, (u8)(spi->clk_div >> 8)); retval = rtsx_write_register(chip, SPI_CLK_DIVIDER1, 0xFF,
RTSX_WRITE_REG(chip, SPI_CLK_DIVIDER0, 0xFF, (u8)(spi->clk_div)); (u8)(spi->clk_div >> 8));
if (retval) {
rtsx_trace(chip);
return retval;
}
retval = rtsx_write_register(chip, SPI_CLK_DIVIDER0, 0xFF,
(u8)(spi->clk_div));
if (retval) {
rtsx_trace(chip);
return retval;
}
retval = switch_clock(chip, spi->spi_clock); retval = switch_clock(chip, spi->spi_clock);
if (retval != STATUS_SUCCESS) { if (retval != STATUS_SUCCESS) {
...@@ -64,8 +84,18 @@ static int spi_set_init_para(struct rtsx_chip *chip) ...@@ -64,8 +84,18 @@ static int spi_set_init_para(struct rtsx_chip *chip)
return STATUS_FAIL; return STATUS_FAIL;
} }
RTSX_WRITE_REG(chip, CARD_CLK_EN, SPI_CLK_EN, SPI_CLK_EN); retval = rtsx_write_register(chip, CARD_CLK_EN, SPI_CLK_EN,
RTSX_WRITE_REG(chip, CARD_OE, SPI_OUTPUT_EN, SPI_OUTPUT_EN); SPI_CLK_EN);
if (retval) {
rtsx_trace(chip);
return retval;
}
retval = rtsx_write_register(chip, CARD_OE, SPI_OUTPUT_EN,
SPI_OUTPUT_EN);
if (retval) {
rtsx_trace(chip);
return retval;
}
wait_timeout(10); wait_timeout(10);
...@@ -228,8 +258,16 @@ static int spi_init_eeprom(struct rtsx_chip *chip) ...@@ -228,8 +258,16 @@ static int spi_init_eeprom(struct rtsx_chip *chip)
else else
clk = CLK_30; clk = CLK_30;
RTSX_WRITE_REG(chip, SPI_CLK_DIVIDER1, 0xFF, 0x00); retval = rtsx_write_register(chip, SPI_CLK_DIVIDER1, 0xFF, 0x00);
RTSX_WRITE_REG(chip, SPI_CLK_DIVIDER0, 0xFF, 0x27); if (retval) {
rtsx_trace(chip);
return retval;
}
retval = rtsx_write_register(chip, SPI_CLK_DIVIDER0, 0xFF, 0x27);
if (retval) {
rtsx_trace(chip);
return retval;
}
retval = switch_clock(chip, clk); retval = switch_clock(chip, clk);
if (retval != STATUS_SUCCESS) { if (retval != STATUS_SUCCESS) {
...@@ -243,14 +281,33 @@ static int spi_init_eeprom(struct rtsx_chip *chip) ...@@ -243,14 +281,33 @@ static int spi_init_eeprom(struct rtsx_chip *chip)
return STATUS_FAIL; return STATUS_FAIL;
} }
RTSX_WRITE_REG(chip, CARD_CLK_EN, SPI_CLK_EN, SPI_CLK_EN); retval = rtsx_write_register(chip, CARD_CLK_EN, SPI_CLK_EN,
RTSX_WRITE_REG(chip, CARD_OE, SPI_OUTPUT_EN, SPI_OUTPUT_EN); SPI_CLK_EN);
if (retval) {
rtsx_trace(chip);
return retval;
}
retval = rtsx_write_register(chip, CARD_OE, SPI_OUTPUT_EN,
SPI_OUTPUT_EN);
if (retval) {
rtsx_trace(chip);
return retval;
}
wait_timeout(10); wait_timeout(10);
RTSX_WRITE_REG(chip, SPI_CONTROL, 0xFF, retval = rtsx_write_register(chip, SPI_CONTROL, 0xFF,
CS_POLARITY_HIGH | SPI_EEPROM_AUTO); CS_POLARITY_HIGH | SPI_EEPROM_AUTO);
RTSX_WRITE_REG(chip, SPI_TCTL, EDO_TIMING_MASK, SAMPLE_DELAY_HALF); if (retval) {
rtsx_trace(chip);
return retval;
}
retval = rtsx_write_register(chip, SPI_TCTL, EDO_TIMING_MASK,
SAMPLE_DELAY_HALF);
if (retval) {
rtsx_trace(chip);
return retval;
}
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
...@@ -310,7 +367,11 @@ int spi_erase_eeprom_chip(struct rtsx_chip *chip) ...@@ -310,7 +367,11 @@ int spi_erase_eeprom_chip(struct rtsx_chip *chip)
return STATUS_FAIL; return STATUS_FAIL;
} }
RTSX_WRITE_REG(chip, CARD_GPIO_DIR, 0x01, 0x01); retval = rtsx_write_register(chip, CARD_GPIO_DIR, 0x01, 0x01);
if (retval) {
rtsx_trace(chip);
return retval;
}
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
...@@ -350,7 +411,11 @@ int spi_erase_eeprom_byte(struct rtsx_chip *chip, u16 addr) ...@@ -350,7 +411,11 @@ int spi_erase_eeprom_byte(struct rtsx_chip *chip, u16 addr)
return STATUS_FAIL; return STATUS_FAIL;
} }
RTSX_WRITE_REG(chip, CARD_GPIO_DIR, 0x01, 0x01); retval = rtsx_write_register(chip, CARD_GPIO_DIR, 0x01, 0x01);
if (retval) {
rtsx_trace(chip);
return retval;
}
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
...@@ -388,12 +453,20 @@ int spi_read_eeprom(struct rtsx_chip *chip, u16 addr, u8 *val) ...@@ -388,12 +453,20 @@ int spi_read_eeprom(struct rtsx_chip *chip, u16 addr, u8 *val)
} }
wait_timeout(5); wait_timeout(5);
RTSX_READ_REG(chip, SPI_DATA, &data); retval = rtsx_read_register(chip, SPI_DATA, &data);
if (retval) {
rtsx_trace(chip);
return retval;
}
if (val) if (val)
*val = data; *val = data;
RTSX_WRITE_REG(chip, CARD_GPIO_DIR, 0x01, 0x01); retval = rtsx_write_register(chip, CARD_GPIO_DIR, 0x01, 0x01);
if (retval) {
rtsx_trace(chip);
return retval;
}
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
...@@ -434,7 +507,11 @@ int spi_write_eeprom(struct rtsx_chip *chip, u16 addr, u8 val) ...@@ -434,7 +507,11 @@ int spi_write_eeprom(struct rtsx_chip *chip, u16 addr, u8 val)
return STATUS_FAIL; return STATUS_FAIL;
} }
RTSX_WRITE_REG(chip, CARD_GPIO_DIR, 0x01, 0x01); retval = rtsx_write_register(chip, CARD_GPIO_DIR, 0x01, 0x01);
if (retval) {
rtsx_trace(chip);
return retval;
}
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
......
...@@ -252,14 +252,22 @@ static int xd_read_cis(struct rtsx_chip *chip, u32 page_addr, u8 *buf, ...@@ -252,14 +252,22 @@ static int xd_read_cis(struct rtsx_chip *chip, u32 page_addr, u8 *buf,
return STATUS_FAIL; return STATUS_FAIL;
} }
RTSX_READ_REG(chip, XD_PAGE_STATUS, &reg); retval = rtsx_read_register(chip, XD_PAGE_STATUS, &reg);
if (retval) {
rtsx_trace(chip);
return retval;
}
if (reg != XD_GPG) { if (reg != XD_GPG) {
rtsx_clear_xd_error(chip); rtsx_clear_xd_error(chip);
rtsx_trace(chip); rtsx_trace(chip);
return STATUS_FAIL; return STATUS_FAIL;
} }
RTSX_READ_REG(chip, XD_CTL, &reg); retval = rtsx_read_register(chip, XD_CTL, &reg);
if (retval) {
rtsx_trace(chip);
return retval;
}
if (!(reg & XD_ECC1_ERROR) || !(reg & XD_ECC1_UNCORRECTABLE)) { if (!(reg & XD_ECC1_ERROR) || !(reg & XD_ECC1_UNCORRECTABLE)) {
retval = xd_read_data_from_ppb(chip, 0, buf, buf_len); retval = xd_read_data_from_ppb(chip, 0, buf, buf_len);
if (retval != STATUS_SUCCESS) { if (retval != STATUS_SUCCESS) {
...@@ -269,8 +277,18 @@ static int xd_read_cis(struct rtsx_chip *chip, u32 page_addr, u8 *buf, ...@@ -269,8 +277,18 @@ static int xd_read_cis(struct rtsx_chip *chip, u32 page_addr, u8 *buf,
if (reg & XD_ECC1_ERROR) { if (reg & XD_ECC1_ERROR) {
u8 ecc_bit, ecc_byte; u8 ecc_bit, ecc_byte;
RTSX_READ_REG(chip, XD_ECC_BIT1, &ecc_bit); retval = rtsx_read_register(chip, XD_ECC_BIT1,
RTSX_READ_REG(chip, XD_ECC_BYTE1, &ecc_byte); &ecc_bit);
if (retval) {
rtsx_trace(chip);
return retval;
}
retval = rtsx_read_register(chip, XD_ECC_BYTE1,
&ecc_byte);
if (retval) {
rtsx_trace(chip);
return retval;
}
dev_dbg(rtsx_dev(chip), "ECC_BIT1 = 0x%x, ECC_BYTE1 = 0x%x\n", dev_dbg(rtsx_dev(chip), "ECC_BIT1 = 0x%x, ECC_BYTE1 = 0x%x\n",
ecc_bit, ecc_byte); ecc_bit, ecc_byte);
...@@ -293,8 +311,18 @@ static int xd_read_cis(struct rtsx_chip *chip, u32 page_addr, u8 *buf, ...@@ -293,8 +311,18 @@ static int xd_read_cis(struct rtsx_chip *chip, u32 page_addr, u8 *buf,
if (reg & XD_ECC2_ERROR) { if (reg & XD_ECC2_ERROR) {
u8 ecc_bit, ecc_byte; u8 ecc_bit, ecc_byte;
RTSX_READ_REG(chip, XD_ECC_BIT2, &ecc_bit); retval = rtsx_read_register(chip, XD_ECC_BIT2,
RTSX_READ_REG(chip, XD_ECC_BYTE2, &ecc_byte); &ecc_bit);
if (retval) {
rtsx_trace(chip);
return retval;
}
retval = rtsx_read_register(chip, XD_ECC_BYTE2,
&ecc_byte);
if (retval) {
rtsx_trace(chip);
return retval;
}
dev_dbg(rtsx_dev(chip), "ECC_BIT2 = 0x%x, ECC_BYTE2 = 0x%x\n", dev_dbg(rtsx_dev(chip), "ECC_BIT2 = 0x%x, ECC_BYTE2 = 0x%x\n",
ecc_bit, ecc_byte); ecc_bit, ecc_byte);
...@@ -385,24 +413,71 @@ static void xd_fill_pull_ctl_enable(struct rtsx_chip *chip) ...@@ -385,24 +413,71 @@ static void xd_fill_pull_ctl_enable(struct rtsx_chip *chip)
static int xd_pull_ctl_disable(struct rtsx_chip *chip) static int xd_pull_ctl_disable(struct rtsx_chip *chip)
{ {
int retval;
if (CHECK_PID(chip, 0x5208)) { if (CHECK_PID(chip, 0x5208)) {
RTSX_WRITE_REG(chip, CARD_PULL_CTL1, 0xFF, retval = rtsx_write_register(chip, CARD_PULL_CTL1, 0xFF,
XD_D3_PD | XD_D2_PD | XD_D1_PD | XD_D0_PD); XD_D3_PD | XD_D2_PD | XD_D1_PD | XD_D0_PD);
RTSX_WRITE_REG(chip, CARD_PULL_CTL2, 0xFF, if (retval) {
XD_D7_PD | XD_D6_PD | XD_D5_PD | XD_D4_PD); rtsx_trace(chip);
RTSX_WRITE_REG(chip, CARD_PULL_CTL3, 0xFF, return retval;
XD_WP_PD | XD_CE_PD | XD_CLE_PD | XD_CD_PU); }
RTSX_WRITE_REG(chip, CARD_PULL_CTL4, 0xFF, retval = rtsx_write_register(chip, CARD_PULL_CTL2, 0xFF,
XD_RDY_PD | XD_WE_PD | XD_RE_PD | XD_ALE_PD); XD_D7_PD | XD_D6_PD | XD_D5_PD | XD_D4_PD);
RTSX_WRITE_REG(chip, CARD_PULL_CTL5, 0xFF, if (retval) {
MS_INS_PU | SD_WP_PD | SD_CD_PU | SD_CMD_PD); rtsx_trace(chip);
RTSX_WRITE_REG(chip, CARD_PULL_CTL6, 0xFF, MS_D5_PD | MS_D4_PD); return retval;
}
retval = rtsx_write_register(chip, CARD_PULL_CTL3, 0xFF,
XD_WP_PD | XD_CE_PD | XD_CLE_PD | XD_CD_PU);
if (retval) {
rtsx_trace(chip);
return retval;
}
retval = rtsx_write_register(chip, CARD_PULL_CTL4, 0xFF,
XD_RDY_PD | XD_WE_PD | XD_RE_PD | XD_ALE_PD);
if (retval) {
rtsx_trace(chip);
return retval;
}
retval = rtsx_write_register(chip, CARD_PULL_CTL5, 0xFF,
MS_INS_PU | SD_WP_PD | SD_CD_PU | SD_CMD_PD);
if (retval) {
rtsx_trace(chip);
return retval;
}
retval = rtsx_write_register(chip, CARD_PULL_CTL6, 0xFF,
MS_D5_PD | MS_D4_PD);
if (retval) {
rtsx_trace(chip);
return retval;
}
} else if (CHECK_PID(chip, 0x5288)) { } else if (CHECK_PID(chip, 0x5288)) {
if (CHECK_BARO_PKG(chip, QFN)) { if (CHECK_BARO_PKG(chip, QFN)) {
RTSX_WRITE_REG(chip, CARD_PULL_CTL1, 0xFF, 0x55); retval = rtsx_write_register(chip, CARD_PULL_CTL1,
RTSX_WRITE_REG(chip, CARD_PULL_CTL2, 0xFF, 0x55); 0xFF, 0x55);
RTSX_WRITE_REG(chip, CARD_PULL_CTL3, 0xFF, 0x4B); if (retval) {
RTSX_WRITE_REG(chip, CARD_PULL_CTL4, 0xFF, 0x69); rtsx_trace(chip);
return retval;
}
retval = rtsx_write_register(chip, CARD_PULL_CTL2,
0xFF, 0x55);
if (retval) {
rtsx_trace(chip);
return retval;
}
retval = rtsx_write_register(chip, CARD_PULL_CTL3,
0xFF, 0x4B);
if (retval) {
rtsx_trace(chip);
return retval;
}
retval = rtsx_write_register(chip, CARD_PULL_CTL4,
0xFF, 0x69);
if (retval) {
rtsx_trace(chip);
return retval;
}
} }
} }
...@@ -1144,7 +1219,12 @@ static int xd_copy_page(struct rtsx_chip *chip, u32 old_blk, u32 new_blk, ...@@ -1144,7 +1219,12 @@ static int xd_copy_page(struct rtsx_chip *chip, u32 old_blk, u32 new_blk,
XD_CLR_BAD_NEWBLK(xd_card); XD_CLR_BAD_NEWBLK(xd_card);
RTSX_WRITE_REG(chip, CARD_DATA_SOURCE, 0x01, PINGPONG_BUFFER); retval = rtsx_write_register(chip, CARD_DATA_SOURCE, 0x01,
PINGPONG_BUFFER);
if (retval) {
rtsx_trace(chip);
return retval;
}
for (i = start_page; i < end_page; i++) { for (i = start_page; i < end_page; i++) {
if (detect_card_cd(chip, XD_CARD) != STATUS_SUCCESS) { if (detect_card_cd(chip, XD_CARD) != STATUS_SUCCESS) {
...@@ -1619,12 +1699,20 @@ static int xd_read_multiple_pages(struct rtsx_chip *chip, u32 phy_blk, ...@@ -1619,12 +1699,20 @@ static int xd_read_multiple_pages(struct rtsx_chip *chip, u32 phy_blk,
return STATUS_SUCCESS; return STATUS_SUCCESS;
Fail: Fail:
RTSX_READ_REG(chip, XD_PAGE_STATUS, &reg_val); retval = rtsx_read_register(chip, XD_PAGE_STATUS, &reg_val);
if (retval) {
rtsx_trace(chip);
return retval;
}
if (reg_val != XD_GPG) if (reg_val != XD_GPG)
xd_set_err_code(chip, XD_PRG_ERROR); xd_set_err_code(chip, XD_PRG_ERROR);
RTSX_READ_REG(chip, XD_CTL, &reg_val); retval = rtsx_read_register(chip, XD_CTL, &reg_val);
if (retval) {
rtsx_trace(chip);
return retval;
}
if (((reg_val & (XD_ECC1_ERROR | XD_ECC1_UNCORRECTABLE)) if (((reg_val & (XD_ECC1_ERROR | XD_ECC1_UNCORRECTABLE))
== (XD_ECC1_ERROR | XD_ECC1_UNCORRECTABLE)) == (XD_ECC1_ERROR | XD_ECC1_UNCORRECTABLE))
...@@ -1847,7 +1935,11 @@ static int xd_write_multiple_pages(struct rtsx_chip *chip, u32 old_blk, ...@@ -1847,7 +1935,11 @@ static int xd_write_multiple_pages(struct rtsx_chip *chip, u32 old_blk,
return STATUS_SUCCESS; return STATUS_SUCCESS;
Fail: Fail:
RTSX_READ_REG(chip, XD_DAT, &reg_val); retval = rtsx_read_register(chip, XD_DAT, &reg_val);
if (retval) {
rtsx_trace(chip);
return retval;
}
if (reg_val & PROGRAM_ERROR) { if (reg_val & PROGRAM_ERROR) {
xd_set_err_code(chip, XD_PRG_ERROR); xd_set_err_code(chip, XD_PRG_ERROR);
xd_mark_bad_block(chip, new_blk); xd_mark_bad_block(chip, new_blk);
...@@ -2197,7 +2289,11 @@ int xd_power_off_card3v3(struct rtsx_chip *chip) ...@@ -2197,7 +2289,11 @@ int xd_power_off_card3v3(struct rtsx_chip *chip)
return STATUS_FAIL; return STATUS_FAIL;
} }
RTSX_WRITE_REG(chip, CARD_OE, XD_OUTPUT_EN, 0); retval = rtsx_write_register(chip, CARD_OE, XD_OUTPUT_EN, 0);
if (retval) {
rtsx_trace(chip);
return retval;
}
if (!chip->ft2_fast_mode) { if (!chip->ft2_fast_mode) {
retval = card_power_off(chip, XD_CARD); retval = card_power_off(chip, XD_CARD);
...@@ -2216,7 +2312,11 @@ int xd_power_off_card3v3(struct rtsx_chip *chip) ...@@ -2216,7 +2312,11 @@ int xd_power_off_card3v3(struct rtsx_chip *chip)
return STATUS_FAIL; return STATUS_FAIL;
} }
} else { } else {
RTSX_WRITE_REG(chip, FPGA_PULL_CTL, 0xFF, 0xDF); retval = rtsx_write_register(chip, FPGA_PULL_CTL, 0xFF, 0xDF);
if (retval) {
rtsx_trace(chip);
return retval;
}
} }
return STATUS_SUCCESS; return STATUS_SUCCESS;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment