diff options
author | Micky Ching <micky_ching@realsil.com.cn> | 2014-10-10 01:58:44 -0400 |
---|---|---|
committer | Lee Jones <lee.jones@linaro.org> | 2014-11-25 11:18:48 -0500 |
commit | 5cb5d9616a47d5383a85379afa4429382ef46b38 (patch) | |
tree | cecbc166e912f9ac1f40dcb32ad2b2fec5be8684 | |
parent | 130dd5b039dcbab7bcb2fdce0bb3cc7347b08b29 (diff) |
mfd: rtsx: Fix PM suspend for 5227 & 5249
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>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
-rw-r--r-- | drivers/mfd/Makefile | 2 | ||||
-rw-r--r-- | drivers/mfd/rts5227.c | 6 | ||||
-rw-r--r-- | drivers/mfd/rts5249.c | 4 | ||||
-rw-r--r-- | drivers/mfd/rtsx_gops.c | 37 | ||||
-rw-r--r-- | drivers/mfd/rtsx_pcr.h | 3 | ||||
-rw-r--r-- | include/linux/mfd/rtsx_pci.h | 28 |
6 files changed, 79 insertions, 1 deletions
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 2cd7e743280c..53467e211381 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile | |||
@@ -13,7 +13,7 @@ obj-$(CONFIG_MFD_CROS_EC) += cros_ec.o | |||
13 | obj-$(CONFIG_MFD_CROS_EC_I2C) += cros_ec_i2c.o | 13 | obj-$(CONFIG_MFD_CROS_EC_I2C) += cros_ec_i2c.o |
14 | obj-$(CONFIG_MFD_CROS_EC_SPI) += cros_ec_spi.o | 14 | obj-$(CONFIG_MFD_CROS_EC_SPI) += cros_ec_spi.o |
15 | 15 | ||
16 | rtsx_pci-objs := rtsx_pcr.o rts5209.o rts5229.o rtl8411.o rts5227.o rts5249.o | 16 | rtsx_pci-objs := rtsx_pcr.o rtsx_gops.o rts5209.o rts5229.o rtl8411.o rts5227.o rts5249.o |
17 | obj-$(CONFIG_MFD_RTSX_PCI) += rtsx_pci.o | 17 | obj-$(CONFIG_MFD_RTSX_PCI) += rtsx_pci.o |
18 | obj-$(CONFIG_MFD_RTSX_USB) += rtsx_usb.o | 18 | obj-$(CONFIG_MFD_RTSX_USB) += rtsx_usb.o |
19 | 19 | ||
diff --git a/drivers/mfd/rts5227.c b/drivers/mfd/rts5227.c index 9c8eec80ceed..32407404d838 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) | |||
130 | 130 | ||
131 | static int rts5227_optimize_phy(struct rtsx_pcr *pcr) | 131 | static int rts5227_optimize_phy(struct rtsx_pcr *pcr) |
132 | { | 132 | { |
133 | int err; | ||
134 | |||
135 | err = rtsx_gops_pm_reset(pcr); | ||
136 | if (err < 0) | ||
137 | return err; | ||
138 | |||
133 | /* Optimize RX sensitivity */ | 139 | /* Optimize RX sensitivity */ |
134 | return rtsx_pci_write_phy_register(pcr, 0x00, 0xBA42); | 140 | return rtsx_pci_write_phy_register(pcr, 0x00, 0xBA42); |
135 | } | 141 | } |
diff --git a/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c index 573de7bfcced..cf425cc959d5 100644 --- a/drivers/mfd/rts5249.c +++ b/drivers/mfd/rts5249.c | |||
@@ -130,6 +130,10 @@ static int rts5249_optimize_phy(struct rtsx_pcr *pcr) | |||
130 | { | 130 | { |
131 | int err; | 131 | int err; |
132 | 132 | ||
133 | err = rtsx_gops_pm_reset(pcr); | ||
134 | if (err < 0) | ||
135 | return err; | ||
136 | |||
133 | err = rtsx_pci_write_phy_register(pcr, PHY_REG_REV, | 137 | err = rtsx_pci_write_phy_register(pcr, PHY_REG_REV, |
134 | PHY_REG_REV_RESV | PHY_REG_REV_RXIDLE_LATCHED | | 138 | PHY_REG_REV_RESV | PHY_REG_REV_RXIDLE_LATCHED | |
135 | PHY_REG_REV_P1_EN | PHY_REG_REV_RXIDLE_EN | | 139 | 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 000000000000..b1a98c678593 --- /dev/null +++ b/drivers/mfd/rtsx_gops.c | |||
@@ -0,0 +1,37 @@ | |||
1 | /* Driver for Realtek PCI-Express card reader | ||
2 | * | ||
3 | * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify it | ||
6 | * under the terms of the GNU General Public License as published by the | ||
7 | * Free Software Foundation; either version 2, or (at your option) any | ||
8 | * later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License along | ||
16 | * with this program; if not, see <http://www.gnu.org/licenses/>. | ||
17 | * | ||
18 | * Author: | ||
19 | * Micky Ching <micky_ching@realsil.com.cn> | ||
20 | */ | ||
21 | |||
22 | #include <linux/mfd/rtsx_pci.h> | ||
23 | #include "rtsx_pcr.h" | ||
24 | |||
25 | int rtsx_gops_pm_reset(struct rtsx_pcr *pcr) | ||
26 | { | ||
27 | int err; | ||
28 | |||
29 | /* init aspm */ | ||
30 | rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, 0xFF, 0x00); | ||
31 | err = rtsx_pci_update_cfg_byte(pcr, LCTLR, ~LCTLR_ASPM_CTL_MASK, 0x00); | ||
32 | if (err < 0) | ||
33 | return err; | ||
34 | |||
35 | /* reset PM_CTRL3 before send buffer cmd */ | ||
36 | return rtsx_pci_write_register(pcr, PM_CTRL3, D3_DELINK_MODE_EN, 0x00); | ||
37 | } | ||
diff --git a/drivers/mfd/rtsx_pcr.h b/drivers/mfd/rtsx_pcr.h index 07e4c2ebf05a..fe2bbb67defc 100644 --- a/drivers/mfd/rtsx_pcr.h +++ b/drivers/mfd/rtsx_pcr.h | |||
@@ -72,4 +72,7 @@ do { \ | |||
72 | pcr->ms_pull_ctl_disable_tbl = __device##_ms_pull_ctl_disable_tbl; \ | 72 | pcr->ms_pull_ctl_disable_tbl = __device##_ms_pull_ctl_disable_tbl; \ |
73 | } while (0) | 73 | } while (0) |
74 | 74 | ||
75 | /* generic operations */ | ||
76 | int rtsx_gops_pm_reset(struct rtsx_pcr *pcr); | ||
77 | |||
75 | #endif | 78 | #endif |
diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h index 74346d5e7899..1604dda4edcf 100644 --- a/include/linux/mfd/rtsx_pci.h +++ b/include/linux/mfd/rtsx_pci.h | |||
@@ -707,6 +707,14 @@ | |||
707 | #define PM_CTRL1 0xFF44 | 707 | #define PM_CTRL1 0xFF44 |
708 | #define PM_CTRL2 0xFF45 | 708 | #define PM_CTRL2 0xFF45 |
709 | #define PM_CTRL3 0xFF46 | 709 | #define PM_CTRL3 0xFF46 |
710 | #define SDIO_SEND_PME_EN 0x80 | ||
711 | #define FORCE_RC_MODE_ON 0x40 | ||
712 | #define FORCE_RX50_LINK_ON 0x20 | ||
713 | #define D3_DELINK_MODE_EN 0x10 | ||
714 | #define USE_PESRTB_CTL_DELINK 0x08 | ||
715 | #define DELAY_PIN_WAKE 0x04 | ||
716 | #define RESET_PIN_WAKE 0x02 | ||
717 | #define PM_WAKE_EN 0x01 | ||
710 | #define PM_CTRL4 0xFF47 | 718 | #define PM_CTRL4 0xFF47 |
711 | 719 | ||
712 | /* Memory mapping */ | 720 | /* Memory mapping */ |
@@ -752,6 +760,14 @@ | |||
752 | #define PHY_DUM_REG 0x1F | 760 | #define PHY_DUM_REG 0x1F |
753 | 761 | ||
754 | #define LCTLR 0x80 | 762 | #define LCTLR 0x80 |
763 | #define LCTLR_EXT_SYNC 0x80 | ||
764 | #define LCTLR_COMMON_CLOCK_CFG 0x40 | ||
765 | #define LCTLR_RETRAIN_LINK 0x20 | ||
766 | #define LCTLR_LINK_DISABLE 0x10 | ||
767 | #define LCTLR_RCB 0x08 | ||
768 | #define LCTLR_RESERVED 0x04 | ||
769 | #define LCTLR_ASPM_CTL_MASK 0x03 | ||
770 | |||
755 | #define PCR_SETTING_REG1 0x724 | 771 | #define PCR_SETTING_REG1 0x724 |
756 | #define PCR_SETTING_REG2 0x814 | 772 | #define PCR_SETTING_REG2 0x814 |
757 | #define PCR_SETTING_REG3 0x747 | 773 | #define PCR_SETTING_REG3 0x747 |
@@ -967,4 +983,16 @@ static inline u8 *rtsx_pci_get_cmd_data(struct rtsx_pcr *pcr) | |||
967 | return (u8 *)(pcr->host_cmds_ptr); | 983 | return (u8 *)(pcr->host_cmds_ptr); |
968 | } | 984 | } |
969 | 985 | ||
986 | static inline int rtsx_pci_update_cfg_byte(struct rtsx_pcr *pcr, int addr, | ||
987 | u8 mask, u8 append) | ||
988 | { | ||
989 | int err; | ||
990 | u8 val; | ||
991 | |||
992 | err = pci_read_config_byte(pcr->pci, addr, &val); | ||
993 | if (err < 0) | ||
994 | return err; | ||
995 | return pci_write_config_byte(pcr->pci, addr, (val & mask) | append); | ||
996 | } | ||
997 | |||
970 | #endif | 998 | #endif |