drivers/usb/gadget/udc/renesas_usb3.c
Source file repositories/reference/linux-study-clean/drivers/usb/gadget/udc/renesas_usb3.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/gadget/udc/renesas_usb3.c- Extension
.c- Size
- 79282 bytes
- Lines
- 3030
- Domain
- Driver Families
- Bucket
- drivers/usb
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/debugfs.hlinux/delay.hlinux/device.hlinux/dma-mapping.hlinux/err.hlinux/extcon-provider.hlinux/interrupt.hlinux/io.hlinux/module.hlinux/of.hlinux/phy/phy.hlinux/platform_device.hlinux/pm_runtime.hlinux/reset.hlinux/sizes.hlinux/slab.hlinux/string.hlinux/uaccess.hlinux/usb/ch9.hlinux/usb/gadget.hlinux/usb/of.hlinux/usb/role.hlinux/usb/rzv2m_usb3drd.h
Detected Declarations
struct renesas_usb3struct renesas_usb3_prdstruct renesas_usb3_dmastruct renesas_usb3_requeststruct renesas_usb3_epstruct renesas_usb3_privstruct renesas_usb3function usb3_writefunction usb3_readfunction usb3_set_bitfunction usb3_clear_bitfunction usb3_drd_writefunction usb3_drd_readfunction usb3_drd_set_bitfunction usb3_drd_clear_bitfunction usb3_waitfunction renesas_usb3_extcon_workfunction usb3_enable_irq_1function usb3_disable_irq_1function usb3_enable_pipe_irqfunction usb3_disable_pipe_irqfunction usb3_is_hostfunction usb3_init_axi_bridgefunction usb3_init_epc_registersfunction usb3_wakeup_usb2_phyfunction usb3_usb2_pullupfunction usb3_set_test_modefunction usb3_start_usb2_connectionfunction usb3_is_usb3_phy_in_u3function usb3_wakeup_usb3_phyfunction usb3_feature_get_un_enabledfunction usb3_feature_u2_enablefunction usb3_feature_u1_enablefunction usb3_start_operation_for_usb3function usb3_start_usb3_connectionfunction usb3_stop_usb3_connectionfunction usb3_transition_to_default_statefunction usb3_connectfunction usb3_reset_epcfunction usb3_disconnectfunction usb3_check_vbusfunction renesas_usb3_role_workfunction usb3_set_modefunction usb3_set_mode_by_role_swfunction usb3_vbus_outfunction usb3_mode_configfunction usb3_is_a_devicefunction usb3_check_id
Annotated Snippet
static const struct file_operations renesas_usb3_b_device_fops = {
.open = renesas_usb3_b_device_open,
.write = renesas_usb3_b_device_write,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static void renesas_usb3_debugfs_init(struct renesas_usb3 *usb3,
struct device *dev)
{
usb3->dentry = debugfs_create_dir(dev_name(dev), usb_debug_root);
debugfs_create_file("b_device", 0644, usb3->dentry, usb3,
&renesas_usb3_b_device_fops);
}
/*------- platform_driver ------------------------------------------------*/
static void renesas_usb3_remove(struct platform_device *pdev)
{
struct renesas_usb3 *usb3 = platform_get_drvdata(pdev);
debugfs_remove_recursive(usb3->dentry);
put_device(usb3->host_dev);
device_remove_file(&pdev->dev, &dev_attr_role);
cancel_work_sync(&usb3->role_work);
usb_role_switch_unregister(usb3->role_sw);
usb_del_gadget_udc(&usb3->gadget);
reset_control_assert(usb3->usbp_rstc);
renesas_usb3_dma_free_prd(usb3, &pdev->dev);
__renesas_usb3_ep_free_request(usb3->ep0_req);
pm_runtime_disable(&pdev->dev);
}
static int renesas_usb3_init_ep(struct renesas_usb3 *usb3, struct device *dev,
const struct renesas_usb3_priv *priv)
{
struct renesas_usb3_ep *usb3_ep;
int i;
/* calculate num_usb3_eps from renesas_usb3_priv */
usb3->num_usb3_eps = priv->ramsize_per_ramif * priv->num_ramif * 2 /
priv->ramsize_per_pipe + 1;
if (usb3->num_usb3_eps > USB3_MAX_NUM_PIPES(usb3))
usb3->num_usb3_eps = USB3_MAX_NUM_PIPES(usb3);
usb3->usb3_ep = devm_kcalloc(dev,
usb3->num_usb3_eps, sizeof(*usb3_ep),
GFP_KERNEL);
if (!usb3->usb3_ep)
return -ENOMEM;
dev_dbg(dev, "%s: num_usb3_eps = %d\n", __func__, usb3->num_usb3_eps);
/*
* This driver prepares pipes as follows:
* - odd pipes = IN pipe
* - even pipes = OUT pipe (except pipe 0)
*/
usb3_for_each_ep(usb3_ep, usb3, i) {
snprintf(usb3_ep->ep_name, sizeof(usb3_ep->ep_name), "ep%d", i);
usb3_ep->usb3 = usb3;
usb3_ep->num = i;
usb3_ep->ep.name = usb3_ep->ep_name;
usb3_ep->ep.ops = &renesas_usb3_ep_ops;
INIT_LIST_HEAD(&usb3_ep->queue);
INIT_LIST_HEAD(&usb3_ep->ep.ep_list);
if (!i) {
/* for control pipe */
usb3->gadget.ep0 = &usb3_ep->ep;
usb_ep_set_maxpacket_limit(&usb3_ep->ep,
USB3_EP0_SS_MAX_PACKET_SIZE);
usb3_ep->ep.caps.type_control = true;
usb3_ep->ep.caps.dir_in = true;
usb3_ep->ep.caps.dir_out = true;
continue;
}
/* for bulk or interrupt pipe */
usb_ep_set_maxpacket_limit(&usb3_ep->ep, ~0);
list_add_tail(&usb3_ep->ep.ep_list, &usb3->gadget.ep_list);
usb3_ep->ep.caps.type_bulk = true;
usb3_ep->ep.caps.type_int = true;
if (i & 1)
usb3_ep->ep.caps.dir_in = true;
else
usb3_ep->ep.caps.dir_out = true;
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/delay.h`, `linux/device.h`, `linux/dma-mapping.h`, `linux/err.h`, `linux/extcon-provider.h`, `linux/interrupt.h`, `linux/io.h`.
- Detected declarations: `struct renesas_usb3`, `struct renesas_usb3_prd`, `struct renesas_usb3_dma`, `struct renesas_usb3_request`, `struct renesas_usb3_ep`, `struct renesas_usb3_priv`, `struct renesas_usb3`, `function usb3_write`, `function usb3_read`, `function usb3_set_bit`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.