diff options
-rw-r--r-- | drivers/mfd/Makefile | 2 | ||||
-rw-r--r-- | drivers/mfd/rts5227.c | 2 | ||||
-rw-r--r-- | drivers/mfd/rts5249.c | 3 | ||||
-rw-r--r-- | drivers/mfd/rtsx_gops.c | 37 | ||||
-rw-r--r-- | drivers/mfd/rtsx_pcr.c | 22 | ||||
-rw-r--r-- | include/linux/mfd/rtsx_pci.h | 10 |
6 files changed, 21 insertions, 55 deletions
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 19f3d744e3bd..c8bb34929903 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 rtsx_gops.o rts5209.o rts5229.o rtl8411.o rts5227.o rts5249.o | 16 | rtsx_pci-objs := rtsx_pcr.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 1f387d4cec6c..0c0283154ab5 100644 --- a/drivers/mfd/rts5227.c +++ b/drivers/mfd/rts5227.c | |||
@@ -130,7 +130,7 @@ static int rts5227_optimize_phy(struct rtsx_pcr *pcr) | |||
130 | { | 130 | { |
131 | int err; | 131 | int err; |
132 | 132 | ||
133 | err = rtsx_gops_pm_reset(pcr); | 133 | err = rtsx_pci_write_register(pcr, PM_CTRL3, D3_DELINK_MODE_EN, 0x00); |
134 | if (err < 0) | 134 | if (err < 0) |
135 | return err; | 135 | return err; |
136 | 136 | ||
diff --git a/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c index 8de822048ff2..3c77058a70d2 100644 --- a/drivers/mfd/rts5249.c +++ b/drivers/mfd/rts5249.c | |||
@@ -119,7 +119,6 @@ static int rts5249_extra_init_hw(struct rtsx_pcr *pcr) | |||
119 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0xB0, 0xB0); | 119 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0xB0, 0xB0); |
120 | else | 120 | else |
121 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0xB0, 0x80); | 121 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0xB0, 0x80); |
122 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PM_CTRL3, 0x10, 0x00); | ||
123 | 122 | ||
124 | return rtsx_pci_send_cmd(pcr, 100); | 123 | return rtsx_pci_send_cmd(pcr, 100); |
125 | } | 124 | } |
@@ -128,7 +127,7 @@ static int rts5249_optimize_phy(struct rtsx_pcr *pcr) | |||
128 | { | 127 | { |
129 | int err; | 128 | int err; |
130 | 129 | ||
131 | err = rtsx_gops_pm_reset(pcr); | 130 | err = rtsx_pci_write_register(pcr, PM_CTRL3, D3_DELINK_MODE_EN, 0x00); |
132 | if (err < 0) | 131 | if (err < 0) |
133 | return err; | 132 | return err; |
134 | 133 | ||
diff --git a/drivers/mfd/rtsx_gops.c b/drivers/mfd/rtsx_gops.c deleted file mode 100644 index b1a98c678593..000000000000 --- a/drivers/mfd/rtsx_gops.c +++ /dev/null | |||
@@ -1,37 +0,0 @@ | |||
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.c b/drivers/mfd/rtsx_pcr.c index 30f7ca89a0e6..81b9c2c2e0f1 100644 --- a/drivers/mfd/rtsx_pcr.c +++ b/drivers/mfd/rtsx_pcr.c | |||
@@ -63,6 +63,18 @@ static const struct pci_device_id rtsx_pci_ids[] = { | |||
63 | 63 | ||
64 | MODULE_DEVICE_TABLE(pci, rtsx_pci_ids); | 64 | MODULE_DEVICE_TABLE(pci, rtsx_pci_ids); |
65 | 65 | ||
66 | static inline void rtsx_pci_enable_aspm(struct rtsx_pcr *pcr) | ||
67 | { | ||
68 | rtsx_pci_update_cfg_byte(pcr, pcr->pcie_cap + PCI_EXP_LNKCTL, | ||
69 | 0xFC, pcr->aspm_en); | ||
70 | } | ||
71 | |||
72 | static inline void rtsx_pci_disable_aspm(struct rtsx_pcr *pcr) | ||
73 | { | ||
74 | rtsx_pci_update_cfg_byte(pcr, pcr->pcie_cap + PCI_EXP_LNKCTL, | ||
75 | 0xFC, 0); | ||
76 | } | ||
77 | |||
66 | void rtsx_pci_start_run(struct rtsx_pcr *pcr) | 78 | void rtsx_pci_start_run(struct rtsx_pcr *pcr) |
67 | { | 79 | { |
68 | /* If pci device removed, don't queue idle work any more */ | 80 | /* If pci device removed, don't queue idle work any more */ |
@@ -75,7 +87,7 @@ void rtsx_pci_start_run(struct rtsx_pcr *pcr) | |||
75 | pcr->ops->enable_auto_blink(pcr); | 87 | pcr->ops->enable_auto_blink(pcr); |
76 | 88 | ||
77 | if (pcr->aspm_en) | 89 | if (pcr->aspm_en) |
78 | rtsx_pci_write_config_byte(pcr, LCTLR, 0); | 90 | rtsx_pci_disable_aspm(pcr); |
79 | } | 91 | } |
80 | 92 | ||
81 | mod_delayed_work(system_wq, &pcr->idle_work, msecs_to_jiffies(200)); | 93 | mod_delayed_work(system_wq, &pcr->idle_work, msecs_to_jiffies(200)); |
@@ -942,7 +954,7 @@ static void rtsx_pci_idle_work(struct work_struct *work) | |||
942 | pcr->ops->turn_off_led(pcr); | 954 | pcr->ops->turn_off_led(pcr); |
943 | 955 | ||
944 | if (pcr->aspm_en) | 956 | if (pcr->aspm_en) |
945 | rtsx_pci_write_config_byte(pcr, LCTLR, pcr->aspm_en); | 957 | rtsx_pci_enable_aspm(pcr); |
946 | 958 | ||
947 | mutex_unlock(&pcr->pcr_mutex); | 959 | mutex_unlock(&pcr->pcr_mutex); |
948 | } | 960 | } |
@@ -968,6 +980,7 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr) | |||
968 | { | 980 | { |
969 | int err; | 981 | int err; |
970 | 982 | ||
983 | pcr->pcie_cap = pci_find_capability(pcr->pci, PCI_CAP_ID_EXP); | ||
971 | rtsx_pci_writel(pcr, RTSX_HCBAR, pcr->host_cmds_addr); | 984 | rtsx_pci_writel(pcr, RTSX_HCBAR, pcr->host_cmds_addr); |
972 | 985 | ||
973 | rtsx_pci_enable_bus_int(pcr); | 986 | rtsx_pci_enable_bus_int(pcr); |
@@ -980,6 +993,7 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr) | |||
980 | /* Wait SSC power stable */ | 993 | /* Wait SSC power stable */ |
981 | udelay(200); | 994 | udelay(200); |
982 | 995 | ||
996 | rtsx_pci_disable_aspm(pcr); | ||
983 | if (pcr->ops->optimize_phy) { | 997 | if (pcr->ops->optimize_phy) { |
984 | err = pcr->ops->optimize_phy(pcr); | 998 | err = pcr->ops->optimize_phy(pcr); |
985 | if (err < 0) | 999 | if (err < 0) |
@@ -1028,10 +1042,8 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr) | |||
1028 | if (err < 0) | 1042 | if (err < 0) |
1029 | return err; | 1043 | return err; |
1030 | 1044 | ||
1031 | rtsx_pci_write_config_byte(pcr, LCTLR, 0); | ||
1032 | |||
1033 | /* Enable clk_request_n to enable clock power management */ | 1045 | /* Enable clk_request_n to enable clock power management */ |
1034 | rtsx_pci_write_config_byte(pcr, 0x81, 1); | 1046 | rtsx_pci_write_config_byte(pcr, pcr->pcie_cap + PCI_EXP_LNKCTL + 1, 1); |
1035 | /* Enter L1 when host tx idle */ | 1047 | /* Enter L1 when host tx idle */ |
1036 | rtsx_pci_write_config_byte(pcr, 0x70F, 0x5B); | 1048 | rtsx_pci_write_config_byte(pcr, 0x70F, 0x5B); |
1037 | 1049 | ||
diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h index 0103210ec3e1..33cc63ced99e 100644 --- a/include/linux/mfd/rtsx_pci.h +++ b/include/linux/mfd/rtsx_pci.h | |||
@@ -716,15 +716,6 @@ | |||
716 | 716 | ||
717 | #define PHY_DUM_REG 0x1F | 717 | #define PHY_DUM_REG 0x1F |
718 | 718 | ||
719 | #define LCTLR 0x80 | ||
720 | #define LCTLR_EXT_SYNC 0x80 | ||
721 | #define LCTLR_COMMON_CLOCK_CFG 0x40 | ||
722 | #define LCTLR_RETRAIN_LINK 0x20 | ||
723 | #define LCTLR_LINK_DISABLE 0x10 | ||
724 | #define LCTLR_RCB 0x08 | ||
725 | #define LCTLR_RESERVED 0x04 | ||
726 | #define LCTLR_ASPM_CTL_MASK 0x03 | ||
727 | |||
728 | #define PCR_SETTING_REG1 0x724 | 719 | #define PCR_SETTING_REG1 0x724 |
729 | #define PCR_SETTING_REG2 0x814 | 720 | #define PCR_SETTING_REG2 0x814 |
730 | #define PCR_SETTING_REG3 0x747 | 721 | #define PCR_SETTING_REG3 0x747 |
@@ -759,6 +750,7 @@ enum PDEV_STAT {PDEV_STAT_IDLE, PDEV_STAT_RUN}; | |||
759 | struct rtsx_pcr { | 750 | struct rtsx_pcr { |
760 | struct pci_dev *pci; | 751 | struct pci_dev *pci; |
761 | unsigned int id; | 752 | unsigned int id; |
753 | int pcie_cap; | ||
762 | 754 | ||
763 | /* pci resources */ | 755 | /* pci resources */ |
764 | unsigned long addr; | 756 | unsigned long addr; |