From: Ricky WU <ricky_wu@realtek.com>
To: Kai-Heng Feng <kai.heng.feng@canonical.com>,
"arnd@arndb.de" <arnd@arndb.de>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"ulf.hansson@linaro.org" <ulf.hansson@linaro.org>
Cc: "linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
Yang Li <yang.lee@linux.alibaba.com>,
Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v6 4/4] misc: rtsx: Quiesce rts5249 on system suspend
Date: Tue, 25 Jan 2022 06:38:53 +0000 [thread overview]
Message-ID: <f43f6994c8834af493e754ee019cbeef@realtek.com> (raw)
In-Reply-To: <20220125055010.1866563-4-kai.heng.feng@canonical.com>
> -----Original Message-----
> From: Kai-Heng Feng <kai.heng.feng@canonical.com>
> Sent: Tuesday, January 25, 2022 1:50 PM
> To: arnd@arndb.de; gregkh@linuxfoundation.org; ulf.hansson@linaro.org
> Cc: linux-pm@vger.kernel.org; Kai-Heng Feng <kai.heng.feng@canonical.com>;
> Ricky WU <ricky_wu@realtek.com>; Yang Li <yang.lee@linux.alibaba.com>;
> Christophe JAILLET <christophe.jaillet@wanadoo.fr>;
> linux-kernel@vger.kernel.org
> Subject: [PATCH v6 4/4] misc: rtsx: Quiesce rts5249 on system suspend
>
> Set more registers in force_power_down callback to avoid S3 wakeup from
> hotplugging cards.
>
> This is originally written by Ricky WU.
>
> Link:
> https://lore.kernel.org/lkml/c4525b4738f94483b9b8f8571fc80646@realtek.co
> m/
> Cc: Ricky WU <ricky_wu@realtek.com>
Tested-by: Ricky WU <ricky_wu@realtek.com>
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> ---
> v6:
> v5:
> v4:
> v3:
> v2:
> - No change.
>
> drivers/misc/cardreader/rtl8411.c | 2 +-
> drivers/misc/cardreader/rts5209.c | 2 +-
> drivers/misc/cardreader/rts5228.c | 2 +-
> drivers/misc/cardreader/rts5229.c | 2 +-
> drivers/misc/cardreader/rts5249.c | 31 ++++++++++++++++++++++++++++--
> drivers/misc/cardreader/rts5261.c | 2 +-
> drivers/misc/cardreader/rtsx_pcr.c | 14 +++++++-------
> drivers/misc/cardreader/rtsx_pcr.h | 1 +
> include/linux/rtsx_pci.h | 2 +-
> 9 files changed, 43 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/misc/cardreader/rtl8411.c
> b/drivers/misc/cardreader/rtl8411.c
> index 4c5621b17a6fb..06457e875a90c 100644
> --- a/drivers/misc/cardreader/rtl8411.c
> +++ b/drivers/misc/cardreader/rtl8411.c
> @@ -76,7 +76,7 @@ static void rtl8411b_fetch_vendor_settings(struct
> rtsx_pcr *pcr)
> map_sd_drive(rtl8411b_reg_to_sd30_drive_sel_3v3(reg));
> }
>
> -static void rtl8411_force_power_down(struct rtsx_pcr *pcr, u8 pm_state)
> +static void rtl8411_force_power_down(struct rtsx_pcr *pcr, u8 pm_state,
> +bool runtime)
> {
> rtsx_pci_write_register(pcr, FPDCTL, 0x07, 0x07); } diff --git
> a/drivers/misc/cardreader/rts5209.c b/drivers/misc/cardreader/rts5209.c
> index 29f5414072bf1..52b0a476ba51f 100644
> --- a/drivers/misc/cardreader/rts5209.c
> +++ b/drivers/misc/cardreader/rts5209.c
> @@ -47,7 +47,7 @@ static void rts5209_fetch_vendor_settings(struct rtsx_pcr
> *pcr)
> }
> }
>
> -static void rts5209_force_power_down(struct rtsx_pcr *pcr, u8 pm_state)
> +static void rts5209_force_power_down(struct rtsx_pcr *pcr, u8 pm_state,
> +bool runtime)
> {
> rtsx_pci_write_register(pcr, FPDCTL, 0x07, 0x07); } diff --git
> a/drivers/misc/cardreader/rts5228.c b/drivers/misc/cardreader/rts5228.c
> index ffc128278613b..ffe3afbf8bfed 100644
> --- a/drivers/misc/cardreader/rts5228.c
> +++ b/drivers/misc/cardreader/rts5228.c
> @@ -91,7 +91,7 @@ static int rts5228_optimize_phy(struct rtsx_pcr *pcr)
> return rtsx_pci_write_phy_register(pcr, 0x07, 0x8F40); }
>
> -static void rts5228_force_power_down(struct rtsx_pcr *pcr, u8 pm_state)
> +static void rts5228_force_power_down(struct rtsx_pcr *pcr, u8 pm_state,
> +bool runtime)
> {
> /* Set relink_time to 0 */
> rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, MASK_8_BIT_DEF,
> 0); diff --git a/drivers/misc/cardreader/rts5229.c
> b/drivers/misc/cardreader/rts5229.c
> index c748eaf1ec1f9..b0edd8006d52f 100644
> --- a/drivers/misc/cardreader/rts5229.c
> +++ b/drivers/misc/cardreader/rts5229.c
> @@ -44,7 +44,7 @@ static void rts5229_fetch_vendor_settings(struct rtsx_pcr
> *pcr)
> map_sd_drive(rtsx_reg_to_sd30_drive_sel_3v3(reg));
> }
>
> -static void rts5229_force_power_down(struct rtsx_pcr *pcr, u8 pm_state)
> +static void rts5229_force_power_down(struct rtsx_pcr *pcr, u8 pm_state,
> +bool runtime)
> {
> rtsx_pci_write_register(pcr, FPDCTL, 0x03, 0x03); } diff --git
> a/drivers/misc/cardreader/rts5249.c b/drivers/misc/cardreader/rts5249.c
> index 53f3a1f45c4a7..91d240dd68faa 100644
> --- a/drivers/misc/cardreader/rts5249.c
> +++ b/drivers/misc/cardreader/rts5249.c
> @@ -74,7 +74,8 @@ static void rtsx_base_fetch_vendor_settings(struct
> rtsx_pcr *pcr)
> pci_read_config_dword(pdev, PCR_SETTING_REG2, ®);
> pcr_dbg(pcr, "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG2, reg);
>
> - pcr->rtd3_en = rtsx_reg_to_rtd3_uhsii(reg);
> + if (CHK_PCI_PID(pcr, PID_524A) || CHK_PCI_PID(pcr, PID_525A))
> + pcr->rtd3_en = rtsx_reg_to_rtd3_uhsii(reg);
>
> if (rtsx_check_mmc_support(reg))
> pcr->extra_caps |= EXTRA_CAPS_NO_MMC; @@ -143,6 +144,27
> @@ static int rts5249_init_from_hw(struct rtsx_pcr *pcr)
> return 0;
> }
>
> +static void rts52xa_force_power_down(struct rtsx_pcr *pcr, u8 pm_state,
> +bool runtime) {
> + /* 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, RTS524A_PM_CTRL3,
> + D3_DELINK_MODE_EN, D3_DELINK_MODE_EN);
> +
> + if (!runtime) {
> + rtsx_pci_write_register(pcr, RTS524A_AUTOLOAD_CFG1,
> + CD_RESUME_EN_MASK, 0);
> + rtsx_pci_write_register(pcr, RTS524A_PM_CTRL3, 0x01, 0x00);
> + rtsx_pci_write_register(pcr, RTS524A_PME_FORCE_CTL, 0x30, 0x20);
> + }
> +
> + rtsx_pci_write_register(pcr, FPDCTL, ALL_POWER_DOWN,
> ALL_POWER_DOWN);
> +}
> +
> static void rts52xa_save_content_from_efuse(struct rtsx_pcr *pcr) {
> u8 cnt, sv;
> @@ -281,8 +303,11 @@ static int rts5249_extra_init_hw(struct rtsx_pcr *pcr)
>
> rtsx_pci_send_cmd(pcr, CMD_TIMEOUT_DEF);
>
> - if (CHK_PCI_PID(pcr, PID_524A) || CHK_PCI_PID(pcr, PID_525A))
> + if (CHK_PCI_PID(pcr, PID_524A) || CHK_PCI_PID(pcr, PID_525A)) {
> rtsx_pci_write_register(pcr, REG_VREF, PWD_SUSPND_EN,
> PWD_SUSPND_EN);
> + rtsx_pci_write_register(pcr, RTS524A_AUTOLOAD_CFG1,
> + CD_RESUME_EN_MASK, CD_RESUME_EN_MASK);
> + }
>
> if (pcr->rtd3_en) {
> if (CHK_PCI_PID(pcr, PID_524A) || CHK_PCI_PID(pcr, PID_525A))
> { @@ -724,6 +749,7 @@ 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 = rts52xa_force_power_down,
> .set_l1off_cfg_sub_d0 = rts5250_set_l1off_cfg_sub_d0, };
>
> @@ -841,6 +867,7 @@ 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 = rts52xa_force_power_down,
> .set_l1off_cfg_sub_d0 = rts5250_set_l1off_cfg_sub_d0, };
>
> diff --git a/drivers/misc/cardreader/rts5261.c
> b/drivers/misc/cardreader/rts5261.c
> index 1fd4e0e507302..64333347c14a4 100644
> --- a/drivers/misc/cardreader/rts5261.c
> +++ b/drivers/misc/cardreader/rts5261.c
> @@ -91,7 +91,7 @@ static void rtsx5261_fetch_vendor_settings(struct
> rtsx_pcr *pcr)
> pcr->sd30_drive_sel_3v3 = rts5261_reg_to_sd30_drive_sel_3v3(reg);
> }
>
> -static void rts5261_force_power_down(struct rtsx_pcr *pcr, u8 pm_state)
> +static void rts5261_force_power_down(struct rtsx_pcr *pcr, u8 pm_state,
> +bool runtime)
> {
> /* Set relink_time to 0 */
> rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, MASK_8_BIT_DEF,
> 0); diff --git a/drivers/misc/cardreader/rtsx_pcr.c
> b/drivers/misc/cardreader/rtsx_pcr.c
> index 3c97d3b50456e..1cb6425e83697 100644
> --- a/drivers/misc/cardreader/rtsx_pcr.c
> +++ b/drivers/misc/cardreader/rtsx_pcr.c
> @@ -1086,7 +1086,7 @@ static void rtsx_pm_power_saving(struct rtsx_pcr
> *pcr)
> rtsx_comm_pm_power_saving(pcr);
> }
>
> -static void rtsx_base_force_power_down(struct rtsx_pcr *pcr, u8 pm_state)
> +static void rtsx_base_force_power_down(struct rtsx_pcr *pcr)
> {
> /* Set relink_time to 0 */
> rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, MASK_8_BIT_DEF,
> 0); @@ -1100,7 +1100,7 @@ static void rtsx_base_force_power_down(struct
> rtsx_pcr *pcr, u8 pm_state)
> 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)
> +static void __maybe_unused rtsx_pci_power_off(struct rtsx_pcr *pcr, u8
> +pm_state, bool runtime)
> {
> if (pcr->ops->turn_off_led)
> pcr->ops->turn_off_led(pcr);
> @@ -1112,9 +1112,9 @@ static void __maybe_unused
> rtsx_pci_power_off(struct rtsx_pcr *pcr, u8 pm_state)
> rtsx_pci_write_register(pcr, HOST_SLEEP_STATE, 0x03, pm_state);
>
> if (pcr->ops->force_power_down)
> - pcr->ops->force_power_down(pcr, pm_state);
> + pcr->ops->force_power_down(pcr, pm_state, runtime);
> else
> - rtsx_base_force_power_down(pcr, pm_state);
> + rtsx_base_force_power_down(pcr);
> }
>
> void rtsx_pci_enable_ocp(struct rtsx_pcr *pcr) @@ -1669,7 +1669,7 @@
> static int __maybe_unused rtsx_pci_suspend(struct device *dev_d)
>
> mutex_lock(&pcr->pcr_mutex);
>
> - rtsx_pci_power_off(pcr, HOST_ENTER_S3);
> + rtsx_pci_power_off(pcr, HOST_ENTER_S3, false);
>
> mutex_unlock(&pcr->pcr_mutex);
> return 0;
> @@ -1708,7 +1708,7 @@ static void rtsx_pci_shutdown(struct pci_dev
> *pcidev)
>
> dev_dbg(&(pcidev->dev), "--> %s\n", __func__);
>
> - rtsx_pci_power_off(pcr, HOST_ENTER_S1);
> + rtsx_pci_power_off(pcr, HOST_ENTER_S1, false);
>
> pci_disable_device(pcidev);
> free_irq(pcr->irq, (void *)pcr);
> @@ -1754,7 +1754,7 @@ static int rtsx_pci_runtime_suspend(struct device
> *device)
> cancel_delayed_work_sync(&pcr->carddet_work);
>
> mutex_lock(&pcr->pcr_mutex);
> - rtsx_pci_power_off(pcr, HOST_ENTER_S3);
> + rtsx_pci_power_off(pcr, HOST_ENTER_S3, true);
>
> mutex_unlock(&pcr->pcr_mutex);
>
> diff --git a/drivers/misc/cardreader/rtsx_pcr.h
> b/drivers/misc/cardreader/rtsx_pcr.h
> index daf057c4eea62..aa0ebd6672277 100644
> --- a/drivers/misc/cardreader/rtsx_pcr.h
> +++ b/drivers/misc/cardreader/rtsx_pcr.h
> @@ -25,6 +25,7 @@
> #define REG_EFUSE_POWEROFF 0x00
> #define RTS5250_CLK_CFG3 0xFF79
> #define RTS525A_CFG_MEM_PD 0xF0
> +#define RTS524A_AUTOLOAD_CFG1 0xFF7C
> #define RTS524A_PM_CTRL3 0xFF7E
> #define RTS525A_BIOS_CFG 0xFF2D
> #define RTS525A_LOAD_BIOS_FLAG 0x01
> diff --git a/include/linux/rtsx_pci.h b/include/linux/rtsx_pci.h index
> 89b7d34e25b63..3d780b44e678a 100644
> --- a/include/linux/rtsx_pci.h
> +++ b/include/linux/rtsx_pci.h
> @@ -1095,7 +1095,7 @@ struct pcr_ops {
> unsigned int (*cd_deglitch)(struct rtsx_pcr *pcr);
> int (*conv_clk_and_div_n)(int clk, int dir);
> void (*fetch_vendor_settings)(struct rtsx_pcr *pcr);
> - void (*force_power_down)(struct rtsx_pcr *pcr, u8 pm_state);
> + void (*force_power_down)(struct rtsx_pcr *pcr, u8 pm_state, bool
> runtime);
> void (*stop_cmd)(struct rtsx_pcr *pcr);
>
> void (*set_aspm)(struct rtsx_pcr *pcr, bool enable);
> --
> 2.33.1
next prev parent reply other threads:[~2022-01-25 6:41 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-20 14:50 [PATCH 1/4] mmc: rtsx: Use pm_runtime_{get,put}() to handle runtime PM Kai-Heng Feng
2022-01-20 14:50 ` [PATCH 2/4] misc: rtsx: Rework runtime power management flow Kai-Heng Feng
2022-01-21 1:40 ` [PATCH v2 " Kai-Heng Feng
2022-01-21 3:57 ` Ricky WU
2022-01-21 4:08 ` Kai-Heng Feng
2022-01-21 4:15 ` Ricky WU
2022-01-21 4:17 ` Kai-Heng Feng
2022-01-21 6:31 ` [PATCH v3 " Kai-Heng Feng
2022-01-21 9:58 ` Ricky WU
2022-01-21 12:39 ` Kai-Heng Feng
2022-01-24 3:26 ` Ricky WU
2022-01-24 4:53 ` Kai-Heng Feng
2022-01-24 5:10 ` Ricky WU
2022-01-24 5:26 ` Kai-Heng Feng
2022-01-24 5:47 ` [PATCH v4 1/4] mmc: rtsx: Use pm_runtime_{get,put}() to handle runtime PM Kai-Heng Feng
2022-01-24 5:47 ` [PATCH v4 2/4] misc: rtsx: Rework runtime power management flow Kai-Heng Feng
2022-01-24 5:47 ` [PATCH v4 3/4] misc: rtsx: Cleanup power management ops Kai-Heng Feng
2022-01-24 5:47 ` [PATCH v4 4/4] misc: rtsx: Quiesce rts5249 on system suspend Kai-Heng Feng
2022-01-24 7:28 ` [PATCH v5 1/4] mmc: rtsx: Use pm_runtime_{get,put}() to handle runtime PM Kai-Heng Feng
2022-01-24 7:28 ` [PATCH v5 2/4] misc: rtsx: Rework runtime power management flow Kai-Heng Feng
2022-01-24 7:28 ` [PATCH v5 3/4] misc: rtsx: Cleanup power management ops Kai-Heng Feng
2022-01-24 7:28 ` [PATCH v5 4/4] misc: rtsx: Quiesce rts5249 on system suspend Kai-Heng Feng
2022-01-25 5:50 ` [PATCH v6 1/4] mmc: rtsx: Use pm_runtime_{get,put}() to handle runtime PM Kai-Heng Feng
2022-01-25 5:50 ` [PATCH v6 2/4] misc: rtsx: Rework runtime power management flow Kai-Heng Feng
2022-01-25 6:38 ` Ricky WU
2022-01-25 5:50 ` [PATCH v6 3/4] misc: rtsx: Cleanup power management ops Kai-Heng Feng
2022-01-25 6:38 ` Ricky WU
2022-01-25 5:50 ` [PATCH v6 4/4] misc: rtsx: Quiesce rts5249 on system suspend Kai-Heng Feng
2022-01-25 6:38 ` Ricky WU [this message]
2022-01-25 6:37 ` [PATCH v6 1/4] mmc: rtsx: Use pm_runtime_{get,put}() to handle runtime PM Ricky WU
2022-02-04 12:28 ` Ulf Hansson
2022-02-16 4:21 ` Kai-Heng Feng
2022-02-16 10:22 ` Ulf Hansson
2022-01-20 14:50 ` [PATCH 3/4] misc: rtsx: Cleanup power management ops Kai-Heng Feng
2022-01-20 14:50 ` [PATCH 4/4] misc: rtsx: Quiesce rts5249 on system suspend Kai-Heng Feng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f43f6994c8834af493e754ee019cbeef@realtek.com \
--to=ricky_wu@realtek.com \
--cc=arnd@arndb.de \
--cc=christophe.jaillet@wanadoo.fr \
--cc=gregkh@linuxfoundation.org \
--cc=kai.heng.feng@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=ulf.hansson@linaro.org \
--cc=yang.lee@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome