92 #include <linux/module.h>
93 #include <linux/kernel.h>
94 #include <linux/sched.h>
95 #include <linux/slab.h>
97 #include <linux/list.h>
99 #include <linux/prefetch.h>
107 #define TA_WAIT_BCON(m) max_t(int, (m)->a_wait_bcon, OTG_TIME_A_WAIT_BCON)
110 #define DRIVER_AUTHOR "Mentor Graphics, Texas Instruments, Nokia"
111 #define DRIVER_DESC "Inventra Dual-Role USB Controller Driver"
113 #define MUSB_VERSION "6.0"
115 #define DRIVER_INFO DRIVER_DESC ", v" MUSB_VERSION
117 #define MUSB_DRIVER_NAME "musb-hdrc"
143 dev_err(dev,
"failed to reserve resource for id\n");
149 dev_err(dev,
"failed to allocate a new id\n");
160 dev_dbg(dev,
"removing id %d\n",
id);
165 #ifndef CONFIG_BLACKFIN
174 pm_runtime_get_sync(phy->
io_dev);
199 r &= ~MUSB_ULPI_REG_CMPLT;
205 pm_runtime_put(phy->
io_dev);
218 pm_runtime_get_sync(phy->
io_dev);
230 & MUSB_ULPI_REG_CMPLT)) {
239 r &= ~MUSB_ULPI_REG_CMPLT;
243 pm_runtime_put(phy->
io_dev);
248 #define musb_ulpi_read NULL
249 #define musb_ulpi_write NULL
253 .read = musb_ulpi_read,
254 .write = musb_ulpi_write,
259 #if !defined(CONFIG_USB_MUSB_TUSB6010) && !defined(CONFIG_USB_MUSB_BLACKFIN)
275 'T', hw_ep->
epnum, fifo, len, src);
278 if (
likely((0x01 & (
unsigned long) src) == 0)) {
282 if ((0x02 & (
unsigned long) src) == 0) {
284 writesl(fifo, src + index, len >> 2);
285 index += len & ~0x03;
288 musb_writew(fifo, 0, *(
u16 *)&src[index]);
293 writesw(fifo, src + index, len >> 1);
294 index += len & ~0x01;
298 musb_writeb(fifo, 0, src[index]);
305 #if !defined(CONFIG_USB_MUSB_AM35X)
318 'R', hw_ep->
epnum, fifo, len, dst);
321 if (
likely((0x01 & (
unsigned long) dst) == 0)) {
325 if ((0x02 & (
unsigned long) dst) == 0) {
327 readsl(fifo, dst, len >> 2);
331 *(
u16 *)&dst[index] = musb_readw(fifo, 0);
336 readsw(fifo, dst, len >> 1);
341 dst[
index] = musb_readb(fifo, 0);
355 static const u8 musb_test_packet[53] = {
359 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
361 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
363 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee,
365 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
367 0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd,
369 0xfc, 0x7e, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0x7e
380 sizeof(musb_test_packet), musb_test_packet);
389 static void musb_otg_timer_func(
unsigned long data)
391 struct musb *
musb = (
struct musb *)data;
395 switch (musb->
xceiv->state) {
406 musb_platform_set_vbus(musb, 0);
414 spin_unlock_irqrestore(&musb->
lock, flags);
422 struct usb_hcd *hcd = musb_to_hcd(musb);
428 switch (musb->
xceiv->state) {
436 hcd->self.is_b_host = 0;
469 static irqreturn_t musb_stage0_irq(
struct musb *musb,
u8 int_usb,
475 dev_dbg(musb->
controller,
"<== Power=%02x, DevCtl=%02x, int_usb=0x%x\n", power, devctl,
489 switch (musb->
xceiv->state) {
502 power &= ~MUSB_POWER_SUSPENDM;
514 usb_hcd_resume_root_hub(musb_to_hcd(musb));
522 WARNING(
"bogus %s RESUME (%s)\n",
527 switch (musb->
xceiv->state) {
531 usb_hcd_resume_root_hub(musb_to_hcd(musb));
551 WARNING(
"bogus %s RESUME (%s)\n",
582 musb_platform_set_vbus(musb, 1);
606 switch (musb->
xceiv->state) {
633 dev_dbg(musb->
controller,
"VBUS_ERROR in %s (%02x, %s), retry #%d, port1 %08x\n",
637 switch (devctl & MUSB_DEVCTL_VBUS) {
639 s =
"<SessEnd";
break;
641 s =
"<AValid";
break;
643 s =
"<VBusValid";
break;
653 musb_platform_set_vbus(musb, 0);
662 switch (musb->
xceiv->state) {
672 usb_hcd_resume_root_hub(musb_to_hcd(musb));
674 musb_platform_try_idle(musb, jiffies
695 musb_platform_try_idle(musb, jiffies
714 struct usb_hcd *hcd = musb_to_hcd(musb);
740 switch (musb->
xceiv->state) {
742 if (int_usb & MUSB_INTR_SUSPEND) {
744 int_usb &= ~MUSB_INTR_SUSPEND;
753 hcd->self.is_b_host = 1;
758 if ((devctl & MUSB_DEVCTL_VBUS)
761 hcd->self.is_b_host = 0;
771 usb_hcd_resume_root_hub(hcd);
783 switch (musb->
xceiv->state) {
786 usb_hcd_resume_root_hub(musb_to_hcd(musb));
789 musb_platform_try_idle(musb, jiffies
799 musb_to_hcd(musb)->self.is_b_host = 0;
815 WARNING(
"unhandled DISCONNECT transition (%s)\n",
826 if ((devctl & MUSB_DEVCTL_HM) != 0) {
837 ERR(
"Stopping host session -- babble\n");
843 switch (musb->
xceiv->state) {
909 && (musb->
epmask >= (1 << epnum));
915 if (ep->dwWaitFrame >= frame) {
917 pr_debug(
"SOF --> periodic TX%s on %d\n",
921 musb_h_tx_start(musb, epnum);
923 cppi_hostdma_start(musb, epnum);
969 if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS)
974 musb_platform_enable(musb);
979 static void musb_generic_disable(
struct musb *musb)
1009 musb_platform_disable(musb);
1010 musb_generic_disable(musb);
1020 musb_platform_try_idle(musb, 0);
1025 struct musb *musb = dev_to_musb(&pdev->
dev);
1026 unsigned long flags;
1033 musb_platform_disable(musb);
1034 musb_generic_disable(musb);
1035 spin_unlock_irqrestore(&musb->
lock, flags);
1038 musb_platform_exit(musb);
1057 #if defined(CONFIG_USB_MUSB_TUSB6010) \
1058 || defined(CONFIG_USB_MUSB_TUSB6010_MODULE) \
1059 || defined(CONFIG_USB_MUSB_OMAP2PLUS) \
1060 || defined(CONFIG_USB_MUSB_OMAP2PLUS_MODULE) \
1061 || defined(CONFIG_USB_MUSB_AM35X) \
1062 || defined(CONFIG_USB_MUSB_AM35X_MODULE) \
1063 || defined(CONFIG_USB_MUSB_DSPS) \
1064 || defined(CONFIG_USB_MUSB_DSPS_MODULE)
1066 #elif defined(CONFIG_USB_MUSB_UX500) \
1067 || defined(CONFIG_USB_MUSB_UX500_MODULE)
1084 { .hw_ep_num = 1, .style =
FIFO_TX, .maxpacket = 512, },
1085 { .hw_ep_num = 1, .style =
FIFO_RX, .maxpacket = 512, },
1086 { .hw_ep_num = 2, .style =
FIFO_RXTX, .maxpacket = 512, },
1087 { .hw_ep_num = 3, .style =
FIFO_RXTX, .maxpacket = 256, },
1088 { .hw_ep_num = 4, .style =
FIFO_RXTX, .maxpacket = 256, },
1096 { .hw_ep_num = 3, .style =
FIFO_RXTX, .maxpacket = 256, },
1097 { .hw_ep_num = 4, .style =
FIFO_RXTX, .maxpacket = 256, },
1102 { .hw_ep_num = 1, .style =
FIFO_TX, .maxpacket = 512, },
1103 { .hw_ep_num = 1, .style =
FIFO_RX, .maxpacket = 512, },
1104 { .hw_ep_num = 2, .style =
FIFO_TX, .maxpacket = 512, },
1105 { .hw_ep_num = 2, .style =
FIFO_RX, .maxpacket = 512, },
1106 { .hw_ep_num = 3, .style =
FIFO_RXTX, .maxpacket = 256, },
1107 { .hw_ep_num = 4, .style =
FIFO_RXTX, .maxpacket = 256, },
1114 { .hw_ep_num = 2, .style =
FIFO_TX, .maxpacket = 512, },
1115 { .hw_ep_num = 2, .style =
FIFO_RX, .maxpacket = 512, },
1116 { .hw_ep_num = 3, .style =
FIFO_RXTX, .maxpacket = 256, },
1117 { .hw_ep_num = 4, .style =
FIFO_RXTX, .maxpacket = 256, },
1122 { .hw_ep_num = 1, .style =
FIFO_TX, .maxpacket = 512, },
1123 { .hw_ep_num = 1, .style =
FIFO_RX, .maxpacket = 512, },
1124 { .hw_ep_num = 2, .style =
FIFO_TX, .maxpacket = 512, },
1125 { .hw_ep_num = 2, .style =
FIFO_RX, .maxpacket = 512, },
1126 { .hw_ep_num = 3, .style =
FIFO_TX, .maxpacket = 512, },
1127 { .hw_ep_num = 3, .style =
FIFO_RX, .maxpacket = 512, },
1128 { .hw_ep_num = 4, .style =
FIFO_TX, .maxpacket = 512, },
1129 { .hw_ep_num = 4, .style =
FIFO_RX, .maxpacket = 512, },
1130 { .hw_ep_num = 5, .style =
FIFO_TX, .maxpacket = 512, },
1131 { .hw_ep_num = 5, .style =
FIFO_RX, .maxpacket = 512, },
1132 { .hw_ep_num = 6, .style =
FIFO_TX, .maxpacket = 512, },
1133 { .hw_ep_num = 6, .style =
FIFO_RX, .maxpacket = 512, },
1134 { .hw_ep_num = 7, .style =
FIFO_TX, .maxpacket = 512, },
1135 { .hw_ep_num = 7, .style =
FIFO_RX, .maxpacket = 512, },
1136 { .hw_ep_num = 8, .style =
FIFO_TX, .maxpacket = 512, },
1137 { .hw_ep_num = 8, .style =
FIFO_RX, .maxpacket = 512, },
1138 { .hw_ep_num = 9, .style =
FIFO_TX, .maxpacket = 512, },
1139 { .hw_ep_num = 9, .style =
FIFO_RX, .maxpacket = 512, },
1140 { .hw_ep_num = 10, .style =
FIFO_TX, .maxpacket = 256, },
1141 { .hw_ep_num = 10, .style =
FIFO_RX, .maxpacket = 64, },
1142 { .hw_ep_num = 11, .style =
FIFO_TX, .maxpacket = 256, },
1143 { .hw_ep_num = 11, .style =
FIFO_RX, .maxpacket = 64, },
1144 { .hw_ep_num = 12, .style =
FIFO_TX, .maxpacket = 256, },
1145 { .hw_ep_num = 12, .style =
FIFO_RX, .maxpacket = 64, },
1146 { .hw_ep_num = 13, .style =
FIFO_RXTX, .maxpacket = 4096, },
1147 { .hw_ep_num = 14, .style =
FIFO_RXTX, .maxpacket = 1024, },
1148 { .hw_ep_num = 15, .style =
FIFO_RXTX, .maxpacket = 1024, },
1153 { .hw_ep_num = 1, .style =
FIFO_TX, .maxpacket = 512, },
1154 { .hw_ep_num = 1, .style =
FIFO_RX, .maxpacket = 512, },
1155 { .hw_ep_num = 2, .style =
FIFO_TX, .maxpacket = 512, },
1156 { .hw_ep_num = 2, .style =
FIFO_RX, .maxpacket = 512, },
1157 { .hw_ep_num = 3, .style =
FIFO_TX, .maxpacket = 512, },
1158 { .hw_ep_num = 3, .style =
FIFO_RX, .maxpacket = 512, },
1159 { .hw_ep_num = 4, .style =
FIFO_TX, .maxpacket = 512, },
1160 { .hw_ep_num = 4, .style =
FIFO_RX, .maxpacket = 512, },
1161 { .hw_ep_num = 5, .style =
FIFO_TX, .maxpacket = 512, },
1162 { .hw_ep_num = 5, .style =
FIFO_RX, .maxpacket = 512, },
1163 { .hw_ep_num = 6, .style =
FIFO_TX, .maxpacket = 32, },
1164 { .hw_ep_num = 6, .style =
FIFO_RX, .maxpacket = 32, },
1165 { .hw_ep_num = 7, .style =
FIFO_TX, .maxpacket = 32, },
1166 { .hw_ep_num = 7, .style =
FIFO_RX, .maxpacket = 32, },
1167 { .hw_ep_num = 8, .style =
FIFO_TX, .maxpacket = 32, },
1168 { .hw_ep_num = 8, .style =
FIFO_RX, .maxpacket = 32, },
1169 { .hw_ep_num = 9, .style =
FIFO_TX, .maxpacket = 32, },
1170 { .hw_ep_num = 9, .style =
FIFO_RX, .maxpacket = 32, },
1171 { .hw_ep_num = 10, .style =
FIFO_TX, .maxpacket = 32, },
1172 { .hw_ep_num = 10, .style =
FIFO_RX, .maxpacket = 32, },
1173 { .hw_ep_num = 11, .style =
FIFO_TX, .maxpacket = 32, },
1174 { .hw_ep_num = 11, .style =
FIFO_RX, .maxpacket = 32, },
1175 { .hw_ep_num = 12, .style =
FIFO_TX, .maxpacket = 32, },
1176 { .hw_ep_num = 12, .style =
FIFO_RX, .maxpacket = 32, },
1177 { .hw_ep_num = 13, .style =
FIFO_RXTX, .maxpacket = 512, },
1178 { .hw_ep_num = 14, .style =
FIFO_RXTX, .maxpacket = 1024, },
1179 { .hw_ep_num = 15, .style =
FIFO_RXTX, .maxpacket = 1024, },
1189 fifo_setup(
struct musb *musb,
struct musb_hw_ep *hw_ep,
1195 u16 c_off = offset >> 3;
1200 size =
ffs(
max(maxpacket, (
u16) 8)) - 1;
1201 maxpacket = 1 <<
size;
1205 if ((offset + (maxpacket << 1)) >
1206 (1 << (musb->
config->ram_bits + 2)))
1210 if ((offset + maxpacket) > (1 << (musb->
config->ram_bits + 2)))
1220 if (hw_ep->
epnum == 1)
1223 switch (cfg->
style) {
1225 musb_write_txfifosz(mbase, c_size);
1226 musb_write_txfifoadd(mbase, c_off);
1231 musb_write_rxfifosz(mbase, c_size);
1232 musb_write_rxfifoadd(mbase, c_off);
1237 musb_write_txfifosz(mbase, c_size);
1238 musb_write_txfifoadd(mbase, c_off);
1242 musb_write_rxfifosz(mbase, c_size);
1243 musb_write_rxfifoadd(mbase, c_off);
1263 static int __devinit ep_config_from_table(
struct musb *musb)
1270 if (musb->
config->fifo_cfg) {
1271 cfg = musb->
config->fifo_cfg;
1272 n = musb->
config->fifo_cfg_size;
1276 switch (fifo_mode) {
1311 offset = fifo_setup(musb, hw_ep, &ep0_cfg, 0);
1318 for (i = 0; i <
n; i++) {
1321 if (epn >= musb->
config->num_eps) {
1326 offset = fifo_setup(musb, hw_ep + epn, cfg++, offset);
1328 pr_debug(
"%s: mem overrun, ep %d\n",
1338 n + 1, musb->
config->num_eps * 2 - 1,
1339 offset, (1 << (musb->
config->ram_bits + 2)));
1354 static int __devinit ep_config_from_hw(
struct musb *musb)
1365 for (epnum = 1; epnum < musb->
config->num_eps; epnum++) {
1369 ret = musb_read_fifosize(musb, hw_ep, epnum);
1401 static int __devinit musb_core_init(
u16 musb_type,
struct musb *musb)
1405 char aInfo[90], aRevision[32], aDate[12];
1411 reg = musb_read_configdata(mbase);
1415 strcat(aInfo,
", dyn FIFOs");
1419 strcat(aInfo,
", bulk combine");
1423 strcat(aInfo,
", bulk split");
1427 strcat(aInfo,
", HB-ISO Rx");
1431 strcat(aInfo,
", HB-ISO Tx");
1435 strcat(aInfo,
", SoftConn");
1447 #ifndef CONFIG_USB_OTG_BLACKLIST_HUB
1449 "%s: kernel must blacklist external hubs\n",
1455 musb->
hwvers = musb_read_hwvers(mbase);
1463 musb_configure_ep0(musb);
1470 status = ep_config_from_table(musb);
1472 status = ep_config_from_hw(musb);
1482 #if defined(CONFIG_USB_MUSB_TUSB6010) || defined (CONFIG_USB_MUSB_TUSB6010_MODULE)
1485 hw_ep->fifo_sync_va =
1491 hw_ep->conf = mbase + 0x400 + (((i - 1) & 0xf) << 2);
1495 hw_ep->
target_regs = musb_read_target_reg_base(i, mbase);
1501 "%s: hw_ep %d%s, %smax %d\n",
1505 ?
"doublebuffer, " :
"",
1510 "%s: hw_ep %d%s, %smax %d\n",
1514 ?
"doublebuffer, " :
"",
1526 #if defined(CONFIG_SOC_OMAP2430) || defined(CONFIG_SOC_OMAP3430) || \
1527 defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_ARCH_U8500)
1531 unsigned long flags;
1533 struct musb *musb = __hci;
1544 spin_unlock_irqrestore(&musb->
lock, flags);
1550 #define generic_interrupt NULL
1571 (devctl & MUSB_DEVCTL_HM) ?
"host" :
"peripheral",
1578 retval |= musb_stage0_irq(musb, musb->
int_usb,
1585 if (devctl & MUSB_DEVCTL_HM)
1599 if (devctl & MUSB_DEVCTL_HM)
1617 if (devctl & MUSB_DEVCTL_HM)
1630 #ifndef CONFIG_MUSB_PIO_ONLY
1644 #ifndef CONFIG_USB_TUSB_OMAP_DMA
1647 if (devctl & MUSB_DEVCTL_HM)
1656 if (devctl & MUSB_DEVCTL_HM)
1662 if (devctl & MUSB_DEVCTL_HM)
1682 struct musb *musb = dev_to_musb(dev);
1683 unsigned long flags;
1688 spin_unlock_irqrestore(&musb->
lock, flags);
1695 const char *buf,
size_t n)
1697 struct musb *musb = dev_to_musb(dev);
1698 unsigned long flags;
1703 status = musb_platform_set_mode(musb,
MUSB_HOST);
1707 status = musb_platform_set_mode(musb,
MUSB_OTG);
1710 spin_unlock_irqrestore(&musb->
lock, flags);
1712 return (status == 0) ? n :
status;
1718 const char *buf,
size_t n)
1720 struct musb *musb = dev_to_musb(dev);
1721 unsigned long flags;
1724 if (
sscanf(buf,
"%lu", &val) < 1) {
1725 dev_err(dev,
"Invalid VBUS timeout ms value\n");
1735 spin_unlock_irqrestore(&musb->
lock, flags);
1743 struct musb *musb = dev_to_musb(dev);
1744 unsigned long flags;
1753 vbus = musb_platform_get_vbus_status(musb);
1754 spin_unlock_irqrestore(&musb->
lock, flags);
1756 return sprintf(buf,
"Vbus %s, timeout %lu msec\n",
1757 vbus ?
"on" :
"off", val);
1759 static DEVICE_ATTR(vbus, 0644, musb_vbus_show, musb_vbus_store);
1766 const char *buf,
size_t n)
1768 struct musb *musb = dev_to_musb(dev);
1771 if (
sscanf(buf,
"%hu", &srp) != 1
1773 dev_err(dev,
"SRP: Value must be 1\n");
1784 static struct attribute *musb_attributes[] = {
1785 &dev_attr_mode.attr,
1786 &dev_attr_vbus.attr,
1792 .
attrs = musb_attributes,
1798 static void musb_irq_work(
struct work_struct *data)
1813 allocate_instance(
struct device *dev,
1819 struct usb_hcd *hcd;
1826 musb = hcd_to_musb(hcd);
1827 INIT_LIST_HEAD(&musb->
control);
1828 INIT_LIST_HEAD(&musb->
in_bulk);
1831 hcd->uses_new_polling = 1;
1837 musb->
mregs = mbase;
1843 epnum < musb->config->
num_eps;
1854 static void musb_free(
struct musb *musb)
1865 if (musb->
nIrq >= 0) {
1867 disable_irq_wake(musb->
nIrq);
1894 struct usb_hcd *hcd;
1900 dev_dbg(dev,
"no platform_data?\n");
1906 musb = allocate_instance(dev, plat->
config, ctrl);
1912 pm_runtime_use_autosuspend(musb->
controller);
1933 status = musb_platform_init(musb);
1942 if (!musb->
xceiv->io_ops) {
1945 musb->
xceiv->io_ops = &musb_ulpi_access;
1950 #ifndef CONFIG_MUSB_PIO_ONLY
1965 musb_platform_disable(musb);
1966 musb_generic_disable(musb);
1969 status = musb_core_init(plat->
config->multipoint
1982 dev_err(dev,
"request_irq %d failed!\n", nIrq);
1988 if (enable_irq_wake(nIrq) == 0) {
1996 hcd = musb_to_hcd(musb);
1997 otg_set_host(musb->
xceiv->otg, &hcd->self);
1998 hcd->self.otg_port = 1;
1999 musb->
xceiv->otg->host = &hcd->self;
2000 hcd->power_budget = 2 * (plat->
power ? : 250);
2004 u8 busctl = musb_read_ulpi_buscontrol(musb->
mregs);
2006 musb_write_ulpi_buscontrol(musb->
mregs, busctl);
2010 musb->
xceiv->otg->default_a = 0;
2044 musb_platform_exit(musb);
2048 "musb_init_controller failed with status %d\n", status);
2072 if (!iomem || irq <= 0)
2077 dev_err(dev,
"ioremap failed\n");
2081 status = musb_init_controller(dev, irq, base);
2091 struct musb *musb = dev_to_musb(dev);
2100 musb_shutdown(pdev);
2105 #ifndef CONFIG_MUSB_PIO_ONLY
2113 static void musb_save_context(
struct musb *musb)
2121 musb->
context.busctl = musb_read_ulpi_buscontrol(musb->
mregs);
2129 for (i = 0; i < musb->
config->num_eps; ++
i) {
2141 musb->
context.index_regs[
i].txmaxp =
2143 musb->
context.index_regs[
i].txcsr =
2145 musb->
context.index_regs[
i].rxmaxp =
2147 musb->
context.index_regs[
i].rxcsr =
2151 musb->
context.index_regs[
i].txfifoadd =
2152 musb_read_txfifoadd(musb_base);
2153 musb->
context.index_regs[
i].rxfifoadd =
2154 musb_read_rxfifoadd(musb_base);
2155 musb->
context.index_regs[
i].txfifosz =
2156 musb_read_txfifosz(musb_base);
2157 musb->
context.index_regs[
i].rxfifosz =
2158 musb_read_rxfifosz(musb_base);
2161 musb->
context.index_regs[
i].txtype =
2163 musb->
context.index_regs[
i].txinterval =
2165 musb->
context.index_regs[
i].rxtype =
2167 musb->
context.index_regs[
i].rxinterval =
2170 musb->
context.index_regs[
i].txfunaddr =
2171 musb_read_txfunaddr(musb_base, i);
2172 musb->
context.index_regs[
i].txhubaddr =
2173 musb_read_txhubaddr(musb_base, i);
2174 musb->
context.index_regs[
i].txhubport =
2175 musb_read_txhubport(musb_base, i);
2177 musb->
context.index_regs[
i].rxfunaddr =
2178 musb_read_rxfunaddr(musb_base, i);
2179 musb->
context.index_regs[
i].rxhubaddr =
2180 musb_read_rxhubaddr(musb_base, i);
2181 musb->
context.index_regs[
i].rxhubport =
2182 musb_read_rxhubport(musb_base, i);
2186 static void musb_restore_context(
struct musb *musb)
2195 musb_write_ulpi_buscontrol(musb->
mregs, musb->
context.busctl);
2202 for (i = 0; i < musb->
config->num_eps; ++
i) {
2215 musb->
context.index_regs[i].txmaxp);
2217 musb->
context.index_regs[i].txcsr);
2219 musb->
context.index_regs[i].rxmaxp);
2221 musb->
context.index_regs[i].rxcsr);
2224 musb_write_txfifosz(musb_base,
2225 musb->
context.index_regs[i].txfifosz);
2226 musb_write_rxfifosz(musb_base,
2227 musb->
context.index_regs[i].rxfifosz);
2228 musb_write_txfifoadd(musb_base,
2229 musb->
context.index_regs[i].txfifoadd);
2230 musb_write_rxfifoadd(musb_base,
2231 musb->
context.index_regs[i].rxfifoadd);
2235 musb->
context.index_regs[i].txtype);
2237 musb->
context.index_regs[i].txinterval);
2239 musb->
context.index_regs[i].rxtype);
2242 musb->
context.index_regs[i].rxinterval);
2243 musb_write_txfunaddr(musb_base, i,
2244 musb->
context.index_regs[i].txfunaddr);
2245 musb_write_txhubaddr(musb_base, i,
2246 musb->
context.index_regs[i].txhubaddr);
2247 musb_write_txhubport(musb_base, i,
2248 musb->
context.index_regs[i].txhubport);
2251 musb_read_target_reg_base(i, musb_base);
2253 musb_write_rxfunaddr(ep_target_regs,
2254 musb->
context.index_regs[i].rxfunaddr);
2255 musb_write_rxhubaddr(ep_target_regs,
2256 musb->
context.index_regs[i].rxhubaddr);
2257 musb_write_rxhubport(ep_target_regs,
2258 musb->
context.index_regs[i].rxhubport);
2263 static int musb_suspend(
struct device *dev)
2265 struct musb *musb = dev_to_musb(dev);
2266 unsigned long flags;
2280 spin_unlock_irqrestore(&musb->
lock, flags);
2284 static int musb_resume_noirq(
struct device *dev)
2293 static int musb_runtime_suspend(
struct device *dev)
2295 struct musb *musb = dev_to_musb(dev);
2297 musb_save_context(musb);
2302 static int musb_runtime_resume(
struct device *dev)
2304 struct musb *musb = dev_to_musb(dev);
2305 static int first = 1;
2317 musb_restore_context(musb);
2323 static const struct dev_pm_ops musb_dev_pm_ops = {
2325 .resume_noirq = musb_resume_noirq,
2326 .runtime_suspend = musb_runtime_suspend,
2327 .runtime_resume = musb_runtime_resume,
2330 #define MUSB_DEV_PM_OPS (&musb_dev_pm_ops)
2332 #define MUSB_DEV_PM_OPS NULL
2342 .
probe = musb_probe,
2344 .shutdown = musb_shutdown,
2349 static int __init musb_init(
void)
2357 "otg (peripheral+host)",
2363 static void __exit musb_cleanup(
void)