* [PATCH] mfd: rtsx: fix PM suspend for 5227 & 5249
@ 2014-09-18 6:55 micky_ching
2014-10-06 21:05 ` Lee Jones
0 siblings, 1 reply; 7+ messages in thread
From: micky_ching @ 2014-09-18 6:55 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&5249 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/Makefile | 2 +-
drivers/mfd/rts5227.c | 6 ++++++
drivers/mfd/rts5249.c | 4 ++++
drivers/mfd/rtsx_gops.c | 36 ++++++++++++++++++++++++++++++++++++
drivers/mfd/rtsx_pcr.h | 3 +++
include/linux/mfd/rtsx_pci.h | 12 ++++++++++++
6 files changed, 62 insertions(+), 1 deletion(-)
create mode 100644 drivers/mfd/rtsx_gops.c
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index f001487..7f45c06 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -13,7 +13,7 @@ obj-$(CONFIG_MFD_CROS_EC) += cros_ec.o
obj-$(CONFIG_MFD_CROS_EC_I2C) += cros_ec_i2c.o
obj-$(CONFIG_MFD_CROS_EC_SPI) += cros_ec_spi.o
-rtsx_pci-objs := rtsx_pcr.o rts5209.o rts5229.o rtl8411.o rts5227.o rts5249.o
+rtsx_pci-objs := rtsx_pcr.o rtsx_gops.o rts5209.o rts5229.o rtl8411.o rts5227.o rts5249.o
obj-$(CONFIG_MFD_RTSX_PCI) += rtsx_pci.o
obj-$(CONFIG_MFD_RTSX_USB) += rtsx_usb.o
diff --git a/drivers/mfd/rts5227.c b/drivers/mfd/rts5227.c
index 9c8eec8..3240740 100644
--- a/drivers/mfd/rts5227.c
+++ b/drivers/mfd/rts5227.c
@@ -130,6 +130,12 @@ static int rts5227_extra_init_hw(struct rtsx_pcr *pcr)
static int rts5227_optimize_phy(struct rtsx_pcr *pcr)
{
+ int err;
+
+ err = rtsx_gops_pm_reset(pcr);
+ if (err < 0)
+ return err;
+
/* Optimize RX sensitivity */
return rtsx_pci_write_phy_register(pcr, 0x00, 0xBA42);
}
diff --git a/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c
index 573de7b..cf425cc 100644
--- a/drivers/mfd/rts5249.c
+++ b/drivers/mfd/rts5249.c
@@ -130,6 +130,10 @@ static int rts5249_optimize_phy(struct rtsx_pcr *pcr)
{
int err;
+ err = rtsx_gops_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 |
diff --git a/drivers/mfd/rtsx_gops.c b/drivers/mfd/rtsx_gops.c
new file mode 100644
index 0000000..3cf596f
--- /dev/null
+++ b/drivers/mfd/rtsx_gops.c
@@ -0,0 +1,36 @@
+/* Driver for Realtek PCI-Express card reader
+ *
+ * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author:
+ * Micky Ching <micky_ching@realsil.com.cn>
+ */
+
+#include <linux/mfd/rtsx_pci.h>
+#include "rtsx_pcr.h"
+
+int rtsx_gops_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);
+}
diff --git a/drivers/mfd/rtsx_pcr.h b/drivers/mfd/rtsx_pcr.h
index 07e4c2e..fe2bbb6 100644
--- a/drivers/mfd/rtsx_pcr.h
+++ b/drivers/mfd/rtsx_pcr.h
@@ -72,4 +72,7 @@ do { \
pcr->ms_pull_ctl_disable_tbl = __device##_ms_pull_ctl_disable_tbl; \
} while (0)
+/* generic operations */
+int rtsx_gops_pm_reset(struct rtsx_pcr *pcr);
+
#endif
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] 7+ messages in thread
* Re: [PATCH] mfd: rtsx: fix PM suspend for 5227 & 5249
2014-09-18 6:55 [PATCH] mfd: rtsx: fix PM suspend for 5227 & 5249 micky_ching
@ 2014-10-06 21:05 ` Lee Jones
0 siblings, 0 replies; 7+ messages in thread
From: Lee Jones @ 2014-10-06 21:05 UTC (permalink / raw)
To: micky_ching; +Cc: sameo, devel, linux-kernel, gregkh, rogerable, wei_wang
On Thu, 18 Sep 2014, micky_ching@realsil.com.cn wrote:
> From: Micky Ching <micky_ching@realsil.com.cn>
>
> Fix rts5227&5249 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/Makefile | 2 +-
> drivers/mfd/rts5227.c | 6 ++++++
> drivers/mfd/rts5249.c | 4 ++++
> drivers/mfd/rtsx_gops.c | 36 ++++++++++++++++++++++++++++++++++++
> drivers/mfd/rtsx_pcr.h | 3 +++
> include/linux/mfd/rtsx_pci.h | 12 ++++++++++++
> 6 files changed, 62 insertions(+), 1 deletion(-)
> create mode 100644 drivers/mfd/rtsx_gops.c
[...]
> diff --git a/drivers/mfd/rtsx_gops.c b/drivers/mfd/rtsx_gops.c
> new file mode 100644
> index 0000000..3cf596f
> --- /dev/null
> +++ b/drivers/mfd/rtsx_gops.c
> @@ -0,0 +1,36 @@
> +/* Driver for Realtek PCI-Express card reader
> + *
> + * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License as published by the
> + * Free Software Foundation; either version 2, or (at your option) any
> + * later version.
> + *
> + * This program is distributed in the hope that it will be useful, but
> + * WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with this program; if not, see <http://www.gnu.org/licenses/>.
> + *
> + * Author:
> + * Micky Ching <micky_ching@realsil.com.cn>
> + */
> +
> +#include <linux/mfd/rtsx_pci.h>
> +#include "rtsx_pcr.h"
> +
> +int rtsx_gops_pm_reset(struct rtsx_pcr *pcr)
> +{
> + int err;
> +
> + /* init aspm */
> + err = rtsx_pci_update_cfg_byte(pcr, LCTLR, 0xFC, 0);
I'm not keen on the magic numbers here. Can you #define them?
> + if (err < 0)
> + return err;
> +
> + /* reset PM_CTRL3 before send buffer cmd */
> + return rtsx_pci_write_register(pcr, PM_CTRL3, 0x10, 0x00);
Same.
> +}
> diff --git a/drivers/mfd/rtsx_pcr.h b/drivers/mfd/rtsx_pcr.h
> index 07e4c2e..fe2bbb6 100644
> --- a/drivers/mfd/rtsx_pcr.h
> +++ b/drivers/mfd/rtsx_pcr.h
> @@ -72,4 +72,7 @@ do { \
> pcr->ms_pull_ctl_disable_tbl = __device##_ms_pull_ctl_disable_tbl; \
> } while (0)
>
> +/* generic operations */
> +int rtsx_gops_pm_reset(struct rtsx_pcr *pcr);
> +
> #endif
> 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] 7+ messages in thread
* Re: [PATCH] mfd: rtsx: fix PM suspend for 5227 & 5249
2014-09-19 0:21 ` Lee Jones
@ 2014-09-19 1:24 ` micky
0 siblings, 0 replies; 7+ messages in thread
From: micky @ 2014-09-19 1:24 UTC (permalink / raw)
To: Lee Jones; +Cc: sameo, devel, linux-kernel, gregkh, rogerable, wei_wang
On 09/19/2014 08:21 AM, Lee Jones wrote:
> On Thu, 18 Sep 2014, micky wrote:
>
>> On 09/18/2014 12:53 PM, Lee Jones wrote:
>>> On Thu, 18 Sep 2014, micky_ching@realsil.com.cn wrote:
>>>
>>>> From: Micky Ching <micky_ching@realsil.com.cn>
>>>>
>>>> Fix rts5227&5249 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 +++++++++++++++++++
>>>> drivers/mfd/rts5249.c | 4 ++++
>>>> drivers/mfd/rtsx_pcr.h | 1 +
>>>> include/linux/mfd/rtsx_pci.h | 12 ++++++++++++
>>>> 4 files changed, 36 insertions(+)
>>> I think you'll find you just broke the build.
>>>
>>> What happens when you compile these as modules?
>> I build as modules with no warning or error, did you find anything wrong?
> Yes, you don't export the functions.
>
> EXPORT_SYMBOL()
No need export symbol, all rts52xx.c and rtsx_pcr.c will build into a
single rtsx_pci.ko file.
and we do not want these functions to be called in other place.
Because they are not a good interface, and may be changed in the future.
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mfd: rtsx: fix PM suspend for 5227 & 5249
2014-09-18 5:49 ` micky
@ 2014-09-19 0:21 ` Lee Jones
2014-09-19 1:24 ` micky
0 siblings, 1 reply; 7+ messages in thread
From: Lee Jones @ 2014-09-19 0:21 UTC (permalink / raw)
To: micky; +Cc: sameo, devel, linux-kernel, gregkh, rogerable, wei_wang
On Thu, 18 Sep 2014, micky wrote:
> On 09/18/2014 12:53 PM, Lee Jones wrote:
> >On Thu, 18 Sep 2014, micky_ching@realsil.com.cn wrote:
> >
> >>From: Micky Ching <micky_ching@realsil.com.cn>
> >>
> >>Fix rts5227&5249 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 +++++++++++++++++++
> >> drivers/mfd/rts5249.c | 4 ++++
> >> drivers/mfd/rtsx_pcr.h | 1 +
> >> include/linux/mfd/rtsx_pci.h | 12 ++++++++++++
> >> 4 files changed, 36 insertions(+)
> >I think you'll find you just broke the build.
> >
> >What happens when you compile these as modules?
> I build as modules with no warning or error, did you find anything wrong?
Yes, you don't export the functions.
EXPORT_SYMBOL()
--
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] 7+ messages in thread
* Re: [PATCH] mfd: rtsx: fix PM suspend for 5227 & 5249
2014-09-18 4:53 ` Lee Jones
@ 2014-09-18 5:49 ` micky
2014-09-19 0:21 ` Lee Jones
0 siblings, 1 reply; 7+ messages in thread
From: micky @ 2014-09-18 5:49 UTC (permalink / raw)
To: Lee Jones; +Cc: sameo, devel, linux-kernel, gregkh, rogerable, wei_wang
On 09/18/2014 12:53 PM, Lee Jones wrote:
> On Thu, 18 Sep 2014, micky_ching@realsil.com.cn wrote:
>
>> From: Micky Ching <micky_ching@realsil.com.cn>
>>
>> Fix rts5227&5249 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 +++++++++++++++++++
>> drivers/mfd/rts5249.c | 4 ++++
>> drivers/mfd/rtsx_pcr.h | 1 +
>> include/linux/mfd/rtsx_pci.h | 12 ++++++++++++
>> 4 files changed, 36 insertions(+)
> I think you'll find you just broke the build.
>
> What happens when you compile these as modules?
I build as modules with no warning or error, did you find anything wrong?
>> diff --git a/drivers/mfd/rts5227.c b/drivers/mfd/rts5227.c
>> index 9c8eec8..8222a31 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);
>> }
>>
>> +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/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c
>> index 573de7b..0f1b0e6 100644
>> --- a/drivers/mfd/rts5249.c
>> +++ b/drivers/mfd/rts5249.c
>> @@ -130,6 +130,10 @@ static int rts5249_optimize_phy(struct rtsx_pcr *pcr)
>> {
>> int err;
>>
>> + err = rts5227_pm_reset(pcr);
>> + if (err < 0)
>> + return err;
> I don't like this. Place rts52xx_pm_reset() somewhere more central.
> Perhaps an inline function in the header would be better?
Thanks, I will fix later.
>> 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 |
>> diff --git a/drivers/mfd/rtsx_pcr.h b/drivers/mfd/rtsx_pcr.h
>> index 07e4c2e..acc7a1e 100644
>> --- a/drivers/mfd/rtsx_pcr.h
>> +++ b/drivers/mfd/rtsx_pcr.h
>> @@ -72,4 +72,5 @@ do { \
>> pcr->ms_pull_ctl_disable_tbl = __device##_ms_pull_ctl_disable_tbl; \
>> } while (0)
>>
>> +int rts5227_pm_reset(struct rtsx_pcr *pcr);
>> #endif
>> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mfd: rtsx: fix PM suspend for 5227 & 5249
2014-09-18 1:35 micky_ching
@ 2014-09-18 4:53 ` Lee Jones
2014-09-18 5:49 ` micky
0 siblings, 1 reply; 7+ messages in thread
From: Lee Jones @ 2014-09-18 4:53 UTC (permalink / raw)
To: micky_ching; +Cc: sameo, devel, linux-kernel, gregkh, rogerable, wei_wang
On Thu, 18 Sep 2014, micky_ching@realsil.com.cn wrote:
> From: Micky Ching <micky_ching@realsil.com.cn>
>
> Fix rts5227&5249 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 +++++++++++++++++++
> drivers/mfd/rts5249.c | 4 ++++
> drivers/mfd/rtsx_pcr.h | 1 +
> include/linux/mfd/rtsx_pci.h | 12 ++++++++++++
> 4 files changed, 36 insertions(+)
I think you'll find you just broke the build.
What happens when you compile these as modules?
> diff --git a/drivers/mfd/rts5227.c b/drivers/mfd/rts5227.c
> index 9c8eec8..8222a31 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);
> }
>
> +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/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c
> index 573de7b..0f1b0e6 100644
> --- a/drivers/mfd/rts5249.c
> +++ b/drivers/mfd/rts5249.c
> @@ -130,6 +130,10 @@ static int rts5249_optimize_phy(struct rtsx_pcr *pcr)
> {
> int err;
>
> + err = rts5227_pm_reset(pcr);
> + if (err < 0)
> + return err;
I don't like this. Place rts52xx_pm_reset() somewhere more central.
Perhaps an inline function in the header would be better?
> 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 |
> diff --git a/drivers/mfd/rtsx_pcr.h b/drivers/mfd/rtsx_pcr.h
> index 07e4c2e..acc7a1e 100644
> --- a/drivers/mfd/rtsx_pcr.h
> +++ b/drivers/mfd/rtsx_pcr.h
> @@ -72,4 +72,5 @@ do { \
> pcr->ms_pull_ctl_disable_tbl = __device##_ms_pull_ctl_disable_tbl; \
> } while (0)
>
> +int rts5227_pm_reset(struct rtsx_pcr *pcr);
> #endif
> 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] 7+ messages in thread
* [PATCH] mfd: rtsx: fix PM suspend for 5227 & 5249
@ 2014-09-18 1:35 micky_ching
2014-09-18 4:53 ` Lee Jones
0 siblings, 1 reply; 7+ messages in thread
From: micky_ching @ 2014-09-18 1:35 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&5249 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 +++++++++++++++++++
drivers/mfd/rts5249.c | 4 ++++
drivers/mfd/rtsx_pcr.h | 1 +
include/linux/mfd/rtsx_pci.h | 12 ++++++++++++
4 files changed, 36 insertions(+)
diff --git a/drivers/mfd/rts5227.c b/drivers/mfd/rts5227.c
index 9c8eec8..8222a31 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);
}
+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/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c
index 573de7b..0f1b0e6 100644
--- a/drivers/mfd/rts5249.c
+++ b/drivers/mfd/rts5249.c
@@ -130,6 +130,10 @@ static int rts5249_optimize_phy(struct rtsx_pcr *pcr)
{
int err;
+ err = rts5227_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 |
diff --git a/drivers/mfd/rtsx_pcr.h b/drivers/mfd/rtsx_pcr.h
index 07e4c2e..acc7a1e 100644
--- a/drivers/mfd/rtsx_pcr.h
+++ b/drivers/mfd/rtsx_pcr.h
@@ -72,4 +72,5 @@ do { \
pcr->ms_pull_ctl_disable_tbl = __device##_ms_pull_ctl_disable_tbl; \
} while (0)
+int rts5227_pm_reset(struct rtsx_pcr *pcr);
#endif
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] 7+ messages in thread
end of thread, other threads:[~2014-10-06 21:05 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-18 6:55 [PATCH] mfd: rtsx: fix PM suspend for 5227 & 5249 micky_ching
2014-10-06 21:05 ` Lee Jones
-- strict thread matches above, loose matches on Subject: below --
2014-09-18 1:35 micky_ching
2014-09-18 4:53 ` Lee Jones
2014-09-18 5:49 ` micky
2014-09-19 0:21 ` Lee Jones
2014-09-19 1:24 ` micky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).