Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: rtsx: Remove LCTLR defination

To enable/disable ASPM we should find LINK CONTROL register
in PCI config space. All old chip use 0x80 address, but new
chip may use another address, so we using pci_find_capability()
to get LINK CONTROL address.

rtsx_gops.c was removed, we consider to put some common operations
to this file, but the actual thing is, only a group of chips
are in common ops1, and another group of chips in common ops2,
it is hard to decide put which ops into generic ops file.

Signed-off-by: Micky Ching <micky_ching@realsil.com.cn>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Micky Ching and committed by
Lee Jones
19f3bd54 b0385381

+21 -55
+1 -1
drivers/mfd/Makefile
··· 13 13 obj-$(CONFIG_MFD_CROS_EC_I2C) += cros_ec_i2c.o 14 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 17 obj-$(CONFIG_MFD_RTSX_PCI) += rtsx_pci.o 18 18 obj-$(CONFIG_MFD_RTSX_USB) += rtsx_usb.o 19 19
+1 -1
drivers/mfd/rts5227.c
··· 130 130 { 131 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 134 if (err < 0) 135 135 return err; 136 136
+1 -2
drivers/mfd/rts5249.c
··· 119 119 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0xB0, 0xB0); 120 120 else 121 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 123 return rtsx_pci_send_cmd(pcr, 100); 125 124 } ··· 127 128 { 128 129 int err; 129 130 130 - err = rtsx_gops_pm_reset(pcr); 131 + err = rtsx_pci_write_register(pcr, PM_CTRL3, D3_DELINK_MODE_EN, 0x00); 131 132 if (err < 0) 132 133 return err; 133 134
-37
drivers/mfd/rtsx_gops.c
··· 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 - }
+17 -5
drivers/mfd/rtsx_pcr.c
··· 63 63 64 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 78 void rtsx_pci_start_run(struct rtsx_pcr *pcr) 67 79 { 68 80 /* If pci device removed, don't queue idle work any more */ ··· 87 75 pcr->ops->enable_auto_blink(pcr); 88 76 89 77 if (pcr->aspm_en) 90 - rtsx_pci_write_config_byte(pcr, LCTLR, 0); 78 + rtsx_pci_disable_aspm(pcr); 91 79 } 92 80 93 81 mod_delayed_work(system_wq, &pcr->idle_work, msecs_to_jiffies(200)); ··· 954 942 pcr->ops->turn_off_led(pcr); 955 943 956 944 if (pcr->aspm_en) 957 - rtsx_pci_write_config_byte(pcr, LCTLR, pcr->aspm_en); 945 + rtsx_pci_enable_aspm(pcr); 958 946 959 947 mutex_unlock(&pcr->pcr_mutex); 960 948 } ··· 980 968 { 981 969 int err; 982 970 971 + pcr->pcie_cap = pci_find_capability(pcr->pci, PCI_CAP_ID_EXP); 983 972 rtsx_pci_writel(pcr, RTSX_HCBAR, pcr->host_cmds_addr); 984 973 985 974 rtsx_pci_enable_bus_int(pcr); ··· 993 980 /* Wait SSC power stable */ 994 981 udelay(200); 995 982 983 + rtsx_pci_disable_aspm(pcr); 996 984 if (pcr->ops->optimize_phy) { 997 985 err = pcr->ops->optimize_phy(pcr); 998 986 if (err < 0) ··· 1042 1028 if (err < 0) 1043 1029 return err; 1044 1030 1045 - rtsx_pci_write_config_byte(pcr, LCTLR, 0); 1046 - 1047 1031 /* Enable clk_request_n to enable clock power management */ 1048 - rtsx_pci_write_config_byte(pcr, 0x81, 1); 1032 + rtsx_pci_write_config_byte(pcr, pcr->pcie_cap + PCI_EXP_LNKCTL + 1, 1); 1049 1033 /* Enter L1 when host tx idle */ 1050 1034 rtsx_pci_write_config_byte(pcr, 0x70F, 0x5B); 1051 1035
+1 -9
include/linux/mfd/rtsx_pci.h
··· 716 716 717 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 719 #define PCR_SETTING_REG1 0x724 729 720 #define PCR_SETTING_REG2 0x814 730 721 #define PCR_SETTING_REG3 0x747 ··· 750 759 struct rtsx_pcr { 751 760 struct pci_dev *pci; 752 761 unsigned int id; 762 + int pcie_cap; 753 763 754 764 /* pci resources */ 755 765 unsigned long addr;