drivers/net/wan/framer/pef2256/pef2256.c

Source file repositories/reference/linux-study-clean/drivers/net/wan/framer/pef2256/pef2256.c

File Facts

System
Linux kernel
Corpus path
drivers/net/wan/framer/pef2256/pef2256.c
Extension
.c
Size
24603 bytes
Lines
894
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: exported/initcall integration point
Status
integration 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 pef2256 {
	struct device *dev;
	struct regmap *regmap;
	enum pef2256_version version;
	const char *version_txt;
	struct clk *mclk;
	struct clk *sclkr;
	struct clk *sclkx;
	struct gpio_desc *reset_gpio;
	unsigned long sysclk_rate;
	u32 data_rate;
	bool is_tx_falling_edge;
	bool is_subordinate;
	enum pef2256_frame_type frame_type;
	u8 channel_phase;
	atomic_t carrier;
	struct framer *framer;
};

static u8 pef2256_read8(struct pef2256 *pef2256, int offset)
{
	int val;

	regmap_read(pef2256->regmap, offset, &val);
	return val;
}

static void pef2256_write8(struct pef2256 *pef2256, int offset, u8 val)
{
	regmap_write(pef2256->regmap, offset, val);
}

static void pef2256_clrbits8(struct pef2256 *pef2256, int offset, u8 clr)
{
	regmap_clear_bits(pef2256->regmap, offset, clr);
}

static void pef2256_setbits8(struct pef2256 *pef2256, int offset, u8 set)
{
	regmap_set_bits(pef2256->regmap, offset, set);
}

static void pef2256_clrsetbits8(struct pef2256 *pef2256, int offset, u8 clr, u8 set)
{
	regmap_update_bits(pef2256->regmap, offset, clr | set, set);
}

enum pef2256_version pef2256_get_version(struct pef2256 *pef2256)
{
	enum pef2256_version version = PEF2256_VERSION_UNKNOWN;
	u8 vstr, wid;

	vstr = pef2256_read8(pef2256, PEF2256_VSTR);
	wid = pef2256_read8(pef2256, PEF2256_WID);

	switch (vstr) {
	case PEF2256_VSTR_VERSION_12:
		if ((wid & PEF2256_12_WID_MASK) == PEF2256_12_WID_VERSION_12)
			version = PEF2256_VERSION_1_2;
		break;
	case PEF2256_VSTR_VERSION_2x:
		switch (wid & PEF2256_2X_WID_MASK) {
		case PEF2256_2X_WID_VERSION_21:
			version = PEF2256_VERSION_2_1;
			break;
		case PEF2256_2X_WID_VERSION_22:
			version = PEF2256_VERSION_2_2;
			break;
		}
		break;
	case PEF2256_VSTR_VERSION_21:
		version = PEF2256_VERSION_2_1;
		break;
	}

	if (version == PEF2256_VERSION_UNKNOWN)
		dev_err(pef2256->dev, "Unknown version (0x%02x, 0x%02x)\n", vstr, wid);

	return version;
}
EXPORT_SYMBOL_GPL(pef2256_get_version);

static ssize_t version_show(struct device *dev, struct device_attribute *attr,
			    char *buf)
{
	struct pef2256 *pef2256 = dev_get_drvdata(dev);

	return sysfs_emit(buf, "%s\n", pef2256->version_txt);
}

Annotation

Implementation Notes