Lines Matching refs:sl811

26  * - usb suspend/resume triggered by sl811
47 #include <linux/usb/sl811.h>
59 #include "sl811.h"
64 MODULE_ALIAS("platform:sl811-hcd");
74 static const char hcd_name[] = "sl811-hcd";
78 static void port_power(struct sl811 *sl811, int is_on)
80 struct usb_hcd *hcd = sl811_to_hcd(sl811);
84 if (sl811->port1 & USB_PORT_STAT_POWER)
87 sl811->port1 = USB_PORT_STAT_POWER;
88 sl811->irq_enable = SL11H_INTMASK_INSRMV;
90 sl811->port1 = 0;
91 sl811->irq_enable = 0;
94 sl811->ctrl1 = 0;
95 sl811_write(sl811, SL11H_IRQ_ENABLE, 0);
96 sl811_write(sl811, SL11H_IRQ_STATUS, ~0);
98 if (sl811->board && sl811->board->port_power) {
102 sl811->board->port_power(hcd->self.controller, is_on);
106 if (sl811->board && sl811->board->reset)
107 sl811->board->reset(hcd->self.controller);
109 sl811_write(sl811, SL11H_CTLREG1, SL11H_CTL1MASK_SE0);
113 sl811_write(sl811, SL11H_IRQ_ENABLE, 0);
114 sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
115 sl811_write(sl811, SL811HS_CTLREG2, SL811HS_CTL2_INIT);
116 sl811_write(sl811, SL11H_IRQ_ENABLE, sl811->irq_enable);
135 struct sl811 *sl811,
148 data_reg = sl811->data_reg;
149 sl811_write_buf(sl811, addr, urb->setup_packet, len);
152 sl811_write(sl811, bank + SL11H_BUFADDRREG, addr);
158 sl811_write(sl811, bank + SL11H_HOSTCTLREG,
166 struct sl811 *sl811,
177 data_reg = sl811->data_reg;
180 sl811_write(sl811, bank + SL11H_BUFADDRREG, 0);
189 sl811_write(sl811, bank + SL11H_HOSTCTLREG, control);
200 struct sl811 *sl811,
217 data_reg = sl811->data_reg;
220 sl811_write(sl811, bank + SL11H_BUFADDRREG, addr);
225 sl811_write(sl811, bank + SL11H_HOSTCTLREG, control);
236 struct sl811 *sl811,
258 data_reg = sl811->data_reg;
260 sl811_write_buf(sl811, addr, buf, len);
263 sl811_write(sl811, bank + SL11H_BUFADDRREG, addr);
268 sl811_write(sl811, bank + SL11H_HOSTCTLREG,
279 static inline void sofirq_on(struct sl811 *sl811)
281 if (sl811->irq_enable & SL11H_INTMASK_SOFINTR)
283 dev_dbg(sl811_to_hcd(sl811)->self.controller, "sof irq on\n");
284 sl811->irq_enable |= SL11H_INTMASK_SOFINTR;
287 static inline void sofirq_off(struct sl811 *sl811)
289 if (!(sl811->irq_enable & SL11H_INTMASK_SOFINTR))
291 dev_dbg(sl811_to_hcd(sl811)->self.controller, "sof irq off\n");
292 sl811->irq_enable &= ~SL11H_INTMASK_SOFINTR;
302 static struct sl811h_ep *start(struct sl811 *sl811, u8 bank)
310 if (sl811->next_periodic) {
311 ep = sl811->next_periodic;
312 sl811->next_periodic = ep->next;
314 if (sl811->next_async)
315 ep = sl811->next_async;
316 else if (!list_empty(&sl811->async))
317 ep = container_of(sl811->async.next,
327 if ((bank && sl811->active_b == ep) || sl811->active_a == ep)
331 if (ep->schedule.next == &sl811->async)
332 sl811->next_async = NULL;
334 sl811->next_async = container_of(ep->schedule.next,
339 dev_dbg(sl811_to_hcd(sl811)->self.controller,
350 fclock = sl811_read(sl811, SL11H_SOFTMRREG) << 6;
362 sl811->stat_overrun++;
363 sofirq_on(sl811);
370 sl811->stat_overrun++;
381 in_packet(sl811, ep, urb, bank, control);
384 out_packet(sl811, ep, urb, bank, control);
387 setup_packet(sl811, ep, urb, bank, control);
390 status_packet(sl811, ep, urb, bank, control);
393 dev_dbg(sl811_to_hcd(sl811)->self.controller,
402 static inline void start_transfer(struct sl811 *sl811)
404 if (sl811->port1 & USB_PORT_STAT_SUSPEND)
406 if (sl811->active_a == NULL) {
407 sl811->active_a = start(sl811, SL811_EP_A(SL811_HOST_BUF));
408 if (sl811->active_a != NULL)
409 sl811->jiffies_a = jiffies + MIN_JIFFIES;
412 if (sl811->active_b == NULL) {
413 sl811->active_b = start(sl811, SL811_EP_B(SL811_HOST_BUF));
414 if (sl811->active_b != NULL)
415 sl811->jiffies_b = jiffies + MIN_JIFFIES;
421 struct sl811 *sl811,
425 ) __releases(sl811->lock) __acquires(sl811->lock)
432 usb_hcd_unlink_urb_from_ep(sl811_to_hcd(sl811), urb);
433 spin_unlock(&sl811->lock);
434 usb_hcd_giveback_urb(sl811_to_hcd(sl811), urb, status);
435 spin_lock(&sl811->lock);
444 if (ep == sl811->next_async)
445 sl811->next_async = NULL;
450 dev_dbg(sl811_to_hcd(sl811)->self.controller,
454 struct sl811h_ep **prev = &sl811->periodic[i];
460 sl811->load[i] -= ep->load;
463 sl811->periodic_count--;
464 sl811_to_hcd(sl811)->self.bandwidth_allocated
466 if (ep == sl811->next_periodic)
467 sl811->next_periodic = ep->next;
470 if (sl811->periodic_count == 0)
471 sofirq_off(sl811);
475 done(struct sl811 *sl811, struct sl811h_ep *ep, u8 bank)
484 status = sl811_read(sl811, bank + SL11H_PKTSTATREG);
527 len = ep->maxpacket - sl811_read(sl811,
534 sl811_read_buf(sl811, SL811HS_PACKET_BUF(bank == 0),
585 finish_request(sl811, ep, urb, urbstat);
588 static inline u8 checkdone(struct sl811 *sl811)
593 if (sl811->active_a && time_before_eq(sl811->jiffies_a, jiffies)) {
594 ctl = sl811_read(sl811, SL811_EP_A(SL11H_HOSTCTLREG));
596 sl811_write(sl811, SL811_EP_A(SL11H_HOSTCTLREG), 0);
597 dev_dbg(sl811_to_hcd(sl811)->self.controller,
601 sl811_read(sl811, SL811_EP_A(SL11H_PKTSTATREG)));
605 if (sl811->active_b && time_before_eq(sl811->jiffies_b, jiffies)) {
606 ctl = sl811_read(sl811, SL811_EP_B(SL11H_HOSTCTLREG));
608 sl811_write(sl811, SL811_EP_B(SL11H_HOSTCTLREG), 0);
609 dev_dbg(sl811_to_hcd(sl811)->self.controller,
613 sl811_read(sl811, SL811_EP_B(SL11H_PKTSTATREG)));
622 struct sl811 *sl811 = hcd_to_sl811(hcd);
627 spin_lock(&sl811->lock);
630 irqstat = sl811_read(sl811, SL11H_IRQ_STATUS) & ~SL11H_INTMASK_DP;
632 sl811_write(sl811, SL11H_IRQ_STATUS, irqstat);
633 irqstat &= sl811->irq_enable;
639 irqstat = checkdone(sl811);
641 sl811->stat_lost++;
649 done(sl811, sl811->active_a, SL811_EP_A(SL811_HOST_BUF));
650 sl811->active_a = NULL;
651 sl811->stat_a++;
655 done(sl811, sl811->active_b, SL811_EP_B(SL811_HOST_BUF));
656 sl811->active_b = NULL;
657 sl811->stat_b++;
663 index = sl811->frame++ % (PERIODIC_SIZE - 1);
664 sl811->stat_sof++;
670 if (sl811->next_periodic) {
672 sl811->stat_overrun++;
674 if (sl811->periodic[index])
675 sl811->next_periodic = sl811->periodic[index];
680 sl811->stat_insrmv++;
683 sl811->stat_wake = 0;
684 sl811->stat_sof = 0;
685 sl811->stat_a = 0;
686 sl811->stat_b = 0;
687 sl811->stat_lost = 0;
689 sl811->ctrl1 = 0;
690 sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
692 sl811->irq_enable = SL11H_INTMASK_INSRMV;
693 sl811_write(sl811, SL11H_IRQ_ENABLE, sl811->irq_enable);
696 if (sl811->active_a) {
697 sl811_write(sl811, SL811_EP_A(SL11H_HOSTCTLREG), 0);
698 finish_request(sl811, sl811->active_a,
699 container_of(sl811->active_a
703 sl811->active_a = NULL;
706 if (sl811->active_b) {
707 sl811_write(sl811, SL811_EP_B(SL11H_HOSTCTLREG), 0);
708 finish_request(sl811, sl811->active_b,
709 container_of(sl811->active_b
713 sl811->active_b = NULL;
721 sl811->port1 &= ~USB_PORT_STAT_CONNECTION;
723 sl811->port1 |= USB_PORT_STAT_CONNECTION;
725 sl811->port1 |= USB_PORT_STAT_C_CONNECTION << 16;
728 if (sl811->port1 & USB_PORT_STAT_SUSPEND) {
730 sl811->port1 |= USB_PORT_STAT_C_SUSPEND << 16;
731 sl811->stat_wake++;
737 if (sl811->port1 & USB_PORT_STAT_ENABLE)
738 start_transfer(sl811);
744 if (sl811->periodic_count == 0 && list_empty(&sl811->async))
745 sofirq_off(sl811);
746 sl811_write(sl811, SL11H_IRQ_ENABLE, sl811->irq_enable);
748 spin_unlock(&sl811->lock);
764 static int balance(struct sl811 *sl811, u16 period, u16 load)
772 if (branch < 0 || sl811->load[branch] > sl811->load[i]) {
776 if ((sl811->load[j] + load)
795 struct sl811 *sl811 = hcd_to_sl811(hcd);
819 spin_lock_irqsave(&sl811->lock, flags);
822 if (!(sl811->port1 & USB_PORT_STAT_ENABLE)
868 if (!(sl811->ctrl1 & SL11H_CTL1MASK_LSPD))
896 list_add_tail(&ep->schedule, &sl811->async);
907 urb->start_frame = (sl811->frame & (PERIODIC_SIZE - 1))
912 retval = balance(sl811, ep->period, ep->load);
917 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)) {
986 sl811_read(sl811,
988 sl811_read(sl811,
990 sl811_write(sl811, SL811_EP_A(SL11H_HOSTCTLREG),
992 sl811->active_a = NULL;
996 } else if (sl811->active_b == ep) {
997 if (time_before_eq(sl811->jiffies_a, jiffies)) {
1001 sl811_read(sl811,
1003 sl811_read(sl811,
1005 sl811_write(sl811, SL811_EP_B(SL11H_HOSTCTLREG),
1007 sl811->active_b = NULL;
1016 finish_request(sl811, ep, urb, 0);
1018 dev_dbg(sl811_to_hcd(sl811)->self.controller,
1020 (sl811->active_a == ep) ? "A" : "B");
1024 spin_unlock_irqrestore(&sl811->lock, flags);
1049 struct sl811 *sl811 = hcd_to_sl811(hcd);
1055 return sl811->frame;
1065 struct sl811 *sl811 = hcd_to_sl811(hcd);
1073 if (!timer_pending(&sl811->timer)) {
1075 sl811->stat_lost++;
1080 if (!(sl811->port1 & (0xffff << 16)))
1090 struct sl811 *sl811,
1103 if (sl811->board && sl811->board->port_power) {
1104 desc->bPwrOn2PwrGood = sl811->board->potpg;
1124 struct sl811 *sl811 = from_timer(sl811, t, timer);
1127 u8 signaling = sl811->ctrl1 & SL11H_CTL1MASK_FORCE;
1132 spin_lock_irqsave(&sl811->lock, flags);
1135 sl811->ctrl1 &= ~SL11H_CTL1MASK_FORCE;
1136 sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
1139 irqstat = sl811_read(sl811, SL11H_IRQ_STATUS);
1143 dev_dbg(sl811_to_hcd(sl811)->self.controller, "end reset\n");
1144 sl811->port1 = (USB_PORT_STAT_C_RESET << 16)
1146 sl811->ctrl1 = 0;
1152 dev_dbg(sl811_to_hcd(sl811)->self.controller, "end resume\n");
1153 sl811->port1 &= ~USB_PORT_STAT_SUSPEND;
1156 dev_dbg(sl811_to_hcd(sl811)->self.controller,
1160 sl811_write(sl811, SL11H_IRQ_STATUS, irqstat);
1164 if (sl811->port1 & USB_PORT_STAT_CONNECTION)
1165 sl811->port1 |= (USB_PORT_STAT_C_CONNECTION << 16)
1167 sl811->port1 &= ~mask;
1168 sl811->irq_enable = SL11H_INTMASK_INSRMV;
1170 sl811->port1 |= mask;
1172 sl811->port1 &= ~USB_PORT_STAT_LOW_SPEED;
1173 sl811->irq_enable = SL11H_INTMASK_INSRMV | SL11H_INTMASK_RD;
1176 if (sl811->port1 & USB_PORT_STAT_CONNECTION) {
1179 sl811->irq_enable |= SL11H_INTMASK_DONE_A;
1181 sl811->irq_enable |= SL11H_INTMASK_DONE_B;
1183 if (sl811->port1 & USB_PORT_STAT_LOW_SPEED) {
1184 sl811->ctrl1 |= SL11H_CTL1MASK_LSPD;
1189 sl811->ctrl1 |= SL11H_CTL1MASK_SOF_ENA;
1190 sl811_write(sl811, SL11H_SOFLOWREG, 0xe0);
1191 sl811_write(sl811, SL811HS_CTLREG2, ctrl2);
1194 sl811_write(sl811, SL811_EP_A(SL11H_BUFLNTHREG), 0);
1195 writeb(SL_SOF, sl811->data_reg);
1196 writeb(0, sl811->data_reg);
1197 sl811_write(sl811, SL811_EP_A(SL11H_HOSTCTLREG),
1202 sl811->ctrl1 = 0;
1204 sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
1207 sl811_write(sl811, SL11H_IRQ_ENABLE, sl811->irq_enable);
1208 spin_unlock_irqrestore(&sl811->lock, flags);
1220 struct sl811 *sl811 = hcd_to_sl811(hcd);
1224 spin_lock_irqsave(&sl811->lock, flags);
1243 sl811->port1 &= USB_PORT_STAT_POWER;
1244 sl811->ctrl1 = 0;
1245 sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
1246 sl811->irq_enable = SL11H_INTMASK_INSRMV;
1247 sl811_write(sl811, SL11H_IRQ_ENABLE,
1248 sl811->irq_enable);
1251 if (!(sl811->port1 & USB_PORT_STAT_SUSPEND))
1256 sl811->irq_enable = 0;
1257 sl811_write(sl811, SL11H_IRQ_ENABLE,
1258 sl811->irq_enable);
1259 sl811->ctrl1 |= SL11H_CTL1MASK_K;
1260 sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
1262 mod_timer(&sl811->timer, jiffies
1266 port_power(sl811, 0);
1277 sl811->port1 &= ~(1 << wValue);
1280 sl811h_hub_descriptor(sl811, (struct usb_hub_descriptor *) buf);
1288 put_unaligned_le32(sl811->port1, buf);
1293 sl811->port1);
1300 if (sl811->port1 & USB_PORT_STAT_RESET)
1302 if (!(sl811->port1 & USB_PORT_STAT_ENABLE))
1306 sl811->ctrl1 &= ~SL11H_CTL1MASK_SOF_ENA;
1307 sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
1310 port_power(sl811, 1);
1313 if (sl811->port1 & USB_PORT_STAT_SUSPEND)
1315 if (!(sl811->port1 & USB_PORT_STAT_POWER))
1319 sl811->irq_enable = 0;
1320 sl811_write(sl811, SL11H_IRQ_ENABLE,
1321 sl811->irq_enable);
1322 sl811->ctrl1 = SL11H_CTL1MASK_SE0;
1323 sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
1324 sl811->port1 |= USB_PORT_STAT_RESET;
1325 mod_timer(&sl811->timer, jiffies
1331 sl811->port1 |= 1 << wValue;
1340 spin_unlock_irqrestore(&sl811->lock, flags);
1385 struct sl811 *sl811 = s->private;
1390 sl811_to_hcd(sl811)->product_desc,
1392 sl811->port1);
1394 seq_printf(s, "insert/remove: %ld\n", sl811->stat_insrmv);
1397 sl811->stat_a, sl811->stat_b,
1398 sl811->stat_wake, sl811->stat_sof,
1399 sl811->stat_overrun, sl811->stat_lost);
1401 spin_lock_irq(&sl811->lock);
1403 if (sl811->ctrl1 & SL11H_CTL1MASK_SUSPEND)
1406 u8 t = sl811_read(sl811, SL11H_CTLREG1);
1420 sl811_read(sl811, SL11H_IRQ_ENABLE));
1422 sl811_read(sl811, SL11H_IRQ_STATUS));
1424 sl811_read(sl811, SL11H_SOFTMRREG) << 6);
1427 seq_printf(s, "A: qh%p ctl %02x sts %02x\n", sl811->active_a,
1428 sl811_read(sl811, SL811_EP_A(SL11H_HOSTCTLREG)),
1429 sl811_read(sl811, SL811_EP_A(SL11H_PKTSTATREG)));
1430 seq_printf(s, "B: qh%p ctl %02x sts %02x\n", sl811->active_b,
1431 sl811_read(sl811, SL811_EP_B(SL11H_HOSTCTLREG)),
1432 sl811_read(sl811, SL811_EP_B(SL11H_PKTSTATREG)));
1434 list_for_each_entry (ep, &sl811->async, schedule) {
1439 (ep == sl811->active_a) ? "(A) " : "",
1440 (ep == sl811->active_b) ? "(B) " : "",
1457 if (!list_empty(&sl811->async))
1463 ep = sl811->periodic[i];
1466 seq_printf(s, "%2d [%3d]:\n", i, sl811->load[i]);
1473 (ep == sl811->active_a) ? "(A) " : "",
1474 (ep == sl811->active_b) ? "(B) " : "",
1488 spin_unlock_irq(&sl811->lock);
1495 /* expect just one sl811 per system */
1496 static void create_debug_file(struct sl811 *sl811)
1498 sl811->debug_file = debugfs_create_file("sl811h", S_IRUGO,
1499 usb_debug_root, sl811,
1503 static void remove_debug_file(struct sl811 *sl811)
1505 debugfs_remove(sl811->debug_file);
1513 struct sl811 *sl811 = hcd_to_sl811(hcd);
1518 spin_lock_irqsave(&sl811->lock, flags);
1519 port_power(sl811, 0);
1520 spin_unlock_irqrestore(&sl811->lock, flags);
1526 struct sl811 *sl811 = hcd_to_sl811(hcd);
1531 if (sl811->board) {
1534 sl811->board->can_wakeup);
1535 hcd->power_budget = sl811->board->power * 2;
1539 port_power(sl811, 1);
1548 .hcd_priv_size = sizeof(struct sl811),
1587 struct sl811 *sl811 = hcd_to_sl811(hcd);
1590 remove_debug_file(sl811);
1596 iounmap(sl811->data_reg);
1600 iounmap(sl811->addr_reg);
1610 struct sl811 *sl811;
1672 sl811 = hcd_to_sl811(hcd);
1674 spin_lock_init(&sl811->lock);
1675 INIT_LIST_HEAD(&sl811->async);
1676 sl811->board = dev_get_platdata(&dev->dev);
1677 timer_setup(&sl811->timer, sl811h_timer, 0);
1678 sl811->addr_reg = addr_reg;
1679 sl811->data_reg = data_reg;
1681 spin_lock_irq(&sl811->lock);
1682 port_power(sl811, 0);
1683 spin_unlock_irq(&sl811->lock);
1686 tmp = sl811_read(sl811, SL11H_HWREVREG);
1717 create_debug_file(sl811);
1743 struct sl811 *sl811 = hcd_to_sl811(hcd);
1753 port_power(sl811, 0);
1763 struct sl811 *sl811 = hcd_to_sl811(hcd);
1768 if (!sl811->port1 || !device_can_wakeup(&hcd->self.root_hub->dev)) {
1769 sl811->port1 = 0;
1770 port_power(sl811, 1);