.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | /* Driver for Realtek PCI-Express card reader |
---|
2 | 3 | * |
---|
3 | 4 | * 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 | 5 | * |
---|
18 | 6 | * Author: |
---|
19 | 7 | * Wei WANG <wei_wang@realsil.com.cn> |
---|
.. | .. |
---|
110 | 98 | iowrite8(value, (pcr)->remap_addr + reg) |
---|
111 | 99 | #define rtsx_pci_readb(pcr, reg) \ |
---|
112 | 100 | ioread8((pcr)->remap_addr + reg) |
---|
113 | | - |
---|
114 | | -#define rtsx_pci_read_config_byte(pcr, where, val) \ |
---|
115 | | - pci_read_config_byte((pcr)->pci, where, val) |
---|
116 | | - |
---|
117 | | -#define rtsx_pci_write_config_byte(pcr, where, val) \ |
---|
118 | | - pci_write_config_byte((pcr)->pci, where, val) |
---|
119 | | - |
---|
120 | | -#define rtsx_pci_read_config_dword(pcr, where, val) \ |
---|
121 | | - pci_read_config_dword((pcr)->pci, where, val) |
---|
122 | | - |
---|
123 | | -#define rtsx_pci_write_config_dword(pcr, where, val) \ |
---|
124 | | - pci_write_config_dword((pcr)->pci, where, val) |
---|
125 | 101 | |
---|
126 | 102 | #define STATE_TRANS_NONE 0 |
---|
127 | 103 | #define STATE_TRANS_CMD 1 |
---|
.. | .. |
---|
317 | 293 | #define SD30_CLK_STOP_CFG0 0x01 |
---|
318 | 294 | #define REG_PRE_RW_MODE 0xFD70 |
---|
319 | 295 | #define EN_INFINITE_MODE 0x01 |
---|
| 296 | +#define REG_CRC_DUMMY_0 0xFD71 |
---|
| 297 | +#define CFG_SD_POW_AUTO_PD (1<<0) |
---|
320 | 298 | |
---|
321 | 299 | #define SRCTL 0xFC13 |
---|
322 | 300 | |
---|
.. | .. |
---|
611 | 589 | |
---|
612 | 590 | #define ASPM_FORCE_CTL 0xFE57 |
---|
613 | 591 | #define FORCE_ASPM_CTL0 0x10 |
---|
| 592 | +#define FORCE_ASPM_CTL1 0x20 |
---|
614 | 593 | #define FORCE_ASPM_VAL_MASK 0x03 |
---|
615 | 594 | #define FORCE_ASPM_L1_EN 0x02 |
---|
616 | 595 | #define FORCE_ASPM_L0_EN 0x01 |
---|
.. | .. |
---|
678 | 657 | #define RESET_PIN_WAKE 0x02 |
---|
679 | 658 | #define PM_WAKE_EN 0x01 |
---|
680 | 659 | #define PM_CTRL4 0xFF47 |
---|
| 660 | + |
---|
| 661 | +#define REG_CFG_OOBS_OFF_TIMER 0xFEA6 |
---|
| 662 | +#define REG_CFG_OOBS_ON_TIMER 0xFEA7 |
---|
| 663 | +#define REG_CFG_VCM_ON_TIMER 0xFEA8 |
---|
| 664 | +#define REG_CFG_OOBS_POLLING 0xFEA9 |
---|
681 | 665 | |
---|
682 | 666 | /* Memory mapping */ |
---|
683 | 667 | #define SRAM_BASE 0xE600 |
---|
.. | .. |
---|
1053 | 1037 | #define PHY_DIG1E_RX_EN_KEEP 0x0001 |
---|
1054 | 1038 | #define PHY_DUM_REG 0x1F |
---|
1055 | 1039 | |
---|
1056 | | -#define PCR_ASPM_SETTING_REG1 0x160 |
---|
1057 | | -#define PCR_ASPM_SETTING_REG2 0x168 |
---|
1058 | | -#define PCR_ASPM_SETTING_5260 0x178 |
---|
1059 | | - |
---|
1060 | 1040 | #define PCR_SETTING_REG1 0x724 |
---|
1061 | 1041 | #define PCR_SETTING_REG2 0x814 |
---|
1062 | 1042 | #define PCR_SETTING_REG3 0x747 |
---|
.. | .. |
---|
1092 | 1072 | void (*stop_cmd)(struct rtsx_pcr *pcr); |
---|
1093 | 1073 | |
---|
1094 | 1074 | void (*set_aspm)(struct rtsx_pcr *pcr, bool enable); |
---|
1095 | | - int (*set_ltr_latency)(struct rtsx_pcr *pcr, u32 latency); |
---|
1096 | | - int (*set_l1off_sub)(struct rtsx_pcr *pcr, u8 val); |
---|
1097 | 1075 | void (*set_l1off_cfg_sub_d0)(struct rtsx_pcr *pcr, int active); |
---|
1098 | | - void (*full_on)(struct rtsx_pcr *pcr); |
---|
1099 | | - void (*power_saving)(struct rtsx_pcr *pcr); |
---|
1100 | 1076 | void (*enable_ocp)(struct rtsx_pcr *pcr); |
---|
1101 | 1077 | void (*disable_ocp)(struct rtsx_pcr *pcr); |
---|
1102 | 1078 | void (*init_ocp)(struct rtsx_pcr *pcr); |
---|
.. | .. |
---|
1107 | 1083 | |
---|
1108 | 1084 | enum PDEV_STAT {PDEV_STAT_IDLE, PDEV_STAT_RUN}; |
---|
1109 | 1085 | |
---|
1110 | | -#define ASPM_L1_1_EN_MASK BIT(3) |
---|
1111 | | -#define ASPM_L1_2_EN_MASK BIT(2) |
---|
1112 | | -#define PM_L1_1_EN_MASK BIT(1) |
---|
1113 | | -#define PM_L1_2_EN_MASK BIT(0) |
---|
1114 | | - |
---|
1115 | 1086 | #define ASPM_L1_1_EN BIT(0) |
---|
1116 | 1087 | #define ASPM_L1_2_EN BIT(1) |
---|
1117 | 1088 | #define PM_L1_1_EN BIT(2) |
---|
.. | .. |
---|
1119 | 1090 | #define LTR_L1SS_PWR_GATE_EN BIT(4) |
---|
1120 | 1091 | #define L1_SNOOZE_TEST_EN BIT(5) |
---|
1121 | 1092 | #define LTR_L1SS_PWR_GATE_CHECK_CARD_EN BIT(6) |
---|
1122 | | - |
---|
1123 | | -enum dev_aspm_mode { |
---|
1124 | | - DEV_ASPM_DYNAMIC, |
---|
1125 | | - DEV_ASPM_BACKDOOR, |
---|
1126 | | - DEV_ASPM_STATIC, |
---|
1127 | | - DEV_ASPM_DISABLE, |
---|
1128 | | -}; |
---|
1129 | 1093 | |
---|
1130 | 1094 | /* |
---|
1131 | 1095 | * struct rtsx_cr_option - card reader option |
---|
.. | .. |
---|
1137 | 1101 | * @ltr_active_latency: ltr mode active latency |
---|
1138 | 1102 | * @ltr_idle_latency: ltr mode idle latency |
---|
1139 | 1103 | * @ltr_l1off_latency: ltr mode l1off latency |
---|
1140 | | - * @dev_aspm_mode: device aspm mode |
---|
1141 | 1104 | * @l1_snooze_delay: l1 snooze delay |
---|
1142 | 1105 | * @ltr_l1off_sspwrgate: ltr l1off sspwrgate |
---|
1143 | 1106 | * @ltr_l1off_snooze_sspwrgate: ltr l1off snooze sspwrgate |
---|
.. | .. |
---|
1154 | 1117 | u32 ltr_active_latency; |
---|
1155 | 1118 | u32 ltr_idle_latency; |
---|
1156 | 1119 | u32 ltr_l1off_latency; |
---|
1157 | | - enum dev_aspm_mode dev_aspm_mode; |
---|
1158 | 1120 | u32 l1_snooze_delay; |
---|
1159 | 1121 | u8 ltr_l1off_sspwrgate; |
---|
1160 | 1122 | u8 ltr_l1off_snooze_sspwrgate; |
---|
.. | .. |
---|
1183 | 1145 | struct rtsx_pcr { |
---|
1184 | 1146 | struct pci_dev *pci; |
---|
1185 | 1147 | unsigned int id; |
---|
1186 | | - int pcie_cap; |
---|
1187 | 1148 | struct rtsx_cr_option option; |
---|
1188 | 1149 | struct rtsx_hw_param hw_param; |
---|
1189 | 1150 | |
---|
.. | .. |
---|
1229 | 1190 | #define EXTRA_CAPS_MMC_HSDDR (1 << 3) |
---|
1230 | 1191 | #define EXTRA_CAPS_MMC_HS200 (1 << 4) |
---|
1231 | 1192 | #define EXTRA_CAPS_MMC_8BIT (1 << 5) |
---|
| 1193 | +#define EXTRA_CAPS_NO_MMC (1 << 7) |
---|
1232 | 1194 | u32 extra_caps; |
---|
1233 | 1195 | |
---|
1234 | 1196 | #define IC_VER_A 0 |
---|
.. | .. |
---|
1267 | 1229 | u8 dma_error_count; |
---|
1268 | 1230 | u8 ocp_stat; |
---|
1269 | 1231 | u8 ocp_stat2; |
---|
| 1232 | + u8 rtd3_en; |
---|
1270 | 1233 | }; |
---|
1271 | 1234 | |
---|
1272 | 1235 | #define PID_524A 0x524A |
---|
.. | .. |
---|
1274 | 1237 | #define PID_5250 0x5250 |
---|
1275 | 1238 | #define PID_525A 0x525A |
---|
1276 | 1239 | #define PID_5260 0x5260 |
---|
| 1240 | +#define PID_5261 0x5261 |
---|
| 1241 | +#define PID_5228 0x5228 |
---|
1277 | 1242 | |
---|
1278 | 1243 | #define CHK_PCI_PID(pcr, pid) ((pcr)->pci->device == (pid)) |
---|
1279 | 1244 | #define PCI_VID(pcr) ((pcr)->pci->vendor) |
---|
.. | .. |
---|
1329 | 1294 | static inline u8 *rtsx_pci_get_cmd_data(struct rtsx_pcr *pcr) |
---|
1330 | 1295 | { |
---|
1331 | 1296 | return (u8 *)(pcr->host_cmds_ptr); |
---|
1332 | | -} |
---|
1333 | | - |
---|
1334 | | -static inline int rtsx_pci_update_cfg_byte(struct rtsx_pcr *pcr, int addr, |
---|
1335 | | - u8 mask, u8 append) |
---|
1336 | | -{ |
---|
1337 | | - int err; |
---|
1338 | | - u8 val; |
---|
1339 | | - |
---|
1340 | | - err = pci_read_config_byte(pcr->pci, addr, &val); |
---|
1341 | | - if (err < 0) |
---|
1342 | | - return err; |
---|
1343 | | - return pci_write_config_byte(pcr->pci, addr, (val & mask) | append); |
---|
1344 | 1297 | } |
---|
1345 | 1298 | |
---|
1346 | 1299 | static inline void rtsx_pci_write_be32(struct rtsx_pcr *pcr, u16 reg, u32 val) |
---|