Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 1 | /* |
| 2 | * drivers/usb/otg/ab8500_usb.c |
| 3 | * |
| 4 | * USB transceiver driver for AB8500 chip |
| 5 | * |
| 6 | * Copyright (C) 2010 ST-Ericsson AB |
| 7 | * Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #include <linux/module.h> |
| 26 | #include <linux/platform_device.h> |
| 27 | #include <linux/usb/otg.h> |
| 28 | #include <linux/slab.h> |
| 29 | #include <linux/notifier.h> |
| 30 | #include <linux/interrupt.h> |
| 31 | #include <linux/delay.h> |
| 32 | #include <linux/mfd/abx500.h> |
Linus Walleij | ee66e65 | 2011-12-02 14:16:33 +0100 | [diff] [blame] | 33 | #include <linux/mfd/abx500/ab8500.h> |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 34 | #include <linux/usb/musb-ux500.h> |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 35 | |
| 36 | #define AB8500_MAIN_WD_CTRL_REG 0x01 |
| 37 | #define AB8500_USB_LINE_STAT_REG 0x80 |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 38 | #define AB8505_USB_LINE_STAT_REG 0x94 |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 39 | #define AB8500_USB_PHY_CTRL_REG 0x8A |
| 40 | |
| 41 | #define AB8500_BIT_OTG_STAT_ID (1 << 0) |
| 42 | #define AB8500_BIT_PHY_CTRL_HOST_EN (1 << 0) |
| 43 | #define AB8500_BIT_PHY_CTRL_DEVICE_EN (1 << 1) |
| 44 | #define AB8500_BIT_WD_CTRL_ENABLE (1 << 0) |
| 45 | #define AB8500_BIT_WD_CTRL_KICK (1 << 1) |
| 46 | |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 47 | #define AB8500_WD_KICK_DELAY_US 100 /* usec */ |
| 48 | #define AB8500_WD_V11_DISABLE_DELAY_US 100 /* usec */ |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 49 | #define AB8500_V20_31952_DISABLE_DELAY_US 100 /* usec */ |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 50 | |
| 51 | /* Usb line status register */ |
| 52 | enum ab8500_usb_link_status { |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 53 | USB_LINK_NOT_CONFIGURED_8500 = 0, |
| 54 | USB_LINK_STD_HOST_NC_8500, |
| 55 | USB_LINK_STD_HOST_C_NS_8500, |
| 56 | USB_LINK_STD_HOST_C_S_8500, |
| 57 | USB_LINK_HOST_CHG_NM_8500, |
| 58 | USB_LINK_HOST_CHG_HS_8500, |
| 59 | USB_LINK_HOST_CHG_HS_CHIRP_8500, |
| 60 | USB_LINK_DEDICATED_CHG_8500, |
| 61 | USB_LINK_ACA_RID_A_8500, |
| 62 | USB_LINK_ACA_RID_B_8500, |
| 63 | USB_LINK_ACA_RID_C_NM_8500, |
| 64 | USB_LINK_ACA_RID_C_HS_8500, |
| 65 | USB_LINK_ACA_RID_C_HS_CHIRP_8500, |
| 66 | USB_LINK_HM_IDGND_8500, |
| 67 | USB_LINK_RESERVED_8500, |
| 68 | USB_LINK_NOT_VALID_LINK_8500, |
| 69 | }; |
| 70 | |
| 71 | enum ab8505_usb_link_status { |
| 72 | USB_LINK_NOT_CONFIGURED_8505 = 0, |
| 73 | USB_LINK_STD_HOST_NC_8505, |
| 74 | USB_LINK_STD_HOST_C_NS_8505, |
| 75 | USB_LINK_STD_HOST_C_S_8505, |
| 76 | USB_LINK_CDP_8505, |
| 77 | USB_LINK_RESERVED0_8505, |
| 78 | USB_LINK_RESERVED1_8505, |
| 79 | USB_LINK_DEDICATED_CHG_8505, |
| 80 | USB_LINK_ACA_RID_A_8505, |
| 81 | USB_LINK_ACA_RID_B_8505, |
| 82 | USB_LINK_ACA_RID_C_NM_8505, |
| 83 | USB_LINK_RESERVED2_8505, |
| 84 | USB_LINK_RESERVED3_8505, |
| 85 | USB_LINK_HM_IDGND_8505, |
| 86 | USB_LINK_CHARGERPORT_NOT_OK_8505, |
| 87 | USB_LINK_CHARGER_DM_HIGH_8505, |
| 88 | USB_LINK_PHYEN_NO_VBUS_NO_IDGND_8505, |
| 89 | USB_LINK_STD_UPSTREAM_NO_IDGNG_NO_VBUS_8505, |
| 90 | USB_LINK_STD_UPSTREAM_8505, |
| 91 | USB_LINK_CHARGER_SE1_8505, |
| 92 | USB_LINK_CARKIT_CHGR_1_8505, |
| 93 | USB_LINK_CARKIT_CHGR_2_8505, |
| 94 | USB_LINK_ACA_DOCK_CHGR_8505, |
| 95 | USB_LINK_SAMSUNG_BOOT_CBL_PHY_EN_8505, |
| 96 | USB_LINK_SAMSUNG_BOOT_CBL_PHY_DISB_8505, |
| 97 | USB_LINK_SAMSUNG_UART_CBL_PHY_EN_8505, |
| 98 | USB_LINK_SAMSUNG_UART_CBL_PHY_DISB_8505, |
| 99 | USB_LINK_MOTOROLA_FACTORY_CBL_PHY_EN_8505, |
| 100 | }; |
| 101 | |
| 102 | enum ab8500_usb_mode { |
| 103 | USB_IDLE = 0, |
| 104 | USB_PERIPHERAL, |
| 105 | USB_HOST, |
| 106 | USB_DEDICATED_CHG |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 107 | }; |
| 108 | |
| 109 | struct ab8500_usb { |
Heikki Krogerus | 144713f | 2012-02-13 13:24:05 +0200 | [diff] [blame] | 110 | struct usb_phy phy; |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 111 | struct device *dev; |
Fabio Baltieri | 73f226c | 2013-03-08 10:27:08 +0800 | [diff] [blame] | 112 | struct ab8500 *ab8500; |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 113 | unsigned vbus_draw; |
| 114 | struct delayed_work dwork; |
| 115 | struct work_struct phy_dis_work; |
| 116 | unsigned long link_status_wait; |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 117 | enum ab8500_usb_mode mode; |
| 118 | int previous_link_status_state; |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 119 | }; |
| 120 | |
Heikki Krogerus | 144713f | 2012-02-13 13:24:05 +0200 | [diff] [blame] | 121 | static inline struct ab8500_usb *phy_to_ab(struct usb_phy *x) |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 122 | { |
Heikki Krogerus | 144713f | 2012-02-13 13:24:05 +0200 | [diff] [blame] | 123 | return container_of(x, struct ab8500_usb, phy); |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | static void ab8500_usb_wd_workaround(struct ab8500_usb *ab) |
| 127 | { |
| 128 | abx500_set_register_interruptible(ab->dev, |
| 129 | AB8500_SYS_CTRL2_BLOCK, |
| 130 | AB8500_MAIN_WD_CTRL_REG, |
| 131 | AB8500_BIT_WD_CTRL_ENABLE); |
| 132 | |
| 133 | udelay(AB8500_WD_KICK_DELAY_US); |
| 134 | |
| 135 | abx500_set_register_interruptible(ab->dev, |
| 136 | AB8500_SYS_CTRL2_BLOCK, |
| 137 | AB8500_MAIN_WD_CTRL_REG, |
| 138 | (AB8500_BIT_WD_CTRL_ENABLE |
| 139 | | AB8500_BIT_WD_CTRL_KICK)); |
| 140 | |
Fabio Baltieri | 73f226c | 2013-03-08 10:27:08 +0800 | [diff] [blame] | 141 | udelay(AB8500_WD_V11_DISABLE_DELAY_US); |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 142 | |
| 143 | abx500_set_register_interruptible(ab->dev, |
| 144 | AB8500_SYS_CTRL2_BLOCK, |
| 145 | AB8500_MAIN_WD_CTRL_REG, |
| 146 | 0); |
| 147 | } |
| 148 | |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 149 | static void ab8500_usb_wd_linkstatus(struct ab8500_usb *ab, u8 bit) |
| 150 | { |
| 151 | /* Workaround for v2.0 bug # 31952 */ |
| 152 | if (is_ab8500_2p0(ab->ab8500)) { |
| 153 | abx500_mask_and_set_register_interruptible(ab->dev, |
| 154 | AB8500_USB, AB8500_USB_PHY_CTRL_REG, |
| 155 | bit, bit); |
| 156 | udelay(AB8500_V20_31952_DISABLE_DELAY_US); |
| 157 | } |
| 158 | } |
| 159 | |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 160 | static void ab8500_usb_phy_ctrl(struct ab8500_usb *ab, bool sel_host, |
| 161 | bool enable) |
| 162 | { |
| 163 | u8 ctrl_reg; |
| 164 | abx500_get_register_interruptible(ab->dev, |
| 165 | AB8500_USB, |
| 166 | AB8500_USB_PHY_CTRL_REG, |
| 167 | &ctrl_reg); |
| 168 | if (sel_host) { |
| 169 | if (enable) |
| 170 | ctrl_reg |= AB8500_BIT_PHY_CTRL_HOST_EN; |
| 171 | else |
| 172 | ctrl_reg &= ~AB8500_BIT_PHY_CTRL_HOST_EN; |
| 173 | } else { |
| 174 | if (enable) |
| 175 | ctrl_reg |= AB8500_BIT_PHY_CTRL_DEVICE_EN; |
| 176 | else |
| 177 | ctrl_reg &= ~AB8500_BIT_PHY_CTRL_DEVICE_EN; |
| 178 | } |
| 179 | |
| 180 | abx500_set_register_interruptible(ab->dev, |
| 181 | AB8500_USB, |
| 182 | AB8500_USB_PHY_CTRL_REG, |
| 183 | ctrl_reg); |
| 184 | |
| 185 | /* Needed to enable the phy.*/ |
| 186 | if (enable) |
| 187 | ab8500_usb_wd_workaround(ab); |
| 188 | } |
| 189 | |
| 190 | #define ab8500_usb_host_phy_en(ab) ab8500_usb_phy_ctrl(ab, true, true) |
| 191 | #define ab8500_usb_host_phy_dis(ab) ab8500_usb_phy_ctrl(ab, true, false) |
| 192 | #define ab8500_usb_peri_phy_en(ab) ab8500_usb_phy_ctrl(ab, false, true) |
| 193 | #define ab8500_usb_peri_phy_dis(ab) ab8500_usb_phy_ctrl(ab, false, false) |
| 194 | |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 195 | static int ab8505_usb_link_status_update(struct ab8500_usb *ab, |
| 196 | enum ab8505_usb_link_status lsts) |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 197 | { |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 198 | enum ux500_musb_vbus_id_status event = 0; |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 199 | |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 200 | dev_dbg(ab->dev, "ab8505_usb_link_status_update %d\n", lsts); |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 201 | |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 202 | /* |
| 203 | * Spurious link_status interrupts are seen at the time of |
| 204 | * disconnection of a device in RIDA state |
| 205 | */ |
| 206 | if (ab->previous_link_status_state == USB_LINK_ACA_RID_A_8505 && |
| 207 | (lsts == USB_LINK_STD_HOST_NC_8505)) |
| 208 | return 0; |
| 209 | |
| 210 | ab->previous_link_status_state = lsts; |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 211 | |
| 212 | switch (lsts) { |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 213 | case USB_LINK_ACA_RID_B_8505: |
| 214 | event = UX500_MUSB_RIDB; |
| 215 | case USB_LINK_NOT_CONFIGURED_8505: |
| 216 | case USB_LINK_RESERVED0_8505: |
| 217 | case USB_LINK_RESERVED1_8505: |
| 218 | case USB_LINK_RESERVED2_8505: |
| 219 | case USB_LINK_RESERVED3_8505: |
| 220 | ab->mode = USB_IDLE; |
Heikki Krogerus | 144713f | 2012-02-13 13:24:05 +0200 | [diff] [blame] | 221 | ab->phy.otg->default_a = false; |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 222 | ab->vbus_draw = 0; |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 223 | if (event != UX500_MUSB_RIDB) |
| 224 | event = UX500_MUSB_NONE; |
| 225 | /* |
| 226 | * Fallback to default B_IDLE as nothing |
| 227 | * is connected |
| 228 | */ |
| 229 | ab->phy.state = OTG_STATE_B_IDLE; |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 230 | break; |
| 231 | |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 232 | case USB_LINK_ACA_RID_C_NM_8505: |
| 233 | event = UX500_MUSB_RIDC; |
| 234 | case USB_LINK_STD_HOST_NC_8505: |
| 235 | case USB_LINK_STD_HOST_C_NS_8505: |
| 236 | case USB_LINK_STD_HOST_C_S_8505: |
| 237 | case USB_LINK_CDP_8505: |
| 238 | if (ab->mode == USB_IDLE) { |
| 239 | ab->mode = USB_PERIPHERAL; |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 240 | ab8500_usb_peri_phy_en(ab); |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 241 | atomic_notifier_call_chain(&ab->phy.notifier, |
| 242 | UX500_MUSB_PREPARE, &ab->vbus_draw); |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 243 | } |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 244 | if (event != UX500_MUSB_RIDC) |
| 245 | event = UX500_MUSB_VBUS; |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 246 | break; |
| 247 | |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 248 | case USB_LINK_ACA_RID_A_8505: |
| 249 | case USB_LINK_ACA_DOCK_CHGR_8505: |
| 250 | event = UX500_MUSB_RIDA; |
| 251 | case USB_LINK_HM_IDGND_8505: |
| 252 | if (ab->mode == USB_IDLE) { |
| 253 | ab->mode = USB_HOST; |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 254 | ab8500_usb_host_phy_en(ab); |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 255 | atomic_notifier_call_chain(&ab->phy.notifier, |
| 256 | UX500_MUSB_PREPARE, &ab->vbus_draw); |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 257 | } |
Heikki Krogerus | 144713f | 2012-02-13 13:24:05 +0200 | [diff] [blame] | 258 | ab->phy.otg->default_a = true; |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 259 | if (event != UX500_MUSB_RIDA) |
| 260 | event = UX500_MUSB_ID; |
| 261 | atomic_notifier_call_chain(&ab->phy.notifier, |
| 262 | event, &ab->vbus_draw); |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 263 | break; |
| 264 | |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 265 | case USB_LINK_DEDICATED_CHG_8505: |
| 266 | ab->mode = USB_DEDICATED_CHG; |
| 267 | event = UX500_MUSB_CHARGER; |
| 268 | atomic_notifier_call_chain(&ab->phy.notifier, |
| 269 | event, &ab->vbus_draw); |
| 270 | break; |
| 271 | |
| 272 | default: |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 273 | break; |
| 274 | } |
| 275 | |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 276 | return 0; |
| 277 | } |
| 278 | |
| 279 | static int ab8500_usb_link_status_update(struct ab8500_usb *ab, |
| 280 | enum ab8500_usb_link_status lsts) |
| 281 | { |
| 282 | enum ux500_musb_vbus_id_status event = 0; |
| 283 | |
| 284 | dev_dbg(ab->dev, "ab8500_usb_link_status_update %d\n", lsts); |
| 285 | |
| 286 | /* |
| 287 | * Spurious link_status interrupts are seen in case of a |
| 288 | * disconnection of a device in IDGND and RIDA stage |
| 289 | */ |
| 290 | if (ab->previous_link_status_state == USB_LINK_HM_IDGND_8500 && |
| 291 | (lsts == USB_LINK_STD_HOST_C_NS_8500 || |
| 292 | lsts == USB_LINK_STD_HOST_NC_8500)) |
| 293 | return 0; |
| 294 | |
| 295 | if (ab->previous_link_status_state == USB_LINK_ACA_RID_A_8500 && |
| 296 | lsts == USB_LINK_STD_HOST_NC_8500) |
| 297 | return 0; |
| 298 | |
| 299 | ab->previous_link_status_state = lsts; |
| 300 | |
| 301 | switch (lsts) { |
| 302 | case USB_LINK_ACA_RID_B_8500: |
| 303 | event = UX500_MUSB_RIDB; |
| 304 | case USB_LINK_NOT_CONFIGURED_8500: |
| 305 | case USB_LINK_NOT_VALID_LINK_8500: |
| 306 | ab->mode = USB_IDLE; |
| 307 | ab->phy.otg->default_a = false; |
| 308 | ab->vbus_draw = 0; |
| 309 | if (event != UX500_MUSB_RIDB) |
| 310 | event = UX500_MUSB_NONE; |
| 311 | /* Fallback to default B_IDLE as nothing is connected */ |
| 312 | ab->phy.state = OTG_STATE_B_IDLE; |
| 313 | break; |
| 314 | |
| 315 | case USB_LINK_ACA_RID_C_NM_8500: |
| 316 | case USB_LINK_ACA_RID_C_HS_8500: |
| 317 | case USB_LINK_ACA_RID_C_HS_CHIRP_8500: |
| 318 | event = UX500_MUSB_RIDC; |
| 319 | case USB_LINK_STD_HOST_NC_8500: |
| 320 | case USB_LINK_STD_HOST_C_NS_8500: |
| 321 | case USB_LINK_STD_HOST_C_S_8500: |
| 322 | case USB_LINK_HOST_CHG_NM_8500: |
| 323 | case USB_LINK_HOST_CHG_HS_8500: |
| 324 | case USB_LINK_HOST_CHG_HS_CHIRP_8500: |
| 325 | if (ab->mode == USB_IDLE) { |
| 326 | ab->mode = USB_PERIPHERAL; |
| 327 | ab8500_usb_peri_phy_en(ab); |
| 328 | atomic_notifier_call_chain(&ab->phy.notifier, |
| 329 | UX500_MUSB_PREPARE, &ab->vbus_draw); |
| 330 | } |
| 331 | if (event != UX500_MUSB_RIDC) |
| 332 | event = UX500_MUSB_VBUS; |
| 333 | break; |
| 334 | |
| 335 | case USB_LINK_ACA_RID_A_8500: |
| 336 | event = UX500_MUSB_RIDA; |
| 337 | case USB_LINK_HM_IDGND_8500: |
| 338 | if (ab->mode == USB_IDLE) { |
| 339 | ab->mode = USB_HOST; |
| 340 | ab8500_usb_host_phy_en(ab); |
| 341 | atomic_notifier_call_chain(&ab->phy.notifier, |
| 342 | UX500_MUSB_PREPARE, &ab->vbus_draw); |
| 343 | } |
| 344 | ab->phy.otg->default_a = true; |
| 345 | if (event != UX500_MUSB_RIDA) |
| 346 | event = UX500_MUSB_ID; |
| 347 | atomic_notifier_call_chain(&ab->phy.notifier, |
| 348 | event, &ab->vbus_draw); |
| 349 | break; |
| 350 | |
| 351 | case USB_LINK_DEDICATED_CHG_8500: |
| 352 | ab->mode = USB_DEDICATED_CHG; |
| 353 | event = UX500_MUSB_CHARGER; |
| 354 | atomic_notifier_call_chain(&ab->phy.notifier, |
| 355 | event, &ab->vbus_draw); |
| 356 | break; |
| 357 | |
| 358 | case USB_LINK_RESERVED_8500: |
| 359 | break; |
| 360 | } |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 361 | |
| 362 | return 0; |
| 363 | } |
| 364 | |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 365 | /* |
| 366 | * Connection Sequence: |
| 367 | * 1. Link Status Interrupt |
| 368 | * 2. Enable AB clock |
| 369 | * 3. Enable AB regulators |
| 370 | * 4. Enable USB phy |
| 371 | * 5. Reset the musb controller |
| 372 | * 6. Switch the ULPI GPIO pins to fucntion mode |
| 373 | * 7. Enable the musb Peripheral5 clock |
| 374 | * 8. Restore MUSB context |
| 375 | */ |
| 376 | static int abx500_usb_link_status_update(struct ab8500_usb *ab) |
| 377 | { |
| 378 | u8 reg; |
| 379 | int ret = 0; |
| 380 | |
| 381 | if (is_ab8500(ab->ab8500)) { |
| 382 | enum ab8500_usb_link_status lsts; |
| 383 | |
| 384 | abx500_get_register_interruptible(ab->dev, |
| 385 | AB8500_USB, AB8500_USB_LINE_STAT_REG, ®); |
| 386 | lsts = (reg >> 3) & 0x0F; |
| 387 | ret = ab8500_usb_link_status_update(ab, lsts); |
| 388 | } else if (is_ab8505(ab->ab8500)) { |
| 389 | enum ab8505_usb_link_status lsts; |
| 390 | |
| 391 | abx500_get_register_interruptible(ab->dev, |
| 392 | AB8500_USB, AB8505_USB_LINE_STAT_REG, ®); |
| 393 | lsts = (reg >> 3) & 0x1F; |
| 394 | ret = ab8505_usb_link_status_update(ab, lsts); |
| 395 | } |
| 396 | |
| 397 | return ret; |
| 398 | } |
| 399 | |
| 400 | /* |
| 401 | * Disconnection Sequence: |
| 402 | * 1. Disconect Interrupt |
| 403 | * 2. Disable regulators |
| 404 | * 3. Disable AB clock |
| 405 | * 4. Disable the Phy |
| 406 | * 5. Link Status Interrupt |
| 407 | * 6. Disable Musb Clock |
| 408 | */ |
| 409 | static irqreturn_t ab8500_usb_disconnect_irq(int irq, void *data) |
| 410 | { |
| 411 | struct ab8500_usb *ab = (struct ab8500_usb *) data; |
| 412 | enum usb_phy_events event = UX500_MUSB_NONE; |
| 413 | |
| 414 | /* Link status will not be updated till phy is disabled. */ |
| 415 | if (ab->mode == USB_HOST) { |
| 416 | ab->phy.otg->default_a = false; |
| 417 | ab->vbus_draw = 0; |
| 418 | atomic_notifier_call_chain(&ab->phy.notifier, |
| 419 | event, &ab->vbus_draw); |
| 420 | ab8500_usb_host_phy_dis(ab); |
| 421 | ab->mode = USB_IDLE; |
| 422 | } |
| 423 | |
| 424 | if (ab->mode == USB_PERIPHERAL) { |
| 425 | atomic_notifier_call_chain(&ab->phy.notifier, |
| 426 | event, &ab->vbus_draw); |
| 427 | ab8500_usb_peri_phy_dis(ab); |
| 428 | atomic_notifier_call_chain(&ab->phy.notifier, |
| 429 | UX500_MUSB_CLEAN, &ab->vbus_draw); |
| 430 | ab->mode = USB_IDLE; |
| 431 | ab->phy.otg->default_a = false; |
| 432 | ab->vbus_draw = 0; |
| 433 | } |
| 434 | |
| 435 | if (is_ab8500_2p0(ab->ab8500)) { |
| 436 | if (ab->mode == USB_DEDICATED_CHG) { |
| 437 | ab8500_usb_wd_linkstatus(ab, |
| 438 | AB8500_BIT_PHY_CTRL_DEVICE_EN); |
| 439 | abx500_mask_and_set_register_interruptible(ab->dev, |
| 440 | AB8500_USB, AB8500_USB_PHY_CTRL_REG, |
| 441 | AB8500_BIT_PHY_CTRL_DEVICE_EN, 0); |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | return IRQ_HANDLED; |
| 446 | } |
| 447 | |
| 448 | static irqreturn_t ab8500_usb_link_status_irq(int irq, void *data) |
| 449 | { |
| 450 | struct ab8500_usb *ab = (struct ab8500_usb *) data; |
| 451 | |
| 452 | abx500_usb_link_status_update(ab); |
| 453 | |
| 454 | return IRQ_HANDLED; |
| 455 | } |
| 456 | |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 457 | static void ab8500_usb_delayed_work(struct work_struct *work) |
| 458 | { |
| 459 | struct ab8500_usb *ab = container_of(work, struct ab8500_usb, |
| 460 | dwork.work); |
| 461 | |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 462 | abx500_usb_link_status_update(ab); |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 463 | } |
| 464 | |
| 465 | static void ab8500_usb_phy_disable_work(struct work_struct *work) |
| 466 | { |
| 467 | struct ab8500_usb *ab = container_of(work, struct ab8500_usb, |
| 468 | phy_dis_work); |
| 469 | |
Heikki Krogerus | 144713f | 2012-02-13 13:24:05 +0200 | [diff] [blame] | 470 | if (!ab->phy.otg->host) |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 471 | ab8500_usb_host_phy_dis(ab); |
| 472 | |
Heikki Krogerus | 144713f | 2012-02-13 13:24:05 +0200 | [diff] [blame] | 473 | if (!ab->phy.otg->gadget) |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 474 | ab8500_usb_peri_phy_dis(ab); |
| 475 | } |
| 476 | |
Heikki Krogerus | 144713f | 2012-02-13 13:24:05 +0200 | [diff] [blame] | 477 | static int ab8500_usb_set_power(struct usb_phy *phy, unsigned mA) |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 478 | { |
| 479 | struct ab8500_usb *ab; |
| 480 | |
Heikki Krogerus | 144713f | 2012-02-13 13:24:05 +0200 | [diff] [blame] | 481 | if (!phy) |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 482 | return -ENODEV; |
| 483 | |
Heikki Krogerus | 144713f | 2012-02-13 13:24:05 +0200 | [diff] [blame] | 484 | ab = phy_to_ab(phy); |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 485 | |
| 486 | ab->vbus_draw = mA; |
| 487 | |
| 488 | if (mA) |
Heikki Krogerus | 144713f | 2012-02-13 13:24:05 +0200 | [diff] [blame] | 489 | atomic_notifier_call_chain(&ab->phy.notifier, |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 490 | UX500_MUSB_ENUMERATED, ab->phy.otg->gadget); |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 491 | return 0; |
| 492 | } |
| 493 | |
| 494 | /* TODO: Implement some way for charging or other drivers to read |
| 495 | * ab->vbus_draw. |
| 496 | */ |
| 497 | |
Heikki Krogerus | 8675381 | 2012-02-13 13:24:02 +0200 | [diff] [blame] | 498 | static int ab8500_usb_set_suspend(struct usb_phy *x, int suspend) |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 499 | { |
| 500 | /* TODO */ |
| 501 | return 0; |
| 502 | } |
| 503 | |
Heikki Krogerus | 144713f | 2012-02-13 13:24:05 +0200 | [diff] [blame] | 504 | static int ab8500_usb_set_peripheral(struct usb_otg *otg, |
| 505 | struct usb_gadget *gadget) |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 506 | { |
| 507 | struct ab8500_usb *ab; |
| 508 | |
| 509 | if (!otg) |
| 510 | return -ENODEV; |
| 511 | |
Heikki Krogerus | 144713f | 2012-02-13 13:24:05 +0200 | [diff] [blame] | 512 | ab = phy_to_ab(otg->phy); |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 513 | |
| 514 | /* Some drivers call this function in atomic context. |
| 515 | * Do not update ab8500 registers directly till this |
| 516 | * is fixed. |
| 517 | */ |
| 518 | |
| 519 | if (!gadget) { |
| 520 | /* TODO: Disable regulators. */ |
Heikki Krogerus | 144713f | 2012-02-13 13:24:05 +0200 | [diff] [blame] | 521 | otg->gadget = NULL; |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 522 | schedule_work(&ab->phy_dis_work); |
| 523 | } else { |
Heikki Krogerus | 144713f | 2012-02-13 13:24:05 +0200 | [diff] [blame] | 524 | otg->gadget = gadget; |
| 525 | otg->phy->state = OTG_STATE_B_IDLE; |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 526 | |
| 527 | /* Phy will not be enabled if cable is already |
| 528 | * plugged-in. Schedule to enable phy. |
| 529 | * Use same delay to avoid any race condition. |
| 530 | */ |
| 531 | schedule_delayed_work(&ab->dwork, ab->link_status_wait); |
| 532 | } |
| 533 | |
| 534 | return 0; |
| 535 | } |
| 536 | |
Heikki Krogerus | 144713f | 2012-02-13 13:24:05 +0200 | [diff] [blame] | 537 | static int ab8500_usb_set_host(struct usb_otg *otg, struct usb_bus *host) |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 538 | { |
| 539 | struct ab8500_usb *ab; |
| 540 | |
| 541 | if (!otg) |
| 542 | return -ENODEV; |
| 543 | |
Heikki Krogerus | 144713f | 2012-02-13 13:24:05 +0200 | [diff] [blame] | 544 | ab = phy_to_ab(otg->phy); |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 545 | |
| 546 | /* Some drivers call this function in atomic context. |
| 547 | * Do not update ab8500 registers directly till this |
| 548 | * is fixed. |
| 549 | */ |
| 550 | |
| 551 | if (!host) { |
| 552 | /* TODO: Disable regulators. */ |
Heikki Krogerus | 144713f | 2012-02-13 13:24:05 +0200 | [diff] [blame] | 553 | otg->host = NULL; |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 554 | schedule_work(&ab->phy_dis_work); |
| 555 | } else { |
Heikki Krogerus | 144713f | 2012-02-13 13:24:05 +0200 | [diff] [blame] | 556 | otg->host = host; |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 557 | /* Phy will not be enabled if cable is already |
| 558 | * plugged-in. Schedule to enable phy. |
| 559 | * Use same delay to avoid any race condition. |
| 560 | */ |
| 561 | schedule_delayed_work(&ab->dwork, ab->link_status_wait); |
| 562 | } |
| 563 | |
| 564 | return 0; |
| 565 | } |
| 566 | |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 567 | static int ab8500_usb_irq_setup(struct platform_device *pdev, |
| 568 | struct ab8500_usb *ab) |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 569 | { |
| 570 | int err; |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 571 | int irq; |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 572 | |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 573 | irq = platform_get_irq_byname(pdev, "USB_LINK_STATUS"); |
| 574 | if (irq < 0) { |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 575 | dev_err(&pdev->dev, "Link status irq not found\n"); |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 576 | return irq; |
| 577 | } |
| 578 | err = devm_request_threaded_irq(&pdev->dev, irq, NULL, |
| 579 | ab8500_usb_link_status_irq, |
| 580 | IRQF_NO_SUSPEND | IRQF_SHARED, "usb-link-status", ab); |
| 581 | if (err < 0) { |
| 582 | dev_err(ab->dev, "request_irq failed for link status irq\n"); |
| 583 | return err; |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 584 | } |
| 585 | |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 586 | irq = platform_get_irq_byname(pdev, "ID_WAKEUP_F"); |
| 587 | if (irq < 0) { |
| 588 | dev_err(&pdev->dev, "ID fall irq not found\n"); |
| 589 | return irq; |
| 590 | } |
| 591 | err = devm_request_threaded_irq(&pdev->dev, irq, NULL, |
| 592 | ab8500_usb_disconnect_irq, |
| 593 | IRQF_NO_SUSPEND | IRQF_SHARED, "usb-id-fall", ab); |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 594 | if (err < 0) { |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 595 | dev_err(ab->dev, "request_irq failed for ID fall irq\n"); |
| 596 | return err; |
| 597 | } |
| 598 | |
| 599 | irq = platform_get_irq_byname(pdev, "VBUS_DET_F"); |
| 600 | if (irq < 0) { |
| 601 | dev_err(&pdev->dev, "VBUS fall irq not found\n"); |
| 602 | return irq; |
| 603 | } |
| 604 | err = devm_request_threaded_irq(&pdev->dev, irq, NULL, |
| 605 | ab8500_usb_disconnect_irq, |
| 606 | IRQF_NO_SUSPEND | IRQF_SHARED, "usb-vbus-fall", ab); |
| 607 | if (err < 0) { |
| 608 | dev_err(ab->dev, "request_irq failed for Vbus fall irq\n"); |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 609 | return err; |
| 610 | } |
| 611 | |
| 612 | return 0; |
| 613 | } |
| 614 | |
Bill Pemberton | 41ac7b3 | 2012-11-19 13:21:48 -0500 | [diff] [blame] | 615 | static int ab8500_usb_probe(struct platform_device *pdev) |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 616 | { |
| 617 | struct ab8500_usb *ab; |
Fabio Baltieri | 73f226c | 2013-03-08 10:27:08 +0800 | [diff] [blame] | 618 | struct ab8500 *ab8500; |
Heikki Krogerus | 144713f | 2012-02-13 13:24:05 +0200 | [diff] [blame] | 619 | struct usb_otg *otg; |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 620 | int err; |
| 621 | int rev; |
| 622 | |
Fabio Baltieri | 73f226c | 2013-03-08 10:27:08 +0800 | [diff] [blame] | 623 | ab8500 = dev_get_drvdata(pdev->dev.parent); |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 624 | rev = abx500_get_chip_id(&pdev->dev); |
Fabio Baltieri | 73f226c | 2013-03-08 10:27:08 +0800 | [diff] [blame] | 625 | |
| 626 | if (is_ab8500_1p1_or_earlier(ab8500)) { |
| 627 | dev_err(&pdev->dev, "Unsupported AB8500 chip rev=%d\n", rev); |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 628 | return -ENODEV; |
| 629 | } |
| 630 | |
| 631 | ab = kzalloc(sizeof *ab, GFP_KERNEL); |
| 632 | if (!ab) |
| 633 | return -ENOMEM; |
| 634 | |
Heikki Krogerus | 144713f | 2012-02-13 13:24:05 +0200 | [diff] [blame] | 635 | otg = kzalloc(sizeof *otg, GFP_KERNEL); |
Dan Carpenter | 5f0b3f9 | 2012-03-02 11:08:14 +0300 | [diff] [blame] | 636 | if (!otg) { |
Heikki Krogerus | 144713f | 2012-02-13 13:24:05 +0200 | [diff] [blame] | 637 | kfree(ab); |
| 638 | return -ENOMEM; |
| 639 | } |
| 640 | |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 641 | ab->dev = &pdev->dev; |
Fabio Baltieri | 73f226c | 2013-03-08 10:27:08 +0800 | [diff] [blame] | 642 | ab->ab8500 = ab8500; |
Heikki Krogerus | 144713f | 2012-02-13 13:24:05 +0200 | [diff] [blame] | 643 | ab->phy.dev = ab->dev; |
| 644 | ab->phy.otg = otg; |
| 645 | ab->phy.label = "ab8500"; |
| 646 | ab->phy.set_suspend = ab8500_usb_set_suspend; |
| 647 | ab->phy.set_power = ab8500_usb_set_power; |
| 648 | ab->phy.state = OTG_STATE_UNDEFINED; |
| 649 | |
| 650 | otg->phy = &ab->phy; |
| 651 | otg->set_host = ab8500_usb_set_host; |
| 652 | otg->set_peripheral = ab8500_usb_set_peripheral; |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 653 | |
| 654 | platform_set_drvdata(pdev, ab); |
| 655 | |
Heikki Krogerus | 144713f | 2012-02-13 13:24:05 +0200 | [diff] [blame] | 656 | ATOMIC_INIT_NOTIFIER_HEAD(&ab->phy.notifier); |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 657 | |
| 658 | /* v1: Wait for link status to become stable. |
| 659 | * all: Updates form set_host and set_peripheral as they are atomic. |
| 660 | */ |
| 661 | INIT_DELAYED_WORK(&ab->dwork, ab8500_usb_delayed_work); |
| 662 | |
| 663 | /* all: Disable phy when called from set_host and set_peripheral */ |
| 664 | INIT_WORK(&ab->phy_dis_work, ab8500_usb_phy_disable_work); |
| 665 | |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 666 | err = ab8500_usb_irq_setup(pdev, ab); |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 667 | if (err < 0) |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 668 | goto fail; |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 669 | |
Kishon Vijay Abraham I | 662dca5 | 2012-06-22 17:02:46 +0530 | [diff] [blame] | 670 | err = usb_add_phy(&ab->phy, USB_PHY_TYPE_USB2); |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 671 | if (err) { |
| 672 | dev_err(&pdev->dev, "Can't register transceiver\n"); |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 673 | goto fail; |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 674 | } |
| 675 | |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 676 | /* Needed to enable ID detection. */ |
| 677 | ab8500_usb_wd_workaround(ab); |
| 678 | |
Fabio Baltieri | 73f226c | 2013-03-08 10:27:08 +0800 | [diff] [blame] | 679 | dev_info(&pdev->dev, "revision 0x%2x driver initialized\n", rev); |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 680 | |
| 681 | return 0; |
Fabio Baltieri | af6882b | 2013-03-08 10:27:09 +0800 | [diff] [blame^] | 682 | fail: |
Heikki Krogerus | 144713f | 2012-02-13 13:24:05 +0200 | [diff] [blame] | 683 | kfree(otg); |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 684 | kfree(ab); |
| 685 | return err; |
| 686 | } |
| 687 | |
Bill Pemberton | fb4e98a | 2012-11-19 13:26:20 -0500 | [diff] [blame] | 688 | static int ab8500_usb_remove(struct platform_device *pdev) |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 689 | { |
| 690 | struct ab8500_usb *ab = platform_get_drvdata(pdev); |
| 691 | |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 692 | cancel_delayed_work_sync(&ab->dwork); |
| 693 | |
| 694 | cancel_work_sync(&ab->phy_dis_work); |
| 695 | |
Kishon Vijay Abraham I | 662dca5 | 2012-06-22 17:02:46 +0530 | [diff] [blame] | 696 | usb_remove_phy(&ab->phy); |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 697 | |
| 698 | ab8500_usb_host_phy_dis(ab); |
| 699 | ab8500_usb_peri_phy_dis(ab); |
| 700 | |
| 701 | platform_set_drvdata(pdev, NULL); |
| 702 | |
Heikki Krogerus | 144713f | 2012-02-13 13:24:05 +0200 | [diff] [blame] | 703 | kfree(ab->phy.otg); |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 704 | kfree(ab); |
| 705 | |
| 706 | return 0; |
| 707 | } |
| 708 | |
| 709 | static struct platform_driver ab8500_usb_driver = { |
| 710 | .probe = ab8500_usb_probe, |
Bill Pemberton | 7690417 | 2012-11-19 13:21:08 -0500 | [diff] [blame] | 711 | .remove = ab8500_usb_remove, |
Mian Yousaf Kaukab | 9691523 | 2010-12-07 15:00:09 +0100 | [diff] [blame] | 712 | .driver = { |
| 713 | .name = "ab8500-usb", |
| 714 | .owner = THIS_MODULE, |
| 715 | }, |
| 716 | }; |
| 717 | |
| 718 | static int __init ab8500_usb_init(void) |
| 719 | { |
| 720 | return platform_driver_register(&ab8500_usb_driver); |
| 721 | } |
| 722 | subsys_initcall(ab8500_usb_init); |
| 723 | |
| 724 | static void __exit ab8500_usb_exit(void) |
| 725 | { |
| 726 | platform_driver_unregister(&ab8500_usb_driver); |
| 727 | } |
| 728 | module_exit(ab8500_usb_exit); |
| 729 | |
| 730 | MODULE_ALIAS("platform:ab8500_usb"); |
| 731 | MODULE_AUTHOR("ST-Ericsson AB"); |
| 732 | MODULE_DESCRIPTION("AB8500 usb transceiver driver"); |
| 733 | MODULE_LICENSE("GPL"); |