Skip to content

Commit 3d804c1

Browse files
committed
Add support for Raspberry Pi 5
Added hack to support Raspberry Pi 5. Updated README with recipe how to control power on RPi5. Closes #547.
1 parent 3e86729 commit 3d804c1

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

README.md

+30
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ This is list of known compatible USB hubs:
105105
| Raspberry Pi | B+, 2B, 3B ([see below](#raspberry-pi-b2b3b)) | 4 | 2.0 | | 2011 | |
106106
| Raspberry Pi | 3B+ ([see below](#raspberry-pi-3b)) | 4 | 2.0 |`0424:2514`| 2018 | |
107107
| Raspberry Pi | 4B ([see below](#raspberry-pi-4b)) | 4 | 3.0 |`2109:3431`| 2019 | |
108+
| Raspberry Pi | 5 ([see below](#raspberry-pi-5)) | 4 | 3.0 |`1d6b:0002`| 2023 | |
108109
| Renesas | uPD720202 PCIe USB 3.0 host controller | 2 | 3.0 | | 2013 | |
109110
| Rosewill | RHUB-210 | 4 | 2.0 |`0409:005A`| 2011 | 2014 |
110111
| Rosonway | RSH-518C ([note](https://bit.ly/3kYZUsA)) | 7 | 3.0 |`2109:0817`| 2021 | |
@@ -415,7 +416,36 @@ to make power switching work on RPi 4B.
415416

416417
* USB2 hub `3`, 1 port, OTG controller. Power switching is [not supported](https://git.io/JUc5Q).
417418

419+
##### Raspberry Pi 5
418420

421+
Raspberry Pi 5 has two USB2 ports and two USB3 ports (total 4).
422+
These ports are connected to 4 distinct USB hubs `1`,`2`,`3`,`4` in really weird configuration.
423+
If USB3 device is connected to blue socket, it will be detected on USB3 hub `2` or `4`.
424+
If USB2 device is connected to any socket or USB3 device connected to black socket,
425+
it will be detected on USB2 hub `1` or `3`.
426+
Regardless of USB2/USB3 connection type, blue sockets are always port `1`,
427+
and black sockets are always port `2`.
428+
429+
Each of 4 USB onboard hubs advertises as supporting per-port power switching, but this is not true.
430+
In reality, Raspberry Pi 5 all 4 ports are ganged together in one group,
431+
despite belonging to 4 different logical USB hubs.
432+
433+
To turn off VBUS power it has to be disabled across all onboard hubs and ports with:
434+
435+
```
436+
uhubctl -l 1 -a 0
437+
uhubctl -l 3 -a 0
438+
```
439+
440+
To turn it back on:
441+
442+
```
443+
uhubctl -l 1 -a 1
444+
uhubctl -l 3 -a 1
445+
```
446+
447+
Note that VBUS power goes down only if all ports are off -
448+
enabling any single port enables VBUS back for all 4 ports.
419449

420450
Notable projects using uhubctl
421451
==============================

uhubctl.c

+27
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,32 @@ static int get_hub_info(struct libusb_device *dev, struct hub_info *info)
490490
lpsm = HUB_CHAR_INDV_PORT_LPSM;
491491
}
492492
info->lpsm = lpsm;
493+
494+
/* Raspberry Pi 5 hack */
495+
496+
/* TODO: make this hack more reliable by querying Raspberry Pi model */
497+
498+
if (strlen(info->container_id)==0 &&
499+
info->lpsm==HUB_CHAR_INDV_PORT_LPSM &&
500+
info->pn_len==0)
501+
{
502+
/* USB2 */
503+
if (strcasecmp(info->vendor, "1d6b:0002")==0 &&
504+
info->nports==2 &&
505+
!info->super_speed &&
506+
(info->bus==1 || info->bus==3))
507+
{
508+
strcpy(info->container_id, "Raspberry Pi 5 Fake Container Id");
509+
}
510+
/* USB3 */
511+
if (strcasecmp(info->vendor, "1d6b:0003")==0 &&
512+
info->nports==1 &&
513+
info->super_speed &&
514+
(info->bus==2 || info->bus==4))
515+
{
516+
strcpy(info->container_id, "Raspberry Pi 5 Fake Container Id");
517+
}
518+
}
493519
rc = 0;
494520
} else {
495521
rc = len;
@@ -685,6 +711,7 @@ static int get_device_description(struct libusb_device * dev, struct descriptor_
685711
}
686712
if (desc.bDeviceClass == LIBUSB_CLASS_HUB) {
687713
struct hub_info info;
714+
bzero(&info, sizeof(info));
688715
rc = get_hub_info(dev, &info);
689716
if (rc == 0) {
690717
const char * lpsm_type;

0 commit comments

Comments
 (0)