Commit 2aa416332933fb05615223a31a415e0c90565f73
Committed by
Ji Luo
1 parent
7191db0835
Exists in
smarc_8mm-imx_v2018.03_4.14.98_2.0.0_ga
and in
4 other branches
MA-14521 AIY: Explicitly set USB Switch (PTN5150A) to UFP
* The default configuration (via resistor stuffing) is DFP (host). This means that on Type-C hosts fastboot won't work. * Set to UFP to ensure fastboot works properly. Change-Id: I2b63d95e08df70da43dee1f8f7bb59d1863943f4
Showing 1 changed file with 46 additions and 0 deletions Side-by-side Diff
board/freescale/imx8mq_aiy/imx8m_aiy.c
... | ... | @@ -24,6 +24,8 @@ |
24 | 24 | #include <power/pmic.h> |
25 | 25 | #include <usb.h> |
26 | 26 | #include <dwc3-uboot.h> |
27 | +#include <dm.h> | |
28 | +#include <i2c.h> | |
27 | 29 | |
28 | 30 | DECLARE_GLOBAL_DATA_PTR; |
29 | 31 | |
... | ... | @@ -274,6 +276,11 @@ |
274 | 276 | #define USB_PHY_CTRL2 0xF0048 |
275 | 277 | #define USB_PHY_CTRL2_TXENABLEN0 BIT(8) |
276 | 278 | |
279 | +#define PTN5150A_BUS 2 | |
280 | +#define PTN5150A_ADDR 0x3D | |
281 | +#define PTN5150A_CONTROL 0x2 | |
282 | +#define PTN5150A_CONTROL_PORT_MASK 0x6 | |
283 | + | |
277 | 284 | static struct dwc3_device dwc3_device_data = { |
278 | 285 | #ifdef CONFIG_SPL_BUILD |
279 | 286 | .maximum_speed = USB_SPEED_HIGH, |
280 | 287 | |
281 | 288 | |
... | ... | @@ -314,12 +321,51 @@ |
314 | 321 | RegData &= ~(USB_PHY_CTRL1_RESET | USB_PHY_CTRL1_ATERESET); |
315 | 322 | writel(RegData, dwc3->base + USB_PHY_CTRL1); |
316 | 323 | } |
324 | + | |
325 | +#ifndef CONFIG_SPL_BUILD | |
326 | +static void configure_cc_switch() { | |
327 | + uint8_t value; | |
328 | + int ret; | |
329 | + struct udevice *bus, *dev; | |
330 | + | |
331 | + ret = uclass_get_device_by_seq(UCLASS_I2C, PTN5150A_BUS, &bus); | |
332 | + if (ret) { | |
333 | + printf("%s: No bus %d\n", __func__, PTN5150A_BUS); | |
334 | + return; | |
335 | + } | |
336 | + | |
337 | + ret = dm_i2c_probe(bus, PTN5150A_ADDR, 0, &dev); | |
338 | + if (ret) { | |
339 | + printf("%s: Can't find device id=0x%x, on bus %d\n", | |
340 | + __func__, PTN5150A_ADDR, PTN5150A_BUS); | |
341 | + return; | |
342 | + } | |
343 | + | |
344 | + if (dm_i2c_read(dev, PTN5150A_CONTROL, &value, 1)) { | |
345 | + printf("Unable to configure USB switch"); | |
346 | + return; | |
347 | + } | |
348 | + | |
349 | + value &= ~PTN5150A_CONTROL_PORT_MASK; | |
350 | + if (dm_i2c_write(dev, PTN5150A_CONTROL, &value, 1)) { | |
351 | + printf("Unable to configure USB switch"); | |
352 | + return; | |
353 | + } | |
354 | + printf("Configured USB Switch for UFP\n"); | |
355 | +} | |
317 | 356 | #endif |
357 | +#endif | |
318 | 358 | |
319 | 359 | #if defined(CONFIG_USB_DWC3) || defined(CONFIG_USB_XHCI_IMX8M) |
320 | 360 | int board_usb_init(int index, enum usb_init_type init) |
321 | 361 | { |
322 | 362 | imx8m_usb_power(index, true); |
363 | + | |
364 | +#ifndef CONFIG_SPL_BUILD | |
365 | + /* Explicitly set USB switch to UFP (device) to ensure proper | |
366 | + *fastboot operation on type-C ports. */ | |
367 | + configure_cc_switch(); | |
368 | +#endif | |
323 | 369 | |
324 | 370 | if (index == 0 && init == USB_INIT_DEVICE) { |
325 | 371 | dwc3_nxp_usb_phy_init(&dwc3_device_data); |