drivers/pinctrl/pinctrl-aw9523.c

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

File Facts

System
Linux kernel
Corpus path
drivers/pinctrl/pinctrl-aw9523.c
Extension
.c
Size
26880 bytes
Lines
1061
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 aw9523_irq {
	struct mutex lock;
	u16 cached_gpio;
};

/*
 * struct aw9523 - Main driver structure
 * @dev: device handle
 * @regmap: regmap handle for current device
 * @i2c_lock: Mutex lock for i2c operations
 * @reset_gpio: Hardware reset (RSTN) signal GPIO
 * @vio_vreg: VCC regulator (Optional)
 * @pctl: pinctrl handle for current device
 * @gpio: structure holding gpiochip params
 * @irq: Interrupt controller structure
 */
struct aw9523 {
	struct device *dev;
	struct regmap *regmap;
	struct mutex i2c_lock;
	struct gpio_desc *reset_gpio;
	int vio_vreg;
	struct pinctrl_dev *pctl;
	struct gpio_chip gpio;
	struct aw9523_irq *irq;
};

static const struct pinctrl_pin_desc aw9523_pins[] = {
	/* Port 0 */
	PINCTRL_PIN(0, "gpio0"),
	PINCTRL_PIN(1, "gpio1"),
	PINCTRL_PIN(2, "gpio2"),
	PINCTRL_PIN(3, "gpio3"),
	PINCTRL_PIN(4, "gpio4"),
	PINCTRL_PIN(5, "gpio5"),
	PINCTRL_PIN(6, "gpio6"),
	PINCTRL_PIN(7, "gpio7"),

	/* Port 1 */
	PINCTRL_PIN(8, "gpio8"),
	PINCTRL_PIN(9, "gpio9"),
	PINCTRL_PIN(10, "gpio10"),
	PINCTRL_PIN(11, "gpio11"),
	PINCTRL_PIN(12, "gpio12"),
	PINCTRL_PIN(13, "gpio13"),
	PINCTRL_PIN(14, "gpio14"),
	PINCTRL_PIN(15, "gpio15"),
};

static int aw9523_pinctrl_get_groups_count(struct pinctrl_dev *pctldev)
{
	return ARRAY_SIZE(aw9523_pins);
}

static const char *aw9523_pinctrl_get_group_name(struct pinctrl_dev *pctldev,
						 unsigned int selector)
{
	return aw9523_pins[selector].name;
}

static int aw9523_pinctrl_get_group_pins(struct pinctrl_dev *pctldev,
					 unsigned int selector,
					 const unsigned int **pins,
					 unsigned int *num_pins)
{
	*pins = &aw9523_pins[selector].number;
	*num_pins = 1;
	return 0;
}

static const struct pinctrl_ops aw9523_pinctrl_ops = {
	.get_groups_count = aw9523_pinctrl_get_groups_count,
	.get_group_pins = aw9523_pinctrl_get_group_pins,
	.get_group_name = aw9523_pinctrl_get_group_name,
	.dt_node_to_map = pinconf_generic_dt_node_to_map_pin,
	.dt_free_map = pinconf_generic_dt_free_map,
};

static const char * const gpio_pwm_groups[] = {
	"gpio0", "gpio1", "gpio2", "gpio3",		/* 0-3 */
	"gpio4", "gpio5", "gpio6", "gpio7",		/* 4-7 */
	"gpio8", "gpio9", "gpio10", "gpio11",		/* 8-11 */
	"gpio12", "gpio13", "gpio14", "gpio15",		/* 11-15 */
};

/* Warning: Do NOT reorder this array */
static const struct pinfunction aw9523_pmx[] = {
	PINCTRL_PINFUNCTION("pwm", gpio_pwm_groups, ARRAY_SIZE(gpio_pwm_groups)),
	PINCTRL_PINFUNCTION("gpio", gpio_pwm_groups, ARRAY_SIZE(gpio_pwm_groups)),
};

Annotation

Implementation Notes