drivers/phy/motorola/phy-cpcap-usb.c
Source file repositories/reference/linux-study-clean/drivers/phy/motorola/phy-cpcap-usb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/phy/motorola/phy-cpcap-usb.c- Extension
.c- Size
- 16491 bytes
- Lines
- 720
- 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/atomic.hlinux/clk.hlinux/delay.hlinux/err.hlinux/io.hlinux/module.hlinux/of.hlinux/iio/consumer.hlinux/pinctrl/consumer.hlinux/platform_device.hlinux/regmap.hlinux/slab.hlinux/gpio/consumer.hlinux/mfd/motorola-cpcap.hlinux/phy/omap_usb.hlinux/phy/phy.hlinux/regulator/consumer.hlinux/usb/musb.h
Detected Declarations
struct cpcap_usb_ints_statestruct cpcap_phy_ddataenum cpcap_gpio_modefunction cpcap_usb_vbus_validfunction cpcap_usb_phy_set_hostfunction cpcap_usb_phy_set_peripheralfunction cpcap_phy_get_ints_statefunction cpcap_usb_try_musb_mailboxfunction cpcap_usb_detectfunction cpcap_phy_irq_threadfunction cpcap_usb_init_irqfunction cpcap_usb_init_interruptsfunction cpcap_usb_gpio_set_modefunction cpcap_usb_set_uart_modefunction cpcap_usb_set_usb_modefunction cpcap_usb_init_optional_pinsfunction cpcap_usb_init_optional_gpiosfunction cpcap_usb_init_iiofunction cpcap_usb_phy_probefunction cpcap_usb_phy_remove
Annotated Snippet
struct cpcap_usb_ints_state {
bool id_ground;
bool id_float;
bool chrg_det;
bool rvrs_chrg;
bool vbusov;
bool chrg_se1b;
bool se0conn;
bool rvrs_mode;
bool chrgcurr1;
bool vbusvld;
bool sessvld;
bool sessend;
bool se1;
bool battdetb;
bool dm;
bool dp;
};
enum cpcap_gpio_mode {
CPCAP_DM_DP,
CPCAP_MDM_RX_TX,
CPCAP_UNKNOWN_DISABLED, /* Seems to disable USB lines */
CPCAP_OTG_DM_DP,
};
struct cpcap_phy_ddata {
struct regmap *reg;
struct device *dev;
struct usb_phy phy;
struct delayed_work detect_work;
struct pinctrl *pins;
struct pinctrl_state *pins_ulpi;
struct pinctrl_state *pins_utmi;
struct pinctrl_state *pins_uart;
struct gpio_desc *gpio[2];
struct iio_channel *vbus;
struct iio_channel *id;
struct regulator *vusb;
atomic_t active;
unsigned int vbus_provider:1;
unsigned int docked:1;
};
static bool cpcap_usb_vbus_valid(struct cpcap_phy_ddata *ddata)
{
int error, value = 0;
error = iio_read_channel_processed(ddata->vbus, &value);
if (error >= 0)
return value > 3900;
dev_err(ddata->dev, "error reading VBUS: %i\n", error);
return false;
}
static int cpcap_usb_phy_set_host(struct usb_otg *otg, struct usb_bus *host)
{
otg->host = host;
if (!host)
otg->state = OTG_STATE_UNDEFINED;
return 0;
}
static int cpcap_usb_phy_set_peripheral(struct usb_otg *otg,
struct usb_gadget *gadget)
{
otg->gadget = gadget;
if (!gadget)
otg->state = OTG_STATE_UNDEFINED;
return 0;
}
static const struct phy_ops ops = {
.owner = THIS_MODULE,
};
static int cpcap_phy_get_ints_state(struct cpcap_phy_ddata *ddata,
struct cpcap_usb_ints_state *s)
{
int val, error;
error = regmap_read(ddata->reg, CPCAP_REG_INTS1, &val);
if (error)
return error;
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/clk.h`, `linux/delay.h`, `linux/err.h`, `linux/io.h`, `linux/module.h`, `linux/of.h`, `linux/iio/consumer.h`.
- Detected declarations: `struct cpcap_usb_ints_state`, `struct cpcap_phy_ddata`, `enum cpcap_gpio_mode`, `function cpcap_usb_vbus_valid`, `function cpcap_usb_phy_set_host`, `function cpcap_usb_phy_set_peripheral`, `function cpcap_phy_get_ints_state`, `function cpcap_usb_try_musb_mailbox`, `function cpcap_usb_detect`, `function cpcap_phy_irq_thread`.
- 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.