19 #include <linux/module.h>
21 #include <linux/kernel.h>
22 #include <linux/slab.h>
46 #define USHC_GET_CAPS_VERSION_MASK 0xff
47 #define USHC_GET_CAPS_3V3 (1 << 8)
48 #define USHC_GET_CAPS_3V0 (1 << 9)
49 #define USHC_GET_CAPS_1V8 (1 << 10)
50 #define USHC_GET_CAPS_HIGH_SPD (1 << 16)
52 #define USHC_HOST_CTRL_4BIT (1 << 1)
53 #define USHC_HOST_CTRL_HIGH_SPD (1 << 0)
55 #define USHC_PWR_CTRL_OFF 0x00
56 #define USHC_PWR_CTRL_3V3 0x01
57 #define USHC_PWR_CTRL_3V0 0x02
58 #define USHC_PWR_CTRL_1V8 0x03
60 #define USHC_READ_RESP_BUSY (1 << 4)
61 #define USHC_READ_RESP_ERR_TIMEOUT (1 << 3)
62 #define USHC_READ_RESP_ERR_CRC (1 << 2)
63 #define USHC_READ_RESP_ERR_DAT (1 << 1)
64 #define USHC_READ_RESP_ERR_CMD (1 << 0)
65 #define USHC_READ_RESP_ERR_MASK 0x0f
74 #define USHC_CBW_SIGNATURE 'C'
82 #define USHC_CSW_SIGNATURE 'S'
89 #define USHC_INT_STATUS_SDIO_INT (1 << 1)
90 #define USHC_INT_STATUS_CARD_PRESENT (1 << 0)
117 #define DISCONNECTED 0
119 #define IGNORE_NEXT_INT 2
121 static void data_callback(
struct urb *
urb);
123 static int ushc_hw_reset(
struct ushc_data *ushc)
130 static int ushc_hw_get_caps(
struct ushc_data *ushc)
137 0, 0, &ushc->
caps,
sizeof(ushc->
caps), 100);
144 if (version != 0x02) {
145 dev_err(&ushc->
usb_dev->dev,
"controller version %d is not supported\n", version);
157 host_ctrl = (ushc->
host_ctrl & ~mask) | val;
160 host_ctrl, 0,
NULL, 0, 100);
167 static void int_callback(
struct urb *
urb)
190 mmc_signal_sdio_irq(ushc->
mmc);
201 static void cbw_callback(
struct urb *urb)
205 if (urb->status != 0) {
211 static void data_callback(
struct urb *urb)
215 if (urb->status != 0)
219 static void csw_callback(
struct urb *urb)
225 status = ushc->
csw->status;
227 if (urb->status != 0) {
228 req->
cmd->error = urb->status;
241 req->
data->bytes_xfered = 0;
243 req->
data->bytes_xfered = req->
data->blksz * req->
data->blocks;
285 ushc->
cbw->block_size = 0;
298 pipe = usb_rcvbulkpipe(ushc->
usb_dev, 6);
300 pipe = usb_sndbulkpipe(ushc->
usb_dev, 2);
303 sg_virt(data->
sg), data->
sg->length,
304 data_callback, ushc);
316 spin_unlock_irqrestore(&ushc->
lock, flags);
325 static int ushc_set_power(
struct ushc_data *ushc,
unsigned char power_mode)
329 switch (power_mode) {
343 voltage, 0,
NULL, 0, 100);
367 clk & 0xffff, (clk >> 16) & 0xffff,
NULL, 0, 100);
380 ushc_set_bus_width(ushc, 1 << ios->
bus_width);
384 static int ushc_get_cd(
struct mmc_host *mmc)
391 static void ushc_enable_sdio_irq(
struct mmc_host *mmc,
int enable)
401 static void ushc_clean_up(
struct ushc_data *ushc)
417 .set_ios = ushc_set_ios,
418 .get_cd = ushc_get_cd,
419 .enable_sdio_irq = ushc_enable_sdio_irq,
424 struct usb_device *usb_dev = interface_to_usbdev(intf);
432 ushc = mmc_priv(mmc);
433 usb_set_intfdata(intf, ushc);
440 ret = ushc_hw_reset(ushc);
445 ret = ushc_hw_get_caps(ushc);
449 mmc->
ops = &ushc_ops;
452 mmc->
f_max = 50000000;
474 usb_rcvintpipe(usb_dev,
475 intf->cur_altsetting->endpoint[0].desc.bEndpointAddress),
478 intf->cur_altsetting->endpoint[0].desc.bInterval);
492 usb_fill_bulk_urb(ushc->
cbw_urb, ushc->
usb_dev, usb_sndbulkpipe(usb_dev, 2),
512 usb_fill_bulk_urb(ushc->
csw_urb, ushc->
usb_dev, usb_rcvbulkpipe(usb_dev, 6),
535 struct ushc_data *ushc = usb_get_intfdata(intf);
537 spin_lock_irq(&ushc->
lock);
539 spin_unlock_irq(&ushc->
lock);
553 { USB_DEVICE(0x0a12, 0x5d10) },
558 static struct usb_driver ushc_driver = {
560 .id_table = ushc_id_table,
562 .disconnect = ushc_disconnect,