162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci#include <linux/kernel.h>
362306a36Sopenharmony_ci#include <linux/types.h>
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#include <linux/pinctrl/pinctrl.h>
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#include "pinctrl-nomadik.h"
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci/* All the pins that can be used for GPIO and some other functions */
1062306a36Sopenharmony_ci#define _GPIO(offset)		(offset)
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#define STN8815_PIN_B4		_GPIO(0)
1362306a36Sopenharmony_ci#define STN8815_PIN_D5		_GPIO(1)
1462306a36Sopenharmony_ci#define STN8815_PIN_C5		_GPIO(2)
1562306a36Sopenharmony_ci#define STN8815_PIN_A4		_GPIO(3)
1662306a36Sopenharmony_ci#define STN8815_PIN_B5		_GPIO(4)
1762306a36Sopenharmony_ci#define STN8815_PIN_D6		_GPIO(5)
1862306a36Sopenharmony_ci#define STN8815_PIN_C6		_GPIO(6)
1962306a36Sopenharmony_ci#define STN8815_PIN_B6		_GPIO(7)
2062306a36Sopenharmony_ci#define STN8815_PIN_B10		_GPIO(8)
2162306a36Sopenharmony_ci#define STN8815_PIN_A10		_GPIO(9)
2262306a36Sopenharmony_ci#define STN8815_PIN_C11		_GPIO(10)
2362306a36Sopenharmony_ci#define STN8815_PIN_B11		_GPIO(11)
2462306a36Sopenharmony_ci#define STN8815_PIN_A11		_GPIO(12)
2562306a36Sopenharmony_ci#define STN8815_PIN_C12		_GPIO(13)
2662306a36Sopenharmony_ci#define STN8815_PIN_B12		_GPIO(14)
2762306a36Sopenharmony_ci#define STN8815_PIN_A12		_GPIO(15)
2862306a36Sopenharmony_ci#define STN8815_PIN_C13		_GPIO(16)
2962306a36Sopenharmony_ci#define STN8815_PIN_B13		_GPIO(17)
3062306a36Sopenharmony_ci#define STN8815_PIN_A13		_GPIO(18)
3162306a36Sopenharmony_ci#define STN8815_PIN_D13		_GPIO(19)
3262306a36Sopenharmony_ci#define STN8815_PIN_C14		_GPIO(20)
3362306a36Sopenharmony_ci#define STN8815_PIN_B14		_GPIO(21)
3462306a36Sopenharmony_ci#define STN8815_PIN_A14		_GPIO(22)
3562306a36Sopenharmony_ci#define STN8815_PIN_D15		_GPIO(23)
3662306a36Sopenharmony_ci#define STN8815_PIN_C15		_GPIO(24)
3762306a36Sopenharmony_ci#define STN8815_PIN_B15		_GPIO(25)
3862306a36Sopenharmony_ci#define STN8815_PIN_A15		_GPIO(26)
3962306a36Sopenharmony_ci#define STN8815_PIN_C16		_GPIO(27)
4062306a36Sopenharmony_ci#define STN8815_PIN_B16		_GPIO(28)
4162306a36Sopenharmony_ci#define STN8815_PIN_A16		_GPIO(29)
4262306a36Sopenharmony_ci#define STN8815_PIN_D17		_GPIO(30)
4362306a36Sopenharmony_ci#define STN8815_PIN_C17		_GPIO(31)
4462306a36Sopenharmony_ci#define STN8815_PIN_AB6		_GPIO(32)
4562306a36Sopenharmony_ci#define STN8815_PIN_AA6		_GPIO(33)
4662306a36Sopenharmony_ci#define STN8815_PIN_Y6		_GPIO(34)
4762306a36Sopenharmony_ci#define STN8815_PIN_Y5		_GPIO(35)
4862306a36Sopenharmony_ci#define STN8815_PIN_AA5		_GPIO(36)
4962306a36Sopenharmony_ci#define STN8815_PIN_AB5		_GPIO(37)
5062306a36Sopenharmony_ci#define STN8815_PIN_AB4		_GPIO(38)
5162306a36Sopenharmony_ci#define STN8815_PIN_Y4		_GPIO(39)
5262306a36Sopenharmony_ci#define STN8815_PIN_R1		_GPIO(40)
5362306a36Sopenharmony_ci#define STN8815_PIN_R2		_GPIO(41)
5462306a36Sopenharmony_ci#define STN8815_PIN_R3		_GPIO(42)
5562306a36Sopenharmony_ci#define STN8815_PIN_P1		_GPIO(43)
5662306a36Sopenharmony_ci#define STN8815_PIN_P2		_GPIO(44)
5762306a36Sopenharmony_ci#define STN8815_PIN_P3		_GPIO(45)
5862306a36Sopenharmony_ci#define STN8815_PIN_N1		_GPIO(46)
5962306a36Sopenharmony_ci#define STN8815_PIN_N2		_GPIO(47)
6062306a36Sopenharmony_ci#define STN8815_PIN_N3		_GPIO(48)
6162306a36Sopenharmony_ci#define STN8815_PIN_M1		_GPIO(49)
6262306a36Sopenharmony_ci#define STN8815_PIN_M3		_GPIO(50)
6362306a36Sopenharmony_ci#define STN8815_PIN_M2		_GPIO(51)
6462306a36Sopenharmony_ci#define STN8815_PIN_L1		_GPIO(52)
6562306a36Sopenharmony_ci#define STN8815_PIN_L4		_GPIO(53)
6662306a36Sopenharmony_ci#define STN8815_PIN_L3		_GPIO(54)
6762306a36Sopenharmony_ci#define STN8815_PIN_L2		_GPIO(55)
6862306a36Sopenharmony_ci#define STN8815_PIN_F3		_GPIO(56)
6962306a36Sopenharmony_ci#define STN8815_PIN_F2		_GPIO(57)
7062306a36Sopenharmony_ci#define STN8815_PIN_E1		_GPIO(58)
7162306a36Sopenharmony_ci#define STN8815_PIN_E3		_GPIO(59)
7262306a36Sopenharmony_ci#define STN8815_PIN_E2		_GPIO(60)
7362306a36Sopenharmony_ci#define STN8815_PIN_E4		_GPIO(61)
7462306a36Sopenharmony_ci#define STN8815_PIN_D3		_GPIO(62)
7562306a36Sopenharmony_ci#define STN8815_PIN_D2		_GPIO(63)
7662306a36Sopenharmony_ci#define STN8815_PIN_F21		_GPIO(64)
7762306a36Sopenharmony_ci#define STN8815_PIN_F20		_GPIO(65)
7862306a36Sopenharmony_ci#define STN8815_PIN_E22		_GPIO(66)
7962306a36Sopenharmony_ci#define STN8815_PIN_D22		_GPIO(67)
8062306a36Sopenharmony_ci#define STN8815_PIN_E21		_GPIO(68)
8162306a36Sopenharmony_ci#define STN8815_PIN_E20		_GPIO(69)
8262306a36Sopenharmony_ci#define STN8815_PIN_C22		_GPIO(70)
8362306a36Sopenharmony_ci#define STN8815_PIN_D21		_GPIO(71)
8462306a36Sopenharmony_ci#define STN8815_PIN_D20		_GPIO(72)
8562306a36Sopenharmony_ci#define STN8815_PIN_C21		_GPIO(73)
8662306a36Sopenharmony_ci#define STN8815_PIN_C20		_GPIO(74)
8762306a36Sopenharmony_ci#define STN8815_PIN_C19		_GPIO(75)
8862306a36Sopenharmony_ci#define STN8815_PIN_B20		_GPIO(76)
8962306a36Sopenharmony_ci#define STN8815_PIN_B8		_GPIO(77)
9062306a36Sopenharmony_ci#define STN8815_PIN_A8		_GPIO(78)
9162306a36Sopenharmony_ci#define STN8815_PIN_C9		_GPIO(79)
9262306a36Sopenharmony_ci#define STN8815_PIN_B9		_GPIO(80)
9362306a36Sopenharmony_ci#define STN8815_PIN_A9		_GPIO(81)
9462306a36Sopenharmony_ci#define STN8815_PIN_C10		_GPIO(82)
9562306a36Sopenharmony_ci#define STN8815_PIN_K1		_GPIO(83)
9662306a36Sopenharmony_ci#define STN8815_PIN_K3		_GPIO(84)
9762306a36Sopenharmony_ci#define STN8815_PIN_K2		_GPIO(85)
9862306a36Sopenharmony_ci#define STN8815_PIN_J1		_GPIO(86)
9962306a36Sopenharmony_ci#define STN8815_PIN_J3		_GPIO(87)
10062306a36Sopenharmony_ci#define STN8815_PIN_J2		_GPIO(88)
10162306a36Sopenharmony_ci#define STN8815_PIN_H1		_GPIO(89)
10262306a36Sopenharmony_ci#define STN8815_PIN_H3		_GPIO(90)
10362306a36Sopenharmony_ci#define STN8815_PIN_H2		_GPIO(91)
10462306a36Sopenharmony_ci#define STN8815_PIN_G1		_GPIO(92)
10562306a36Sopenharmony_ci#define STN8815_PIN_G3		_GPIO(93)
10662306a36Sopenharmony_ci#define STN8815_PIN_G2		_GPIO(94)
10762306a36Sopenharmony_ci#define STN8815_PIN_F1		_GPIO(95)
10862306a36Sopenharmony_ci#define STN8815_PIN_T20		_GPIO(96)
10962306a36Sopenharmony_ci#define STN8815_PIN_R21		_GPIO(97)
11062306a36Sopenharmony_ci#define STN8815_PIN_R20		_GPIO(98)
11162306a36Sopenharmony_ci#define STN8815_PIN_U22		_GPIO(99)
11262306a36Sopenharmony_ci#define STN8815_PIN_N21		_GPIO(100)
11362306a36Sopenharmony_ci#define STN8815_PIN_N20		_GPIO(101)
11462306a36Sopenharmony_ci#define STN8815_PIN_P22		_GPIO(102)
11562306a36Sopenharmony_ci#define STN8815_PIN_N22		_GPIO(103)
11662306a36Sopenharmony_ci#define STN8815_PIN_V22		_GPIO(104)
11762306a36Sopenharmony_ci#define STN8815_PIN_V21		_GPIO(105)
11862306a36Sopenharmony_ci#define STN8815_PIN_K22		_GPIO(106)
11962306a36Sopenharmony_ci#define STN8815_PIN_K21		_GPIO(107)
12062306a36Sopenharmony_ci#define STN8815_PIN_H20		_GPIO(108)
12162306a36Sopenharmony_ci#define STN8815_PIN_G20		_GPIO(109)
12262306a36Sopenharmony_ci#define STN8815_PIN_L21		_GPIO(110)
12362306a36Sopenharmony_ci#define STN8815_PIN_H21		_GPIO(111)
12462306a36Sopenharmony_ci#define STN8815_PIN_J21		_GPIO(112)
12562306a36Sopenharmony_ci#define STN8815_PIN_H22		_GPIO(113)
12662306a36Sopenharmony_ci#define STN8815_PIN_K20		_GPIO(114)
12762306a36Sopenharmony_ci#define STN8815_PIN_L22		_GPIO(115)
12862306a36Sopenharmony_ci#define STN8815_PIN_G21		_GPIO(116)
12962306a36Sopenharmony_ci#define STN8815_PIN_J20		_GPIO(117)
13062306a36Sopenharmony_ci#define STN8815_PIN_G22		_GPIO(118)
13162306a36Sopenharmony_ci#define STN8815_PIN_U19		_GPIO(119)
13262306a36Sopenharmony_ci#define STN8815_PIN_G19		_GPIO(120)
13362306a36Sopenharmony_ci#define STN8815_PIN_M22		_GPIO(121)
13462306a36Sopenharmony_ci#define STN8815_PIN_M19		_GPIO(122)
13562306a36Sopenharmony_ci#define STN8815_PIN_J22		_GPIO(123)
13662306a36Sopenharmony_ci/* GPIOs 124-127 not routed to pins */
13762306a36Sopenharmony_ci
13862306a36Sopenharmony_ci/*
13962306a36Sopenharmony_ci * The names of the pins are denoted by GPIO number and ball name, even
14062306a36Sopenharmony_ci * though they can be used for other things than GPIO, this is the first
14162306a36Sopenharmony_ci * column in the table of the data sheet and often used on schematics and
14262306a36Sopenharmony_ci * such.
14362306a36Sopenharmony_ci */
14462306a36Sopenharmony_cistatic const struct pinctrl_pin_desc nmk_stn8815_pins[] = {
14562306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_B4, "GPIO0_B4"),
14662306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_D5, "GPIO1_D5"),
14762306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_C5, "GPIO2_C5"),
14862306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_A4, "GPIO3_A4"),
14962306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_B5, "GPIO4_B5"),
15062306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_D6, "GPIO5_D6"),
15162306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_C6, "GPIO6_C6"),
15262306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_B6, "GPIO7_B6"),
15362306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_B10, "GPIO8_B10"),
15462306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_A10, "GPIO9_A10"),
15562306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_C11, "GPIO10_C11"),
15662306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_B11, "GPIO11_B11"),
15762306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_A11, "GPIO12_A11"),
15862306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_C12, "GPIO13_C12"),
15962306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_B12, "GPIO14_B12"),
16062306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_A12, "GPIO15_A12"),
16162306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_C13, "GPIO16_C13"),
16262306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_B13, "GPIO17_B13"),
16362306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_A13, "GPIO18_A13"),
16462306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_D13, "GPIO19_D13"),
16562306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_C14, "GPIO20_C14"),
16662306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_B14, "GPIO21_B14"),
16762306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_A14, "GPIO22_A14"),
16862306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_D15, "GPIO23_D15"),
16962306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_C15, "GPIO24_C15"),
17062306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_B15, "GPIO25_B15"),
17162306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_A15, "GPIO26_A15"),
17262306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_C16, "GPIO27_C16"),
17362306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_B16, "GPIO28_B16"),
17462306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_A16, "GPIO29_A16"),
17562306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_D17, "GPIO30_D17"),
17662306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_C17, "GPIO31_C17"),
17762306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_AB6, "GPIO32_AB6"),
17862306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_AA6, "GPIO33_AA6"),
17962306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_Y6, "GPIO34_Y6"),
18062306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_Y5, "GPIO35_Y5"),
18162306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_AA5, "GPIO36_AA5"),
18262306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_AB5, "GPIO37_AB5"),
18362306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_AB4, "GPIO38_AB4"),
18462306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_Y4, "GPIO39_Y4"),
18562306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_R1, "GPIO40_R1"),
18662306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_R2, "GPIO41_R2"),
18762306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_R3, "GPIO42_R3"),
18862306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_P1, "GPIO43_P1"),
18962306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_P2, "GPIO44_P2"),
19062306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_P3, "GPIO45_P3"),
19162306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_N1, "GPIO46_N1"),
19262306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_N2, "GPIO47_N2"),
19362306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_N3, "GPIO48_N3"),
19462306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_M1, "GPIO49_M1"),
19562306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_M3, "GPIO50_M3"),
19662306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_M2, "GPIO51_M2"),
19762306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_L1, "GPIO52_L1"),
19862306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_L4, "GPIO53_L4"),
19962306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_L3, "GPIO54_L3"),
20062306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_L2, "GPIO55_L2"),
20162306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_F3, "GPIO56_F3"),
20262306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_F2, "GPIO57_F2"),
20362306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_E1, "GPIO58_E1"),
20462306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_E3, "GPIO59_E3"),
20562306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_E2, "GPIO60_E2"),
20662306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_E4, "GPIO61_E4"),
20762306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_D3, "GPIO62_D3"),
20862306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_D2, "GPIO63_D2"),
20962306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_F21, "GPIO64_F21"),
21062306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_F20, "GPIO65_F20"),
21162306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_E22, "GPIO66_E22"),
21262306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_D22, "GPIO67_D22"),
21362306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_E21, "GPIO68_E21"),
21462306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_E20, "GPIO69_E20"),
21562306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_C22, "GPIO70_C22"),
21662306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_D21, "GPIO71_D21"),
21762306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_D20, "GPIO72_D20"),
21862306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_C21, "GPIO73_C21"),
21962306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_C20, "GPIO74_C20"),
22062306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_C19, "GPIO75_C19"),
22162306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_B20, "GPIO76_B20"),
22262306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_B8, "GPIO77_B8"),
22362306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_A8, "GPIO78_A8"),
22462306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_C9, "GPIO79_C9"),
22562306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_B9, "GPIO80_B9"),
22662306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_A9, "GPIO81_A9"),
22762306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_C10, "GPIO82_C10"),
22862306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_K1, "GPIO83_K1"),
22962306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_K3, "GPIO84_K3"),
23062306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_K2, "GPIO85_K2"),
23162306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_J1, "GPIO86_J1"),
23262306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_J3, "GPIO87_J3"),
23362306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_J2, "GPIO88_J2"),
23462306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_H1, "GPIO89_H1"),
23562306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_H3, "GPIO90_H3"),
23662306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_H2, "GPIO91_H2"),
23762306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_G1, "GPIO92_G1"),
23862306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_G3, "GPIO93_G3"),
23962306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_G2, "GPIO94_G2"),
24062306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_F1, "GPIO95_F1"),
24162306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_T20, "GPIO96_T20"),
24262306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_R21, "GPIO97_R21"),
24362306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_R20, "GPIO98_R20"),
24462306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_U22, "GPIO99_U22"),
24562306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_N21, "GPIO100_N21"),
24662306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_N20, "GPIO101_N20"),
24762306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_P22, "GPIO102_P22"),
24862306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_N22, "GPIO103_N22"),
24962306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_V22, "GPIO104_V22"),
25062306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_V21, "GPIO105_V21"),
25162306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_K22, "GPIO106_K22"),
25262306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_K21, "GPIO107_K21"),
25362306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_H20, "GPIO108_H20"),
25462306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_G20, "GPIO109_G20"),
25562306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_L21, "GPIO110_L21"),
25662306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_H21, "GPIO111_H21"),
25762306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_J21, "GPIO112_J21"),
25862306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_H22, "GPIO113_H22"),
25962306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_K20, "GPIO114_K20"),
26062306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_L22, "GPIO115_L22"),
26162306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_G21, "GPIO116_G21"),
26262306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_J20, "GPIO117_J20"),
26362306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_G22, "GPIO118_G22"),
26462306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_U19, "GPIO119_U19"),
26562306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_G19, "GPIO120_G19"),
26662306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_M22, "GPIO121_M22"),
26762306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_M19, "GPIO122_M19"),
26862306a36Sopenharmony_ci	PINCTRL_PIN(STN8815_PIN_J22, "GPIO123_J22"),
26962306a36Sopenharmony_ci};
27062306a36Sopenharmony_ci
27162306a36Sopenharmony_ci/*
27262306a36Sopenharmony_ci * Read the pin group names like this:
27362306a36Sopenharmony_ci * u0_a_1    = first groups of pins for uart0 on alt function a
27462306a36Sopenharmony_ci * i2c2_b_2  = second group of pins for i2c2 on alt function b
27562306a36Sopenharmony_ci */
27662306a36Sopenharmony_ci
27762306a36Sopenharmony_ci/* Altfunction A */
27862306a36Sopenharmony_cistatic const unsigned u0txrx_a_1_pins[] = { STN8815_PIN_B4, STN8815_PIN_D5 };
27962306a36Sopenharmony_cistatic const unsigned u0ctsrts_a_1_pins[] = { STN8815_PIN_C5, STN8815_PIN_B6 };
28062306a36Sopenharmony_ci/* Modem pins: DCD, DSR, RI, DTR */
28162306a36Sopenharmony_cistatic const unsigned u0modem_a_1_pins[] = { STN8815_PIN_A4, STN8815_PIN_B5,
28262306a36Sopenharmony_ci	STN8815_PIN_D6, STN8815_PIN_C6 };
28362306a36Sopenharmony_cistatic const unsigned mmcsd_a_1_pins[] = { STN8815_PIN_B10, STN8815_PIN_A10,
28462306a36Sopenharmony_ci	STN8815_PIN_C11, STN8815_PIN_B11, STN8815_PIN_A11, STN8815_PIN_C12,
28562306a36Sopenharmony_ci	STN8815_PIN_B12, STN8815_PIN_A12, STN8815_PIN_C13, STN8815_PIN_C15 };
28662306a36Sopenharmony_cistatic const unsigned mmcsd_b_1_pins[] = { STN8815_PIN_D15 };
28762306a36Sopenharmony_cistatic const unsigned u1_a_1_pins[] = { STN8815_PIN_M2, STN8815_PIN_L1,
28862306a36Sopenharmony_ci					STN8815_PIN_F3, STN8815_PIN_F2 };
28962306a36Sopenharmony_cistatic const unsigned i2c1_a_1_pins[] = { STN8815_PIN_L4, STN8815_PIN_L3 };
29062306a36Sopenharmony_cistatic const unsigned i2c0_a_1_pins[] = { STN8815_PIN_D3, STN8815_PIN_D2 };
29162306a36Sopenharmony_ci/* Altfunction B */
29262306a36Sopenharmony_cistatic const unsigned u1_b_1_pins[] = { STN8815_PIN_B16, STN8815_PIN_A16 };
29362306a36Sopenharmony_cistatic const unsigned i2cusb_b_1_pins[] = { STN8815_PIN_C21, STN8815_PIN_C20 };
29462306a36Sopenharmony_cistatic const unsigned clcd_16_23_b_1_pins[] = { STN8815_PIN_AB6,
29562306a36Sopenharmony_ci	STN8815_PIN_AA6, STN8815_PIN_Y6, STN8815_PIN_Y5, STN8815_PIN_AA5,
29662306a36Sopenharmony_ci	STN8815_PIN_AB5, STN8815_PIN_AB4, STN8815_PIN_Y4 };
29762306a36Sopenharmony_ci/* Full-speed and high-speed USB pins */
29862306a36Sopenharmony_cistatic const unsigned usbfs_b_1_pins[] = { STN8815_PIN_E21, STN8815_PIN_E20,
29962306a36Sopenharmony_ci					   STN8815_PIN_C22, STN8815_PIN_D21,
30062306a36Sopenharmony_ci					   STN8815_PIN_D20, STN8815_PIN_C21,
30162306a36Sopenharmony_ci					   STN8815_PIN_C20 };
30262306a36Sopenharmony_cistatic const unsigned usbhs_c_1_pins[] = { STN8815_PIN_E21, STN8815_PIN_E20,
30362306a36Sopenharmony_ci					   STN8815_PIN_C20, STN8815_PIN_C19,
30462306a36Sopenharmony_ci					   STN8815_PIN_C22, STN8815_PIN_D21,
30562306a36Sopenharmony_ci					   STN8815_PIN_D20, STN8815_PIN_C21,
30662306a36Sopenharmony_ci					   STN8815_PIN_C16, STN8815_PIN_A15,
30762306a36Sopenharmony_ci					   STN8815_PIN_D17, STN8815_PIN_C17 };
30862306a36Sopenharmony_ci
30962306a36Sopenharmony_cistatic const struct nmk_pingroup nmk_stn8815_groups[] = {
31062306a36Sopenharmony_ci	NMK_PIN_GROUP(u0txrx_a_1, NMK_GPIO_ALT_A),
31162306a36Sopenharmony_ci	NMK_PIN_GROUP(u0ctsrts_a_1, NMK_GPIO_ALT_A),
31262306a36Sopenharmony_ci	NMK_PIN_GROUP(u0modem_a_1, NMK_GPIO_ALT_A),
31362306a36Sopenharmony_ci	NMK_PIN_GROUP(mmcsd_a_1, NMK_GPIO_ALT_A),
31462306a36Sopenharmony_ci	NMK_PIN_GROUP(mmcsd_b_1, NMK_GPIO_ALT_B),
31562306a36Sopenharmony_ci	NMK_PIN_GROUP(u1_a_1, NMK_GPIO_ALT_A),
31662306a36Sopenharmony_ci	NMK_PIN_GROUP(i2c1_a_1, NMK_GPIO_ALT_A),
31762306a36Sopenharmony_ci	NMK_PIN_GROUP(i2c0_a_1, NMK_GPIO_ALT_A),
31862306a36Sopenharmony_ci	NMK_PIN_GROUP(u1_b_1, NMK_GPIO_ALT_B),
31962306a36Sopenharmony_ci	NMK_PIN_GROUP(i2cusb_b_1, NMK_GPIO_ALT_B),
32062306a36Sopenharmony_ci	NMK_PIN_GROUP(clcd_16_23_b_1, NMK_GPIO_ALT_B),
32162306a36Sopenharmony_ci	NMK_PIN_GROUP(usbfs_b_1, NMK_GPIO_ALT_B),
32262306a36Sopenharmony_ci	NMK_PIN_GROUP(usbhs_c_1, NMK_GPIO_ALT_C),
32362306a36Sopenharmony_ci};
32462306a36Sopenharmony_ci
32562306a36Sopenharmony_ci/* We use this macro to define the groups applicable to a function */
32662306a36Sopenharmony_ci#define STN8815_FUNC_GROUPS(a, b...)	   \
32762306a36Sopenharmony_cistatic const char * const a##_groups[] = { b };
32862306a36Sopenharmony_ci
32962306a36Sopenharmony_ciSTN8815_FUNC_GROUPS(u0, "u0txrx_a_1", "u0ctsrts_a_1", "u0modem_a_1");
33062306a36Sopenharmony_ciSTN8815_FUNC_GROUPS(mmcsd, "mmcsd_a_1", "mmcsd_b_1");
33162306a36Sopenharmony_ciSTN8815_FUNC_GROUPS(u1, "u1_a_1", "u1_b_1");
33262306a36Sopenharmony_ciSTN8815_FUNC_GROUPS(i2c1, "i2c1_a_1");
33362306a36Sopenharmony_ciSTN8815_FUNC_GROUPS(i2c0, "i2c0_a_1");
33462306a36Sopenharmony_ciSTN8815_FUNC_GROUPS(i2cusb, "i2cusb_b_1");
33562306a36Sopenharmony_ciSTN8815_FUNC_GROUPS(clcd, "clcd_16_23_b_1");
33662306a36Sopenharmony_ciSTN8815_FUNC_GROUPS(usb, "usbfs_b_1", "usbhs_c_1");
33762306a36Sopenharmony_ci
33862306a36Sopenharmony_ci#define FUNCTION(fname)					\
33962306a36Sopenharmony_ci	{						\
34062306a36Sopenharmony_ci		.name = #fname,				\
34162306a36Sopenharmony_ci		.groups = fname##_groups,		\
34262306a36Sopenharmony_ci		.ngroups = ARRAY_SIZE(fname##_groups),	\
34362306a36Sopenharmony_ci	}
34462306a36Sopenharmony_ci
34562306a36Sopenharmony_cistatic const struct nmk_function nmk_stn8815_functions[] = {
34662306a36Sopenharmony_ci	FUNCTION(u0),
34762306a36Sopenharmony_ci	FUNCTION(mmcsd),
34862306a36Sopenharmony_ci	FUNCTION(u1),
34962306a36Sopenharmony_ci	FUNCTION(i2c1),
35062306a36Sopenharmony_ci	FUNCTION(i2c0),
35162306a36Sopenharmony_ci	FUNCTION(i2cusb),
35262306a36Sopenharmony_ci	FUNCTION(clcd),
35362306a36Sopenharmony_ci	FUNCTION(usb),
35462306a36Sopenharmony_ci};
35562306a36Sopenharmony_ci
35662306a36Sopenharmony_cistatic const struct nmk_pinctrl_soc_data nmk_stn8815_soc = {
35762306a36Sopenharmony_ci	.pins = nmk_stn8815_pins,
35862306a36Sopenharmony_ci	.npins = ARRAY_SIZE(nmk_stn8815_pins),
35962306a36Sopenharmony_ci	.functions = nmk_stn8815_functions,
36062306a36Sopenharmony_ci	.nfunctions = ARRAY_SIZE(nmk_stn8815_functions),
36162306a36Sopenharmony_ci	.groups = nmk_stn8815_groups,
36262306a36Sopenharmony_ci	.ngroups = ARRAY_SIZE(nmk_stn8815_groups),
36362306a36Sopenharmony_ci};
36462306a36Sopenharmony_ci
36562306a36Sopenharmony_civoid nmk_pinctrl_stn8815_init(const struct nmk_pinctrl_soc_data **soc)
36662306a36Sopenharmony_ci{
36762306a36Sopenharmony_ci	*soc = &nmk_stn8815_soc;
36862306a36Sopenharmony_ci}
369