Message ID | 20200907100718.7672-1-ricky_wu@realtek.com (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers | show |
Series | [v5,1/2] misc: rtsx: Fix power down flow | expand |
On Mon, Sep 07, 2020 at 06:07:18PM +0800, ricky_wu@realtek.com wrote: > From: Ricky Wu <ricky_wu@realtek.com> > > Fix and sort out rtsx driver power down flow It would be nice to say what's changing here, but it's a great improvement to have this split out. For example, this drops the "pm_state == HOST_ENTER_S3" check, but there's no explanation. Minor comments below. > Signed-off-by: Ricky Wu <ricky_wu@realtek.com> > --- > drivers/misc/cardreader/rts5227.c | 15 --------------- > drivers/misc/cardreader/rts5228.c | 5 ++--- > drivers/misc/cardreader/rts5249.c | 17 ----------------- > drivers/misc/cardreader/rts5260.c | 16 ---------------- > drivers/misc/cardreader/rtsx_pcr.c | 16 ++++++++++++++++ > 5 files changed, 18 insertions(+), 51 deletions(-) > > diff --git a/drivers/misc/cardreader/rts5227.c b/drivers/misc/cardreader/rts5227.c > index f5f392ddf3d6..747391e3fb5d 100644 > --- a/drivers/misc/cardreader/rts5227.c > +++ b/drivers/misc/cardreader/rts5227.c > @@ -77,19 +77,6 @@ static void rts5227_fetch_vendor_settings(struct rtsx_pcr *pcr) > pcr->flags |= PCR_REVERSE_SOCKET; > } > > -static void rts5227_force_power_down(struct rtsx_pcr *pcr, u8 pm_state) > -{ > - /* Set relink_time to 0 */ > - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, 0xFF, 0); > - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 2, 0xFF, 0); > - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, 0x01, 0); > - > - if (pm_state == HOST_ENTER_S3) > - rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3, 0x10, 0x10); > - > - rtsx_pci_write_register(pcr, FPDCTL, 0x03, 0x03); > -} > - > static int rts5227_extra_init_hw(struct rtsx_pcr *pcr) > { > u16 cap; > @@ -239,7 +226,6 @@ static const struct pcr_ops rts5227_pcr_ops = { > .switch_output_voltage = rts5227_switch_output_voltage, > .cd_deglitch = NULL, > .conv_clk_and_div_n = NULL, > - .force_power_down = rts5227_force_power_down, > }; > > /* SD Pull Control Enable: > @@ -389,7 +375,6 @@ static const struct pcr_ops rts522a_pcr_ops = { > .switch_output_voltage = rts522a_switch_output_voltage, > .cd_deglitch = NULL, > .conv_clk_and_div_n = NULL, > - .force_power_down = rts5227_force_power_down, > }; > > void rts522a_init_params(struct rtsx_pcr *pcr) > diff --git a/drivers/misc/cardreader/rts5228.c b/drivers/misc/cardreader/rts5228.c > index 28feab1449ab..781a86def59a 100644 > --- a/drivers/misc/cardreader/rts5228.c > +++ b/drivers/misc/cardreader/rts5228.c > @@ -99,9 +99,8 @@ static void rts5228_force_power_down(struct rtsx_pcr *pcr, u8 pm_state) > rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, > RELINK_TIME_MASK, 0); > > - if (pm_state == HOST_ENTER_S3) > - rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3, > - D3_DELINK_MODE_EN, D3_DELINK_MODE_EN); > + rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3, > + D3_DELINK_MODE_EN, D3_DELINK_MODE_EN); > > rtsx_pci_write_register(pcr, FPDCTL, > SSC_POWER_DOWN, SSC_POWER_DOWN); > diff --git a/drivers/misc/cardreader/rts5249.c b/drivers/misc/cardreader/rts5249.c > index 941b3d77f1e9..719aa2d61919 100644 > --- a/drivers/misc/cardreader/rts5249.c > +++ b/drivers/misc/cardreader/rts5249.c > @@ -78,20 +78,6 @@ static void rtsx_base_fetch_vendor_settings(struct rtsx_pcr *pcr) > pcr->flags |= PCR_REVERSE_SOCKET; > } > > -static void rtsx_base_force_power_down(struct rtsx_pcr *pcr, u8 pm_state) > -{ > - /* Set relink_time to 0 */ > - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, 0xFF, 0); > - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 2, 0xFF, 0); > - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, 0x01, 0); > - > - if (pm_state == HOST_ENTER_S3) > - rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3, > - D3_DELINK_MODE_EN, D3_DELINK_MODE_EN); > - > - rtsx_pci_write_register(pcr, FPDCTL, 0x03, 0x03); > -} > - > static void rts5249_init_from_cfg(struct rtsx_pcr *pcr) > { > struct pci_dev *pdev = pcr->pci; > @@ -360,7 +346,6 @@ static const struct pcr_ops rts5249_pcr_ops = { > .card_power_on = rtsx_base_card_power_on, > .card_power_off = rtsx_base_card_power_off, > .switch_output_voltage = rtsx_base_switch_output_voltage, > - .force_power_down = rtsx_base_force_power_down, > }; > > /* SD Pull Control Enable: > @@ -585,7 +570,6 @@ static const struct pcr_ops rts524a_pcr_ops = { > .card_power_on = rtsx_base_card_power_on, > .card_power_off = rtsx_base_card_power_off, > .switch_output_voltage = rtsx_base_switch_output_voltage, > - .force_power_down = rtsx_base_force_power_down, > .set_l1off_cfg_sub_d0 = rts5250_set_l1off_cfg_sub_d0, > }; > > @@ -700,7 +684,6 @@ static const struct pcr_ops rts525a_pcr_ops = { > .card_power_on = rts525a_card_power_on, > .card_power_off = rtsx_base_card_power_off, > .switch_output_voltage = rts525a_switch_output_voltage, > - .force_power_down = rtsx_base_force_power_down, > .set_l1off_cfg_sub_d0 = rts5250_set_l1off_cfg_sub_d0, > }; > > diff --git a/drivers/misc/cardreader/rts5260.c b/drivers/misc/cardreader/rts5260.c > index b9f66b1384a6..897cfee350e7 100644 > --- a/drivers/misc/cardreader/rts5260.c > +++ b/drivers/misc/cardreader/rts5260.c > @@ -87,21 +87,6 @@ static void rtsx_base_fetch_vendor_settings(struct rtsx_pcr *pcr) > pcr->flags |= PCR_REVERSE_SOCKET; > } > > -static void rtsx_base_force_power_down(struct rtsx_pcr *pcr, u8 pm_state) > -{ > - /* Set relink_time to 0 */ > - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, MASK_8_BIT_DEF, 0); > - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 2, MASK_8_BIT_DEF, 0); > - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, > - RELINK_TIME_MASK, 0); > - > - if (pm_state == HOST_ENTER_S3) > - rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3, > - D3_DELINK_MODE_EN, D3_DELINK_MODE_EN); > - > - rtsx_pci_write_register(pcr, FPDCTL, ALL_POWER_DOWN, ALL_POWER_DOWN); > -} > - > static int rtsx_base_enable_auto_blink(struct rtsx_pcr *pcr) > { > return rtsx_pci_write_register(pcr, OLT_LED_CTL, > @@ -620,7 +605,6 @@ static const struct pcr_ops rts5260_pcr_ops = { > .card_power_on = rts5260_card_power_on, > .card_power_off = rts5260_card_power_off, > .switch_output_voltage = rts5260_switch_output_voltage, > - .force_power_down = rtsx_base_force_power_down, > .stop_cmd = rts5260_stop_cmd, > .set_l1off_cfg_sub_d0 = rts5260_set_l1off_cfg_sub_d0, > .enable_ocp = rts5260_enable_ocp, > diff --git a/drivers/misc/cardreader/rtsx_pcr.c b/drivers/misc/cardreader/rtsx_pcr.c > index 37ccc67f4914..3f84b898bd9c 100644 > --- a/drivers/misc/cardreader/rtsx_pcr.c > +++ b/drivers/misc/cardreader/rtsx_pcr.c > @@ -1096,6 +1096,20 @@ static void rtsx_pci_idle_work(struct work_struct *work) > mutex_unlock(&pcr->pcr_mutex); > } > > +static void rtsx_base_force_power_down(struct rtsx_pcr *pcr, u8 pm_state) > +{ > + /* Set relink_time to 0 */ > + rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, MASK_8_BIT_DEF, 0); > + rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 2, MASK_8_BIT_DEF, 0); Personally, I don't think MASK_8_BIT_DEF is an improvement over 0xFF. > + rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, > + RELINK_TIME_MASK, 0); > + > + rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3, > + D3_DELINK_MODE_EN, D3_DELINK_MODE_EN); > + > + rtsx_pci_write_register(pcr, FPDCTL, ALL_POWER_DOWN, ALL_POWER_DOWN); This changes the value written from 0x3 to 0x7 (ALL_POWER_DOWN) in a couple cases. I guess you know that's OK. > +} > + > static void __maybe_unused rtsx_pci_power_off(struct rtsx_pcr *pcr, u8 pm_state) > { > if (pcr->ops->turn_off_led) > @@ -1109,6 +1123,8 @@ static void __maybe_unused rtsx_pci_power_off(struct rtsx_pcr *pcr, u8 pm_state) > > if (pcr->ops->force_power_down) > pcr->ops->force_power_down(pcr, pm_state); > + else > + rtsx_base_force_power_down(pcr, pm_state); > } > > void rtsx_pci_enable_ocp(struct rtsx_pcr *pcr) > -- > 2.17.1 >
> -----Original Message----- > From: Bjorn Helgaas [mailto:helgaas@kernel.org] > Sent: Wednesday, September 09, 2020 6:20 AM > To: 吳昊澄 Ricky > Cc: arnd@arndb.de; gregkh@linuxfoundation.org; bhelgaas@google.com; > ulf.hansson@linaro.org; rui_feng@realsil.com.cn; linux-kernel@vger.kernel.org; > puranjay12@gmail.com; linux-pci@vger.kernel.org; > vailbhavgupta40@gamail.com > Subject: Re: [PATCH v5 1/2] misc: rtsx: Fix power down flow > > On Mon, Sep 07, 2020 at 06:07:18PM +0800, ricky_wu@realtek.com wrote: > > From: Ricky Wu <ricky_wu@realtek.com> > > > > Fix and sort out rtsx driver power down flow > > It would be nice to say what's changing here, but it's a great > improvement to have this split out. > > For example, this drops the "pm_state == HOST_ENTER_S3" check, but > there's no explanation. > > Minor comments below. > Drop out "pm_state == HOST_ENTER_S3" Because in shutdown flow we also need to clean this register But pm_state we may use in the future like D3... > > Signed-off-by: Ricky Wu <ricky_wu@realtek.com> > > --- > > drivers/misc/cardreader/rts5227.c | 15 --------------- > > drivers/misc/cardreader/rts5228.c | 5 ++--- > > drivers/misc/cardreader/rts5249.c | 17 ----------------- > > drivers/misc/cardreader/rts5260.c | 16 ---------------- > > drivers/misc/cardreader/rtsx_pcr.c | 16 ++++++++++++++++ > > 5 files changed, 18 insertions(+), 51 deletions(-) > > > > diff --git a/drivers/misc/cardreader/rts5227.c > b/drivers/misc/cardreader/rts5227.c > > index f5f392ddf3d6..747391e3fb5d 100644 > > --- a/drivers/misc/cardreader/rts5227.c > > +++ b/drivers/misc/cardreader/rts5227.c > > @@ -77,19 +77,6 @@ static void rts5227_fetch_vendor_settings(struct > rtsx_pcr *pcr) > > pcr->flags |= PCR_REVERSE_SOCKET; > > } > > > > -static void rts5227_force_power_down(struct rtsx_pcr *pcr, u8 pm_state) > > -{ > > - /* Set relink_time to 0 */ > > - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, 0xFF, 0); > > - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 2, 0xFF, 0); > > - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, 0x01, 0); > > - > > - if (pm_state == HOST_ENTER_S3) > > - rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3, 0x10, 0x10); > > - > > - rtsx_pci_write_register(pcr, FPDCTL, 0x03, 0x03); > > -} > > - > > static int rts5227_extra_init_hw(struct rtsx_pcr *pcr) > > { > > u16 cap; > > @@ -239,7 +226,6 @@ static const struct pcr_ops rts5227_pcr_ops = { > > .switch_output_voltage = rts5227_switch_output_voltage, > > .cd_deglitch = NULL, > > .conv_clk_and_div_n = NULL, > > - .force_power_down = rts5227_force_power_down, > > }; > > > > /* SD Pull Control Enable: > > @@ -389,7 +375,6 @@ static const struct pcr_ops rts522a_pcr_ops = { > > .switch_output_voltage = rts522a_switch_output_voltage, > > .cd_deglitch = NULL, > > .conv_clk_and_div_n = NULL, > > - .force_power_down = rts5227_force_power_down, > > }; > > > > void rts522a_init_params(struct rtsx_pcr *pcr) > > diff --git a/drivers/misc/cardreader/rts5228.c > b/drivers/misc/cardreader/rts5228.c > > index 28feab1449ab..781a86def59a 100644 > > --- a/drivers/misc/cardreader/rts5228.c > > +++ b/drivers/misc/cardreader/rts5228.c > > @@ -99,9 +99,8 @@ static void rts5228_force_power_down(struct rtsx_pcr > *pcr, u8 pm_state) > > rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, > > RELINK_TIME_MASK, 0); > > > > - if (pm_state == HOST_ENTER_S3) > > - rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3, > > - D3_DELINK_MODE_EN, D3_DELINK_MODE_EN); > > + rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3, > > + D3_DELINK_MODE_EN, D3_DELINK_MODE_EN); > > > > rtsx_pci_write_register(pcr, FPDCTL, > > SSC_POWER_DOWN, SSC_POWER_DOWN); > > diff --git a/drivers/misc/cardreader/rts5249.c > b/drivers/misc/cardreader/rts5249.c > > index 941b3d77f1e9..719aa2d61919 100644 > > --- a/drivers/misc/cardreader/rts5249.c > > +++ b/drivers/misc/cardreader/rts5249.c > > @@ -78,20 +78,6 @@ static void rtsx_base_fetch_vendor_settings(struct > rtsx_pcr *pcr) > > pcr->flags |= PCR_REVERSE_SOCKET; > > } > > > > -static void rtsx_base_force_power_down(struct rtsx_pcr *pcr, u8 pm_state) > > -{ > > - /* Set relink_time to 0 */ > > - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, 0xFF, 0); > > - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 2, 0xFF, 0); > > - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, 0x01, 0); > > - > > - if (pm_state == HOST_ENTER_S3) > > - rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3, > > - D3_DELINK_MODE_EN, D3_DELINK_MODE_EN); > > - > > - rtsx_pci_write_register(pcr, FPDCTL, 0x03, 0x03); > > -} > > - > > static void rts5249_init_from_cfg(struct rtsx_pcr *pcr) > > { > > struct pci_dev *pdev = pcr->pci; > > @@ -360,7 +346,6 @@ static const struct pcr_ops rts5249_pcr_ops = { > > .card_power_on = rtsx_base_card_power_on, > > .card_power_off = rtsx_base_card_power_off, > > .switch_output_voltage = rtsx_base_switch_output_voltage, > > - .force_power_down = rtsx_base_force_power_down, > > }; > > > > /* SD Pull Control Enable: > > @@ -585,7 +570,6 @@ static const struct pcr_ops rts524a_pcr_ops = { > > .card_power_on = rtsx_base_card_power_on, > > .card_power_off = rtsx_base_card_power_off, > > .switch_output_voltage = rtsx_base_switch_output_voltage, > > - .force_power_down = rtsx_base_force_power_down, > > .set_l1off_cfg_sub_d0 = rts5250_set_l1off_cfg_sub_d0, > > }; > > > > @@ -700,7 +684,6 @@ static const struct pcr_ops rts525a_pcr_ops = { > > .card_power_on = rts525a_card_power_on, > > .card_power_off = rtsx_base_card_power_off, > > .switch_output_voltage = rts525a_switch_output_voltage, > > - .force_power_down = rtsx_base_force_power_down, > > .set_l1off_cfg_sub_d0 = rts5250_set_l1off_cfg_sub_d0, > > }; > > > > diff --git a/drivers/misc/cardreader/rts5260.c > b/drivers/misc/cardreader/rts5260.c > > index b9f66b1384a6..897cfee350e7 100644 > > --- a/drivers/misc/cardreader/rts5260.c > > +++ b/drivers/misc/cardreader/rts5260.c > > @@ -87,21 +87,6 @@ static void rtsx_base_fetch_vendor_settings(struct > rtsx_pcr *pcr) > > pcr->flags |= PCR_REVERSE_SOCKET; > > } > > > > -static void rtsx_base_force_power_down(struct rtsx_pcr *pcr, u8 pm_state) > > -{ > > - /* Set relink_time to 0 */ > > - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, MASK_8_BIT_DEF, > 0); > > - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 2, MASK_8_BIT_DEF, > 0); > > - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, > > - RELINK_TIME_MASK, 0); > > - > > - if (pm_state == HOST_ENTER_S3) > > - rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3, > > - D3_DELINK_MODE_EN, D3_DELINK_MODE_EN); > > - > > - rtsx_pci_write_register(pcr, FPDCTL, ALL_POWER_DOWN, > ALL_POWER_DOWN); > > -} > > - > > static int rtsx_base_enable_auto_blink(struct rtsx_pcr *pcr) > > { > > return rtsx_pci_write_register(pcr, OLT_LED_CTL, > > @@ -620,7 +605,6 @@ static const struct pcr_ops rts5260_pcr_ops = { > > .card_power_on = rts5260_card_power_on, > > .card_power_off = rts5260_card_power_off, > > .switch_output_voltage = rts5260_switch_output_voltage, > > - .force_power_down = rtsx_base_force_power_down, > > .stop_cmd = rts5260_stop_cmd, > > .set_l1off_cfg_sub_d0 = rts5260_set_l1off_cfg_sub_d0, > > .enable_ocp = rts5260_enable_ocp, > > diff --git a/drivers/misc/cardreader/rtsx_pcr.c > b/drivers/misc/cardreader/rtsx_pcr.c > > index 37ccc67f4914..3f84b898bd9c 100644 > > --- a/drivers/misc/cardreader/rtsx_pcr.c > > +++ b/drivers/misc/cardreader/rtsx_pcr.c > > @@ -1096,6 +1096,20 @@ static void rtsx_pci_idle_work(struct work_struct > *work) > > mutex_unlock(&pcr->pcr_mutex); > > } > > > > +static void rtsx_base_force_power_down(struct rtsx_pcr *pcr, u8 pm_state) > > +{ > > + /* Set relink_time to 0 */ > > + rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, MASK_8_BIT_DEF, > 0); > > + rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 2, MASK_8_BIT_DEF, > 0); > > Personally, I don't think MASK_8_BIT_DEF is an improvement over 0xFF. > > > + rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, > > + RELINK_TIME_MASK, 0); > > + > > + rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3, > > + D3_DELINK_MODE_EN, D3_DELINK_MODE_EN); > > + > > + rtsx_pci_write_register(pcr, FPDCTL, ALL_POWER_DOWN, > ALL_POWER_DOWN); > > This changes the value written from 0x3 to 0x7 (ALL_POWER_DOWN) in a > couple cases. I guess you know that's OK. > Yes, so I left rts5228_force_power_down for call back > > +} > > + > > static void __maybe_unused rtsx_pci_power_off(struct rtsx_pcr *pcr, u8 > pm_state) > > { > > if (pcr->ops->turn_off_led) > > @@ -1109,6 +1123,8 @@ static void __maybe_unused > rtsx_pci_power_off(struct rtsx_pcr *pcr, u8 pm_state) > > > > if (pcr->ops->force_power_down) > > pcr->ops->force_power_down(pcr, pm_state); > > + else > > + rtsx_base_force_power_down(pcr, pm_state); > > } > > > > void rtsx_pci_enable_ocp(struct rtsx_pcr *pcr) > > -- > > 2.17.1 > > > > ------Please consider the environment before printing this e-mail.
diff --git a/drivers/misc/cardreader/rts5227.c b/drivers/misc/cardreader/rts5227.c index f5f392ddf3d6..747391e3fb5d 100644 --- a/drivers/misc/cardreader/rts5227.c +++ b/drivers/misc/cardreader/rts5227.c @@ -77,19 +77,6 @@ static void rts5227_fetch_vendor_settings(struct rtsx_pcr *pcr) pcr->flags |= PCR_REVERSE_SOCKET; } -static void rts5227_force_power_down(struct rtsx_pcr *pcr, u8 pm_state) -{ - /* Set relink_time to 0 */ - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, 0xFF, 0); - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 2, 0xFF, 0); - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, 0x01, 0); - - if (pm_state == HOST_ENTER_S3) - rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3, 0x10, 0x10); - - rtsx_pci_write_register(pcr, FPDCTL, 0x03, 0x03); -} - static int rts5227_extra_init_hw(struct rtsx_pcr *pcr) { u16 cap; @@ -239,7 +226,6 @@ static const struct pcr_ops rts5227_pcr_ops = { .switch_output_voltage = rts5227_switch_output_voltage, .cd_deglitch = NULL, .conv_clk_and_div_n = NULL, - .force_power_down = rts5227_force_power_down, }; /* SD Pull Control Enable: @@ -389,7 +375,6 @@ static const struct pcr_ops rts522a_pcr_ops = { .switch_output_voltage = rts522a_switch_output_voltage, .cd_deglitch = NULL, .conv_clk_and_div_n = NULL, - .force_power_down = rts5227_force_power_down, }; void rts522a_init_params(struct rtsx_pcr *pcr) diff --git a/drivers/misc/cardreader/rts5228.c b/drivers/misc/cardreader/rts5228.c index 28feab1449ab..781a86def59a 100644 --- a/drivers/misc/cardreader/rts5228.c +++ b/drivers/misc/cardreader/rts5228.c @@ -99,9 +99,8 @@ static void rts5228_force_power_down(struct rtsx_pcr *pcr, u8 pm_state) rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, RELINK_TIME_MASK, 0); - if (pm_state == HOST_ENTER_S3) - rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3, - D3_DELINK_MODE_EN, D3_DELINK_MODE_EN); + rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3, + D3_DELINK_MODE_EN, D3_DELINK_MODE_EN); rtsx_pci_write_register(pcr, FPDCTL, SSC_POWER_DOWN, SSC_POWER_DOWN); diff --git a/drivers/misc/cardreader/rts5249.c b/drivers/misc/cardreader/rts5249.c index 941b3d77f1e9..719aa2d61919 100644 --- a/drivers/misc/cardreader/rts5249.c +++ b/drivers/misc/cardreader/rts5249.c @@ -78,20 +78,6 @@ static void rtsx_base_fetch_vendor_settings(struct rtsx_pcr *pcr) pcr->flags |= PCR_REVERSE_SOCKET; } -static void rtsx_base_force_power_down(struct rtsx_pcr *pcr, u8 pm_state) -{ - /* Set relink_time to 0 */ - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, 0xFF, 0); - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 2, 0xFF, 0); - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, 0x01, 0); - - if (pm_state == HOST_ENTER_S3) - rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3, - D3_DELINK_MODE_EN, D3_DELINK_MODE_EN); - - rtsx_pci_write_register(pcr, FPDCTL, 0x03, 0x03); -} - static void rts5249_init_from_cfg(struct rtsx_pcr *pcr) { struct pci_dev *pdev = pcr->pci; @@ -360,7 +346,6 @@ static const struct pcr_ops rts5249_pcr_ops = { .card_power_on = rtsx_base_card_power_on, .card_power_off = rtsx_base_card_power_off, .switch_output_voltage = rtsx_base_switch_output_voltage, - .force_power_down = rtsx_base_force_power_down, }; /* SD Pull Control Enable: @@ -585,7 +570,6 @@ static const struct pcr_ops rts524a_pcr_ops = { .card_power_on = rtsx_base_card_power_on, .card_power_off = rtsx_base_card_power_off, .switch_output_voltage = rtsx_base_switch_output_voltage, - .force_power_down = rtsx_base_force_power_down, .set_l1off_cfg_sub_d0 = rts5250_set_l1off_cfg_sub_d0, }; @@ -700,7 +684,6 @@ static const struct pcr_ops rts525a_pcr_ops = { .card_power_on = rts525a_card_power_on, .card_power_off = rtsx_base_card_power_off, .switch_output_voltage = rts525a_switch_output_voltage, - .force_power_down = rtsx_base_force_power_down, .set_l1off_cfg_sub_d0 = rts5250_set_l1off_cfg_sub_d0, }; diff --git a/drivers/misc/cardreader/rts5260.c b/drivers/misc/cardreader/rts5260.c index b9f66b1384a6..897cfee350e7 100644 --- a/drivers/misc/cardreader/rts5260.c +++ b/drivers/misc/cardreader/rts5260.c @@ -87,21 +87,6 @@ static void rtsx_base_fetch_vendor_settings(struct rtsx_pcr *pcr) pcr->flags |= PCR_REVERSE_SOCKET; } -static void rtsx_base_force_power_down(struct rtsx_pcr *pcr, u8 pm_state) -{ - /* Set relink_time to 0 */ - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, MASK_8_BIT_DEF, 0); - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 2, MASK_8_BIT_DEF, 0); - rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, - RELINK_TIME_MASK, 0); - - if (pm_state == HOST_ENTER_S3) - rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3, - D3_DELINK_MODE_EN, D3_DELINK_MODE_EN); - - rtsx_pci_write_register(pcr, FPDCTL, ALL_POWER_DOWN, ALL_POWER_DOWN); -} - static int rtsx_base_enable_auto_blink(struct rtsx_pcr *pcr) { return rtsx_pci_write_register(pcr, OLT_LED_CTL, @@ -620,7 +605,6 @@ static const struct pcr_ops rts5260_pcr_ops = { .card_power_on = rts5260_card_power_on, .card_power_off = rts5260_card_power_off, .switch_output_voltage = rts5260_switch_output_voltage, - .force_power_down = rtsx_base_force_power_down, .stop_cmd = rts5260_stop_cmd, .set_l1off_cfg_sub_d0 = rts5260_set_l1off_cfg_sub_d0, .enable_ocp = rts5260_enable_ocp, diff --git a/drivers/misc/cardreader/rtsx_pcr.c b/drivers/misc/cardreader/rtsx_pcr.c index 37ccc67f4914..3f84b898bd9c 100644 --- a/drivers/misc/cardreader/rtsx_pcr.c +++ b/drivers/misc/cardreader/rtsx_pcr.c @@ -1096,6 +1096,20 @@ static void rtsx_pci_idle_work(struct work_struct *work) mutex_unlock(&pcr->pcr_mutex); } +static void rtsx_base_force_power_down(struct rtsx_pcr *pcr, u8 pm_state) +{ + /* Set relink_time to 0 */ + rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, MASK_8_BIT_DEF, 0); + rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 2, MASK_8_BIT_DEF, 0); + rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, + RELINK_TIME_MASK, 0); + + rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3, + D3_DELINK_MODE_EN, D3_DELINK_MODE_EN); + + rtsx_pci_write_register(pcr, FPDCTL, ALL_POWER_DOWN, ALL_POWER_DOWN); +} + static void __maybe_unused rtsx_pci_power_off(struct rtsx_pcr *pcr, u8 pm_state) { if (pcr->ops->turn_off_led) @@ -1109,6 +1123,8 @@ static void __maybe_unused rtsx_pci_power_off(struct rtsx_pcr *pcr, u8 pm_state) if (pcr->ops->force_power_down) pcr->ops->force_power_down(pcr, pm_state); + else + rtsx_base_force_power_down(pcr, pm_state); } void rtsx_pci_enable_ocp(struct rtsx_pcr *pcr)