* [PATCH v2 0/2] mfd: rtsx: fix PM suspend for 5227 & 5249 @ 2014-09-12 1:30 micky_ching 2014-09-12 1:30 ` [PATCH v2 1/2] mfd: rtsx: fix PM suspend for 5227 micky_ching 2014-09-12 1:30 ` [PATCH v2 2/2] mfd: rtsx: fix PM suspend for 5249 micky_ching 0 siblings, 2 replies; 4+ messages in thread From: micky_ching @ 2014-09-12 1:30 UTC (permalink / raw) To: sameo, lee.jones Cc: devel, linux-kernel, gregkh, rogerable, wei_wang, Micky Ching From: Micky Ching <micky_ching@realsil.com.cn> 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/2] mfd: rtsx: fix PM suspend for 5227 2014-09-12 1:30 [PATCH v2 0/2] mfd: rtsx: fix PM suspend for 5227 & 5249 micky_ching @ 2014-09-12 1:30 ` micky_ching 2014-09-17 16:39 ` Lee Jones 2014-09-12 1:30 ` [PATCH v2 2/2] mfd: rtsx: fix PM suspend for 5249 micky_ching 1 sibling, 1 reply; 4+ messages in thread From: micky_ching @ 2014-09-12 1:30 UTC (permalink / raw) To: sameo, lee.jones Cc: devel, linux-kernel, gregkh, rogerable, wei_wang, Micky Ching From: Micky Ching <micky_ching@realsil.com.cn> 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. Signed-off-by: Micky Ching <micky_ching@realsil.com.cn> --- drivers/mfd/rts5227.c | 19 +++++++++++++++++++ include/linux/mfd/rtsx_pci.h | 12 ++++++++++++ 2 files changed, 31 insertions(+) diff --git a/drivers/mfd/rts5227.c b/drivers/mfd/rts5227.c index 9c8eec8..197f5c1 100644 --- a/drivers/mfd/rts5227.c +++ b/drivers/mfd/rts5227.c @@ -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); } diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h index 74346d5..b34fec8 100644 --- a/include/linux/mfd/rtsx_pci.h +++ b/include/linux/mfd/rtsx_pci.h @@ -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 -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/2] mfd: rtsx: fix PM suspend for 5227 2014-09-12 1:30 ` [PATCH v2 1/2] mfd: rtsx: fix PM suspend for 5227 micky_ching @ 2014-09-17 16:39 ` Lee Jones 0 siblings, 0 replies; 4+ messages in thread From: Lee Jones @ 2014-09-17 16:39 UTC (permalink / raw) To: micky_ching; +Cc: sameo, devel, linux-kernel, gregkh, rogerable, wei_wang On Fri, 12 Sep 2014, micky_ching@realsil.com.cn wrote: > From: Micky Ching <micky_ching@realsil.com.cn> > > 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. > > Signed-off-by: Micky Ching <micky_ching@realsil.com.cn> > --- > drivers/mfd/rts5227.c | 19 +++++++++++++++++++ > include/linux/mfd/rtsx_pci.h | 12 ++++++++++++ > 2 files changed, 31 insertions(+) > > diff --git a/drivers/mfd/rts5227.c b/drivers/mfd/rts5227.c > index 9c8eec8..197f5c1 100644 > --- a/drivers/mfd/rts5227.c > +++ b/drivers/mfd/rts5227.c > @@ -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); > +} > + This is exactly the same function as in the other patch. Please place it somewhere it can be referenced by both drivers. > 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); > } > diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h > index 74346d5..b34fec8 100644 > --- a/include/linux/mfd/rtsx_pci.h > +++ b/include/linux/mfd/rtsx_pci.h > @@ -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 -- Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] mfd: rtsx: fix PM suspend for 5249 2014-09-12 1:30 [PATCH v2 0/2] mfd: rtsx: fix PM suspend for 5227 & 5249 micky_ching 2014-09-12 1:30 ` [PATCH v2 1/2] mfd: rtsx: fix PM suspend for 5227 micky_ching @ 2014-09-12 1:30 ` micky_ching 1 sibling, 0 replies; 4+ messages in thread From: micky_ching @ 2014-09-12 1:30 UTC (permalink / raw) To: sameo, lee.jones Cc: devel, linux-kernel, gregkh, rogerable, wei_wang, Micky Ching From: Micky Ching <micky_ching@realsil.com.cn> 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. Signed-off-by: Micky Ching <micky_ching@realsil.com.cn> --- drivers/mfd/rts5249.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c index 573de7b..5dd7dc0 100644 --- a/drivers/mfd/rts5249.c +++ b/drivers/mfd/rts5249.c @@ -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 | -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-09-17 16:39 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-09-12 1:30 [PATCH v2 0/2] mfd: rtsx: fix PM suspend for 5227 & 5249 micky_ching 2014-09-12 1:30 ` [PATCH v2 1/2] mfd: rtsx: fix PM suspend for 5227 micky_ching 2014-09-17 16:39 ` Lee Jones 2014-09-12 1:30 ` [PATCH v2 2/2] mfd: rtsx: fix PM suspend for 5249 micky_ching
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.