Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Generic ULPI USB transceiver support |
| 3 | * |
| 4 | * Copyright (C) 2009 Daniel Mack <daniel@caiaq.de> |
| 5 | * |
| 6 | * Based on sources from |
| 7 | * |
| 8 | * Sascha Hauer <s.hauer@pengutronix.de> |
| 9 | * Freescale Semiconductors |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 of the License, or |
| 14 | * (at your option) any later version. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 24 | */ |
| 25 | |
| 26 | #include <linux/kernel.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 27 | #include <linux/slab.h> |
Paul Gortmaker | f940fcd | 2011-05-27 09:56:31 -0400 | [diff] [blame] | 28 | #include <linux/export.h> |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 29 | #include <linux/usb.h> |
| 30 | #include <linux/usb/otg.h> |
| 31 | #include <linux/usb/ulpi.h> |
| 32 | |
Igor Grinberg | 96b9e83 | 2010-10-10 17:59:19 +0200 | [diff] [blame] | 33 | |
| 34 | struct ulpi_info { |
| 35 | unsigned int id; |
| 36 | char *name; |
| 37 | }; |
| 38 | |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 39 | #define ULPI_ID(vendor, product) (((vendor) << 16) | (product)) |
Igor Grinberg | 96b9e83 | 2010-10-10 17:59:19 +0200 | [diff] [blame] | 40 | #define ULPI_INFO(_id, _name) \ |
| 41 | { \ |
| 42 | .id = (_id), \ |
| 43 | .name = (_name), \ |
| 44 | } |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 45 | |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 46 | /* ULPI hardcoded IDs, used for probing */ |
Igor Grinberg | 96b9e83 | 2010-10-10 17:59:19 +0200 | [diff] [blame] | 47 | static struct ulpi_info ulpi_ids[] = { |
| 48 | ULPI_INFO(ULPI_ID(0x04cc, 0x1504), "NXP ISP1504"), |
Fabio Estevam | 1e4cba8 | 2010-12-20 21:54:30 -0200 | [diff] [blame] | 49 | ULPI_INFO(ULPI_ID(0x0424, 0x0006), "SMSC USB331x"), |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 50 | }; |
| 51 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 52 | static int ulpi_set_otg_flags(struct usb_phy *phy) |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 53 | { |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 54 | unsigned int flags = ULPI_OTG_CTRL_DP_PULLDOWN | |
| 55 | ULPI_OTG_CTRL_DM_PULLDOWN; |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 56 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 57 | if (phy->flags & ULPI_OTG_ID_PULLUP) |
Heikki Krogerus | fc567f0 | 2010-05-03 09:13:02 +0300 | [diff] [blame] | 58 | flags |= ULPI_OTG_CTRL_ID_PULLUP; |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 59 | |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 60 | /* |
| 61 | * ULPI Specification rev.1.1 default |
| 62 | * for Dp/DmPulldown is enabled. |
| 63 | */ |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 64 | if (phy->flags & ULPI_OTG_DP_PULLDOWN_DIS) |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 65 | flags &= ~ULPI_OTG_CTRL_DP_PULLDOWN; |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 66 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 67 | if (phy->flags & ULPI_OTG_DM_PULLDOWN_DIS) |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 68 | flags &= ~ULPI_OTG_CTRL_DM_PULLDOWN; |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 69 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 70 | if (phy->flags & ULPI_OTG_EXTVBUSIND) |
Heikki Krogerus | fc567f0 | 2010-05-03 09:13:02 +0300 | [diff] [blame] | 71 | flags |= ULPI_OTG_CTRL_EXTVBUSIND; |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 72 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 73 | return usb_phy_io_write(phy, flags, ULPI_OTG_CTRL); |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 74 | } |
| 75 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 76 | static int ulpi_set_fc_flags(struct usb_phy *phy) |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 77 | { |
| 78 | unsigned int flags = 0; |
| 79 | |
| 80 | /* |
| 81 | * ULPI Specification rev.1.1 default |
| 82 | * for XcvrSelect is Full Speed. |
| 83 | */ |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 84 | if (phy->flags & ULPI_FC_HS) |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 85 | flags |= ULPI_FUNC_CTRL_HIGH_SPEED; |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 86 | else if (phy->flags & ULPI_FC_LS) |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 87 | flags |= ULPI_FUNC_CTRL_LOW_SPEED; |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 88 | else if (phy->flags & ULPI_FC_FS4LS) |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 89 | flags |= ULPI_FUNC_CTRL_FS4LS; |
| 90 | else |
| 91 | flags |= ULPI_FUNC_CTRL_FULL_SPEED; |
| 92 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 93 | if (phy->flags & ULPI_FC_TERMSEL) |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 94 | flags |= ULPI_FUNC_CTRL_TERMSELECT; |
| 95 | |
| 96 | /* |
| 97 | * ULPI Specification rev.1.1 default |
| 98 | * for OpMode is Normal Operation. |
| 99 | */ |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 100 | if (phy->flags & ULPI_FC_OP_NODRV) |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 101 | flags |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING; |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 102 | else if (phy->flags & ULPI_FC_OP_DIS_NRZI) |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 103 | flags |= ULPI_FUNC_CTRL_OPMODE_DISABLE_NRZI; |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 104 | else if (phy->flags & ULPI_FC_OP_NSYNC_NEOP) |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 105 | flags |= ULPI_FUNC_CTRL_OPMODE_NOSYNC_NOEOP; |
| 106 | else |
| 107 | flags |= ULPI_FUNC_CTRL_OPMODE_NORMAL; |
| 108 | |
| 109 | /* |
| 110 | * ULPI Specification rev.1.1 default |
| 111 | * for SuspendM is Powered. |
| 112 | */ |
| 113 | flags |= ULPI_FUNC_CTRL_SUSPENDM; |
| 114 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 115 | return usb_phy_io_write(phy, flags, ULPI_FUNC_CTRL); |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 116 | } |
| 117 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 118 | static int ulpi_set_ic_flags(struct usb_phy *phy) |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 119 | { |
| 120 | unsigned int flags = 0; |
| 121 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 122 | if (phy->flags & ULPI_IC_AUTORESUME) |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 123 | flags |= ULPI_IFC_CTRL_AUTORESUME; |
| 124 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 125 | if (phy->flags & ULPI_IC_EXTVBUS_INDINV) |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 126 | flags |= ULPI_IFC_CTRL_EXTERNAL_VBUS; |
| 127 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 128 | if (phy->flags & ULPI_IC_IND_PASSTHRU) |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 129 | flags |= ULPI_IFC_CTRL_PASSTHRU; |
| 130 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 131 | if (phy->flags & ULPI_IC_PROTECT_DIS) |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 132 | flags |= ULPI_IFC_CTRL_PROTECT_IFC_DISABLE; |
| 133 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 134 | return usb_phy_io_write(phy, flags, ULPI_IFC_CTRL); |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 135 | } |
| 136 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 137 | static int ulpi_set_flags(struct usb_phy *phy) |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 138 | { |
| 139 | int ret; |
| 140 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 141 | ret = ulpi_set_otg_flags(phy); |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 142 | if (ret) |
| 143 | return ret; |
| 144 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 145 | ret = ulpi_set_ic_flags(phy); |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 146 | if (ret) |
| 147 | return ret; |
| 148 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 149 | return ulpi_set_fc_flags(phy); |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 150 | } |
| 151 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 152 | static int ulpi_check_integrity(struct usb_phy *phy) |
Igor Grinberg | a913819 | 2010-10-10 17:59:18 +0200 | [diff] [blame] | 153 | { |
| 154 | int ret, i; |
| 155 | unsigned int val = 0x55; |
| 156 | |
| 157 | for (i = 0; i < 2; i++) { |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 158 | ret = usb_phy_io_write(phy, val, ULPI_SCRATCH); |
Igor Grinberg | a913819 | 2010-10-10 17:59:18 +0200 | [diff] [blame] | 159 | if (ret < 0) |
| 160 | return ret; |
| 161 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 162 | ret = usb_phy_io_read(phy, ULPI_SCRATCH); |
Igor Grinberg | a913819 | 2010-10-10 17:59:18 +0200 | [diff] [blame] | 163 | if (ret < 0) |
| 164 | return ret; |
| 165 | |
| 166 | if (ret != val) { |
| 167 | pr_err("ULPI integrity check: failed!"); |
| 168 | return -ENODEV; |
| 169 | } |
| 170 | val = val << 1; |
| 171 | } |
| 172 | |
| 173 | pr_info("ULPI integrity check: passed.\n"); |
| 174 | |
| 175 | return 0; |
| 176 | } |
| 177 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 178 | static int ulpi_init(struct usb_phy *phy) |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 179 | { |
Wolfram Sang | 7b4a036 | 2010-06-15 12:34:22 +0200 | [diff] [blame] | 180 | int i, vid, pid, ret; |
| 181 | u32 ulpi_id = 0; |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 182 | |
Wolfram Sang | 7b4a036 | 2010-06-15 12:34:22 +0200 | [diff] [blame] | 183 | for (i = 0; i < 4; i++) { |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 184 | ret = usb_phy_io_read(phy, ULPI_PRODUCT_ID_HIGH - i); |
Wolfram Sang | 7b4a036 | 2010-06-15 12:34:22 +0200 | [diff] [blame] | 185 | if (ret < 0) |
| 186 | return ret; |
| 187 | ulpi_id = (ulpi_id << 8) | ret; |
| 188 | } |
| 189 | vid = ulpi_id & 0xffff; |
| 190 | pid = ulpi_id >> 16; |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 191 | |
| 192 | pr_info("ULPI transceiver vendor/product ID 0x%04x/0x%04x\n", vid, pid); |
| 193 | |
Igor Grinberg | 96b9e83 | 2010-10-10 17:59:19 +0200 | [diff] [blame] | 194 | for (i = 0; i < ARRAY_SIZE(ulpi_ids); i++) { |
| 195 | if (ulpi_ids[i].id == ULPI_ID(vid, pid)) { |
| 196 | pr_info("Found %s ULPI transceiver.\n", |
| 197 | ulpi_ids[i].name); |
Igor Grinberg | a913819 | 2010-10-10 17:59:18 +0200 | [diff] [blame] | 198 | break; |
Igor Grinberg | 96b9e83 | 2010-10-10 17:59:19 +0200 | [diff] [blame] | 199 | } |
| 200 | } |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 201 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 202 | ret = ulpi_check_integrity(phy); |
Igor Grinberg | a913819 | 2010-10-10 17:59:18 +0200 | [diff] [blame] | 203 | if (ret) |
| 204 | return ret; |
| 205 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 206 | return ulpi_set_flags(phy); |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 207 | } |
| 208 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 209 | static int ulpi_set_host(struct usb_otg *otg, struct usb_bus *host) |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 210 | { |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 211 | struct usb_phy *phy = otg->phy; |
| 212 | unsigned int flags = usb_phy_io_read(phy, ULPI_IFC_CTRL); |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 213 | |
| 214 | if (!host) { |
| 215 | otg->host = NULL; |
| 216 | return 0; |
| 217 | } |
| 218 | |
| 219 | otg->host = host; |
| 220 | |
| 221 | flags &= ~(ULPI_IFC_CTRL_6_PIN_SERIAL_MODE | |
| 222 | ULPI_IFC_CTRL_3_PIN_SERIAL_MODE | |
| 223 | ULPI_IFC_CTRL_CARKITMODE); |
| 224 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 225 | if (phy->flags & ULPI_IC_6PIN_SERIAL) |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 226 | flags |= ULPI_IFC_CTRL_6_PIN_SERIAL_MODE; |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 227 | else if (phy->flags & ULPI_IC_3PIN_SERIAL) |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 228 | flags |= ULPI_IFC_CTRL_3_PIN_SERIAL_MODE; |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 229 | else if (phy->flags & ULPI_IC_CARKIT) |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 230 | flags |= ULPI_IFC_CTRL_CARKITMODE; |
| 231 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 232 | return usb_phy_io_write(phy, flags, ULPI_IFC_CTRL); |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 233 | } |
| 234 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 235 | static int ulpi_set_vbus(struct usb_otg *otg, bool on) |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 236 | { |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 237 | struct usb_phy *phy = otg->phy; |
| 238 | unsigned int flags = usb_phy_io_read(phy, ULPI_OTG_CTRL); |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 239 | |
Heikki Krogerus | fc567f0 | 2010-05-03 09:13:02 +0300 | [diff] [blame] | 240 | flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT); |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 241 | |
| 242 | if (on) { |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 243 | if (phy->flags & ULPI_OTG_DRVVBUS) |
Heikki Krogerus | fc567f0 | 2010-05-03 09:13:02 +0300 | [diff] [blame] | 244 | flags |= ULPI_OTG_CTRL_DRVVBUS; |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 245 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 246 | if (phy->flags & ULPI_OTG_DRVVBUS_EXT) |
Heikki Krogerus | fc567f0 | 2010-05-03 09:13:02 +0300 | [diff] [blame] | 247 | flags |= ULPI_OTG_CTRL_DRVVBUS_EXT; |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 248 | } |
| 249 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 250 | return usb_phy_io_write(phy, flags, ULPI_OTG_CTRL); |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 251 | } |
| 252 | |
Heikki Krogerus | 8675381 | 2012-02-13 13:24:02 +0200 | [diff] [blame] | 253 | struct usb_phy * |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 254 | otg_ulpi_create(struct usb_phy_io_ops *ops, |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 255 | unsigned int flags) |
| 256 | { |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 257 | struct usb_phy *phy; |
| 258 | struct usb_otg *otg; |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 259 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 260 | phy = kzalloc(sizeof(*phy), GFP_KERNEL); |
| 261 | if (!phy) |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 262 | return NULL; |
| 263 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 264 | otg = kzalloc(sizeof(*otg), GFP_KERNEL); |
| 265 | if (!otg) { |
| 266 | kfree(phy); |
| 267 | return NULL; |
| 268 | } |
| 269 | |
| 270 | phy->label = "ULPI"; |
| 271 | phy->flags = flags; |
| 272 | phy->io_ops = ops; |
| 273 | phy->otg = otg; |
| 274 | phy->init = ulpi_init; |
| 275 | |
| 276 | otg->phy = phy; |
Igor Grinberg | 13dd0c9 | 2010-07-15 16:00:16 +0300 | [diff] [blame] | 277 | otg->set_host = ulpi_set_host; |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 278 | otg->set_vbus = ulpi_set_vbus; |
| 279 | |
Heikki Krogerus | 298b083 | 2012-02-13 13:24:13 +0200 | [diff] [blame] | 280 | return phy; |
Daniel Mack | 2d57a95 | 2009-10-15 17:09:35 +0300 | [diff] [blame] | 281 | } |
| 282 | EXPORT_SYMBOL_GPL(otg_ulpi_create); |
| 283 | |