drivers/usb/dwc3/dwc3-of-simple.c
Source file repositories/reference/linux-study-clean/drivers/usb/dwc3/dwc3-of-simple.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/dwc3/dwc3-of-simple.c- Extension
.c- Size
- 5076 bytes
- Lines
- 197
- 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/module.hlinux/kernel.hlinux/slab.hlinux/platform_device.hlinux/dma-mapping.hlinux/clk.hlinux/of.hlinux/of_platform.hlinux/pm_runtime.hlinux/reset.h
Detected Declarations
struct dwc3_of_simplefunction dwc3_of_simple_probefunction __dwc3_of_simple_teardownfunction dwc3_of_simple_removefunction dwc3_of_simple_shutdownfunction dwc3_of_simple_runtime_suspendfunction dwc3_of_simple_runtime_resumefunction dwc3_of_simple_suspendfunction dwc3_of_simple_resume
Annotated Snippet
struct dwc3_of_simple {
struct device *dev;
struct clk_bulk_data *clks;
int num_clocks;
struct reset_control *resets;
bool need_reset;
};
static int dwc3_of_simple_probe(struct platform_device *pdev)
{
struct dwc3_of_simple *simple;
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;
int ret;
simple = devm_kzalloc(dev, sizeof(*simple), GFP_KERNEL);
if (!simple)
return -ENOMEM;
platform_set_drvdata(pdev, simple);
simple->dev = dev;
/*
* Some controllers need to toggle the usb3-otg reset before trying to
* initialize the PHY, otherwise the PHY times out.
*/
if (of_device_is_compatible(np, "rockchip,rk3399-dwc3"))
simple->need_reset = true;
simple->resets = of_reset_control_array_get_optional_exclusive(np);
if (IS_ERR(simple->resets)) {
ret = PTR_ERR(simple->resets);
dev_err(dev, "failed to get device resets, err=%d\n", ret);
return ret;
}
ret = reset_control_deassert(simple->resets);
if (ret)
goto err_resetc_put;
ret = clk_bulk_get_all(simple->dev, &simple->clks);
if (ret < 0)
goto err_resetc_assert;
simple->num_clocks = ret;
ret = clk_bulk_prepare_enable(simple->num_clocks, simple->clks);
if (ret)
goto err_clk_put_all;
ret = of_platform_populate(np, NULL, NULL, dev);
if (ret)
goto err_clk_disable;
pm_runtime_set_active(dev);
pm_runtime_enable(dev);
pm_runtime_get_sync(dev);
return 0;
err_clk_disable:
clk_bulk_disable_unprepare(simple->num_clocks, simple->clks);
err_clk_put_all:
clk_bulk_put_all(simple->num_clocks, simple->clks);
err_resetc_assert:
reset_control_assert(simple->resets);
err_resetc_put:
reset_control_put(simple->resets);
return ret;
}
static void __dwc3_of_simple_teardown(struct dwc3_of_simple *simple)
{
of_platform_depopulate(simple->dev);
clk_bulk_disable_unprepare(simple->num_clocks, simple->clks);
clk_bulk_put_all(simple->num_clocks, simple->clks);
simple->num_clocks = 0;
reset_control_assert(simple->resets);
reset_control_put(simple->resets);
pm_runtime_disable(simple->dev);
pm_runtime_put_noidle(simple->dev);
pm_runtime_set_suspended(simple->dev);
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/slab.h`, `linux/platform_device.h`, `linux/dma-mapping.h`, `linux/clk.h`, `linux/of.h`, `linux/of_platform.h`.
- Detected declarations: `struct dwc3_of_simple`, `function dwc3_of_simple_probe`, `function __dwc3_of_simple_teardown`, `function dwc3_of_simple_remove`, `function dwc3_of_simple_shutdown`, `function dwc3_of_simple_runtime_suspend`, `function dwc3_of_simple_runtime_resume`, `function dwc3_of_simple_suspend`, `function dwc3_of_simple_resume`.
- 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.