drivers/reset/reset-rzv2h-usb2phy.c

Source file repositories/reference/linux-study-clean/drivers/reset/reset-rzv2h-usb2phy.c

File Facts

System
Linux kernel
Corpus path
drivers/reset/reset-rzv2h-usb2phy.c
Extension
.c
Size
6763 bytes
Lines
244
Domain
Driver Families
Bucket
drivers/reset
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 rzv2h_usb2phy_reset_of_data {
	const struct reg_sequence *init_seq;
	unsigned int init_nseq;

	const struct reg_sequence *assert_seq;
	unsigned int assert_nseq;

	const struct reg_sequence *deassert_seq;
	unsigned int deassert_nseq;

	u16 reset_reg;
	u16 reset_status_bits;
};

struct rzv2h_usb2phy_reset_priv {
	const struct rzv2h_usb2phy_reset_of_data *data;
	struct regmap *regmap;
	struct device *dev;
	struct reset_controller_dev rcdev;
};

static inline struct rzv2h_usb2phy_reset_priv
*rzv2h_usbphy_rcdev_to_priv(struct reset_controller_dev *rcdev)
{
	return container_of(rcdev, struct rzv2h_usb2phy_reset_priv, rcdev);
}

static int rzv2h_usbphy_reset_assert(struct reset_controller_dev *rcdev,
				     unsigned long id)
{
	struct rzv2h_usb2phy_reset_priv *priv = rzv2h_usbphy_rcdev_to_priv(rcdev);

	return regmap_multi_reg_write(priv->regmap, priv->data->assert_seq,
				      priv->data->assert_nseq);
}

static int rzv2h_usbphy_reset_deassert(struct reset_controller_dev *rcdev,
				       unsigned long id)
{
	struct rzv2h_usb2phy_reset_priv *priv = rzv2h_usbphy_rcdev_to_priv(rcdev);

	return regmap_multi_reg_write(priv->regmap, priv->data->deassert_seq,
				      priv->data->deassert_nseq);
}

static int rzv2h_usbphy_reset_status(struct reset_controller_dev *rcdev,
				     unsigned long id)
{
	struct rzv2h_usb2phy_reset_priv *priv = rzv2h_usbphy_rcdev_to_priv(rcdev);
	u32 reg;

	regmap_read(priv->regmap, priv->data->reset_reg, &reg);

	return (reg & priv->data->reset_status_bits) == priv->data->reset_status_bits;
}

static const struct reset_control_ops rzv2h_usbphy_reset_ops = {
	.assert = rzv2h_usbphy_reset_assert,
	.deassert = rzv2h_usbphy_reset_deassert,
	.status = rzv2h_usbphy_reset_status,
};

static int rzv2h_usb2phy_reset_of_xlate(struct reset_controller_dev *rcdev,
					const struct of_phandle_args *reset_spec)
{
	/* No special handling needed, we have only one reset line per device */
	return 0;
}

static void rzv2h_usb2phy_reset_ida_free(void *data)
{
	struct auxiliary_device *adev = data;

	ida_free(&auxiliary_ids, adev->id);
}

static int rzv2h_usb2phy_reset_mux_register(struct device *dev,
					    const char *mux_name)
{
	struct auxiliary_device *adev;
	int id;

	id = ida_alloc(&auxiliary_ids, GFP_KERNEL);
	if (id < 0)
		return id;

	adev = __devm_auxiliary_device_create(dev, dev->driver->name,
					      mux_name, NULL, id);
	if (!adev) {
		ida_free(&auxiliary_ids, id);

Annotation

Implementation Notes