mfd: rtsx: fix PM suspend for 5227 & 5249
v2 cover mfd: rtsx: fix PM suspend for 5227 & 5249
From: Micky Ching <[email protected]>
v2:
using (err < 0) to check if a function failed, not using "if (err)" and "if (err < 0)" in mixing way.
This patch fix rts5227 and rts5249 suspend issue, when card reader resumed from suspend state, the power state should reset before send buffer command. The original not reset PM state first, so this will lead resume failed, and can not do anything more.
Micky Ching (2):
mfd: rtsx: fix PM suspend for 5227
mfd: rtsx: fix PM suspend for 5249
drivers/mfd/rts5227.c | 19 +++++++++++++++++++ drivers/mfd/rts5249.c | 17 +++++++++++++++++ include/linux/mfd/rtsx_pci.h | 12 ++++++++++++ 3 files changed, 48 insertions(+)
--
1.7.9.5
PATCH v2 1/2 mfd: rtsx: fix PM suspend for 5227
From: Micky Ching <[email protected]>
Fix rts5227 failed send buffer cmd after suspend, PM_CTRL3 should reset before send any buffer cmd after suspend. Otherwise, buffer cmd will failed, this will lead resume fail.
--- drivers/mfd/rts5227.c | 19 +++++++++++++++++++ include/linux/mfd/rtsx_pci.h | 12 ++++++++++++ 2 files changed, 31 insertions(+)
drivers/mfd/rts5227.c +19 -0
@@ -128,8 +128,27 @@ static int rts5227_extra_init_hw(struct rtsx_pcr *pcr)return rtsx_pci_send_cmd (pcr,100 ); } +static int rts5227_pm_reset (struct rtsx_pcr *pcr) +{ +int err; + +/* init aspm */ + err =rtsx_pci_update_cfg_byte (pcr,LCTLR ,0xFC ,0 ); +if (err <0 ) +return err; + +/* reset PM_CTRL3 before send buffer cmd */ +return rtsx_pci_write_register (pcr,PM_CTRL3 ,0x10 ,0x00 ); +} +static int rts5227_optimize_phy (struct rtsx_pcr *pcr) { +int err; + + err =rts5227_pm_reset (pcr); +if (err <0 ) +return err; +/* Optimize RX sensitivity */ return rtsx_pci_write_phy_register (pcr,0x00 ,0xBA42 ); }
include/linux/mfd/rtsx_pci.h +12 -0
@@ -967,4 +967,16 @@ static inline u8 *rtsx_pci_get_cmd_data(struct rtsx_pcr *pcr) return (u8 *)(pcr->host_cmds_ptr); } +static inline int rtsx_pci_update_cfg_byte (struct rtsx_pcr *pcr,int addr, +u8 mask,u8 append) +{ +int err; +u8 val; + + err =pci_read_config_byte (pcr->pci, addr, &val); +if (err <0 ) +return err; +return pci_write_config_byte (pcr->pci, addr, (val & mask) | append); +} +#endif
Signature · 1 line
1.7.9.5
Re: [PATCH v2 1/2] mfd: rtsx: fix PM suspend for 5227
Quoted 23 lines · On Fri, 12 Sep 2014, [email protected] wrote:
From: Micky Ching <[email protected]>
Fix rts5227 failed send buffer cmd after suspend,
PM_CTRL3should reset before send any buffer cmd after suspend. Otherwise, buffer cmd will failed, this will lead resume fail.Signed-off-by Micky Ching <[email protected]>--- drivers/mfd/rts5227.c | 19 +++++++++++++++++++ include/linux/mfd/rtsx_pci.h | 12 ++++++++++++ 2 files changed, 31 insertions(+)drivers/mfd/rts5227.c +3
-0@@ -128,8 +128,27 @@ static int rts5227_extra_init_hw(struct rtsx_pcr *pcr)return rtsx_pci_send_cmd (pcr,100 ); } +static int rts5227_pm_reset (struct rtsx_pcr *pcr) +{ +int err;
drivers/mfd/rts5227.c static int rts5227_extra_init_hw(struct rtsx_pcr *pcr) · line 143
Quoted 10 lines
drivers/mfd/rts5227.c +10
-0+ +/* init aspm */ + err =rtsx_pci_update_cfg_byte (pcr,LCTLR ,0xFC ,0 ); +if (err <0 ) +return err; + +/* reset PM_CTRL3 before send buffer cmd */ +return rtsx_pci_write_register (pcr,PM_CTRL3 ,0x10 ,0x00 ); +} +
This is exactly the same function as in the other patch. Please place it somewhere it can be referenced by both drivers.
Quoted 32 lines
drivers/mfd/rts5227.c +6
-0static int rts5227_optimize_phy (struct rtsx_pcr *pcr) { +int err; + + err =rts5227_pm_reset (pcr); +if (err <0 ) +return err; +/* Optimize RX sensitivity */ return rtsx_pci_write_phy_register (pcr,0x00 ,0xBA42 ); }include/linux/mfd/rtsx_pci.h +12
-0@@ -967,4 +967,16 @@ static inline u8 *rtsx_pci_get_cmd_data(struct rtsx_pcr *pcr) return (u8 *)(pcr->host_cmds_ptr); } +static inline int rtsx_pci_update_cfg_byte (struct rtsx_pcr *pcr,int addr, +u8 mask,u8 append) +{ +int err; +u8 val; + + err =pci_read_config_byte (pcr->pci, addr, &val); +if (err <0 ) +return err; +return pci_write_config_byte (pcr->pci, addr, (val & mask) | append); +} +#endif
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH v2 2/2 mfd: rtsx: fix PM suspend for 5249
In reply to [email protected]From: Micky Ching <[email protected]>
Fix rts5249 failed send buffer cmd after suspend, PM_CTRL3 should reset before send any buffer cmd after suspend. Otherwise, buffer cmd will failed, this will lead resume fail.
--- drivers/mfd/rts5249.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/mfd/rts5249.c +17 -0
@@ -126,10 +126,27 @@ static int rts5249_extra_init_hw(struct rtsx_pcr *pcr)return rtsx_pci_send_cmd (pcr,100 ); } +static int rts5249_pm_reset (struct rtsx_pcr *pcr) +{ +int err; + +/* init aspm */ + err =rtsx_pci_update_cfg_byte (pcr,LCTLR ,0xFC ,0 ); +if (err <0 ) +return err; + +/* reset PM_CTRL3 before send buffer cmd */ +return rtsx_pci_write_register (pcr,PM_CTRL3 ,0x10 ,0x00 ); +} +static int rts5249_optimize_phy (struct rtsx_pcr *pcr) {int err; + err =rts5249_pm_reset (pcr); +if (err <0 ) +return err; + err = rtsx_pci_write_phy_register(pcr, PHY_REG_REV, PHY_REG_REV_RESV | PHY_REG_REV_RXIDLE_LATCHED | PHY_REG_REV_P1_EN | PHY_REG_REV_RXIDLE_EN |
Signature · 1 line
1.7.9.5