drivers/phy/renesas/phy-rcar-gen3-usb2.c
Source file repositories/reference/linux-study-clean/drivers/phy/renesas/phy-rcar-gen3-usb2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/phy/renesas/phy-rcar-gen3-usb2.c- Extension
.c- Size
- 29253 bytes
- Lines
- 1117
- Domain
- Driver Families
- Bucket
- drivers/phy
- 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/bitfield.hlinux/bits.hlinux/cleanup.hlinux/extcon-provider.hlinux/interrupt.hlinux/io.hlinux/module.hlinux/mutex.hlinux/mux/consumer.hlinux/of.hlinux/phy/phy.hlinux/platform_device.hlinux/pm_runtime.hlinux/regulator/consumer.hlinux/regulator/driver.hlinux/reset.hlinux/string.hlinux/usb/of.hlinux/workqueue.h
Detected Declarations
struct rcar_gen3_phystruct rcar_gen3_chanstruct rcar_gen3_phy_drv_dataenum rcar_gen3_phy_indexfunction rcar_gen3_phy_usb2_workfunction rcar_gen3_set_host_modefunction rcar_gen3_set_linectrlfunction rcar_gen3_phy_usb2_set_vbusfunction rcar_gen3_enable_vbus_ctrlfunction rcar_gen3_control_otg_irqfunction rcar_gen3_init_for_hostfunction rcar_gen3_init_for_perifunction rcar_gen3_init_for_b_hostfunction rcar_gen3_init_for_a_perifunction rcar_gen3_init_from_a_peri_to_a_hostfunction rcar_gen3_check_idfunction rcar_gen3_device_recognitionfunction rcar_gen3_is_hostfunction rcar_gen3_get_phy_modefunction rcar_gen3_is_any_rphy_initializedfunction rcar_gen3_is_any_otg_rphy_initializedfunction rcar_gen3_are_all_rphys_power_offfunction role_storefunction role_showfunction rcar_gen3_init_otgfunction rcar_gen3_configure_vblvl_ctrlfunction rcar_gen3_phy_usb2_irqfunction scoped_guardfunction rcar_gen3_phy_usb2_initfunction rcar_gen3_phy_usb2_exitfunction rcar_gen3_phy_usb2_power_onfunction rcar_gen3_phy_usb2_power_offfunction scoped_guardfunction rcar_gen3_get_dr_modefunction rcar_gen3_reset_assertfunction rcar_gen3_phy_usb2_init_busfunction rcar_gen3_phy_usb2_regulator_endisablefunction rcar_gen3_phy_usb2_regulator_enablefunction rcar_gen3_phy_usb2_regulator_disablefunction rcar_gen3_phy_usb2_regulator_is_enabledfunction rcar_gen3_phy_usb2_vbus_disable_actionfunction rcar_gen3_phy_usb2_vbus_regulator_get_exclusive_enablefunction rcar_gen3_phy_usb2_vbus_regulator_registerfunction rcar_gen3_phy_usb2_probefunction rcar_gen3_phy_usb2_removefunction rcar_gen3_phy_usb2_suspendfunction rcar_gen3_phy_usb2_resume
Annotated Snippet
struct rcar_gen3_phy {
struct phy *phy;
struct rcar_gen3_chan *ch;
u32 int_enable_bits;
bool initialized;
bool powered;
};
struct rcar_gen3_chan {
void __iomem *base;
struct device *dev; /* platform_device's device */
const struct rcar_gen3_phy_drv_data *phy_data;
struct extcon_dev *extcon;
struct reset_control *rstc;
struct rcar_gen3_phy rphys[NUM_OF_PHYS];
struct regulator *vbus;
struct work_struct work;
spinlock_t lock; /* protects access to hardware and driver data structure. */
enum usb_dr_mode dr_mode;
bool extcon_host;
bool is_otg_channel;
bool uses_otg_pins;
bool otg_internal_reg;
};
struct rcar_gen3_phy_drv_data {
const struct phy_ops *phy_usb2_ops;
bool no_adp_ctrl;
bool init_bus;
bool utmi_ctrl;
bool vblvl_ctrl;
u32 obint_enable_bits;
};
/*
* Combination about is_otg_channel and uses_otg_pins:
*
* Parameters || Behaviors
* is_otg_channel | uses_otg_pins || irqs | role sysfs
* ---------------------+---------------++--------------+------------
* true | true || enabled | enabled
* true | false || disabled | enabled
* false | any || disabled | disabled
*/
static void rcar_gen3_phy_usb2_work(struct work_struct *work)
{
struct rcar_gen3_chan *ch = container_of(work, struct rcar_gen3_chan,
work);
if (ch->extcon_host) {
extcon_set_state_sync(ch->extcon, EXTCON_USB_HOST, true);
extcon_set_state_sync(ch->extcon, EXTCON_USB, false);
} else {
extcon_set_state_sync(ch->extcon, EXTCON_USB_HOST, false);
extcon_set_state_sync(ch->extcon, EXTCON_USB, true);
}
}
static void rcar_gen3_set_host_mode(struct rcar_gen3_chan *ch, int host)
{
void __iomem *usb2_base = ch->base;
u32 val = readl(usb2_base + USB2_COMMCTRL);
dev_vdbg(ch->dev, "%s: %08x, %d\n", __func__, val, host);
if (host)
val &= ~USB2_COMMCTRL_OTG_PERI;
else
val |= USB2_COMMCTRL_OTG_PERI;
writel(val, usb2_base + USB2_COMMCTRL);
}
static void rcar_gen3_set_linectrl(struct rcar_gen3_chan *ch, int dp, int dm)
{
void __iomem *usb2_base = ch->base;
u32 val = readl(usb2_base + USB2_LINECTRL1);
dev_vdbg(ch->dev, "%s: %08x, %d, %d\n", __func__, val, dp, dm);
val &= ~(USB2_LINECTRL1_DP_RPD | USB2_LINECTRL1_DM_RPD);
if (dp)
val |= USB2_LINECTRL1_DP_RPD;
if (dm)
val |= USB2_LINECTRL1_DM_RPD;
writel(val, usb2_base + USB2_LINECTRL1);
}
static void rcar_gen3_phy_usb2_set_vbus(struct rcar_gen3_chan *ch,
u32 vbus_ctrl_reg,
u32 vbus_ctrl_val,
bool enable)
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bits.h`, `linux/cleanup.h`, `linux/extcon-provider.h`, `linux/interrupt.h`, `linux/io.h`, `linux/module.h`, `linux/mutex.h`.
- Detected declarations: `struct rcar_gen3_phy`, `struct rcar_gen3_chan`, `struct rcar_gen3_phy_drv_data`, `enum rcar_gen3_phy_index`, `function rcar_gen3_phy_usb2_work`, `function rcar_gen3_set_host_mode`, `function rcar_gen3_set_linectrl`, `function rcar_gen3_phy_usb2_set_vbus`, `function rcar_gen3_enable_vbus_ctrl`, `function rcar_gen3_control_otg_irq`.
- Atlas domain: Driver Families / drivers/phy.
- 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.