drivers/gpio/gpio-rtd.c

Source file repositories/reference/linux-study-clean/drivers/gpio/gpio-rtd.c

File Facts

System
Linux kernel
Corpus path
drivers/gpio/gpio-rtd.c
Extension
.c
Size
17448 bytes
Lines
610
Domain
Driver Families
Bucket
drivers/gpio
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 rtd_gpio_info {
	const char	*name;
	unsigned int	gpio_base;
	unsigned int	num_gpios;
	u8		*dir_offset;
	u8		*dato_offset;
	u8		*dati_offset;
	u8		*ie_offset;
	u8		*dp_offset;
	u8		*gpa_offset;
	u8		*gpda_offset;
	u8		*deb_offset;
	u8		*deb_val;
	u8		(*get_deb_setval)(const struct rtd_gpio_info *info,
					  unsigned int offset, u8 deb_index,
					  u8 *reg_offset, u8 *shift);
};

struct rtd_gpio {
	struct gpio_chip		gpio_chip;
	const struct rtd_gpio_info	*info;
	void __iomem			*base;
	void __iomem			*irq_base;
	unsigned int			irqs[2];
	raw_spinlock_t			lock;
};

static u8 rtd_gpio_get_deb_setval(const struct rtd_gpio_info *info, unsigned int offset,
				  u8 deb_index, u8 *reg_offset, u8 *shift)
{
	*reg_offset = info->deb_offset[offset / 8];
	*shift = (offset % 8) * 4;
	return info->deb_val[deb_index];
}

static u8 rtd1295_misc_gpio_get_deb_setval(const struct rtd_gpio_info *info, unsigned int offset,
					   u8 deb_index, u8 *reg_offset, u8 *shift)
{
	*reg_offset = info->deb_offset[0];
	*shift = (offset % 8) * 4;
	return info->deb_val[deb_index];
}

static u8 rtd1295_iso_gpio_get_deb_setval(const struct rtd_gpio_info *info, unsigned int offset,
					  u8 deb_index, u8 *reg_offset, u8 *shift)
{
	*reg_offset = info->deb_offset[0];
	*shift = 0;
	return info->deb_val[deb_index];
}

static const struct rtd_gpio_info rtd_iso_gpio_info = {
	.name			= "rtd_iso_gpio",
	.gpio_base		= 0,
	.num_gpios		= 82,
	.dir_offset		= (u8 []){ 0x0, 0x18, 0x2c },
	.dato_offset		= (u8 []){ 0x4, 0x1c, 0x30 },
	.dati_offset		= (u8 []){ 0x8, 0x20, 0x34 },
	.ie_offset		= (u8 []){ 0xc, 0x24, 0x38 },
	.dp_offset		= (u8 []){ 0x10, 0x28, 0x3c },
	.gpa_offset		= (u8 []){ 0x8, 0xe0, 0x90 },
	.gpda_offset		= (u8 []){ 0xc, 0xe4, 0x94 },
	.deb_offset		= (u8 []){ 0x44, 0x48, 0x4c, 0x50, 0x54, 0x58, 0x5c,
					   0x60, 0x64, 0x68, 0x6c },
	.deb_val		= (u8 []){ 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6 },
	.get_deb_setval		= rtd_gpio_get_deb_setval,
};

static const struct rtd_gpio_info rtd1619_iso_gpio_info = {
	.name			= "rtd1619_iso_gpio",
	.gpio_base		= 0,
	.num_gpios		= 86,
	.dir_offset		= (u8 []){ 0x0, 0x18, 0x2c },
	.dato_offset		= (u8 []){ 0x4, 0x1c, 0x30 },
	.dati_offset		= (u8 []){ 0x8, 0x20, 0x34 },
	.ie_offset		= (u8 []){ 0xc, 0x24, 0x38 },
	.dp_offset		= (u8 []){ 0x10, 0x28, 0x3c },
	.gpa_offset		= (u8 []){ 0x8, 0xe0, 0x90 },
	.gpda_offset		= (u8 []){ 0xc, 0xe4, 0x94 },
	.deb_offset		= (u8 []){ 0x44, 0x48, 0x4c, 0x50, 0x54, 0x58, 0x5c,
					   0x60, 0x64, 0x68, 0x6c },
	.deb_val		= (u8 []){ 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6 },
	.get_deb_setval		= rtd_gpio_get_deb_setval,
};

static const struct rtd_gpio_info rtd1395_iso_gpio_info = {
	.name			= "rtd1395_iso_gpio",
	.gpio_base		= 0,
	.num_gpios		= 57,
	.dir_offset		= (u8 []){ 0x0, 0x18 },

Annotation

Implementation Notes