Skip to content

Commit

Permalink
Workaround lack of SPMI support in usb.c
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
dberlin authored and marcan committed Dec 3, 2023
1 parent b50b17c commit 9065c70
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "iodev.h"
#include "malloc.h"
#include "pmgr.h"
#include "string.h"
#include "tps6598x.h"
#include "types.h"
#include "usb_dwc3.h"
Expand Down Expand Up @@ -228,13 +229,30 @@ static tps6598x_dev_t *hpm_init(i2c_dev_t *i2c, const char *hpm_path)
return tps;
}

void usb_spmi_init(void)
{
for (int idx = 0; idx < USB_IODEV_COUNT; ++idx)
usb_phy_bringup(idx); /* Fails on missing devices, just continue */

usb_is_initialized = true;
}

void usb_init(void)
{
char hpm_path[sizeof(FMT_HPM_PATH)];

if (usb_is_initialized)
return;

/*
* M3 models do not use i2c, but instead SPMI with a new controller.
* We can get USB going for now by just bringing up the phys.
*/
if (adt_path_offset(adt, "/arm-io/nub-spmi-a0/hpm0") != 0) {
usb_spmi_init();
return;
}

i2c_dev_t *i2c = i2c_init("/arm-io/i2c0");
if (!i2c) {
printf("usb: i2c init failed.\n");
Expand Down

0 comments on commit 9065c70

Please sign in to comment.