drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c

Source file repositories/reference/linux-study-clean/drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c

File Facts

System
Linux kernel
Corpus path
drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c
Extension
.c
Size
8590 bytes
Lines
338
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 eusb2_repeater_init_tbl_reg {
	unsigned int reg;
	unsigned int value;
};

struct eusb2_repeater_cfg {
	const struct eusb2_repeater_init_tbl_reg *init_tbl;
	int init_tbl_num;
	const char * const *vreg_list;
	int num_vregs;
};

struct eusb2_repeater {
	struct device *dev;
	struct regmap *regmap;
	struct phy *phy;
	struct regulator_bulk_data *vregs;
	const struct eusb2_repeater_cfg *cfg;
	u32 base;
	enum phy_mode mode;
};

static const char * const pm8550b_vreg_l[] = {
	"vdd18", "vdd3",
};

static const struct eusb2_repeater_init_tbl_reg pm8550b_init_tbl[] = {
	{ EUSB2_TUNE_IUSB2, 0x8 },
	{ EUSB2_TUNE_SQUELCH_U, 0x3 },
	{ EUSB2_TUNE_USB2_PREEM, 0x5 },
};

static const struct eusb2_repeater_init_tbl_reg smb2360_init_tbl[] = {
	{ EUSB2_TUNE_IUSB2, 0x5 },
	{ EUSB2_TUNE_SQUELCH_U, 0x3 },
	{ EUSB2_TUNE_USB2_PREEM, 0x2 },
};

static const struct eusb2_repeater_init_tbl_reg smb2370_init_tbl[] = {
	{ EUSB2_TUNE_IUSB2, 0x4 },
	{ EUSB2_TUNE_SQUELCH_U, 0x3 },
	{ EUSB2_TUNE_USB2_SLEW, 0x7 },
	{ EUSB2_TUNE_USB2_PREEM, 0x0 },
};

static const struct eusb2_repeater_cfg pm8550b_eusb2_cfg = {
	.init_tbl	= pm8550b_init_tbl,
	.init_tbl_num	= ARRAY_SIZE(pm8550b_init_tbl),
	.vreg_list	= pm8550b_vreg_l,
	.num_vregs	= ARRAY_SIZE(pm8550b_vreg_l),
};

static const struct eusb2_repeater_cfg pmiv0104_eusb2_cfg = {
	/* No PMIC-specific init sequence, only board level tuning via DT */
	.init_tbl	= (struct eusb2_repeater_init_tbl_reg[]) {},
	.init_tbl_num	= 0,
	.vreg_list	= pm8550b_vreg_l,
	.num_vregs	= ARRAY_SIZE(pm8550b_vreg_l),
};

static const struct eusb2_repeater_cfg smb2360_eusb2_cfg = {
	.init_tbl	= smb2360_init_tbl,
	.init_tbl_num	= ARRAY_SIZE(smb2360_init_tbl),
	.vreg_list	= pm8550b_vreg_l,
	.num_vregs	= ARRAY_SIZE(pm8550b_vreg_l),
};

static const struct eusb2_repeater_cfg smb2370_eusb2_cfg = {
	.init_tbl	= smb2370_init_tbl,
	.init_tbl_num	= ARRAY_SIZE(smb2370_init_tbl),
	.vreg_list	= pm8550b_vreg_l,
	.num_vregs	= ARRAY_SIZE(pm8550b_vreg_l),
};

static int eusb2_repeater_init_vregs(struct eusb2_repeater *rptr)
{
	int num = rptr->cfg->num_vregs;
	struct device *dev = rptr->dev;
	int i;

	rptr->vregs = devm_kcalloc(dev, num, sizeof(*rptr->vregs), GFP_KERNEL);
	if (!rptr->vregs)
		return -ENOMEM;

	for (i = 0; i < num; i++)
		rptr->vregs[i].supply = rptr->cfg->vreg_list[i];

	return devm_regulator_bulk_get(dev, num, rptr->vregs);
}

Annotation

Implementation Notes