Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround new USB using SPMI instead of I2C #365

Merged
merged 1 commit into from
Dec 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading