xref: /linux/drivers/usb/musb/musb_dsps.c (revision 0f901c980110cd69b63670096465b35377e73b1c)
19ecb8875SAjay Kumar Gupta /*
29ecb8875SAjay Kumar Gupta  * Texas Instruments DSPS platforms "glue layer"
39ecb8875SAjay Kumar Gupta  *
49ecb8875SAjay Kumar Gupta  * Copyright (C) 2012, by Texas Instruments
59ecb8875SAjay Kumar Gupta  *
69ecb8875SAjay Kumar Gupta  * Based on the am35x "glue layer" code.
79ecb8875SAjay Kumar Gupta  *
89ecb8875SAjay Kumar Gupta  * This file is part of the Inventra Controller Driver for Linux.
99ecb8875SAjay Kumar Gupta  *
109ecb8875SAjay Kumar Gupta  * The Inventra Controller Driver for Linux is free software; you
119ecb8875SAjay Kumar Gupta  * can redistribute it and/or modify it under the terms of the GNU
129ecb8875SAjay Kumar Gupta  * General Public License version 2 as published by the Free Software
139ecb8875SAjay Kumar Gupta  * Foundation.
149ecb8875SAjay Kumar Gupta  *
159ecb8875SAjay Kumar Gupta  * The Inventra Controller Driver for Linux is distributed in
169ecb8875SAjay Kumar Gupta  * the hope that it will be useful, but WITHOUT ANY WARRANTY;
179ecb8875SAjay Kumar Gupta  * without even the implied warranty of MERCHANTABILITY or
189ecb8875SAjay Kumar Gupta  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
199ecb8875SAjay Kumar Gupta  * License for more details.
209ecb8875SAjay Kumar Gupta  *
219ecb8875SAjay Kumar Gupta  * You should have received a copy of the GNU General Public License
229ecb8875SAjay Kumar Gupta  * along with The Inventra Controller Driver for Linux ; if not,
239ecb8875SAjay Kumar Gupta  * write to the Free Software Foundation, Inc., 59 Temple Place,
249ecb8875SAjay Kumar Gupta  * Suite 330, Boston, MA  02111-1307  USA
259ecb8875SAjay Kumar Gupta  *
269ecb8875SAjay Kumar Gupta  * musb_dsps.c will be a common file for all the TI DSPS platforms
279ecb8875SAjay Kumar Gupta  * such as dm64x, dm36x, dm35x, da8x, am35x and ti81x.
289ecb8875SAjay Kumar Gupta  * For now only ti81x is using this and in future davinci.c, am35x.c
299ecb8875SAjay Kumar Gupta  * da8xx.c would be merged to this file after testing.
309ecb8875SAjay Kumar Gupta  */
319ecb8875SAjay Kumar Gupta 
329ecb8875SAjay Kumar Gupta #include <linux/init.h>
339ecb8875SAjay Kumar Gupta #include <linux/io.h>
34ded017eeSKishon Vijay Abraham I #include <linux/err.h>
359ecb8875SAjay Kumar Gupta #include <linux/platform_device.h>
369ecb8875SAjay Kumar Gupta #include <linux/dma-mapping.h>
379ecb8875SAjay Kumar Gupta #include <linux/pm_runtime.h>
389ecb8875SAjay Kumar Gupta #include <linux/module.h>
393fa4d734SSebastian Andrzej Siewior #include <linux/usb/usb_phy_gen_xceiv.h>
40e8c4a7acSFelipe Balbi #include <linux/platform_data/usb-omap.h>
410f53e481SFelipe Balbi #include <linux/sizes.h>
429ecb8875SAjay Kumar Gupta 
439ecb8875SAjay Kumar Gupta #include <linux/of.h>
449ecb8875SAjay Kumar Gupta #include <linux/of_device.h>
459ecb8875SAjay Kumar Gupta #include <linux/of_address.h>
4697238b35SSebastian Andrzej Siewior #include <linux/of_irq.h>
47c031a7d4SSebastian Andrzej Siewior #include <linux/usb/of.h>
489ecb8875SAjay Kumar Gupta 
499ecb8875SAjay Kumar Gupta #include "musb_core.h"
509ecb8875SAjay Kumar Gupta 
5165145677SAjay Kumar Gupta static const struct of_device_id musb_dsps_of_match[];
5265145677SAjay Kumar Gupta 
539ecb8875SAjay Kumar Gupta /**
549ecb8875SAjay Kumar Gupta  * avoid using musb_readx()/musb_writex() as glue layer should not be
559ecb8875SAjay Kumar Gupta  * dependent on musb core layer symbols.
569ecb8875SAjay Kumar Gupta  */
579ecb8875SAjay Kumar Gupta static inline u8 dsps_readb(const void __iomem *addr, unsigned offset)
589ecb8875SAjay Kumar Gupta 	{ return __raw_readb(addr + offset); }
599ecb8875SAjay Kumar Gupta 
609ecb8875SAjay Kumar Gupta static inline u32 dsps_readl(const void __iomem *addr, unsigned offset)
619ecb8875SAjay Kumar Gupta 	{ return __raw_readl(addr + offset); }
629ecb8875SAjay Kumar Gupta 
639ecb8875SAjay Kumar Gupta static inline void dsps_writeb(void __iomem *addr, unsigned offset, u8 data)
649ecb8875SAjay Kumar Gupta 	{ __raw_writeb(data, addr + offset); }
659ecb8875SAjay Kumar Gupta 
669ecb8875SAjay Kumar Gupta static inline void dsps_writel(void __iomem *addr, unsigned offset, u32 data)
679ecb8875SAjay Kumar Gupta 	{ __raw_writel(data, addr + offset); }
689ecb8875SAjay Kumar Gupta 
699ecb8875SAjay Kumar Gupta /**
709ecb8875SAjay Kumar Gupta  * DSPS musb wrapper register offset.
719ecb8875SAjay Kumar Gupta  * FIXME: This should be expanded to have all the wrapper registers from TI DSPS
729ecb8875SAjay Kumar Gupta  * musb ips.
739ecb8875SAjay Kumar Gupta  */
749ecb8875SAjay Kumar Gupta struct dsps_musb_wrapper {
759ecb8875SAjay Kumar Gupta 	u16	revision;
769ecb8875SAjay Kumar Gupta 	u16	control;
779ecb8875SAjay Kumar Gupta 	u16	status;
789ecb8875SAjay Kumar Gupta 	u16	epintr_set;
799ecb8875SAjay Kumar Gupta 	u16	epintr_clear;
809ecb8875SAjay Kumar Gupta 	u16	epintr_status;
819ecb8875SAjay Kumar Gupta 	u16	coreintr_set;
829ecb8875SAjay Kumar Gupta 	u16	coreintr_clear;
839ecb8875SAjay Kumar Gupta 	u16	coreintr_status;
849ecb8875SAjay Kumar Gupta 	u16	phy_utmi;
859ecb8875SAjay Kumar Gupta 	u16	mode;
869ecb8875SAjay Kumar Gupta 
879ecb8875SAjay Kumar Gupta 	/* bit positions for control */
889ecb8875SAjay Kumar Gupta 	unsigned	reset:5;
899ecb8875SAjay Kumar Gupta 
909ecb8875SAjay Kumar Gupta 	/* bit positions for interrupt */
919ecb8875SAjay Kumar Gupta 	unsigned	usb_shift:5;
929ecb8875SAjay Kumar Gupta 	u32		usb_mask;
939ecb8875SAjay Kumar Gupta 	u32		usb_bitmap;
949ecb8875SAjay Kumar Gupta 	unsigned	drvvbus:5;
959ecb8875SAjay Kumar Gupta 
969ecb8875SAjay Kumar Gupta 	unsigned	txep_shift:5;
979ecb8875SAjay Kumar Gupta 	u32		txep_mask;
989ecb8875SAjay Kumar Gupta 	u32		txep_bitmap;
999ecb8875SAjay Kumar Gupta 
1009ecb8875SAjay Kumar Gupta 	unsigned	rxep_shift:5;
1019ecb8875SAjay Kumar Gupta 	u32		rxep_mask;
1029ecb8875SAjay Kumar Gupta 	u32		rxep_bitmap;
1039ecb8875SAjay Kumar Gupta 
1049ecb8875SAjay Kumar Gupta 	/* bit positions for phy_utmi */
1059ecb8875SAjay Kumar Gupta 	unsigned	otg_disable:5;
1069ecb8875SAjay Kumar Gupta 
1079ecb8875SAjay Kumar Gupta 	/* bit positions for mode */
1089ecb8875SAjay Kumar Gupta 	unsigned	iddig:5;
1099ecb8875SAjay Kumar Gupta 	/* miscellaneous stuff */
1109ecb8875SAjay Kumar Gupta 	u8		poll_seconds;
1119ecb8875SAjay Kumar Gupta };
1129ecb8875SAjay Kumar Gupta 
1139ecb8875SAjay Kumar Gupta /**
1149ecb8875SAjay Kumar Gupta  * DSPS glue structure.
1159ecb8875SAjay Kumar Gupta  */
1169ecb8875SAjay Kumar Gupta struct dsps_glue {
1179ecb8875SAjay Kumar Gupta 	struct device *dev;
11897238b35SSebastian Andrzej Siewior 	struct platform_device *musb;	/* child musb pdev */
1199ecb8875SAjay Kumar Gupta 	const struct dsps_musb_wrapper *wrp; /* wrapper register offsets */
12097238b35SSebastian Andrzej Siewior 	struct timer_list timer;	/* otg_workaround timer */
12197238b35SSebastian Andrzej Siewior 	unsigned long last_timer;    /* last timer data for each instance */
1229ecb8875SAjay Kumar Gupta };
1239ecb8875SAjay Kumar Gupta 
124807d0d2bSSebastian Andrzej Siewior static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout)
125807d0d2bSSebastian Andrzej Siewior {
126807d0d2bSSebastian Andrzej Siewior 	struct device *dev = musb->controller;
127807d0d2bSSebastian Andrzej Siewior 	struct dsps_glue *glue = dev_get_drvdata(dev->parent);
128807d0d2bSSebastian Andrzej Siewior 
129807d0d2bSSebastian Andrzej Siewior 	if (timeout == 0)
130807d0d2bSSebastian Andrzej Siewior 		timeout = jiffies + msecs_to_jiffies(3);
131807d0d2bSSebastian Andrzej Siewior 
132807d0d2bSSebastian Andrzej Siewior 	/* Never idle if active, or when VBUS timeout is not set as host */
133807d0d2bSSebastian Andrzej Siewior 	if (musb->is_active || (musb->a_wait_bcon == 0 &&
134807d0d2bSSebastian Andrzej Siewior 				musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) {
135807d0d2bSSebastian Andrzej Siewior 		dev_dbg(musb->controller, "%s active, deleting timer\n",
136807d0d2bSSebastian Andrzej Siewior 				usb_otg_state_string(musb->xceiv->state));
137807d0d2bSSebastian Andrzej Siewior 		del_timer(&glue->timer);
138807d0d2bSSebastian Andrzej Siewior 		glue->last_timer = jiffies;
139807d0d2bSSebastian Andrzej Siewior 		return;
140807d0d2bSSebastian Andrzej Siewior 	}
141807d0d2bSSebastian Andrzej Siewior 	if (musb->port_mode == MUSB_PORT_MODE_HOST)
142807d0d2bSSebastian Andrzej Siewior 		return;
143807d0d2bSSebastian Andrzej Siewior 
144807d0d2bSSebastian Andrzej Siewior 	if (!musb->g.dev.driver)
145807d0d2bSSebastian Andrzej Siewior 		return;
146807d0d2bSSebastian Andrzej Siewior 
147807d0d2bSSebastian Andrzej Siewior 	if (time_after(glue->last_timer, timeout) &&
148807d0d2bSSebastian Andrzej Siewior 				timer_pending(&glue->timer)) {
149807d0d2bSSebastian Andrzej Siewior 		dev_dbg(musb->controller,
150807d0d2bSSebastian Andrzej Siewior 			"Longer idle timer already pending, ignoring...\n");
151807d0d2bSSebastian Andrzej Siewior 		return;
152807d0d2bSSebastian Andrzej Siewior 	}
153807d0d2bSSebastian Andrzej Siewior 	glue->last_timer = timeout;
154807d0d2bSSebastian Andrzej Siewior 
155807d0d2bSSebastian Andrzej Siewior 	dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
156807d0d2bSSebastian Andrzej Siewior 		usb_otg_state_string(musb->xceiv->state),
157807d0d2bSSebastian Andrzej Siewior 			jiffies_to_msecs(timeout - jiffies));
158807d0d2bSSebastian Andrzej Siewior 	mod_timer(&glue->timer, timeout);
159807d0d2bSSebastian Andrzej Siewior }
160807d0d2bSSebastian Andrzej Siewior 
1619ecb8875SAjay Kumar Gupta /**
1629ecb8875SAjay Kumar Gupta  * dsps_musb_enable - enable interrupts
1639ecb8875SAjay Kumar Gupta  */
1649ecb8875SAjay Kumar Gupta static void dsps_musb_enable(struct musb *musb)
1659ecb8875SAjay Kumar Gupta {
1669ecb8875SAjay Kumar Gupta 	struct device *dev = musb->controller;
1679ecb8875SAjay Kumar Gupta 	struct platform_device *pdev = to_platform_device(dev->parent);
1689ecb8875SAjay Kumar Gupta 	struct dsps_glue *glue = platform_get_drvdata(pdev);
1699ecb8875SAjay Kumar Gupta 	const struct dsps_musb_wrapper *wrp = glue->wrp;
1709ecb8875SAjay Kumar Gupta 	void __iomem *reg_base = musb->ctrl_base;
1719ecb8875SAjay Kumar Gupta 	u32 epmask, coremask;
1729ecb8875SAjay Kumar Gupta 
1739ecb8875SAjay Kumar Gupta 	/* Workaround: setup IRQs through both register sets. */
1749ecb8875SAjay Kumar Gupta 	epmask = ((musb->epmask & wrp->txep_mask) << wrp->txep_shift) |
1759ecb8875SAjay Kumar Gupta 	       ((musb->epmask & wrp->rxep_mask) << wrp->rxep_shift);
1769ecb8875SAjay Kumar Gupta 	coremask = (wrp->usb_bitmap & ~MUSB_INTR_SOF);
1779ecb8875SAjay Kumar Gupta 
1789ecb8875SAjay Kumar Gupta 	dsps_writel(reg_base, wrp->epintr_set, epmask);
1799ecb8875SAjay Kumar Gupta 	dsps_writel(reg_base, wrp->coreintr_set, coremask);
1809ecb8875SAjay Kumar Gupta 	/* Force the DRVVBUS IRQ so we can start polling for ID change. */
1819ecb8875SAjay Kumar Gupta 	dsps_writel(reg_base, wrp->coreintr_set,
1829ecb8875SAjay Kumar Gupta 		    (1 << wrp->drvvbus) << wrp->usb_shift);
1838b9fcce2SSebastian Andrzej Siewior 	dsps_musb_try_idle(musb, 0);
1849ecb8875SAjay Kumar Gupta }
1859ecb8875SAjay Kumar Gupta 
1869ecb8875SAjay Kumar Gupta /**
1879ecb8875SAjay Kumar Gupta  * dsps_musb_disable - disable HDRC and flush interrupts
1889ecb8875SAjay Kumar Gupta  */
1899ecb8875SAjay Kumar Gupta static void dsps_musb_disable(struct musb *musb)
1909ecb8875SAjay Kumar Gupta {
1919ecb8875SAjay Kumar Gupta 	struct device *dev = musb->controller;
1929ecb8875SAjay Kumar Gupta 	struct platform_device *pdev = to_platform_device(dev->parent);
1939ecb8875SAjay Kumar Gupta 	struct dsps_glue *glue = platform_get_drvdata(pdev);
1949ecb8875SAjay Kumar Gupta 	const struct dsps_musb_wrapper *wrp = glue->wrp;
1959ecb8875SAjay Kumar Gupta 	void __iomem *reg_base = musb->ctrl_base;
1969ecb8875SAjay Kumar Gupta 
1979ecb8875SAjay Kumar Gupta 	dsps_writel(reg_base, wrp->coreintr_clear, wrp->usb_bitmap);
1989ecb8875SAjay Kumar Gupta 	dsps_writel(reg_base, wrp->epintr_clear,
1999ecb8875SAjay Kumar Gupta 			 wrp->txep_bitmap | wrp->rxep_bitmap);
2009ecb8875SAjay Kumar Gupta 	dsps_writeb(musb->mregs, MUSB_DEVCTL, 0);
2019ecb8875SAjay Kumar Gupta }
2029ecb8875SAjay Kumar Gupta 
2039ecb8875SAjay Kumar Gupta static void otg_timer(unsigned long _musb)
2049ecb8875SAjay Kumar Gupta {
2059ecb8875SAjay Kumar Gupta 	struct musb *musb = (void *)_musb;
2069ecb8875SAjay Kumar Gupta 	void __iomem *mregs = musb->mregs;
2079ecb8875SAjay Kumar Gupta 	struct device *dev = musb->controller;
208db4a9320SB, Ravi 	struct dsps_glue *glue = dev_get_drvdata(dev->parent);
2099ecb8875SAjay Kumar Gupta 	const struct dsps_musb_wrapper *wrp = glue->wrp;
2109ecb8875SAjay Kumar Gupta 	u8 devctl;
2119ecb8875SAjay Kumar Gupta 	unsigned long flags;
212*0f901c98SSebastian Andrzej Siewior 	int skip_session = 0;
2139ecb8875SAjay Kumar Gupta 
2149ecb8875SAjay Kumar Gupta 	/*
2159ecb8875SAjay Kumar Gupta 	 * We poll because DSPS IP's won't expose several OTG-critical
2169ecb8875SAjay Kumar Gupta 	 * status change events (from the transceiver) otherwise.
2179ecb8875SAjay Kumar Gupta 	 */
2189ecb8875SAjay Kumar Gupta 	devctl = dsps_readb(mregs, MUSB_DEVCTL);
2199ecb8875SAjay Kumar Gupta 	dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
22042c0bf1cSFelipe Balbi 				usb_otg_state_string(musb->xceiv->state));
2219ecb8875SAjay Kumar Gupta 
2229ecb8875SAjay Kumar Gupta 	spin_lock_irqsave(&musb->lock, flags);
2239ecb8875SAjay Kumar Gupta 	switch (musb->xceiv->state) {
2249ecb8875SAjay Kumar Gupta 	case OTG_STATE_A_WAIT_BCON:
225*0f901c98SSebastian Andrzej Siewior 		dsps_writeb(musb->mregs, MUSB_DEVCTL, 0);
226*0f901c98SSebastian Andrzej Siewior 		skip_session = 1;
227*0f901c98SSebastian Andrzej Siewior 		/* fall */
2289ecb8875SAjay Kumar Gupta 
229*0f901c98SSebastian Andrzej Siewior 	case OTG_STATE_A_IDLE:
230*0f901c98SSebastian Andrzej Siewior 	case OTG_STATE_B_IDLE:
2319ecb8875SAjay Kumar Gupta 		if (devctl & MUSB_DEVCTL_BDEVICE) {
2329ecb8875SAjay Kumar Gupta 			musb->xceiv->state = OTG_STATE_B_IDLE;
2339ecb8875SAjay Kumar Gupta 			MUSB_DEV_MODE(musb);
2349ecb8875SAjay Kumar Gupta 		} else {
2359ecb8875SAjay Kumar Gupta 			musb->xceiv->state = OTG_STATE_A_IDLE;
2369ecb8875SAjay Kumar Gupta 			MUSB_HST_MODE(musb);
2379ecb8875SAjay Kumar Gupta 		}
238*0f901c98SSebastian Andrzej Siewior 		if (!(devctl & MUSB_DEVCTL_SESSION) && !skip_session)
239*0f901c98SSebastian Andrzej Siewior 			dsps_writeb(mregs, MUSB_DEVCTL, MUSB_DEVCTL_SESSION);
240*0f901c98SSebastian Andrzej Siewior 		mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
2419ecb8875SAjay Kumar Gupta 		break;
2429ecb8875SAjay Kumar Gupta 	case OTG_STATE_A_WAIT_VFALL:
2439ecb8875SAjay Kumar Gupta 		musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
2449ecb8875SAjay Kumar Gupta 		dsps_writel(musb->ctrl_base, wrp->coreintr_set,
2459ecb8875SAjay Kumar Gupta 			    MUSB_INTR_VBUSERROR << wrp->usb_shift);
2469ecb8875SAjay Kumar Gupta 		break;
2479ecb8875SAjay Kumar Gupta 	default:
2489ecb8875SAjay Kumar Gupta 		break;
2499ecb8875SAjay Kumar Gupta 	}
2509ecb8875SAjay Kumar Gupta 	spin_unlock_irqrestore(&musb->lock, flags);
2519ecb8875SAjay Kumar Gupta }
2529ecb8875SAjay Kumar Gupta 
2539ecb8875SAjay Kumar Gupta static irqreturn_t dsps_interrupt(int irq, void *hci)
2549ecb8875SAjay Kumar Gupta {
2559ecb8875SAjay Kumar Gupta 	struct musb  *musb = hci;
2569ecb8875SAjay Kumar Gupta 	void __iomem *reg_base = musb->ctrl_base;
2579ecb8875SAjay Kumar Gupta 	struct device *dev = musb->controller;
258db4a9320SB, Ravi 	struct dsps_glue *glue = dev_get_drvdata(dev->parent);
2599ecb8875SAjay Kumar Gupta 	const struct dsps_musb_wrapper *wrp = glue->wrp;
2609ecb8875SAjay Kumar Gupta 	unsigned long flags;
2619ecb8875SAjay Kumar Gupta 	irqreturn_t ret = IRQ_NONE;
2629ecb8875SAjay Kumar Gupta 	u32 epintr, usbintr;
2639ecb8875SAjay Kumar Gupta 
2649ecb8875SAjay Kumar Gupta 	spin_lock_irqsave(&musb->lock, flags);
2659ecb8875SAjay Kumar Gupta 
2669ecb8875SAjay Kumar Gupta 	/* Get endpoint interrupts */
2679ecb8875SAjay Kumar Gupta 	epintr = dsps_readl(reg_base, wrp->epintr_status);
2689ecb8875SAjay Kumar Gupta 	musb->int_rx = (epintr & wrp->rxep_bitmap) >> wrp->rxep_shift;
2699ecb8875SAjay Kumar Gupta 	musb->int_tx = (epintr & wrp->txep_bitmap) >> wrp->txep_shift;
2709ecb8875SAjay Kumar Gupta 
2719ecb8875SAjay Kumar Gupta 	if (epintr)
2729ecb8875SAjay Kumar Gupta 		dsps_writel(reg_base, wrp->epintr_status, epintr);
2739ecb8875SAjay Kumar Gupta 
2749ecb8875SAjay Kumar Gupta 	/* Get usb core interrupts */
2759ecb8875SAjay Kumar Gupta 	usbintr = dsps_readl(reg_base, wrp->coreintr_status);
2769ecb8875SAjay Kumar Gupta 	if (!usbintr && !epintr)
2779be73baeSSebastian Andrzej Siewior 		goto out;
2789ecb8875SAjay Kumar Gupta 
2799ecb8875SAjay Kumar Gupta 	musb->int_usb =	(usbintr & wrp->usb_bitmap) >> wrp->usb_shift;
2809ecb8875SAjay Kumar Gupta 	if (usbintr)
2819ecb8875SAjay Kumar Gupta 		dsps_writel(reg_base, wrp->coreintr_status, usbintr);
2829ecb8875SAjay Kumar Gupta 
2839ecb8875SAjay Kumar Gupta 	dev_dbg(musb->controller, "usbintr (%x) epintr(%x)\n",
2849ecb8875SAjay Kumar Gupta 			usbintr, epintr);
2859ecb8875SAjay Kumar Gupta 	/*
2869ecb8875SAjay Kumar Gupta 	 * DRVVBUS IRQs are the only proxy we have (a very poor one!) for
2879ecb8875SAjay Kumar Gupta 	 * DSPS IP's missing ID change IRQ.  We need an ID change IRQ to
2889ecb8875SAjay Kumar Gupta 	 * switch appropriately between halves of the OTG state machine.
2899ecb8875SAjay Kumar Gupta 	 * Managing DEVCTL.SESSION per Mentor docs requires that we know its
2909ecb8875SAjay Kumar Gupta 	 * value but DEVCTL.BDEVICE is invalid without DEVCTL.SESSION set.
2919ecb8875SAjay Kumar Gupta 	 * Also, DRVVBUS pulses for SRP (but not at 5V) ...
2929ecb8875SAjay Kumar Gupta 	 */
29396449f09SRavi Babu 	if (is_host_active(musb) && usbintr & MUSB_INTR_BABBLE)
294984e833cSMasanari Iida 		pr_info("CAUTION: musb: Babble Interrupt Occurred\n");
2959ecb8875SAjay Kumar Gupta 
2969ecb8875SAjay Kumar Gupta 	if (usbintr & ((1 << wrp->drvvbus) << wrp->usb_shift)) {
2979ecb8875SAjay Kumar Gupta 		int drvvbus = dsps_readl(reg_base, wrp->status);
2989ecb8875SAjay Kumar Gupta 		void __iomem *mregs = musb->mregs;
2999ecb8875SAjay Kumar Gupta 		u8 devctl = dsps_readb(mregs, MUSB_DEVCTL);
3009ecb8875SAjay Kumar Gupta 		int err;
3019ecb8875SAjay Kumar Gupta 
302032ec49fSFelipe Balbi 		err = musb->int_usb & MUSB_INTR_VBUSERROR;
3039ecb8875SAjay Kumar Gupta 		if (err) {
3049ecb8875SAjay Kumar Gupta 			/*
3059ecb8875SAjay Kumar Gupta 			 * The Mentor core doesn't debounce VBUS as needed
3069ecb8875SAjay Kumar Gupta 			 * to cope with device connect current spikes. This
3079ecb8875SAjay Kumar Gupta 			 * means it's not uncommon for bus-powered devices
3089ecb8875SAjay Kumar Gupta 			 * to get VBUS errors during enumeration.
3099ecb8875SAjay Kumar Gupta 			 *
3109ecb8875SAjay Kumar Gupta 			 * This is a workaround, but newer RTL from Mentor
3119ecb8875SAjay Kumar Gupta 			 * seems to allow a better one: "re"-starting sessions
3129ecb8875SAjay Kumar Gupta 			 * without waiting for VBUS to stop registering in
3139ecb8875SAjay Kumar Gupta 			 * devctl.
3149ecb8875SAjay Kumar Gupta 			 */
3159ecb8875SAjay Kumar Gupta 			musb->int_usb &= ~MUSB_INTR_VBUSERROR;
3169ecb8875SAjay Kumar Gupta 			musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
31797238b35SSebastian Andrzej Siewior 			mod_timer(&glue->timer,
3189ecb8875SAjay Kumar Gupta 					jiffies + wrp->poll_seconds * HZ);
3199ecb8875SAjay Kumar Gupta 			WARNING("VBUS error workaround (delay coming)\n");
320032ec49fSFelipe Balbi 		} else if (drvvbus) {
3219ecb8875SAjay Kumar Gupta 			MUSB_HST_MODE(musb);
3229ecb8875SAjay Kumar Gupta 			musb->xceiv->otg->default_a = 1;
3239ecb8875SAjay Kumar Gupta 			musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
32497238b35SSebastian Andrzej Siewior 			del_timer(&glue->timer);
3259ecb8875SAjay Kumar Gupta 		} else {
3269ecb8875SAjay Kumar Gupta 			musb->is_active = 0;
3279ecb8875SAjay Kumar Gupta 			MUSB_DEV_MODE(musb);
3289ecb8875SAjay Kumar Gupta 			musb->xceiv->otg->default_a = 0;
3299ecb8875SAjay Kumar Gupta 			musb->xceiv->state = OTG_STATE_B_IDLE;
3309ecb8875SAjay Kumar Gupta 		}
3319ecb8875SAjay Kumar Gupta 
3329ecb8875SAjay Kumar Gupta 		/* NOTE: this must complete power-on within 100 ms. */
3339ecb8875SAjay Kumar Gupta 		dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
3349ecb8875SAjay Kumar Gupta 				drvvbus ? "on" : "off",
33542c0bf1cSFelipe Balbi 				usb_otg_state_string(musb->xceiv->state),
3369ecb8875SAjay Kumar Gupta 				err ? " ERROR" : "",
3379ecb8875SAjay Kumar Gupta 				devctl);
3389ecb8875SAjay Kumar Gupta 		ret = IRQ_HANDLED;
3399ecb8875SAjay Kumar Gupta 	}
3409ecb8875SAjay Kumar Gupta 
3419ecb8875SAjay Kumar Gupta 	if (musb->int_tx || musb->int_rx || musb->int_usb)
3429ecb8875SAjay Kumar Gupta 		ret |= musb_interrupt(musb);
3439ecb8875SAjay Kumar Gupta 
3449ecb8875SAjay Kumar Gupta 	/* Poll for ID change */
345032ec49fSFelipe Balbi 	if (musb->xceiv->state == OTG_STATE_B_IDLE)
34697238b35SSebastian Andrzej Siewior 		mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
3479be73baeSSebastian Andrzej Siewior out:
3489ecb8875SAjay Kumar Gupta 	spin_unlock_irqrestore(&musb->lock, flags);
3499ecb8875SAjay Kumar Gupta 
3509ecb8875SAjay Kumar Gupta 	return ret;
3519ecb8875SAjay Kumar Gupta }
3529ecb8875SAjay Kumar Gupta 
3539ecb8875SAjay Kumar Gupta static int dsps_musb_init(struct musb *musb)
3549ecb8875SAjay Kumar Gupta {
3559ecb8875SAjay Kumar Gupta 	struct device *dev = musb->controller;
356db4a9320SB, Ravi 	struct dsps_glue *glue = dev_get_drvdata(dev->parent);
35797238b35SSebastian Andrzej Siewior 	struct platform_device *parent = to_platform_device(dev->parent);
3589ecb8875SAjay Kumar Gupta 	const struct dsps_musb_wrapper *wrp = glue->wrp;
35997238b35SSebastian Andrzej Siewior 	void __iomem *reg_base;
36097238b35SSebastian Andrzej Siewior 	struct resource *r;
3619ecb8875SAjay Kumar Gupta 	u32 rev, val;
3629ecb8875SAjay Kumar Gupta 
36397238b35SSebastian Andrzej Siewior 	r = platform_get_resource_byname(parent, IORESOURCE_MEM, "control");
36497238b35SSebastian Andrzej Siewior 	if (!r)
36597238b35SSebastian Andrzej Siewior 		return -EINVAL;
36697238b35SSebastian Andrzej Siewior 
36797238b35SSebastian Andrzej Siewior 	reg_base = devm_ioremap_resource(dev, r);
36851ef74f6SJulia Lawall 	if (IS_ERR(reg_base))
36951ef74f6SJulia Lawall 		return PTR_ERR(reg_base);
37097238b35SSebastian Andrzej Siewior 	musb->ctrl_base = reg_base;
3719ecb8875SAjay Kumar Gupta 
372d7554226SAfzal Mohammed 	/* NOP driver needs change if supporting dual instance */
37397238b35SSebastian Andrzej Siewior 	musb->xceiv = devm_usb_get_phy_by_phandle(dev, "phys", 0);
37497238b35SSebastian Andrzej Siewior 	if (IS_ERR(musb->xceiv))
37597238b35SSebastian Andrzej Siewior 		return PTR_ERR(musb->xceiv);
3769ecb8875SAjay Kumar Gupta 
3779ecb8875SAjay Kumar Gupta 	/* Returns zero if e.g. not clocked */
3789ecb8875SAjay Kumar Gupta 	rev = dsps_readl(reg_base, wrp->revision);
37997238b35SSebastian Andrzej Siewior 	if (!rev)
38097238b35SSebastian Andrzej Siewior 		return -ENODEV;
3819ecb8875SAjay Kumar Gupta 
3827557a57fSSebastian Andrzej Siewior 	usb_phy_init(musb->xceiv);
38397238b35SSebastian Andrzej Siewior 	setup_timer(&glue->timer, otg_timer, (unsigned long) musb);
3849ecb8875SAjay Kumar Gupta 
3859ecb8875SAjay Kumar Gupta 	/* Reset the musb */
3869ecb8875SAjay Kumar Gupta 	dsps_writel(reg_base, wrp->control, (1 << wrp->reset));
3879ecb8875SAjay Kumar Gupta 
3889ecb8875SAjay Kumar Gupta 	musb->isr = dsps_interrupt;
3899ecb8875SAjay Kumar Gupta 
3909ecb8875SAjay Kumar Gupta 	/* reset the otgdisable bit, needed for host mode to work */
3919ecb8875SAjay Kumar Gupta 	val = dsps_readl(reg_base, wrp->phy_utmi);
3929ecb8875SAjay Kumar Gupta 	val &= ~(1 << wrp->otg_disable);
3939ecb8875SAjay Kumar Gupta 	dsps_writel(musb->ctrl_base, wrp->phy_utmi, val);
3949ecb8875SAjay Kumar Gupta 
3959ecb8875SAjay Kumar Gupta 	return 0;
3969ecb8875SAjay Kumar Gupta }
3979ecb8875SAjay Kumar Gupta 
3989ecb8875SAjay Kumar Gupta static int dsps_musb_exit(struct musb *musb)
3999ecb8875SAjay Kumar Gupta {
4009ecb8875SAjay Kumar Gupta 	struct device *dev = musb->controller;
401db4a9320SB, Ravi 	struct dsps_glue *glue = dev_get_drvdata(dev->parent);
4029ecb8875SAjay Kumar Gupta 
40397238b35SSebastian Andrzej Siewior 	del_timer_sync(&glue->timer);
4049ecb8875SAjay Kumar Gupta 
4057557a57fSSebastian Andrzej Siewior 	usb_phy_shutdown(musb->xceiv);
4069ecb8875SAjay Kumar Gupta 	return 0;
4079ecb8875SAjay Kumar Gupta }
4089ecb8875SAjay Kumar Gupta 
4099ecb8875SAjay Kumar Gupta static struct musb_platform_ops dsps_ops = {
4109ecb8875SAjay Kumar Gupta 	.init		= dsps_musb_init,
4119ecb8875SAjay Kumar Gupta 	.exit		= dsps_musb_exit,
4129ecb8875SAjay Kumar Gupta 
4139ecb8875SAjay Kumar Gupta 	.enable		= dsps_musb_enable,
4149ecb8875SAjay Kumar Gupta 	.disable	= dsps_musb_disable,
4159ecb8875SAjay Kumar Gupta 
4169ecb8875SAjay Kumar Gupta 	.try_idle	= dsps_musb_try_idle,
4179ecb8875SAjay Kumar Gupta };
4189ecb8875SAjay Kumar Gupta 
4199ecb8875SAjay Kumar Gupta static u64 musb_dmamask = DMA_BIT_MASK(32);
4209ecb8875SAjay Kumar Gupta 
42197238b35SSebastian Andrzej Siewior static int get_int_prop(struct device_node *dn, const char *s)
4229ecb8875SAjay Kumar Gupta {
42397238b35SSebastian Andrzej Siewior 	int ret;
42497238b35SSebastian Andrzej Siewior 	u32 val;
42597238b35SSebastian Andrzej Siewior 
42697238b35SSebastian Andrzej Siewior 	ret = of_property_read_u32(dn, s, &val);
42797238b35SSebastian Andrzej Siewior 	if (ret)
42897238b35SSebastian Andrzej Siewior 		return 0;
42997238b35SSebastian Andrzej Siewior 	return val;
43097238b35SSebastian Andrzej Siewior }
43197238b35SSebastian Andrzej Siewior 
432c031a7d4SSebastian Andrzej Siewior static int get_musb_port_mode(struct device *dev)
433c031a7d4SSebastian Andrzej Siewior {
434c031a7d4SSebastian Andrzej Siewior 	enum usb_dr_mode mode;
435c031a7d4SSebastian Andrzej Siewior 
436c031a7d4SSebastian Andrzej Siewior 	mode = of_usb_get_dr_mode(dev->of_node);
437c031a7d4SSebastian Andrzej Siewior 	switch (mode) {
438c031a7d4SSebastian Andrzej Siewior 	case USB_DR_MODE_HOST:
439c031a7d4SSebastian Andrzej Siewior 		return MUSB_PORT_MODE_HOST;
440c031a7d4SSebastian Andrzej Siewior 
441c031a7d4SSebastian Andrzej Siewior 	case USB_DR_MODE_PERIPHERAL:
442c031a7d4SSebastian Andrzej Siewior 		return MUSB_PORT_MODE_GADGET;
443c031a7d4SSebastian Andrzej Siewior 
444c031a7d4SSebastian Andrzej Siewior 	case USB_DR_MODE_UNKNOWN:
445c031a7d4SSebastian Andrzej Siewior 	case USB_DR_MODE_OTG:
446c031a7d4SSebastian Andrzej Siewior 	default:
447c031a7d4SSebastian Andrzej Siewior 		return MUSB_PORT_MODE_DUAL_ROLE;
448c031a7d4SSebastian Andrzej Siewior 	};
449c031a7d4SSebastian Andrzej Siewior }
450c031a7d4SSebastian Andrzej Siewior 
45197238b35SSebastian Andrzej Siewior static int dsps_create_musb_pdev(struct dsps_glue *glue,
45297238b35SSebastian Andrzej Siewior 		struct platform_device *parent)
45397238b35SSebastian Andrzej Siewior {
45497238b35SSebastian Andrzej Siewior 	struct musb_hdrc_platform_data pdata;
45597238b35SSebastian Andrzej Siewior 	struct resource	resources[2];
456c031a7d4SSebastian Andrzej Siewior 	struct resource	*res;
45797238b35SSebastian Andrzej Siewior 	struct device *dev = &parent->dev;
45865145677SAjay Kumar Gupta 	struct musb_hdrc_config	*config;
4599ecb8875SAjay Kumar Gupta 	struct platform_device *musb;
46097238b35SSebastian Andrzej Siewior 	struct device_node *dn = parent->dev.of_node;
4612f771164SSebastian Andrzej Siewior 	int ret;
4629ecb8875SAjay Kumar Gupta 
46397238b35SSebastian Andrzej Siewior 	memset(resources, 0, sizeof(resources));
464c031a7d4SSebastian Andrzej Siewior 	res = platform_get_resource_byname(parent, IORESOURCE_MEM, "mc");
465c031a7d4SSebastian Andrzej Siewior 	if (!res) {
46697238b35SSebastian Andrzej Siewior 		dev_err(dev, "failed to get memory.\n");
467c031a7d4SSebastian Andrzej Siewior 		return -EINVAL;
4689ecb8875SAjay Kumar Gupta 	}
469c031a7d4SSebastian Andrzej Siewior 	resources[0] = *res;
47097238b35SSebastian Andrzej Siewior 
471c031a7d4SSebastian Andrzej Siewior 	res = platform_get_resource_byname(parent, IORESOURCE_IRQ, "mc");
472c031a7d4SSebastian Andrzej Siewior 	if (!res) {
47397238b35SSebastian Andrzej Siewior 		dev_err(dev, "failed to get irq.\n");
474c031a7d4SSebastian Andrzej Siewior 		return -EINVAL;
47597238b35SSebastian Andrzej Siewior 	}
476c031a7d4SSebastian Andrzej Siewior 	resources[1] = *res;
4779ecb8875SAjay Kumar Gupta 
47865b3d52dSB, Ravi 	/* allocate the child platform device */
4792f771164SSebastian Andrzej Siewior 	musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
48065b3d52dSB, Ravi 	if (!musb) {
48165b3d52dSB, Ravi 		dev_err(dev, "failed to allocate musb device\n");
48297238b35SSebastian Andrzej Siewior 		return -ENOMEM;
48365b3d52dSB, Ravi 	}
4849ecb8875SAjay Kumar Gupta 
4859ecb8875SAjay Kumar Gupta 	musb->dev.parent		= dev;
4869ecb8875SAjay Kumar Gupta 	musb->dev.dma_mask		= &musb_dmamask;
4879ecb8875SAjay Kumar Gupta 	musb->dev.coherent_dma_mask	= musb_dmamask;
488c031a7d4SSebastian Andrzej Siewior 	musb->dev.of_node		= of_node_get(dn);
4899ecb8875SAjay Kumar Gupta 
49097238b35SSebastian Andrzej Siewior 	glue->musb = musb;
4919ecb8875SAjay Kumar Gupta 
49297238b35SSebastian Andrzej Siewior 	ret = platform_device_add_resources(musb, resources,
49397238b35SSebastian Andrzej Siewior 			ARRAY_SIZE(resources));
4949ecb8875SAjay Kumar Gupta 	if (ret) {
4959ecb8875SAjay Kumar Gupta 		dev_err(dev, "failed to add resources\n");
49697238b35SSebastian Andrzej Siewior 		goto err;
4979ecb8875SAjay Kumar Gupta 	}
4989ecb8875SAjay Kumar Gupta 
49997238b35SSebastian Andrzej Siewior 	config = devm_kzalloc(&parent->dev, sizeof(*config), GFP_KERNEL);
50065145677SAjay Kumar Gupta 	if (!config) {
50197238b35SSebastian Andrzej Siewior 		dev_err(dev, "failed to allocate musb hdrc config\n");
502b25e5f1cSWei Yongjun 		ret = -ENOMEM;
50397238b35SSebastian Andrzej Siewior 		goto err;
50465145677SAjay Kumar Gupta 	}
50597238b35SSebastian Andrzej Siewior 	pdata.config = config;
50697238b35SSebastian Andrzej Siewior 	pdata.platform_ops = &dsps_ops;
50765145677SAjay Kumar Gupta 
508c031a7d4SSebastian Andrzej Siewior 	config->num_eps = get_int_prop(dn, "mentor,num-eps");
509c031a7d4SSebastian Andrzej Siewior 	config->ram_bits = get_int_prop(dn, "mentor,ram-bits");
510c031a7d4SSebastian Andrzej Siewior 	pdata.mode = get_musb_port_mode(dev);
511c031a7d4SSebastian Andrzej Siewior 	/* DT keeps this entry in mA, musb expects it as per USB spec */
512c031a7d4SSebastian Andrzej Siewior 	pdata.power = get_int_prop(dn, "mentor,power") / 2;
513c031a7d4SSebastian Andrzej Siewior 	config->multipoint = of_property_read_bool(dn, "mentor,multipoint");
51465145677SAjay Kumar Gupta 
51597238b35SSebastian Andrzej Siewior 	ret = platform_device_add_data(musb, &pdata, sizeof(pdata));
5169ecb8875SAjay Kumar Gupta 	if (ret) {
5179ecb8875SAjay Kumar Gupta 		dev_err(dev, "failed to add platform_data\n");
51897238b35SSebastian Andrzej Siewior 		goto err;
5199ecb8875SAjay Kumar Gupta 	}
5209ecb8875SAjay Kumar Gupta 
5219ecb8875SAjay Kumar Gupta 	ret = platform_device_add(musb);
5229ecb8875SAjay Kumar Gupta 	if (ret) {
5239ecb8875SAjay Kumar Gupta 		dev_err(dev, "failed to register musb device\n");
52497238b35SSebastian Andrzej Siewior 		goto err;
5259ecb8875SAjay Kumar Gupta 	}
5269ecb8875SAjay Kumar Gupta 	return 0;
5279ecb8875SAjay Kumar Gupta 
52897238b35SSebastian Andrzej Siewior err:
5299ecb8875SAjay Kumar Gupta 	platform_device_put(musb);
5309ecb8875SAjay Kumar Gupta 	return ret;
5319ecb8875SAjay Kumar Gupta }
5329ecb8875SAjay Kumar Gupta 
53341ac7b3aSBill Pemberton static int dsps_probe(struct platform_device *pdev)
5349ecb8875SAjay Kumar Gupta {
53565145677SAjay Kumar Gupta 	const struct of_device_id *match;
53665145677SAjay Kumar Gupta 	const struct dsps_musb_wrapper *wrp;
5379ecb8875SAjay Kumar Gupta 	struct dsps_glue *glue;
53897238b35SSebastian Andrzej Siewior 	int ret;
5399ecb8875SAjay Kumar Gupta 
540cc506036SFelipe Balbi 	match = of_match_node(musb_dsps_of_match, pdev->dev.of_node);
54165145677SAjay Kumar Gupta 	if (!match) {
54265145677SAjay Kumar Gupta 		dev_err(&pdev->dev, "fail to get matching of_match struct\n");
54397238b35SSebastian Andrzej Siewior 		return -EINVAL;
54465145677SAjay Kumar Gupta 	}
54565145677SAjay Kumar Gupta 	wrp = match->data;
5469ecb8875SAjay Kumar Gupta 
5479ecb8875SAjay Kumar Gupta 	/* allocate glue */
5489ecb8875SAjay Kumar Gupta 	glue = kzalloc(sizeof(*glue), GFP_KERNEL);
5499ecb8875SAjay Kumar Gupta 	if (!glue) {
5509ecb8875SAjay Kumar Gupta 		dev_err(&pdev->dev, "unable to allocate glue memory\n");
55197238b35SSebastian Andrzej Siewior 		return -ENOMEM;
5529ecb8875SAjay Kumar Gupta 	}
5539ecb8875SAjay Kumar Gupta 
5549ecb8875SAjay Kumar Gupta 	glue->dev = &pdev->dev;
55597238b35SSebastian Andrzej Siewior 	glue->wrp = wrp;
5569ecb8875SAjay Kumar Gupta 
5579ecb8875SAjay Kumar Gupta 	platform_set_drvdata(pdev, glue);
5589ecb8875SAjay Kumar Gupta 	pm_runtime_enable(&pdev->dev);
5599ecb8875SAjay Kumar Gupta 
5609ecb8875SAjay Kumar Gupta 	ret = pm_runtime_get_sync(&pdev->dev);
5619ecb8875SAjay Kumar Gupta 	if (ret < 0) {
5629ecb8875SAjay Kumar Gupta 		dev_err(&pdev->dev, "pm_runtime_get_sync FAILED");
5630e38c4edSAjay Kumar Gupta 		goto err2;
5640e38c4edSAjay Kumar Gupta 	}
5650e38c4edSAjay Kumar Gupta 
56697238b35SSebastian Andrzej Siewior 	ret = dsps_create_musb_pdev(glue, pdev);
56797238b35SSebastian Andrzej Siewior 	if (ret)
5689ecb8875SAjay Kumar Gupta 		goto err3;
5699ecb8875SAjay Kumar Gupta 
5709ecb8875SAjay Kumar Gupta 	return 0;
5719ecb8875SAjay Kumar Gupta 
5729ecb8875SAjay Kumar Gupta err3:
5730e38c4edSAjay Kumar Gupta 	pm_runtime_put(&pdev->dev);
5749ecb8875SAjay Kumar Gupta err2:
5750e38c4edSAjay Kumar Gupta 	pm_runtime_disable(&pdev->dev);
5769ecb8875SAjay Kumar Gupta 	kfree(glue);
5779ecb8875SAjay Kumar Gupta 	return ret;
5789ecb8875SAjay Kumar Gupta }
57997238b35SSebastian Andrzej Siewior 
580fb4e98abSBill Pemberton static int dsps_remove(struct platform_device *pdev)
5819ecb8875SAjay Kumar Gupta {
5829ecb8875SAjay Kumar Gupta 	struct dsps_glue *glue = platform_get_drvdata(pdev);
5839ecb8875SAjay Kumar Gupta 
58497238b35SSebastian Andrzej Siewior 	platform_device_unregister(glue->musb);
5859ecb8875SAjay Kumar Gupta 
5869ecb8875SAjay Kumar Gupta 	/* disable usbss clocks */
5879ecb8875SAjay Kumar Gupta 	pm_runtime_put(&pdev->dev);
5889ecb8875SAjay Kumar Gupta 	pm_runtime_disable(&pdev->dev);
5899ecb8875SAjay Kumar Gupta 	kfree(glue);
5909ecb8875SAjay Kumar Gupta 	return 0;
5919ecb8875SAjay Kumar Gupta }
5929ecb8875SAjay Kumar Gupta 
593fa7b4ca5SSebastian Andrzej Siewior static const struct dsps_musb_wrapper am33xx_driver_data = {
5949ecb8875SAjay Kumar Gupta 	.revision		= 0x00,
5959ecb8875SAjay Kumar Gupta 	.control		= 0x14,
5969ecb8875SAjay Kumar Gupta 	.status			= 0x18,
5979ecb8875SAjay Kumar Gupta 	.epintr_set		= 0x38,
5989ecb8875SAjay Kumar Gupta 	.epintr_clear		= 0x40,
5999ecb8875SAjay Kumar Gupta 	.epintr_status		= 0x30,
6009ecb8875SAjay Kumar Gupta 	.coreintr_set		= 0x3c,
6019ecb8875SAjay Kumar Gupta 	.coreintr_clear		= 0x44,
6029ecb8875SAjay Kumar Gupta 	.coreintr_status	= 0x34,
6039ecb8875SAjay Kumar Gupta 	.phy_utmi		= 0xe0,
6049ecb8875SAjay Kumar Gupta 	.mode			= 0xe8,
6059ecb8875SAjay Kumar Gupta 	.reset			= 0,
6069ecb8875SAjay Kumar Gupta 	.otg_disable		= 21,
6079ecb8875SAjay Kumar Gupta 	.iddig			= 8,
6089ecb8875SAjay Kumar Gupta 	.usb_shift		= 0,
6099ecb8875SAjay Kumar Gupta 	.usb_mask		= 0x1ff,
6109ecb8875SAjay Kumar Gupta 	.usb_bitmap		= (0x1ff << 0),
6119ecb8875SAjay Kumar Gupta 	.drvvbus		= 8,
6129ecb8875SAjay Kumar Gupta 	.txep_shift		= 0,
6139ecb8875SAjay Kumar Gupta 	.txep_mask		= 0xffff,
6149ecb8875SAjay Kumar Gupta 	.txep_bitmap		= (0xffff << 0),
6159ecb8875SAjay Kumar Gupta 	.rxep_shift		= 16,
6169ecb8875SAjay Kumar Gupta 	.rxep_mask		= 0xfffe,
6179ecb8875SAjay Kumar Gupta 	.rxep_bitmap		= (0xfffe << 16),
6189ecb8875SAjay Kumar Gupta 	.poll_seconds		= 2,
6199ecb8875SAjay Kumar Gupta };
6209ecb8875SAjay Kumar Gupta 
6212f82686eSBill Pemberton static const struct of_device_id musb_dsps_of_match[] = {
62265145677SAjay Kumar Gupta 	{ .compatible = "ti,musb-am33xx",
623fa7b4ca5SSebastian Andrzej Siewior 		.data = (void *) &am33xx_driver_data, },
6249ecb8875SAjay Kumar Gupta 	{  },
6259ecb8875SAjay Kumar Gupta };
6269ecb8875SAjay Kumar Gupta MODULE_DEVICE_TABLE(of, musb_dsps_of_match);
6279ecb8875SAjay Kumar Gupta 
6289ecb8875SAjay Kumar Gupta static struct platform_driver dsps_usbss_driver = {
6299ecb8875SAjay Kumar Gupta 	.probe		= dsps_probe,
6307690417dSBill Pemberton 	.remove         = dsps_remove,
6319ecb8875SAjay Kumar Gupta 	.driver         = {
6329ecb8875SAjay Kumar Gupta 		.name   = "musb-dsps",
633b432cb83SSachin Kamat 		.of_match_table	= musb_dsps_of_match,
6349ecb8875SAjay Kumar Gupta 	},
6359ecb8875SAjay Kumar Gupta };
6369ecb8875SAjay Kumar Gupta 
6379ecb8875SAjay Kumar Gupta MODULE_DESCRIPTION("TI DSPS MUSB Glue Layer");
6389ecb8875SAjay Kumar Gupta MODULE_AUTHOR("Ravi B <ravibabu@ti.com>");
6399ecb8875SAjay Kumar Gupta MODULE_AUTHOR("Ajay Kumar Gupta <ajay.gupta@ti.com>");
6409ecb8875SAjay Kumar Gupta MODULE_LICENSE("GPL v2");
6419ecb8875SAjay Kumar Gupta 
64297238b35SSebastian Andrzej Siewior module_platform_driver(dsps_usbss_driver);
643