Skip to content

Commit 9065c70

Browse files
dberlinmarcan
authored andcommitted
Workaround lack of SPMI support in usb.c
M3+ have a new USB power controller and it works over SPMI. However, the USB ports work (at least within m1n1) if we ignore this and just init the phys directly. This detects the case where we are not on an I2C based USB machine, and initializes the phys directly. Eventually we should support SPMI properly. Signed-off-By: Daniel Berlin <[email protected]>
1 parent b50b17c commit 9065c70

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/usb.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "iodev.h"
88
#include "malloc.h"
99
#include "pmgr.h"
10+
#include "string.h"
1011
#include "tps6598x.h"
1112
#include "types.h"
1213
#include "usb_dwc3.h"
@@ -228,13 +229,30 @@ static tps6598x_dev_t *hpm_init(i2c_dev_t *i2c, const char *hpm_path)
228229
return tps;
229230
}
230231

232+
void usb_spmi_init(void)
233+
{
234+
for (int idx = 0; idx < USB_IODEV_COUNT; ++idx)
235+
usb_phy_bringup(idx); /* Fails on missing devices, just continue */
236+
237+
usb_is_initialized = true;
238+
}
239+
231240
void usb_init(void)
232241
{
233242
char hpm_path[sizeof(FMT_HPM_PATH)];
234243

235244
if (usb_is_initialized)
236245
return;
237246

247+
/*
248+
* M3 models do not use i2c, but instead SPMI with a new controller.
249+
* We can get USB going for now by just bringing up the phys.
250+
*/
251+
if (adt_path_offset(adt, "/arm-io/nub-spmi-a0/hpm0") != 0) {
252+
usb_spmi_init();
253+
return;
254+
}
255+
238256
i2c_dev_t *i2c = i2c_init("/arm-io/i2c0");
239257
if (!i2c) {
240258
printf("usb: i2c init failed.\n");

0 commit comments

Comments
 (0)