void try_to_switch_sdio_ctrl(struct rtsx_chip *chip) { u8 reg1 = 0, reg2 = 0; rtsx_read_register(chip, 0xFF34, ®1); rtsx_read_register(chip, 0xFF38, ®2); RTSX_DEBUGP("reg 0xFF34: 0x%x, reg 0xFF38: 0x%x\n", reg1, reg2); if ((reg1 & 0xC0) && (reg2 & 0xC0)) { chip->sd_int = 1; rtsx_write_register(chip, SDIO_CTRL, 0xFF, SDIO_BUS_CTRL | SDIO_CD_CTRL); rtsx_write_register(chip, PWR_GATE_CTRL, LDO3318_PWR_MASK, LDO_ON); } }
void toggle_gpio(struct rtsx_chip *chip, u8 gpio) { u8 temp_reg; rtsx_read_register(chip, CARD_GPIO, &temp_reg); temp_reg ^= (0x01 << gpio); rtsx_write_register(chip, CARD_GPIO, 0xFF, temp_reg); }
void dynamic_configure_sdio_aspm(struct rtsx_chip *chip) { u8 buf[12], reg; int i; for (i = 0; i < 12; i++) { rtsx_read_register(chip, 0xFF08 + i, &buf[i]); } rtsx_read_register(chip, 0xFF25, ®); if ((memcmp(buf, chip->sdio_raw_data, 12) != 0) || (reg & 0x03)) { chip->sdio_counter = 0; chip->sdio_idle = 0; } else { if (!chip->sdio_idle) { chip->sdio_counter ++; if (chip->sdio_counter >= SDIO_IDLE_COUNT) { chip->sdio_counter = 0; chip->sdio_idle = 1; } } } memcpy(chip->sdio_raw_data, buf, 12); if (chip->sdio_idle) { if (!chip->sdio_aspm) { RTSX_DEBUGP(("SDIO enter ASPM!\n")); rtsx_write_register(chip, ASPM_FORCE_CTL, 0xFC, 0x30 | (chip->aspm_level[1] << 2)); chip->sdio_aspm = 1; } } else { if (chip->sdio_aspm) { RTSX_DEBUGP(("SDIO exit ASPM!\n")); rtsx_write_register(chip, ASPM_FORCE_CTL, 0xFC, 0x30); chip->sdio_aspm = 0; } } }