Lines Matching refs:sl811
25 * - usb suspend/resume triggered by sl811 (with USB_SUSPEND)
47 #include <linux/usb/sl811.h>
57 #include "sl811.h"
62 MODULE_ALIAS("platform:sl811-hcd");
83 static const char hcd_name[] = "sl811-hcd";
87 static void port_power(struct sl811 *sl811, int is_on)
89 struct usb_hcd *hcd = sl811_to_hcd(sl811);
93 if (sl811->port1 & USB_PORT_STAT_POWER)
96 sl811->port1 = USB_PORT_STAT_POWER;
97 sl811->irq_enable = SL11H_INTMASK_INSRMV;
99 sl811->port1 = 0;
100 sl811->irq_enable = 0;
103 sl811->ctrl1 = 0;
104 sl811_write(sl811, SL11H_IRQ_ENABLE, 0);
105 sl811_write(sl811, SL11H_IRQ_STATUS, ~0);
107 if (sl811->board && sl811->board->port_power) {
110 sl811->board->port_power(hcd->self.controller, is_on);
114 if (sl811->board && sl811->board->reset)
115 sl811->board->reset(hcd->self.controller);
117 sl811_write(sl811, SL11H_CTLREG1, SL11H_CTL1MASK_SE0);
121 sl811_write(sl811, SL11H_IRQ_ENABLE, 0);
122 sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
123 sl811_write(sl811, SL811HS_CTLREG2, SL811HS_CTL2_INIT);
124 sl811_write(sl811, SL11H_IRQ_ENABLE, sl811->irq_enable);
143 struct sl811 *sl811,
156 data_reg = sl811->data_reg;
157 sl811_write_buf(sl811, addr, urb->setup_packet, len);
160 sl811_write(sl811, bank + SL11H_BUFADDRREG, addr);
166 sl811_write(sl811, bank + SL11H_HOSTCTLREG,
174 struct sl811 *sl811,
185 data_reg = sl811->data_reg;
188 sl811_write(sl811, bank + SL11H_BUFADDRREG, 0);
197 sl811_write(sl811, bank + SL11H_HOSTCTLREG, control);
208 struct sl811 *sl811,
225 data_reg = sl811->data_reg;
228 sl811_write(sl811, bank + SL11H_BUFADDRREG, addr);
233 sl811_write(sl811, bank + SL11H_HOSTCTLREG, control);
244 struct sl811 *sl811,
266 data_reg = sl811->data_reg;
268 sl811_write_buf(sl811, addr, buf, len);
271 sl811_write(sl811, bank + SL11H_BUFADDRREG, addr);
276 sl811_write(sl811, bank + SL11H_HOSTCTLREG,
287 static inline void sofirq_on(struct sl811 *sl811)
289 if (sl811->irq_enable & SL11H_INTMASK_SOFINTR)
292 sl811->irq_enable |= SL11H_INTMASK_SOFINTR;
295 static inline void sofirq_off(struct sl811 *sl811)
297 if (!(sl811->irq_enable & SL11H_INTMASK_SOFINTR))
300 sl811->irq_enable &= ~SL11H_INTMASK_SOFINTR;
310 static struct sl811h_ep *start(struct sl811 *sl811, u8 bank)
318 if (sl811->next_periodic) {
319 ep = sl811->next_periodic;
320 sl811->next_periodic = ep->next;
322 if (sl811->next_async)
323 ep = sl811->next_async;
324 else if (!list_empty(&sl811->async))
325 ep = container_of(sl811->async.next,
335 if ((bank && sl811->active_b == ep) || sl811->active_a == ep)
339 if (ep->schedule.next == &sl811->async)
340 sl811->next_async = NULL;
342 sl811->next_async = container_of(ep->schedule.next,
357 fclock = sl811_read(sl811, SL11H_SOFTMRREG) << 6;
369 sl811->stat_overrun++;
370 sofirq_on(sl811);
377 sl811->stat_overrun++;
388 in_packet(sl811, ep, urb, bank, control);
391 out_packet(sl811, ep, urb, bank, control);
394 setup_packet(sl811, ep, urb, bank, control);
397 status_packet(sl811, ep, urb, bank, control);
408 static inline void start_transfer(struct sl811 *sl811)
410 if (sl811->port1 & USB_PORT_STAT_SUSPEND)
412 if (sl811->active_a == NULL) {
413 sl811->active_a = start(sl811, SL811_EP_A(SL811_HOST_BUF));
414 if (sl811->active_a != NULL)
415 sl811->jiffies_a = jiffies + MIN_JIFFIES;
418 if (sl811->active_b == NULL) {
419 sl811->active_b = start(sl811, SL811_EP_B(SL811_HOST_BUF));
420 if (sl811->active_b != NULL)
421 sl811->jiffies_b = jiffies + MIN_JIFFIES;
427 struct sl811 *sl811,
431 ) __releases(sl811->lock) __acquires(sl811->lock)
438 usb_hcd_unlink_urb_from_ep(sl811_to_hcd(sl811), urb);
439 spin_unlock(&sl811->lock);
440 usb_hcd_giveback_urb(sl811_to_hcd(sl811), urb, status);
441 spin_lock(&sl811->lock);
450 if (ep == sl811->next_async)
451 sl811->next_async = NULL;
459 struct sl811h_ep **prev = &sl811->periodic[i];
465 sl811->load[i] -= ep->load;
468 sl811->periodic_count--;
469 sl811_to_hcd(sl811)->self.bandwidth_allocated
471 if (ep == sl811->next_periodic)
472 sl811->next_periodic = ep->next;
475 if (sl811->periodic_count == 0)
476 sofirq_off(sl811);
480 done(struct sl811 *sl811, struct sl811h_ep *ep, u8 bank)
489 status = sl811_read(sl811, bank + SL11H_PKTSTATREG);
532 len = ep->maxpacket - sl811_read(sl811,
539 sl811_read_buf(sl811, SL811HS_PACKET_BUF(bank == 0),
590 finish_request(sl811, ep, urb, urbstat);
593 static inline u8 checkdone(struct sl811 *sl811)
598 if (sl811->active_a && time_before_eq(sl811->jiffies_a, jiffies)) {
599 ctl = sl811_read(sl811, SL811_EP_A(SL11H_HOSTCTLREG));
601 sl811_write(sl811, SL811_EP_A(SL11H_HOSTCTLREG), 0);
605 sl811_read(sl811, SL811_EP_A(SL11H_PKTSTATREG)));
609 if (sl811->active_b && time_before_eq(sl811->jiffies_b, jiffies)) {
610 ctl = sl811_read(sl811, SL811_EP_B(SL11H_HOSTCTLREG));
612 sl811_write(sl811, SL811_EP_B(SL11H_HOSTCTLREG), 0);
616 sl811_read(sl811, SL811_EP_B(SL11H_PKTSTATREG)));
625 struct sl811 *sl811 = hcd_to_sl811(hcd);
630 spin_lock(&sl811->lock);
633 irqstat = sl811_read(sl811, SL11H_IRQ_STATUS) & ~SL11H_INTMASK_DP;
635 sl811_write(sl811, SL11H_IRQ_STATUS, irqstat);
636 irqstat &= sl811->irq_enable;
642 irqstat = checkdone(sl811);
644 sl811->stat_lost++;
652 done(sl811, sl811->active_a, SL811_EP_A(SL811_HOST_BUF));
653 sl811->active_a = NULL;
654 sl811->stat_a++;
658 done(sl811, sl811->active_b, SL811_EP_B(SL811_HOST_BUF));
659 sl811->active_b = NULL;
660 sl811->stat_b++;
666 index = sl811->frame++ % (PERIODIC_SIZE - 1);
667 sl811->stat_sof++;
673 if (sl811->next_periodic) {
675 sl811->stat_overrun++;
677 if (sl811->periodic[index])
678 sl811->next_periodic = sl811->periodic[index];
683 sl811->stat_insrmv++;
686 sl811->stat_wake = 0;
687 sl811->stat_sof = 0;
688 sl811->stat_a = 0;
689 sl811->stat_b = 0;
690 sl811->stat_lost = 0;
692 sl811->ctrl1 = 0;
693 sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
695 sl811->irq_enable = SL11H_INTMASK_INSRMV;
696 sl811_write(sl811, SL11H_IRQ_ENABLE, sl811->irq_enable);
699 if (sl811->active_a) {
700 sl811_write(sl811, SL811_EP_A(SL11H_HOSTCTLREG), 0);
701 finish_request(sl811, sl811->active_a,
702 container_of(sl811->active_a
706 sl811->active_a = NULL;
709 if (sl811->active_b) {
710 sl811_write(sl811, SL811_EP_B(SL11H_HOSTCTLREG), 0);
711 finish_request(sl811, sl811->active_b,
712 container_of(sl811->active_b
716 sl811->active_b = NULL;
724 sl811->port1 &= ~USB_PORT_STAT_CONNECTION;
726 sl811->port1 |= USB_PORT_STAT_CONNECTION;
728 sl811->port1 |= USB_PORT_STAT_C_CONNECTION << 16;
731 if (sl811->port1 & USB_PORT_STAT_SUSPEND) {
733 sl811->port1 |= USB_PORT_STAT_C_SUSPEND << 16;
734 sl811->stat_wake++;
740 if (sl811->port1 & USB_PORT_STAT_ENABLE)
741 start_transfer(sl811);
747 if (sl811->periodic_count == 0 && list_empty(&sl811->async))
748 sofirq_off(sl811);
749 sl811_write(sl811, SL11H_IRQ_ENABLE, sl811->irq_enable);
751 spin_unlock(&sl811->lock);
767 static int balance(struct sl811 *sl811, u16 period, u16 load)
775 if (branch < 0 || sl811->load[branch] > sl811->load[i]) {
779 if ((sl811->load[j] + load)
798 struct sl811 *sl811 = hcd_to_sl811(hcd);
822 spin_lock_irqsave(&sl811->lock, flags);
825 if (!(sl811->port1 & USB_PORT_STAT_ENABLE)
869 if (!(sl811->ctrl1 & SL11H_CTL1MASK_LSPD))
897 list_add_tail(&ep->schedule, &sl811->async);
908 urb->start_frame = (sl811->frame & (PERIODIC_SIZE - 1))
913 retval = balance(sl811, ep->period, ep->load);
918 urb->start_frame = (sl811->frame & (PERIODIC_SIZE - 1))
927 struct sl811h_ep **prev = &sl811->periodic[i];
940 sl811->load[i] += ep->load;
942 sl811->periodic_count++;
944 sofirq_on(sl811);
948 start_transfer(sl811);
949 sl811_write(sl811, SL11H_IRQ_ENABLE, sl811->irq_enable);
954 spin_unlock_irqrestore(&sl811->lock, flags);
960 struct sl811 *sl811 = hcd_to_sl811(hcd);
966 spin_lock_irqsave(&sl811->lock, flags);
981 } else if (sl811->active_a == ep) {
982 if (time_before_eq(sl811->jiffies_a, jiffies)) {
985 sl811_read(sl811,
987 sl811_read(sl811,
989 sl811_write(sl811, SL811_EP_A(SL11H_HOSTCTLREG),
991 sl811->active_a = NULL;
995 } else if (sl811->active_b == ep) {
996 if (time_before_eq(sl811->jiffies_a, jiffies)) {
999 sl811_read(sl811,
1001 sl811_read(sl811,
1003 sl811_write(sl811, SL811_EP_B(SL11H_HOSTCTLREG),
1005 sl811->active_b = NULL;
1014 finish_request(sl811, ep, urb, 0);
1017 (sl811->active_a == ep) ? "A" : "B");
1021 spin_unlock_irqrestore(&sl811->lock, flags);
1046 struct sl811 *sl811 = hcd_to_sl811(hcd);
1052 return sl811->frame;
1062 struct sl811 *sl811 = hcd_to_sl811(hcd);
1070 if (!timer_pending(&sl811->timer)) {
1072 sl811->stat_lost++;
1077 if (!(sl811->port1 & (0xffff << 16)))
1087 struct sl811 *sl811,
1100 if (sl811->board && sl811->board->port_power) {
1101 desc->bPwrOn2PwrGood = sl811->board->potpg;
1121 struct sl811 *sl811 = (void *) _sl811;
1124 u8 signaling = sl811->ctrl1 & SL11H_CTL1MASK_FORCE;
1129 spin_lock_irqsave(&sl811->lock, flags);
1132 sl811->ctrl1 &= ~SL11H_CTL1MASK_FORCE;
1133 sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
1136 irqstat = sl811_read(sl811, SL11H_IRQ_STATUS);
1141 sl811->port1 = (USB_PORT_STAT_C_RESET << 16)
1143 sl811->ctrl1 = 0;
1150 sl811->port1 &= ~USB_PORT_STAT_SUSPEND;
1156 sl811_write(sl811, SL11H_IRQ_STATUS, irqstat);
1160 if (sl811->port1 & USB_PORT_STAT_CONNECTION)
1161 sl811->port1 |= (USB_PORT_STAT_C_CONNECTION << 16)
1163 sl811->port1 &= ~mask;
1164 sl811->irq_enable = SL11H_INTMASK_INSRMV;
1166 sl811->port1 |= mask;
1168 sl811->port1 &= ~USB_PORT_STAT_LOW_SPEED;
1169 sl811->irq_enable = SL11H_INTMASK_INSRMV | SL11H_INTMASK_RD;
1172 if (sl811->port1 & USB_PORT_STAT_CONNECTION) {
1175 sl811->irq_enable |= SL11H_INTMASK_DONE_A;
1177 sl811->irq_enable |= SL11H_INTMASK_DONE_B;
1179 if (sl811->port1 & USB_PORT_STAT_LOW_SPEED) {
1180 sl811->ctrl1 |= SL11H_CTL1MASK_LSPD;
1185 sl811->ctrl1 |= SL11H_CTL1MASK_SOF_ENA;
1186 sl811_write(sl811, SL11H_SOFLOWREG, 0xe0);
1187 sl811_write(sl811, SL811HS_CTLREG2, ctrl2);
1190 sl811_write(sl811, SL811_EP_A(SL11H_BUFLNTHREG), 0);
1191 writeb(SL_SOF, sl811->data_reg);
1192 writeb(0, sl811->data_reg);
1193 sl811_write(sl811, SL811_EP_A(SL11H_HOSTCTLREG),
1198 sl811->ctrl1 = 0;
1200 sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
1203 sl811_write(sl811, SL11H_IRQ_ENABLE, sl811->irq_enable);
1204 spin_unlock_irqrestore(&sl811->lock, flags);
1216 struct sl811 *sl811 = hcd_to_sl811(hcd);
1220 spin_lock_irqsave(&sl811->lock, flags);
1239 sl811->port1 &= USB_PORT_STAT_POWER;
1240 sl811->ctrl1 = 0;
1241 sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
1242 sl811->irq_enable = SL11H_INTMASK_INSRMV;
1243 sl811_write(sl811, SL11H_IRQ_ENABLE,
1244 sl811->irq_enable);
1247 if (!(sl811->port1 & USB_PORT_STAT_SUSPEND))
1252 sl811->irq_enable = 0;
1253 sl811_write(sl811, SL11H_IRQ_ENABLE,
1254 sl811->irq_enable);
1255 sl811->ctrl1 |= SL11H_CTL1MASK_K;
1256 sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
1258 mod_timer(&sl811->timer, jiffies
1262 port_power(sl811, 0);
1273 sl811->port1 &= ~(1 << wValue);
1276 sl811h_hub_descriptor(sl811, (struct usb_hub_descriptor *) buf);
1284 put_unaligned_le32(sl811->port1, buf);
1289 DBG("GetPortStatus %08x\n", sl811->port1);
1296 if (sl811->port1 & USB_PORT_STAT_RESET)
1298 if (!(sl811->port1 & USB_PORT_STAT_ENABLE))
1302 sl811->ctrl1 &= ~SL11H_CTL1MASK_SOF_ENA;
1303 sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
1306 port_power(sl811, 1);
1309 if (sl811->port1 & USB_PORT_STAT_SUSPEND)
1311 if (!(sl811->port1 & USB_PORT_STAT_POWER))
1315 sl811->irq_enable = 0;
1316 sl811_write(sl811, SL11H_IRQ_ENABLE,
1317 sl811->irq_enable);
1318 sl811->ctrl1 = SL11H_CTL1MASK_SE0;
1319 sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
1320 sl811->port1 |= USB_PORT_STAT_RESET;
1321 mod_timer(&sl811->timer, jiffies
1327 sl811->port1 |= 1 << wValue;
1336 spin_unlock_irqrestore(&sl811->lock, flags);
1370 static inline void create_debug_file(struct sl811 *sl811) { }
1371 static inline void remove_debug_file(struct sl811 *sl811) { }
1391 struct sl811 *sl811 = s->private;
1396 sl811_to_hcd(sl811)->product_desc,
1398 sl811->port1);
1400 seq_printf(s, "insert/remove: %ld\n", sl811->stat_insrmv);
1403 sl811->stat_a, sl811->stat_b,
1404 sl811->stat_wake, sl811->stat_sof,
1405 sl811->stat_overrun, sl811->stat_lost);
1407 spin_lock_irq(&sl811->lock);
1409 if (sl811->ctrl1 & SL11H_CTL1MASK_SUSPEND)
1412 u8 t = sl811_read(sl811, SL11H_CTLREG1);
1426 sl811_read(sl811, SL11H_IRQ_ENABLE));
1428 sl811_read(sl811, SL11H_IRQ_STATUS));
1430 sl811_read(sl811, SL11H_SOFTMRREG) << 6);
1433 seq_printf(s, "A: qh%p ctl %02x sts %02x\n", sl811->active_a,
1434 sl811_read(sl811, SL811_EP_A(SL11H_HOSTCTLREG)),
1435 sl811_read(sl811, SL811_EP_A(SL11H_PKTSTATREG)));
1436 seq_printf(s, "B: qh%p ctl %02x sts %02x\n", sl811->active_b,
1437 sl811_read(sl811, SL811_EP_B(SL11H_HOSTCTLREG)),
1438 sl811_read(sl811, SL811_EP_B(SL11H_PKTSTATREG)));
1440 list_for_each_entry (ep, &sl811->async, schedule) {
1445 (ep == sl811->active_a) ? "(A) " : "",
1446 (ep == sl811->active_b) ? "(B) " : "",
1463 if (!list_empty(&sl811->async))
1469 ep = sl811->periodic[i];
1472 seq_printf(s, "%2d [%3d]:\n", i, sl811->load[i]);
1479 (ep == sl811->active_a) ? "(A) " : "",
1480 (ep == sl811->active_b) ? "(B) " : "",
1494 spin_unlock_irq(&sl811->lock);
1512 /* expect just one sl811 per system */
1515 static void create_debug_file(struct sl811 *sl811)
1517 sl811->pde = proc_create_data(proc_filename, 0, NULL, &proc_ops, sl811);
1520 static void remove_debug_file(struct sl811 *sl811)
1522 if (sl811->pde)
1533 struct sl811 *sl811 = hcd_to_sl811(hcd);
1538 spin_lock_irqsave(&sl811->lock, flags);
1539 port_power(sl811, 0);
1540 spin_unlock_irqrestore(&sl811->lock, flags);
1546 struct sl811 *sl811 = hcd_to_sl811(hcd);
1551 if (sl811->board) {
1554 sl811->board->can_wakeup);
1555 hcd->power_budget = sl811->board->power * 2;
1559 port_power(sl811, 1);
1568 .hcd_priv_size = sizeof(struct sl811),
1607 struct sl811 *sl811 = hcd_to_sl811(hcd);
1610 remove_debug_file(sl811);
1616 iounmap(sl811->data_reg);
1620 iounmap(sl811->addr_reg);
1630 struct sl811 *sl811;
1695 sl811 = hcd_to_sl811(hcd);
1697 spin_lock_init(&sl811->lock);
1698 INIT_LIST_HEAD(&sl811->async);
1699 sl811->board = dev->dev.platform_data;
1700 init_timer(&sl811->timer);
1701 sl811->timer.function = sl811h_timer;
1702 sl811->timer.data = (unsigned long) sl811;
1703 sl811->addr_reg = addr_reg;
1704 sl811->data_reg = data_reg;
1706 spin_lock_irq(&sl811->lock);
1707 port_power(sl811, 0);
1708 spin_unlock_irq(&sl811->lock);
1711 tmp = sl811_read(sl811, SL11H_HWREVREG);
1740 create_debug_file(sl811);
1767 struct sl811 *sl811 = hcd_to_sl811(hcd);
1777 port_power(sl811, 0);
1787 struct sl811 *sl811 = hcd_to_sl811(hcd);
1792 if (!sl811->port1 || !device_can_wakeup(&hcd->self.root_hub->dev)) {
1793 sl811->port1 = 0;
1794 port_power(sl811, 1);