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.

Dependency Surface

Detected Declarations

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

Implementation Notes