drivers/usb/gadget/udc/aspeed-vhub/hub.c
Source file repositories/reference/linux-study-clean/drivers/usb/gadget/udc/aspeed-vhub/hub.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/gadget/udc/aspeed-vhub/hub.c- Extension
.c- Size
- 27884 bytes
- Lines
- 1083
- Domain
- Driver Families
- Bucket
- drivers/usb
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/module.hlinux/platform_device.hlinux/delay.hlinux/ioport.hlinux/slab.hlinux/errno.hlinux/list.hlinux/interrupt.hlinux/proc_fs.hlinux/prefetch.hlinux/clk.hlinux/usb/gadget.hlinux/of.hlinux/regmap.hlinux/string_choices.hlinux/dma-mapping.hlinux/bcd.hlinux/version.hlinux/usb.hlinux/usb/hcd.hvhub.h
Detected Declarations
function ast_vhub_hub_dev_statusfunction ast_vhub_hub_ep_statusfunction ast_vhub_hub_dev_featurefunction ast_vhub_hub_ep_featurefunction ast_vhub_rep_descfunction ast_vhub_str_of_containerfunction ast_vhub_collect_languagesfunction list_for_each_entryfunction ast_vhub_rep_stringfunction ast_vhub_std_hub_requestfunction ast_vhub_update_hub_ep1function ast_vhub_change_port_statfunction ast_vhub_send_host_wakeupfunction ast_vhub_device_connectfunction ast_vhub_wake_workfunction ast_vhub_hub_wake_allfunction ast_vhub_port_resetfunction ast_vhub_set_port_featurefunction ast_vhub_clr_port_featurefunction ast_vhub_get_port_statfunction ast_vhub_class_hub_requestfunction ast_vhub_hub_suspendfunction ast_vhub_hub_resumefunction ast_vhub_hub_resetfunction ast_vhub_of_parse_dev_descfunction ast_vhub_fixup_usb1_dev_descfunction ast_vhub_str_container_allocfunction ast_vhub_str_deep_copyfunction ast_vhub_str_alloc_addfunction ast_vhub_of_parse_str_descfunction for_each_child_of_nodefunction ast_vhub_init_descfunction ast_vhub_init_hub
Annotated Snippet
switch (wValue >> 8) {
case USB_DT_DEVICE:
case USB_DT_CONFIG:
case USB_DT_DEVICE_QUALIFIER:
case USB_DT_OTHER_SPEED_CONFIG:
return ast_vhub_rep_desc(ep, wValue >> 8,
wLength);
case USB_DT_STRING:
return ast_vhub_rep_string(ep, wValue & 0xff,
wIndex, wLength);
}
return std_req_stall;
/* GET/SET_INTERFACE */
case DeviceRequest | USB_REQ_GET_INTERFACE:
return ast_vhub_simple_reply(ep, 0);
case DeviceOutRequest | USB_REQ_SET_INTERFACE:
if (wValue != 0 || wIndex != 0)
return std_req_stall;
return std_req_complete;
}
return std_req_stall;
}
static void ast_vhub_update_hub_ep1(struct ast_vhub *vhub,
unsigned int port)
{
/* Update HW EP1 response */
u32 reg = readl(vhub->regs + AST_VHUB_EP1_STS_CHG);
u32 pmask = (1 << (port + 1));
if (vhub->ports[port].change)
reg |= pmask;
else
reg &= ~pmask;
writel(reg, vhub->regs + AST_VHUB_EP1_STS_CHG);
}
static void ast_vhub_change_port_stat(struct ast_vhub *vhub,
unsigned int port,
u16 clr_flags,
u16 set_flags,
bool set_c)
{
struct ast_vhub_port *p = &vhub->ports[port];
u16 prev;
/* Update port status */
prev = p->status;
p->status = (prev & ~clr_flags) | set_flags;
DDBG(&p->dev, "port %d status %04x -> %04x (C=%d)\n",
port + 1, prev, p->status, set_c);
/* Update change bits if needed */
if (set_c) {
u16 chg = p->status ^ prev;
/* Only these are relevant for change */
chg &= USB_PORT_STAT_C_CONNECTION |
USB_PORT_STAT_C_ENABLE |
USB_PORT_STAT_C_SUSPEND |
USB_PORT_STAT_C_OVERCURRENT |
USB_PORT_STAT_C_RESET |
USB_PORT_STAT_C_L1;
/*
* We only set USB_PORT_STAT_C_ENABLE if we are disabling
* the port as per USB spec, otherwise MacOS gets upset
*/
if (p->status & USB_PORT_STAT_ENABLE)
chg &= ~USB_PORT_STAT_C_ENABLE;
p->change = chg;
ast_vhub_update_hub_ep1(vhub, port);
}
}
static void ast_vhub_send_host_wakeup(struct ast_vhub *vhub)
{
u32 reg = readl(vhub->regs + AST_VHUB_CTRL);
UDCDBG(vhub, "Waking up host !\n");
reg |= VHUB_CTRL_MANUAL_REMOTE_WAKEUP;
writel(reg, vhub->regs + AST_VHUB_CTRL);
}
void ast_vhub_device_connect(struct ast_vhub *vhub,
unsigned int port, bool on)
{
if (on)
ast_vhub_change_port_stat(vhub, port, 0,
USB_PORT_STAT_CONNECTION, true);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/platform_device.h`, `linux/delay.h`, `linux/ioport.h`, `linux/slab.h`, `linux/errno.h`, `linux/list.h`.
- Detected declarations: `function ast_vhub_hub_dev_status`, `function ast_vhub_hub_ep_status`, `function ast_vhub_hub_dev_feature`, `function ast_vhub_hub_ep_feature`, `function ast_vhub_rep_desc`, `function ast_vhub_str_of_container`, `function ast_vhub_collect_languages`, `function list_for_each_entry`, `function ast_vhub_rep_string`, `function ast_vhub_std_hub_request`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.