1 /* Driver for Realtek USB card reader
3 * Copyright(c) 2009-2013 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 version 2
7 * as published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, see <http://www.gnu.org/licenses/>.
18 * Roger Tseng <rogerable@realtek.com>
20 #include <linux/module.h>
21 #include <linux/slab.h>
22 #include <linux/mutex.h>
23 #include <linux/usb.h>
24 #include <linux/platform_device.h>
25 #include <linux/mfd/core.h>
26 #include <linux/mfd/rtsx_usb.h>
28 static int polling_pipe = 1;
29 module_param(polling_pipe, int, S_IRUGO | S_IWUSR);
30 MODULE_PARM_DESC(polling_pipe, "polling pipe (0: ctl, 1: bulk)");
32 static const struct mfd_cell rtsx_usb_cells[] = {
33 [RTSX_USB_SD_CARD] = {
34 .name = "rtsx_usb_sdmmc",
37 [RTSX_USB_MS_CARD] = {
38 .name = "rtsx_usb_ms",
43 static void rtsx_usb_sg_timed_out(unsigned long data)
45 struct rtsx_ucr *ucr = (struct rtsx_ucr *)data;
47 dev_dbg(&ucr->pusb_intf->dev, "%s: sg transfer timed out", __func__);
48 usb_sg_cancel(&ucr->current_sg);
51 static int rtsx_usb_bulk_transfer_sglist(struct rtsx_ucr *ucr,
52 unsigned int pipe, struct scatterlist *sg, int num_sg,
53 unsigned int length, unsigned int *act_len, int timeout)
57 dev_dbg(&ucr->pusb_intf->dev, "%s: xfer %u bytes, %d entries\n",
58 __func__, length, num_sg);
59 ret = usb_sg_init(&ucr->current_sg, ucr->pusb_dev, pipe, 0,
60 sg, num_sg, length, GFP_NOIO);
64 ucr->sg_timer.expires = jiffies + msecs_to_jiffies(timeout);
65 add_timer(&ucr->sg_timer);
66 usb_sg_wait(&ucr->current_sg);
67 if (!del_timer_sync(&ucr->sg_timer))
70 ret = ucr->current_sg.status;
73 *act_len = ucr->current_sg.bytes;
78 int rtsx_usb_transfer_data(struct rtsx_ucr *ucr, unsigned int pipe,
79 void *buf, unsigned int len, int num_sg,
80 unsigned int *act_len, int timeout)
86 return rtsx_usb_bulk_transfer_sglist(ucr, pipe,
87 (struct scatterlist *)buf, num_sg, len, act_len,
90 return usb_bulk_msg(ucr->pusb_dev, pipe, buf, len, act_len,
93 EXPORT_SYMBOL_GPL(rtsx_usb_transfer_data);
95 static inline void rtsx_usb_seq_cmd_hdr(struct rtsx_ucr *ucr,
96 u16 addr, u16 len, u8 seq_type)
98 rtsx_usb_cmd_hdr_tag(ucr);
100 ucr->cmd_buf[PACKET_TYPE] = seq_type;
101 ucr->cmd_buf[5] = (u8)(len >> 8);
102 ucr->cmd_buf[6] = (u8)len;
103 ucr->cmd_buf[8] = (u8)(addr >> 8);
104 ucr->cmd_buf[9] = (u8)addr;
106 if (seq_type == SEQ_WRITE)
107 ucr->cmd_buf[STAGE_FLAG] = 0;
109 ucr->cmd_buf[STAGE_FLAG] = STAGE_R;
112 static int rtsx_usb_seq_write_register(struct rtsx_ucr *ucr,
113 u16 addr, u16 len, u8 *data)
115 u16 cmd_len = ALIGN(SEQ_WRITE_DATA_OFFSET + len, 4);
120 if (cmd_len > IOBUF_SIZE)
123 rtsx_usb_seq_cmd_hdr(ucr, addr, len, SEQ_WRITE);
124 memcpy(ucr->cmd_buf + SEQ_WRITE_DATA_OFFSET, data, len);
126 return rtsx_usb_transfer_data(ucr,
127 usb_sndbulkpipe(ucr->pusb_dev, EP_BULK_OUT),
128 ucr->cmd_buf, cmd_len, 0, NULL, 100);
131 static int rtsx_usb_seq_read_register(struct rtsx_ucr *ucr,
132 u16 addr, u16 len, u8 *data)
135 u16 rsp_len = round_down(len, 4);
136 u16 res_len = len - rsp_len;
141 /* 4-byte aligned part */
143 rtsx_usb_seq_cmd_hdr(ucr, addr, len, SEQ_READ);
144 ret = rtsx_usb_transfer_data(ucr,
145 usb_sndbulkpipe(ucr->pusb_dev, EP_BULK_OUT),
146 ucr->cmd_buf, 12, 0, NULL, 100);
150 ret = rtsx_usb_transfer_data(ucr,
151 usb_rcvbulkpipe(ucr->pusb_dev, EP_BULK_IN),
152 data, rsp_len, 0, NULL, 100);
158 for (i = 0; i < res_len; i++) {
159 ret = rtsx_usb_read_register(ucr, addr + rsp_len + i,
168 int rtsx_usb_read_ppbuf(struct rtsx_ucr *ucr, u8 *buf, int buf_len)
170 return rtsx_usb_seq_read_register(ucr, PPBUF_BASE2, (u16)buf_len, buf);
172 EXPORT_SYMBOL_GPL(rtsx_usb_read_ppbuf);
174 int rtsx_usb_write_ppbuf(struct rtsx_ucr *ucr, u8 *buf, int buf_len)
176 return rtsx_usb_seq_write_register(ucr, PPBUF_BASE2, (u16)buf_len, buf);
178 EXPORT_SYMBOL_GPL(rtsx_usb_write_ppbuf);
180 int rtsx_usb_ep0_write_register(struct rtsx_ucr *ucr, u16 addr,
185 addr |= EP0_WRITE_REG_CMD << EP0_OP_SHIFT;
186 value = swab16(addr);
187 index = mask | data << 8;
189 return usb_control_msg(ucr->pusb_dev,
190 usb_sndctrlpipe(ucr->pusb_dev, 0), RTSX_USB_REQ_REG_OP,
191 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
192 value, index, NULL, 0, 100);
194 EXPORT_SYMBOL_GPL(rtsx_usb_ep0_write_register);
196 int rtsx_usb_ep0_read_register(struct rtsx_ucr *ucr, u16 addr, u8 *data)
205 buf = kzalloc(sizeof(u8), GFP_KERNEL);
209 addr |= EP0_READ_REG_CMD << EP0_OP_SHIFT;
210 value = swab16(addr);
212 ret = usb_control_msg(ucr->pusb_dev,
213 usb_rcvctrlpipe(ucr->pusb_dev, 0), RTSX_USB_REQ_REG_OP,
214 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
215 value, 0, buf, 1, 100);
221 EXPORT_SYMBOL_GPL(rtsx_usb_ep0_read_register);
223 void rtsx_usb_add_cmd(struct rtsx_ucr *ucr, u8 cmd_type, u16 reg_addr,
228 if (ucr->cmd_idx < (IOBUF_SIZE - CMD_OFFSET) / 4) {
229 i = CMD_OFFSET + ucr->cmd_idx * 4;
231 ucr->cmd_buf[i++] = ((cmd_type & 0x03) << 6) |
232 (u8)((reg_addr >> 8) & 0x3F);
233 ucr->cmd_buf[i++] = (u8)reg_addr;
234 ucr->cmd_buf[i++] = mask;
235 ucr->cmd_buf[i++] = data;
240 EXPORT_SYMBOL_GPL(rtsx_usb_add_cmd);
242 int rtsx_usb_send_cmd(struct rtsx_ucr *ucr, u8 flag, int timeout)
246 ucr->cmd_buf[CNT_H] = (u8)(ucr->cmd_idx >> 8);
247 ucr->cmd_buf[CNT_L] = (u8)(ucr->cmd_idx);
248 ucr->cmd_buf[STAGE_FLAG] = flag;
250 ret = rtsx_usb_transfer_data(ucr,
251 usb_sndbulkpipe(ucr->pusb_dev, EP_BULK_OUT),
252 ucr->cmd_buf, ucr->cmd_idx * 4 + CMD_OFFSET,
255 rtsx_usb_clear_fsm_err(ucr);
261 EXPORT_SYMBOL_GPL(rtsx_usb_send_cmd);
263 int rtsx_usb_get_rsp(struct rtsx_ucr *ucr, int rsp_len, int timeout)
268 rsp_len = ALIGN(rsp_len, 4);
270 return rtsx_usb_transfer_data(ucr,
271 usb_rcvbulkpipe(ucr->pusb_dev, EP_BULK_IN),
272 ucr->rsp_buf, rsp_len, 0, NULL, timeout);
274 EXPORT_SYMBOL_GPL(rtsx_usb_get_rsp);
276 static int rtsx_usb_get_status_with_bulk(struct rtsx_ucr *ucr, u16 *status)
280 rtsx_usb_init_cmd(ucr);
281 rtsx_usb_add_cmd(ucr, READ_REG_CMD, CARD_EXIST, 0x00, 0x00);
282 rtsx_usb_add_cmd(ucr, READ_REG_CMD, OCPSTAT, 0x00, 0x00);
283 ret = rtsx_usb_send_cmd(ucr, MODE_CR, 100);
287 ret = rtsx_usb_get_rsp(ucr, 2, 100);
291 *status = ((ucr->rsp_buf[0] >> 2) & 0x0f) |
292 ((ucr->rsp_buf[1] & 0x03) << 4);
297 int rtsx_usb_get_card_status(struct rtsx_ucr *ucr, u16 *status)
305 if (polling_pipe == 0) {
306 buf = kzalloc(sizeof(u16), GFP_KERNEL);
310 ret = usb_control_msg(ucr->pusb_dev,
311 usb_rcvctrlpipe(ucr->pusb_dev, 0),
313 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
319 ret = rtsx_usb_get_status_with_bulk(ucr, status);
322 /* usb_control_msg may return positive when success */
328 EXPORT_SYMBOL_GPL(rtsx_usb_get_card_status);
330 static int rtsx_usb_write_phy_register(struct rtsx_ucr *ucr, u8 addr, u8 val)
332 dev_dbg(&ucr->pusb_intf->dev, "Write 0x%x to phy register 0x%x\n",
335 rtsx_usb_init_cmd(ucr);
337 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, HS_VSTAIN, 0xFF, val);
338 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, HS_VCONTROL, 0xFF, addr & 0x0F);
339 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00);
340 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00);
341 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x01);
342 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, HS_VCONTROL,
343 0xFF, (addr >> 4) & 0x0F);
344 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00);
345 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00);
346 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x01);
348 return rtsx_usb_send_cmd(ucr, MODE_C, 100);
351 int rtsx_usb_write_register(struct rtsx_ucr *ucr, u16 addr, u8 mask, u8 data)
353 rtsx_usb_init_cmd(ucr);
354 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, addr, mask, data);
355 return rtsx_usb_send_cmd(ucr, MODE_C, 100);
357 EXPORT_SYMBOL_GPL(rtsx_usb_write_register);
359 int rtsx_usb_read_register(struct rtsx_ucr *ucr, u16 addr, u8 *data)
366 rtsx_usb_init_cmd(ucr);
367 rtsx_usb_add_cmd(ucr, READ_REG_CMD, addr, 0, 0);
368 ret = rtsx_usb_send_cmd(ucr, MODE_CR, 100);
372 ret = rtsx_usb_get_rsp(ucr, 1, 100);
377 *data = ucr->rsp_buf[0];
381 EXPORT_SYMBOL_GPL(rtsx_usb_read_register);
383 static inline u8 double_ssc_depth(u8 depth)
385 return (depth > 1) ? (depth - 1) : depth;
388 static u8 revise_ssc_depth(u8 ssc_depth, u8 div)
390 if (div > CLK_DIV_1) {
391 if (ssc_depth > div - 1)
392 ssc_depth -= (div - 1);
394 ssc_depth = SSC_DEPTH_2M;
400 int rtsx_usb_switch_clock(struct rtsx_ucr *ucr, unsigned int card_clock,
401 u8 ssc_depth, bool initial_mode, bool double_clk, bool vpclk)
404 u8 n, clk_divider, mcu_cnt, div;
412 /* We use 250k(around) here, in initial stage */
413 clk_divider = SD_CLK_DIVIDE_128;
414 card_clock = 30000000;
416 clk_divider = SD_CLK_DIVIDE_0;
419 ret = rtsx_usb_write_register(ucr, SD_CFG1,
420 SD_CLK_DIVIDE_MASK, clk_divider);
424 card_clock /= 1000000;
425 dev_dbg(&ucr->pusb_intf->dev,
426 "Switch card clock to %dMHz\n", card_clock);
428 if (!initial_mode && double_clk)
430 dev_dbg(&ucr->pusb_intf->dev,
431 "Internal SSC clock: %dMHz (cur_clk = %d)\n",
432 card_clock, ucr->cur_clk);
434 if (card_clock == ucr->cur_clk)
437 /* Converting clock value into internal settings: n and div */
439 if ((card_clock <= 2) || (n > MAX_DIV_N))
442 mcu_cnt = 60/card_clock + 3;
446 /* Make sure that the SSC clock div_n is not less than MIN_DIV_N */
449 while (n < MIN_DIV_N && div < CLK_DIV_4) {
453 dev_dbg(&ucr->pusb_intf->dev, "n = %d, div = %d\n", n, div);
456 ssc_depth = double_ssc_depth(ssc_depth);
458 ssc_depth = revise_ssc_depth(ssc_depth, div);
459 dev_dbg(&ucr->pusb_intf->dev, "ssc_depth = %d\n", ssc_depth);
461 rtsx_usb_init_cmd(ucr);
462 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CLK_DIV, CLK_CHANGE, CLK_CHANGE);
463 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CLK_DIV,
464 0x3F, (div << 4) | mcu_cnt);
465 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, SSC_CTL1, SSC_RSTB, 0);
466 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, SSC_CTL2,
467 SSC_DEPTH_MASK, ssc_depth);
468 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, SSC_DIV_N_0, 0xFF, n);
469 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, SSC_CTL1, SSC_RSTB, SSC_RSTB);
471 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, SD_VPCLK0_CTL,
473 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, SD_VPCLK0_CTL,
474 PHASE_NOT_RESET, PHASE_NOT_RESET);
477 ret = rtsx_usb_send_cmd(ucr, MODE_C, 2000);
481 ret = rtsx_usb_write_register(ucr, SSC_CTL1, 0xff,
482 SSC_RSTB | SSC_8X_EN | SSC_SEL_4M);
486 /* Wait SSC clock stable */
487 usleep_range(100, 1000);
489 ret = rtsx_usb_write_register(ucr, CLK_DIV, CLK_CHANGE, 0);
493 ucr->cur_clk = card_clock;
497 EXPORT_SYMBOL_GPL(rtsx_usb_switch_clock);
499 int rtsx_usb_card_exclusive_check(struct rtsx_ucr *ucr, int card)
504 [RTSX_USB_SD_CARD] = (CD_MASK & ~SD_CD),
505 [RTSX_USB_MS_CARD] = (CD_MASK & ~MS_CD)
508 ret = rtsx_usb_get_card_status(ucr, &val);
510 * If get status fails, return 0 (ok) for the exclusive check
511 * and let the flow fail at somewhere else.
516 if (val & cd_mask[card])
521 EXPORT_SYMBOL_GPL(rtsx_usb_card_exclusive_check);
523 static int rtsx_usb_reset_chip(struct rtsx_ucr *ucr)
528 rtsx_usb_init_cmd(ucr);
530 if (CHECK_PKG(ucr, LQFP48)) {
531 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PWR_CTL,
532 LDO3318_PWR_MASK, LDO_SUSPEND);
533 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PWR_CTL,
534 FORCE_LDO_POWERB, FORCE_LDO_POWERB);
535 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL1,
537 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL5,
539 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL6,
543 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, SYS_DUMMY0, NYET_MSAK, NYET_EN);
544 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CD_DEGLITCH_WIDTH, 0xFF, 0x08);
545 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD,
546 CD_DEGLITCH_EN, XD_CD_DEGLITCH_EN, 0x0);
547 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, SD30_DRIVE_SEL,
548 SD30_DRIVE_MASK, DRIVER_TYPE_D);
549 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD,
550 CARD_DRIVE_SEL, SD20_DRIVE_MASK, 0x0);
551 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, LDO_POWER_CFG, 0xE0, 0x0);
554 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD,
555 CARD_PULL_CTL5, 0x03, 0x01);
557 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_DMA1_CTL,
558 EXTEND_DMA1_ASYNC_SIGNAL, EXTEND_DMA1_ASYNC_SIGNAL);
559 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_INT_PEND,
560 XD_INT | MS_INT | SD_INT,
561 XD_INT | MS_INT | SD_INT);
563 ret = rtsx_usb_send_cmd(ucr, MODE_C, 100);
567 /* config non-crystal mode */
568 rtsx_usb_read_register(ucr, CFG_MODE, &val);
569 if ((val & XTAL_FREE) || ((val & CLK_MODE_MASK) == CLK_MODE_NON_XTAL)) {
570 ret = rtsx_usb_write_phy_register(ucr, 0xC2, 0x7C);
578 static int rtsx_usb_init_chip(struct rtsx_ucr *ucr)
583 rtsx_usb_clear_fsm_err(ucr);
586 ret = rtsx_usb_write_register(ucr,
587 FPDCTL, SSC_POWER_MASK, SSC_POWER_ON);
591 usleep_range(100, 1000);
592 ret = rtsx_usb_write_register(ucr, CLK_DIV, CLK_CHANGE, 0x00);
596 /* determine IC version */
597 ret = rtsx_usb_read_register(ucr, HW_VERSION, &val);
601 ucr->ic_version = val & HW_VER_MASK;
603 /* determine package */
604 ret = rtsx_usb_read_register(ucr, CARD_SHARE_MODE, &val);
608 if (val & CARD_SHARE_LQFP_SEL) {
609 ucr->package = LQFP48;
610 dev_dbg(&ucr->pusb_intf->dev, "Package: LQFP48\n");
612 ucr->package = QFN24;
613 dev_dbg(&ucr->pusb_intf->dev, "Package: QFN24\n");
616 /* determine IC variations */
617 rtsx_usb_read_register(ucr, CFG_MODE_1, &val);
619 ucr->is_rts5179 = true;
620 dev_dbg(&ucr->pusb_intf->dev, "Device is rts5179\n");
622 ucr->is_rts5179 = false;
625 return rtsx_usb_reset_chip(ucr);
628 static int rtsx_usb_probe(struct usb_interface *intf,
629 const struct usb_device_id *id)
631 struct usb_device *usb_dev = interface_to_usbdev(intf);
632 struct rtsx_ucr *ucr;
636 ": Realtek USB Card Reader found at bus %03d address %03d\n",
637 usb_dev->bus->busnum, usb_dev->devnum);
639 ucr = devm_kzalloc(&intf->dev, sizeof(*ucr), GFP_KERNEL);
643 ucr->pusb_dev = usb_dev;
645 ucr->iobuf = usb_alloc_coherent(ucr->pusb_dev, IOBUF_SIZE,
646 GFP_KERNEL, &ucr->iobuf_dma);
650 usb_set_intfdata(intf, ucr);
652 ucr->vendor_id = id->idVendor;
653 ucr->product_id = id->idProduct;
654 ucr->cmd_buf = ucr->rsp_buf = ucr->iobuf;
656 mutex_init(&ucr->dev_mutex);
658 ucr->pusb_intf = intf;
661 ret = rtsx_usb_init_chip(ucr);
665 /* initialize USB SG transfer timer */
666 setup_timer(&ucr->sg_timer, rtsx_usb_sg_timed_out, (unsigned long) ucr);
668 ret = mfd_add_hotplug_devices(&intf->dev, rtsx_usb_cells,
669 ARRAY_SIZE(rtsx_usb_cells));
674 intf->needs_remote_wakeup = 1;
675 usb_enable_autosuspend(usb_dev);
681 usb_free_coherent(ucr->pusb_dev, IOBUF_SIZE, ucr->iobuf,
686 static void rtsx_usb_disconnect(struct usb_interface *intf)
688 struct rtsx_ucr *ucr = (struct rtsx_ucr *)usb_get_intfdata(intf);
690 dev_dbg(&intf->dev, "%s called\n", __func__);
692 mfd_remove_devices(&intf->dev);
694 usb_set_intfdata(ucr->pusb_intf, NULL);
695 usb_free_coherent(ucr->pusb_dev, IOBUF_SIZE, ucr->iobuf,
700 static int rtsx_usb_suspend(struct usb_interface *intf, pm_message_t message)
702 struct rtsx_ucr *ucr =
703 (struct rtsx_ucr *)usb_get_intfdata(intf);
706 dev_dbg(&intf->dev, "%s called with pm message 0x%04x\n",
707 __func__, message.event);
709 if (PMSG_IS_AUTO(message)) {
710 if (mutex_trylock(&ucr->dev_mutex)) {
711 rtsx_usb_get_card_status(ucr, &val);
712 mutex_unlock(&ucr->dev_mutex);
714 /* Defer the autosuspend if card exists */
715 if (val & (SD_CD | MS_CD))
718 /* There is an ongoing operation*/
726 static int rtsx_usb_resume(struct usb_interface *intf)
731 static int rtsx_usb_reset_resume(struct usb_interface *intf)
733 struct rtsx_ucr *ucr =
734 (struct rtsx_ucr *)usb_get_intfdata(intf);
736 rtsx_usb_reset_chip(ucr);
740 #else /* CONFIG_PM */
742 #define rtsx_usb_suspend NULL
743 #define rtsx_usb_resume NULL
744 #define rtsx_usb_reset_resume NULL
746 #endif /* CONFIG_PM */
749 static int rtsx_usb_pre_reset(struct usb_interface *intf)
751 struct rtsx_ucr *ucr = (struct rtsx_ucr *)usb_get_intfdata(intf);
753 mutex_lock(&ucr->dev_mutex);
757 static int rtsx_usb_post_reset(struct usb_interface *intf)
759 struct rtsx_ucr *ucr = (struct rtsx_ucr *)usb_get_intfdata(intf);
761 mutex_unlock(&ucr->dev_mutex);
765 static struct usb_device_id rtsx_usb_usb_ids[] = {
766 { USB_DEVICE(0x0BDA, 0x0129) },
767 { USB_DEVICE(0x0BDA, 0x0139) },
768 { USB_DEVICE(0x0BDA, 0x0140) },
771 MODULE_DEVICE_TABLE(usb, rtsx_usb_usb_ids);
773 static struct usb_driver rtsx_usb_driver = {
775 .probe = rtsx_usb_probe,
776 .disconnect = rtsx_usb_disconnect,
777 .suspend = rtsx_usb_suspend,
778 .resume = rtsx_usb_resume,
779 .reset_resume = rtsx_usb_reset_resume,
780 .pre_reset = rtsx_usb_pre_reset,
781 .post_reset = rtsx_usb_post_reset,
782 .id_table = rtsx_usb_usb_ids,
783 .supports_autosuspend = 1,
787 module_usb_driver(rtsx_usb_driver);
789 MODULE_LICENSE("GPL v2");
790 MODULE_AUTHOR("Roger Tseng <rogerable@realtek.com>");
791 MODULE_DESCRIPTION("Realtek USB Card Reader Driver");