xref: /linux/drivers/usb/musb/musb_dsps.c (revision d0cddae7926f39e8fd488f62496cfebf7a5e757d)
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/io.h>
33ded017eeSKishon Vijay Abraham I #include <linux/err.h>
349ecb8875SAjay Kumar Gupta #include <linux/platform_device.h>
359ecb8875SAjay Kumar Gupta #include <linux/dma-mapping.h>
369ecb8875SAjay Kumar Gupta #include <linux/pm_runtime.h>
379ecb8875SAjay Kumar Gupta #include <linux/module.h>
38d7078df6SFelipe Balbi #include <linux/usb/usb_phy_generic.h>
39e8c4a7acSFelipe Balbi #include <linux/platform_data/usb-omap.h>
400f53e481SFelipe Balbi #include <linux/sizes.h>
419ecb8875SAjay Kumar Gupta 
429ecb8875SAjay Kumar Gupta #include <linux/of.h>
439ecb8875SAjay Kumar Gupta #include <linux/of_device.h>
449ecb8875SAjay Kumar Gupta #include <linux/of_address.h>
4597238b35SSebastian Andrzej Siewior #include <linux/of_irq.h>
46c031a7d4SSebastian Andrzej Siewior #include <linux/usb/of.h>
479ecb8875SAjay Kumar Gupta 
4840f099e3SMarkus Pargmann #include <linux/debugfs.h>
4940f099e3SMarkus Pargmann 
509ecb8875SAjay Kumar Gupta #include "musb_core.h"
519ecb8875SAjay Kumar Gupta 
5265145677SAjay Kumar Gupta static const struct of_device_id musb_dsps_of_match[];
5365145677SAjay Kumar Gupta 
549ecb8875SAjay Kumar Gupta /**
559ecb8875SAjay Kumar Gupta  * avoid using musb_readx()/musb_writex() as glue layer should not be
569ecb8875SAjay Kumar Gupta  * dependent on musb core layer symbols.
579ecb8875SAjay Kumar Gupta  */
589ecb8875SAjay Kumar Gupta static inline u8 dsps_readb(const void __iomem *addr, unsigned offset)
59fc7af215SLothar Waßmann {
60fc7af215SLothar Waßmann 	return __raw_readb(addr + offset);
61fc7af215SLothar Waßmann }
629ecb8875SAjay Kumar Gupta 
639ecb8875SAjay Kumar Gupta static inline u32 dsps_readl(const void __iomem *addr, unsigned offset)
64fc7af215SLothar Waßmann {
65fc7af215SLothar Waßmann 	return __raw_readl(addr + offset);
66fc7af215SLothar Waßmann }
679ecb8875SAjay Kumar Gupta 
689ecb8875SAjay Kumar Gupta static inline void dsps_writeb(void __iomem *addr, unsigned offset, u8 data)
69fc7af215SLothar Waßmann {
70fc7af215SLothar Waßmann 	__raw_writeb(data, addr + offset);
71fc7af215SLothar Waßmann }
729ecb8875SAjay Kumar Gupta 
739ecb8875SAjay Kumar Gupta static inline void dsps_writel(void __iomem *addr, unsigned offset, u32 data)
74fc7af215SLothar Waßmann {
75fc7af215SLothar Waßmann 	__raw_writel(data, addr + offset);
76fc7af215SLothar Waßmann }
779ecb8875SAjay Kumar Gupta 
789ecb8875SAjay Kumar Gupta /**
799ecb8875SAjay Kumar Gupta  * DSPS musb wrapper register offset.
809ecb8875SAjay Kumar Gupta  * FIXME: This should be expanded to have all the wrapper registers from TI DSPS
819ecb8875SAjay Kumar Gupta  * musb ips.
829ecb8875SAjay Kumar Gupta  */
839ecb8875SAjay Kumar Gupta struct dsps_musb_wrapper {
849ecb8875SAjay Kumar Gupta 	u16	revision;
859ecb8875SAjay Kumar Gupta 	u16	control;
869ecb8875SAjay Kumar Gupta 	u16	status;
879ecb8875SAjay Kumar Gupta 	u16	epintr_set;
889ecb8875SAjay Kumar Gupta 	u16	epintr_clear;
899ecb8875SAjay Kumar Gupta 	u16	epintr_status;
909ecb8875SAjay Kumar Gupta 	u16	coreintr_set;
919ecb8875SAjay Kumar Gupta 	u16	coreintr_clear;
929ecb8875SAjay Kumar Gupta 	u16	coreintr_status;
939ecb8875SAjay Kumar Gupta 	u16	phy_utmi;
949ecb8875SAjay Kumar Gupta 	u16	mode;
95b991f9b7SDaniel Mack 	u16	tx_mode;
96b991f9b7SDaniel Mack 	u16	rx_mode;
979ecb8875SAjay Kumar Gupta 
989ecb8875SAjay Kumar Gupta 	/* bit positions for control */
999ecb8875SAjay Kumar Gupta 	unsigned	reset:5;
1009ecb8875SAjay Kumar Gupta 
1019ecb8875SAjay Kumar Gupta 	/* bit positions for interrupt */
1029ecb8875SAjay Kumar Gupta 	unsigned	usb_shift:5;
1039ecb8875SAjay Kumar Gupta 	u32		usb_mask;
1049ecb8875SAjay Kumar Gupta 	u32		usb_bitmap;
1059ecb8875SAjay Kumar Gupta 	unsigned	drvvbus:5;
1069ecb8875SAjay Kumar Gupta 
1079ecb8875SAjay Kumar Gupta 	unsigned	txep_shift:5;
1089ecb8875SAjay Kumar Gupta 	u32		txep_mask;
1099ecb8875SAjay Kumar Gupta 	u32		txep_bitmap;
1109ecb8875SAjay Kumar Gupta 
1119ecb8875SAjay Kumar Gupta 	unsigned	rxep_shift:5;
1129ecb8875SAjay Kumar Gupta 	u32		rxep_mask;
1139ecb8875SAjay Kumar Gupta 	u32		rxep_bitmap;
1149ecb8875SAjay Kumar Gupta 
1159ecb8875SAjay Kumar Gupta 	/* bit positions for phy_utmi */
1169ecb8875SAjay Kumar Gupta 	unsigned	otg_disable:5;
1179ecb8875SAjay Kumar Gupta 
1189ecb8875SAjay Kumar Gupta 	/* bit positions for mode */
1199ecb8875SAjay Kumar Gupta 	unsigned	iddig:5;
120943c1397SFelipe Balbi 	unsigned	iddig_mux:5;
1219ecb8875SAjay Kumar Gupta 	/* miscellaneous stuff */
1229ecb8875SAjay Kumar Gupta 	u8		poll_seconds;
1239ecb8875SAjay Kumar Gupta };
1249ecb8875SAjay Kumar Gupta 
125869c5978SDaniel Mack /*
126869c5978SDaniel Mack  * register shadow for suspend
127869c5978SDaniel Mack  */
128869c5978SDaniel Mack struct dsps_context {
129869c5978SDaniel Mack 	u32 control;
130869c5978SDaniel Mack 	u32 epintr;
131869c5978SDaniel Mack 	u32 coreintr;
132869c5978SDaniel Mack 	u32 phy_utmi;
133869c5978SDaniel Mack 	u32 mode;
134869c5978SDaniel Mack 	u32 tx_mode;
135869c5978SDaniel Mack 	u32 rx_mode;
136869c5978SDaniel Mack };
137869c5978SDaniel Mack 
1389ecb8875SAjay Kumar Gupta /**
1399ecb8875SAjay Kumar Gupta  * DSPS glue structure.
1409ecb8875SAjay Kumar Gupta  */
1419ecb8875SAjay Kumar Gupta struct dsps_glue {
1429ecb8875SAjay Kumar Gupta 	struct device *dev;
14397238b35SSebastian Andrzej Siewior 	struct platform_device *musb;	/* child musb pdev */
1449ecb8875SAjay Kumar Gupta 	const struct dsps_musb_wrapper *wrp; /* wrapper register offsets */
14597238b35SSebastian Andrzej Siewior 	struct timer_list timer;	/* otg_workaround timer */
14697238b35SSebastian Andrzej Siewior 	unsigned long last_timer;    /* last timer data for each instance */
147371254ceSGeorge Cherian 	bool sw_babble_enabled;
148869c5978SDaniel Mack 
149869c5978SDaniel Mack 	struct dsps_context context;
15040f099e3SMarkus Pargmann 	struct debugfs_regset32 regset;
15140f099e3SMarkus Pargmann 	struct dentry *dbgfs_root;
15240f099e3SMarkus Pargmann };
15340f099e3SMarkus Pargmann 
15440f099e3SMarkus Pargmann static const struct debugfs_reg32 dsps_musb_regs[] = {
15540f099e3SMarkus Pargmann 	{ "revision",		0x00 },
15640f099e3SMarkus Pargmann 	{ "control",		0x14 },
15740f099e3SMarkus Pargmann 	{ "status",		0x18 },
15840f099e3SMarkus Pargmann 	{ "eoi",		0x24 },
15940f099e3SMarkus Pargmann 	{ "intr0_stat",		0x30 },
16040f099e3SMarkus Pargmann 	{ "intr1_stat",		0x34 },
16140f099e3SMarkus Pargmann 	{ "intr0_set",		0x38 },
16240f099e3SMarkus Pargmann 	{ "intr1_set",		0x3c },
16340f099e3SMarkus Pargmann 	{ "txmode",		0x70 },
16440f099e3SMarkus Pargmann 	{ "rxmode",		0x74 },
16540f099e3SMarkus Pargmann 	{ "autoreq",		0xd0 },
16640f099e3SMarkus Pargmann 	{ "srpfixtime",		0xd4 },
16740f099e3SMarkus Pargmann 	{ "tdown",		0xd8 },
16840f099e3SMarkus Pargmann 	{ "phy_utmi",		0xe0 },
16940f099e3SMarkus Pargmann 	{ "mode",		0xe8 },
1709ecb8875SAjay Kumar Gupta };
1719ecb8875SAjay Kumar Gupta 
172807d0d2bSSebastian Andrzej Siewior static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout)
173807d0d2bSSebastian Andrzej Siewior {
174807d0d2bSSebastian Andrzej Siewior 	struct device *dev = musb->controller;
175807d0d2bSSebastian Andrzej Siewior 	struct dsps_glue *glue = dev_get_drvdata(dev->parent);
176807d0d2bSSebastian Andrzej Siewior 
177807d0d2bSSebastian Andrzej Siewior 	if (timeout == 0)
178807d0d2bSSebastian Andrzej Siewior 		timeout = jiffies + msecs_to_jiffies(3);
179807d0d2bSSebastian Andrzej Siewior 
180807d0d2bSSebastian Andrzej Siewior 	/* Never idle if active, or when VBUS timeout is not set as host */
181807d0d2bSSebastian Andrzej Siewior 	if (musb->is_active || (musb->a_wait_bcon == 0 &&
182e47d9254SAntoine Tenart 			musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
183807d0d2bSSebastian Andrzej Siewior 		dev_dbg(musb->controller, "%s active, deleting timer\n",
184e47d9254SAntoine Tenart 				usb_otg_state_string(musb->xceiv->otg->state));
185807d0d2bSSebastian Andrzej Siewior 		del_timer(&glue->timer);
186807d0d2bSSebastian Andrzej Siewior 		glue->last_timer = jiffies;
187807d0d2bSSebastian Andrzej Siewior 		return;
188807d0d2bSSebastian Andrzej Siewior 	}
18924616eb6SSebastian Andrzej Siewior 	if (musb->port_mode != MUSB_PORT_MODE_DUAL_ROLE)
190807d0d2bSSebastian Andrzej Siewior 		return;
191807d0d2bSSebastian Andrzej Siewior 
192807d0d2bSSebastian Andrzej Siewior 	if (!musb->g.dev.driver)
193807d0d2bSSebastian Andrzej Siewior 		return;
194807d0d2bSSebastian Andrzej Siewior 
195807d0d2bSSebastian Andrzej Siewior 	if (time_after(glue->last_timer, timeout) &&
196807d0d2bSSebastian Andrzej Siewior 				timer_pending(&glue->timer)) {
197807d0d2bSSebastian Andrzej Siewior 		dev_dbg(musb->controller,
198807d0d2bSSebastian Andrzej Siewior 			"Longer idle timer already pending, ignoring...\n");
199807d0d2bSSebastian Andrzej Siewior 		return;
200807d0d2bSSebastian Andrzej Siewior 	}
201807d0d2bSSebastian Andrzej Siewior 	glue->last_timer = timeout;
202807d0d2bSSebastian Andrzej Siewior 
203807d0d2bSSebastian Andrzej Siewior 	dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
204e47d9254SAntoine Tenart 		usb_otg_state_string(musb->xceiv->otg->state),
205807d0d2bSSebastian Andrzej Siewior 			jiffies_to_msecs(timeout - jiffies));
206807d0d2bSSebastian Andrzej Siewior 	mod_timer(&glue->timer, timeout);
207807d0d2bSSebastian Andrzej Siewior }
208807d0d2bSSebastian Andrzej Siewior 
2099ecb8875SAjay Kumar Gupta /**
2109ecb8875SAjay Kumar Gupta  * dsps_musb_enable - enable interrupts
2119ecb8875SAjay Kumar Gupta  */
2129ecb8875SAjay Kumar Gupta static void dsps_musb_enable(struct musb *musb)
2139ecb8875SAjay Kumar Gupta {
2149ecb8875SAjay Kumar Gupta 	struct device *dev = musb->controller;
2159ecb8875SAjay Kumar Gupta 	struct platform_device *pdev = to_platform_device(dev->parent);
2169ecb8875SAjay Kumar Gupta 	struct dsps_glue *glue = platform_get_drvdata(pdev);
2179ecb8875SAjay Kumar Gupta 	const struct dsps_musb_wrapper *wrp = glue->wrp;
2189ecb8875SAjay Kumar Gupta 	void __iomem *reg_base = musb->ctrl_base;
2199ecb8875SAjay Kumar Gupta 	u32 epmask, coremask;
2209ecb8875SAjay Kumar Gupta 
2219ecb8875SAjay Kumar Gupta 	/* Workaround: setup IRQs through both register sets. */
2229ecb8875SAjay Kumar Gupta 	epmask = ((musb->epmask & wrp->txep_mask) << wrp->txep_shift) |
2239ecb8875SAjay Kumar Gupta 	       ((musb->epmask & wrp->rxep_mask) << wrp->rxep_shift);
2249ecb8875SAjay Kumar Gupta 	coremask = (wrp->usb_bitmap & ~MUSB_INTR_SOF);
2259ecb8875SAjay Kumar Gupta 
2269ecb8875SAjay Kumar Gupta 	dsps_writel(reg_base, wrp->epintr_set, epmask);
2279ecb8875SAjay Kumar Gupta 	dsps_writel(reg_base, wrp->coreintr_set, coremask);
2289ecb8875SAjay Kumar Gupta 	/* Force the DRVVBUS IRQ so we can start polling for ID change. */
2299ecb8875SAjay Kumar Gupta 	dsps_writel(reg_base, wrp->coreintr_set,
2309ecb8875SAjay Kumar Gupta 		    (1 << wrp->drvvbus) << wrp->usb_shift);
2318b9fcce2SSebastian Andrzej Siewior 	dsps_musb_try_idle(musb, 0);
2329ecb8875SAjay Kumar Gupta }
2339ecb8875SAjay Kumar Gupta 
2349ecb8875SAjay Kumar Gupta /**
2359ecb8875SAjay Kumar Gupta  * dsps_musb_disable - disable HDRC and flush interrupts
2369ecb8875SAjay Kumar Gupta  */
2379ecb8875SAjay Kumar Gupta static void dsps_musb_disable(struct musb *musb)
2389ecb8875SAjay Kumar Gupta {
2399ecb8875SAjay Kumar Gupta 	struct device *dev = musb->controller;
2409ecb8875SAjay Kumar Gupta 	struct platform_device *pdev = to_platform_device(dev->parent);
2419ecb8875SAjay Kumar Gupta 	struct dsps_glue *glue = platform_get_drvdata(pdev);
2429ecb8875SAjay Kumar Gupta 	const struct dsps_musb_wrapper *wrp = glue->wrp;
2439ecb8875SAjay Kumar Gupta 	void __iomem *reg_base = musb->ctrl_base;
2449ecb8875SAjay Kumar Gupta 
2459ecb8875SAjay Kumar Gupta 	dsps_writel(reg_base, wrp->coreintr_clear, wrp->usb_bitmap);
2469ecb8875SAjay Kumar Gupta 	dsps_writel(reg_base, wrp->epintr_clear,
2479ecb8875SAjay Kumar Gupta 			 wrp->txep_bitmap | wrp->rxep_bitmap);
2489ecb8875SAjay Kumar Gupta 	dsps_writeb(musb->mregs, MUSB_DEVCTL, 0);
2499ecb8875SAjay Kumar Gupta }
2509ecb8875SAjay Kumar Gupta 
2519ecb8875SAjay Kumar Gupta static void otg_timer(unsigned long _musb)
2529ecb8875SAjay Kumar Gupta {
2539ecb8875SAjay Kumar Gupta 	struct musb *musb = (void *)_musb;
2549ecb8875SAjay Kumar Gupta 	void __iomem *mregs = musb->mregs;
2559ecb8875SAjay Kumar Gupta 	struct device *dev = musb->controller;
256db4a9320SB, Ravi 	struct dsps_glue *glue = dev_get_drvdata(dev->parent);
2579ecb8875SAjay Kumar Gupta 	const struct dsps_musb_wrapper *wrp = glue->wrp;
2589ecb8875SAjay Kumar Gupta 	u8 devctl;
2599ecb8875SAjay Kumar Gupta 	unsigned long flags;
2600f901c98SSebastian Andrzej Siewior 	int skip_session = 0;
2619ecb8875SAjay Kumar Gupta 
2629ecb8875SAjay Kumar Gupta 	/*
2639ecb8875SAjay Kumar Gupta 	 * We poll because DSPS IP's won't expose several OTG-critical
2649ecb8875SAjay Kumar Gupta 	 * status change events (from the transceiver) otherwise.
2659ecb8875SAjay Kumar Gupta 	 */
2669ecb8875SAjay Kumar Gupta 	devctl = dsps_readb(mregs, MUSB_DEVCTL);
2679ecb8875SAjay Kumar Gupta 	dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
268e47d9254SAntoine Tenart 				usb_otg_state_string(musb->xceiv->otg->state));
2699ecb8875SAjay Kumar Gupta 
2709ecb8875SAjay Kumar Gupta 	spin_lock_irqsave(&musb->lock, flags);
271e47d9254SAntoine Tenart 	switch (musb->xceiv->otg->state) {
2729ecb8875SAjay Kumar Gupta 	case OTG_STATE_A_WAIT_BCON:
2730f901c98SSebastian Andrzej Siewior 		dsps_writeb(musb->mregs, MUSB_DEVCTL, 0);
2740f901c98SSebastian Andrzej Siewior 		skip_session = 1;
2750f901c98SSebastian Andrzej Siewior 		/* fall */
2769ecb8875SAjay Kumar Gupta 
2770f901c98SSebastian Andrzej Siewior 	case OTG_STATE_A_IDLE:
2780f901c98SSebastian Andrzej Siewior 	case OTG_STATE_B_IDLE:
2799ecb8875SAjay Kumar Gupta 		if (devctl & MUSB_DEVCTL_BDEVICE) {
280e47d9254SAntoine Tenart 			musb->xceiv->otg->state = OTG_STATE_B_IDLE;
2819ecb8875SAjay Kumar Gupta 			MUSB_DEV_MODE(musb);
2829ecb8875SAjay Kumar Gupta 		} else {
283e47d9254SAntoine Tenart 			musb->xceiv->otg->state = OTG_STATE_A_IDLE;
2849ecb8875SAjay Kumar Gupta 			MUSB_HST_MODE(musb);
2859ecb8875SAjay Kumar Gupta 		}
2860f901c98SSebastian Andrzej Siewior 		if (!(devctl & MUSB_DEVCTL_SESSION) && !skip_session)
2870f901c98SSebastian Andrzej Siewior 			dsps_writeb(mregs, MUSB_DEVCTL, MUSB_DEVCTL_SESSION);
2880f901c98SSebastian Andrzej Siewior 		mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
2899ecb8875SAjay Kumar Gupta 		break;
2909ecb8875SAjay Kumar Gupta 	case OTG_STATE_A_WAIT_VFALL:
291e47d9254SAntoine Tenart 		musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
2929ecb8875SAjay Kumar Gupta 		dsps_writel(musb->ctrl_base, wrp->coreintr_set,
2939ecb8875SAjay Kumar Gupta 			    MUSB_INTR_VBUSERROR << wrp->usb_shift);
2949ecb8875SAjay Kumar Gupta 		break;
2959ecb8875SAjay Kumar Gupta 	default:
2969ecb8875SAjay Kumar Gupta 		break;
2979ecb8875SAjay Kumar Gupta 	}
2989ecb8875SAjay Kumar Gupta 	spin_unlock_irqrestore(&musb->lock, flags);
2999ecb8875SAjay Kumar Gupta }
3009ecb8875SAjay Kumar Gupta 
3019ecb8875SAjay Kumar Gupta static irqreturn_t dsps_interrupt(int irq, void *hci)
3029ecb8875SAjay Kumar Gupta {
3039ecb8875SAjay Kumar Gupta 	struct musb  *musb = hci;
3049ecb8875SAjay Kumar Gupta 	void __iomem *reg_base = musb->ctrl_base;
3059ecb8875SAjay Kumar Gupta 	struct device *dev = musb->controller;
306db4a9320SB, Ravi 	struct dsps_glue *glue = dev_get_drvdata(dev->parent);
3079ecb8875SAjay Kumar Gupta 	const struct dsps_musb_wrapper *wrp = glue->wrp;
3089ecb8875SAjay Kumar Gupta 	unsigned long flags;
3099ecb8875SAjay Kumar Gupta 	irqreturn_t ret = IRQ_NONE;
3109ecb8875SAjay Kumar Gupta 	u32 epintr, usbintr;
3119ecb8875SAjay Kumar Gupta 
3129ecb8875SAjay Kumar Gupta 	spin_lock_irqsave(&musb->lock, flags);
3139ecb8875SAjay Kumar Gupta 
3149ecb8875SAjay Kumar Gupta 	/* Get endpoint interrupts */
3159ecb8875SAjay Kumar Gupta 	epintr = dsps_readl(reg_base, wrp->epintr_status);
3169ecb8875SAjay Kumar Gupta 	musb->int_rx = (epintr & wrp->rxep_bitmap) >> wrp->rxep_shift;
3179ecb8875SAjay Kumar Gupta 	musb->int_tx = (epintr & wrp->txep_bitmap) >> wrp->txep_shift;
3189ecb8875SAjay Kumar Gupta 
3199ecb8875SAjay Kumar Gupta 	if (epintr)
3209ecb8875SAjay Kumar Gupta 		dsps_writel(reg_base, wrp->epintr_status, epintr);
3219ecb8875SAjay Kumar Gupta 
3229ecb8875SAjay Kumar Gupta 	/* Get usb core interrupts */
3239ecb8875SAjay Kumar Gupta 	usbintr = dsps_readl(reg_base, wrp->coreintr_status);
3249ecb8875SAjay Kumar Gupta 	if (!usbintr && !epintr)
3259be73baeSSebastian Andrzej Siewior 		goto out;
3269ecb8875SAjay Kumar Gupta 
3279ecb8875SAjay Kumar Gupta 	musb->int_usb =	(usbintr & wrp->usb_bitmap) >> wrp->usb_shift;
3289ecb8875SAjay Kumar Gupta 	if (usbintr)
3299ecb8875SAjay Kumar Gupta 		dsps_writel(reg_base, wrp->coreintr_status, usbintr);
3309ecb8875SAjay Kumar Gupta 
3319ecb8875SAjay Kumar Gupta 	dev_dbg(musb->controller, "usbintr (%x) epintr(%x)\n",
3329ecb8875SAjay Kumar Gupta 			usbintr, epintr);
3339ecb8875SAjay Kumar Gupta 	/*
3349ecb8875SAjay Kumar Gupta 	 * DRVVBUS IRQs are the only proxy we have (a very poor one!) for
3359ecb8875SAjay Kumar Gupta 	 * DSPS IP's missing ID change IRQ.  We need an ID change IRQ to
3369ecb8875SAjay Kumar Gupta 	 * switch appropriately between halves of the OTG state machine.
3379ecb8875SAjay Kumar Gupta 	 * Managing DEVCTL.SESSION per Mentor docs requires that we know its
3389ecb8875SAjay Kumar Gupta 	 * value but DEVCTL.BDEVICE is invalid without DEVCTL.SESSION set.
3399ecb8875SAjay Kumar Gupta 	 * Also, DRVVBUS pulses for SRP (but not at 5V) ...
3409ecb8875SAjay Kumar Gupta 	 */
3411d57de30SDaniel Mack 	if (is_host_active(musb) && usbintr & MUSB_INTR_BABBLE) {
342984e833cSMasanari Iida 		pr_info("CAUTION: musb: Babble Interrupt Occurred\n");
3439ecb8875SAjay Kumar Gupta 
3441d57de30SDaniel Mack 		/*
3451d57de30SDaniel Mack 		 * When a babble condition occurs, the musb controller removes
3461d57de30SDaniel Mack 		 * the session and is no longer in host mode. Hence, all
3471d57de30SDaniel Mack 		 * devices connected to its root hub get disconnected.
3481d57de30SDaniel Mack 		 *
3491d57de30SDaniel Mack 		 * Hand this error down to the musb core isr, so it can
3501d57de30SDaniel Mack 		 * recover.
3511d57de30SDaniel Mack 		 */
3521d57de30SDaniel Mack 		musb->int_usb = MUSB_INTR_BABBLE | MUSB_INTR_DISCONNECT;
3531d57de30SDaniel Mack 		musb->int_tx = musb->int_rx = 0;
3541d57de30SDaniel Mack 	}
3551d57de30SDaniel Mack 
3569ecb8875SAjay Kumar Gupta 	if (usbintr & ((1 << wrp->drvvbus) << wrp->usb_shift)) {
3579ecb8875SAjay Kumar Gupta 		int drvvbus = dsps_readl(reg_base, wrp->status);
3589ecb8875SAjay Kumar Gupta 		void __iomem *mregs = musb->mregs;
3599ecb8875SAjay Kumar Gupta 		u8 devctl = dsps_readb(mregs, MUSB_DEVCTL);
3609ecb8875SAjay Kumar Gupta 		int err;
3619ecb8875SAjay Kumar Gupta 
362032ec49fSFelipe Balbi 		err = musb->int_usb & MUSB_INTR_VBUSERROR;
3639ecb8875SAjay Kumar Gupta 		if (err) {
3649ecb8875SAjay Kumar Gupta 			/*
3659ecb8875SAjay Kumar Gupta 			 * The Mentor core doesn't debounce VBUS as needed
3669ecb8875SAjay Kumar Gupta 			 * to cope with device connect current spikes. This
3679ecb8875SAjay Kumar Gupta 			 * means it's not uncommon for bus-powered devices
3689ecb8875SAjay Kumar Gupta 			 * to get VBUS errors during enumeration.
3699ecb8875SAjay Kumar Gupta 			 *
3709ecb8875SAjay Kumar Gupta 			 * This is a workaround, but newer RTL from Mentor
3719ecb8875SAjay Kumar Gupta 			 * seems to allow a better one: "re"-starting sessions
3729ecb8875SAjay Kumar Gupta 			 * without waiting for VBUS to stop registering in
3739ecb8875SAjay Kumar Gupta 			 * devctl.
3749ecb8875SAjay Kumar Gupta 			 */
3759ecb8875SAjay Kumar Gupta 			musb->int_usb &= ~MUSB_INTR_VBUSERROR;
376e47d9254SAntoine Tenart 			musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
37797238b35SSebastian Andrzej Siewior 			mod_timer(&glue->timer,
3789ecb8875SAjay Kumar Gupta 					jiffies + wrp->poll_seconds * HZ);
3799ecb8875SAjay Kumar Gupta 			WARNING("VBUS error workaround (delay coming)\n");
380032ec49fSFelipe Balbi 		} else if (drvvbus) {
3819ecb8875SAjay Kumar Gupta 			MUSB_HST_MODE(musb);
3829ecb8875SAjay Kumar Gupta 			musb->xceiv->otg->default_a = 1;
383e47d9254SAntoine Tenart 			musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
38497238b35SSebastian Andrzej Siewior 			del_timer(&glue->timer);
3859ecb8875SAjay Kumar Gupta 		} else {
3869ecb8875SAjay Kumar Gupta 			musb->is_active = 0;
3879ecb8875SAjay Kumar Gupta 			MUSB_DEV_MODE(musb);
3889ecb8875SAjay Kumar Gupta 			musb->xceiv->otg->default_a = 0;
389e47d9254SAntoine Tenart 			musb->xceiv->otg->state = OTG_STATE_B_IDLE;
3909ecb8875SAjay Kumar Gupta 		}
3919ecb8875SAjay Kumar Gupta 
3929ecb8875SAjay Kumar Gupta 		/* NOTE: this must complete power-on within 100 ms. */
3939ecb8875SAjay Kumar Gupta 		dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
3949ecb8875SAjay Kumar Gupta 				drvvbus ? "on" : "off",
395e47d9254SAntoine Tenart 				usb_otg_state_string(musb->xceiv->otg->state),
3969ecb8875SAjay Kumar Gupta 				err ? " ERROR" : "",
3979ecb8875SAjay Kumar Gupta 				devctl);
3989ecb8875SAjay Kumar Gupta 		ret = IRQ_HANDLED;
3999ecb8875SAjay Kumar Gupta 	}
4009ecb8875SAjay Kumar Gupta 
4019ecb8875SAjay Kumar Gupta 	if (musb->int_tx || musb->int_rx || musb->int_usb)
4029ecb8875SAjay Kumar Gupta 		ret |= musb_interrupt(musb);
4039ecb8875SAjay Kumar Gupta 
4045ace3d00SBin Liu 	/* Poll for ID change in OTG port mode */
405e47d9254SAntoine Tenart 	if (musb->xceiv->otg->state == OTG_STATE_B_IDLE &&
4065ace3d00SBin Liu 			musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE)
40797238b35SSebastian Andrzej Siewior 		mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
4089be73baeSSebastian Andrzej Siewior out:
4099ecb8875SAjay Kumar Gupta 	spin_unlock_irqrestore(&musb->lock, flags);
4109ecb8875SAjay Kumar Gupta 
4119ecb8875SAjay Kumar Gupta 	return ret;
4129ecb8875SAjay Kumar Gupta }
4139ecb8875SAjay Kumar Gupta 
41440f099e3SMarkus Pargmann static int dsps_musb_dbg_init(struct musb *musb, struct dsps_glue *glue)
41540f099e3SMarkus Pargmann {
41640f099e3SMarkus Pargmann 	struct dentry *root;
41740f099e3SMarkus Pargmann 	struct dentry *file;
41840f099e3SMarkus Pargmann 	char buf[128];
41940f099e3SMarkus Pargmann 
42040f099e3SMarkus Pargmann 	sprintf(buf, "%s.dsps", dev_name(musb->controller));
42140f099e3SMarkus Pargmann 	root = debugfs_create_dir(buf, NULL);
42240f099e3SMarkus Pargmann 	if (!root)
42340f099e3SMarkus Pargmann 		return -ENOMEM;
42440f099e3SMarkus Pargmann 	glue->dbgfs_root = root;
42540f099e3SMarkus Pargmann 
42640f099e3SMarkus Pargmann 	glue->regset.regs = dsps_musb_regs;
42740f099e3SMarkus Pargmann 	glue->regset.nregs = ARRAY_SIZE(dsps_musb_regs);
42840f099e3SMarkus Pargmann 	glue->regset.base = musb->ctrl_base;
42940f099e3SMarkus Pargmann 
43040f099e3SMarkus Pargmann 	file = debugfs_create_regset32("regdump", S_IRUGO, root, &glue->regset);
43140f099e3SMarkus Pargmann 	if (!file) {
43240f099e3SMarkus Pargmann 		debugfs_remove_recursive(root);
43340f099e3SMarkus Pargmann 		return -ENOMEM;
43440f099e3SMarkus Pargmann 	}
43540f099e3SMarkus Pargmann 	return 0;
43640f099e3SMarkus Pargmann }
43740f099e3SMarkus Pargmann 
4389ecb8875SAjay Kumar Gupta static int dsps_musb_init(struct musb *musb)
4399ecb8875SAjay Kumar Gupta {
4409ecb8875SAjay Kumar Gupta 	struct device *dev = musb->controller;
441db4a9320SB, Ravi 	struct dsps_glue *glue = dev_get_drvdata(dev->parent);
44297238b35SSebastian Andrzej Siewior 	struct platform_device *parent = to_platform_device(dev->parent);
4439ecb8875SAjay Kumar Gupta 	const struct dsps_musb_wrapper *wrp = glue->wrp;
44497238b35SSebastian Andrzej Siewior 	void __iomem *reg_base;
44597238b35SSebastian Andrzej Siewior 	struct resource *r;
4469ecb8875SAjay Kumar Gupta 	u32 rev, val;
44740f099e3SMarkus Pargmann 	int ret;
4489ecb8875SAjay Kumar Gupta 
44997238b35SSebastian Andrzej Siewior 	r = platform_get_resource_byname(parent, IORESOURCE_MEM, "control");
45097238b35SSebastian Andrzej Siewior 	reg_base = devm_ioremap_resource(dev, r);
45151ef74f6SJulia Lawall 	if (IS_ERR(reg_base))
45251ef74f6SJulia Lawall 		return PTR_ERR(reg_base);
45397238b35SSebastian Andrzej Siewior 	musb->ctrl_base = reg_base;
4549ecb8875SAjay Kumar Gupta 
455d7554226SAfzal Mohammed 	/* NOP driver needs change if supporting dual instance */
45697238b35SSebastian Andrzej Siewior 	musb->xceiv = devm_usb_get_phy_by_phandle(dev, "phys", 0);
45797238b35SSebastian Andrzej Siewior 	if (IS_ERR(musb->xceiv))
45897238b35SSebastian Andrzej Siewior 		return PTR_ERR(musb->xceiv);
4599ecb8875SAjay Kumar Gupta 
460bb90600dSTony Lindgren 	musb->phy = devm_phy_get(dev->parent, "usb2-phy");
461bb90600dSTony Lindgren 
4629ecb8875SAjay Kumar Gupta 	/* Returns zero if e.g. not clocked */
4639ecb8875SAjay Kumar Gupta 	rev = dsps_readl(reg_base, wrp->revision);
46497238b35SSebastian Andrzej Siewior 	if (!rev)
46597238b35SSebastian Andrzej Siewior 		return -ENODEV;
4669ecb8875SAjay Kumar Gupta 
4677557a57fSSebastian Andrzej Siewior 	usb_phy_init(musb->xceiv);
468bb90600dSTony Lindgren 	if (IS_ERR(musb->phy))  {
469bb90600dSTony Lindgren 		musb->phy = NULL;
470bb90600dSTony Lindgren 	} else {
471bb90600dSTony Lindgren 		ret = phy_init(musb->phy);
472bb90600dSTony Lindgren 		if (ret < 0)
473bb90600dSTony Lindgren 			return ret;
474bb90600dSTony Lindgren 		ret = phy_power_on(musb->phy);
475bb90600dSTony Lindgren 		if (ret) {
476bb90600dSTony Lindgren 			phy_exit(musb->phy);
477bb90600dSTony Lindgren 			return ret;
478bb90600dSTony Lindgren 		}
479bb90600dSTony Lindgren 	}
480bb90600dSTony Lindgren 
48197238b35SSebastian Andrzej Siewior 	setup_timer(&glue->timer, otg_timer, (unsigned long) musb);
4829ecb8875SAjay Kumar Gupta 
4839ecb8875SAjay Kumar Gupta 	/* Reset the musb */
4849ecb8875SAjay Kumar Gupta 	dsps_writel(reg_base, wrp->control, (1 << wrp->reset));
4859ecb8875SAjay Kumar Gupta 
4869ecb8875SAjay Kumar Gupta 	musb->isr = dsps_interrupt;
4879ecb8875SAjay Kumar Gupta 
4889ecb8875SAjay Kumar Gupta 	/* reset the otgdisable bit, needed for host mode to work */
4899ecb8875SAjay Kumar Gupta 	val = dsps_readl(reg_base, wrp->phy_utmi);
4909ecb8875SAjay Kumar Gupta 	val &= ~(1 << wrp->otg_disable);
4919ecb8875SAjay Kumar Gupta 	dsps_writel(musb->ctrl_base, wrp->phy_utmi, val);
4929ecb8875SAjay Kumar Gupta 
493371254ceSGeorge Cherian 	/*
494371254ceSGeorge Cherian 	 *  Check whether the dsps version has babble control enabled.
495371254ceSGeorge Cherian 	 * In latest silicon revision the babble control logic is enabled.
496371254ceSGeorge Cherian 	 * If MUSB_BABBLE_CTL returns 0x4 then we have the babble control
497371254ceSGeorge Cherian 	 * logic enabled.
498371254ceSGeorge Cherian 	 */
499371254ceSGeorge Cherian 	val = dsps_readb(musb->mregs, MUSB_BABBLE_CTL);
500371254ceSGeorge Cherian 	if (val == MUSB_BABBLE_RCV_DISABLE) {
501371254ceSGeorge Cherian 		glue->sw_babble_enabled = true;
502371254ceSGeorge Cherian 		val |= MUSB_BABBLE_SW_SESSION_CTRL;
503371254ceSGeorge Cherian 		dsps_writeb(musb->mregs, MUSB_BABBLE_CTL, val);
504371254ceSGeorge Cherian 	}
505371254ceSGeorge Cherian 
50640f099e3SMarkus Pargmann 	ret = dsps_musb_dbg_init(musb, glue);
50740f099e3SMarkus Pargmann 	if (ret)
50840f099e3SMarkus Pargmann 		return ret;
50940f099e3SMarkus Pargmann 
5109ecb8875SAjay Kumar Gupta 	return 0;
5119ecb8875SAjay Kumar Gupta }
5129ecb8875SAjay Kumar Gupta 
5139ecb8875SAjay Kumar Gupta static int dsps_musb_exit(struct musb *musb)
5149ecb8875SAjay Kumar Gupta {
5159ecb8875SAjay Kumar Gupta 	struct device *dev = musb->controller;
516db4a9320SB, Ravi 	struct dsps_glue *glue = dev_get_drvdata(dev->parent);
5179ecb8875SAjay Kumar Gupta 
51897238b35SSebastian Andrzej Siewior 	del_timer_sync(&glue->timer);
5197557a57fSSebastian Andrzej Siewior 	usb_phy_shutdown(musb->xceiv);
520bb90600dSTony Lindgren 	phy_power_off(musb->phy);
521bb90600dSTony Lindgren 	phy_exit(musb->phy);
5220fca91b8SDaniel Mack 	debugfs_remove_recursive(glue->dbgfs_root);
5230fca91b8SDaniel Mack 
5249ecb8875SAjay Kumar Gupta 	return 0;
5259ecb8875SAjay Kumar Gupta }
5269ecb8875SAjay Kumar Gupta 
527943c1397SFelipe Balbi static int dsps_musb_set_mode(struct musb *musb, u8 mode)
528943c1397SFelipe Balbi {
529943c1397SFelipe Balbi 	struct device *dev = musb->controller;
530943c1397SFelipe Balbi 	struct dsps_glue *glue = dev_get_drvdata(dev->parent);
531943c1397SFelipe Balbi 	const struct dsps_musb_wrapper *wrp = glue->wrp;
532943c1397SFelipe Balbi 	void __iomem *ctrl_base = musb->ctrl_base;
533943c1397SFelipe Balbi 	u32 reg;
534943c1397SFelipe Balbi 
53580356913SLothar Waßmann 	reg = dsps_readl(ctrl_base, wrp->mode);
536943c1397SFelipe Balbi 
537943c1397SFelipe Balbi 	switch (mode) {
538943c1397SFelipe Balbi 	case MUSB_HOST:
539943c1397SFelipe Balbi 		reg &= ~(1 << wrp->iddig);
540943c1397SFelipe Balbi 
541943c1397SFelipe Balbi 		/*
542943c1397SFelipe Balbi 		 * if we're setting mode to host-only or device-only, we're
543943c1397SFelipe Balbi 		 * going to ignore whatever the PHY sends us and just force
544943c1397SFelipe Balbi 		 * ID pin status by SW
545943c1397SFelipe Balbi 		 */
546943c1397SFelipe Balbi 		reg |= (1 << wrp->iddig_mux);
547943c1397SFelipe Balbi 
54880356913SLothar Waßmann 		dsps_writel(ctrl_base, wrp->mode, reg);
549943c1397SFelipe Balbi 		dsps_writel(ctrl_base, wrp->phy_utmi, 0x02);
550943c1397SFelipe Balbi 		break;
551943c1397SFelipe Balbi 	case MUSB_PERIPHERAL:
552943c1397SFelipe Balbi 		reg |= (1 << wrp->iddig);
553943c1397SFelipe Balbi 
554943c1397SFelipe Balbi 		/*
555943c1397SFelipe Balbi 		 * if we're setting mode to host-only or device-only, we're
556943c1397SFelipe Balbi 		 * going to ignore whatever the PHY sends us and just force
557943c1397SFelipe Balbi 		 * ID pin status by SW
558943c1397SFelipe Balbi 		 */
559943c1397SFelipe Balbi 		reg |= (1 << wrp->iddig_mux);
560943c1397SFelipe Balbi 
56180356913SLothar Waßmann 		dsps_writel(ctrl_base, wrp->mode, reg);
562943c1397SFelipe Balbi 		break;
563943c1397SFelipe Balbi 	case MUSB_OTG:
56480356913SLothar Waßmann 		dsps_writel(ctrl_base, wrp->phy_utmi, 0x02);
565943c1397SFelipe Balbi 		break;
566943c1397SFelipe Balbi 	default:
567943c1397SFelipe Balbi 		dev_err(glue->dev, "unsupported mode %d\n", mode);
568943c1397SFelipe Balbi 		return -EINVAL;
569943c1397SFelipe Balbi 	}
570943c1397SFelipe Balbi 
571943c1397SFelipe Balbi 	return 0;
572943c1397SFelipe Balbi }
573943c1397SFelipe Balbi 
574371254ceSGeorge Cherian static bool  sw_babble_control(struct musb *musb)
575371254ceSGeorge Cherian {
576371254ceSGeorge Cherian 	u8 babble_ctl;
577371254ceSGeorge Cherian 	bool session_restart =  false;
578371254ceSGeorge Cherian 
579371254ceSGeorge Cherian 	babble_ctl = dsps_readb(musb->mregs, MUSB_BABBLE_CTL);
580371254ceSGeorge Cherian 	dev_dbg(musb->controller, "babble: MUSB_BABBLE_CTL value %x\n",
581371254ceSGeorge Cherian 		babble_ctl);
582371254ceSGeorge Cherian 	/*
583371254ceSGeorge Cherian 	 * check line monitor flag to check whether babble is
584371254ceSGeorge Cherian 	 * due to noise
585371254ceSGeorge Cherian 	 */
586371254ceSGeorge Cherian 	dev_dbg(musb->controller, "STUCK_J is %s\n",
587371254ceSGeorge Cherian 		babble_ctl & MUSB_BABBLE_STUCK_J ? "set" : "reset");
588371254ceSGeorge Cherian 
589371254ceSGeorge Cherian 	if (babble_ctl & MUSB_BABBLE_STUCK_J) {
590371254ceSGeorge Cherian 		int timeout = 10;
591371254ceSGeorge Cherian 
592371254ceSGeorge Cherian 		/*
593371254ceSGeorge Cherian 		 * babble is due to noise, then set transmit idle (d7 bit)
594371254ceSGeorge Cherian 		 * to resume normal operation
595371254ceSGeorge Cherian 		 */
596371254ceSGeorge Cherian 		babble_ctl = dsps_readb(musb->mregs, MUSB_BABBLE_CTL);
597371254ceSGeorge Cherian 		babble_ctl |= MUSB_BABBLE_FORCE_TXIDLE;
598371254ceSGeorge Cherian 		dsps_writeb(musb->mregs, MUSB_BABBLE_CTL, babble_ctl);
599371254ceSGeorge Cherian 
600371254ceSGeorge Cherian 		/* wait till line monitor flag cleared */
601371254ceSGeorge Cherian 		dev_dbg(musb->controller, "Set TXIDLE, wait J to clear\n");
602371254ceSGeorge Cherian 		do {
603371254ceSGeorge Cherian 			babble_ctl = dsps_readb(musb->mregs, MUSB_BABBLE_CTL);
604371254ceSGeorge Cherian 			udelay(1);
605371254ceSGeorge Cherian 		} while ((babble_ctl & MUSB_BABBLE_STUCK_J) && timeout--);
606371254ceSGeorge Cherian 
607371254ceSGeorge Cherian 		/* check whether stuck_at_j bit cleared */
608371254ceSGeorge Cherian 		if (babble_ctl & MUSB_BABBLE_STUCK_J) {
609371254ceSGeorge Cherian 			/*
610371254ceSGeorge Cherian 			 * real babble condition has occurred
611371254ceSGeorge Cherian 			 * restart the controller to start the
612371254ceSGeorge Cherian 			 * session again
613371254ceSGeorge Cherian 			 */
614371254ceSGeorge Cherian 			dev_dbg(musb->controller, "J not cleared, misc (%x)\n",
615371254ceSGeorge Cherian 				babble_ctl);
616371254ceSGeorge Cherian 			session_restart = true;
617371254ceSGeorge Cherian 		}
618371254ceSGeorge Cherian 	} else {
619371254ceSGeorge Cherian 		session_restart = true;
620371254ceSGeorge Cherian 	}
621371254ceSGeorge Cherian 
622371254ceSGeorge Cherian 	return session_restart;
623371254ceSGeorge Cherian }
624371254ceSGeorge Cherian 
625d871c622SGeorge Cherian static int dsps_musb_reset(struct musb *musb)
6261d57de30SDaniel Mack {
6271d57de30SDaniel Mack 	struct device *dev = musb->controller;
6281d57de30SDaniel Mack 	struct dsps_glue *glue = dev_get_drvdata(dev->parent);
6291d57de30SDaniel Mack 	const struct dsps_musb_wrapper *wrp = glue->wrp;
630bb90600dSTony Lindgren 	int session_restart = 0, error;
6311d57de30SDaniel Mack 
632371254ceSGeorge Cherian 	if (glue->sw_babble_enabled)
633371254ceSGeorge Cherian 		session_restart = sw_babble_control(musb);
634371254ceSGeorge Cherian 	/*
635371254ceSGeorge Cherian 	 * In case of new silicon version babble condition can be recovered
636371254ceSGeorge Cherian 	 * without resetting the MUSB. But for older silicon versions, MUSB
637371254ceSGeorge Cherian 	 * reset is needed
638371254ceSGeorge Cherian 	 */
639371254ceSGeorge Cherian 	if (session_restart || !glue->sw_babble_enabled) {
640371254ceSGeorge Cherian 		dev_info(musb->controller, "Restarting MUSB to recover from Babble\n");
6411d57de30SDaniel Mack 		dsps_writel(musb->ctrl_base, wrp->control, (1 << wrp->reset));
64256700178SGeorge Cherian 		usleep_range(100, 200);
64356700178SGeorge Cherian 		usb_phy_shutdown(musb->xceiv);
644bb90600dSTony Lindgren 		error = phy_power_off(musb->phy);
645bb90600dSTony Lindgren 		if (error)
646bb90600dSTony Lindgren 			dev_err(dev, "phy shutdown failed: %i\n", error);
64756700178SGeorge Cherian 		usleep_range(100, 200);
64856700178SGeorge Cherian 		usb_phy_init(musb->xceiv);
649bb90600dSTony Lindgren 		error = phy_power_on(musb->phy);
650bb90600dSTony Lindgren 		if (error)
651bb90600dSTony Lindgren 			dev_err(dev, "phy powerup failed: %i\n", error);
652371254ceSGeorge Cherian 		session_restart = 1;
653371254ceSGeorge Cherian 	}
65456700178SGeorge Cherian 
655*d0cddae7SFelipe Balbi 	return session_restart ? 0 : -EPIPE;
6561d57de30SDaniel Mack }
6571d57de30SDaniel Mack 
6589ecb8875SAjay Kumar Gupta static struct musb_platform_ops dsps_ops = {
659d026e9c7STony Lindgren 	.quirks		= MUSB_INDEXED_EP,
6609ecb8875SAjay Kumar Gupta 	.init		= dsps_musb_init,
6619ecb8875SAjay Kumar Gupta 	.exit		= dsps_musb_exit,
6629ecb8875SAjay Kumar Gupta 
6639ecb8875SAjay Kumar Gupta 	.enable		= dsps_musb_enable,
6649ecb8875SAjay Kumar Gupta 	.disable	= dsps_musb_disable,
6659ecb8875SAjay Kumar Gupta 
6669ecb8875SAjay Kumar Gupta 	.try_idle	= dsps_musb_try_idle,
667943c1397SFelipe Balbi 	.set_mode	= dsps_musb_set_mode,
6681d57de30SDaniel Mack 	.reset		= dsps_musb_reset,
6699ecb8875SAjay Kumar Gupta };
6709ecb8875SAjay Kumar Gupta 
6719ecb8875SAjay Kumar Gupta static u64 musb_dmamask = DMA_BIT_MASK(32);
6729ecb8875SAjay Kumar Gupta 
67397238b35SSebastian Andrzej Siewior static int get_int_prop(struct device_node *dn, const char *s)
6749ecb8875SAjay Kumar Gupta {
67597238b35SSebastian Andrzej Siewior 	int ret;
67697238b35SSebastian Andrzej Siewior 	u32 val;
67797238b35SSebastian Andrzej Siewior 
67897238b35SSebastian Andrzej Siewior 	ret = of_property_read_u32(dn, s, &val);
67997238b35SSebastian Andrzej Siewior 	if (ret)
68097238b35SSebastian Andrzej Siewior 		return 0;
68197238b35SSebastian Andrzej Siewior 	return val;
68297238b35SSebastian Andrzej Siewior }
68397238b35SSebastian Andrzej Siewior 
684c031a7d4SSebastian Andrzej Siewior static int get_musb_port_mode(struct device *dev)
685c031a7d4SSebastian Andrzej Siewior {
686c031a7d4SSebastian Andrzej Siewior 	enum usb_dr_mode mode;
687c031a7d4SSebastian Andrzej Siewior 
688c031a7d4SSebastian Andrzej Siewior 	mode = of_usb_get_dr_mode(dev->of_node);
689c031a7d4SSebastian Andrzej Siewior 	switch (mode) {
690c031a7d4SSebastian Andrzej Siewior 	case USB_DR_MODE_HOST:
691c031a7d4SSebastian Andrzej Siewior 		return MUSB_PORT_MODE_HOST;
692c031a7d4SSebastian Andrzej Siewior 
693c031a7d4SSebastian Andrzej Siewior 	case USB_DR_MODE_PERIPHERAL:
694c031a7d4SSebastian Andrzej Siewior 		return MUSB_PORT_MODE_GADGET;
695c031a7d4SSebastian Andrzej Siewior 
696c031a7d4SSebastian Andrzej Siewior 	case USB_DR_MODE_UNKNOWN:
697c031a7d4SSebastian Andrzej Siewior 	case USB_DR_MODE_OTG:
698c031a7d4SSebastian Andrzej Siewior 	default:
699c031a7d4SSebastian Andrzej Siewior 		return MUSB_PORT_MODE_DUAL_ROLE;
7002b84f92bSJoe Perches 	}
701c031a7d4SSebastian Andrzej Siewior }
702c031a7d4SSebastian Andrzej Siewior 
70397238b35SSebastian Andrzej Siewior static int dsps_create_musb_pdev(struct dsps_glue *glue,
70497238b35SSebastian Andrzej Siewior 		struct platform_device *parent)
70597238b35SSebastian Andrzej Siewior {
70697238b35SSebastian Andrzej Siewior 	struct musb_hdrc_platform_data pdata;
70797238b35SSebastian Andrzej Siewior 	struct resource	resources[2];
708c031a7d4SSebastian Andrzej Siewior 	struct resource	*res;
70997238b35SSebastian Andrzej Siewior 	struct device *dev = &parent->dev;
71065145677SAjay Kumar Gupta 	struct musb_hdrc_config	*config;
7119ecb8875SAjay Kumar Gupta 	struct platform_device *musb;
71297238b35SSebastian Andrzej Siewior 	struct device_node *dn = parent->dev.of_node;
713606bf4d5STony Lindgren 	int ret, val;
7149ecb8875SAjay Kumar Gupta 
71597238b35SSebastian Andrzej Siewior 	memset(resources, 0, sizeof(resources));
716c031a7d4SSebastian Andrzej Siewior 	res = platform_get_resource_byname(parent, IORESOURCE_MEM, "mc");
717c031a7d4SSebastian Andrzej Siewior 	if (!res) {
71897238b35SSebastian Andrzej Siewior 		dev_err(dev, "failed to get memory.\n");
719c031a7d4SSebastian Andrzej Siewior 		return -EINVAL;
7209ecb8875SAjay Kumar Gupta 	}
721c031a7d4SSebastian Andrzej Siewior 	resources[0] = *res;
72297238b35SSebastian Andrzej Siewior 
723c031a7d4SSebastian Andrzej Siewior 	res = platform_get_resource_byname(parent, IORESOURCE_IRQ, "mc");
724c031a7d4SSebastian Andrzej Siewior 	if (!res) {
72597238b35SSebastian Andrzej Siewior 		dev_err(dev, "failed to get irq.\n");
726c031a7d4SSebastian Andrzej Siewior 		return -EINVAL;
72797238b35SSebastian Andrzej Siewior 	}
728c031a7d4SSebastian Andrzej Siewior 	resources[1] = *res;
7299ecb8875SAjay Kumar Gupta 
73065b3d52dSB, Ravi 	/* allocate the child platform device */
7312f771164SSebastian Andrzej Siewior 	musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
73265b3d52dSB, Ravi 	if (!musb) {
73365b3d52dSB, Ravi 		dev_err(dev, "failed to allocate musb device\n");
73497238b35SSebastian Andrzej Siewior 		return -ENOMEM;
73565b3d52dSB, Ravi 	}
7369ecb8875SAjay Kumar Gupta 
7379ecb8875SAjay Kumar Gupta 	musb->dev.parent		= dev;
7389ecb8875SAjay Kumar Gupta 	musb->dev.dma_mask		= &musb_dmamask;
7399ecb8875SAjay Kumar Gupta 	musb->dev.coherent_dma_mask	= musb_dmamask;
740c031a7d4SSebastian Andrzej Siewior 	musb->dev.of_node		= of_node_get(dn);
7419ecb8875SAjay Kumar Gupta 
74297238b35SSebastian Andrzej Siewior 	glue->musb = musb;
7439ecb8875SAjay Kumar Gupta 
74497238b35SSebastian Andrzej Siewior 	ret = platform_device_add_resources(musb, resources,
74597238b35SSebastian Andrzej Siewior 			ARRAY_SIZE(resources));
7469ecb8875SAjay Kumar Gupta 	if (ret) {
7479ecb8875SAjay Kumar Gupta 		dev_err(dev, "failed to add resources\n");
74897238b35SSebastian Andrzej Siewior 		goto err;
7499ecb8875SAjay Kumar Gupta 	}
7509ecb8875SAjay Kumar Gupta 
75197238b35SSebastian Andrzej Siewior 	config = devm_kzalloc(&parent->dev, sizeof(*config), GFP_KERNEL);
75265145677SAjay Kumar Gupta 	if (!config) {
753b25e5f1cSWei Yongjun 		ret = -ENOMEM;
75497238b35SSebastian Andrzej Siewior 		goto err;
75565145677SAjay Kumar Gupta 	}
75697238b35SSebastian Andrzej Siewior 	pdata.config = config;
75797238b35SSebastian Andrzej Siewior 	pdata.platform_ops = &dsps_ops;
75865145677SAjay Kumar Gupta 
759c031a7d4SSebastian Andrzej Siewior 	config->num_eps = get_int_prop(dn, "mentor,num-eps");
760c031a7d4SSebastian Andrzej Siewior 	config->ram_bits = get_int_prop(dn, "mentor,ram-bits");
761869c5978SDaniel Mack 	config->host_port_deassert_reset_at_resume = 1;
762c031a7d4SSebastian Andrzej Siewior 	pdata.mode = get_musb_port_mode(dev);
763c031a7d4SSebastian Andrzej Siewior 	/* DT keeps this entry in mA, musb expects it as per USB spec */
764c031a7d4SSebastian Andrzej Siewior 	pdata.power = get_int_prop(dn, "mentor,power") / 2;
765606bf4d5STony Lindgren 
766606bf4d5STony Lindgren 	ret = of_property_read_u32(dn, "mentor,multipoint", &val);
767606bf4d5STony Lindgren 	if (!ret && val)
768606bf4d5STony Lindgren 		config->multipoint = true;
76965145677SAjay Kumar Gupta 
77097238b35SSebastian Andrzej Siewior 	ret = platform_device_add_data(musb, &pdata, sizeof(pdata));
7719ecb8875SAjay Kumar Gupta 	if (ret) {
7729ecb8875SAjay Kumar Gupta 		dev_err(dev, "failed to add platform_data\n");
77397238b35SSebastian Andrzej Siewior 		goto err;
7749ecb8875SAjay Kumar Gupta 	}
7759ecb8875SAjay Kumar Gupta 
7769ecb8875SAjay Kumar Gupta 	ret = platform_device_add(musb);
7779ecb8875SAjay Kumar Gupta 	if (ret) {
7789ecb8875SAjay Kumar Gupta 		dev_err(dev, "failed to register musb device\n");
77997238b35SSebastian Andrzej Siewior 		goto err;
7809ecb8875SAjay Kumar Gupta 	}
7819ecb8875SAjay Kumar Gupta 	return 0;
7829ecb8875SAjay Kumar Gupta 
78397238b35SSebastian Andrzej Siewior err:
7849ecb8875SAjay Kumar Gupta 	platform_device_put(musb);
7859ecb8875SAjay Kumar Gupta 	return ret;
7869ecb8875SAjay Kumar Gupta }
7879ecb8875SAjay Kumar Gupta 
78841ac7b3aSBill Pemberton static int dsps_probe(struct platform_device *pdev)
7899ecb8875SAjay Kumar Gupta {
79065145677SAjay Kumar Gupta 	const struct of_device_id *match;
79165145677SAjay Kumar Gupta 	const struct dsps_musb_wrapper *wrp;
7929ecb8875SAjay Kumar Gupta 	struct dsps_glue *glue;
79397238b35SSebastian Andrzej Siewior 	int ret;
7949ecb8875SAjay Kumar Gupta 
7954fc4b274SSebastian Andrzej Siewior 	if (!strcmp(pdev->name, "musb-hdrc"))
7964fc4b274SSebastian Andrzej Siewior 		return -ENODEV;
7974fc4b274SSebastian Andrzej Siewior 
798cc506036SFelipe Balbi 	match = of_match_node(musb_dsps_of_match, pdev->dev.of_node);
79965145677SAjay Kumar Gupta 	if (!match) {
80065145677SAjay Kumar Gupta 		dev_err(&pdev->dev, "fail to get matching of_match struct\n");
80197238b35SSebastian Andrzej Siewior 		return -EINVAL;
80265145677SAjay Kumar Gupta 	}
80365145677SAjay Kumar Gupta 	wrp = match->data;
8049ecb8875SAjay Kumar Gupta 
8059ecb8875SAjay Kumar Gupta 	/* allocate glue */
806de9db572SMarkus Pargmann 	glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
8070816ea2fSPeter Chen 	if (!glue)
80897238b35SSebastian Andrzej Siewior 		return -ENOMEM;
8099ecb8875SAjay Kumar Gupta 
8109ecb8875SAjay Kumar Gupta 	glue->dev = &pdev->dev;
81197238b35SSebastian Andrzej Siewior 	glue->wrp = wrp;
8129ecb8875SAjay Kumar Gupta 
8139ecb8875SAjay Kumar Gupta 	platform_set_drvdata(pdev, glue);
8149ecb8875SAjay Kumar Gupta 	pm_runtime_enable(&pdev->dev);
8159ecb8875SAjay Kumar Gupta 
8169ecb8875SAjay Kumar Gupta 	ret = pm_runtime_get_sync(&pdev->dev);
8179ecb8875SAjay Kumar Gupta 	if (ret < 0) {
8189ecb8875SAjay Kumar Gupta 		dev_err(&pdev->dev, "pm_runtime_get_sync FAILED");
8190e38c4edSAjay Kumar Gupta 		goto err2;
8200e38c4edSAjay Kumar Gupta 	}
8210e38c4edSAjay Kumar Gupta 
82297238b35SSebastian Andrzej Siewior 	ret = dsps_create_musb_pdev(glue, pdev);
82397238b35SSebastian Andrzej Siewior 	if (ret)
8249ecb8875SAjay Kumar Gupta 		goto err3;
8259ecb8875SAjay Kumar Gupta 
8269ecb8875SAjay Kumar Gupta 	return 0;
8279ecb8875SAjay Kumar Gupta 
8289ecb8875SAjay Kumar Gupta err3:
8290e38c4edSAjay Kumar Gupta 	pm_runtime_put(&pdev->dev);
8309ecb8875SAjay Kumar Gupta err2:
8310e38c4edSAjay Kumar Gupta 	pm_runtime_disable(&pdev->dev);
8329ecb8875SAjay Kumar Gupta 	return ret;
8339ecb8875SAjay Kumar Gupta }
83497238b35SSebastian Andrzej Siewior 
835fb4e98abSBill Pemberton static int dsps_remove(struct platform_device *pdev)
8369ecb8875SAjay Kumar Gupta {
8379ecb8875SAjay Kumar Gupta 	struct dsps_glue *glue = platform_get_drvdata(pdev);
8389ecb8875SAjay Kumar Gupta 
83997238b35SSebastian Andrzej Siewior 	platform_device_unregister(glue->musb);
8409ecb8875SAjay Kumar Gupta 
8419ecb8875SAjay Kumar Gupta 	/* disable usbss clocks */
8429ecb8875SAjay Kumar Gupta 	pm_runtime_put(&pdev->dev);
8439ecb8875SAjay Kumar Gupta 	pm_runtime_disable(&pdev->dev);
84440f099e3SMarkus Pargmann 
8459ecb8875SAjay Kumar Gupta 	return 0;
8469ecb8875SAjay Kumar Gupta }
8479ecb8875SAjay Kumar Gupta 
848fa7b4ca5SSebastian Andrzej Siewior static const struct dsps_musb_wrapper am33xx_driver_data = {
8499ecb8875SAjay Kumar Gupta 	.revision		= 0x00,
8509ecb8875SAjay Kumar Gupta 	.control		= 0x14,
8519ecb8875SAjay Kumar Gupta 	.status			= 0x18,
8529ecb8875SAjay Kumar Gupta 	.epintr_set		= 0x38,
8539ecb8875SAjay Kumar Gupta 	.epintr_clear		= 0x40,
8549ecb8875SAjay Kumar Gupta 	.epintr_status		= 0x30,
8559ecb8875SAjay Kumar Gupta 	.coreintr_set		= 0x3c,
8569ecb8875SAjay Kumar Gupta 	.coreintr_clear		= 0x44,
8579ecb8875SAjay Kumar Gupta 	.coreintr_status	= 0x34,
8589ecb8875SAjay Kumar Gupta 	.phy_utmi		= 0xe0,
8599ecb8875SAjay Kumar Gupta 	.mode			= 0xe8,
860b991f9b7SDaniel Mack 	.tx_mode		= 0x70,
861b991f9b7SDaniel Mack 	.rx_mode		= 0x74,
8629ecb8875SAjay Kumar Gupta 	.reset			= 0,
8639ecb8875SAjay Kumar Gupta 	.otg_disable		= 21,
8649ecb8875SAjay Kumar Gupta 	.iddig			= 8,
865943c1397SFelipe Balbi 	.iddig_mux		= 7,
8669ecb8875SAjay Kumar Gupta 	.usb_shift		= 0,
8679ecb8875SAjay Kumar Gupta 	.usb_mask		= 0x1ff,
8689ecb8875SAjay Kumar Gupta 	.usb_bitmap		= (0x1ff << 0),
8699ecb8875SAjay Kumar Gupta 	.drvvbus		= 8,
8709ecb8875SAjay Kumar Gupta 	.txep_shift		= 0,
8719ecb8875SAjay Kumar Gupta 	.txep_mask		= 0xffff,
8729ecb8875SAjay Kumar Gupta 	.txep_bitmap		= (0xffff << 0),
8739ecb8875SAjay Kumar Gupta 	.rxep_shift		= 16,
8749ecb8875SAjay Kumar Gupta 	.rxep_mask		= 0xfffe,
8759ecb8875SAjay Kumar Gupta 	.rxep_bitmap		= (0xfffe << 16),
8769ecb8875SAjay Kumar Gupta 	.poll_seconds		= 2,
8779ecb8875SAjay Kumar Gupta };
8789ecb8875SAjay Kumar Gupta 
8792f82686eSBill Pemberton static const struct of_device_id musb_dsps_of_match[] = {
88065145677SAjay Kumar Gupta 	{ .compatible = "ti,musb-am33xx",
881fa7b4ca5SSebastian Andrzej Siewior 		.data = (void *) &am33xx_driver_data, },
8829ecb8875SAjay Kumar Gupta 	{  },
8839ecb8875SAjay Kumar Gupta };
8849ecb8875SAjay Kumar Gupta MODULE_DEVICE_TABLE(of, musb_dsps_of_match);
8859ecb8875SAjay Kumar Gupta 
8865b783983SWolfram Sang #ifdef CONFIG_PM_SLEEP
887869c5978SDaniel Mack static int dsps_suspend(struct device *dev)
888869c5978SDaniel Mack {
889869c5978SDaniel Mack 	struct dsps_glue *glue = dev_get_drvdata(dev);
890869c5978SDaniel Mack 	const struct dsps_musb_wrapper *wrp = glue->wrp;
891869c5978SDaniel Mack 	struct musb *musb = platform_get_drvdata(glue->musb);
892f042e9cbSSebastian Andrzej Siewior 	void __iomem *mbase;
893869c5978SDaniel Mack 
894468bcc2aSFelipe Balbi 	del_timer_sync(&glue->timer);
895f042e9cbSSebastian Andrzej Siewior 
896f042e9cbSSebastian Andrzej Siewior 	if (!musb)
897f042e9cbSSebastian Andrzej Siewior 		/* This can happen if the musb device is in -EPROBE_DEFER */
898f042e9cbSSebastian Andrzej Siewior 		return 0;
899f042e9cbSSebastian Andrzej Siewior 
900f042e9cbSSebastian Andrzej Siewior 	mbase = musb->ctrl_base;
901869c5978SDaniel Mack 	glue->context.control = dsps_readl(mbase, wrp->control);
902869c5978SDaniel Mack 	glue->context.epintr = dsps_readl(mbase, wrp->epintr_set);
903869c5978SDaniel Mack 	glue->context.coreintr = dsps_readl(mbase, wrp->coreintr_set);
904869c5978SDaniel Mack 	glue->context.phy_utmi = dsps_readl(mbase, wrp->phy_utmi);
905869c5978SDaniel Mack 	glue->context.mode = dsps_readl(mbase, wrp->mode);
906869c5978SDaniel Mack 	glue->context.tx_mode = dsps_readl(mbase, wrp->tx_mode);
907869c5978SDaniel Mack 	glue->context.rx_mode = dsps_readl(mbase, wrp->rx_mode);
908869c5978SDaniel Mack 
909869c5978SDaniel Mack 	return 0;
910869c5978SDaniel Mack }
911869c5978SDaniel Mack 
912869c5978SDaniel Mack static int dsps_resume(struct device *dev)
913869c5978SDaniel Mack {
914869c5978SDaniel Mack 	struct dsps_glue *glue = dev_get_drvdata(dev);
915869c5978SDaniel Mack 	const struct dsps_musb_wrapper *wrp = glue->wrp;
916869c5978SDaniel Mack 	struct musb *musb = platform_get_drvdata(glue->musb);
917f042e9cbSSebastian Andrzej Siewior 	void __iomem *mbase;
918869c5978SDaniel Mack 
919f042e9cbSSebastian Andrzej Siewior 	if (!musb)
920f042e9cbSSebastian Andrzej Siewior 		return 0;
921f042e9cbSSebastian Andrzej Siewior 
922f042e9cbSSebastian Andrzej Siewior 	mbase = musb->ctrl_base;
923869c5978SDaniel Mack 	dsps_writel(mbase, wrp->control, glue->context.control);
924869c5978SDaniel Mack 	dsps_writel(mbase, wrp->epintr_set, glue->context.epintr);
925869c5978SDaniel Mack 	dsps_writel(mbase, wrp->coreintr_set, glue->context.coreintr);
926869c5978SDaniel Mack 	dsps_writel(mbase, wrp->phy_utmi, glue->context.phy_utmi);
927869c5978SDaniel Mack 	dsps_writel(mbase, wrp->mode, glue->context.mode);
928869c5978SDaniel Mack 	dsps_writel(mbase, wrp->tx_mode, glue->context.tx_mode);
929869c5978SDaniel Mack 	dsps_writel(mbase, wrp->rx_mode, glue->context.rx_mode);
930e47d9254SAntoine Tenart 	if (musb->xceiv->otg->state == OTG_STATE_B_IDLE &&
93153185b3aSSebastian Andrzej Siewior 	    musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE)
93253185b3aSSebastian Andrzej Siewior 		mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
933869c5978SDaniel Mack 
934869c5978SDaniel Mack 	return 0;
935869c5978SDaniel Mack }
936869c5978SDaniel Mack #endif
937869c5978SDaniel Mack 
938869c5978SDaniel Mack static SIMPLE_DEV_PM_OPS(dsps_pm_ops, dsps_suspend, dsps_resume);
939869c5978SDaniel Mack 
9409ecb8875SAjay Kumar Gupta static struct platform_driver dsps_usbss_driver = {
9419ecb8875SAjay Kumar Gupta 	.probe		= dsps_probe,
9427690417dSBill Pemberton 	.remove         = dsps_remove,
9439ecb8875SAjay Kumar Gupta 	.driver         = {
9449ecb8875SAjay Kumar Gupta 		.name   = "musb-dsps",
945869c5978SDaniel Mack 		.pm	= &dsps_pm_ops,
946b432cb83SSachin Kamat 		.of_match_table	= musb_dsps_of_match,
9479ecb8875SAjay Kumar Gupta 	},
9489ecb8875SAjay Kumar Gupta };
9499ecb8875SAjay Kumar Gupta 
9509ecb8875SAjay Kumar Gupta MODULE_DESCRIPTION("TI DSPS MUSB Glue Layer");
9519ecb8875SAjay Kumar Gupta MODULE_AUTHOR("Ravi B <ravibabu@ti.com>");
9529ecb8875SAjay Kumar Gupta MODULE_AUTHOR("Ajay Kumar Gupta <ajay.gupta@ti.com>");
9539ecb8875SAjay Kumar Gupta MODULE_LICENSE("GPL v2");
9549ecb8875SAjay Kumar Gupta 
95597238b35SSebastian Andrzej Siewior module_platform_driver(dsps_usbss_driver);
956