drivers/usb/phy/phy-fsl-usb.c
Source file repositories/reference/linux-study-clean/drivers/usb/phy/phy-fsl-usb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/phy/phy-fsl-usb.c- Extension
.c- Size
- 24365 bytes
- Lines
- 1018
- 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.
- 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/module.hlinux/kernel.hlinux/delay.hlinux/slab.hlinux/string_choices.hlinux/proc_fs.hlinux/errno.hlinux/interrupt.hlinux/io.hlinux/timer.hlinux/usb.hlinux/device.hlinux/usb/ch9.hlinux/usb/gadget.hlinux/workqueue.hlinux/time.hlinux/fsl_devices.hlinux/platform_device.hlinux/uaccess.hlinux/unaligned.hphy-fsl-usb.h
Detected Declarations
function _fsl_readl_befunction _fsl_readl_lefunction _fsl_writel_befunction _fsl_writel_lefunction write_ulpifunction fsl_otg_chrg_vbusfunction fsl_otg_dischrg_vbusfunction fsl_otg_drv_vbusfunction fsl_otg_loc_connfunction fsl_otg_loc_soffunction fsl_otg_start_pulsefunction b_data_pulse_endfunction fsl_otg_pulse_vbusfunction b_vbus_pulse_endfunction b_srp_endfunction a_wait_enumfunction set_tmoutfunction fsl_otg_init_timersfunction fsl_otg_uninit_timersfunction fsl_otg_add_timerfunction fsl_otg_fsm_add_timerfunction fsl_otg_del_timerfunction fsl_otg_fsm_del_timerfunction otg_reset_controllerfunction fsl_otg_start_hostfunction fsl_otg_start_gadgetfunction fsl_otg_set_hostfunction fsl_otg_set_peripheralfunction devicefunction fsl_otg_start_srpfunction fsl_otg_start_hnpfunction fsl_otg_isrfunction fsl_otg_conffunction usb_otg_startfunction identificationfunction fsl_otg_probefunction fsl_otg_remove
Annotated Snippet
if (tmp_timer == timer) {
timer->count = timer->expires;
return;
}
timer->count = timer->expires;
list_add_tail(&timer->list, &active_timers);
}
static void fsl_otg_fsm_add_timer(struct otg_fsm *fsm, enum otg_fsm_timer t)
{
struct fsl_otg_timer *timer;
timer = fsl_otg_get_timer(t);
if (!timer)
return;
fsl_otg_add_timer(fsm, timer);
}
/* Remove timer from the timer list; clear timeout status */
void fsl_otg_del_timer(struct otg_fsm *fsm, void *gtimer)
{
struct fsl_otg_timer *timer = gtimer;
struct fsl_otg_timer *tmp_timer, *del_tmp;
list_for_each_entry_safe(tmp_timer, del_tmp, &active_timers, list)
if (tmp_timer == timer)
list_del(&timer->list);
}
static void fsl_otg_fsm_del_timer(struct otg_fsm *fsm, enum otg_fsm_timer t)
{
struct fsl_otg_timer *timer;
timer = fsl_otg_get_timer(t);
if (!timer)
return;
fsl_otg_del_timer(fsm, timer);
}
/* Reset controller, not reset the bus */
void otg_reset_controller(void)
{
u32 command;
command = fsl_readl(&usb_dr_regs->usbcmd);
command |= (1 << 1);
fsl_writel(command, &usb_dr_regs->usbcmd);
while (fsl_readl(&usb_dr_regs->usbcmd) & (1 << 1))
;
}
/* Call suspend/resume routines in host driver */
int fsl_otg_start_host(struct otg_fsm *fsm, int on)
{
struct usb_otg *otg = fsm->otg;
struct device *dev;
struct fsl_otg *otg_dev =
container_of(otg->usb_phy, struct fsl_otg, phy);
u32 retval = 0;
if (!otg->host)
return -ENODEV;
dev = otg->host->controller;
/*
* Update a_vbus_vld state as a_vbus_vld int is disabled
* in device mode
*/
fsm->a_vbus_vld =
!!(fsl_readl(&usb_dr_regs->otgsc) & OTGSC_STS_A_VBUS_VALID);
if (on) {
/* start fsl usb host controller */
if (otg_dev->host_working)
goto end;
else {
otg_reset_controller();
VDBG("host on......\n");
if (dev->driver->pm && dev->driver->pm->resume) {
retval = dev->driver->pm->resume(dev);
if (fsm->id) {
/* default-b */
fsl_otg_drv_vbus(fsm, 1);
/*
* Workaround: b_host can't driver
* vbus, but PP in PORTSC needs to
* be 1 for host to work.
* So we set drv_vbus bit in
* transceiver to 0 thru ULPI.
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/delay.h`, `linux/slab.h`, `linux/string_choices.h`, `linux/proc_fs.h`, `linux/errno.h`, `linux/interrupt.h`.
- Detected declarations: `function _fsl_readl_be`, `function _fsl_readl_le`, `function _fsl_writel_be`, `function _fsl_writel_le`, `function write_ulpi`, `function fsl_otg_chrg_vbus`, `function fsl_otg_dischrg_vbus`, `function fsl_otg_drv_vbus`, `function fsl_otg_loc_conn`, `function fsl_otg_loc_sof`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: source implementation candidate.
- 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.