misc: rtsx: rts5249 support runtime PM
Subsystems (2)
PATCH v2 4/4 misc: rtsx: rts5249 support runtime PM
From: Ricky Wu <[email protected]>
rtsx_pcr:
add callback functions to support runtime PM
add delay_work to put device to D3 after idle
over 10 sec
rts5249:
add extra init flow for rtd3 and set rtd3_en from
config setting
rtsx_pci_sdmmc:
child device support autosuspend
Signed-off-by Ricky Wu <[email protected]>
--- drivers/misc/cardreader/rts5249.c | 26 +++++-- drivers/misc/cardreader/rtsx_pcr.c | 106 ++++++++++++++++++++++++++++- drivers/misc/cardreader/rtsx_pcr.h | 1 + drivers/mmc/host/rtsx_pci_sdmmc.c | 16 +++++ include/linux/rtsx_pci.h | 2 + 5 files changed, 145 insertions(+), 6 deletions(-)
drivers/misc/cardreader/rts5249.c +21 -5
@@ -73,6 +73,9 @@ 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 (rtsx_check_mmc_support (reg)) pcr->extra_caps |=EXTRA_CAPS_NO_MMC ; pcr->sd30_drive_sel_3v3 =rtsx_reg_to_sd30_drive_sel_3v3 (reg);
@@ -278,15 +281,28 @@ 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_PM_CTRL3 ,0x01 ,0x00 ); -rtsx_pci_write_register (pcr,RTS524A_PME_FORCE_CTL ,0x30 ,0x20 ); + +if (pcr->rtd3_en) { +if (CHK_PCI_PID (pcr,PID_524A ) ||CHK_PCI_PID (pcr,PID_525A )) { +rtsx_pci_write_register (pcr,RTS524A_PM_CTRL3 ,0x01 ,0x01 ); +rtsx_pci_write_register (pcr,RTS524A_PME_FORCE_CTL ,0x30 ,0x30 ); + }else { +rtsx_pci_write_register (pcr,PM_CTRL3 ,0x01 ,0x01 ); +rtsx_pci_write_register (pcr,PME_FORCE_CTL ,0xFF ,0x33 ); + } }else { -rtsx_pci_write_register (pcr,PME_FORCE_CTL ,0xFF ,0x30 ); -rtsx_pci_write_register (pcr,PM_CTRL3 ,0x01 ,0x00 ); +if (CHK_PCI_PID (pcr,PID_524A ) ||CHK_PCI_PID (pcr,PID_525A )) { +rtsx_pci_write_register (pcr,RTS524A_PM_CTRL3 ,0x01 ,0x00 ); +rtsx_pci_write_register (pcr,RTS524A_PME_FORCE_CTL ,0x30 ,0x20 ); + }else { +rtsx_pci_write_register (pcr,PME_FORCE_CTL ,0xFF ,0x30 ); +rtsx_pci_write_register (pcr,PM_CTRL3 ,0x01 ,0x00 ); + } } +/* * If u_force_clkreq_0 is enabled, CLKREQ# PIN will be forced * to drive low, and we forcibly request clock.
drivers/misc/cardreader/rtsx_pcr.c +105 -1
166 lines not on this page · raw message
drivers/misc/cardreader/rtsx_pcr.h +1 -0
@@ -90,6 +90,7 @@ static inline u8 map_sd_drive(int idx)#define rtsx_check_mmc_support (reg) ((reg) & 0x10)#define rtsx_reg_to_rtd3 (reg) ((reg) & 0x02) +#define rtsx_reg_to_rtd3_uhsii (reg) ((reg) & 0x04)#define rtsx_reg_to_aspm (reg) (((reg) >> 28) & 0x03)#define rtsx_reg_to_sd30_drive_sel_1v8 (reg) (((reg) >> 26) & 0x03)#define rtsx_reg_to_sd30_drive_sel_3v3 (reg) (((reg) >> 5) & 0x03)
drivers/mmc/host/rtsx_pci_sdmmc.c +16 -0
@@ -20,6 +20,7 @@#include <linux/mmc/card.h> #include <linux/rtsx_pci.h> #include <asm/unaligned.h> +#include <linux/pm_runtime.h> struct realtek_pci_sdmmc {struct platform_device *pdev;
@@ -1343,6 +1344,7 @@ static void init_extra_caps(struct realtek_pci_sdmmc *host)static void realtek_init_host (struct realtek_pci_sdmmc *host) {struct mmc_host *mmc = host->mmc; +struct rtsx_pcr *pcr = host->pcr; mmc->f_min =250000 ; mmc->f_max =208000000 ;
@@ -1350,6 +1352,8 @@ static void realtek_init_host(struct realtek_pci_sdmmc *host) mmc->caps =MMC_CAP_4_BIT_DATA |MMC_CAP_SD_HIGHSPEED |MMC_CAP_MMC_HIGHSPEED |MMC_CAP_BUS_WIDTH_TEST |MMC_CAP_UHS_SDR12 |MMC_CAP_UHS_SDR25 ; +if (pcr->rtd3_en) + mmc->caps = mmc->caps |MMC_CAP_AGGRESSIVE_PM ; mmc->caps2 =MMC_CAP2_NO_PRESCAN_POWERUP |MMC_CAP2_FULL_PWR_CYCLE ; mmc->max_current_330 =400 ; mmc->max_current_180 =800 ;
@@ -1407,6 +1411,13 @@ static int rtsx_pci_sdmmc_drv_probe(struct platform_device *pdev)realtek_init_host (host); +if (pcr->rtd3_en) { +pm_runtime_set_autosuspend_delay (&pdev->dev,5000 ); +pm_runtime_use_autosuspend (&pdev->dev); +pm_runtime_enable (&pdev->dev); + } + +mmc_add_host (mmc);return 0 ;
@@ -1426,6 +1437,11 @@ static int rtsx_pci_sdmmc_drv_remove(struct platform_device *pdev) pcr->slots[RTSX_SD_CARD ].card_event =NULL ; mmc = host->mmc; +if (pcr->rtd3_en) { +pm_runtime_dont_use_autosuspend (&pdev->dev); +pm_runtime_disable (&pdev->dev); + } +cancel_work_sync (&host->work);mutex_lock (&host->host_mutex);
include/linux/rtsx_pci.h +2 -0
@@ -1174,6 +1174,7 @@ struct rtsx_pcr {struct delayed_work carddet_work;struct delayed_work idle_work; +struct delayed_work rtd3_work;spinlock_t lock;struct mutex pcr_mutex;
@@ -1183,6 +1184,7 @@ struct rtsx_pcr {unsigned int cur_clock;bool remove_pci;bool msi_en; +bool is_runtime_suspended;#define EXTRA_CAPS_SD_SDR50 (1 << 0)#define EXTRA_CAPS_SD_SDR104 (1 << 1)
Signature · 1 line
2.17.1