drivers/usb/dwc2/platform.c
Source file repositories/reference/linux-study-clean/drivers/usb/dwc2/platform.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/dwc2/platform.c- Extension
.c- Size
- 20762 bytes
- Lines
- 812
- 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.
- 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/kernel.hlinux/module.hlinux/slab.hlinux/clk.hlinux/device.hlinux/dma-mapping.hlinux/of.hlinux/mutex.hlinux/platform_device.hlinux/phy/phy.hlinux/platform_data/s3c-hsotg.hlinux/reset.hlinux/usb/of.hcore.hhcd.hdebug.h
Detected Declarations
function dwc2_get_dr_modefunction __dwc2_lowlevel_hw_enablefunction dwc2_lowlevel_hw_enablefunction __dwc2_lowlevel_hw_disablefunction dwc2_lowlevel_hw_disablefunction dwc2_reset_control_assertfunction dwc2_lowlevel_hw_initfunction dwc2_driver_removefunction dwc2_driver_shutdownfunction dwc2_check_core_endiannessfunction dwc2_check_core_versionfunction dwc2_driver_probefunction dwc2_suspendfunction dwc2_restore_critical_registersfunction dwc2_resume
Annotated Snippet
if (IS_ENABLED(CONFIG_USB_DWC2_HOST)) {
dev_err(hsotg->dev,
"Controller does not support host mode.\n");
return -EINVAL;
}
mode = USB_DR_MODE_PERIPHERAL;
} else if (dwc2_hw_is_host(hsotg)) {
if (IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL)) {
dev_err(hsotg->dev,
"Controller does not support device mode.\n");
return -EINVAL;
}
mode = USB_DR_MODE_HOST;
} else {
if (IS_ENABLED(CONFIG_USB_DWC2_HOST))
mode = USB_DR_MODE_HOST;
else if (IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL))
mode = USB_DR_MODE_PERIPHERAL;
}
if (mode != hsotg->dr_mode) {
dev_warn(hsotg->dev,
"Configuration mismatch. dr_mode forced to %s\n",
mode == USB_DR_MODE_HOST ? "host" : "device");
hsotg->dr_mode = mode;
}
return 0;
}
static int __dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg)
{
struct platform_device *pdev = to_platform_device(hsotg->dev);
int ret;
ret = regulator_bulk_enable(ARRAY_SIZE(hsotg->supplies),
hsotg->supplies);
if (ret)
return ret;
if (hsotg->utmi_clk) {
ret = clk_prepare_enable(hsotg->utmi_clk);
if (ret)
goto err_dis_reg;
}
if (hsotg->clk) {
ret = clk_prepare_enable(hsotg->clk);
if (ret)
goto err_dis_utmi_clk;
}
if (hsotg->uphy) {
ret = usb_phy_init(hsotg->uphy);
} else if (hsotg->plat && hsotg->plat->phy_init) {
ret = hsotg->plat->phy_init(pdev, hsotg->plat->phy_type);
} else {
ret = phy_init(hsotg->phy);
if (ret == 0) {
ret = phy_power_on(hsotg->phy);
if (ret)
phy_exit(hsotg->phy);
}
}
if (ret)
goto err_dis_clk;
return 0;
err_dis_clk:
if (hsotg->clk)
clk_disable_unprepare(hsotg->clk);
err_dis_utmi_clk:
if (hsotg->utmi_clk)
clk_disable_unprepare(hsotg->utmi_clk);
err_dis_reg:
regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies), hsotg->supplies);
return ret;
}
/**
* dwc2_lowlevel_hw_enable - enable platform lowlevel hw resources
* @hsotg: The driver state
*
* A wrapper for platform code responsible for controlling
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/slab.h`, `linux/clk.h`, `linux/device.h`, `linux/dma-mapping.h`, `linux/of.h`, `linux/mutex.h`.
- Detected declarations: `function dwc2_get_dr_mode`, `function __dwc2_lowlevel_hw_enable`, `function dwc2_lowlevel_hw_enable`, `function __dwc2_lowlevel_hw_disable`, `function dwc2_lowlevel_hw_disable`, `function dwc2_reset_control_assert`, `function dwc2_lowlevel_hw_init`, `function dwc2_driver_remove`, `function dwc2_driver_shutdown`, `function dwc2_check_core_endianness`.
- 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.
- 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.