H A D | max3421-hcd.c | 106 /* Bit numbers for max3421_hcd->todo: */ 119 struct max3421_hcd { struct 124 struct max3421_hcd *next; 175 static struct max3421_hcd *max3421_hcd_list; 336 static inline struct max3421_hcd * hcd_to_max3421() 339 return (struct max3421_hcd *) hcd->hcd_priv; hcd_to_max3421() 343 max3421_to_hcd(struct max3421_hcd *max3421_hcd) max3421_to_hcd() argument 345 return container_of((void *) max3421_hcd, struct usb_hcd, hcd_priv); max3421_to_hcd() 351 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); spi_rd8() local 360 max3421_hcd->tx->data[0] = spi_rd8() 364 transfer.tx_buf = max3421_hcd->tx->data; spi_rd8() 365 transfer.rx_buf = max3421_hcd->rx->data; spi_rd8() 371 return max3421_hcd->rx->data[1]; spi_rd8() 378 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); spi_wr8() local 386 max3421_hcd->tx->data[0] = spi_wr8() 389 max3421_hcd->tx->data[1] = val; spi_wr8() 391 transfer.tx_buf = max3421_hcd->tx->data; spi_wr8() 402 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); spi_rd_buf() local 410 max3421_hcd->tx->data[0] = spi_rd_buf() 413 transfer[0].tx_buf = max3421_hcd->tx->data; spi_rd_buf() 428 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); spi_wr_buf() local 436 max3421_hcd->tx->data[0] = spi_wr_buf() 440 transfer[0].tx_buf = max3421_hcd->tx->data; spi_wr_buf() 467 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_set_speed() local 468 u8 mode_lowspeed, mode_hubpre, mode = max3421_hcd->mode; max3421_set_speed() 472 if (max3421_hcd->port_status & USB_PORT_STAT_LOW_SPEED) { max3421_set_speed() 480 if (mode != max3421_hcd->mode) { max3421_set_speed() 481 max3421_hcd->mode = mode; max3421_set_speed() 482 spi_wr8(hcd, MAX3421_REG_MODE, max3421_hcd->mode); max3421_set_speed() 494 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_set_address() local 499 old_dev = max3421_hcd->loaded_dev; max3421_set_address() 500 old_epnum = max3421_hcd->loaded_epnum; max3421_set_address() 523 max3421_hcd->loaded_epnum = epnum; max3421_set_address() 531 max3421_hcd->loaded_dev = dev; max3421_set_address() 545 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_transfer_in() local 548 max3421_hcd->curr_len = 0; max3421_transfer_in() 549 max3421_hcd->hien |= BIT(MAX3421_HI_RCVDAV_BIT); max3421_transfer_in() 557 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_transfer_out() local 565 if (max3421_hcd->rev == 0x12) { max3421_transfer_out() 569 spi_wr8(hcd, MAX3421_REG_SNDBC, max3421_hcd->curr_len); max3421_transfer_out() 584 max3421_hcd->urb_done = -EMSGSIZE; max3421_transfer_out() 587 max3421_hcd->curr_len = min((urb->transfer_buffer_length - max3421_transfer_out() 590 spi_wr_buf(hcd, MAX3421_REG_SNDFIFO, src, max3421_hcd->curr_len); max3421_transfer_out() 591 spi_wr8(hcd, MAX3421_REG_SNDBC, max3421_hcd->curr_len); max3421_transfer_out() 602 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_next_transfer() local 603 struct urb *urb = max3421_hcd->curr_urb; max3421_next_transfer() 642 max3421_hcd->hien |= BIT(MAX3421_HI_HXFRDN_BIT); max3421_next_transfer() 656 * o max3421_hcd->curr_urb MUST BE NULL. 663 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_select_and_start_urb() local 671 spin_lock_irqsave(&max3421_hcd->lock, flags); max3421_select_and_start_urb() 674 max3421_hcd->sched_pass < SCHED_PASS_DONE; max3421_select_and_start_urb() 675 ++max3421_hcd->sched_pass) max3421_select_and_start_urb() 676 list_for_each(pos, &max3421_hcd->ep_list) { max3421_select_and_start_urb() 685 if (max3421_hcd->sched_pass != max3421_select_and_start_urb() 692 if (max3421_hcd->sched_pass != max3421_select_and_start_urb() 705 max3421_hcd->curr_urb = urb; max3421_select_and_start_urb() 706 max3421_hcd->urb_done = 1; max3421_select_and_start_urb() 707 spin_unlock_irqrestore(&max3421_hcd->lock, max3421_select_and_start_urb() 719 max3421_hcd->frame_number) == 0) max3421_select_and_start_urb() 726 max3421_hcd->frame_number) max3421_select_and_start_urb() 738 if (frame_diff(max3421_hcd->frame_number, max3421_select_and_start_urb() 751 list_move_tail(pos, &max3421_hcd->ep_list); max3421_select_and_start_urb() 757 spin_unlock_irqrestore(&max3421_hcd->lock, flags); max3421_select_and_start_urb() 761 urb = max3421_hcd->curr_urb = curr_urb; max3421_select_and_start_urb() 781 spin_unlock_irqrestore(&max3421_hcd->lock, flags); max3421_select_and_start_urb() 783 max3421_ep->last_active = max3421_hcd->frame_number; max3421_select_and_start_urb() 799 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_check_unlink() local 807 spin_lock_irqsave(&max3421_hcd->lock, flags); max3421_check_unlink() 808 list_for_each(pos, &max3421_hcd->ep_list) { max3421_check_unlink() 818 spin_unlock_irqrestore(&max3421_hcd->lock, max3421_check_unlink() 821 spin_lock_irqsave(&max3421_hcd->lock, flags); max3421_check_unlink() 825 spin_unlock_irqrestore(&max3421_hcd->lock, flags); max3421_check_unlink() 835 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_slow_retransmit() local 836 struct urb *urb = max3421_hcd->curr_urb; max3421_slow_retransmit() 841 max3421_hcd->curr_urb = NULL; max3421_slow_retransmit() 850 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_recv_data_available() local 851 struct urb *urb = max3421_hcd->curr_urb; max3421_recv_data_available() 871 max3421_hcd->curr_len = transfer_size; max3421_recv_data_available() 882 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_handle_error() local 884 struct urb *urb = max3421_hcd->curr_urb; max3421_handle_error() 911 max3421_hcd->urb_done = hrsl_to_error[result_code]; max3421_handle_error() 939 max3421_hcd->urb_done = hrsl_to_error[result_code]; max3421_handle_error() 948 max3421_hcd->urb_done = hrsl_to_error[result_code]; max3421_handle_error() 974 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_transfer_in_done() local 996 if (max3421_hcd->curr_len < max_packet) { max3421_transfer_in_done() 1017 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_transfer_out_done() local 1019 urb->actual_length += max3421_hcd->curr_len; max3421_transfer_out_done() 1032 if (max3421_hcd->curr_len == max_packet) max3421_transfer_out_done() 1044 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_host_transfer_done() local 1045 struct urb *urb = max3421_hcd->curr_urb; max3421_host_transfer_done() 1050 max3421_hcd->hien &= ~(BIT(MAX3421_HI_HXFRDN_BIT) | max3421_host_transfer_done() 1057 ++max3421_hcd->err_stat[result_code]; max3421_host_transfer_done() 1088 max3421_hcd->urb_done = urb_done = 0; max3421_host_transfer_done() 1099 max3421_hcd->urb_done = urb_done; max3421_host_transfer_done() 1110 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_detect_conn() local 1121 mode = max3421_hcd->mode; max3421_detect_conn() 1146 max3421_hcd->mode = mode; max3421_detect_conn() 1147 spi_wr8(hcd, MAX3421_REG_MODE, max3421_hcd->mode); max3421_detect_conn() 1149 spin_lock_irqsave(&max3421_hcd->lock, flags); max3421_detect_conn() 1150 old_port_status = max3421_hcd->port_status; max3421_detect_conn() 1152 max3421_hcd->port_status |= USB_PORT_STAT_CONNECTION; max3421_detect_conn() 1154 max3421_hcd->port_status &= ~USB_PORT_STAT_CONNECTION; max3421_detect_conn() 1156 max3421_hcd->port_status |= USB_PORT_STAT_LOW_SPEED; max3421_detect_conn() 1158 max3421_hcd->port_status &= ~USB_PORT_STAT_LOW_SPEED; max3421_detect_conn() 1159 chg = (old_port_status ^ max3421_hcd->port_status); max3421_detect_conn() 1160 max3421_hcd->port_status |= chg << 16; max3421_detect_conn() 1161 spin_unlock_irqrestore(&max3421_hcd->lock, flags); max3421_detect_conn() 1169 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_irq_handler() local 1171 if (max3421_hcd->spi_thread && max3421_irq_handler() 1172 max3421_hcd->spi_thread->state != TASK_RUNNING) max3421_irq_handler() 1173 wake_up_process(max3421_hcd->spi_thread); max3421_irq_handler() 1174 if (!test_and_set_bit(ENABLE_IRQ, &max3421_hcd->todo)) max3421_irq_handler() 1184 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); dump_eps() local 1193 spin_lock_irqsave(&max3421_hcd->lock, flags); dump_eps() 1194 list_for_each(pos, &max3421_hcd->ep_list) { dump_eps() 1219 spin_unlock_irqrestore(&max3421_hcd->lock, flags); dump_eps() 1228 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_handle_irqs() local 1239 hirq &= max3421_hcd->hien; max3421_handle_irqs() 1248 max3421_hcd->frame_number = ((max3421_hcd->frame_number + 1) max3421_handle_irqs() 1250 max3421_hcd->sched_pass = SCHED_PASS_PERIODIC; max3421_handle_irqs() 1266 spin_lock_irqsave(&max3421_hcd->lock, flags); max3421_handle_irqs() 1268 old_port_status = max3421_hcd->port_status; max3421_handle_irqs() 1270 if (max3421_hcd->port_status & USB_PORT_STAT_RESET) { max3421_handle_irqs() 1272 max3421_hcd->port_status &= ~USB_PORT_STAT_RESET; max3421_handle_irqs() 1273 max3421_hcd->port_status |= USB_PORT_STAT_ENABLE; max3421_handle_irqs() 1284 chg = (old_port_status ^ max3421_hcd->port_status); max3421_handle_irqs() 1285 max3421_hcd->port_status |= chg << 16; max3421_handle_irqs() 1287 spin_unlock_irqrestore(&max3421_hcd->lock, flags); max3421_handle_irqs() 1301 max3421_hcd->err_stat[i]); max3421_handle_irqs() 1307 memset(max3421_hcd->err_stat, 0, max3421_handle_irqs() 1308 sizeof(max3421_hcd->err_stat)); max3421_handle_irqs() 1322 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_reset_hcd() local 1346 max3421_hcd->mode = (BIT(MAX3421_MODE_HOST_BIT) | max3421_reset_hcd() 1350 spi_wr8(hcd, MAX3421_REG_MODE, max3421_hcd->mode); max3421_reset_hcd() 1353 max3421_hcd->frame_number = USB_MAX_FRAME_NUMBER; max3421_reset_hcd() 1361 max3421_hcd->hien = (BIT(MAX3421_HI_FRAME_BIT) | max3421_reset_hcd() 1364 spi_wr8(hcd, MAX3421_REG_HIEN, max3421_hcd->hien); max3421_reset_hcd() 1374 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_urb_done() local 1379 status = max3421_hcd->urb_done; max3421_urb_done() 1380 max3421_hcd->urb_done = 0; max3421_urb_done() 1383 urb = max3421_hcd->curr_urb; max3421_urb_done() 1385 max3421_hcd->curr_urb = NULL; max3421_urb_done() 1386 spin_lock_irqsave(&max3421_hcd->lock, flags); max3421_urb_done() 1388 spin_unlock_irqrestore(&max3421_hcd->lock, flags); max3421_urb_done() 1401 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_spi_thread() local 1410 max3421_hcd->rev = spi_rd8(hcd, MAX3421_REG_REVISION); max3421_spi_thread() 1411 if (max3421_hcd->rev == 0x12 || max3421_hcd->rev == 0x13) max3421_spi_thread() 1413 dev_err(&spi->dev, "bad rev 0x%02x", max3421_hcd->rev); max3421_spi_thread() 1417 max3421_hcd->rev, spi->max_speed_hz, spi->bits_per_word, max3421_spi_thread() 1427 spi_wr8(hcd, MAX3421_REG_HIEN, max3421_hcd->hien); max3421_spi_thread() 1430 if (test_and_clear_bit(ENABLE_IRQ, &max3421_hcd->todo)) max3421_spi_thread() 1438 if (max3421_hcd->urb_done) max3421_spi_thread() 1442 else if (!max3421_hcd->curr_urb) max3421_spi_thread() 1445 if (test_and_clear_bit(RESET_HCD, &max3421_hcd->todo)) max3421_spi_thread() 1448 if (test_and_clear_bit(RESET_PORT, &max3421_hcd->todo)) { max3421_spi_thread() 1454 if (test_and_clear_bit(CHECK_UNLINK, &max3421_hcd->todo)) max3421_spi_thread() 1456 if (test_and_clear_bit(IOPIN_UPDATE, &max3421_hcd->todo)) { max3421_spi_thread() 1461 for (i = 0; i < ARRAY_SIZE(max3421_hcd->iopins); ++i) { max3421_spi_thread() 1465 (max3421_hcd->iopins[i] & 0x0f)); max3421_spi_thread() 1467 max3421_hcd->iopins[i] = val; max3421_spi_thread() 1480 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_reset_port() local 1482 max3421_hcd->port_status &= ~(USB_PORT_STAT_ENABLE | max3421_reset_port() 1484 max3421_hcd->port_status |= USB_PORT_STAT_RESET; max3421_reset_port() 1485 set_bit(RESET_PORT, &max3421_hcd->todo); max3421_reset_port() 1486 wake_up_process(max3421_hcd->spi_thread); max3421_reset_port() 1493 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_reset() local 1498 set_bit(RESET_HCD, &max3421_hcd->todo); max3421_reset() 1499 wake_up_process(max3421_hcd->spi_thread); max3421_reset() 1506 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_start() local 1508 spin_lock_init(&max3421_hcd->lock); max3421_start() 1509 max3421_hcd->rh_state = MAX3421_RH_RUNNING; max3421_start() 1511 INIT_LIST_HEAD(&max3421_hcd->ep_list); max3421_start() 1528 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_urb_enqueue() local 1546 spin_lock_irqsave(&max3421_hcd->lock, flags); max3421_urb_enqueue() 1557 max3421_ep->last_active = max3421_hcd->frame_number; max3421_urb_enqueue() 1560 list_add_tail(&max3421_ep->ep_list, &max3421_hcd->ep_list); max3421_urb_enqueue() 1566 max3421_hcd->sched_pass = SCHED_PASS_PERIODIC; max3421_urb_enqueue() 1567 wake_up_process(max3421_hcd->spi_thread); max3421_urb_enqueue() 1571 spin_unlock_irqrestore(&max3421_hcd->lock, flags); max3421_urb_enqueue() 1578 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_urb_dequeue() local 1582 spin_lock_irqsave(&max3421_hcd->lock, flags); max3421_urb_dequeue() 1590 set_bit(CHECK_UNLINK, &max3421_hcd->todo); max3421_urb_dequeue() 1591 wake_up_process(max3421_hcd->spi_thread); max3421_urb_dequeue() 1593 spin_unlock_irqrestore(&max3421_hcd->lock, flags); max3421_urb_dequeue() 1600 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_endpoint_disable() local 1603 spin_lock_irqsave(&max3421_hcd->lock, flags); max3421_endpoint_disable() 1615 spin_unlock_irqrestore(&max3421_hcd->lock, flags); max3421_endpoint_disable() 1621 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_get_frame_number() local 1622 return max3421_hcd->frame_number; max3421_get_frame_number() 1632 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_hub_status_data() local 1636 spin_lock_irqsave(&max3421_hcd->lock, flags); max3421_hub_status_data() 1641 if ((max3421_hcd->port_status & PORT_C_MASK) != 0) { max3421_hub_status_data() 1645 max3421_hcd->port_status); max3421_hub_status_data() 1647 if (max3421_hcd->rh_state == MAX3421_RH_SUSPENDED) max3421_hub_status_data() 1651 spin_unlock_irqrestore(&max3421_hcd->lock, flags); max3421_hub_status_data() 1677 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_gpout_set_value() local 1688 max3421_hcd->iopins[idx] |= mask; max3421_gpout_set_value() 1690 max3421_hcd->iopins[idx] &= ~mask; max3421_gpout_set_value() 1691 set_bit(IOPIN_UPDATE, &max3421_hcd->todo); max3421_gpout_set_value() 1692 wake_up_process(max3421_hcd->spi_thread); max3421_gpout_set_value() 1700 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); max3421_hub_control() local 1705 spin_lock_irqsave(&max3421_hcd->lock, flags); max3421_hub_control() 1722 max3421_hcd->port_status &= ~(1 << value); max3421_hub_control() 1744 ((__le16 *) buf)[0] = cpu_to_le16(max3421_hcd->port_status); max3421_hub_control() 1746 cpu_to_le16(max3421_hcd->port_status >> 16); max3421_hub_control() 1761 if (max3421_hcd->active) max3421_hub_control() 1762 max3421_hcd->port_status |= max3421_hub_control() 1767 max3421_hcd->port_status |= USB_PORT_STAT_POWER; max3421_hub_control() 1775 if ((max3421_hcd->port_status & USB_PORT_STAT_POWER) max3421_hub_control() 1777 max3421_hcd->port_status |= (1 << value); max3421_hub_control() 1789 spin_unlock_irqrestore(&max3421_hcd->lock, flags); max3421_hub_control() 1823 .hcd_priv_size = sizeof(struct max3421_hcd), 1843 struct max3421_hcd *max3421_hcd; max3421_probe() local 1859 max3421_hcd = hcd_to_max3421(hcd); max3421_probe() 1860 max3421_hcd->next = max3421_hcd_list; max3421_probe() 1861 max3421_hcd_list = max3421_hcd; max3421_probe() 1862 INIT_LIST_HEAD(&max3421_hcd->ep_list); max3421_probe() 1864 max3421_hcd->tx = kmalloc(sizeof(*max3421_hcd->tx), GFP_KERNEL); max3421_probe() 1865 if (!max3421_hcd->tx) { max3421_probe() 1869 max3421_hcd->rx = kmalloc(sizeof(*max3421_hcd->rx), GFP_KERNEL); max3421_probe() 1870 if (!max3421_hcd->rx) { max3421_probe() 1875 max3421_hcd->spi_thread = kthread_run(max3421_spi_thread, hcd, max3421_probe() 1877 if (max3421_hcd->spi_thread == ERR_PTR(-ENOMEM)) { max3421_probe() 1899 kfree(max3421_hcd->tx); max3421_probe() 1900 kfree(max3421_hcd->rx); max3421_probe() 1901 if (max3421_hcd->spi_thread) max3421_probe() 1902 kthread_stop(max3421_hcd->spi_thread); max3421_probe() 1911 struct max3421_hcd *max3421_hcd = NULL, **prev; max3421_remove() local 1916 max3421_hcd = *prev; max3421_remove() 1917 hcd = max3421_to_hcd(max3421_hcd); max3421_remove() 1921 if (!max3421_hcd) { max3421_remove() 1929 spin_lock_irqsave(&max3421_hcd->lock, flags); max3421_remove() 1931 kthread_stop(max3421_hcd->spi_thread); max3421_remove() 1932 *prev = max3421_hcd->next; max3421_remove() 1934 spin_unlock_irqrestore(&max3421_hcd->lock, flags); max3421_remove()
|