2 * Texas Instruments DSPS platforms "glue layer"
4 * Copyright (C) 2012, by Texas Instruments
6 * Based on the am35x "glue layer" code.
8 * This file is part of the Inventra Controller Driver for Linux.
10 * The Inventra Controller Driver for Linux is free software; you
11 * can redistribute it and/or modify it under the terms of the GNU
12 * General Public License version 2 as published by the Free Software
15 * The Inventra Controller Driver for Linux is distributed in
16 * the hope that it will be useful, but WITHOUT ANY WARRANTY;
17 * without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
19 * License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with The Inventra Controller Driver for Linux ; if not,
23 * write to the Free Software Foundation, Inc., 59 Temple Place,
24 * Suite 330, Boston, MA 02111-1307 USA
26 * musb_dsps.c will be a common file for all the TI DSPS platforms
27 * such as dm64x, dm36x, dm35x, da8x, am35x and ti81x.
28 * For now only ti81x is using this and in future davinci.c, am35x.c
29 * da8xx.c would be merged to this file after testing.
33 #include <linux/err.h>
34 #include <linux/platform_device.h>
35 #include <linux/dma-mapping.h>
36 #include <linux/pm_runtime.h>
37 #include <linux/module.h>
38 #include <linux/usb/usb_phy_generic.h>
39 #include <linux/platform_data/usb-omap.h>
40 #include <linux/sizes.h>
43 #include <linux/of_device.h>
44 #include <linux/of_address.h>
45 #include <linux/of_irq.h>
46 #include <linux/usb/of.h>
48 #include <linux/debugfs.h>
50 #include "musb_core.h"
52 static const struct of_device_id musb_dsps_of_match[];
55 * DSPS musb wrapper register offset.
56 * FIXME: This should be expanded to have all the wrapper registers from TI DSPS
59 struct dsps_musb_wrapper {
74 /* bit positions for control */
77 /* bit positions for interrupt */
83 unsigned txep_shift:5;
87 unsigned rxep_shift:5;
91 /* bit positions for phy_utmi */
92 unsigned otg_disable:5;
94 /* bit positions for mode */
97 /* miscellaneous stuff */
98 unsigned poll_timeout;
102 * register shadow for suspend
104 struct dsps_context {
115 * DSPS glue structure.
119 struct platform_device *musb; /* child musb pdev */
120 const struct dsps_musb_wrapper *wrp; /* wrapper register offsets */
121 struct timer_list timer; /* otg_workaround timer */
122 unsigned long last_timer; /* last timer data for each instance */
123 bool sw_babble_enabled;
125 struct dsps_context context;
126 struct debugfs_regset32 regset;
127 struct dentry *dbgfs_root;
130 static const struct debugfs_reg32 dsps_musb_regs[] = {
131 { "revision", 0x00 },
135 { "intr0_stat", 0x30 },
136 { "intr1_stat", 0x34 },
137 { "intr0_set", 0x38 },
138 { "intr1_set", 0x3c },
142 { "srpfixtime", 0xd4 },
144 { "phy_utmi", 0xe0 },
149 * dsps_musb_enable - enable interrupts
151 static void dsps_musb_enable(struct musb *musb)
153 struct device *dev = musb->controller;
154 struct platform_device *pdev = to_platform_device(dev->parent);
155 struct dsps_glue *glue = platform_get_drvdata(pdev);
156 const struct dsps_musb_wrapper *wrp = glue->wrp;
157 void __iomem *reg_base = musb->ctrl_base;
158 u32 epmask, coremask;
160 /* Workaround: setup IRQs through both register sets. */
161 epmask = ((musb->epmask & wrp->txep_mask) << wrp->txep_shift) |
162 ((musb->epmask & wrp->rxep_mask) << wrp->rxep_shift);
163 coremask = (wrp->usb_bitmap & ~MUSB_INTR_SOF);
165 musb_writel(reg_base, wrp->epintr_set, epmask);
166 musb_writel(reg_base, wrp->coreintr_set, coremask);
167 /* start polling for ID change in dual-role idle mode */
168 if (musb->xceiv->otg->state == OTG_STATE_B_IDLE &&
169 musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE)
170 mod_timer(&glue->timer, jiffies +
171 msecs_to_jiffies(wrp->poll_timeout));
175 * dsps_musb_disable - disable HDRC and flush interrupts
177 static void dsps_musb_disable(struct musb *musb)
179 struct device *dev = musb->controller;
180 struct platform_device *pdev = to_platform_device(dev->parent);
181 struct dsps_glue *glue = platform_get_drvdata(pdev);
182 const struct dsps_musb_wrapper *wrp = glue->wrp;
183 void __iomem *reg_base = musb->ctrl_base;
185 musb_writel(reg_base, wrp->coreintr_clear, wrp->usb_bitmap);
186 musb_writel(reg_base, wrp->epintr_clear,
187 wrp->txep_bitmap | wrp->rxep_bitmap);
188 musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
191 static void otg_timer(unsigned long _musb)
193 struct musb *musb = (void *)_musb;
194 void __iomem *mregs = musb->mregs;
195 struct device *dev = musb->controller;
196 struct dsps_glue *glue = dev_get_drvdata(dev->parent);
197 const struct dsps_musb_wrapper *wrp = glue->wrp;
200 int skip_session = 0;
203 err = pm_runtime_get_sync(dev);
205 dev_err(dev, "Poll could not pm_runtime_get: %i\n", err);
208 * We poll because DSPS IP's won't expose several OTG-critical
209 * status change events (from the transceiver) otherwise.
211 devctl = musb_readb(mregs, MUSB_DEVCTL);
212 dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
213 usb_otg_state_string(musb->xceiv->otg->state));
215 spin_lock_irqsave(&musb->lock, flags);
216 switch (musb->xceiv->otg->state) {
217 case OTG_STATE_A_WAIT_VRISE:
218 mod_timer(&glue->timer, jiffies +
219 msecs_to_jiffies(wrp->poll_timeout));
221 case OTG_STATE_A_WAIT_BCON:
222 musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
226 case OTG_STATE_A_IDLE:
227 case OTG_STATE_B_IDLE:
228 if (devctl & MUSB_DEVCTL_BDEVICE) {
229 musb->xceiv->otg->state = OTG_STATE_B_IDLE;
232 musb->xceiv->otg->state = OTG_STATE_A_IDLE;
235 if (!(devctl & MUSB_DEVCTL_SESSION) && !skip_session)
236 musb_writeb(mregs, MUSB_DEVCTL, MUSB_DEVCTL_SESSION);
237 mod_timer(&glue->timer, jiffies +
238 msecs_to_jiffies(wrp->poll_timeout));
240 case OTG_STATE_A_WAIT_VFALL:
241 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
242 musb_writel(musb->ctrl_base, wrp->coreintr_set,
243 MUSB_INTR_VBUSERROR << wrp->usb_shift);
248 spin_unlock_irqrestore(&musb->lock, flags);
250 pm_runtime_mark_last_busy(dev);
251 pm_runtime_put_autosuspend(dev);
254 static irqreturn_t dsps_interrupt(int irq, void *hci)
256 struct musb *musb = hci;
257 void __iomem *reg_base = musb->ctrl_base;
258 struct device *dev = musb->controller;
259 struct dsps_glue *glue = dev_get_drvdata(dev->parent);
260 const struct dsps_musb_wrapper *wrp = glue->wrp;
262 irqreturn_t ret = IRQ_NONE;
265 spin_lock_irqsave(&musb->lock, flags);
267 /* Get endpoint interrupts */
268 epintr = musb_readl(reg_base, wrp->epintr_status);
269 musb->int_rx = (epintr & wrp->rxep_bitmap) >> wrp->rxep_shift;
270 musb->int_tx = (epintr & wrp->txep_bitmap) >> wrp->txep_shift;
273 musb_writel(reg_base, wrp->epintr_status, epintr);
275 /* Get usb core interrupts */
276 usbintr = musb_readl(reg_base, wrp->coreintr_status);
277 if (!usbintr && !epintr)
280 musb->int_usb = (usbintr & wrp->usb_bitmap) >> wrp->usb_shift;
282 musb_writel(reg_base, wrp->coreintr_status, usbintr);
284 dev_dbg(musb->controller, "usbintr (%x) epintr(%x)\n",
287 if (usbintr & ((1 << wrp->drvvbus) << wrp->usb_shift)) {
288 int drvvbus = musb_readl(reg_base, wrp->status);
289 void __iomem *mregs = musb->mregs;
290 u8 devctl = musb_readb(mregs, MUSB_DEVCTL);
293 err = musb->int_usb & MUSB_INTR_VBUSERROR;
296 * The Mentor core doesn't debounce VBUS as needed
297 * to cope with device connect current spikes. This
298 * means it's not uncommon for bus-powered devices
299 * to get VBUS errors during enumeration.
301 * This is a workaround, but newer RTL from Mentor
302 * seems to allow a better one: "re"-starting sessions
303 * without waiting for VBUS to stop registering in
306 musb->int_usb &= ~MUSB_INTR_VBUSERROR;
307 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
308 mod_timer(&glue->timer, jiffies +
309 msecs_to_jiffies(wrp->poll_timeout));
310 WARNING("VBUS error workaround (delay coming)\n");
311 } else if (drvvbus) {
313 musb->xceiv->otg->default_a = 1;
314 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
315 mod_timer(&glue->timer, jiffies +
316 msecs_to_jiffies(wrp->poll_timeout));
320 musb->xceiv->otg->default_a = 0;
321 musb->xceiv->otg->state = OTG_STATE_B_IDLE;
324 /* NOTE: this must complete power-on within 100 ms. */
325 dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
326 drvvbus ? "on" : "off",
327 usb_otg_state_string(musb->xceiv->otg->state),
333 if (musb->int_tx || musb->int_rx || musb->int_usb)
334 ret |= musb_interrupt(musb);
336 /* Poll for ID change and connect */
337 switch (musb->xceiv->otg->state) {
338 case OTG_STATE_B_IDLE:
339 case OTG_STATE_A_WAIT_BCON:
340 mod_timer(&glue->timer, jiffies +
341 msecs_to_jiffies(wrp->poll_timeout));
348 spin_unlock_irqrestore(&musb->lock, flags);
353 static int dsps_musb_dbg_init(struct musb *musb, struct dsps_glue *glue)
359 sprintf(buf, "%s.dsps", dev_name(musb->controller));
360 root = debugfs_create_dir(buf, NULL);
363 glue->dbgfs_root = root;
365 glue->regset.regs = dsps_musb_regs;
366 glue->regset.nregs = ARRAY_SIZE(dsps_musb_regs);
367 glue->regset.base = musb->ctrl_base;
369 file = debugfs_create_regset32("regdump", S_IRUGO, root, &glue->regset);
371 debugfs_remove_recursive(root);
377 static int dsps_musb_init(struct musb *musb)
379 struct device *dev = musb->controller;
380 struct dsps_glue *glue = dev_get_drvdata(dev->parent);
381 struct platform_device *parent = to_platform_device(dev->parent);
382 const struct dsps_musb_wrapper *wrp = glue->wrp;
383 void __iomem *reg_base;
388 r = platform_get_resource_byname(parent, IORESOURCE_MEM, "control");
389 reg_base = devm_ioremap_resource(dev, r);
390 if (IS_ERR(reg_base))
391 return PTR_ERR(reg_base);
392 musb->ctrl_base = reg_base;
394 /* NOP driver needs change if supporting dual instance */
395 musb->xceiv = devm_usb_get_phy_by_phandle(dev->parent, "phys", 0);
396 if (IS_ERR(musb->xceiv))
397 return PTR_ERR(musb->xceiv);
399 musb->phy = devm_phy_get(dev->parent, "usb2-phy");
401 /* Returns zero if e.g. not clocked */
402 rev = musb_readl(reg_base, wrp->revision);
406 usb_phy_init(musb->xceiv);
407 if (IS_ERR(musb->phy)) {
410 ret = phy_init(musb->phy);
413 ret = phy_power_on(musb->phy);
420 setup_timer(&glue->timer, otg_timer, (unsigned long) musb);
423 musb_writel(reg_base, wrp->control, (1 << wrp->reset));
425 musb->isr = dsps_interrupt;
427 /* reset the otgdisable bit, needed for host mode to work */
428 val = musb_readl(reg_base, wrp->phy_utmi);
429 val &= ~(1 << wrp->otg_disable);
430 musb_writel(musb->ctrl_base, wrp->phy_utmi, val);
433 * Check whether the dsps version has babble control enabled.
434 * In latest silicon revision the babble control logic is enabled.
435 * If MUSB_BABBLE_CTL returns 0x4 then we have the babble control
438 val = musb_readb(musb->mregs, MUSB_BABBLE_CTL);
439 if (val & MUSB_BABBLE_RCV_DISABLE) {
440 glue->sw_babble_enabled = true;
441 val |= MUSB_BABBLE_SW_SESSION_CTRL;
442 musb_writeb(musb->mregs, MUSB_BABBLE_CTL, val);
445 mod_timer(&glue->timer, jiffies +
446 msecs_to_jiffies(glue->wrp->poll_timeout));
448 return dsps_musb_dbg_init(musb, glue);
451 static int dsps_musb_exit(struct musb *musb)
453 struct device *dev = musb->controller;
454 struct dsps_glue *glue = dev_get_drvdata(dev->parent);
456 del_timer_sync(&glue->timer);
457 usb_phy_shutdown(musb->xceiv);
458 phy_power_off(musb->phy);
460 debugfs_remove_recursive(glue->dbgfs_root);
465 static int dsps_musb_set_mode(struct musb *musb, u8 mode)
467 struct device *dev = musb->controller;
468 struct dsps_glue *glue = dev_get_drvdata(dev->parent);
469 const struct dsps_musb_wrapper *wrp = glue->wrp;
470 void __iomem *ctrl_base = musb->ctrl_base;
473 reg = musb_readl(ctrl_base, wrp->mode);
477 reg &= ~(1 << wrp->iddig);
480 * if we're setting mode to host-only or device-only, we're
481 * going to ignore whatever the PHY sends us and just force
482 * ID pin status by SW
484 reg |= (1 << wrp->iddig_mux);
486 musb_writel(ctrl_base, wrp->mode, reg);
487 musb_writel(ctrl_base, wrp->phy_utmi, 0x02);
489 case MUSB_PERIPHERAL:
490 reg |= (1 << wrp->iddig);
493 * if we're setting mode to host-only or device-only, we're
494 * going to ignore whatever the PHY sends us and just force
495 * ID pin status by SW
497 reg |= (1 << wrp->iddig_mux);
499 musb_writel(ctrl_base, wrp->mode, reg);
502 musb_writel(ctrl_base, wrp->phy_utmi, 0x02);
505 dev_err(glue->dev, "unsupported mode %d\n", mode);
512 static bool dsps_sw_babble_control(struct musb *musb)
515 bool session_restart = false;
517 babble_ctl = musb_readb(musb->mregs, MUSB_BABBLE_CTL);
518 dev_dbg(musb->controller, "babble: MUSB_BABBLE_CTL value %x\n",
521 * check line monitor flag to check whether babble is
524 dev_dbg(musb->controller, "STUCK_J is %s\n",
525 babble_ctl & MUSB_BABBLE_STUCK_J ? "set" : "reset");
527 if (babble_ctl & MUSB_BABBLE_STUCK_J) {
531 * babble is due to noise, then set transmit idle (d7 bit)
532 * to resume normal operation
534 babble_ctl = musb_readb(musb->mregs, MUSB_BABBLE_CTL);
535 babble_ctl |= MUSB_BABBLE_FORCE_TXIDLE;
536 musb_writeb(musb->mregs, MUSB_BABBLE_CTL, babble_ctl);
538 /* wait till line monitor flag cleared */
539 dev_dbg(musb->controller, "Set TXIDLE, wait J to clear\n");
541 babble_ctl = musb_readb(musb->mregs, MUSB_BABBLE_CTL);
543 } while ((babble_ctl & MUSB_BABBLE_STUCK_J) && timeout--);
545 /* check whether stuck_at_j bit cleared */
546 if (babble_ctl & MUSB_BABBLE_STUCK_J) {
548 * real babble condition has occurred
549 * restart the controller to start the
552 dev_dbg(musb->controller, "J not cleared, misc (%x)\n",
554 session_restart = true;
557 session_restart = true;
560 return session_restart;
563 static int dsps_musb_recover(struct musb *musb)
565 struct device *dev = musb->controller;
566 struct dsps_glue *glue = dev_get_drvdata(dev->parent);
567 int session_restart = 0;
569 if (glue->sw_babble_enabled)
570 session_restart = dsps_sw_babble_control(musb);
574 return session_restart ? 0 : -EPIPE;
577 /* Similar to am35x, dm81xx support only 32-bit read operation */
578 static void dsps_read_fifo32(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
580 void __iomem *fifo = hw_ep->fifo;
583 ioread32_rep(fifo, dst, len >> 2);
588 /* Read any remaining 1 to 3 bytes */
590 u32 val = musb_readl(fifo, 0);
591 memcpy(dst, &val, len);
595 static struct musb_platform_ops dsps_ops = {
596 .quirks = MUSB_DMA_CPPI41 | MUSB_INDEXED_EP,
597 .init = dsps_musb_init,
598 .exit = dsps_musb_exit,
600 #ifdef CONFIG_USB_TI_CPPI41_DMA
601 .dma_init = cppi41_dma_controller_create,
602 .dma_exit = cppi41_dma_controller_destroy,
604 .enable = dsps_musb_enable,
605 .disable = dsps_musb_disable,
607 .set_mode = dsps_musb_set_mode,
608 .recover = dsps_musb_recover,
611 static u64 musb_dmamask = DMA_BIT_MASK(32);
613 static int get_int_prop(struct device_node *dn, const char *s)
618 ret = of_property_read_u32(dn, s, &val);
624 static int get_musb_port_mode(struct device *dev)
626 enum usb_dr_mode mode;
628 mode = usb_get_dr_mode(dev);
630 case USB_DR_MODE_HOST:
631 return MUSB_PORT_MODE_HOST;
633 case USB_DR_MODE_PERIPHERAL:
634 return MUSB_PORT_MODE_GADGET;
636 case USB_DR_MODE_UNKNOWN:
637 case USB_DR_MODE_OTG:
639 return MUSB_PORT_MODE_DUAL_ROLE;
643 static int dsps_create_musb_pdev(struct dsps_glue *glue,
644 struct platform_device *parent)
646 struct musb_hdrc_platform_data pdata;
647 struct resource resources[2];
648 struct resource *res;
649 struct device *dev = &parent->dev;
650 struct musb_hdrc_config *config;
651 struct platform_device *musb;
652 struct device_node *dn = parent->dev.of_node;
655 memset(resources, 0, sizeof(resources));
656 res = platform_get_resource_byname(parent, IORESOURCE_MEM, "mc");
658 dev_err(dev, "failed to get memory.\n");
663 res = platform_get_resource_byname(parent, IORESOURCE_IRQ, "mc");
665 dev_err(dev, "failed to get irq.\n");
670 /* allocate the child platform device */
671 musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
673 dev_err(dev, "failed to allocate musb device\n");
677 musb->dev.parent = dev;
678 musb->dev.dma_mask = &musb_dmamask;
679 musb->dev.coherent_dma_mask = musb_dmamask;
683 ret = platform_device_add_resources(musb, resources,
684 ARRAY_SIZE(resources));
686 dev_err(dev, "failed to add resources\n");
690 config = devm_kzalloc(&parent->dev, sizeof(*config), GFP_KERNEL);
695 pdata.config = config;
696 pdata.platform_ops = &dsps_ops;
698 config->num_eps = get_int_prop(dn, "mentor,num-eps");
699 config->ram_bits = get_int_prop(dn, "mentor,ram-bits");
700 config->host_port_deassert_reset_at_resume = 1;
701 pdata.mode = get_musb_port_mode(dev);
702 /* DT keeps this entry in mA, musb expects it as per USB spec */
703 pdata.power = get_int_prop(dn, "mentor,power") / 2;
705 ret = of_property_read_u32(dn, "mentor,multipoint", &val);
707 config->multipoint = true;
709 config->maximum_speed = usb_get_maximum_speed(&parent->dev);
710 switch (config->maximum_speed) {
714 case USB_SPEED_SUPER:
715 dev_warn(dev, "ignore incorrect maximum_speed "
716 "(super-speed) setting in dts");
719 config->maximum_speed = USB_SPEED_HIGH;
722 ret = platform_device_add_data(musb, &pdata, sizeof(pdata));
724 dev_err(dev, "failed to add platform_data\n");
728 ret = platform_device_add(musb);
730 dev_err(dev, "failed to register musb device\n");
736 platform_device_put(musb);
740 static int dsps_probe(struct platform_device *pdev)
742 const struct of_device_id *match;
743 const struct dsps_musb_wrapper *wrp;
744 struct dsps_glue *glue;
747 if (!strcmp(pdev->name, "musb-hdrc"))
750 match = of_match_node(musb_dsps_of_match, pdev->dev.of_node);
752 dev_err(&pdev->dev, "fail to get matching of_match struct\n");
757 if (of_device_is_compatible(pdev->dev.of_node, "ti,musb-dm816"))
758 dsps_ops.read_fifo = dsps_read_fifo32;
761 glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
765 glue->dev = &pdev->dev;
768 platform_set_drvdata(pdev, glue);
769 pm_runtime_enable(&pdev->dev);
770 pm_runtime_use_autosuspend(&pdev->dev);
771 pm_runtime_set_autosuspend_delay(&pdev->dev, 200);
773 ret = pm_runtime_get_sync(&pdev->dev);
775 dev_err(&pdev->dev, "pm_runtime_get_sync FAILED");
779 ret = dsps_create_musb_pdev(glue, pdev);
783 pm_runtime_mark_last_busy(&pdev->dev);
784 pm_runtime_put_autosuspend(&pdev->dev);
789 pm_runtime_put_sync(&pdev->dev);
791 pm_runtime_dont_use_autosuspend(&pdev->dev);
792 pm_runtime_disable(&pdev->dev);
796 static int dsps_remove(struct platform_device *pdev)
798 struct dsps_glue *glue = platform_get_drvdata(pdev);
800 platform_device_unregister(glue->musb);
802 /* disable usbss clocks */
803 pm_runtime_dont_use_autosuspend(&pdev->dev);
804 pm_runtime_put_sync(&pdev->dev);
805 pm_runtime_disable(&pdev->dev);
810 static const struct dsps_musb_wrapper am33xx_driver_data = {
815 .epintr_clear = 0x40,
816 .epintr_status = 0x30,
817 .coreintr_set = 0x3c,
818 .coreintr_clear = 0x44,
819 .coreintr_status = 0x34,
830 .usb_bitmap = (0x1ff << 0),
834 .txep_bitmap = (0xffff << 0),
837 .rxep_bitmap = (0xfffe << 16),
838 .poll_timeout = 2000, /* ms */
841 static const struct of_device_id musb_dsps_of_match[] = {
842 { .compatible = "ti,musb-am33xx",
843 .data = &am33xx_driver_data, },
844 { .compatible = "ti,musb-dm816",
845 .data = &am33xx_driver_data, },
848 MODULE_DEVICE_TABLE(of, musb_dsps_of_match);
850 #ifdef CONFIG_PM_SLEEP
851 static int dsps_suspend(struct device *dev)
853 struct dsps_glue *glue = dev_get_drvdata(dev);
854 const struct dsps_musb_wrapper *wrp = glue->wrp;
855 struct musb *musb = platform_get_drvdata(glue->musb);
858 del_timer_sync(&glue->timer);
861 /* This can happen if the musb device is in -EPROBE_DEFER */
864 mbase = musb->ctrl_base;
865 glue->context.control = musb_readl(mbase, wrp->control);
866 glue->context.epintr = musb_readl(mbase, wrp->epintr_set);
867 glue->context.coreintr = musb_readl(mbase, wrp->coreintr_set);
868 glue->context.phy_utmi = musb_readl(mbase, wrp->phy_utmi);
869 glue->context.mode = musb_readl(mbase, wrp->mode);
870 glue->context.tx_mode = musb_readl(mbase, wrp->tx_mode);
871 glue->context.rx_mode = musb_readl(mbase, wrp->rx_mode);
876 static int dsps_resume(struct device *dev)
878 struct dsps_glue *glue = dev_get_drvdata(dev);
879 const struct dsps_musb_wrapper *wrp = glue->wrp;
880 struct musb *musb = platform_get_drvdata(glue->musb);
886 mbase = musb->ctrl_base;
887 musb_writel(mbase, wrp->control, glue->context.control);
888 musb_writel(mbase, wrp->epintr_set, glue->context.epintr);
889 musb_writel(mbase, wrp->coreintr_set, glue->context.coreintr);
890 musb_writel(mbase, wrp->phy_utmi, glue->context.phy_utmi);
891 musb_writel(mbase, wrp->mode, glue->context.mode);
892 musb_writel(mbase, wrp->tx_mode, glue->context.tx_mode);
893 musb_writel(mbase, wrp->rx_mode, glue->context.rx_mode);
894 if (musb->xceiv->otg->state == OTG_STATE_B_IDLE &&
895 musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE)
896 mod_timer(&glue->timer, jiffies +
897 msecs_to_jiffies(wrp->poll_timeout));
903 static SIMPLE_DEV_PM_OPS(dsps_pm_ops, dsps_suspend, dsps_resume);
905 static struct platform_driver dsps_usbss_driver = {
907 .remove = dsps_remove,
911 .of_match_table = musb_dsps_of_match,
915 MODULE_DESCRIPTION("TI DSPS MUSB Glue Layer");
918 MODULE_LICENSE("GPL v2");
920 module_platform_driver(dsps_usbss_driver);