Lines Matching refs:max3421_hcd

123 struct max3421_hcd {  struct
128 struct max3421_hcd *next; argument
179 static struct max3421_hcd *max3421_hcd_list; argument
340 static inline struct max3421_hcd *
343 return (struct max3421_hcd *) hcd->hcd_priv; in hcd_to_max3421()
347 max3421_to_hcd(struct max3421_hcd *max3421_hcd) in max3421_to_hcd() argument
349 return container_of((void *) max3421_hcd, struct usb_hcd, hcd_priv); in max3421_to_hcd()
355 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in spi_rd8() local
364 max3421_hcd->tx->data[0] = in spi_rd8()
368 transfer.tx_buf = max3421_hcd->tx->data; in spi_rd8()
369 transfer.rx_buf = max3421_hcd->rx->data; in spi_rd8()
375 return max3421_hcd->rx->data[1]; in spi_rd8()
382 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in spi_wr8() local
390 max3421_hcd->tx->data[0] = in spi_wr8()
393 max3421_hcd->tx->data[1] = val; in spi_wr8()
395 transfer.tx_buf = max3421_hcd->tx->data; in spi_wr8()
406 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in spi_rd_buf() local
414 max3421_hcd->tx->data[0] = in spi_rd_buf()
417 transfer[0].tx_buf = max3421_hcd->tx->data; in spi_rd_buf()
432 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in spi_wr_buf() local
440 max3421_hcd->tx->data[0] = in spi_wr_buf()
444 transfer[0].tx_buf = max3421_hcd->tx->data; in spi_wr_buf()
471 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_set_speed() local
472 u8 mode_lowspeed, mode_hubpre, mode = max3421_hcd->mode; in max3421_set_speed()
476 if (max3421_hcd->port_status & USB_PORT_STAT_LOW_SPEED) { in max3421_set_speed()
484 if (mode != max3421_hcd->mode) { in max3421_set_speed()
485 max3421_hcd->mode = mode; in max3421_set_speed()
486 spi_wr8(hcd, MAX3421_REG_MODE, max3421_hcd->mode); in max3421_set_speed()
498 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_set_address() local
503 old_dev = max3421_hcd->loaded_dev; in max3421_set_address()
504 old_epnum = max3421_hcd->loaded_epnum; in max3421_set_address()
527 max3421_hcd->loaded_epnum = epnum; in max3421_set_address()
535 max3421_hcd->loaded_dev = dev; in max3421_set_address()
549 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_transfer_in() local
552 max3421_hcd->curr_len = 0; in max3421_transfer_in()
553 max3421_hcd->hien |= BIT(MAX3421_HI_RCVDAV_BIT); in max3421_transfer_in()
561 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_transfer_out() local
569 if (max3421_hcd->rev == 0x12) { in max3421_transfer_out()
573 spi_wr8(hcd, MAX3421_REG_SNDBC, max3421_hcd->curr_len); in max3421_transfer_out()
588 max3421_hcd->urb_done = -EMSGSIZE; in max3421_transfer_out()
591 max3421_hcd->curr_len = min((urb->transfer_buffer_length - in max3421_transfer_out()
594 spi_wr_buf(hcd, MAX3421_REG_SNDFIFO, src, max3421_hcd->curr_len); in max3421_transfer_out()
595 spi_wr8(hcd, MAX3421_REG_SNDBC, max3421_hcd->curr_len); in max3421_transfer_out()
606 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_next_transfer() local
607 struct urb *urb = max3421_hcd->curr_urb; in max3421_next_transfer()
646 max3421_hcd->hien |= BIT(MAX3421_HI_HXFRDN_BIT); in max3421_next_transfer()
667 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_select_and_start_urb() local
675 spin_lock_irqsave(&max3421_hcd->lock, flags); in max3421_select_and_start_urb()
678 max3421_hcd->sched_pass < SCHED_PASS_DONE; in max3421_select_and_start_urb()
679 ++max3421_hcd->sched_pass) in max3421_select_and_start_urb()
680 list_for_each(pos, &max3421_hcd->ep_list) { in max3421_select_and_start_urb()
689 if (max3421_hcd->sched_pass != in max3421_select_and_start_urb()
696 if (max3421_hcd->sched_pass != in max3421_select_and_start_urb()
709 max3421_hcd->curr_urb = urb; in max3421_select_and_start_urb()
710 max3421_hcd->urb_done = 1; in max3421_select_and_start_urb()
711 spin_unlock_irqrestore(&max3421_hcd->lock, in max3421_select_and_start_urb()
723 max3421_hcd->frame_number) == 0) in max3421_select_and_start_urb()
730 max3421_hcd->frame_number) in max3421_select_and_start_urb()
742 if (frame_diff(max3421_hcd->frame_number, in max3421_select_and_start_urb()
755 list_move_tail(pos, &max3421_hcd->ep_list); in max3421_select_and_start_urb()
761 spin_unlock_irqrestore(&max3421_hcd->lock, flags); in max3421_select_and_start_urb()
765 urb = max3421_hcd->curr_urb = curr_urb; in max3421_select_and_start_urb()
785 spin_unlock_irqrestore(&max3421_hcd->lock, flags); in max3421_select_and_start_urb()
787 max3421_ep->last_active = max3421_hcd->frame_number; in max3421_select_and_start_urb()
803 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_check_unlink() local
810 spin_lock_irqsave(&max3421_hcd->lock, flags); in max3421_check_unlink()
811 list_for_each_entry(max3421_ep, &max3421_hcd->ep_list, ep_list) { in max3421_check_unlink()
819 spin_unlock_irqrestore(&max3421_hcd->lock, in max3421_check_unlink()
822 spin_lock_irqsave(&max3421_hcd->lock, flags); in max3421_check_unlink()
826 spin_unlock_irqrestore(&max3421_hcd->lock, flags); in max3421_check_unlink()
836 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_slow_retransmit() local
837 struct urb *urb = max3421_hcd->curr_urb; in max3421_slow_retransmit()
842 max3421_hcd->curr_urb = NULL; in max3421_slow_retransmit()
851 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_recv_data_available() local
852 struct urb *urb = max3421_hcd->curr_urb; in max3421_recv_data_available()
872 max3421_hcd->curr_len = transfer_size; in max3421_recv_data_available()
883 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_handle_error() local
885 struct urb *urb = max3421_hcd->curr_urb; in max3421_handle_error()
912 max3421_hcd->urb_done = hrsl_to_error[result_code]; in max3421_handle_error()
940 max3421_hcd->urb_done = hrsl_to_error[result_code]; in max3421_handle_error()
949 max3421_hcd->urb_done = hrsl_to_error[result_code]; in max3421_handle_error()
975 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_transfer_in_done() local
997 if (max3421_hcd->curr_len < max_packet) { in max3421_transfer_in_done()
1018 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_transfer_out_done() local
1020 urb->actual_length += max3421_hcd->curr_len; in max3421_transfer_out_done()
1033 if (max3421_hcd->curr_len == max_packet) in max3421_transfer_out_done()
1045 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_host_transfer_done() local
1046 struct urb *urb = max3421_hcd->curr_urb; in max3421_host_transfer_done()
1051 max3421_hcd->hien &= ~(BIT(MAX3421_HI_HXFRDN_BIT) | in max3421_host_transfer_done()
1058 ++max3421_hcd->err_stat[result_code]; in max3421_host_transfer_done()
1089 max3421_hcd->urb_done = urb_done = 0; in max3421_host_transfer_done()
1100 max3421_hcd->urb_done = urb_done; in max3421_host_transfer_done()
1111 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_detect_conn() local
1122 mode = max3421_hcd->mode; in max3421_detect_conn()
1147 max3421_hcd->mode = mode; in max3421_detect_conn()
1148 spi_wr8(hcd, MAX3421_REG_MODE, max3421_hcd->mode); in max3421_detect_conn()
1150 spin_lock_irqsave(&max3421_hcd->lock, flags); in max3421_detect_conn()
1151 old_port_status = max3421_hcd->port_status; in max3421_detect_conn()
1153 max3421_hcd->port_status |= USB_PORT_STAT_CONNECTION; in max3421_detect_conn()
1155 max3421_hcd->port_status &= ~USB_PORT_STAT_CONNECTION; in max3421_detect_conn()
1157 max3421_hcd->port_status |= USB_PORT_STAT_LOW_SPEED; in max3421_detect_conn()
1159 max3421_hcd->port_status &= ~USB_PORT_STAT_LOW_SPEED; in max3421_detect_conn()
1160 chg = (old_port_status ^ max3421_hcd->port_status); in max3421_detect_conn()
1161 max3421_hcd->port_status |= chg << 16; in max3421_detect_conn()
1162 spin_unlock_irqrestore(&max3421_hcd->lock, flags); in max3421_detect_conn()
1170 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_irq_handler() local
1172 if (max3421_hcd->spi_thread && in max3421_irq_handler()
1173 max3421_hcd->spi_thread->state != TASK_RUNNING) in max3421_irq_handler()
1174 wake_up_process(max3421_hcd->spi_thread); in max3421_irq_handler()
1175 if (!test_and_set_bit(ENABLE_IRQ, &max3421_hcd->todo)) in max3421_irq_handler()
1185 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in dump_eps() local
1193 spin_lock_irqsave(&max3421_hcd->lock, flags); in dump_eps()
1194 list_for_each_entry(max3421_ep, &max3421_hcd->ep_list, ep_list) { in dump_eps()
1217 spin_unlock_irqrestore(&max3421_hcd->lock, flags); in dump_eps()
1226 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_handle_irqs() local
1237 hirq &= max3421_hcd->hien; in max3421_handle_irqs()
1246 max3421_hcd->frame_number = ((max3421_hcd->frame_number + 1) in max3421_handle_irqs()
1248 max3421_hcd->sched_pass = SCHED_PASS_PERIODIC; in max3421_handle_irqs()
1264 spin_lock_irqsave(&max3421_hcd->lock, flags); in max3421_handle_irqs()
1266 old_port_status = max3421_hcd->port_status; in max3421_handle_irqs()
1268 if (max3421_hcd->port_status & USB_PORT_STAT_RESET) { in max3421_handle_irqs()
1270 max3421_hcd->port_status &= ~USB_PORT_STAT_RESET; in max3421_handle_irqs()
1271 max3421_hcd->port_status |= USB_PORT_STAT_ENABLE; in max3421_handle_irqs()
1282 chg = (old_port_status ^ max3421_hcd->port_status); in max3421_handle_irqs()
1283 max3421_hcd->port_status |= chg << 16; in max3421_handle_irqs()
1285 spin_unlock_irqrestore(&max3421_hcd->lock, flags); in max3421_handle_irqs()
1299 max3421_hcd->err_stat[i]); in max3421_handle_irqs()
1305 memset(max3421_hcd->err_stat, 0, in max3421_handle_irqs()
1306 sizeof(max3421_hcd->err_stat)); in max3421_handle_irqs()
1320 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_reset_hcd() local
1344 max3421_hcd->mode = (BIT(MAX3421_MODE_HOST_BIT) | in max3421_reset_hcd()
1348 spi_wr8(hcd, MAX3421_REG_MODE, max3421_hcd->mode); in max3421_reset_hcd()
1351 max3421_hcd->frame_number = USB_MAX_FRAME_NUMBER; in max3421_reset_hcd()
1359 max3421_hcd->hien = (BIT(MAX3421_HI_FRAME_BIT) | in max3421_reset_hcd()
1362 spi_wr8(hcd, MAX3421_REG_HIEN, max3421_hcd->hien); in max3421_reset_hcd()
1372 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_urb_done() local
1377 status = max3421_hcd->urb_done; in max3421_urb_done()
1378 max3421_hcd->urb_done = 0; in max3421_urb_done()
1381 urb = max3421_hcd->curr_urb; in max3421_urb_done()
1383 max3421_hcd->curr_urb = NULL; in max3421_urb_done()
1384 spin_lock_irqsave(&max3421_hcd->lock, flags); in max3421_urb_done()
1386 spin_unlock_irqrestore(&max3421_hcd->lock, flags); in max3421_urb_done()
1399 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_spi_thread() local
1408 max3421_hcd->rev = spi_rd8(hcd, MAX3421_REG_REVISION); in max3421_spi_thread()
1409 if (max3421_hcd->rev == 0x12 || max3421_hcd->rev == 0x13) in max3421_spi_thread()
1411 dev_err(&spi->dev, "bad rev 0x%02x", max3421_hcd->rev); in max3421_spi_thread()
1415 max3421_hcd->rev, spi->max_speed_hz, spi->bits_per_word, in max3421_spi_thread()
1425 spi_wr8(hcd, MAX3421_REG_HIEN, max3421_hcd->hien); in max3421_spi_thread()
1428 if (test_and_clear_bit(ENABLE_IRQ, &max3421_hcd->todo)) in max3421_spi_thread()
1436 if (max3421_hcd->urb_done) in max3421_spi_thread()
1440 else if (!max3421_hcd->curr_urb) in max3421_spi_thread()
1443 if (test_and_clear_bit(RESET_HCD, &max3421_hcd->todo)) in max3421_spi_thread()
1446 if (test_and_clear_bit(RESET_PORT, &max3421_hcd->todo)) { in max3421_spi_thread()
1452 if (test_and_clear_bit(CHECK_UNLINK, &max3421_hcd->todo)) in max3421_spi_thread()
1454 if (test_and_clear_bit(IOPIN_UPDATE, &max3421_hcd->todo)) { in max3421_spi_thread()
1459 for (i = 0; i < ARRAY_SIZE(max3421_hcd->iopins); ++i) { in max3421_spi_thread()
1463 (max3421_hcd->iopins[i] & 0x0f)); in max3421_spi_thread()
1465 max3421_hcd->iopins[i] = val; in max3421_spi_thread()
1478 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_reset_port() local
1480 max3421_hcd->port_status &= ~(USB_PORT_STAT_ENABLE | in max3421_reset_port()
1482 max3421_hcd->port_status |= USB_PORT_STAT_RESET; in max3421_reset_port()
1483 set_bit(RESET_PORT, &max3421_hcd->todo); in max3421_reset_port()
1484 wake_up_process(max3421_hcd->spi_thread); in max3421_reset_port()
1491 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_reset() local
1496 set_bit(RESET_HCD, &max3421_hcd->todo); in max3421_reset()
1497 wake_up_process(max3421_hcd->spi_thread); in max3421_reset()
1504 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_start() local
1506 spin_lock_init(&max3421_hcd->lock); in max3421_start()
1507 max3421_hcd->rh_state = MAX3421_RH_RUNNING; in max3421_start()
1509 INIT_LIST_HEAD(&max3421_hcd->ep_list); in max3421_start()
1526 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_urb_enqueue() local
1544 spin_lock_irqsave(&max3421_hcd->lock, flags); in max3421_urb_enqueue()
1555 max3421_ep->last_active = max3421_hcd->frame_number; in max3421_urb_enqueue()
1558 list_add_tail(&max3421_ep->ep_list, &max3421_hcd->ep_list); in max3421_urb_enqueue()
1564 max3421_hcd->sched_pass = SCHED_PASS_PERIODIC; in max3421_urb_enqueue()
1565 wake_up_process(max3421_hcd->spi_thread); in max3421_urb_enqueue()
1569 spin_unlock_irqrestore(&max3421_hcd->lock, flags); in max3421_urb_enqueue()
1576 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_urb_dequeue() local
1580 spin_lock_irqsave(&max3421_hcd->lock, flags); in max3421_urb_dequeue()
1588 set_bit(CHECK_UNLINK, &max3421_hcd->todo); in max3421_urb_dequeue()
1589 wake_up_process(max3421_hcd->spi_thread); in max3421_urb_dequeue()
1591 spin_unlock_irqrestore(&max3421_hcd->lock, flags); in max3421_urb_dequeue()
1598 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_endpoint_disable() local
1601 spin_lock_irqsave(&max3421_hcd->lock, flags); in max3421_endpoint_disable()
1613 spin_unlock_irqrestore(&max3421_hcd->lock, flags); in max3421_endpoint_disable()
1619 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_get_frame_number() local
1620 return max3421_hcd->frame_number; in max3421_get_frame_number()
1630 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_hub_status_data() local
1634 spin_lock_irqsave(&max3421_hcd->lock, flags); in max3421_hub_status_data()
1639 if ((max3421_hcd->port_status & PORT_C_MASK) != 0) { in max3421_hub_status_data()
1643 max3421_hcd->port_status); in max3421_hub_status_data()
1645 if (max3421_hcd->rh_state == MAX3421_RH_SUSPENDED) in max3421_hub_status_data()
1649 spin_unlock_irqrestore(&max3421_hcd->lock, flags); in max3421_hub_status_data()
1675 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_gpout_set_value() local
1686 max3421_hcd->iopins[idx] |= mask; in max3421_gpout_set_value()
1688 max3421_hcd->iopins[idx] &= ~mask; in max3421_gpout_set_value()
1689 set_bit(IOPIN_UPDATE, &max3421_hcd->todo); in max3421_gpout_set_value()
1690 wake_up_process(max3421_hcd->spi_thread); in max3421_gpout_set_value()
1698 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_hub_control() local
1705 spin_lock_irqsave(&max3421_hcd->lock, flags); in max3421_hub_control()
1720 max3421_hcd->port_status &= ~(1 << value); in max3421_hub_control()
1742 ((__le16 *) buf)[0] = cpu_to_le16(max3421_hcd->port_status); in max3421_hub_control()
1744 cpu_to_le16(max3421_hcd->port_status >> 16); in max3421_hub_control()
1759 if (max3421_hcd->active) in max3421_hub_control()
1760 max3421_hcd->port_status |= in max3421_hub_control()
1765 max3421_hcd->port_status |= USB_PORT_STAT_POWER; in max3421_hub_control()
1773 if ((max3421_hcd->port_status & USB_PORT_STAT_POWER) in max3421_hub_control()
1775 max3421_hcd->port_status |= (1 << value); in max3421_hub_control()
1787 spin_unlock_irqrestore(&max3421_hcd->lock, flags); in max3421_hub_control()
1821 .hcd_priv_size = sizeof(struct max3421_hcd),
1864 struct max3421_hcd *max3421_hcd; in max3421_probe() local
1916 max3421_hcd = hcd_to_max3421(hcd); in max3421_probe()
1917 max3421_hcd->next = max3421_hcd_list; in max3421_probe()
1918 max3421_hcd_list = max3421_hcd; in max3421_probe()
1919 INIT_LIST_HEAD(&max3421_hcd->ep_list); in max3421_probe()
1921 max3421_hcd->tx = kmalloc(sizeof(*max3421_hcd->tx), GFP_KERNEL); in max3421_probe()
1922 if (!max3421_hcd->tx) in max3421_probe()
1924 max3421_hcd->rx = kmalloc(sizeof(*max3421_hcd->rx), GFP_KERNEL); in max3421_probe()
1925 if (!max3421_hcd->rx) in max3421_probe()
1928 max3421_hcd->spi_thread = kthread_run(max3421_spi_thread, hcd, in max3421_probe()
1930 if (max3421_hcd->spi_thread == ERR_PTR(-ENOMEM)) { in max3421_probe()
1957 kfree(max3421_hcd->tx); in max3421_probe()
1958 kfree(max3421_hcd->rx); in max3421_probe()
1959 if (max3421_hcd->spi_thread) in max3421_probe()
1960 kthread_stop(max3421_hcd->spi_thread); in max3421_probe()
1969 struct max3421_hcd *max3421_hcd = NULL, **prev; in max3421_remove() local
1974 max3421_hcd = *prev; in max3421_remove()
1975 hcd = max3421_to_hcd(max3421_hcd); in max3421_remove()
1979 if (!max3421_hcd) { in max3421_remove()
1987 spin_lock_irqsave(&max3421_hcd->lock, flags); in max3421_remove()
1989 kthread_stop(max3421_hcd->spi_thread); in max3421_remove()
1990 *prev = max3421_hcd->next; in max3421_remove()
1992 spin_unlock_irqrestore(&max3421_hcd->lock, flags); in max3421_remove()