All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] mfd: rtsx: fix PM suspend for 5227 & 5249
@ 2014-09-11  7:17 micky_ching
  2014-09-11  7:17 ` [PATCH 1/2] mfd: rtsx: fix PM suspend for 5227 micky_ching
  2014-09-11  7:17 ` [PATCH 2/2] mfd: rtsx: fix PM suspend for 5249 micky_ching
  0 siblings, 2 replies; 6+ messages in thread
From: micky_ching @ 2014-09-11  7:17 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>

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        |   23 +++++++++++++++++++++++
 drivers/mfd/rts5249.c        |   21 +++++++++++++++++++++
 include/linux/mfd/rtsx_pci.h |   13 +++++++++++++
 3 files changed, 57 insertions(+)

--
1.7.9.5

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] mfd: rtsx: fix PM suspend for 5227
  2014-09-11  7:17 [PATCH 0/2] mfd: rtsx: fix PM suspend for 5227 & 5249 micky_ching
@ 2014-09-11  7:17 ` micky_ching
  2014-09-11  7:42   ` Dan Carpenter
  2014-09-11  7:17 ` [PATCH 2/2] mfd: rtsx: fix PM suspend for 5249 micky_ching
  1 sibling, 1 reply; 6+ messages in thread
From: micky_ching @ 2014-09-11  7:17 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        |   23 +++++++++++++++++++++++
 include/linux/mfd/rtsx_pci.h |   13 +++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/drivers/mfd/rts5227.c b/drivers/mfd/rts5227.c
index 9c8eec8..3d4998e 100644
--- a/drivers/mfd/rts5227.c
+++ b/drivers/mfd/rts5227.c
@@ -128,8 +128,31 @@ 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 */
+	err = rtsx_pci_write_register(pcr, PM_CTRL3, 0x10, 0x00);
+	if (err < 0)
+		return err;
+
+	return err;
+}
+
 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..037fbc5 100644
--- a/include/linux/mfd/rtsx_pci.h
+++ b/include/linux/mfd/rtsx_pci.h
@@ -967,4 +967,17 @@ 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)
+		return err;
+	err = pci_write_config_byte(pcr->pci, addr, (val & mask) | append);
+	return err;
+}
+
 #endif
--
1.7.9.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] mfd: rtsx: fix PM suspend for 5249
  2014-09-11  7:17 [PATCH 0/2] mfd: rtsx: fix PM suspend for 5227 & 5249 micky_ching
  2014-09-11  7:17 ` [PATCH 1/2] mfd: rtsx: fix PM suspend for 5227 micky_ching
@ 2014-09-11  7:17 ` micky_ching
  1 sibling, 0 replies; 6+ messages in thread
From: micky_ching @ 2014-09-11  7:17 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 |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c
index 573de7b..d6cc546 100644
--- a/drivers/mfd/rts5249.c
+++ b/drivers/mfd/rts5249.c
@@ -126,10 +126,31 @@ 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 */
+	err = rtsx_pci_write_register(pcr, PM_CTRL3, 0x10, 0x00);
+	if (err < 0)
+		return err;
+
+	return err;
+}
+
 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] 6+ messages in thread

* Re: [PATCH 1/2] mfd: rtsx: fix PM suspend for 5227
  2014-09-11  7:17 ` [PATCH 1/2] mfd: rtsx: fix PM suspend for 5227 micky_ching
@ 2014-09-11  7:42   ` Dan Carpenter
  2014-09-12  8:36     ` Dan Carpenter
  0 siblings, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2014-09-11  7:42 UTC (permalink / raw)
  To: micky_ching
  Cc: sameo, lee.jones, gregkh, linux-kernel, wei_wang, rogerable, devel

On Thu, Sep 11, 2014 at 03:17:52PM +0800, micky_ching@realsil.com.cn wrote:
> +	/* reset PM_CTRL3 before send buffer cmd */
> +	err = rtsx_pci_write_register(pcr, PM_CTRL3, 0x10, 0x00);
> +	if (err < 0)
> +		return err;
> +
> +	return err;

Just do:
	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..037fbc5 100644
> --- a/include/linux/mfd/rtsx_pci.h
> +++ b/include/linux/mfd/rtsx_pci.h
> @@ -967,4 +967,17 @@ 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)
> +		return err;

Some of these check for "if (err) " and some check for "if (err < 0) ".
What is the significance of that?  I'm a newbie here.  Did you mean for
them to be different?


> +	err = pci_write_config_byte(pcr->pci, addr, (val & mask) | append);
> +	return err;

	return pci_write_config_byte(pcr->pci, addr, (val & mask) | append);

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] mfd: rtsx: fix PM suspend for 5227
  2014-09-11  7:42   ` Dan Carpenter
@ 2014-09-12  8:36     ` Dan Carpenter
  2014-09-12  8:43       ` micky
  0 siblings, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2014-09-12  8:36 UTC (permalink / raw)
  To: micky_ching
  Cc: sameo, gregkh, linux-kernel, wei_wang, devel, rogerable, lee.jones

On Thu, Sep 11, 2014 at 10:42:49AM +0300, Dan Carpenter wrote:
> On Thu, Sep 11, 2014 at 03:17:52PM +0800, micky_ching@realsil.com.cn wrote:
> > +	err = pci_read_config_byte(pcr->pci, addr, &val);
> > +	if (err)
> > +		return err;
> 
> Some of these check for "if (err) " and some check for "if (err < 0) ".
> What is the significance of that?  I'm a newbie here.  Did you mean for
> them to be different?

You've updated them all to be "if (err < 0)" how is that different from
"if (err)"?  What I'm saying is that could you reply to the question?

I guess I normally prefer "if (err)" over "if (err < 0)" but I don't
know if it makes a difference here?

regards,
dan carpenter
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] mfd: rtsx: fix PM suspend for 5227
  2014-09-12  8:36     ` Dan Carpenter
@ 2014-09-12  8:43       ` micky
  0 siblings, 0 replies; 6+ messages in thread
From: micky @ 2014-09-12  8:43 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: sameo, gregkh, linux-kernel, wei_wang, devel, rogerable, lee.jones

On 09/12/2014 04:36 PM, Dan Carpenter wrote:
> You've updated them all to be "if (err < 0)" how is that different from
> "if (err)"?  What I'm saying is that could you reply to the question?
>
> I guess I normally prefer "if (err)" over "if (err < 0)" but I don't
> know if it makes a difference here?
Hi Dan,

these function never return positive value, but other part of the driver 
code
use (err < 0), I use (err < 0) here for consistency.

(err) and (err < 0) is same at least for these function called here.

Best Regards.
micky.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-09-12 10:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-11  7:17 [PATCH 0/2] mfd: rtsx: fix PM suspend for 5227 & 5249 micky_ching
2014-09-11  7:17 ` [PATCH 1/2] mfd: rtsx: fix PM suspend for 5227 micky_ching
2014-09-11  7:42   ` Dan Carpenter
2014-09-12  8:36     ` Dan Carpenter
2014-09-12  8:43       ` micky
2014-09-11  7:17 ` [PATCH 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.