blob: 278587b4933bd0a034e74a85b6af47b14e769447 [file] [log] [blame]
Hans de Goede0eccec42015-01-07 15:08:43 +01001/*
Hans de Goede7b798652015-04-27 14:54:47 +02002 * Sunxi usb-phy code
Hans de Goede0eccec42015-01-07 15:08:43 +01003 *
Hans de Goede7b798652015-04-27 14:54:47 +02004 * Copyright (C) 2015 Hans de Goede <hdegoede@redhat.com>
5 * Copyright (C) 2014 Roman Byshko <rbyshko@gmail.com>
Hans de Goede0eccec42015-01-07 15:08:43 +01006 *
7 * Based on code from
8 * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
9 *
10 * SPDX-License-Identifier: GPL-2.0+
11 */
12
Hans de Goede375de012015-04-27 11:44:22 +020013#include <common.h>
Hans de Goede0eccec42015-01-07 15:08:43 +010014#include <asm/arch/clock.h>
15#include <asm/arch/cpu.h>
Hans de Goede2aacc422015-04-27 15:05:10 +020016#include <asm/arch/usb_phy.h>
Hans de Goede0eccec42015-01-07 15:08:43 +010017#include <asm/gpio.h>
18#include <asm/io.h>
Hans de Goedea7254262015-04-22 17:39:59 +020019#include <errno.h>
Hans de Goede0eccec42015-01-07 15:08:43 +010020
21#define SUNXI_USB_PMU_IRQ_ENABLE 0x800
Vishnu Patekar8c3dacf2015-03-01 23:47:48 +053022#ifdef CONFIG_MACH_SUN8I_A33
23#define SUNXI_USB_CSR 0x410
24#else
Hans de Goede0eccec42015-01-07 15:08:43 +010025#define SUNXI_USB_CSR 0x404
Vishnu Patekar8c3dacf2015-03-01 23:47:48 +053026#endif
Hans de Goede0eccec42015-01-07 15:08:43 +010027#define SUNXI_USB_PASSBY_EN 1
28
29#define SUNXI_EHCI_AHB_ICHR8_EN (1 << 10)
30#define SUNXI_EHCI_AHB_INCR4_BURST_EN (1 << 9)
31#define SUNXI_EHCI_AHB_INCRX_ALIGN_EN (1 << 8)
32#define SUNXI_EHCI_ULPI_BYPASS_EN (1 << 0)
33
Jelle van der Waadc44fd82016-02-09 23:59:33 +010034#define REG_PHY_UNK_H3 0x420
35#define REG_PMU_UNK_H3 0x810
36
Chen-Yu Tsai0c935ac2016-03-30 00:26:51 +080037/* A83T specific control bits for PHY0 */
38#define SUNXI_PHY_CTL_VBUSVLDEXT BIT(5)
39#define SUNXI_PHY_CTL_SIDDQ BIT(3)
40
41/* A83T HSIC specific bits */
42#define SUNXI_EHCI_HS_FORCE BIT(20)
43#define SUNXI_EHCI_CONNECT_DET BIT(17)
44#define SUNXI_EHCI_CONNECT_INT BIT(16)
45#define SUNXI_EHCI_HSIC BIT(1)
46
Hans de Goede7b798652015-04-27 14:54:47 +020047static struct sunxi_usb_phy {
Hans de Goede0eccec42015-01-07 15:08:43 +010048 int usb_rst_mask;
Hans de Goede0eccec42015-01-07 15:08:43 +010049 int gpio_vbus;
Paul Kocialkowskiebd468b2015-03-22 18:07:12 +010050 int gpio_vbus_det;
Hans de Goede48c06c92015-06-14 17:29:53 +020051 int gpio_id_det;
Hans de Goede0eccec42015-01-07 15:08:43 +010052 int id;
Hans de Goedefd01ae12015-04-27 16:57:54 +020053 int init_count;
54 int power_on_count;
Alexander Graf0ea5a042016-03-29 17:29:09 +020055 ulong base;
Hans de Goede7b798652015-04-27 14:54:47 +020056} sunxi_usb_phy[] = {
Hans de Goede0eccec42015-01-07 15:08:43 +010057 {
Hans de Goede4458b7a2015-01-07 15:26:06 +010058 .usb_rst_mask = CCM_USB_CTRL_PHY0_RST | CCM_USB_CTRL_PHY0_CLK,
Hans de Goede4458b7a2015-01-07 15:26:06 +010059 .id = 0,
Jelle van der Waadc44fd82016-02-09 23:59:33 +010060 .base = SUNXI_USB0_BASE,
Hans de Goede4458b7a2015-01-07 15:26:06 +010061 },
62 {
Hans de Goede0eccec42015-01-07 15:08:43 +010063 .usb_rst_mask = CCM_USB_CTRL_PHY1_RST | CCM_USB_CTRL_PHY1_CLK,
Hans de Goede0eccec42015-01-07 15:08:43 +010064 .id = 1,
Jelle van der Waadc44fd82016-02-09 23:59:33 +010065 .base = SUNXI_USB1_BASE,
Hans de Goede0eccec42015-01-07 15:08:43 +010066 },
Hans de Goedee13afee2015-04-27 16:50:04 +020067#if CONFIG_SUNXI_USB_PHYS >= 3
Hans de Goede0eccec42015-01-07 15:08:43 +010068 {
Chen-Yu Tsai0c935ac2016-03-30 00:26:51 +080069#ifdef CONFIG_MACH_SUN8I_A83T
70 .usb_rst_mask = CCM_USB_CTRL_HSIC_RST | CCM_USB_CTRL_HSIC_CLK |
71 CCM_USB_CTRL_12M_CLK,
72#else
Hans de Goede0eccec42015-01-07 15:08:43 +010073 .usb_rst_mask = CCM_USB_CTRL_PHY2_RST | CCM_USB_CTRL_PHY2_CLK,
Chen-Yu Tsai0c935ac2016-03-30 00:26:51 +080074#endif
Hans de Goede0eccec42015-01-07 15:08:43 +010075 .id = 2,
Jelle van der Waadc44fd82016-02-09 23:59:33 +010076 .base = SUNXI_USB2_BASE,
77 },
78#endif
79#if CONFIG_SUNXI_USB_PHYS >= 4
80 {
81 .usb_rst_mask = CCM_USB_CTRL_PHY3_RST | CCM_USB_CTRL_PHY3_CLK,
82 .id = 3,
83 .base = SUNXI_USB3_BASE,
Hans de Goede0eccec42015-01-07 15:08:43 +010084 }
85#endif
86};
87
Hans de Goede2c3c3ec2016-04-01 22:39:26 +020088static int initial_usb_scan_delay = CONFIG_INITIAL_USB_SCAN_DELAY;
89
Hans de Goede0eccec42015-01-07 15:08:43 +010090static int get_vbus_gpio(int index)
91{
92 switch (index) {
Hans de Goede4458b7a2015-01-07 15:26:06 +010093 case 0: return sunxi_name_to_gpio(CONFIG_USB0_VBUS_PIN);
Hans de Goede0eccec42015-01-07 15:08:43 +010094 case 1: return sunxi_name_to_gpio(CONFIG_USB1_VBUS_PIN);
95 case 2: return sunxi_name_to_gpio(CONFIG_USB2_VBUS_PIN);
Hans de Goede60fa6302016-03-18 08:42:01 +010096 case 3: return sunxi_name_to_gpio(CONFIG_USB3_VBUS_PIN);
Hans de Goede0eccec42015-01-07 15:08:43 +010097 }
Hans de Goedea7254262015-04-22 17:39:59 +020098 return -EINVAL;
Hans de Goede0eccec42015-01-07 15:08:43 +010099}
100
Paul Kocialkowskiebd468b2015-03-22 18:07:12 +0100101static int get_vbus_detect_gpio(int index)
102{
103 switch (index) {
104 case 0: return sunxi_name_to_gpio(CONFIG_USB0_VBUS_DET);
105 }
Hans de Goedea7254262015-04-22 17:39:59 +0200106 return -EINVAL;
Paul Kocialkowskiebd468b2015-03-22 18:07:12 +0100107}
108
Hans de Goede48c06c92015-06-14 17:29:53 +0200109static int get_id_detect_gpio(int index)
110{
111 switch (index) {
112 case 0: return sunxi_name_to_gpio(CONFIG_USB0_ID_DET);
113 }
114 return -EINVAL;
115}
116
Chen-Yu Tsai0c935ac2016-03-30 00:26:51 +0800117__maybe_unused static void usb_phy_write(struct sunxi_usb_phy *phy, int addr,
118 int data, int len)
Hans de Goede0eccec42015-01-07 15:08:43 +0100119{
120 int j = 0, usbc_bit = 0;
Hans de Goedea781c972015-04-27 14:36:23 +0200121 void *dest = (void *)SUNXI_USB0_BASE + SUNXI_USB_CSR;
Hans de Goede0eccec42015-01-07 15:08:43 +0100122
Vishnu Patekar8c3dacf2015-03-01 23:47:48 +0530123#ifdef CONFIG_MACH_SUN8I_A33
124 /* CSR needs to be explicitly initialized to 0 on A33 */
125 writel(0, dest);
126#endif
127
Hans de Goede7b798652015-04-27 14:54:47 +0200128 usbc_bit = 1 << (phy->id * 2);
Hans de Goede0eccec42015-01-07 15:08:43 +0100129 for (j = 0; j < len; j++) {
130 /* set the bit address to be written */
131 clrbits_le32(dest, 0xff << 8);
132 setbits_le32(dest, (addr + j) << 8);
133
134 clrbits_le32(dest, usbc_bit);
135 /* set data bit */
136 if (data & 0x1)
137 setbits_le32(dest, 1 << 7);
138 else
139 clrbits_le32(dest, 1 << 7);
140
141 setbits_le32(dest, usbc_bit);
142
143 clrbits_le32(dest, usbc_bit);
144
145 data >>= 1;
146 }
147}
148
Amit Singh Tomar9d6c9d92016-10-21 02:24:30 +0100149#if defined(CONFIG_MACH_SUN8I_H3) || defined(CONFIG_MACH_SUN50I)
Jelle van der Waadc44fd82016-02-09 23:59:33 +0100150static void sunxi_usb_phy_config(struct sunxi_usb_phy *phy)
151{
Amit Singh Tomar9d6c9d92016-10-21 02:24:30 +0100152#if defined CONFIG_MACH_SUN8I_H3
Jelle van der Waadc44fd82016-02-09 23:59:33 +0100153 if (phy->id == 0)
154 clrbits_le32(SUNXI_USBPHY_BASE + REG_PHY_UNK_H3, 0x01);
Amit Singh Tomar9d6c9d92016-10-21 02:24:30 +0100155#endif
Jelle van der Waadc44fd82016-02-09 23:59:33 +0100156 clrbits_le32(phy->base + REG_PMU_UNK_H3, 0x02);
157}
Chen-Yu Tsai0c935ac2016-03-30 00:26:51 +0800158#elif defined CONFIG_MACH_SUN8I_A83T
159static void sunxi_usb_phy_config(struct sunxi_usb_phy *phy)
160{
161}
Jelle van der Waadc44fd82016-02-09 23:59:33 +0100162#else
Hans de Goede7b798652015-04-27 14:54:47 +0200163static void sunxi_usb_phy_config(struct sunxi_usb_phy *phy)
Hans de Goede0eccec42015-01-07 15:08:43 +0100164{
165 /* The following comments are machine
166 * translated from Chinese, you have been warned!
167 */
168
Hans de Goede4458b7a2015-01-07 15:26:06 +0100169 /* Regulation 45 ohms */
Hans de Goede7b798652015-04-27 14:54:47 +0200170 if (phy->id == 0)
171 usb_phy_write(phy, 0x0c, 0x01, 1);
Hans de Goede4458b7a2015-01-07 15:26:06 +0100172
Hans de Goede0eccec42015-01-07 15:08:43 +0100173 /* adjust PHY's magnitude and rate */
Hans de Goede7b798652015-04-27 14:54:47 +0200174 usb_phy_write(phy, 0x20, 0x14, 5);
Hans de Goede0eccec42015-01-07 15:08:43 +0100175
176 /* threshold adjustment disconnect */
Hans de Goede7afebb52015-05-31 19:26:54 +0200177#if defined CONFIG_MACH_SUN5I || defined CONFIG_MACH_SUN7I
Hans de Goede7b798652015-04-27 14:54:47 +0200178 usb_phy_write(phy, 0x2a, 2, 2);
Hans de Goede7afebb52015-05-31 19:26:54 +0200179#else
180 usb_phy_write(phy, 0x2a, 3, 2);
Hans de Goede0eccec42015-01-07 15:08:43 +0100181#endif
182
183 return;
184}
Jelle van der Waadc44fd82016-02-09 23:59:33 +0100185#endif
Hans de Goede0eccec42015-01-07 15:08:43 +0100186
Jelle van der Waadc44fd82016-02-09 23:59:33 +0100187static void sunxi_usb_phy_passby(struct sunxi_usb_phy *phy, int enable)
Hans de Goede0eccec42015-01-07 15:08:43 +0100188{
189 unsigned long bits = 0;
Hans de Goedea781c972015-04-27 14:36:23 +0200190 void *addr;
191
Jelle van der Waadc44fd82016-02-09 23:59:33 +0100192 addr = (void *)phy->base + SUNXI_USB_PMU_IRQ_ENABLE;
Hans de Goede0eccec42015-01-07 15:08:43 +0100193
194 bits = SUNXI_EHCI_AHB_ICHR8_EN |
195 SUNXI_EHCI_AHB_INCR4_BURST_EN |
196 SUNXI_EHCI_AHB_INCRX_ALIGN_EN |
197 SUNXI_EHCI_ULPI_BYPASS_EN;
198
Chen-Yu Tsai0c935ac2016-03-30 00:26:51 +0800199#ifdef CONFIG_MACH_SUN8I_A83T
200 if (phy->id == 2)
201 bits |= SUNXI_EHCI_HS_FORCE |
202 SUNXI_EHCI_CONNECT_INT |
203 SUNXI_EHCI_HSIC;
204#endif
205
Hans de Goede0eccec42015-01-07 15:08:43 +0100206 if (enable)
207 setbits_le32(addr, bits);
208 else
209 clrbits_le32(addr, bits);
210
211 return;
212}
213
Hans de Goede7b798652015-04-27 14:54:47 +0200214void sunxi_usb_phy_enable_squelch_detect(int index, int enable)
Hans de Goede246e3b82015-03-27 20:54:25 +0100215{
Chen-Yu Tsai0c935ac2016-03-30 00:26:51 +0800216#ifndef CONFIG_MACH_SUN8I_A83T
Hans de Goede7b798652015-04-27 14:54:47 +0200217 struct sunxi_usb_phy *phy = &sunxi_usb_phy[index];
Hans de Goede246e3b82015-03-27 20:54:25 +0100218
Hans de Goede7b798652015-04-27 14:54:47 +0200219 usb_phy_write(phy, 0x3c, enable ? 0 : 2, 2);
Chen-Yu Tsai0c935ac2016-03-30 00:26:51 +0800220#endif
Hans de Goede246e3b82015-03-27 20:54:25 +0100221}
222
Hans de Goede7b798652015-04-27 14:54:47 +0200223void sunxi_usb_phy_init(int index)
Hans de Goede0eccec42015-01-07 15:08:43 +0100224{
Hans de Goede7b798652015-04-27 14:54:47 +0200225 struct sunxi_usb_phy *phy = &sunxi_usb_phy[index];
Hans de Goede0eccec42015-01-07 15:08:43 +0100226 struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
227
Hans de Goedefd01ae12015-04-27 16:57:54 +0200228 phy->init_count++;
229 if (phy->init_count != 1)
230 return;
231
Hans de Goede7b798652015-04-27 14:54:47 +0200232 setbits_le32(&ccm->usb_clk_cfg, phy->usb_rst_mask);
Hans de Goede0eccec42015-01-07 15:08:43 +0100233
Hans de Goede7b798652015-04-27 14:54:47 +0200234 sunxi_usb_phy_config(phy);
Hans de Goede0eccec42015-01-07 15:08:43 +0100235
Hans de Goede7b798652015-04-27 14:54:47 +0200236 if (phy->id != 0)
Jelle van der Waadc44fd82016-02-09 23:59:33 +0100237 sunxi_usb_phy_passby(phy, SUNXI_USB_PASSBY_EN);
Chen-Yu Tsai0c935ac2016-03-30 00:26:51 +0800238
239#ifdef CONFIG_MACH_SUN8I_A83T
240 if (phy->id == 0) {
241 setbits_le32(SUNXI_USB0_BASE + SUNXI_USB_CSR,
242 SUNXI_PHY_CTL_VBUSVLDEXT);
243 clrbits_le32(SUNXI_USB0_BASE + SUNXI_USB_CSR,
244 SUNXI_PHY_CTL_SIDDQ);
245 }
246#endif
Hans de Goede0eccec42015-01-07 15:08:43 +0100247}
248
Hans de Goede7b798652015-04-27 14:54:47 +0200249void sunxi_usb_phy_exit(int index)
Hans de Goede0eccec42015-01-07 15:08:43 +0100250{
Hans de Goede7b798652015-04-27 14:54:47 +0200251 struct sunxi_usb_phy *phy = &sunxi_usb_phy[index];
Hans de Goede0eccec42015-01-07 15:08:43 +0100252 struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
253
Hans de Goedefd01ae12015-04-27 16:57:54 +0200254 phy->init_count--;
255 if (phy->init_count != 0)
256 return;
257
Hans de Goede7b798652015-04-27 14:54:47 +0200258 if (phy->id != 0)
Jelle van der Waadc44fd82016-02-09 23:59:33 +0100259 sunxi_usb_phy_passby(phy, !SUNXI_USB_PASSBY_EN);
Hans de Goede0eccec42015-01-07 15:08:43 +0100260
Chen-Yu Tsai0c935ac2016-03-30 00:26:51 +0800261#ifdef CONFIG_MACH_SUN8I_A83T
262 if (phy->id == 0) {
263 setbits_le32(SUNXI_USB0_BASE + SUNXI_USB_CSR,
264 SUNXI_PHY_CTL_SIDDQ);
265 }
266#endif
267
Hans de Goede7b798652015-04-27 14:54:47 +0200268 clrbits_le32(&ccm->usb_clk_cfg, phy->usb_rst_mask);
Hans de Goede0eccec42015-01-07 15:08:43 +0100269}
270
Hans de Goede7b798652015-04-27 14:54:47 +0200271void sunxi_usb_phy_power_on(int index)
Hans de Goede0eccec42015-01-07 15:08:43 +0100272{
Hans de Goede7b798652015-04-27 14:54:47 +0200273 struct sunxi_usb_phy *phy = &sunxi_usb_phy[index];
Hans de Goede0eccec42015-01-07 15:08:43 +0100274
Hans de Goede2c3c3ec2016-04-01 22:39:26 +0200275 if (initial_usb_scan_delay) {
276 mdelay(initial_usb_scan_delay);
277 initial_usb_scan_delay = 0;
278 }
279
Hans de Goedefd01ae12015-04-27 16:57:54 +0200280 phy->power_on_count++;
281 if (phy->power_on_count != 1)
282 return;
283
Hans de Goede7b798652015-04-27 14:54:47 +0200284 if (phy->gpio_vbus >= 0)
285 gpio_set_value(phy->gpio_vbus, 1);
Hans de Goede0eccec42015-01-07 15:08:43 +0100286}
287
Hans de Goede7b798652015-04-27 14:54:47 +0200288void sunxi_usb_phy_power_off(int index)
Hans de Goede0eccec42015-01-07 15:08:43 +0100289{
Hans de Goede7b798652015-04-27 14:54:47 +0200290 struct sunxi_usb_phy *phy = &sunxi_usb_phy[index];
Hans de Goede0eccec42015-01-07 15:08:43 +0100291
Hans de Goedefd01ae12015-04-27 16:57:54 +0200292 phy->power_on_count--;
293 if (phy->power_on_count != 0)
294 return;
295
Hans de Goede7b798652015-04-27 14:54:47 +0200296 if (phy->gpio_vbus >= 0)
297 gpio_set_value(phy->gpio_vbus, 0);
Hans de Goede0eccec42015-01-07 15:08:43 +0100298}
Paul Kocialkowskiebd468b2015-03-22 18:07:12 +0100299
Hans de Goede7b798652015-04-27 14:54:47 +0200300int sunxi_usb_phy_vbus_detect(int index)
Paul Kocialkowskiebd468b2015-03-22 18:07:12 +0100301{
Hans de Goede7b798652015-04-27 14:54:47 +0200302 struct sunxi_usb_phy *phy = &sunxi_usb_phy[index];
Hans de Goedea0e2b1b2015-03-27 21:46:00 +0100303 int err, retries = 3;
Paul Kocialkowskiebd468b2015-03-22 18:07:12 +0100304
Hans de Goede9ecce972015-06-18 18:21:33 +0200305 if (phy->gpio_vbus_det < 0)
Hans de Goede7b798652015-04-27 14:54:47 +0200306 return phy->gpio_vbus_det;
Paul Kocialkowskiebd468b2015-03-22 18:07:12 +0100307
Hans de Goede7b798652015-04-27 14:54:47 +0200308 err = gpio_get_value(phy->gpio_vbus_det);
Hans de Goedea0e2b1b2015-03-27 21:46:00 +0100309 /*
310 * Vbus may have been provided by the board and just been turned of
311 * some milliseconds ago on reset, what we're measuring then is a
312 * residual charge on Vbus, sleep a bit and try again.
313 */
314 while (err > 0 && retries--) {
315 mdelay(100);
Hans de Goede7b798652015-04-27 14:54:47 +0200316 err = gpio_get_value(phy->gpio_vbus_det);
Hans de Goedea0e2b1b2015-03-27 21:46:00 +0100317 }
318
319 return err;
Paul Kocialkowskiebd468b2015-03-22 18:07:12 +0100320}
Hans de Goedee13afee2015-04-27 16:50:04 +0200321
Hans de Goede48c06c92015-06-14 17:29:53 +0200322int sunxi_usb_phy_id_detect(int index)
323{
324 struct sunxi_usb_phy *phy = &sunxi_usb_phy[index];
325
326 if (phy->gpio_id_det < 0)
327 return phy->gpio_id_det;
328
329 return gpio_get_value(phy->gpio_id_det);
330}
331
Hans de Goedee13afee2015-04-27 16:50:04 +0200332int sunxi_usb_phy_probe(void)
333{
334 struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
335 struct sunxi_usb_phy *phy;
336 int i, ret = 0;
337
338 for (i = 0; i < CONFIG_SUNXI_USB_PHYS; i++) {
339 phy = &sunxi_usb_phy[i];
340
341 phy->gpio_vbus = get_vbus_gpio(i);
342 if (phy->gpio_vbus >= 0) {
343 ret = gpio_request(phy->gpio_vbus, "usb_vbus");
344 if (ret)
345 return ret;
346 ret = gpio_direction_output(phy->gpio_vbus, 0);
347 if (ret)
348 return ret;
349 }
350
351 phy->gpio_vbus_det = get_vbus_detect_gpio(i);
352 if (phy->gpio_vbus_det >= 0) {
353 ret = gpio_request(phy->gpio_vbus_det, "usb_vbus_det");
354 if (ret)
355 return ret;
356 ret = gpio_direction_input(phy->gpio_vbus_det);
357 if (ret)
358 return ret;
359 }
Hans de Goede48c06c92015-06-14 17:29:53 +0200360
361 phy->gpio_id_det = get_id_detect_gpio(i);
362 if (phy->gpio_id_det >= 0) {
363 ret = gpio_request(phy->gpio_id_det, "usb_id_det");
364 if (ret)
365 return ret;
366 ret = gpio_direction_input(phy->gpio_id_det);
367 if (ret)
368 return ret;
369 sunxi_gpio_set_pull(phy->gpio_id_det,
370 SUNXI_GPIO_PULL_UP);
371 }
Hans de Goedee13afee2015-04-27 16:50:04 +0200372 }
373
374 setbits_le32(&ccm->usb_clk_cfg, CCM_USB_CTRL_PHYGATE);
375
376 return 0;
377}
378
379int sunxi_usb_phy_remove(void)
380{
381 struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
382 struct sunxi_usb_phy *phy;
383 int i;
384
385 clrbits_le32(&ccm->usb_clk_cfg, CCM_USB_CTRL_PHYGATE);
386
387 for (i = 0; i < CONFIG_SUNXI_USB_PHYS; i++) {
388 phy = &sunxi_usb_phy[i];
389
390 if (phy->gpio_vbus >= 0)
391 gpio_free(phy->gpio_vbus);
392
393 if (phy->gpio_vbus_det >= 0)
394 gpio_free(phy->gpio_vbus_det);
Hans de Goede48c06c92015-06-14 17:29:53 +0200395
396 if (phy->gpio_id_det >= 0)
397 gpio_free(phy->gpio_id_det);
Hans de Goedee13afee2015-04-27 16:50:04 +0200398 }
399
400 return 0;
401}