Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2005-2007 by Texas Instruments |
| 3 | * Some code has been taken from tusb6010.c |
| 4 | * Copyrights for that are attributable to: |
| 5 | * Copyright (C) 2006 Nokia Corporation |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 6 | * Tony Lindgren <tony@atomide.com> |
| 7 | * |
| 8 | * This file is part of the Inventra Controller Driver for Linux. |
| 9 | * |
| 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 |
| 13 | * Foundation. |
| 14 | * |
| 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. |
| 20 | * |
| 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 |
| 25 | * |
| 26 | */ |
| 27 | #include <linux/module.h> |
| 28 | #include <linux/kernel.h> |
| 29 | #include <linux/sched.h> |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 30 | #include <linux/init.h> |
| 31 | #include <linux/list.h> |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 32 | #include <linux/io.h> |
Felipe Balbi | dc09886 | 2010-12-01 15:01:11 +0200 | [diff] [blame] | 33 | #include <linux/platform_device.h> |
| 34 | #include <linux/dma-mapping.h> |
Hema HK | 207b0e1 | 2011-02-17 12:07:22 +0530 | [diff] [blame] | 35 | #include <linux/pm_runtime.h> |
| 36 | #include <linux/err.h> |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 37 | #include <linux/usb/musb-omap.h> |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 38 | |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 39 | #include "musb_core.h" |
| 40 | #include "omap2430.h" |
| 41 | |
Felipe Balbi | a3cee12 | 2010-12-02 09:27:29 +0200 | [diff] [blame] | 42 | struct omap2430_glue { |
| 43 | struct device *dev; |
| 44 | struct platform_device *musb; |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 45 | enum omap_musb_vbus_id_status status; |
Kishon Vijay Abraham I | 1e5acb8 | 2012-06-22 17:40:51 +0530 | [diff] [blame] | 46 | struct work_struct omap_musb_mailbox_work; |
Felipe Balbi | a3cee12 | 2010-12-02 09:27:29 +0200 | [diff] [blame] | 47 | }; |
Felipe Balbi | c20aebb | 2010-12-02 12:44:40 +0200 | [diff] [blame] | 48 | #define glue_to_musb(g) platform_get_drvdata(g->musb) |
Felipe Balbi | a3cee12 | 2010-12-02 09:27:29 +0200 | [diff] [blame] | 49 | |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 50 | struct omap2430_glue *_glue; |
| 51 | |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 52 | static struct timer_list musb_idle_timer; |
| 53 | |
| 54 | static void musb_do_idle(unsigned long _musb) |
| 55 | { |
| 56 | struct musb *musb = (void *)_musb; |
| 57 | unsigned long flags; |
| 58 | u8 power; |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 59 | u8 devctl; |
| 60 | |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 61 | spin_lock_irqsave(&musb->lock, flags); |
| 62 | |
David Brownell | 84e250f | 2009-03-31 12:30:04 -0700 | [diff] [blame] | 63 | switch (musb->xceiv->state) { |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 64 | case OTG_STATE_A_WAIT_BCON: |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 65 | |
| 66 | devctl = musb_readb(musb->mregs, MUSB_DEVCTL); |
| 67 | if (devctl & MUSB_DEVCTL_BDEVICE) { |
David Brownell | 84e250f | 2009-03-31 12:30:04 -0700 | [diff] [blame] | 68 | musb->xceiv->state = OTG_STATE_B_IDLE; |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 69 | MUSB_DEV_MODE(musb); |
| 70 | } else { |
David Brownell | 84e250f | 2009-03-31 12:30:04 -0700 | [diff] [blame] | 71 | musb->xceiv->state = OTG_STATE_A_IDLE; |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 72 | MUSB_HST_MODE(musb); |
| 73 | } |
| 74 | break; |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 75 | case OTG_STATE_A_SUSPEND: |
| 76 | /* finish RESUME signaling? */ |
| 77 | if (musb->port1_status & MUSB_PORT_STAT_RESUME) { |
| 78 | power = musb_readb(musb->mregs, MUSB_POWER); |
| 79 | power &= ~MUSB_POWER_RESUME; |
Felipe Balbi | 5c8a86e | 2011-05-11 12:44:08 +0300 | [diff] [blame] | 80 | dev_dbg(musb->controller, "root port resume stopped, power %02x\n", power); |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 81 | musb_writeb(musb->mregs, MUSB_POWER, power); |
| 82 | musb->is_active = 1; |
| 83 | musb->port1_status &= ~(USB_PORT_STAT_SUSPEND |
| 84 | | MUSB_PORT_STAT_RESUME); |
| 85 | musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16; |
| 86 | usb_hcd_poll_rh_status(musb_to_hcd(musb)); |
| 87 | /* NOTE: it might really be A_WAIT_BCON ... */ |
David Brownell | 84e250f | 2009-03-31 12:30:04 -0700 | [diff] [blame] | 88 | musb->xceiv->state = OTG_STATE_A_HOST; |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 89 | } |
| 90 | break; |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 91 | case OTG_STATE_A_HOST: |
| 92 | devctl = musb_readb(musb->mregs, MUSB_DEVCTL); |
| 93 | if (devctl & MUSB_DEVCTL_BDEVICE) |
David Brownell | 84e250f | 2009-03-31 12:30:04 -0700 | [diff] [blame] | 94 | musb->xceiv->state = OTG_STATE_B_IDLE; |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 95 | else |
David Brownell | 84e250f | 2009-03-31 12:30:04 -0700 | [diff] [blame] | 96 | musb->xceiv->state = OTG_STATE_A_WAIT_BCON; |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 97 | default: |
| 98 | break; |
| 99 | } |
| 100 | spin_unlock_irqrestore(&musb->lock, flags); |
| 101 | } |
| 102 | |
| 103 | |
Felipe Balbi | 743411b | 2010-12-01 13:22:05 +0200 | [diff] [blame] | 104 | static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout) |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 105 | { |
| 106 | unsigned long default_timeout = jiffies + msecs_to_jiffies(3); |
| 107 | static unsigned long last_timer; |
| 108 | |
| 109 | if (timeout == 0) |
| 110 | timeout = default_timeout; |
| 111 | |
| 112 | /* Never idle if active, or when VBUS timeout is not set as host */ |
| 113 | if (musb->is_active || ((musb->a_wait_bcon == 0) |
David Brownell | 84e250f | 2009-03-31 12:30:04 -0700 | [diff] [blame] | 114 | && (musb->xceiv->state == OTG_STATE_A_WAIT_BCON))) { |
Felipe Balbi | 5c8a86e | 2011-05-11 12:44:08 +0300 | [diff] [blame] | 115 | dev_dbg(musb->controller, "%s active, deleting timer\n", |
Anatolij Gustschin | 3df0045 | 2011-05-05 12:11:21 +0200 | [diff] [blame] | 116 | otg_state_string(musb->xceiv->state)); |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 117 | del_timer(&musb_idle_timer); |
| 118 | last_timer = jiffies; |
| 119 | return; |
| 120 | } |
| 121 | |
| 122 | if (time_after(last_timer, timeout)) { |
| 123 | if (!timer_pending(&musb_idle_timer)) |
| 124 | last_timer = timeout; |
| 125 | else { |
Felipe Balbi | 5c8a86e | 2011-05-11 12:44:08 +0300 | [diff] [blame] | 126 | dev_dbg(musb->controller, "Longer idle timer already pending, ignoring\n"); |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 127 | return; |
| 128 | } |
| 129 | } |
| 130 | last_timer = timeout; |
| 131 | |
Felipe Balbi | 5c8a86e | 2011-05-11 12:44:08 +0300 | [diff] [blame] | 132 | dev_dbg(musb->controller, "%s inactive, for idle timer for %lu ms\n", |
Anatolij Gustschin | 3df0045 | 2011-05-05 12:11:21 +0200 | [diff] [blame] | 133 | otg_state_string(musb->xceiv->state), |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 134 | (unsigned long)jiffies_to_msecs(timeout - jiffies)); |
| 135 | mod_timer(&musb_idle_timer, timeout); |
| 136 | } |
| 137 | |
Felipe Balbi | 743411b | 2010-12-01 13:22:05 +0200 | [diff] [blame] | 138 | static void omap2430_musb_set_vbus(struct musb *musb, int is_on) |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 139 | { |
Heikki Krogerus | d445b6d | 2012-02-13 13:24:15 +0200 | [diff] [blame] | 140 | struct usb_otg *otg = musb->xceiv->otg; |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 141 | u8 devctl; |
Hema HK | 594632e | 2010-12-10 18:10:51 +0530 | [diff] [blame] | 142 | unsigned long timeout = jiffies + msecs_to_jiffies(1000); |
| 143 | int ret = 1; |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 144 | /* HDRC controls CPEN, but beware current surges during device |
| 145 | * connect. They can trigger transient overcurrent conditions |
| 146 | * that must be ignored. |
| 147 | */ |
| 148 | |
| 149 | devctl = musb_readb(musb->mregs, MUSB_DEVCTL); |
| 150 | |
| 151 | if (is_on) { |
Hema HK | 594632e | 2010-12-10 18:10:51 +0530 | [diff] [blame] | 152 | if (musb->xceiv->state == OTG_STATE_A_IDLE) { |
| 153 | /* start the session */ |
| 154 | devctl |= MUSB_DEVCTL_SESSION; |
| 155 | musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); |
| 156 | /* |
| 157 | * Wait for the musb to set as A device to enable the |
| 158 | * VBUS |
| 159 | */ |
| 160 | while (musb_readb(musb->mregs, MUSB_DEVCTL) & 0x80) { |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 161 | |
Hema HK | 594632e | 2010-12-10 18:10:51 +0530 | [diff] [blame] | 162 | cpu_relax(); |
| 163 | |
| 164 | if (time_after(jiffies, timeout)) { |
| 165 | dev_err(musb->controller, |
| 166 | "configured as A device timeout"); |
| 167 | ret = -EINVAL; |
| 168 | break; |
| 169 | } |
| 170 | } |
| 171 | |
Heikki Krogerus | 6e13c65 | 2012-02-13 13:24:20 +0200 | [diff] [blame] | 172 | if (ret && otg->set_vbus) |
| 173 | otg_set_vbus(otg, 1); |
Hema HK | 594632e | 2010-12-10 18:10:51 +0530 | [diff] [blame] | 174 | } else { |
| 175 | musb->is_active = 1; |
Heikki Krogerus | d445b6d | 2012-02-13 13:24:15 +0200 | [diff] [blame] | 176 | otg->default_a = 1; |
Hema HK | 594632e | 2010-12-10 18:10:51 +0530 | [diff] [blame] | 177 | musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; |
| 178 | devctl |= MUSB_DEVCTL_SESSION; |
| 179 | MUSB_HST_MODE(musb); |
| 180 | } |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 181 | } else { |
| 182 | musb->is_active = 0; |
| 183 | |
| 184 | /* NOTE: we're skipping A_WAIT_VFALL -> A_IDLE and |
| 185 | * jumping right to B_IDLE... |
| 186 | */ |
| 187 | |
Heikki Krogerus | d445b6d | 2012-02-13 13:24:15 +0200 | [diff] [blame] | 188 | otg->default_a = 0; |
David Brownell | 84e250f | 2009-03-31 12:30:04 -0700 | [diff] [blame] | 189 | musb->xceiv->state = OTG_STATE_B_IDLE; |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 190 | devctl &= ~MUSB_DEVCTL_SESSION; |
| 191 | |
| 192 | MUSB_DEV_MODE(musb); |
| 193 | } |
| 194 | musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); |
| 195 | |
Felipe Balbi | 5c8a86e | 2011-05-11 12:44:08 +0300 | [diff] [blame] | 196 | dev_dbg(musb->controller, "VBUS %s, devctl %02x " |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 197 | /* otg %3x conf %08x prcm %08x */ "\n", |
Anatolij Gustschin | 3df0045 | 2011-05-05 12:11:21 +0200 | [diff] [blame] | 198 | otg_state_string(musb->xceiv->state), |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 199 | musb_readb(musb->mregs, MUSB_DEVCTL)); |
| 200 | } |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 201 | |
Felipe Balbi | 743411b | 2010-12-01 13:22:05 +0200 | [diff] [blame] | 202 | static int omap2430_musb_set_mode(struct musb *musb, u8 musb_mode) |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 203 | { |
| 204 | u8 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); |
| 205 | |
| 206 | devctl |= MUSB_DEVCTL_SESSION; |
| 207 | musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); |
| 208 | |
David Brownell | 96a274d | 2008-11-24 13:06:47 +0200 | [diff] [blame] | 209 | return 0; |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 210 | } |
| 211 | |
Felipe Balbi | c20aebb | 2010-12-02 12:44:40 +0200 | [diff] [blame] | 212 | static inline void omap2430_low_level_exit(struct musb *musb) |
| 213 | { |
| 214 | u32 l; |
| 215 | |
| 216 | /* in any role */ |
| 217 | l = musb_readl(musb->mregs, OTG_FORCESTDBY); |
| 218 | l |= ENABLEFORCE; /* enable MSTANDBY */ |
| 219 | musb_writel(musb->mregs, OTG_FORCESTDBY, l); |
Felipe Balbi | c20aebb | 2010-12-02 12:44:40 +0200 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | static inline void omap2430_low_level_init(struct musb *musb) |
| 223 | { |
| 224 | u32 l; |
| 225 | |
Felipe Balbi | c20aebb | 2010-12-02 12:44:40 +0200 | [diff] [blame] | 226 | l = musb_readl(musb->mregs, OTG_FORCESTDBY); |
| 227 | l &= ~ENABLEFORCE; /* disable MSTANDBY */ |
| 228 | musb_writel(musb->mregs, OTG_FORCESTDBY, l); |
| 229 | } |
| 230 | |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 231 | void omap_musb_mailbox(enum omap_musb_vbus_id_status status) |
Hema HK | 594632e | 2010-12-10 18:10:51 +0530 | [diff] [blame] | 232 | { |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 233 | struct omap2430_glue *glue = _glue; |
| 234 | struct musb *musb = glue_to_musb(glue); |
Vikram Pandita | 712d8ef | 2011-08-12 07:38:51 -0700 | [diff] [blame] | 235 | |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 236 | glue->status = status; |
| 237 | if (!musb) { |
| 238 | dev_err(glue->dev, "musb core is not yet ready\n"); |
| 239 | return; |
| 240 | } |
| 241 | |
Kishon Vijay Abraham I | 1e5acb8 | 2012-06-22 17:40:51 +0530 | [diff] [blame] | 242 | schedule_work(&glue->omap_musb_mailbox_work); |
Vikram Pandita | 712d8ef | 2011-08-12 07:38:51 -0700 | [diff] [blame] | 243 | } |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 244 | EXPORT_SYMBOL_GPL(omap_musb_mailbox); |
Vikram Pandita | 712d8ef | 2011-08-12 07:38:51 -0700 | [diff] [blame] | 245 | |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 246 | static void omap_musb_set_mailbox(struct omap2430_glue *glue) |
Vikram Pandita | 712d8ef | 2011-08-12 07:38:51 -0700 | [diff] [blame] | 247 | { |
Kishon Vijay Abraham I | 1e5acb8 | 2012-06-22 17:40:51 +0530 | [diff] [blame] | 248 | struct musb *musb = glue_to_musb(glue); |
Hema HK | 594632e | 2010-12-10 18:10:51 +0530 | [diff] [blame] | 249 | struct device *dev = musb->controller; |
| 250 | struct musb_hdrc_platform_data *pdata = dev->platform_data; |
| 251 | struct omap_musb_board_data *data = pdata->board_data; |
Kishon Vijay Abraham I | c83a854 | 2012-06-22 17:40:53 +0530 | [diff] [blame] | 252 | struct usb_otg *otg = musb->xceiv->otg; |
Hema HK | 594632e | 2010-12-10 18:10:51 +0530 | [diff] [blame] | 253 | |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 254 | switch (glue->status) { |
| 255 | case OMAP_MUSB_ID_GROUND: |
| 256 | dev_dbg(dev, "ID GND\n"); |
Hema HK | 594632e | 2010-12-10 18:10:51 +0530 | [diff] [blame] | 257 | |
Kishon Vijay Abraham I | c83a854 | 2012-06-22 17:40:53 +0530 | [diff] [blame] | 258 | otg->default_a = true; |
| 259 | musb->xceiv->state = OTG_STATE_A_IDLE; |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 260 | musb->xceiv->last_event = USB_EVENT_ID; |
Felipe Contreras | b3314d9 | 2011-12-19 22:17:49 +0200 | [diff] [blame] | 261 | if (!is_otg_enabled(musb) || musb->gadget_driver) { |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 262 | pm_runtime_get_sync(dev); |
Heikki Krogerus | b96d3b0 | 2012-02-13 13:24:18 +0200 | [diff] [blame] | 263 | usb_phy_init(musb->xceiv); |
Hema HK | 70045c5 | 2011-02-28 15:05:29 +0530 | [diff] [blame] | 264 | omap2430_musb_set_vbus(musb, 1); |
Hema HK | 594632e | 2010-12-10 18:10:51 +0530 | [diff] [blame] | 265 | } |
| 266 | break; |
| 267 | |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 268 | case OMAP_MUSB_VBUS_VALID: |
| 269 | dev_dbg(dev, "VBUS Connect\n"); |
Hema HK | 594632e | 2010-12-10 18:10:51 +0530 | [diff] [blame] | 270 | |
Kishon Vijay Abraham I | c83a854 | 2012-06-22 17:40:53 +0530 | [diff] [blame] | 271 | otg->default_a = false; |
| 272 | musb->xceiv->state = OTG_STATE_B_IDLE; |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 273 | musb->xceiv->last_event = USB_EVENT_VBUS; |
Hema HK | 7acc619 | 2011-02-28 14:19:34 +0530 | [diff] [blame] | 274 | if (musb->gadget_driver) |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 275 | pm_runtime_get_sync(dev); |
Heikki Krogerus | b96d3b0 | 2012-02-13 13:24:18 +0200 | [diff] [blame] | 276 | usb_phy_init(musb->xceiv); |
Hema HK | 594632e | 2010-12-10 18:10:51 +0530 | [diff] [blame] | 277 | break; |
| 278 | |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 279 | case OMAP_MUSB_ID_FLOAT: |
| 280 | case OMAP_MUSB_VBUS_OFF: |
| 281 | dev_dbg(dev, "VBUS Disconnect\n"); |
Hema HK | 594632e | 2010-12-10 18:10:51 +0530 | [diff] [blame] | 282 | |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 283 | musb->xceiv->last_event = USB_EVENT_NONE; |
Jarkko Nikula | 383cf4e | 2011-04-27 17:02:37 +0300 | [diff] [blame] | 284 | if (is_otg_enabled(musb) || is_peripheral_enabled(musb)) |
Felipe Balbi | 6228596 | 2011-06-22 17:28:09 +0300 | [diff] [blame] | 285 | if (musb->gadget_driver) { |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 286 | pm_runtime_mark_last_busy(dev); |
| 287 | pm_runtime_put_autosuspend(dev); |
Hema HK | 7acc619 | 2011-02-28 14:19:34 +0530 | [diff] [blame] | 288 | } |
| 289 | |
Hema HK | 594632e | 2010-12-10 18:10:51 +0530 | [diff] [blame] | 290 | if (data->interface_type == MUSB_INTERFACE_UTMI) { |
Heikki Krogerus | 6e13c65 | 2012-02-13 13:24:20 +0200 | [diff] [blame] | 291 | if (musb->xceiv->otg->set_vbus) |
| 292 | otg_set_vbus(musb->xceiv->otg, 0); |
Hema HK | 594632e | 2010-12-10 18:10:51 +0530 | [diff] [blame] | 293 | } |
Heikki Krogerus | b96d3b0 | 2012-02-13 13:24:18 +0200 | [diff] [blame] | 294 | usb_phy_shutdown(musb->xceiv); |
Hema HK | 594632e | 2010-12-10 18:10:51 +0530 | [diff] [blame] | 295 | break; |
| 296 | default: |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 297 | dev_dbg(dev, "ID float\n"); |
Hema HK | 594632e | 2010-12-10 18:10:51 +0530 | [diff] [blame] | 298 | } |
Hema HK | 594632e | 2010-12-10 18:10:51 +0530 | [diff] [blame] | 299 | } |
| 300 | |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 301 | |
| 302 | static void omap_musb_mailbox_work(struct work_struct *mailbox_work) |
| 303 | { |
| 304 | struct omap2430_glue *glue = container_of(mailbox_work, |
| 305 | struct omap2430_glue, omap_musb_mailbox_work); |
| 306 | omap_musb_set_mailbox(glue); |
| 307 | } |
| 308 | |
Felipe Balbi | 743411b | 2010-12-01 13:22:05 +0200 | [diff] [blame] | 309 | static int omap2430_musb_init(struct musb *musb) |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 310 | { |
Shubhrajyoti D | ad57969 | 2012-03-22 12:48:06 +0530 | [diff] [blame] | 311 | u32 l; |
| 312 | int status = 0; |
Hema Kalliguddi | ea65df5 | 2010-09-22 19:27:40 -0500 | [diff] [blame] | 313 | struct device *dev = musb->controller; |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 314 | struct omap2430_glue *glue = dev_get_drvdata(dev->parent); |
Hema Kalliguddi | ea65df5 | 2010-09-22 19:27:40 -0500 | [diff] [blame] | 315 | struct musb_hdrc_platform_data *plat = dev->platform_data; |
| 316 | struct omap_musb_board_data *data = plat->board_data; |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 317 | |
David Brownell | 84e250f | 2009-03-31 12:30:04 -0700 | [diff] [blame] | 318 | /* We require some kind of external transceiver, hooked |
| 319 | * up through ULPI. TWL4030-family PMICs include one, |
| 320 | * which needs a driver, drivers aren't always needed. |
| 321 | */ |
Kishon Vijay Abraham I | b1183c2 | 2012-06-22 17:40:54 +0530 | [diff] [blame] | 322 | musb->xceiv = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); |
Kishon Vijay Abraham I | ded017e | 2012-06-26 17:40:32 +0530 | [diff] [blame] | 323 | if (IS_ERR_OR_NULL(musb->xceiv)) { |
David Brownell | 84e250f | 2009-03-31 12:30:04 -0700 | [diff] [blame] | 324 | pr_err("HS USB OTG: no transceiver configured\n"); |
| 325 | return -ENODEV; |
| 326 | } |
| 327 | |
Hema HK | 7acc619 | 2011-02-28 14:19:34 +0530 | [diff] [blame] | 328 | status = pm_runtime_get_sync(dev); |
| 329 | if (status < 0) { |
Shubhrajyoti D | ad57969 | 2012-03-22 12:48:06 +0530 | [diff] [blame] | 330 | dev_err(dev, "pm_runtime_get_sync FAILED %d\n", status); |
Hema HK | 7acc619 | 2011-02-28 14:19:34 +0530 | [diff] [blame] | 331 | goto err1; |
| 332 | } |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 333 | |
Felipe Balbi | 8573e6a | 2010-01-21 15:33:53 +0200 | [diff] [blame] | 334 | l = musb_readl(musb->mregs, OTG_INTERFSEL); |
Maulik Mankad | de2e1b0 | 2010-03-12 10:29:07 +0200 | [diff] [blame] | 335 | |
| 336 | if (data->interface_type == MUSB_INTERFACE_UTMI) { |
| 337 | /* OMAP4 uses Internal PHY GS70 which uses UTMI interface */ |
| 338 | l &= ~ULPI_12PIN; /* Disable ULPI */ |
| 339 | l |= UTMI_8BIT; /* Enable UTMI */ |
| 340 | } else { |
| 341 | l |= ULPI_12PIN; |
| 342 | } |
| 343 | |
Felipe Balbi | 8573e6a | 2010-01-21 15:33:53 +0200 | [diff] [blame] | 344 | musb_writel(musb->mregs, OTG_INTERFSEL, l); |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 345 | |
| 346 | pr_debug("HS USB OTG: revision 0x%x, sysconfig 0x%02x, " |
| 347 | "sysstatus 0x%x, intrfsel 0x%x, simenable 0x%x\n", |
Felipe Balbi | 8573e6a | 2010-01-21 15:33:53 +0200 | [diff] [blame] | 348 | musb_readl(musb->mregs, OTG_REVISION), |
| 349 | musb_readl(musb->mregs, OTG_SYSCONFIG), |
| 350 | musb_readl(musb->mregs, OTG_SYSSTATUS), |
| 351 | musb_readl(musb->mregs, OTG_INTERFSEL), |
| 352 | musb_readl(musb->mregs, OTG_SIMENABLE)); |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 353 | |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 354 | setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb); |
| 355 | |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 356 | if (glue->status != OMAP_MUSB_UNKNOWN) |
| 357 | omap_musb_set_mailbox(glue); |
| 358 | |
Grazvydas Ignotas | c04352a | 2012-02-04 19:43:51 +0200 | [diff] [blame] | 359 | pm_runtime_put_noidle(musb->controller); |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 360 | return 0; |
Hema HK | 7acc619 | 2011-02-28 14:19:34 +0530 | [diff] [blame] | 361 | |
| 362 | err1: |
Hema HK | 7acc619 | 2011-02-28 14:19:34 +0530 | [diff] [blame] | 363 | return status; |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 364 | } |
| 365 | |
Hema HK | 002eda1 | 2011-02-17 12:06:10 +0530 | [diff] [blame] | 366 | static void omap2430_musb_enable(struct musb *musb) |
| 367 | { |
| 368 | u8 devctl; |
| 369 | unsigned long timeout = jiffies + msecs_to_jiffies(1000); |
| 370 | struct device *dev = musb->controller; |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 371 | struct omap2430_glue *glue = dev_get_drvdata(dev->parent); |
Hema HK | 002eda1 | 2011-02-17 12:06:10 +0530 | [diff] [blame] | 372 | struct musb_hdrc_platform_data *pdata = dev->platform_data; |
| 373 | struct omap_musb_board_data *data = pdata->board_data; |
| 374 | |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 375 | switch (glue->status) { |
Hema HK | 002eda1 | 2011-02-17 12:06:10 +0530 | [diff] [blame] | 376 | |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 377 | case OMAP_MUSB_ID_GROUND: |
Heikki Krogerus | b96d3b0 | 2012-02-13 13:24:18 +0200 | [diff] [blame] | 378 | usb_phy_init(musb->xceiv); |
Felipe Contreras | 08dec56 | 2011-12-19 22:17:50 +0200 | [diff] [blame] | 379 | if (data->interface_type != MUSB_INTERFACE_UTMI) |
| 380 | break; |
| 381 | devctl = musb_readb(musb->mregs, MUSB_DEVCTL); |
| 382 | /* start the session */ |
| 383 | devctl |= MUSB_DEVCTL_SESSION; |
| 384 | musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); |
| 385 | while (musb_readb(musb->mregs, MUSB_DEVCTL) & |
| 386 | MUSB_DEVCTL_BDEVICE) { |
| 387 | cpu_relax(); |
Hema HK | 002eda1 | 2011-02-17 12:06:10 +0530 | [diff] [blame] | 388 | |
Felipe Contreras | 08dec56 | 2011-12-19 22:17:50 +0200 | [diff] [blame] | 389 | if (time_after(jiffies, timeout)) { |
| 390 | dev_err(dev, "configured as A device timeout"); |
| 391 | break; |
Hema HK | 002eda1 | 2011-02-17 12:06:10 +0530 | [diff] [blame] | 392 | } |
| 393 | } |
| 394 | break; |
| 395 | |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 396 | case OMAP_MUSB_VBUS_VALID: |
Heikki Krogerus | b96d3b0 | 2012-02-13 13:24:18 +0200 | [diff] [blame] | 397 | usb_phy_init(musb->xceiv); |
Hema HK | 002eda1 | 2011-02-17 12:06:10 +0530 | [diff] [blame] | 398 | break; |
| 399 | |
| 400 | default: |
| 401 | break; |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | static void omap2430_musb_disable(struct musb *musb) |
| 406 | { |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 407 | struct device *dev = musb->controller; |
| 408 | struct omap2430_glue *glue = dev_get_drvdata(dev->parent); |
| 409 | |
| 410 | if (glue->status != OMAP_MUSB_UNKNOWN) |
Heikki Krogerus | b96d3b0 | 2012-02-13 13:24:18 +0200 | [diff] [blame] | 411 | usb_phy_shutdown(musb->xceiv); |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 412 | } |
| 413 | |
Felipe Balbi | 743411b | 2010-12-01 13:22:05 +0200 | [diff] [blame] | 414 | static int omap2430_musb_exit(struct musb *musb) |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 415 | { |
Johan Hovold | 19b9a83 | 2011-02-11 16:57:08 +0100 | [diff] [blame] | 416 | del_timer_sync(&musb_idle_timer); |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 417 | |
Felipe Balbi | c20aebb | 2010-12-02 12:44:40 +0200 | [diff] [blame] | 418 | omap2430_low_level_exit(musb); |
Felipe Balbi | c20aebb | 2010-12-02 12:44:40 +0200 | [diff] [blame] | 419 | |
Felipe Balbi | 550a737 | 2008-07-24 12:27:36 +0300 | [diff] [blame] | 420 | return 0; |
| 421 | } |
Felipe Balbi | 743411b | 2010-12-01 13:22:05 +0200 | [diff] [blame] | 422 | |
Felipe Balbi | f7ec943 | 2010-12-02 09:48:58 +0200 | [diff] [blame] | 423 | static const struct musb_platform_ops omap2430_ops = { |
Felipe Balbi | 743411b | 2010-12-01 13:22:05 +0200 | [diff] [blame] | 424 | .init = omap2430_musb_init, |
| 425 | .exit = omap2430_musb_exit, |
| 426 | |
Felipe Balbi | 743411b | 2010-12-01 13:22:05 +0200 | [diff] [blame] | 427 | .set_mode = omap2430_musb_set_mode, |
| 428 | .try_idle = omap2430_musb_try_idle, |
| 429 | |
| 430 | .set_vbus = omap2430_musb_set_vbus, |
Hema HK | 002eda1 | 2011-02-17 12:06:10 +0530 | [diff] [blame] | 431 | |
| 432 | .enable = omap2430_musb_enable, |
| 433 | .disable = omap2430_musb_disable, |
Felipe Balbi | 743411b | 2010-12-01 13:22:05 +0200 | [diff] [blame] | 434 | }; |
Felipe Balbi | dc09886 | 2010-12-01 15:01:11 +0200 | [diff] [blame] | 435 | |
| 436 | static u64 omap2430_dmamask = DMA_BIT_MASK(32); |
| 437 | |
Felipe Balbi | e9e8c85 | 2012-01-26 12:40:23 +0200 | [diff] [blame] | 438 | static int __devinit omap2430_probe(struct platform_device *pdev) |
Felipe Balbi | dc09886 | 2010-12-01 15:01:11 +0200 | [diff] [blame] | 439 | { |
| 440 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; |
| 441 | struct platform_device *musb; |
Felipe Balbi | a3cee12 | 2010-12-02 09:27:29 +0200 | [diff] [blame] | 442 | struct omap2430_glue *glue; |
Felipe Balbi | dc09886 | 2010-12-01 15:01:11 +0200 | [diff] [blame] | 443 | int ret = -ENOMEM; |
| 444 | |
Kishon Vijay Abraham I | b1183c2 | 2012-06-22 17:40:54 +0530 | [diff] [blame] | 445 | glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); |
Felipe Balbi | a3cee12 | 2010-12-02 09:27:29 +0200 | [diff] [blame] | 446 | if (!glue) { |
| 447 | dev_err(&pdev->dev, "failed to allocate glue context\n"); |
| 448 | goto err0; |
| 449 | } |
| 450 | |
Felipe Balbi | dc09886 | 2010-12-01 15:01:11 +0200 | [diff] [blame] | 451 | musb = platform_device_alloc("musb-hdrc", -1); |
| 452 | if (!musb) { |
| 453 | dev_err(&pdev->dev, "failed to allocate musb device\n"); |
Kishon Vijay Abraham I | b1183c2 | 2012-06-22 17:40:54 +0530 | [diff] [blame] | 454 | goto err0; |
Felipe Balbi | dc09886 | 2010-12-01 15:01:11 +0200 | [diff] [blame] | 455 | } |
| 456 | |
| 457 | musb->dev.parent = &pdev->dev; |
| 458 | musb->dev.dma_mask = &omap2430_dmamask; |
| 459 | musb->dev.coherent_dma_mask = omap2430_dmamask; |
| 460 | |
Felipe Balbi | a3cee12 | 2010-12-02 09:27:29 +0200 | [diff] [blame] | 461 | glue->dev = &pdev->dev; |
| 462 | glue->musb = musb; |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 463 | glue->status = OMAP_MUSB_UNKNOWN; |
Felipe Balbi | a3cee12 | 2010-12-02 09:27:29 +0200 | [diff] [blame] | 464 | |
Felipe Balbi | f7ec943 | 2010-12-02 09:48:58 +0200 | [diff] [blame] | 465 | pdata->platform_ops = &omap2430_ops; |
| 466 | |
Felipe Balbi | a3cee12 | 2010-12-02 09:27:29 +0200 | [diff] [blame] | 467 | platform_set_drvdata(pdev, glue); |
Felipe Balbi | dc09886 | 2010-12-01 15:01:11 +0200 | [diff] [blame] | 468 | |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 469 | /* |
| 470 | * REVISIT if we ever have two instances of the wrapper, we will be |
| 471 | * in big trouble |
| 472 | */ |
| 473 | _glue = glue; |
| 474 | |
Kishon Vijay Abraham I | 1e5acb8 | 2012-06-22 17:40:51 +0530 | [diff] [blame] | 475 | INIT_WORK(&glue->omap_musb_mailbox_work, omap_musb_mailbox_work); |
| 476 | |
Felipe Balbi | dc09886 | 2010-12-01 15:01:11 +0200 | [diff] [blame] | 477 | ret = platform_device_add_resources(musb, pdev->resource, |
| 478 | pdev->num_resources); |
| 479 | if (ret) { |
| 480 | dev_err(&pdev->dev, "failed to add resources\n"); |
Kishon Vijay Abraham I | b1183c2 | 2012-06-22 17:40:54 +0530 | [diff] [blame] | 481 | goto err1; |
Felipe Balbi | dc09886 | 2010-12-01 15:01:11 +0200 | [diff] [blame] | 482 | } |
| 483 | |
| 484 | ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); |
| 485 | if (ret) { |
| 486 | dev_err(&pdev->dev, "failed to add platform_data\n"); |
Kishon Vijay Abraham I | b1183c2 | 2012-06-22 17:40:54 +0530 | [diff] [blame] | 487 | goto err1; |
Felipe Balbi | dc09886 | 2010-12-01 15:01:11 +0200 | [diff] [blame] | 488 | } |
| 489 | |
Kishon Vijay Abraham I | 3006dc8 | 2012-03-21 21:30:20 +0530 | [diff] [blame] | 490 | pm_runtime_enable(&pdev->dev); |
| 491 | |
Felipe Balbi | dc09886 | 2010-12-01 15:01:11 +0200 | [diff] [blame] | 492 | ret = platform_device_add(musb); |
| 493 | if (ret) { |
| 494 | dev_err(&pdev->dev, "failed to register musb device\n"); |
Kishon Vijay Abraham I | b1183c2 | 2012-06-22 17:40:54 +0530 | [diff] [blame] | 495 | goto err1; |
Felipe Balbi | dc09886 | 2010-12-01 15:01:11 +0200 | [diff] [blame] | 496 | } |
| 497 | |
| 498 | return 0; |
| 499 | |
Felipe Balbi | a3cee12 | 2010-12-02 09:27:29 +0200 | [diff] [blame] | 500 | err1: |
Kishon Vijay Abraham I | b1183c2 | 2012-06-22 17:40:54 +0530 | [diff] [blame] | 501 | platform_device_put(musb); |
Felipe Balbi | a3cee12 | 2010-12-02 09:27:29 +0200 | [diff] [blame] | 502 | |
Felipe Balbi | dc09886 | 2010-12-01 15:01:11 +0200 | [diff] [blame] | 503 | err0: |
| 504 | return ret; |
| 505 | } |
| 506 | |
Felipe Balbi | e9e8c85 | 2012-01-26 12:40:23 +0200 | [diff] [blame] | 507 | static int __devexit omap2430_remove(struct platform_device *pdev) |
Felipe Balbi | dc09886 | 2010-12-01 15:01:11 +0200 | [diff] [blame] | 508 | { |
Felipe Balbi | a3cee12 | 2010-12-02 09:27:29 +0200 | [diff] [blame] | 509 | struct omap2430_glue *glue = platform_get_drvdata(pdev); |
Felipe Balbi | dc09886 | 2010-12-01 15:01:11 +0200 | [diff] [blame] | 510 | |
Kishon Vijay Abraham I | 1e5acb8 | 2012-06-22 17:40:51 +0530 | [diff] [blame] | 511 | cancel_work_sync(&glue->omap_musb_mailbox_work); |
Kishon Vijay Abraham I | f039df5 | 2012-08-02 15:30:07 +0530 | [diff] [blame^] | 512 | platform_device_unregister(glue->musb); |
Felipe Balbi | dc09886 | 2010-12-01 15:01:11 +0200 | [diff] [blame] | 513 | |
| 514 | return 0; |
| 515 | } |
| 516 | |
Felipe Balbi | c20aebb | 2010-12-02 12:44:40 +0200 | [diff] [blame] | 517 | #ifdef CONFIG_PM |
Felipe Balbi | c20aebb | 2010-12-02 12:44:40 +0200 | [diff] [blame] | 518 | |
Hema HK | 7acc619 | 2011-02-28 14:19:34 +0530 | [diff] [blame] | 519 | static int omap2430_runtime_suspend(struct device *dev) |
Felipe Balbi | c20aebb | 2010-12-02 12:44:40 +0200 | [diff] [blame] | 520 | { |
| 521 | struct omap2430_glue *glue = dev_get_drvdata(dev); |
| 522 | struct musb *musb = glue_to_musb(glue); |
| 523 | |
Vladimir Zapolskiy | afb76df | 2011-12-23 18:37:18 +0200 | [diff] [blame] | 524 | if (musb) { |
| 525 | musb->context.otg_interfsel = musb_readl(musb->mregs, |
| 526 | OTG_INTERFSEL); |
Hema HK | e25bec1 | 2011-09-07 09:19:24 -0700 | [diff] [blame] | 527 | |
Vladimir Zapolskiy | afb76df | 2011-12-23 18:37:18 +0200 | [diff] [blame] | 528 | omap2430_low_level_exit(musb); |
| 529 | usb_phy_set_suspend(musb->xceiv, 1); |
| 530 | } |
Felipe Balbi | c20aebb | 2010-12-02 12:44:40 +0200 | [diff] [blame] | 531 | |
| 532 | return 0; |
| 533 | } |
| 534 | |
Hema HK | 7acc619 | 2011-02-28 14:19:34 +0530 | [diff] [blame] | 535 | static int omap2430_runtime_resume(struct device *dev) |
Felipe Balbi | c20aebb | 2010-12-02 12:44:40 +0200 | [diff] [blame] | 536 | { |
| 537 | struct omap2430_glue *glue = dev_get_drvdata(dev); |
| 538 | struct musb *musb = glue_to_musb(glue); |
Felipe Balbi | c20aebb | 2010-12-02 12:44:40 +0200 | [diff] [blame] | 539 | |
Vladimir Zapolskiy | afb76df | 2011-12-23 18:37:18 +0200 | [diff] [blame] | 540 | if (musb) { |
| 541 | omap2430_low_level_init(musb); |
| 542 | musb_writel(musb->mregs, OTG_INTERFSEL, |
| 543 | musb->context.otg_interfsel); |
Hema HK | e25bec1 | 2011-09-07 09:19:24 -0700 | [diff] [blame] | 544 | |
Vladimir Zapolskiy | afb76df | 2011-12-23 18:37:18 +0200 | [diff] [blame] | 545 | usb_phy_set_suspend(musb->xceiv, 0); |
| 546 | } |
Felipe Balbi | c20aebb | 2010-12-02 12:44:40 +0200 | [diff] [blame] | 547 | |
| 548 | return 0; |
| 549 | } |
| 550 | |
| 551 | static struct dev_pm_ops omap2430_pm_ops = { |
Hema HK | 7acc619 | 2011-02-28 14:19:34 +0530 | [diff] [blame] | 552 | .runtime_suspend = omap2430_runtime_suspend, |
| 553 | .runtime_resume = omap2430_runtime_resume, |
Felipe Balbi | c20aebb | 2010-12-02 12:44:40 +0200 | [diff] [blame] | 554 | }; |
| 555 | |
| 556 | #define DEV_PM_OPS (&omap2430_pm_ops) |
| 557 | #else |
| 558 | #define DEV_PM_OPS NULL |
| 559 | #endif |
| 560 | |
Felipe Balbi | dc09886 | 2010-12-01 15:01:11 +0200 | [diff] [blame] | 561 | static struct platform_driver omap2430_driver = { |
Felipe Balbi | e9e8c85 | 2012-01-26 12:40:23 +0200 | [diff] [blame] | 562 | .probe = omap2430_probe, |
| 563 | .remove = __devexit_p(omap2430_remove), |
Felipe Balbi | dc09886 | 2010-12-01 15:01:11 +0200 | [diff] [blame] | 564 | .driver = { |
| 565 | .name = "musb-omap2430", |
Felipe Balbi | c20aebb | 2010-12-02 12:44:40 +0200 | [diff] [blame] | 566 | .pm = DEV_PM_OPS, |
Felipe Balbi | dc09886 | 2010-12-01 15:01:11 +0200 | [diff] [blame] | 567 | }, |
| 568 | }; |
| 569 | |
| 570 | MODULE_DESCRIPTION("OMAP2PLUS MUSB Glue Layer"); |
| 571 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); |
| 572 | MODULE_LICENSE("GPL v2"); |
| 573 | |
| 574 | static int __init omap2430_init(void) |
| 575 | { |
Felipe Balbi | e9e8c85 | 2012-01-26 12:40:23 +0200 | [diff] [blame] | 576 | return platform_driver_register(&omap2430_driver); |
Felipe Balbi | dc09886 | 2010-12-01 15:01:11 +0200 | [diff] [blame] | 577 | } |
Kishon Vijay Abraham I | c972143 | 2012-06-22 17:40:52 +0530 | [diff] [blame] | 578 | subsys_initcall(omap2430_init); |
Felipe Balbi | dc09886 | 2010-12-01 15:01:11 +0200 | [diff] [blame] | 579 | |
| 580 | static void __exit omap2430_exit(void) |
| 581 | { |
| 582 | platform_driver_unregister(&omap2430_driver); |
| 583 | } |
| 584 | module_exit(omap2430_exit); |