mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 13:11:40 +00:00
misc: rtsx: separate aspm mode into MODE_REG and MODE_CFG
aspm (Active State Power Management)
rtsx_comm_set_aspm: this function is for driver to make sure
not enter power saving when processing of init and card_detcct
ASPM_MODE_CFG: 8411 5209 5227 5229 5249 5250
Change back to use original way to control aspm
ASPM_MODE_REG: 5227A 524A 5250A 5260 5261 5228
Keep the new way to control aspm
Fixes: 121e9c6b5c
("misc: rtsx: modify and fix init_hw function")
Reported-by: Chris Chiu <chris.chiu@canonical.com>
Tested-by: Gordon Lack <gordon.lack@dsl.pipex.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Ricky Wu <ricky_wu@realtek.com>
Link: https://lore.kernel.org/r/20210607101634.4948-1-ricky_wu@realtek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
5f0c2ee1fe
commit
3df4fce739
@ -468,6 +468,7 @@ static void rtl8411_init_common_params(struct rtsx_pcr *pcr)
|
||||
pcr->sd30_drive_sel_1v8 = DRIVER_TYPE_B;
|
||||
pcr->sd30_drive_sel_3v3 = DRIVER_TYPE_D;
|
||||
pcr->aspm_en = ASPM_L1_EN;
|
||||
pcr->aspm_mode = ASPM_MODE_CFG;
|
||||
pcr->tx_initial_phase = SET_CLOCK_PHASE(23, 7, 14);
|
||||
pcr->rx_initial_phase = SET_CLOCK_PHASE(4, 3, 10);
|
||||
pcr->ic_version = rtl8411_get_ic_version(pcr);
|
||||
|
@ -255,6 +255,7 @@ void rts5209_init_params(struct rtsx_pcr *pcr)
|
||||
pcr->sd30_drive_sel_1v8 = DRIVER_TYPE_B;
|
||||
pcr->sd30_drive_sel_3v3 = DRIVER_TYPE_D;
|
||||
pcr->aspm_en = ASPM_L1_EN;
|
||||
pcr->aspm_mode = ASPM_MODE_CFG;
|
||||
pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 27, 16);
|
||||
pcr->rx_initial_phase = SET_CLOCK_PHASE(24, 6, 5);
|
||||
|
||||
|
@ -358,6 +358,7 @@ void rts5227_init_params(struct rtsx_pcr *pcr)
|
||||
pcr->sd30_drive_sel_1v8 = CFG_DRIVER_TYPE_B;
|
||||
pcr->sd30_drive_sel_3v3 = CFG_DRIVER_TYPE_B;
|
||||
pcr->aspm_en = ASPM_L1_EN;
|
||||
pcr->aspm_mode = ASPM_MODE_CFG;
|
||||
pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 27, 15);
|
||||
pcr->rx_initial_phase = SET_CLOCK_PHASE(30, 7, 7);
|
||||
|
||||
@ -483,6 +484,7 @@ void rts522a_init_params(struct rtsx_pcr *pcr)
|
||||
|
||||
rts5227_init_params(pcr);
|
||||
pcr->ops = &rts522a_pcr_ops;
|
||||
pcr->aspm_mode = ASPM_MODE_REG;
|
||||
pcr->tx_initial_phase = SET_CLOCK_PHASE(20, 20, 11);
|
||||
pcr->reg_pm_ctrl3 = RTS522A_PM_CTRL3;
|
||||
|
||||
|
@ -718,6 +718,7 @@ void rts5228_init_params(struct rtsx_pcr *pcr)
|
||||
pcr->sd30_drive_sel_1v8 = CFG_DRIVER_TYPE_B;
|
||||
pcr->sd30_drive_sel_3v3 = CFG_DRIVER_TYPE_B;
|
||||
pcr->aspm_en = ASPM_L1_EN;
|
||||
pcr->aspm_mode = ASPM_MODE_REG;
|
||||
pcr->tx_initial_phase = SET_CLOCK_PHASE(28, 27, 11);
|
||||
pcr->rx_initial_phase = SET_CLOCK_PHASE(24, 6, 5);
|
||||
|
||||
|
@ -246,6 +246,7 @@ void rts5229_init_params(struct rtsx_pcr *pcr)
|
||||
pcr->sd30_drive_sel_1v8 = DRIVER_TYPE_B;
|
||||
pcr->sd30_drive_sel_3v3 = DRIVER_TYPE_D;
|
||||
pcr->aspm_en = ASPM_L1_EN;
|
||||
pcr->aspm_mode = ASPM_MODE_CFG;
|
||||
pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 27, 15);
|
||||
pcr->rx_initial_phase = SET_CLOCK_PHASE(30, 6, 6);
|
||||
|
||||
|
@ -566,6 +566,7 @@ void rts5249_init_params(struct rtsx_pcr *pcr)
|
||||
pcr->sd30_drive_sel_1v8 = CFG_DRIVER_TYPE_B;
|
||||
pcr->sd30_drive_sel_3v3 = CFG_DRIVER_TYPE_B;
|
||||
pcr->aspm_en = ASPM_L1_EN;
|
||||
pcr->aspm_mode = ASPM_MODE_CFG;
|
||||
pcr->tx_initial_phase = SET_CLOCK_PHASE(1, 29, 16);
|
||||
pcr->rx_initial_phase = SET_CLOCK_PHASE(24, 6, 5);
|
||||
|
||||
@ -729,6 +730,7 @@ static const struct pcr_ops rts524a_pcr_ops = {
|
||||
void rts524a_init_params(struct rtsx_pcr *pcr)
|
||||
{
|
||||
rts5249_init_params(pcr);
|
||||
pcr->aspm_mode = ASPM_MODE_REG;
|
||||
pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 29, 11);
|
||||
pcr->option.ltr_l1off_sspwrgate = LTR_L1OFF_SSPWRGATE_5250_DEF;
|
||||
pcr->option.ltr_l1off_snooze_sspwrgate =
|
||||
@ -845,6 +847,7 @@ static const struct pcr_ops rts525a_pcr_ops = {
|
||||
void rts525a_init_params(struct rtsx_pcr *pcr)
|
||||
{
|
||||
rts5249_init_params(pcr);
|
||||
pcr->aspm_mode = ASPM_MODE_REG;
|
||||
pcr->tx_initial_phase = SET_CLOCK_PHASE(25, 29, 11);
|
||||
pcr->option.ltr_l1off_sspwrgate = LTR_L1OFF_SSPWRGATE_5250_DEF;
|
||||
pcr->option.ltr_l1off_snooze_sspwrgate =
|
||||
|
@ -628,6 +628,7 @@ void rts5260_init_params(struct rtsx_pcr *pcr)
|
||||
pcr->sd30_drive_sel_1v8 = CFG_DRIVER_TYPE_B;
|
||||
pcr->sd30_drive_sel_3v3 = CFG_DRIVER_TYPE_B;
|
||||
pcr->aspm_en = ASPM_L1_EN;
|
||||
pcr->aspm_mode = ASPM_MODE_REG;
|
||||
pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 29, 11);
|
||||
pcr->rx_initial_phase = SET_CLOCK_PHASE(24, 6, 5);
|
||||
|
||||
|
@ -783,6 +783,7 @@ void rts5261_init_params(struct rtsx_pcr *pcr)
|
||||
pcr->sd30_drive_sel_1v8 = 0x00;
|
||||
pcr->sd30_drive_sel_3v3 = 0x00;
|
||||
pcr->aspm_en = ASPM_L1_EN;
|
||||
pcr->aspm_mode = ASPM_MODE_REG;
|
||||
pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 27, 11);
|
||||
pcr->rx_initial_phase = SET_CLOCK_PHASE(24, 6, 5);
|
||||
|
||||
|
@ -85,12 +85,18 @@ static void rtsx_comm_set_aspm(struct rtsx_pcr *pcr, bool enable)
|
||||
if (pcr->aspm_enabled == enable)
|
||||
return;
|
||||
|
||||
if (pcr->aspm_en & 0x02)
|
||||
rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, FORCE_ASPM_CTL0 |
|
||||
FORCE_ASPM_CTL1, enable ? 0 : FORCE_ASPM_CTL0 | FORCE_ASPM_CTL1);
|
||||
else
|
||||
rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, FORCE_ASPM_CTL0 |
|
||||
FORCE_ASPM_CTL1, FORCE_ASPM_CTL0 | FORCE_ASPM_CTL1);
|
||||
if (pcr->aspm_mode == ASPM_MODE_CFG) {
|
||||
pcie_capability_clear_and_set_word(pcr->pci, PCI_EXP_LNKCTL,
|
||||
PCI_EXP_LNKCTL_ASPMC,
|
||||
enable ? pcr->aspm_en : 0);
|
||||
} else if (pcr->aspm_mode == ASPM_MODE_REG) {
|
||||
if (pcr->aspm_en & 0x02)
|
||||
rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, FORCE_ASPM_CTL0 |
|
||||
FORCE_ASPM_CTL1, enable ? 0 : FORCE_ASPM_CTL0 | FORCE_ASPM_CTL1);
|
||||
else
|
||||
rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, FORCE_ASPM_CTL0 |
|
||||
FORCE_ASPM_CTL1, FORCE_ASPM_CTL0 | FORCE_ASPM_CTL1);
|
||||
}
|
||||
|
||||
if (!enable && (pcr->aspm_en & 0x02))
|
||||
mdelay(10);
|
||||
@ -1394,7 +1400,8 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr)
|
||||
return err;
|
||||
}
|
||||
|
||||
rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, 0x30, 0x30);
|
||||
if (pcr->aspm_mode == ASPM_MODE_REG)
|
||||
rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, 0x30, 0x30);
|
||||
|
||||
/* No CD interrupt if probing driver with card inserted.
|
||||
* So we need to initialize pcr->card_exist here.
|
||||
@ -1410,6 +1417,8 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr)
|
||||
static int rtsx_pci_init_chip(struct rtsx_pcr *pcr)
|
||||
{
|
||||
int err;
|
||||
u16 cfg_val;
|
||||
u8 val;
|
||||
|
||||
spin_lock_init(&pcr->lock);
|
||||
mutex_init(&pcr->pcr_mutex);
|
||||
@ -1477,6 +1486,21 @@ static int rtsx_pci_init_chip(struct rtsx_pcr *pcr)
|
||||
if (!pcr->slots)
|
||||
return -ENOMEM;
|
||||
|
||||
if (pcr->aspm_mode == ASPM_MODE_CFG) {
|
||||
pcie_capability_read_word(pcr->pci, PCI_EXP_LNKCTL, &cfg_val);
|
||||
if (cfg_val & PCI_EXP_LNKCTL_ASPM_L1)
|
||||
pcr->aspm_enabled = true;
|
||||
else
|
||||
pcr->aspm_enabled = false;
|
||||
|
||||
} else if (pcr->aspm_mode == ASPM_MODE_REG) {
|
||||
rtsx_pci_read_register(pcr, ASPM_FORCE_CTL, &val);
|
||||
if (val & FORCE_ASPM_CTL0 && val & FORCE_ASPM_CTL1)
|
||||
pcr->aspm_enabled = false;
|
||||
else
|
||||
pcr->aspm_enabled = true;
|
||||
}
|
||||
|
||||
if (pcr->ops->fetch_vendor_settings)
|
||||
pcr->ops->fetch_vendor_settings(pcr);
|
||||
|
||||
@ -1506,7 +1530,6 @@ static int rtsx_pci_probe(struct pci_dev *pcidev,
|
||||
struct pcr_handle *handle;
|
||||
u32 base, len;
|
||||
int ret, i, bar = 0;
|
||||
u8 val;
|
||||
|
||||
dev_dbg(&(pcidev->dev),
|
||||
": Realtek PCI-E Card Reader found at %s [%04x:%04x] (rev %x)\n",
|
||||
@ -1572,11 +1595,6 @@ static int rtsx_pci_probe(struct pci_dev *pcidev,
|
||||
pcr->host_cmds_addr = pcr->rtsx_resv_buf_addr;
|
||||
pcr->host_sg_tbl_ptr = pcr->rtsx_resv_buf + HOST_CMDS_BUF_LEN;
|
||||
pcr->host_sg_tbl_addr = pcr->rtsx_resv_buf_addr + HOST_CMDS_BUF_LEN;
|
||||
rtsx_pci_read_register(pcr, ASPM_FORCE_CTL, &val);
|
||||
if (val & FORCE_ASPM_CTL0 && val & FORCE_ASPM_CTL1)
|
||||
pcr->aspm_enabled = false;
|
||||
else
|
||||
pcr->aspm_enabled = true;
|
||||
pcr->card_inserted = 0;
|
||||
pcr->card_removed = 0;
|
||||
INIT_DELAYED_WORK(&pcr->carddet_work, rtsx_pci_card_detect);
|
||||
|
@ -1109,6 +1109,7 @@ struct pcr_ops {
|
||||
};
|
||||
|
||||
enum PDEV_STAT {PDEV_STAT_IDLE, PDEV_STAT_RUN};
|
||||
enum ASPM_MODE {ASPM_MODE_CFG, ASPM_MODE_REG};
|
||||
|
||||
#define ASPM_L1_1_EN BIT(0)
|
||||
#define ASPM_L1_2_EN BIT(1)
|
||||
@ -1234,6 +1235,7 @@ struct rtsx_pcr {
|
||||
u8 card_drive_sel;
|
||||
#define ASPM_L1_EN 0x02
|
||||
u8 aspm_en;
|
||||
enum ASPM_MODE aspm_mode;
|
||||
bool aspm_enabled;
|
||||
|
||||
#define PCR_MS_PMOS (1 << 0)
|
||||
|
Loading…
Reference in New Issue
Block a user