mfd: rtsx: fix PM suspend for 5227 & 5249
PATCH 1/1 mfd: rtsx: fix PM suspend for 5227 & 5249
From: Micky Ching <[email protected]>
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 <[email protected]>
--- 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
drivers/mfd/Makefile +1 -1
@@ -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
drivers/mfd/rts5227.c +6 -0
@@ -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 ); }
drivers/mfd/rts5249.c +4 -0
@@ -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 |
drivers/mfd/rtsx_gops.c new file +36 -0
@@ -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 <[email protected]> +*/ + +#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 ); +}
drivers/mfd/rtsx_pcr.h +3 -0
@@ -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
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
Quoted 16 lines · On Thu, 18 Sep 2014, [email protected] wrote:
From: Micky Ching <[email protected]>
Fix rts5227&5249 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/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
[...]
Quoted 26 lines
drivers/mfd/rtsx_gops.c new file +20
-0@@ -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 <[email protected]> +*/
drivers/mfd/rtsx_gops.c line 30
Quoted 10 lines
drivers/mfd/rtsx_gops.c new file +10
-0+ +#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?
drivers/mfd/rtsx_gops.c line 35
Quoted 5 lines
drivers/mfd/rtsx_gops.c new file +5
-0+if (err <0 ) +return err; + +/* reset PM_CTRL3 before send buffer cmd */ +return rtsx_pci_write_register (pcr,PM_CTRL3 ,0x10 ,0x00 );
Same.
Quoted 34 lines
drivers/mfd/rtsx_gops.c new file +1
-0+}drivers/mfd/rtsx_pcr.h +3
-0@@ -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 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