drivers/usb/mtu3/mtu3_plat.c
Source file repositories/reference/linux-study-clean/drivers/usb/mtu3/mtu3_plat.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/mtu3/mtu3_plat.c- Extension
.c- Size
- 14511 bytes
- Lines
- 635
- 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.
- 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/dma-mapping.hlinux/iopoll.hlinux/kernel.hlinux/module.hlinux/of_address.hlinux/of_irq.hlinux/platform_device.hlinux/pm_wakeirq.hlinux/reset.hmtu3.hmtu3_dr.hmtu3_debug.h
Detected Declarations
function ssusb_check_clocksfunction wait_for_ip_sleepfunction ssusb_phy_initfunction ssusb_phy_exitfunction ssusb_phy_power_onfunction ssusb_phy_power_offfunction ssusb_rscs_initfunction ssusb_rscs_exitfunction ssusb_ip_sw_resetfunction ssusb_u3_drd_checkfunction get_ssusb_rscsfunction mtu3_probefunction mtu3_removefunction resume_ip_and_portsfunction mtu3_suspend_commonfunction mtu3_resume_commonfunction mtu3_suspendfunction mtu3_resumefunction mtu3_runtime_suspendfunction mtu3_runtime_resume
Annotated Snippet
if (IS_ERR(ssusb->phys[i])) {
dev_err(dev, "failed to get phy-%d\n", i);
return PTR_ERR(ssusb->phys[i]);
}
}
ssusb->ippc_base = devm_platform_ioremap_resource_byname(pdev, "ippc");
if (IS_ERR(ssusb->ippc_base))
return PTR_ERR(ssusb->ippc_base);
ssusb->wakeup_irq = platform_get_irq_byname_optional(pdev, "wakeup");
if (ssusb->wakeup_irq == -EPROBE_DEFER)
return ssusb->wakeup_irq;
ssusb->dr_mode = usb_get_dr_mode(dev);
if (ssusb->dr_mode == USB_DR_MODE_UNKNOWN)
ssusb->dr_mode = USB_DR_MODE_OTG;
of_property_read_u32(node, "mediatek,u3p-dis-msk", &ssusb->u3p_dis_msk);
if (ssusb->dr_mode == USB_DR_MODE_PERIPHERAL)
goto out;
/* if host role is supported */
ret = ssusb_wakeup_of_property_parse(ssusb, node);
if (ret) {
dev_err(dev, "failed to parse uwk property\n");
return ret;
}
/* optional property, ignore the error if it does not exist */
of_property_read_u32(node, "mediatek,u2p-dis-msk",
&ssusb->u2p_dis_msk);
otg_sx->vbus = devm_regulator_get(dev, "vbus");
if (IS_ERR(otg_sx->vbus)) {
dev_err(dev, "failed to get vbus\n");
return PTR_ERR(otg_sx->vbus);
}
if (ssusb->dr_mode == USB_DR_MODE_HOST)
goto out;
/* if dual-role mode is supported */
otg_sx->manual_drd_enabled =
of_property_read_bool(node, "enable-manual-drd");
otg_sx->role_sw_used = of_property_read_bool(node, "usb-role-switch");
/* can't disable port0 when use dual-role mode */
ssusb->u2p_dis_msk &= ~0x1;
if (otg_sx->role_sw_used || otg_sx->manual_drd_enabled)
goto out;
if (of_property_present(node, "extcon")) {
otg_sx->edev = extcon_get_edev_by_phandle(ssusb->dev, 0);
if (IS_ERR(otg_sx->edev)) {
return dev_err_probe(dev, PTR_ERR(otg_sx->edev),
"couldn't get extcon device\n");
}
}
out:
dev_info(dev, "dr_mode: %d, drd: %s\n", ssusb->dr_mode,
otg_sx->manual_drd_enabled ? "manual" : "auto");
dev_info(dev, "u2p_dis_msk: %x, u3p_dis_msk: %x\n",
ssusb->u2p_dis_msk, ssusb->u3p_dis_msk);
return 0;
}
static int mtu3_probe(struct platform_device *pdev)
{
struct device_node *node = pdev->dev.of_node;
struct device *dev = &pdev->dev;
struct ssusb_mtk *ssusb;
int ret = -ENOMEM;
/* all elements are set to ZERO as default value */
ssusb = devm_kzalloc(dev, sizeof(*ssusb), GFP_KERNEL);
if (!ssusb)
return -ENOMEM;
ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
if (ret) {
dev_err(dev, "No suitable DMA config available\n");
return -ENOTSUPP;
}
platform_set_drvdata(pdev, ssusb);
Annotation
- Immediate include surface: `linux/dma-mapping.h`, `linux/iopoll.h`, `linux/kernel.h`, `linux/module.h`, `linux/of_address.h`, `linux/of_irq.h`, `linux/platform_device.h`, `linux/pm_wakeirq.h`.
- Detected declarations: `function ssusb_check_clocks`, `function wait_for_ip_sleep`, `function ssusb_phy_init`, `function ssusb_phy_exit`, `function ssusb_phy_power_on`, `function ssusb_phy_power_off`, `function ssusb_rscs_init`, `function ssusb_rscs_exit`, `function ssusb_ip_sw_reset`, `function ssusb_u3_drd_check`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: source implementation candidate.
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.