summaryrefslogtreecommitdiff
path: root/drivers/pinctrl/pinctrl-amdisp.h
blob: 9e3597a03227e7b40a17c87fe9f3f7d83b67ef6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * AMD ISP Pinctrl Driver
 *
 * Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.
 *
 */

static const struct pinctrl_pin_desc amdisp_pins[] = {
	PINCTRL_PIN(0, "GPIO_0"), /* sensor0 control */
	PINCTRL_PIN(1, "GPIO_1"), /* sensor1 control */
	PINCTRL_PIN(2, "GPIO_2"), /* sensor2 control */
};

#define AMDISP_GPIO_PINS(pin) \
static const unsigned int gpio##pin##_pins[] = { pin }
AMDISP_GPIO_PINS(0);
AMDISP_GPIO_PINS(1);
AMDISP_GPIO_PINS(2);

static const unsigned int amdisp_range_pins[] = {
	0, 1, 2
};

static const char * const amdisp_range_pins_name[] = {
	"gpio0", "gpio1", "gpio2"
};

enum amdisp_functions {
	mux_gpio,
	mux_NA
};

static const char * const gpio_groups[] = {
	"gpio0", "gpio1", "gpio2"
};

/**
 * struct amdisp_function - a pinmux function
 * @name:    Name of the pinmux function.
 * @groups:  List of pingroups for this function.
 * @ngroups: Number of entries in @groups.
 */
struct amdisp_function {
	const char *name;
	const char * const *groups;
	unsigned int ngroups;
};

#define FUNCTION(fname)					\
	[mux_##fname] = {				\
		.name = #fname,				\
		.groups = fname##_groups,		\
		.ngroups = ARRAY_SIZE(fname##_groups),	\
	}

static const struct amdisp_function amdisp_functions[] = {
	FUNCTION(gpio),
};

/**
 * struct amdisp_pingroup - a pinmux group
 * @name:  Name of the pinmux group.
 * @pins:  List of pins for this group.
 * @npins: Number of entries in @pins.
 * @funcs: List of functions belongs to this group.
 * @nfuncs: Number of entries in @funcs.
 * @offset: Group offset in amdisp pinmux groups.
 */
struct amdisp_pingroup {
	const char *name;
	const unsigned int *pins;
	unsigned int npins;
	unsigned int *funcs;
	unsigned int nfuncs;
	unsigned int offset;
};

#define PINGROUP(id, f0)					\
	{							\
		.name = "gpio" #id,				\
		.pins = gpio##id##_pins,			\
		.npins = ARRAY_SIZE(gpio##id##_pins),		\
		.funcs = (int[]){				\
			mux_##f0,				\
		},						\
		.nfuncs = 1,					\
		.offset = id,					\
	}

static const struct amdisp_pingroup amdisp_groups[] = {
	PINGROUP(0, gpio),
	PINGROUP(1, gpio),
	PINGROUP(2, gpio),
};