1 // SPDX-License-Identifier: GPL-2.0-only
3 * Driver for onboard USB hubs
5 * Copyright (C) 2022, STMicroelectronics - All Rights Reserved
7 * Mostly inspired by Linux kernel v6.1 onboard_usb_hub driver
12 #include <dm/device_compat.h>
13 #include <power/regulator.h>
19 static int usb_onboard_hub_probe(struct udevice *dev)
21 struct onboard_hub *hub = dev_get_priv(dev);
24 ret = device_get_supply_regulator(dev, "vdd-supply", &hub->vdd);
26 dev_err(dev, "can't get vdd-supply: %d\n", ret);
30 ret = regulator_set_enable_if_allowed(hub->vdd, true);
32 dev_err(dev, "can't enable vdd-supply: %d\n", ret);
37 static int usb_onboard_hub_remove(struct udevice *dev)
39 struct onboard_hub *hub = dev_get_priv(dev);
42 ret = regulator_set_enable_if_allowed(hub->vdd, false);
44 dev_err(dev, "can't disable vdd-supply: %d\n", ret);
49 static const struct udevice_id usb_onboard_hub_ids[] = {
50 /* Use generic usbVID,PID dt-bindings (usb-device.yaml) */
51 { .compatible = "usb424,2514" }, /* USB2514B USB 2.0 */
55 U_BOOT_DRIVER(usb_onboard_hub) = {
56 .name = "usb_onboard_hub",
58 .probe = usb_onboard_hub_probe,
59 .remove = usb_onboard_hub_remove,
60 .of_match = usb_onboard_hub_ids,
61 .priv_auto = sizeof(struct onboard_hub),