drivers/phy/socionext/phy-uniphier-usb2.c

Source file repositories/reference/linux-study-clean/drivers/phy/socionext/phy-uniphier-usb2.c

File Facts

System
Linux kernel
Corpus path
drivers/phy/socionext/phy-uniphier-usb2.c
Extension
.c
Size
5708 bytes
Lines
237
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 uniphier_u2phy_param {
	u32 offset;
	u32 value;
};

struct uniphier_u2phy_soc_data {
	struct uniphier_u2phy_param config0;
	struct uniphier_u2phy_param config1;
};

struct uniphier_u2phy_priv {
	struct regmap *regmap;
	struct phy *phy;
	struct regulator *vbus;
	const struct uniphier_u2phy_soc_data *data;
	struct uniphier_u2phy_priv *next;
};

static int uniphier_u2phy_power_on(struct phy *phy)
{
	struct uniphier_u2phy_priv *priv = phy_get_drvdata(phy);
	int ret = 0;

	if (priv->vbus)
		ret = regulator_enable(priv->vbus);

	return ret;
}

static int uniphier_u2phy_power_off(struct phy *phy)
{
	struct uniphier_u2phy_priv *priv = phy_get_drvdata(phy);

	if (priv->vbus)
		regulator_disable(priv->vbus);

	return 0;
}

static int uniphier_u2phy_init(struct phy *phy)
{
	struct uniphier_u2phy_priv *priv = phy_get_drvdata(phy);

	if (!priv->data)
		return 0;

	regmap_write(priv->regmap, priv->data->config0.offset,
		     priv->data->config0.value);
	regmap_write(priv->regmap, priv->data->config1.offset,
		     priv->data->config1.value);

	return 0;
}

static struct phy *uniphier_u2phy_xlate(struct device *dev,
					const struct of_phandle_args *args)
{
	struct uniphier_u2phy_priv *priv = dev_get_drvdata(dev);

	while (priv && args->np != priv->phy->dev.of_node)
		priv = priv->next;

	if (!priv) {
		dev_err(dev, "Failed to find appropriate phy\n");
		return ERR_PTR(-EINVAL);
	}

	return priv->phy;
}

static const struct phy_ops uniphier_u2phy_ops = {
	.init      = uniphier_u2phy_init,
	.power_on  = uniphier_u2phy_power_on,
	.power_off = uniphier_u2phy_power_off,
	.owner = THIS_MODULE,
};

static int uniphier_u2phy_probe(struct platform_device *pdev)
{
	struct device *dev = &pdev->dev;
	struct device_node *parent;
	struct uniphier_u2phy_priv *priv = NULL, *next = NULL;
	struct phy_provider *phy_provider;
	struct regmap *regmap;
	const struct uniphier_u2phy_soc_data *data;
	int ret, data_idx, ndatas;

	data = of_device_get_match_data(dev);
	if (WARN_ON(!data))
		return -EINVAL;

Annotation

Implementation Notes