28 #include <linux/sched.h>
31 #include <scsi/scsi.h>
114 rts51x_init_cmd(chip);
141 rts51x_init_cmd(chip);
150 static void do_reset_ms_card(
struct rts51x_chip *chip)
168 rts51x_init_cmd(chip);
177 static void card_cd_debounce(
struct rts51x_chip *chip,
u8 *need_reset,
181 u8 release_map = 0, reset_map = 0;
230 int xd_cnt = 0, sd_cnt = 0, ms_cnt = 0;
233 for (i = 0; i < (chip->
option.debounce_num); i++) {
237 reset_map = release_map = 0;
257 && (xd_cnt > (chip->
option.debounce_num - 1))) {
261 && (sd_cnt > (chip->
option.debounce_num - 1))) {
265 && (ms_cnt > (chip->
option.debounce_num - 1))) {
274 *need_reset = reset_map;
276 *need_release = release_map;
281 u8 need_reset = 0, need_release = 0;
283 card_cd_debounce(chip, &need_reset, &need_release);
342 do_reset_xd_card(chip);
343 }
else if (need_reset &
SD_CARD) {
346 }
else if (need_reset &
MS_CARD) {
348 do_reset_ms_card(chip);
376 return ((depth > 1) ? (depth - 1) : depth);
384 u8 N = (
u8) (clk - 2), min_N, max_N;
385 u8 mcu_cnt,
div, max_div, ssc_depth;
386 int sd_vpclk_phase_reset = 0;
397 if ((clk <= 2) || (N > max_N))
400 mcu_cnt = (
u8) (60 / clk + 3);
406 while ((N < min_N) && (div < max_div)) {
412 if (chip->
option.ssc_en) {
415 ssc_depth = chip->
option.ssc_depth_sd_sdr104;
417 ssc_depth = chip->
option.ssc_depth_sd_sdr50;
420 double_depth(chip->
option.
424 double_depth(chip->
option.ssc_depth_sd_hs);
428 double_depth(chip->
option.
432 double_depth(chip->
option.
433 ssc_depth_low_speed);
439 double_depth(chip->
option.
443 double_depth(chip->
option.
449 double_depth(chip->
option.
453 double_depth(chip->
option.
454 ssc_depth_low_speed);
459 double_depth(chip->
option.ssc_depth_low_speed);
486 rts51x_init_cmd(chip);
489 (div << 4) | mcu_cnt);
494 if (sd_vpclk_phase_reset) {
504 if (chip->
option.ssc_en && ssc_depth)
520 int sd_vpclk_phase_reset = 0;
528 sd_vpclk_phase_reset = 1;
601 if (!sd_vpclk_phase_reset) {
602 rts51x_init_cmd(chip);
607 (div << 4) | mcu_cnt);
616 rts51x_init_cmd(chip);
625 (div << 4) | mcu_cnt);
635 rts51x_init_cmd(chip);
666 RTS51X_DEBUGP(
"%s card, sector addr: 0x%x, sector cnt: %d\n",
671 for (i = 0; i < 3; i++) {
675 if (chip->option.reset_or_rw_fail_set_pad_drive) {
682 if (!chip->rw_need_retry)
739 retval = card_share_mode(chip, card);
774 u32 byte_cnt,
u8 pack_size)
783 (
u8) (byte_cnt >> 24));
785 (
u8) (byte_cnt >> 16));
787 (
u8) (byte_cnt >> 8));
825 #ifdef SD_XD_IO_FOLLOW_PWR
832 #ifdef SD_XD_IO_FOLLOW_PWR
837 #ifdef SD_XD_IO_FOLLOW_PWR
850 u8 card_cd[32] = { 0 };
870 u8 gpio_output[4] = {
880 temp_reg ^= gpio_oe[
gpio];
890 temp_reg ^= gpio_output[
gpio];
893 temp_reg | gpio_oe[gpio]);
923 u8 gpio_output[4] = {
935 gpio_oe[gpio] | gpio_output[gpio]);