1 /* Realtek PCI-Express SD/MMC Card Interface driver
3 * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved.
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
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.
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/>.
19 * Wei WANG <wei_wang@realsil.com.cn>
20 * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
23 #include <linux/module.h>
24 #include <linux/slab.h>
25 #include <linux/highmem.h>
26 #include <linux/delay.h>
27 #include <linux/platform_device.h>
28 #include <linux/mmc/host.h>
29 #include <linux/mmc/mmc.h>
30 #include <linux/mmc/sd.h>
31 #include <linux/mmc/card.h>
32 #include <linux/mfd/rtsx_pci.h>
33 #include <asm/unaligned.h>
35 /* SD Tuning Data Structure
36 * Record continuous timing phase path
38 struct timing_phase_path
{
45 struct realtek_pci_sdmmc
{
46 struct platform_device
*pdev
;
49 struct mmc_request
*mrq
;
51 struct mutex host_mutex
;
62 static inline struct device
*sdmmc_dev(struct realtek_pci_sdmmc
*host
)
64 return &(host
->pdev
->dev
);
67 static inline void sd_clear_error(struct realtek_pci_sdmmc
*host
)
69 rtsx_pci_write_register(host
->pcr
, CARD_STOP
,
70 SD_STOP
| SD_CLR_ERR
, SD_STOP
| SD_CLR_ERR
);
74 static void sd_print_debug_regs(struct realtek_pci_sdmmc
*host
)
76 struct rtsx_pcr
*pcr
= host
->pcr
;
80 /* Print SD host internal registers */
81 rtsx_pci_init_cmd(pcr
);
82 for (i
= 0xFDA0; i
<= 0xFDAE; i
++)
83 rtsx_pci_add_cmd(pcr
, READ_REG_CMD
, i
, 0, 0);
84 for (i
= 0xFD52; i
<= 0xFD69; i
++)
85 rtsx_pci_add_cmd(pcr
, READ_REG_CMD
, i
, 0, 0);
86 rtsx_pci_send_cmd(pcr
, 100);
88 ptr
= rtsx_pci_get_cmd_data(pcr
);
89 for (i
= 0xFDA0; i
<= 0xFDAE; i
++)
90 dev_dbg(sdmmc_dev(host
), "0x%04X: 0x%02x\n", i
, *(ptr
++));
91 for (i
= 0xFD52; i
<= 0xFD69; i
++)
92 dev_dbg(sdmmc_dev(host
), "0x%04X: 0x%02x\n", i
, *(ptr
++));
95 #define sd_print_debug_regs(host)
98 static int sd_read_data(struct realtek_pci_sdmmc
*host
, u8
*cmd
, u16 byte_cnt
,
99 u8
*buf
, int buf_len
, int timeout
)
101 struct rtsx_pcr
*pcr
= host
->pcr
;
105 dev_dbg(sdmmc_dev(host
), "%s: SD/MMC CMD%d\n", __func__
, cmd
[0] - 0x40);
110 if ((cmd
[0] & 0x3F) == MMC_SEND_TUNING_BLOCK
)
111 trans_mode
= SD_TM_AUTO_TUNING
;
113 trans_mode
= SD_TM_NORMAL_READ
;
115 rtsx_pci_init_cmd(pcr
);
117 for (i
= 0; i
< 5; i
++)
118 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_CMD0
+ i
, 0xFF, cmd
[i
]);
120 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_BYTE_CNT_L
, 0xFF, (u8
)byte_cnt
);
121 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_BYTE_CNT_H
,
122 0xFF, (u8
)(byte_cnt
>> 8));
123 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_BLOCK_CNT_L
, 0xFF, 1);
124 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_BLOCK_CNT_H
, 0xFF, 0);
126 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_CFG2
, 0xFF,
127 SD_CALCULATE_CRC7
| SD_CHECK_CRC16
|
128 SD_NO_WAIT_BUSY_END
| SD_CHECK_CRC7
| SD_RSP_LEN_6
);
129 if (trans_mode
!= SD_TM_AUTO_TUNING
)
130 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
,
131 CARD_DATA_SOURCE
, 0x01, PINGPONG_BUFFER
);
133 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_TRANSFER
,
134 0xFF, trans_mode
| SD_TRANSFER_START
);
135 rtsx_pci_add_cmd(pcr
, CHECK_REG_CMD
, SD_TRANSFER
,
136 SD_TRANSFER_END
, SD_TRANSFER_END
);
138 err
= rtsx_pci_send_cmd(pcr
, timeout
);
140 sd_print_debug_regs(host
);
141 dev_dbg(sdmmc_dev(host
),
142 "rtsx_pci_send_cmd fail (err = %d)\n", err
);
146 if (buf
&& buf_len
) {
147 err
= rtsx_pci_read_ppbuf(pcr
, buf
, buf_len
);
149 dev_dbg(sdmmc_dev(host
),
150 "rtsx_pci_read_ppbuf fail (err = %d)\n", err
);
158 static int sd_write_data(struct realtek_pci_sdmmc
*host
, u8
*cmd
, u16 byte_cnt
,
159 u8
*buf
, int buf_len
, int timeout
)
161 struct rtsx_pcr
*pcr
= host
->pcr
;
168 if (buf
&& buf_len
) {
169 err
= rtsx_pci_write_ppbuf(pcr
, buf
, buf_len
);
171 dev_dbg(sdmmc_dev(host
),
172 "rtsx_pci_write_ppbuf fail (err = %d)\n", err
);
177 trans_mode
= cmd
? SD_TM_AUTO_WRITE_2
: SD_TM_AUTO_WRITE_3
;
178 rtsx_pci_init_cmd(pcr
);
181 dev_dbg(sdmmc_dev(host
), "%s: SD/MMC CMD %d\n", __func__
,
184 for (i
= 0; i
< 5; i
++)
185 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
,
186 SD_CMD0
+ i
, 0xFF, cmd
[i
]);
189 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_BYTE_CNT_L
, 0xFF, (u8
)byte_cnt
);
190 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_BYTE_CNT_H
,
191 0xFF, (u8
)(byte_cnt
>> 8));
192 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_BLOCK_CNT_L
, 0xFF, 1);
193 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_BLOCK_CNT_H
, 0xFF, 0);
195 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_CFG2
, 0xFF,
196 SD_CALCULATE_CRC7
| SD_CHECK_CRC16
|
197 SD_NO_WAIT_BUSY_END
| SD_CHECK_CRC7
| SD_RSP_LEN_6
);
199 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_TRANSFER
, 0xFF,
200 trans_mode
| SD_TRANSFER_START
);
201 rtsx_pci_add_cmd(pcr
, CHECK_REG_CMD
, SD_TRANSFER
,
202 SD_TRANSFER_END
, SD_TRANSFER_END
);
204 err
= rtsx_pci_send_cmd(pcr
, timeout
);
206 sd_print_debug_regs(host
);
207 dev_dbg(sdmmc_dev(host
),
208 "rtsx_pci_send_cmd fail (err = %d)\n", err
);
215 static void sd_send_cmd_get_rsp(struct realtek_pci_sdmmc
*host
,
216 struct mmc_command
*cmd
)
218 struct rtsx_pcr
*pcr
= host
->pcr
;
219 u8 cmd_idx
= (u8
)cmd
->opcode
;
229 dev_dbg(sdmmc_dev(host
), "%s: SD/MMC CMD %d, arg = 0x%08x\n",
230 __func__
, cmd_idx
, arg
);
239 switch (mmc_resp_type(cmd
)) {
241 rsp_type
= SD_RSP_TYPE_R0
;
245 rsp_type
= SD_RSP_TYPE_R1
;
248 rsp_type
= SD_RSP_TYPE_R1b
;
251 rsp_type
= SD_RSP_TYPE_R2
;
255 rsp_type
= SD_RSP_TYPE_R3
;
258 dev_dbg(sdmmc_dev(host
), "cmd->flag is not valid\n");
263 if (rsp_type
== SD_RSP_TYPE_R1b
)
266 if (cmd
->opcode
== SD_SWITCH_VOLTAGE
) {
267 err
= rtsx_pci_write_register(pcr
, SD_BUS_STAT
,
268 0xFF, SD_CLK_TOGGLE_EN
);
273 rtsx_pci_init_cmd(pcr
);
275 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_CMD0
, 0xFF, 0x40 | cmd_idx
);
276 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_CMD1
, 0xFF, (u8
)(arg
>> 24));
277 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_CMD2
, 0xFF, (u8
)(arg
>> 16));
278 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_CMD3
, 0xFF, (u8
)(arg
>> 8));
279 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_CMD4
, 0xFF, (u8
)arg
);
281 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_CFG2
, 0xFF, rsp_type
);
282 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, CARD_DATA_SOURCE
,
283 0x01, PINGPONG_BUFFER
);
284 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_TRANSFER
,
285 0xFF, SD_TM_CMD_RSP
| SD_TRANSFER_START
);
286 rtsx_pci_add_cmd(pcr
, CHECK_REG_CMD
, SD_TRANSFER
,
287 SD_TRANSFER_END
| SD_STAT_IDLE
,
288 SD_TRANSFER_END
| SD_STAT_IDLE
);
290 if (rsp_type
== SD_RSP_TYPE_R2
) {
291 /* Read data from ping-pong buffer */
292 for (i
= PPBUF_BASE2
; i
< PPBUF_BASE2
+ 16; i
++)
293 rtsx_pci_add_cmd(pcr
, READ_REG_CMD
, (u16
)i
, 0, 0);
295 } else if (rsp_type
!= SD_RSP_TYPE_R0
) {
296 /* Read data from SD_CMDx registers */
297 for (i
= SD_CMD0
; i
<= SD_CMD4
; i
++)
298 rtsx_pci_add_cmd(pcr
, READ_REG_CMD
, (u16
)i
, 0, 0);
302 rtsx_pci_add_cmd(pcr
, READ_REG_CMD
, SD_STAT1
, 0, 0);
304 err
= rtsx_pci_send_cmd(pcr
, timeout
);
306 sd_print_debug_regs(host
);
307 sd_clear_error(host
);
308 dev_dbg(sdmmc_dev(host
),
309 "rtsx_pci_send_cmd error (err = %d)\n", err
);
313 if (rsp_type
== SD_RSP_TYPE_R0
) {
318 /* Eliminate returned value of CHECK_REG_CMD */
319 ptr
= rtsx_pci_get_cmd_data(pcr
) + 1;
321 /* Check (Start,Transmission) bit of Response */
322 if ((ptr
[0] & 0xC0) != 0) {
324 dev_dbg(sdmmc_dev(host
), "Invalid response bit\n");
329 if (!(rsp_type
& SD_NO_CHECK_CRC7
)) {
330 if (ptr
[stat_idx
] & SD_CRC7_ERR
) {
332 dev_dbg(sdmmc_dev(host
), "CRC7 error\n");
337 if (rsp_type
== SD_RSP_TYPE_R2
) {
338 for (i
= 0; i
< 4; i
++) {
339 cmd
->resp
[i
] = get_unaligned_be32(ptr
+ 1 + i
* 4);
340 dev_dbg(sdmmc_dev(host
), "cmd->resp[%d] = 0x%08x\n",
344 cmd
->resp
[0] = get_unaligned_be32(ptr
+ 1);
345 dev_dbg(sdmmc_dev(host
), "cmd->resp[0] = 0x%08x\n",
353 static int sd_rw_multi(struct realtek_pci_sdmmc
*host
, struct mmc_request
*mrq
)
355 struct rtsx_pcr
*pcr
= host
->pcr
;
356 struct mmc_host
*mmc
= host
->mmc
;
357 struct mmc_card
*card
= mmc
->card
;
358 struct mmc_data
*data
= mrq
->data
;
359 int uhs
= mmc_sd_card_uhs(card
);
360 int read
= (data
->flags
& MMC_DATA_READ
) ? 1 : 0;
363 size_t data_len
= data
->blksz
* data
->blocks
;
366 cfg2
= SD_CALCULATE_CRC7
| SD_CHECK_CRC16
|
367 SD_NO_WAIT_BUSY_END
| SD_CHECK_CRC7
| SD_RSP_LEN_0
;
368 trans_mode
= SD_TM_AUTO_READ_3
;
370 cfg2
= SD_NO_CALCULATE_CRC7
| SD_CHECK_CRC16
|
371 SD_NO_WAIT_BUSY_END
| SD_NO_CHECK_CRC7
| SD_RSP_LEN_0
;
372 trans_mode
= SD_TM_AUTO_WRITE_3
;
376 cfg2
|= SD_NO_CHECK_WAIT_CRC_TO
;
378 rtsx_pci_init_cmd(pcr
);
380 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_BYTE_CNT_L
, 0xFF, 0x00);
381 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_BYTE_CNT_H
, 0xFF, 0x02);
382 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_BLOCK_CNT_L
,
383 0xFF, (u8
)data
->blocks
);
384 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_BLOCK_CNT_H
,
385 0xFF, (u8
)(data
->blocks
>> 8));
387 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, IRQSTAT0
,
388 DMA_DONE_INT
, DMA_DONE_INT
);
389 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, DMATC3
,
390 0xFF, (u8
)(data_len
>> 24));
391 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, DMATC2
,
392 0xFF, (u8
)(data_len
>> 16));
393 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, DMATC1
,
394 0xFF, (u8
)(data_len
>> 8));
395 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, DMATC0
, 0xFF, (u8
)data_len
);
397 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, DMACTL
,
398 0x03 | DMA_PACK_SIZE_MASK
,
399 DMA_DIR_FROM_CARD
| DMA_EN
| DMA_512
);
401 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, DMACTL
,
402 0x03 | DMA_PACK_SIZE_MASK
,
403 DMA_DIR_TO_CARD
| DMA_EN
| DMA_512
);
406 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, CARD_DATA_SOURCE
,
409 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_CFG2
, 0xFF, cfg2
);
410 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_TRANSFER
, 0xFF,
411 trans_mode
| SD_TRANSFER_START
);
412 rtsx_pci_add_cmd(pcr
, CHECK_REG_CMD
, SD_TRANSFER
,
413 SD_TRANSFER_END
, SD_TRANSFER_END
);
415 rtsx_pci_send_cmd_no_wait(pcr
);
417 err
= rtsx_pci_transfer_data(pcr
, data
->sg
, data
->sg_len
, read
, 10000);
419 sd_clear_error(host
);
426 static inline void sd_enable_initial_mode(struct realtek_pci_sdmmc
*host
)
428 rtsx_pci_write_register(host
->pcr
, SD_CFG1
,
429 SD_CLK_DIVIDE_MASK
, SD_CLK_DIVIDE_128
);
432 static inline void sd_disable_initial_mode(struct realtek_pci_sdmmc
*host
)
434 rtsx_pci_write_register(host
->pcr
, SD_CFG1
,
435 SD_CLK_DIVIDE_MASK
, SD_CLK_DIVIDE_0
);
438 static void sd_normal_rw(struct realtek_pci_sdmmc
*host
,
439 struct mmc_request
*mrq
)
441 struct mmc_command
*cmd
= mrq
->cmd
;
442 struct mmc_data
*data
= mrq
->data
;
445 _cmd
[0] = 0x40 | (u8
)cmd
->opcode
;
446 put_unaligned_be32(cmd
->arg
, (u32
*)(&_cmd
[1]));
448 buf
= kzalloc(data
->blksz
, GFP_NOIO
);
450 cmd
->error
= -ENOMEM
;
454 if (data
->flags
& MMC_DATA_READ
) {
455 if (host
->initial_mode
)
456 sd_disable_initial_mode(host
);
458 cmd
->error
= sd_read_data(host
, _cmd
, (u16
)data
->blksz
, buf
,
461 if (host
->initial_mode
)
462 sd_enable_initial_mode(host
);
464 sg_copy_from_buffer(data
->sg
, data
->sg_len
, buf
, data
->blksz
);
466 sg_copy_to_buffer(data
->sg
, data
->sg_len
, buf
, data
->blksz
);
468 cmd
->error
= sd_write_data(host
, _cmd
, (u16
)data
->blksz
, buf
,
475 static int sd_change_phase(struct realtek_pci_sdmmc
*host
, u8 sample_point
)
477 struct rtsx_pcr
*pcr
= host
->pcr
;
480 dev_dbg(sdmmc_dev(host
), "%s: sample_point = %d\n",
481 __func__
, sample_point
);
483 rtsx_pci_init_cmd(pcr
);
485 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, CLK_CTL
, CHANGE_CLK
, CHANGE_CLK
);
486 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_VPRX_CTL
, 0x1F, sample_point
);
487 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_VPCLK0_CTL
, PHASE_NOT_RESET
, 0);
488 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_VPCLK0_CTL
,
489 PHASE_NOT_RESET
, PHASE_NOT_RESET
);
490 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, CLK_CTL
, CHANGE_CLK
, 0);
491 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_CFG1
, SD_ASYNC_FIFO_NOT_RST
, 0);
493 err
= rtsx_pci_send_cmd(pcr
, 100);
500 static u8
sd_search_final_phase(struct realtek_pci_sdmmc
*host
, u32 phase_map
)
502 struct timing_phase_path path
[MAX_PHASE
+ 1];
503 int i
, j
, cont_path_cnt
;
504 int new_block
, max_len
, final_path_idx
;
505 u8 final_phase
= 0xFF;
507 /* Parse phase_map, take it as a bit-ring */
511 for (i
= 0; i
< MAX_PHASE
+ 1; i
++) {
512 if (phase_map
& (1 << i
)) {
524 /* Calculate path length and middle point */
525 int idx
= cont_path_cnt
- 1;
527 path
[idx
].end
- path
[idx
].start
+ 1;
529 path
[idx
].start
+ path
[idx
].len
/ 2;
534 if (cont_path_cnt
== 0) {
535 dev_dbg(sdmmc_dev(host
), "No continuous phase path\n");
538 /* Calculate last continuous path length and middle point */
539 int idx
= cont_path_cnt
- 1;
540 path
[idx
].len
= path
[idx
].end
- path
[idx
].start
+ 1;
541 path
[idx
].mid
= path
[idx
].start
+ path
[idx
].len
/ 2;
544 /* Connect the first and last continuous paths if they are adjacent */
545 if (!path
[0].start
&& (path
[cont_path_cnt
- 1].end
== MAX_PHASE
)) {
546 /* Using negative index */
547 path
[0].start
= path
[cont_path_cnt
- 1].start
- MAX_PHASE
- 1;
548 path
[0].len
+= path
[cont_path_cnt
- 1].len
;
549 path
[0].mid
= path
[0].start
+ path
[0].len
/ 2;
550 /* Convert negative middle point index to positive one */
552 path
[0].mid
+= MAX_PHASE
+ 1;
556 /* Choose the longest continuous phase path */
560 for (i
= 0; i
< cont_path_cnt
; i
++) {
561 if (path
[i
].len
> max_len
) {
562 max_len
= path
[i
].len
;
563 final_phase
= (u8
)path
[i
].mid
;
567 dev_dbg(sdmmc_dev(host
), "path[%d].start = %d\n",
569 dev_dbg(sdmmc_dev(host
), "path[%d].end = %d\n",
571 dev_dbg(sdmmc_dev(host
), "path[%d].len = %d\n",
573 dev_dbg(sdmmc_dev(host
), "path[%d].mid = %d\n",
578 dev_dbg(sdmmc_dev(host
), "Final chosen phase: %d\n", final_phase
);
582 static void sd_wait_data_idle(struct realtek_pci_sdmmc
*host
)
587 for (i
= 0; i
< 100; i
++) {
588 err
= rtsx_pci_read_register(host
->pcr
, SD_DATA_STATE
, &val
);
589 if (val
& SD_DATA_IDLE
)
596 static int sd_tuning_rx_cmd(struct realtek_pci_sdmmc
*host
,
597 u8 opcode
, u8 sample_point
)
602 err
= sd_change_phase(host
, sample_point
);
606 cmd
[0] = 0x40 | opcode
;
607 err
= sd_read_data(host
, cmd
, 0x40, NULL
, 0, 100);
609 /* Wait till SD DATA IDLE */
610 sd_wait_data_idle(host
);
611 sd_clear_error(host
);
618 static int sd_tuning_phase(struct realtek_pci_sdmmc
*host
,
619 u8 opcode
, u32
*phase_map
)
622 u32 raw_phase_map
= 0;
624 for (i
= MAX_PHASE
; i
>= 0; i
--) {
625 err
= sd_tuning_rx_cmd(host
, opcode
, (u8
)i
);
627 raw_phase_map
|= 1 << i
;
631 *phase_map
= raw_phase_map
;
636 static int sd_tuning_rx(struct realtek_pci_sdmmc
*host
, u8 opcode
)
639 u32 raw_phase_map
[RX_TUNING_CNT
] = {0}, phase_map
;
642 for (i
= 0; i
< RX_TUNING_CNT
; i
++) {
643 err
= sd_tuning_phase(host
, opcode
, &(raw_phase_map
[i
]));
647 if (raw_phase_map
[i
] == 0)
651 phase_map
= 0xFFFFFFFF;
652 for (i
= 0; i
< RX_TUNING_CNT
; i
++) {
653 dev_dbg(sdmmc_dev(host
), "RX raw_phase_map[%d] = 0x%08x\n",
654 i
, raw_phase_map
[i
]);
655 phase_map
&= raw_phase_map
[i
];
657 dev_dbg(sdmmc_dev(host
), "RX phase_map = 0x%08x\n", phase_map
);
660 final_phase
= sd_search_final_phase(host
, phase_map
);
661 if (final_phase
== 0xFF)
664 err
= sd_change_phase(host
, final_phase
);
674 static void sdmmc_request(struct mmc_host
*mmc
, struct mmc_request
*mrq
)
676 struct realtek_pci_sdmmc
*host
= mmc_priv(mmc
);
677 struct rtsx_pcr
*pcr
= host
->pcr
;
678 struct mmc_command
*cmd
= mrq
->cmd
;
679 struct mmc_data
*data
= mrq
->data
;
680 unsigned int data_size
= 0;
684 cmd
->error
= -ENOMEDIUM
;
688 err
= rtsx_pci_card_exclusive_check(host
->pcr
, RTSX_SD_CARD
);
694 mutex_lock(&pcr
->pcr_mutex
);
696 rtsx_pci_start_run(pcr
);
698 rtsx_pci_switch_clock(pcr
, host
->clock
, host
->ssc_depth
,
699 host
->initial_mode
, host
->double_clk
, host
->vpclk
);
700 rtsx_pci_write_register(pcr
, CARD_SELECT
, 0x07, SD_MOD_SEL
);
701 rtsx_pci_write_register(pcr
, CARD_SHARE_MODE
,
702 CARD_SHARE_MASK
, CARD_SHARE_48_SD
);
704 mutex_lock(&host
->host_mutex
);
706 mutex_unlock(&host
->host_mutex
);
709 data_size
= data
->blocks
* data
->blksz
;
711 if (!data_size
|| mmc_op_multi(cmd
->opcode
) ||
712 (cmd
->opcode
== MMC_READ_SINGLE_BLOCK
) ||
713 (cmd
->opcode
== MMC_WRITE_BLOCK
)) {
714 sd_send_cmd_get_rsp(host
, cmd
);
716 if (!cmd
->error
&& data_size
) {
717 sd_rw_multi(host
, mrq
);
719 if (mmc_op_multi(cmd
->opcode
) && mrq
->stop
)
720 sd_send_cmd_get_rsp(host
, mrq
->stop
);
723 sd_normal_rw(host
, mrq
);
727 if (cmd
->error
|| data
->error
)
728 data
->bytes_xfered
= 0;
730 data
->bytes_xfered
= data
->blocks
* data
->blksz
;
733 mutex_unlock(&pcr
->pcr_mutex
);
737 dev_dbg(sdmmc_dev(host
), "cmd->error = %d\n", cmd
->error
);
739 mutex_lock(&host
->host_mutex
);
741 mutex_unlock(&host
->host_mutex
);
743 mmc_request_done(mmc
, mrq
);
746 static int sd_set_bus_width(struct realtek_pci_sdmmc
*host
,
747 unsigned char bus_width
)
751 [MMC_BUS_WIDTH_1
] = SD_BUS_WIDTH_1BIT
,
752 [MMC_BUS_WIDTH_4
] = SD_BUS_WIDTH_4BIT
,
753 [MMC_BUS_WIDTH_8
] = SD_BUS_WIDTH_8BIT
,
756 if (bus_width
<= MMC_BUS_WIDTH_8
)
757 err
= rtsx_pci_write_register(host
->pcr
, SD_CFG1
,
758 0x03, width
[bus_width
]);
763 static int sd_power_on(struct realtek_pci_sdmmc
*host
)
765 struct rtsx_pcr
*pcr
= host
->pcr
;
768 rtsx_pci_init_cmd(pcr
);
769 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, CARD_SELECT
, 0x07, SD_MOD_SEL
);
770 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, CARD_SHARE_MODE
,
771 CARD_SHARE_MASK
, CARD_SHARE_48_SD
);
772 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, CARD_CLK_EN
,
773 SD_CLK_EN
, SD_CLK_EN
);
774 err
= rtsx_pci_send_cmd(pcr
, 100);
778 err
= rtsx_pci_card_pull_ctl_enable(pcr
, RTSX_SD_CARD
);
782 err
= rtsx_pci_card_power_on(pcr
, RTSX_SD_CARD
);
786 err
= rtsx_pci_write_register(pcr
, CARD_OE
, SD_OUTPUT_EN
, SD_OUTPUT_EN
);
793 static int sd_power_off(struct realtek_pci_sdmmc
*host
)
795 struct rtsx_pcr
*pcr
= host
->pcr
;
798 rtsx_pci_init_cmd(pcr
);
800 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, CARD_CLK_EN
, SD_CLK_EN
, 0);
801 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, CARD_OE
, SD_OUTPUT_EN
, 0);
803 err
= rtsx_pci_send_cmd(pcr
, 100);
807 err
= rtsx_pci_card_power_off(pcr
, RTSX_SD_CARD
);
811 return rtsx_pci_card_pull_ctl_disable(pcr
, RTSX_SD_CARD
);
814 static int sd_set_power_mode(struct realtek_pci_sdmmc
*host
,
815 unsigned char power_mode
)
819 if (power_mode
== MMC_POWER_OFF
)
820 err
= sd_power_off(host
);
822 err
= sd_power_on(host
);
827 static int sd_set_timing(struct realtek_pci_sdmmc
*host
,
828 unsigned char timing
, bool *ddr_mode
)
830 struct rtsx_pcr
*pcr
= host
->pcr
;
835 rtsx_pci_init_cmd(pcr
);
838 case MMC_TIMING_UHS_SDR104
:
839 case MMC_TIMING_UHS_SDR50
:
840 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_CFG1
,
841 0x0C | SD_ASYNC_FIFO_NOT_RST
,
842 SD_30_MODE
| SD_ASYNC_FIFO_NOT_RST
);
843 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, CLK_CTL
,
844 CLK_LOW_FREQ
, CLK_LOW_FREQ
);
845 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, CARD_CLK_SOURCE
, 0xFF,
846 CRC_VAR_CLK0
| SD30_FIX_CLK
| SAMPLE_VAR_CLK1
);
847 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, CLK_CTL
, CLK_LOW_FREQ
, 0);
850 case MMC_TIMING_UHS_DDR50
:
853 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_CFG1
,
854 0x0C | SD_ASYNC_FIFO_NOT_RST
,
855 SD_DDR_MODE
| SD_ASYNC_FIFO_NOT_RST
);
856 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, CLK_CTL
,
857 CLK_LOW_FREQ
, CLK_LOW_FREQ
);
858 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, CARD_CLK_SOURCE
, 0xFF,
859 CRC_VAR_CLK0
| SD30_FIX_CLK
| SAMPLE_VAR_CLK1
);
860 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, CLK_CTL
, CLK_LOW_FREQ
, 0);
861 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_PUSH_POINT_CTL
,
862 DDR_VAR_TX_CMD_DAT
, DDR_VAR_TX_CMD_DAT
);
863 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_SAMPLE_POINT_CTL
,
864 DDR_VAR_RX_DAT
| DDR_VAR_RX_CMD
,
865 DDR_VAR_RX_DAT
| DDR_VAR_RX_CMD
);
868 case MMC_TIMING_MMC_HS
:
869 case MMC_TIMING_SD_HS
:
870 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_CFG1
,
872 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, CLK_CTL
,
873 CLK_LOW_FREQ
, CLK_LOW_FREQ
);
874 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, CARD_CLK_SOURCE
, 0xFF,
875 CRC_FIX_CLK
| SD30_VAR_CLK0
| SAMPLE_VAR_CLK1
);
876 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, CLK_CTL
, CLK_LOW_FREQ
, 0);
877 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_PUSH_POINT_CTL
,
878 SD20_TX_SEL_MASK
, SD20_TX_14_AHEAD
);
879 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_SAMPLE_POINT_CTL
,
880 SD20_RX_SEL_MASK
, SD20_RX_14_DELAY
);
884 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
,
885 SD_CFG1
, 0x0C, SD_20_MODE
);
886 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, CLK_CTL
,
887 CLK_LOW_FREQ
, CLK_LOW_FREQ
);
888 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, CARD_CLK_SOURCE
, 0xFF,
889 CRC_FIX_CLK
| SD30_VAR_CLK0
| SAMPLE_VAR_CLK1
);
890 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, CLK_CTL
, CLK_LOW_FREQ
, 0);
891 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
,
892 SD_PUSH_POINT_CTL
, 0xFF, 0);
893 rtsx_pci_add_cmd(pcr
, WRITE_REG_CMD
, SD_SAMPLE_POINT_CTL
,
894 SD20_RX_SEL_MASK
, SD20_RX_POS_EDGE
);
898 err
= rtsx_pci_send_cmd(pcr
, 100);
903 static void sdmmc_set_ios(struct mmc_host
*mmc
, struct mmc_ios
*ios
)
905 struct realtek_pci_sdmmc
*host
= mmc_priv(mmc
);
906 struct rtsx_pcr
*pcr
= host
->pcr
;
911 if (rtsx_pci_card_exclusive_check(host
->pcr
, RTSX_SD_CARD
))
914 mutex_lock(&pcr
->pcr_mutex
);
916 rtsx_pci_start_run(pcr
);
918 sd_set_bus_width(host
, ios
->bus_width
);
919 sd_set_power_mode(host
, ios
->power_mode
);
920 sd_set_timing(host
, ios
->timing
, &host
->ddr_mode
);
923 host
->double_clk
= true;
925 switch (ios
->timing
) {
926 case MMC_TIMING_UHS_SDR104
:
927 case MMC_TIMING_UHS_SDR50
:
928 host
->ssc_depth
= RTSX_SSC_DEPTH_2M
;
930 host
->double_clk
= false;
932 case MMC_TIMING_UHS_DDR50
:
933 case MMC_TIMING_UHS_SDR25
:
934 host
->ssc_depth
= RTSX_SSC_DEPTH_1M
;
937 host
->ssc_depth
= RTSX_SSC_DEPTH_500K
;
941 host
->initial_mode
= (ios
->clock
<= 1000000) ? true : false;
943 host
->clock
= ios
->clock
;
944 rtsx_pci_switch_clock(pcr
, ios
->clock
, host
->ssc_depth
,
945 host
->initial_mode
, host
->double_clk
, host
->vpclk
);
947 mutex_unlock(&pcr
->pcr_mutex
);
950 static int sdmmc_get_ro(struct mmc_host
*mmc
)
952 struct realtek_pci_sdmmc
*host
= mmc_priv(mmc
);
953 struct rtsx_pcr
*pcr
= host
->pcr
;
960 mutex_lock(&pcr
->pcr_mutex
);
962 rtsx_pci_start_run(pcr
);
964 /* Check SD mechanical write-protect switch */
965 val
= rtsx_pci_readl(pcr
, RTSX_BIPR
);
966 dev_dbg(sdmmc_dev(host
), "%s: RTSX_BIPR = 0x%08x\n", __func__
, val
);
967 if (val
& SD_WRITE_PROTECT
)
970 mutex_unlock(&pcr
->pcr_mutex
);
975 static int sdmmc_get_cd(struct mmc_host
*mmc
)
977 struct realtek_pci_sdmmc
*host
= mmc_priv(mmc
);
978 struct rtsx_pcr
*pcr
= host
->pcr
;
985 mutex_lock(&pcr
->pcr_mutex
);
987 rtsx_pci_start_run(pcr
);
989 /* Check SD card detect */
990 val
= rtsx_pci_card_exist(pcr
);
991 dev_dbg(sdmmc_dev(host
), "%s: RTSX_BIPR = 0x%08x\n", __func__
, val
);
995 mutex_unlock(&pcr
->pcr_mutex
);
1000 static int sd_wait_voltage_stable_1(struct realtek_pci_sdmmc
*host
)
1002 struct rtsx_pcr
*pcr
= host
->pcr
;
1006 /* Reference to Signal Voltage Switch Sequence in SD spec.
1007 * Wait for a period of time so that the card can drive SD_CMD and
1008 * SD_DAT[3:0] to low after sending back CMD11 response.
1012 /* SD_CMD, SD_DAT[3:0] should be driven to low by card;
1013 * If either one of SD_CMD,SD_DAT[3:0] is not low,
1014 * abort the voltage switch sequence;
1016 err
= rtsx_pci_read_register(pcr
, SD_BUS_STAT
, &stat
);
1020 if (stat
& (SD_CMD_STATUS
| SD_DAT3_STATUS
| SD_DAT2_STATUS
|
1021 SD_DAT1_STATUS
| SD_DAT0_STATUS
))
1024 /* Stop toggle SD clock */
1025 err
= rtsx_pci_write_register(pcr
, SD_BUS_STAT
,
1026 0xFF, SD_CLK_FORCE_STOP
);
1033 static int sd_wait_voltage_stable_2(struct realtek_pci_sdmmc
*host
)
1035 struct rtsx_pcr
*pcr
= host
->pcr
;
1039 /* Wait 1.8V output of voltage regulator in card stable */
1042 /* Toggle SD clock again */
1043 err
= rtsx_pci_write_register(pcr
, SD_BUS_STAT
, 0xFF, SD_CLK_TOGGLE_EN
);
1047 /* Wait for a period of time so that the card can drive
1048 * SD_DAT[3:0] to high at 1.8V
1052 /* SD_CMD, SD_DAT[3:0] should be pulled high by host */
1053 err
= rtsx_pci_read_register(pcr
, SD_BUS_STAT
, &stat
);
1057 mask
= SD_CMD_STATUS
| SD_DAT3_STATUS
| SD_DAT2_STATUS
|
1058 SD_DAT1_STATUS
| SD_DAT0_STATUS
;
1059 val
= SD_CMD_STATUS
| SD_DAT3_STATUS
| SD_DAT2_STATUS
|
1060 SD_DAT1_STATUS
| SD_DAT0_STATUS
;
1061 if ((stat
& mask
) != val
) {
1062 dev_dbg(sdmmc_dev(host
),
1063 "%s: SD_BUS_STAT = 0x%x\n", __func__
, stat
);
1064 rtsx_pci_write_register(pcr
, SD_BUS_STAT
,
1065 SD_CLK_TOGGLE_EN
| SD_CLK_FORCE_STOP
, 0);
1066 rtsx_pci_write_register(pcr
, CARD_CLK_EN
, 0xFF, 0);
1073 static int sdmmc_switch_voltage(struct mmc_host
*mmc
, struct mmc_ios
*ios
)
1075 struct realtek_pci_sdmmc
*host
= mmc_priv(mmc
);
1076 struct rtsx_pcr
*pcr
= host
->pcr
;
1080 dev_dbg(sdmmc_dev(host
), "%s: signal_voltage = %d\n",
1081 __func__
, ios
->signal_voltage
);
1086 err
= rtsx_pci_card_exclusive_check(host
->pcr
, RTSX_SD_CARD
);
1090 mutex_lock(&pcr
->pcr_mutex
);
1092 rtsx_pci_start_run(pcr
);
1094 if (ios
->signal_voltage
== MMC_SIGNAL_VOLTAGE_330
)
1095 voltage
= OUTPUT_3V3
;
1097 voltage
= OUTPUT_1V8
;
1099 if (voltage
== OUTPUT_1V8
) {
1100 err
= sd_wait_voltage_stable_1(host
);
1105 err
= rtsx_pci_switch_output_voltage(pcr
, voltage
);
1109 if (voltage
== OUTPUT_1V8
) {
1110 err
= sd_wait_voltage_stable_2(host
);
1115 /* Stop toggle SD clock in idle */
1116 err
= rtsx_pci_write_register(pcr
, SD_BUS_STAT
,
1117 SD_CLK_TOGGLE_EN
| SD_CLK_FORCE_STOP
, 0);
1120 mutex_unlock(&pcr
->pcr_mutex
);
1125 static int sdmmc_execute_tuning(struct mmc_host
*mmc
, u32 opcode
)
1127 struct realtek_pci_sdmmc
*host
= mmc_priv(mmc
);
1128 struct rtsx_pcr
*pcr
= host
->pcr
;
1134 err
= rtsx_pci_card_exclusive_check(host
->pcr
, RTSX_SD_CARD
);
1138 mutex_lock(&pcr
->pcr_mutex
);
1140 rtsx_pci_start_run(pcr
);
1142 if (!host
->ddr_mode
)
1143 err
= sd_tuning_rx(host
, MMC_SEND_TUNING_BLOCK
);
1145 mutex_unlock(&pcr
->pcr_mutex
);
1150 static const struct mmc_host_ops realtek_pci_sdmmc_ops
= {
1151 .request
= sdmmc_request
,
1152 .set_ios
= sdmmc_set_ios
,
1153 .get_ro
= sdmmc_get_ro
,
1154 .get_cd
= sdmmc_get_cd
,
1155 .start_signal_voltage_switch
= sdmmc_switch_voltage
,
1156 .execute_tuning
= sdmmc_execute_tuning
,
1160 static int rtsx_pci_sdmmc_suspend(struct platform_device
*pdev
,
1163 struct realtek_pci_sdmmc
*host
= platform_get_drvdata(pdev
);
1164 struct mmc_host
*mmc
= host
->mmc
;
1167 dev_dbg(sdmmc_dev(host
), "--> %s\n", __func__
);
1169 err
= mmc_suspend_host(mmc
);
1176 static int rtsx_pci_sdmmc_resume(struct platform_device
*pdev
)
1178 struct realtek_pci_sdmmc
*host
= platform_get_drvdata(pdev
);
1179 struct mmc_host
*mmc
= host
->mmc
;
1181 dev_dbg(sdmmc_dev(host
), "--> %s\n", __func__
);
1183 return mmc_resume_host(mmc
);
1185 #else /* CONFIG_PM */
1186 #define rtsx_pci_sdmmc_suspend NULL
1187 #define rtsx_pci_sdmmc_resume NULL
1188 #endif /* CONFIG_PM */
1190 static void init_extra_caps(struct realtek_pci_sdmmc
*host
)
1192 struct mmc_host
*mmc
= host
->mmc
;
1193 struct rtsx_pcr
*pcr
= host
->pcr
;
1195 dev_dbg(sdmmc_dev(host
), "pcr->extra_caps = 0x%x\n", pcr
->extra_caps
);
1197 if (pcr
->extra_caps
& EXTRA_CAPS_SD_SDR50
)
1198 mmc
->caps
|= MMC_CAP_UHS_SDR50
;
1199 if (pcr
->extra_caps
& EXTRA_CAPS_SD_SDR104
)
1200 mmc
->caps
|= MMC_CAP_UHS_SDR104
;
1201 if (pcr
->extra_caps
& EXTRA_CAPS_SD_DDR50
)
1202 mmc
->caps
|= MMC_CAP_UHS_DDR50
;
1203 if (pcr
->extra_caps
& EXTRA_CAPS_MMC_HSDDR
)
1204 mmc
->caps
|= MMC_CAP_1_8V_DDR
;
1205 if (pcr
->extra_caps
& EXTRA_CAPS_MMC_8BIT
)
1206 mmc
->caps
|= MMC_CAP_8_BIT_DATA
;
1209 static void realtek_init_host(struct realtek_pci_sdmmc
*host
)
1211 struct mmc_host
*mmc
= host
->mmc
;
1213 mmc
->f_min
= 250000;
1214 mmc
->f_max
= 208000000;
1215 mmc
->ocr_avail
= MMC_VDD_32_33
| MMC_VDD_33_34
| MMC_VDD_165_195
;
1216 mmc
->caps
= MMC_CAP_4_BIT_DATA
| MMC_CAP_SD_HIGHSPEED
|
1217 MMC_CAP_MMC_HIGHSPEED
| MMC_CAP_BUS_WIDTH_TEST
|
1218 MMC_CAP_UHS_SDR12
| MMC_CAP_UHS_SDR25
;
1219 mmc
->max_current_330
= 400;
1220 mmc
->max_current_180
= 800;
1221 mmc
->ops
= &realtek_pci_sdmmc_ops
;
1223 init_extra_caps(host
);
1225 mmc
->max_segs
= 256;
1226 mmc
->max_seg_size
= 65536;
1227 mmc
->max_blk_size
= 512;
1228 mmc
->max_blk_count
= 65535;
1229 mmc
->max_req_size
= 524288;
1232 static void rtsx_pci_sdmmc_card_event(struct platform_device
*pdev
)
1234 struct realtek_pci_sdmmc
*host
= platform_get_drvdata(pdev
);
1236 mmc_detect_change(host
->mmc
, 0);
1239 static int rtsx_pci_sdmmc_drv_probe(struct platform_device
*pdev
)
1241 struct mmc_host
*mmc
;
1242 struct realtek_pci_sdmmc
*host
;
1243 struct rtsx_pcr
*pcr
;
1244 struct pcr_handle
*handle
= pdev
->dev
.platform_data
;
1253 dev_dbg(&(pdev
->dev
), ": Realtek PCI-E SDMMC controller found\n");
1255 mmc
= mmc_alloc_host(sizeof(*host
), &pdev
->dev
);
1259 host
= mmc_priv(mmc
);
1263 platform_set_drvdata(pdev
, host
);
1264 pcr
->slots
[RTSX_SD_CARD
].p_dev
= pdev
;
1265 pcr
->slots
[RTSX_SD_CARD
].card_event
= rtsx_pci_sdmmc_card_event
;
1267 mutex_init(&host
->host_mutex
);
1269 realtek_init_host(host
);
1276 static int rtsx_pci_sdmmc_drv_remove(struct platform_device
*pdev
)
1278 struct realtek_pci_sdmmc
*host
= platform_get_drvdata(pdev
);
1279 struct rtsx_pcr
*pcr
;
1280 struct mmc_host
*mmc
;
1286 pcr
->slots
[RTSX_SD_CARD
].p_dev
= NULL
;
1287 pcr
->slots
[RTSX_SD_CARD
].card_event
= NULL
;
1291 mutex_lock(&host
->host_mutex
);
1293 dev_dbg(&(pdev
->dev
),
1294 "%s: Controller removed during transfer\n",
1297 rtsx_pci_complete_unfinished_transfer(pcr
);
1299 host
->mrq
->cmd
->error
= -ENOMEDIUM
;
1300 if (host
->mrq
->stop
)
1301 host
->mrq
->stop
->error
= -ENOMEDIUM
;
1302 mmc_request_done(mmc
, host
->mrq
);
1304 mutex_unlock(&host
->host_mutex
);
1306 mmc_remove_host(mmc
);
1309 platform_set_drvdata(pdev
, NULL
);
1311 dev_dbg(&(pdev
->dev
),
1312 ": Realtek PCI-E SDMMC controller has been removed\n");
1317 static struct platform_device_id rtsx_pci_sdmmc_ids
[] = {
1319 .name
= DRV_NAME_RTSX_PCI_SDMMC
,
1324 MODULE_DEVICE_TABLE(platform
, rtsx_pci_sdmmc_ids
);
1326 static struct platform_driver rtsx_pci_sdmmc_driver
= {
1327 .probe
= rtsx_pci_sdmmc_drv_probe
,
1328 .remove
= rtsx_pci_sdmmc_drv_remove
,
1329 .id_table
= rtsx_pci_sdmmc_ids
,
1330 .suspend
= rtsx_pci_sdmmc_suspend
,
1331 .resume
= rtsx_pci_sdmmc_resume
,
1333 .owner
= THIS_MODULE
,
1334 .name
= DRV_NAME_RTSX_PCI_SDMMC
,
1337 module_platform_driver(rtsx_pci_sdmmc_driver
);
1339 MODULE_LICENSE("GPL");
1340 MODULE_AUTHOR("Wei WANG <wei_wang@realsil.com.cn>");
1341 MODULE_DESCRIPTION("Realtek PCI-E SD/MMC Card Host Driver");