drivers/pinctrl/pinctrl-max7360.c

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

File Facts

System
Linux kernel
Corpus path
drivers/pinctrl/pinctrl-max7360.c
Extension
.c
Size
6419 bytes
Lines
216
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 max7360_pinctrl {
	struct pinctrl_dev *pctldev;
	struct pinctrl_desc pinctrl_desc;
};

static const struct pinctrl_pin_desc max7360_pins[] = {
	PINCTRL_PIN(0, "PORT0"),
	PINCTRL_PIN(1, "PORT1"),
	PINCTRL_PIN(2, "PORT2"),
	PINCTRL_PIN(3, "PORT3"),
	PINCTRL_PIN(4, "PORT4"),
	PINCTRL_PIN(5, "PORT5"),
	PINCTRL_PIN(6, "PORT6"),
	PINCTRL_PIN(7, "PORT7"),
};

static const unsigned int port0_pins[] = {0};
static const unsigned int port1_pins[] = {1};
static const unsigned int port2_pins[] = {2};
static const unsigned int port3_pins[] = {3};
static const unsigned int port4_pins[] = {4};
static const unsigned int port5_pins[] = {5};
static const unsigned int port6_pins[] = {6};
static const unsigned int port7_pins[] = {7};
static const unsigned int rotary_pins[] = {6, 7};

static const struct pingroup max7360_groups[] = {
	PINCTRL_PINGROUP("PORT0", port0_pins, ARRAY_SIZE(port0_pins)),
	PINCTRL_PINGROUP("PORT1", port1_pins, ARRAY_SIZE(port1_pins)),
	PINCTRL_PINGROUP("PORT2", port2_pins, ARRAY_SIZE(port2_pins)),
	PINCTRL_PINGROUP("PORT3", port3_pins, ARRAY_SIZE(port3_pins)),
	PINCTRL_PINGROUP("PORT4", port4_pins, ARRAY_SIZE(port4_pins)),
	PINCTRL_PINGROUP("PORT5", port5_pins, ARRAY_SIZE(port5_pins)),
	PINCTRL_PINGROUP("PORT6", port6_pins, ARRAY_SIZE(port6_pins)),
	PINCTRL_PINGROUP("PORT7", port7_pins, ARRAY_SIZE(port7_pins)),
	PINCTRL_PINGROUP("ROTARY", rotary_pins, ARRAY_SIZE(rotary_pins)),
};

static int max7360_pinctrl_get_groups_count(struct pinctrl_dev *pctldev)
{
	return ARRAY_SIZE(max7360_groups);
}

static const char *max7360_pinctrl_get_group_name(struct pinctrl_dev *pctldev,
						  unsigned int group)
{
	return max7360_groups[group].name;
}

static int max7360_pinctrl_get_group_pins(struct pinctrl_dev *pctldev,
					  unsigned int group,
					  const unsigned int **pins,
					  unsigned int *num_pins)
{
	*pins = max7360_groups[group].pins;
	*num_pins = max7360_groups[group].npins;
	return 0;
}

static const struct pinctrl_ops max7360_pinctrl_ops = {
	.get_groups_count = max7360_pinctrl_get_groups_count,
	.get_group_name = max7360_pinctrl_get_group_name,
	.get_group_pins = max7360_pinctrl_get_group_pins,
#ifdef CONFIG_OF
	.dt_node_to_map = pinconf_generic_dt_node_to_map_pin,
	.dt_free_map = pinconf_generic_dt_free_map,
#endif
};

static const char * const simple_groups[] = {
	"PORT0", "PORT1", "PORT2", "PORT3",
	"PORT4", "PORT5", "PORT6", "PORT7",
};

static const char * const rotary_groups[] = { "ROTARY" };

#define MAX7360_PINCTRL_FN_GPIO		0
#define MAX7360_PINCTRL_FN_PWM		1
#define MAX7360_PINCTRL_FN_ROTARY	2
static const struct pinfunction max7360_functions[] = {
	[MAX7360_PINCTRL_FN_GPIO] = PINCTRL_PINFUNCTION("gpio", simple_groups,
							ARRAY_SIZE(simple_groups)),
	[MAX7360_PINCTRL_FN_PWM] = PINCTRL_PINFUNCTION("pwm", simple_groups,
						       ARRAY_SIZE(simple_groups)),
	[MAX7360_PINCTRL_FN_ROTARY] = PINCTRL_PINFUNCTION("rotary", rotary_groups,
							  ARRAY_SIZE(rotary_groups)),
};

static int max7360_get_functions_count(struct pinctrl_dev *pctldev)
{

Annotation

Implementation Notes