drivers/pinctrl/spacemit/pinctrl-k1.c

Source file repositories/reference/linux-study-clean/drivers/pinctrl/spacemit/pinctrl-k1.c

File Facts

System
Linux kernel
Corpus path
drivers/pinctrl/spacemit/pinctrl-k1.c
Extension
.c
Size
40526 bytes
Lines
1451
Domain
Driver Families
Bucket
drivers/pinctrl
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 spacemit_pin_drv_strength {
	u8		val;
	u32		mA;
};

struct spacemit_pinctrl_dconf {
	u64				schmitt_mask;
	u64				drive_mask;

	struct spacemit_pin_drv_strength *ds_1v8_tbl;
	size_t				 ds_1v8_tbl_num;
	struct spacemit_pin_drv_strength *ds_3v3_tbl;
	size_t				 ds_3v3_tbl_num;
};

struct spacemit_pin {
	u16				pin;
	u16				flags;
	u8				gpiofunc;
};

struct spacemit_pinctrl {
	struct device				*dev;
	struct pinctrl_dev			*pctl_dev;
	const struct spacemit_pinctrl_data	*data;
	struct pinctrl_desc			pdesc;

	struct mutex				mutex;
	raw_spinlock_t				lock;

	void __iomem				*regs;

	struct regmap				*regmap_apbc;
};

struct spacemit_pinctrl_data {
	const struct pinctrl_pin_desc   *pins;
	const struct spacemit_pin	*data;
	u16				npins;
	unsigned int			(*pin_to_offset)(unsigned int pin);
	unsigned int			(*pin_to_io_pd_offset)(unsigned int pin);
	const struct spacemit_pinctrl_dconf	*dconf;
};

/* map pin id to pinctrl register offset, refer MFPR definition */
static unsigned int spacemit_k1_pin_to_offset(unsigned int pin)
{
	unsigned int offset = 0;

	switch (pin) {
	case 0 ... 85:
		offset = pin + 1;
		break;
	case 86 ... 92:
		offset = pin + 37;
		break;
	case 93 ... 97:
		offset = pin + 24;
		break;
	case 98:
		offset = 93;
		break;
	case 99:
		offset = 92;
		break;
	case 100:
		offset = 91;
		break;
	case 101:
		offset = 90;
		break;
	case 102:
		offset = 95;
		break;
	case 103:
		offset = 94;
		break;
	case 104 ... 110:
		offset = pin + 6;
		break;
	case 111 ... 127:
		offset = pin + 20;
		break;
	default:
		break;
	}

	return offset << 2;
}

Annotation

Implementation Notes