xref: /openbmc/linux/drivers/pinctrl/pinctrl-bm1880.c (revision 7ae9fb1b7ecbb5d85d07857943f677fd1a559b18)
18f3f0246SManivannan Sadhasivam // SPDX-License-Identifier: GPL-2.0+
28f3f0246SManivannan Sadhasivam /*
38f3f0246SManivannan Sadhasivam  * Bitmain BM1880 SoC Pinctrl driver
48f3f0246SManivannan Sadhasivam  *
58f3f0246SManivannan Sadhasivam  * Copyright (c) 2019 Linaro Ltd.
68f3f0246SManivannan Sadhasivam  * Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
78f3f0246SManivannan Sadhasivam  */
88f3f0246SManivannan Sadhasivam 
98f3f0246SManivannan Sadhasivam #include <linux/io.h>
108f3f0246SManivannan Sadhasivam #include <linux/of.h>
118f3f0246SManivannan Sadhasivam #include <linux/platform_device.h>
12*810644ccSAndy Shevchenko #include <linux/slab.h>
13*810644ccSAndy Shevchenko 
14*810644ccSAndy Shevchenko #include <linux/pinctrl/pinconf-generic.h>
15*810644ccSAndy Shevchenko #include <linux/pinctrl/pinconf.h>
168f3f0246SManivannan Sadhasivam #include <linux/pinctrl/pinctrl.h>
178f3f0246SManivannan Sadhasivam #include <linux/pinctrl/pinmux.h>
188f3f0246SManivannan Sadhasivam 
198f3f0246SManivannan Sadhasivam #include "core.h"
208f3f0246SManivannan Sadhasivam #include "pinctrl-utils.h"
218f3f0246SManivannan Sadhasivam 
228f3f0246SManivannan Sadhasivam #define BM1880_REG_MUX 0x20
238f3f0246SManivannan Sadhasivam 
248f3f0246SManivannan Sadhasivam /**
258f3f0246SManivannan Sadhasivam  * struct bm1880_pinctrl - driver data
268f3f0246SManivannan Sadhasivam  * @base:	Pinctrl base address
2721f97985SLee Jones  * @pctrldev:	Pinctrl device
288f3f0246SManivannan Sadhasivam  * @groups:	Pingroups
298f3f0246SManivannan Sadhasivam  * @ngroups:	Number of @groups
308f3f0246SManivannan Sadhasivam  * @funcs:	Pinmux functions
318f3f0246SManivannan Sadhasivam  * @nfuncs:	Number of @funcs
3221f97985SLee Jones  * @pinconf:	Pinconf data
338f3f0246SManivannan Sadhasivam  */
348f3f0246SManivannan Sadhasivam struct bm1880_pinctrl {
358f3f0246SManivannan Sadhasivam 	void __iomem *base;
368f3f0246SManivannan Sadhasivam 	struct pinctrl_dev *pctrldev;
378f3f0246SManivannan Sadhasivam 	const struct bm1880_pctrl_group *groups;
388f3f0246SManivannan Sadhasivam 	unsigned int ngroups;
398f3f0246SManivannan Sadhasivam 	const struct bm1880_pinmux_function *funcs;
408f3f0246SManivannan Sadhasivam 	unsigned int nfuncs;
419f1e3c59SManivannan Sadhasivam 	const struct bm1880_pinconf_data *pinconf;
428f3f0246SManivannan Sadhasivam };
438f3f0246SManivannan Sadhasivam 
448f3f0246SManivannan Sadhasivam /**
458f3f0246SManivannan Sadhasivam  * struct bm1880_pctrl_group - pinctrl group
468f3f0246SManivannan Sadhasivam  * @name:	Name of the group
478f3f0246SManivannan Sadhasivam  * @pins:	Array of pins belonging to this group
488f3f0246SManivannan Sadhasivam  * @npins:	Number of @pins
498f3f0246SManivannan Sadhasivam  */
508f3f0246SManivannan Sadhasivam struct bm1880_pctrl_group {
518f3f0246SManivannan Sadhasivam 	const char *name;
528f3f0246SManivannan Sadhasivam 	const unsigned int *pins;
538f3f0246SManivannan Sadhasivam 	const unsigned int npins;
548f3f0246SManivannan Sadhasivam };
558f3f0246SManivannan Sadhasivam 
568f3f0246SManivannan Sadhasivam /**
578f3f0246SManivannan Sadhasivam  * struct bm1880_pinmux_function - a pinmux function
588f3f0246SManivannan Sadhasivam  * @name:	Name of the pinmux function.
598f3f0246SManivannan Sadhasivam  * @groups:	List of pingroups for this function.
608f3f0246SManivannan Sadhasivam  * @ngroups:	Number of entries in @groups.
618f3f0246SManivannan Sadhasivam  * @mux_val:	Selector for this function
628f3f0246SManivannan Sadhasivam  * @mux:	Offset of function specific mux
638f3f0246SManivannan Sadhasivam  * @mux_shift:	Shift for function specific selector
648f3f0246SManivannan Sadhasivam  */
658f3f0246SManivannan Sadhasivam struct bm1880_pinmux_function {
668f3f0246SManivannan Sadhasivam 	const char *name;
678f3f0246SManivannan Sadhasivam 	const char * const *groups;
688f3f0246SManivannan Sadhasivam 	unsigned int ngroups;
698f3f0246SManivannan Sadhasivam 	u32 mux_val;
708f3f0246SManivannan Sadhasivam 	u32 mux;
718f3f0246SManivannan Sadhasivam 	u8 mux_shift;
728f3f0246SManivannan Sadhasivam };
738f3f0246SManivannan Sadhasivam 
749f1e3c59SManivannan Sadhasivam /**
759f1e3c59SManivannan Sadhasivam  * struct bm1880_pinconf_data - pinconf data
769f1e3c59SManivannan Sadhasivam  * @drv_bits:	Drive strength bit width
779f1e3c59SManivannan Sadhasivam  */
789f1e3c59SManivannan Sadhasivam struct bm1880_pinconf_data {
799f1e3c59SManivannan Sadhasivam 	u32 drv_bits;
809f1e3c59SManivannan Sadhasivam };
819f1e3c59SManivannan Sadhasivam 
828f3f0246SManivannan Sadhasivam static const struct pinctrl_pin_desc bm1880_pins[] = {
838f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(0,   "MIO0"),
848f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(1,   "MIO1"),
858f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(2,   "MIO2"),
868f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(3,   "MIO3"),
878f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(4,   "MIO4"),
888f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(5,   "MIO5"),
898f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(6,   "MIO6"),
908f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(7,   "MIO7"),
918f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(8,   "MIO8"),
928f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(9,   "MIO9"),
938f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(10,   "MIO10"),
948f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(11,   "MIO11"),
958f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(12,   "MIO12"),
968f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(13,   "MIO13"),
978f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(14,   "MIO14"),
988f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(15,   "MIO15"),
998f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(16,   "MIO16"),
1008f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(17,   "MIO17"),
1018f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(18,   "MIO18"),
1028f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(19,   "MIO19"),
1038f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(20,   "MIO20"),
1048f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(21,   "MIO21"),
1058f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(22,   "MIO22"),
1068f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(23,   "MIO23"),
1078f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(24,   "MIO24"),
1088f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(25,   "MIO25"),
1098f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(26,   "MIO26"),
1108f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(27,   "MIO27"),
1118f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(28,   "MIO28"),
1128f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(29,   "MIO29"),
1138f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(30,   "MIO30"),
1148f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(31,   "MIO31"),
1158f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(32,   "MIO32"),
1168f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(33,   "MIO33"),
1178f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(34,   "MIO34"),
1188f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(35,   "MIO35"),
1198f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(36,   "MIO36"),
1208f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(37,   "MIO37"),
1218f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(38,   "MIO38"),
1228f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(39,   "MIO39"),
1238f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(40,   "MIO40"),
1248f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(41,   "MIO41"),
1258f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(42,   "MIO42"),
1268f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(43,   "MIO43"),
1278f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(44,   "MIO44"),
1288f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(45,   "MIO45"),
1298f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(46,   "MIO46"),
1308f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(47,   "MIO47"),
1318f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(48,   "MIO48"),
1328f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(49,   "MIO49"),
1338f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(50,   "MIO50"),
1348f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(51,   "MIO51"),
1358f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(52,   "MIO52"),
1368f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(53,   "MIO53"),
1378f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(54,   "MIO54"),
1388f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(55,   "MIO55"),
1398f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(56,   "MIO56"),
1408f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(57,   "MIO57"),
1418f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(58,   "MIO58"),
1428f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(59,   "MIO59"),
1438f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(60,   "MIO60"),
1448f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(61,   "MIO61"),
1458f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(62,   "MIO62"),
1468f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(63,   "MIO63"),
1478f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(64,   "MIO64"),
1488f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(65,   "MIO65"),
1498f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(66,   "MIO66"),
1508f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(67,   "MIO67"),
1518f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(68,   "MIO68"),
1528f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(69,   "MIO69"),
1538f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(70,   "MIO70"),
1548f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(71,   "MIO71"),
1558f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(72,   "MIO72"),
1568f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(73,   "MIO73"),
1578f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(74,   "MIO74"),
1588f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(75,   "MIO75"),
1598f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(76,   "MIO76"),
1608f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(77,   "MIO77"),
1618f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(78,   "MIO78"),
1628f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(79,   "MIO79"),
1638f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(80,   "MIO80"),
1648f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(81,   "MIO81"),
1658f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(82,   "MIO82"),
1668f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(83,   "MIO83"),
1678f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(84,   "MIO84"),
1688f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(85,   "MIO85"),
1698f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(86,   "MIO86"),
1708f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(87,   "MIO87"),
1718f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(88,   "MIO88"),
1728f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(89,   "MIO89"),
1738f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(90,   "MIO90"),
1748f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(91,   "MIO91"),
1758f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(92,   "MIO92"),
1768f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(93,   "MIO93"),
1778f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(94,   "MIO94"),
1788f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(95,   "MIO95"),
1798f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(96,   "MIO96"),
1808f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(97,   "MIO97"),
1818f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(98,   "MIO98"),
1828f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(99,   "MIO99"),
1838f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(100,   "MIO100"),
1848f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(101,   "MIO101"),
1858f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(102,   "MIO102"),
1868f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(103,   "MIO103"),
1878f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(104,   "MIO104"),
1888f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(105,   "MIO105"),
1898f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(106,   "MIO106"),
1908f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(107,   "MIO107"),
1918f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(108,   "MIO108"),
1928f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(109,   "MIO109"),
1938f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(110,   "MIO110"),
1948f3f0246SManivannan Sadhasivam 	PINCTRL_PIN(111,   "MIO111"),
1958f3f0246SManivannan Sadhasivam };
1968f3f0246SManivannan Sadhasivam 
1978f3f0246SManivannan Sadhasivam enum bm1880_pinmux_functions {
1988f3f0246SManivannan Sadhasivam 	F_nand, F_spi, F_emmc, F_sdio, F_eth0, F_pwm0, F_pwm1, F_pwm2,
1998f3f0246SManivannan Sadhasivam 	F_pwm3, F_pwm4, F_pwm5, F_pwm6, F_pwm7, F_pwm8, F_pwm9, F_pwm10,
2008f3f0246SManivannan Sadhasivam 	F_pwm11, F_pwm12, F_pwm13, F_pwm14, F_pwm15, F_pwm16, F_pwm17,
2018f3f0246SManivannan Sadhasivam 	F_pwm18, F_pwm19, F_pwm20, F_pwm21, F_pwm22, F_pwm23, F_pwm24,
2028f3f0246SManivannan Sadhasivam 	F_pwm25, F_pwm26, F_pwm27, F_pwm28, F_pwm29, F_pwm30, F_pwm31,
2038f3f0246SManivannan Sadhasivam 	F_pwm32, F_pwm33, F_pwm34, F_pwm35, F_pwm36, F_pwm37, F_i2c0, F_i2c1,
2048f3f0246SManivannan Sadhasivam 	F_i2c2, F_i2c3, F_i2c4, F_uart0, F_uart1, F_uart2, F_uart3, F_uart4,
2058f3f0246SManivannan Sadhasivam 	F_uart5, F_uart6, F_uart7, F_uart8, F_uart9, F_uart10, F_uart11,
2068f3f0246SManivannan Sadhasivam 	F_uart12, F_uart13, F_uart14, F_uart15, F_gpio0, F_gpio1, F_gpio2,
2078f3f0246SManivannan Sadhasivam 	F_gpio3, F_gpio4, F_gpio5, F_gpio6, F_gpio7, F_gpio8, F_gpio9, F_gpio10,
2088f3f0246SManivannan Sadhasivam 	F_gpio11, F_gpio12, F_gpio13, F_gpio14, F_gpio15, F_gpio16, F_gpio17,
2098f3f0246SManivannan Sadhasivam 	F_gpio18, F_gpio19, F_gpio20, F_gpio21, F_gpio22, F_gpio23, F_gpio24,
2108f3f0246SManivannan Sadhasivam 	F_gpio25, F_gpio26, F_gpio27, F_gpio28, F_gpio29, F_gpio30, F_gpio31,
2118f3f0246SManivannan Sadhasivam 	F_gpio32, F_gpio33, F_gpio34, F_gpio35, F_gpio36, F_gpio37, F_gpio38,
2128f3f0246SManivannan Sadhasivam 	F_gpio39, F_gpio40, F_gpio41, F_gpio42, F_gpio43, F_gpio44, F_gpio45,
2138f3f0246SManivannan Sadhasivam 	F_gpio46, F_gpio47, F_gpio48, F_gpio49, F_gpio50, F_gpio51, F_gpio52,
2148f3f0246SManivannan Sadhasivam 	F_gpio53, F_gpio54, F_gpio55, F_gpio56, F_gpio57, F_gpio58, F_gpio59,
2158f3f0246SManivannan Sadhasivam 	F_gpio60, F_gpio61, F_gpio62, F_gpio63, F_gpio64, F_gpio65, F_gpio66,
2168f3f0246SManivannan Sadhasivam 	F_gpio67, F_eth1, F_i2s0, F_i2s0_mclkin, F_i2s1, F_i2s1_mclkin, F_spi0,
2178f3f0246SManivannan Sadhasivam 	F_max
2188f3f0246SManivannan Sadhasivam };
2198f3f0246SManivannan Sadhasivam 
2208f3f0246SManivannan Sadhasivam static const unsigned int nand_pins[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
2218f3f0246SManivannan Sadhasivam 					  10, 11, 12, 13, 14, 15, 16 };
2228f3f0246SManivannan Sadhasivam static const unsigned int spi_pins[] = { 0, 1, 8, 10, 11, 12, 13 };
2238f3f0246SManivannan Sadhasivam static const unsigned int emmc_pins[] = { 2, 3, 4, 5, 6, 7, 9, 14, 15, 16 };
2248f3f0246SManivannan Sadhasivam static const unsigned int sdio_pins[] = { 17, 18, 19, 20, 21, 22, 23, 24,
2258f3f0246SManivannan Sadhasivam 					  25, 26 };
2268f3f0246SManivannan Sadhasivam static const unsigned int eth0_pins[] = { 27, 28, 29, 30, 31, 32, 33, 34, 35,
2278f3f0246SManivannan Sadhasivam 					  36, 37, 38, 39, 40, 41, 42 };
2288f3f0246SManivannan Sadhasivam static const unsigned int pwm0_pins[] = { 29 };
2298f3f0246SManivannan Sadhasivam static const unsigned int pwm1_pins[] = { 30 };
2308f3f0246SManivannan Sadhasivam static const unsigned int pwm2_pins[] = { 34 };
2318f3f0246SManivannan Sadhasivam static const unsigned int pwm3_pins[] = { 35 };
2328f3f0246SManivannan Sadhasivam static const unsigned int pwm4_pins[] = { 43 };
2338f3f0246SManivannan Sadhasivam static const unsigned int pwm5_pins[] = { 44 };
2348f3f0246SManivannan Sadhasivam static const unsigned int pwm6_pins[] = { 45 };
2358f3f0246SManivannan Sadhasivam static const unsigned int pwm7_pins[] = { 46 };
2368f3f0246SManivannan Sadhasivam static const unsigned int pwm8_pins[] = { 47 };
2378f3f0246SManivannan Sadhasivam static const unsigned int pwm9_pins[] = { 48 };
2388f3f0246SManivannan Sadhasivam static const unsigned int pwm10_pins[] = { 49 };
2398f3f0246SManivannan Sadhasivam static const unsigned int pwm11_pins[] = { 50 };
2408f3f0246SManivannan Sadhasivam static const unsigned int pwm12_pins[] = { 51 };
2418f3f0246SManivannan Sadhasivam static const unsigned int pwm13_pins[] = { 52 };
2428f3f0246SManivannan Sadhasivam static const unsigned int pwm14_pins[] = { 53 };
2438f3f0246SManivannan Sadhasivam static const unsigned int pwm15_pins[] = { 54 };
2448f3f0246SManivannan Sadhasivam static const unsigned int pwm16_pins[] = { 55 };
2458f3f0246SManivannan Sadhasivam static const unsigned int pwm17_pins[] = { 56 };
2468f3f0246SManivannan Sadhasivam static const unsigned int pwm18_pins[] = { 57 };
2478f3f0246SManivannan Sadhasivam static const unsigned int pwm19_pins[] = { 58 };
2488f3f0246SManivannan Sadhasivam static const unsigned int pwm20_pins[] = { 59 };
2498f3f0246SManivannan Sadhasivam static const unsigned int pwm21_pins[] = { 60 };
2508f3f0246SManivannan Sadhasivam static const unsigned int pwm22_pins[] = { 61 };
2518f3f0246SManivannan Sadhasivam static const unsigned int pwm23_pins[] = { 62 };
2528f3f0246SManivannan Sadhasivam static const unsigned int pwm24_pins[] = { 97 };
2538f3f0246SManivannan Sadhasivam static const unsigned int pwm25_pins[] = { 98 };
2548f3f0246SManivannan Sadhasivam static const unsigned int pwm26_pins[] = { 99 };
2558f3f0246SManivannan Sadhasivam static const unsigned int pwm27_pins[] = { 100 };
2568f3f0246SManivannan Sadhasivam static const unsigned int pwm28_pins[] = { 101 };
2578f3f0246SManivannan Sadhasivam static const unsigned int pwm29_pins[] = { 102 };
2588f3f0246SManivannan Sadhasivam static const unsigned int pwm30_pins[] = { 103 };
2598f3f0246SManivannan Sadhasivam static const unsigned int pwm31_pins[] = { 104 };
2608f3f0246SManivannan Sadhasivam static const unsigned int pwm32_pins[] = { 105 };
2618f3f0246SManivannan Sadhasivam static const unsigned int pwm33_pins[] = { 106 };
2628f3f0246SManivannan Sadhasivam static const unsigned int pwm34_pins[] = { 107 };
2638f3f0246SManivannan Sadhasivam static const unsigned int pwm35_pins[] = { 108 };
2648f3f0246SManivannan Sadhasivam static const unsigned int pwm36_pins[] = { 109 };
2658f3f0246SManivannan Sadhasivam static const unsigned int pwm37_pins[] = { 110 };
2668f3f0246SManivannan Sadhasivam static const unsigned int i2c0_pins[] = { 63, 64 };
2678f3f0246SManivannan Sadhasivam static const unsigned int i2c1_pins[] = { 65, 66 };
2688f3f0246SManivannan Sadhasivam static const unsigned int i2c2_pins[] = { 67, 68 };
2698f3f0246SManivannan Sadhasivam static const unsigned int i2c3_pins[] = { 69, 70 };
2708f3f0246SManivannan Sadhasivam static const unsigned int i2c4_pins[] = { 71, 72 };
2718f3f0246SManivannan Sadhasivam static const unsigned int uart0_pins[] = { 73, 74 };
2728f3f0246SManivannan Sadhasivam static const unsigned int uart1_pins[] = { 75, 76 };
2738f3f0246SManivannan Sadhasivam static const unsigned int uart2_pins[] = { 77, 78 };
2748f3f0246SManivannan Sadhasivam static const unsigned int uart3_pins[] = { 79, 80 };
2758f3f0246SManivannan Sadhasivam static const unsigned int uart4_pins[] = { 81, 82 };
2768f3f0246SManivannan Sadhasivam static const unsigned int uart5_pins[] = { 83, 84 };
2778f3f0246SManivannan Sadhasivam static const unsigned int uart6_pins[] = { 85, 86 };
2788f3f0246SManivannan Sadhasivam static const unsigned int uart7_pins[] = { 87, 88 };
2798f3f0246SManivannan Sadhasivam static const unsigned int uart8_pins[] = { 89, 90 };
2808f3f0246SManivannan Sadhasivam static const unsigned int uart9_pins[] = { 91, 92 };
2818f3f0246SManivannan Sadhasivam static const unsigned int uart10_pins[] = { 93, 94 };
2828f3f0246SManivannan Sadhasivam static const unsigned int uart11_pins[] = { 95, 96 };
2838f3f0246SManivannan Sadhasivam static const unsigned int uart12_pins[] = { 73, 74, 75, 76 };
2848f3f0246SManivannan Sadhasivam static const unsigned int uart13_pins[] = { 77, 78, 83, 84 };
2858f3f0246SManivannan Sadhasivam static const unsigned int uart14_pins[] = { 79, 80, 85, 86 };
2868f3f0246SManivannan Sadhasivam static const unsigned int uart15_pins[] = { 81, 82, 87, 88 };
2878f3f0246SManivannan Sadhasivam static const unsigned int gpio0_pins[] = { 97 };
2888f3f0246SManivannan Sadhasivam static const unsigned int gpio1_pins[] = { 98 };
2898f3f0246SManivannan Sadhasivam static const unsigned int gpio2_pins[] = { 99 };
2908f3f0246SManivannan Sadhasivam static const unsigned int gpio3_pins[] = { 100 };
2918f3f0246SManivannan Sadhasivam static const unsigned int gpio4_pins[] = { 101 };
2928f3f0246SManivannan Sadhasivam static const unsigned int gpio5_pins[] = { 102 };
2938f3f0246SManivannan Sadhasivam static const unsigned int gpio6_pins[] = { 103 };
2948f3f0246SManivannan Sadhasivam static const unsigned int gpio7_pins[] = { 104 };
2958f3f0246SManivannan Sadhasivam static const unsigned int gpio8_pins[] = { 105 };
2968f3f0246SManivannan Sadhasivam static const unsigned int gpio9_pins[] = { 106 };
2978f3f0246SManivannan Sadhasivam static const unsigned int gpio10_pins[] = { 107 };
2988f3f0246SManivannan Sadhasivam static const unsigned int gpio11_pins[] = { 108 };
2998f3f0246SManivannan Sadhasivam static const unsigned int gpio12_pins[] = { 109 };
3008f3f0246SManivannan Sadhasivam static const unsigned int gpio13_pins[] = { 110 };
3018f3f0246SManivannan Sadhasivam static const unsigned int gpio14_pins[] = { 43 };
3028f3f0246SManivannan Sadhasivam static const unsigned int gpio15_pins[] = { 44 };
3038f3f0246SManivannan Sadhasivam static const unsigned int gpio16_pins[] = { 45 };
3048f3f0246SManivannan Sadhasivam static const unsigned int gpio17_pins[] = { 46 };
3058f3f0246SManivannan Sadhasivam static const unsigned int gpio18_pins[] = { 47 };
3068f3f0246SManivannan Sadhasivam static const unsigned int gpio19_pins[] = { 48 };
3078f3f0246SManivannan Sadhasivam static const unsigned int gpio20_pins[] = { 49 };
3088f3f0246SManivannan Sadhasivam static const unsigned int gpio21_pins[] = { 50 };
3098f3f0246SManivannan Sadhasivam static const unsigned int gpio22_pins[] = { 51 };
3108f3f0246SManivannan Sadhasivam static const unsigned int gpio23_pins[] = { 52 };
3118f3f0246SManivannan Sadhasivam static const unsigned int gpio24_pins[] = { 53 };
3128f3f0246SManivannan Sadhasivam static const unsigned int gpio25_pins[] = { 54 };
3138f3f0246SManivannan Sadhasivam static const unsigned int gpio26_pins[] = { 55 };
3148f3f0246SManivannan Sadhasivam static const unsigned int gpio27_pins[] = { 56 };
3158f3f0246SManivannan Sadhasivam static const unsigned int gpio28_pins[] = { 57 };
3168f3f0246SManivannan Sadhasivam static const unsigned int gpio29_pins[] = { 58 };
3178f3f0246SManivannan Sadhasivam static const unsigned int gpio30_pins[] = { 59 };
3188f3f0246SManivannan Sadhasivam static const unsigned int gpio31_pins[] = { 60 };
3198f3f0246SManivannan Sadhasivam static const unsigned int gpio32_pins[] = { 61 };
3208f3f0246SManivannan Sadhasivam static const unsigned int gpio33_pins[] = { 62 };
3218f3f0246SManivannan Sadhasivam static const unsigned int gpio34_pins[] = { 63 };
3228f3f0246SManivannan Sadhasivam static const unsigned int gpio35_pins[] = { 64 };
3238f3f0246SManivannan Sadhasivam static const unsigned int gpio36_pins[] = { 65 };
3248f3f0246SManivannan Sadhasivam static const unsigned int gpio37_pins[] = { 66 };
3258f3f0246SManivannan Sadhasivam static const unsigned int gpio38_pins[] = { 67 };
3268f3f0246SManivannan Sadhasivam static const unsigned int gpio39_pins[] = { 68 };
3278f3f0246SManivannan Sadhasivam static const unsigned int gpio40_pins[] = { 69 };
3288f3f0246SManivannan Sadhasivam static const unsigned int gpio41_pins[] = { 70 };
3298f3f0246SManivannan Sadhasivam static const unsigned int gpio42_pins[] = { 71 };
3308f3f0246SManivannan Sadhasivam static const unsigned int gpio43_pins[] = { 72 };
3318f3f0246SManivannan Sadhasivam static const unsigned int gpio44_pins[] = { 73 };
3328f3f0246SManivannan Sadhasivam static const unsigned int gpio45_pins[] = { 74 };
3338f3f0246SManivannan Sadhasivam static const unsigned int gpio46_pins[] = { 75 };
3348f3f0246SManivannan Sadhasivam static const unsigned int gpio47_pins[] = { 76 };
3358f3f0246SManivannan Sadhasivam static const unsigned int gpio48_pins[] = { 77 };
3368f3f0246SManivannan Sadhasivam static const unsigned int gpio49_pins[] = { 78 };
3378f3f0246SManivannan Sadhasivam static const unsigned int gpio50_pins[] = { 79 };
3388f3f0246SManivannan Sadhasivam static const unsigned int gpio51_pins[] = { 80 };
3398f3f0246SManivannan Sadhasivam static const unsigned int gpio52_pins[] = { 81 };
3408f3f0246SManivannan Sadhasivam static const unsigned int gpio53_pins[] = { 82 };
3418f3f0246SManivannan Sadhasivam static const unsigned int gpio54_pins[] = { 83 };
3428f3f0246SManivannan Sadhasivam static const unsigned int gpio55_pins[] = { 84 };
3438f3f0246SManivannan Sadhasivam static const unsigned int gpio56_pins[] = { 85 };
3448f3f0246SManivannan Sadhasivam static const unsigned int gpio57_pins[] = { 86 };
3458f3f0246SManivannan Sadhasivam static const unsigned int gpio58_pins[] = { 87 };
3468f3f0246SManivannan Sadhasivam static const unsigned int gpio59_pins[] = { 88 };
3478f3f0246SManivannan Sadhasivam static const unsigned int gpio60_pins[] = { 89 };
3488f3f0246SManivannan Sadhasivam static const unsigned int gpio61_pins[] = { 90 };
3498f3f0246SManivannan Sadhasivam static const unsigned int gpio62_pins[] = { 91 };
3508f3f0246SManivannan Sadhasivam static const unsigned int gpio63_pins[] = { 92 };
3518f3f0246SManivannan Sadhasivam static const unsigned int gpio64_pins[] = { 93 };
3528f3f0246SManivannan Sadhasivam static const unsigned int gpio65_pins[] = { 94 };
3538f3f0246SManivannan Sadhasivam static const unsigned int gpio66_pins[] = { 95 };
3548f3f0246SManivannan Sadhasivam static const unsigned int gpio67_pins[] = { 96 };
3558f3f0246SManivannan Sadhasivam static const unsigned int eth1_pins[] = { 43, 44, 45, 46, 47, 48, 49, 50, 51,
3568f3f0246SManivannan Sadhasivam 					  52, 53, 54, 55, 56, 57, 58 };
3578f3f0246SManivannan Sadhasivam static const unsigned int i2s0_pins[] = { 87, 88, 89, 90, 91 };
3588f3f0246SManivannan Sadhasivam static const unsigned int i2s0_mclkin_pins[] = { 97 };
3598f3f0246SManivannan Sadhasivam static const unsigned int i2s1_pins[] = { 92, 93, 94, 95, 96 };
3608f3f0246SManivannan Sadhasivam static const unsigned int i2s1_mclkin_pins[] = { 98 };
3618f3f0246SManivannan Sadhasivam static const unsigned int spi0_pins[] = { 59, 60, 61, 62 };
3628f3f0246SManivannan Sadhasivam 
3638f3f0246SManivannan Sadhasivam #define BM1880_PINCTRL_GRP(nm) \
3648f3f0246SManivannan Sadhasivam 	{ \
3658f3f0246SManivannan Sadhasivam 		.name = #nm "_grp", \
3668f3f0246SManivannan Sadhasivam 		.pins = nm ## _pins, \
3678f3f0246SManivannan Sadhasivam 		.npins = ARRAY_SIZE(nm ## _pins), \
3688f3f0246SManivannan Sadhasivam 	}
3698f3f0246SManivannan Sadhasivam 
3708f3f0246SManivannan Sadhasivam static const struct bm1880_pctrl_group bm1880_pctrl_groups[] = {
3718f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(nand),
3728f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(spi),
3738f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(emmc),
3748f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(sdio),
3758f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(eth0),
3768f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm0),
3778f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm1),
3788f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm2),
3798f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm3),
3808f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm4),
3818f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm5),
3828f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm6),
3838f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm7),
3848f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm8),
3858f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm9),
3868f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm10),
3878f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm11),
3888f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm12),
3898f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm13),
3908f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm14),
3918f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm15),
3928f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm16),
3938f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm17),
3948f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm18),
3958f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm19),
3968f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm20),
3978f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm21),
3988f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm22),
3998f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm23),
4008f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm24),
4018f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm25),
4028f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm26),
4038f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm27),
4048f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm28),
4058f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm29),
4068f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm30),
4078f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm31),
4088f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm32),
4098f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm33),
4108f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm34),
4118f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm35),
4128f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(pwm36),
4130320d260SJason Yan 	BM1880_PINCTRL_GRP(pwm37),
4148f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(i2c0),
4158f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(i2c1),
4168f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(i2c2),
4178f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(i2c3),
4188f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(i2c4),
4198f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(uart0),
4208f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(uart1),
4218f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(uart2),
4228f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(uart3),
4238f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(uart4),
4248f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(uart5),
4258f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(uart6),
4268f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(uart7),
4278f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(uart8),
4288f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(uart9),
4298f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(uart10),
4308f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(uart11),
4318f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(uart12),
4328f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(uart13),
4338f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(uart14),
4348f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(uart15),
4358f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio0),
4368f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio1),
4378f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio2),
4388f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio3),
4398f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio4),
4408f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio5),
4418f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio6),
4428f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio7),
4438f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio8),
4448f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio9),
4458f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio10),
4468f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio11),
4478f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio12),
4488f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio13),
4498f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio14),
4508f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio15),
4518f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio16),
4528f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio17),
4538f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio18),
4548f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio19),
4558f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio20),
4568f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio21),
4578f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio22),
4588f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio23),
4598f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio24),
4608f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio25),
4618f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio26),
4628f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio27),
4638f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio28),
4648f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio29),
4658f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio30),
4668f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio31),
4678f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio32),
4688f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio33),
4698f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio34),
4708f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio35),
4718f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio36),
4728f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio37),
4738f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio38),
4748f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio39),
4758f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio40),
4768f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio41),
4778f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio42),
4788f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio43),
4798f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio44),
4808f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio45),
4818f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio46),
4828f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio47),
4838f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio48),
4848f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio49),
4858f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio50),
4868f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio51),
4878f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio52),
4888f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio53),
4898f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio54),
4908f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio55),
4918f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio56),
4928f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio57),
4938f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio58),
4948f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio59),
4958f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio60),
4968f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio61),
4978f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio62),
4988f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio63),
4998f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio64),
5008f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio65),
5018f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio66),
5028f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(gpio67),
5038f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(eth1),
5048f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(i2s0),
5058f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(i2s0_mclkin),
5068f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(i2s1),
5078f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(i2s1_mclkin),
5088f3f0246SManivannan Sadhasivam 	BM1880_PINCTRL_GRP(spi0),
5098f3f0246SManivannan Sadhasivam };
5108f3f0246SManivannan Sadhasivam 
5118f3f0246SManivannan Sadhasivam static const char * const nand_group[] = { "nand_grp" };
5128f3f0246SManivannan Sadhasivam static const char * const spi_group[] = { "spi_grp" };
5138f3f0246SManivannan Sadhasivam static const char * const emmc_group[] = { "emmc_grp" };
5148f3f0246SManivannan Sadhasivam static const char * const sdio_group[] = { "sdio_grp" };
5158f3f0246SManivannan Sadhasivam static const char * const eth0_group[] = { "eth0_grp" };
5168f3f0246SManivannan Sadhasivam static const char * const pwm0_group[] = { "pwm0_grp" };
5178f3f0246SManivannan Sadhasivam static const char * const pwm1_group[] = { "pwm1_grp" };
5188f3f0246SManivannan Sadhasivam static const char * const pwm2_group[] = { "pwm2_grp" };
5198f3f0246SManivannan Sadhasivam static const char * const pwm3_group[] = { "pwm3_grp" };
5208f3f0246SManivannan Sadhasivam static const char * const pwm4_group[] = { "pwm4_grp" };
5218f3f0246SManivannan Sadhasivam static const char * const pwm5_group[] = { "pwm5_grp" };
5228f3f0246SManivannan Sadhasivam static const char * const pwm6_group[] = { "pwm6_grp" };
5238f3f0246SManivannan Sadhasivam static const char * const pwm7_group[] = { "pwm7_grp" };
5248f3f0246SManivannan Sadhasivam static const char * const pwm8_group[] = { "pwm8_grp" };
5258f3f0246SManivannan Sadhasivam static const char * const pwm9_group[] = { "pwm9_grp" };
5268f3f0246SManivannan Sadhasivam static const char * const pwm10_group[] = { "pwm10_grp" };
5278f3f0246SManivannan Sadhasivam static const char * const pwm11_group[] = { "pwm11_grp" };
5288f3f0246SManivannan Sadhasivam static const char * const pwm12_group[] = { "pwm12_grp" };
5298f3f0246SManivannan Sadhasivam static const char * const pwm13_group[] = { "pwm13_grp" };
5308f3f0246SManivannan Sadhasivam static const char * const pwm14_group[] = { "pwm14_grp" };
5318f3f0246SManivannan Sadhasivam static const char * const pwm15_group[] = { "pwm15_grp" };
5328f3f0246SManivannan Sadhasivam static const char * const pwm16_group[] = { "pwm16_grp" };
5338f3f0246SManivannan Sadhasivam static const char * const pwm17_group[] = { "pwm17_grp" };
5348f3f0246SManivannan Sadhasivam static const char * const pwm18_group[] = { "pwm18_grp" };
5358f3f0246SManivannan Sadhasivam static const char * const pwm19_group[] = { "pwm19_grp" };
5368f3f0246SManivannan Sadhasivam static const char * const pwm20_group[] = { "pwm20_grp" };
5378f3f0246SManivannan Sadhasivam static const char * const pwm21_group[] = { "pwm21_grp" };
5388f3f0246SManivannan Sadhasivam static const char * const pwm22_group[] = { "pwm22_grp" };
5398f3f0246SManivannan Sadhasivam static const char * const pwm23_group[] = { "pwm23_grp" };
5408f3f0246SManivannan Sadhasivam static const char * const pwm24_group[] = { "pwm24_grp" };
5418f3f0246SManivannan Sadhasivam static const char * const pwm25_group[] = { "pwm25_grp" };
5428f3f0246SManivannan Sadhasivam static const char * const pwm26_group[] = { "pwm26_grp" };
5438f3f0246SManivannan Sadhasivam static const char * const pwm27_group[] = { "pwm27_grp" };
5448f3f0246SManivannan Sadhasivam static const char * const pwm28_group[] = { "pwm28_grp" };
5458f3f0246SManivannan Sadhasivam static const char * const pwm29_group[] = { "pwm29_grp" };
5468f3f0246SManivannan Sadhasivam static const char * const pwm30_group[] = { "pwm30_grp" };
5478f3f0246SManivannan Sadhasivam static const char * const pwm31_group[] = { "pwm31_grp" };
5488f3f0246SManivannan Sadhasivam static const char * const pwm32_group[] = { "pwm32_grp" };
5498f3f0246SManivannan Sadhasivam static const char * const pwm33_group[] = { "pwm33_grp" };
5508f3f0246SManivannan Sadhasivam static const char * const pwm34_group[] = { "pwm34_grp" };
5518f3f0246SManivannan Sadhasivam static const char * const pwm35_group[] = { "pwm35_grp" };
5528f3f0246SManivannan Sadhasivam static const char * const pwm36_group[] = { "pwm36_grp" };
5538f3f0246SManivannan Sadhasivam static const char * const pwm37_group[] = { "pwm37_grp" };
5548f3f0246SManivannan Sadhasivam static const char * const i2c0_group[] = { "i2c0_grp" };
5558f3f0246SManivannan Sadhasivam static const char * const i2c1_group[] = { "i2c1_grp" };
5568f3f0246SManivannan Sadhasivam static const char * const i2c2_group[] = { "i2c2_grp" };
5578f3f0246SManivannan Sadhasivam static const char * const i2c3_group[] = { "i2c3_grp" };
5588f3f0246SManivannan Sadhasivam static const char * const i2c4_group[] = { "i2c4_grp" };
5598f3f0246SManivannan Sadhasivam static const char * const uart0_group[] = { "uart0_grp" };
5608f3f0246SManivannan Sadhasivam static const char * const uart1_group[] = { "uart1_grp" };
5618f3f0246SManivannan Sadhasivam static const char * const uart2_group[] = { "uart2_grp" };
5628f3f0246SManivannan Sadhasivam static const char * const uart3_group[] = { "uart3_grp" };
5638f3f0246SManivannan Sadhasivam static const char * const uart4_group[] = { "uart4_grp" };
5648f3f0246SManivannan Sadhasivam static const char * const uart5_group[] = { "uart5_grp" };
5658f3f0246SManivannan Sadhasivam static const char * const uart6_group[] = { "uart6_grp" };
5668f3f0246SManivannan Sadhasivam static const char * const uart7_group[] = { "uart7_grp" };
5678f3f0246SManivannan Sadhasivam static const char * const uart8_group[] = { "uart8_grp" };
5688f3f0246SManivannan Sadhasivam static const char * const uart9_group[] = { "uart9_grp" };
5698f3f0246SManivannan Sadhasivam static const char * const uart10_group[] = { "uart10_grp" };
5708f3f0246SManivannan Sadhasivam static const char * const uart11_group[] = { "uart11_grp" };
5718f3f0246SManivannan Sadhasivam static const char * const uart12_group[] = { "uart12_grp" };
5728f3f0246SManivannan Sadhasivam static const char * const uart13_group[] = { "uart13_grp" };
5738f3f0246SManivannan Sadhasivam static const char * const uart14_group[] = { "uart14_grp" };
5748f3f0246SManivannan Sadhasivam static const char * const uart15_group[] = { "uart15_grp" };
5758f3f0246SManivannan Sadhasivam static const char * const gpio0_group[] = { "gpio0_grp" };
5768f3f0246SManivannan Sadhasivam static const char * const gpio1_group[] = { "gpio1_grp" };
5778f3f0246SManivannan Sadhasivam static const char * const gpio2_group[] = { "gpio2_grp" };
5788f3f0246SManivannan Sadhasivam static const char * const gpio3_group[] = { "gpio3_grp" };
5798f3f0246SManivannan Sadhasivam static const char * const gpio4_group[] = { "gpio4_grp" };
5808f3f0246SManivannan Sadhasivam static const char * const gpio5_group[] = { "gpio5_grp" };
5818f3f0246SManivannan Sadhasivam static const char * const gpio6_group[] = { "gpio6_grp" };
5828f3f0246SManivannan Sadhasivam static const char * const gpio7_group[] = { "gpio7_grp" };
5838f3f0246SManivannan Sadhasivam static const char * const gpio8_group[] = { "gpio8_grp" };
5848f3f0246SManivannan Sadhasivam static const char * const gpio9_group[] = { "gpio9_grp" };
5858f3f0246SManivannan Sadhasivam static const char * const gpio10_group[] = { "gpio10_grp" };
5868f3f0246SManivannan Sadhasivam static const char * const gpio11_group[] = { "gpio11_grp" };
5878f3f0246SManivannan Sadhasivam static const char * const gpio12_group[] = { "gpio12_grp" };
5888f3f0246SManivannan Sadhasivam static const char * const gpio13_group[] = { "gpio13_grp" };
5898f3f0246SManivannan Sadhasivam static const char * const gpio14_group[] = { "gpio14_grp" };
5908f3f0246SManivannan Sadhasivam static const char * const gpio15_group[] = { "gpio15_grp" };
5918f3f0246SManivannan Sadhasivam static const char * const gpio16_group[] = { "gpio16_grp" };
5928f3f0246SManivannan Sadhasivam static const char * const gpio17_group[] = { "gpio17_grp" };
5938f3f0246SManivannan Sadhasivam static const char * const gpio18_group[] = { "gpio18_grp" };
5948f3f0246SManivannan Sadhasivam static const char * const gpio19_group[] = { "gpio19_grp" };
5958f3f0246SManivannan Sadhasivam static const char * const gpio20_group[] = { "gpio20_grp" };
5968f3f0246SManivannan Sadhasivam static const char * const gpio21_group[] = { "gpio21_grp" };
5978f3f0246SManivannan Sadhasivam static const char * const gpio22_group[] = { "gpio22_grp" };
5988f3f0246SManivannan Sadhasivam static const char * const gpio23_group[] = { "gpio23_grp" };
5998f3f0246SManivannan Sadhasivam static const char * const gpio24_group[] = { "gpio24_grp" };
6008f3f0246SManivannan Sadhasivam static const char * const gpio25_group[] = { "gpio25_grp" };
6018f3f0246SManivannan Sadhasivam static const char * const gpio26_group[] = { "gpio26_grp" };
6028f3f0246SManivannan Sadhasivam static const char * const gpio27_group[] = { "gpio27_grp" };
6038f3f0246SManivannan Sadhasivam static const char * const gpio28_group[] = { "gpio28_grp" };
6048f3f0246SManivannan Sadhasivam static const char * const gpio29_group[] = { "gpio29_grp" };
6058f3f0246SManivannan Sadhasivam static const char * const gpio30_group[] = { "gpio30_grp" };
6068f3f0246SManivannan Sadhasivam static const char * const gpio31_group[] = { "gpio31_grp" };
6078f3f0246SManivannan Sadhasivam static const char * const gpio32_group[] = { "gpio32_grp" };
6088f3f0246SManivannan Sadhasivam static const char * const gpio33_group[] = { "gpio33_grp" };
6098f3f0246SManivannan Sadhasivam static const char * const gpio34_group[] = { "gpio34_grp" };
6108f3f0246SManivannan Sadhasivam static const char * const gpio35_group[] = { "gpio35_grp" };
6118f3f0246SManivannan Sadhasivam static const char * const gpio36_group[] = { "gpio36_grp" };
6128f3f0246SManivannan Sadhasivam static const char * const gpio37_group[] = { "gpio37_grp" };
6138f3f0246SManivannan Sadhasivam static const char * const gpio38_group[] = { "gpio38_grp" };
6148f3f0246SManivannan Sadhasivam static const char * const gpio39_group[] = { "gpio39_grp" };
6158f3f0246SManivannan Sadhasivam static const char * const gpio40_group[] = { "gpio40_grp" };
6168f3f0246SManivannan Sadhasivam static const char * const gpio41_group[] = { "gpio41_grp" };
6178f3f0246SManivannan Sadhasivam static const char * const gpio42_group[] = { "gpio42_grp" };
6188f3f0246SManivannan Sadhasivam static const char * const gpio43_group[] = { "gpio43_grp" };
6198f3f0246SManivannan Sadhasivam static const char * const gpio44_group[] = { "gpio44_grp" };
6208f3f0246SManivannan Sadhasivam static const char * const gpio45_group[] = { "gpio45_grp" };
6218f3f0246SManivannan Sadhasivam static const char * const gpio46_group[] = { "gpio46_grp" };
6228f3f0246SManivannan Sadhasivam static const char * const gpio47_group[] = { "gpio47_grp" };
6238f3f0246SManivannan Sadhasivam static const char * const gpio48_group[] = { "gpio48_grp" };
6248f3f0246SManivannan Sadhasivam static const char * const gpio49_group[] = { "gpio49_grp" };
6258f3f0246SManivannan Sadhasivam static const char * const gpio50_group[] = { "gpio50_grp" };
6268f3f0246SManivannan Sadhasivam static const char * const gpio51_group[] = { "gpio51_grp" };
6278f3f0246SManivannan Sadhasivam static const char * const gpio52_group[] = { "gpio52_grp" };
6288f3f0246SManivannan Sadhasivam static const char * const gpio53_group[] = { "gpio53_grp" };
6298f3f0246SManivannan Sadhasivam static const char * const gpio54_group[] = { "gpio54_grp" };
6308f3f0246SManivannan Sadhasivam static const char * const gpio55_group[] = { "gpio55_grp" };
6318f3f0246SManivannan Sadhasivam static const char * const gpio56_group[] = { "gpio56_grp" };
6328f3f0246SManivannan Sadhasivam static const char * const gpio57_group[] = { "gpio57_grp" };
6338f3f0246SManivannan Sadhasivam static const char * const gpio58_group[] = { "gpio58_grp" };
6348f3f0246SManivannan Sadhasivam static const char * const gpio59_group[] = { "gpio59_grp" };
6358f3f0246SManivannan Sadhasivam static const char * const gpio60_group[] = { "gpio60_grp" };
6368f3f0246SManivannan Sadhasivam static const char * const gpio61_group[] = { "gpio61_grp" };
6378f3f0246SManivannan Sadhasivam static const char * const gpio62_group[] = { "gpio62_grp" };
6388f3f0246SManivannan Sadhasivam static const char * const gpio63_group[] = { "gpio63_grp" };
6398f3f0246SManivannan Sadhasivam static const char * const gpio64_group[] = { "gpio64_grp" };
6408f3f0246SManivannan Sadhasivam static const char * const gpio65_group[] = { "gpio65_grp" };
6418f3f0246SManivannan Sadhasivam static const char * const gpio66_group[] = { "gpio66_grp" };
6428f3f0246SManivannan Sadhasivam static const char * const gpio67_group[] = { "gpio67_grp" };
6438f3f0246SManivannan Sadhasivam static const char * const eth1_group[] = { "eth1_grp" };
6448f3f0246SManivannan Sadhasivam static const char * const i2s0_group[] = { "i2s0_grp" };
6458f3f0246SManivannan Sadhasivam static const char * const i2s0_mclkin_group[] = { "i2s0_mclkin_grp" };
6468f3f0246SManivannan Sadhasivam static const char * const i2s1_group[] = { "i2s1_grp" };
6478f3f0246SManivannan Sadhasivam static const char * const i2s1_mclkin_group[] = { "i2s1_mclkin_grp" };
6488f3f0246SManivannan Sadhasivam static const char * const spi0_group[] = { "spi0_grp" };
6498f3f0246SManivannan Sadhasivam 
6508247b247SManivannan Sadhasivam #define BM1880_PINMUX_FUNCTION(fname, mval)		\
6518f3f0246SManivannan Sadhasivam 	[F_##fname] = {					\
6528f3f0246SManivannan Sadhasivam 		.name = #fname,				\
6538f3f0246SManivannan Sadhasivam 		.groups = fname##_group,		\
6548f3f0246SManivannan Sadhasivam 		.ngroups = ARRAY_SIZE(fname##_group),	\
6558f3f0246SManivannan Sadhasivam 		.mux_val = mval,			\
6568f3f0246SManivannan Sadhasivam 	}
6578f3f0246SManivannan Sadhasivam 
6588f3f0246SManivannan Sadhasivam static const struct bm1880_pinmux_function bm1880_pmux_functions[] = {
6598247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(nand, 2),
6608247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(spi, 0),
6618247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(emmc, 1),
6628247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(sdio, 0),
6638247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(eth0, 0),
6648247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm0, 2),
6658247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm1, 2),
6668247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm2, 2),
6678247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm3, 2),
6688247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm4, 2),
6698247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm5, 2),
6708247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm6, 2),
6718247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm7, 2),
6728247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm8, 2),
6738247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm9, 2),
6748247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm10, 2),
6758247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm11, 2),
6768247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm12, 2),
6778247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm13, 2),
6788247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm14, 2),
6798247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm15, 2),
6808247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm16, 2),
6818247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm17, 2),
6828247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm18, 2),
6838247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm19, 2),
6848247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm20, 2),
6858247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm21, 2),
6868247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm22, 2),
6878247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm23, 2),
6888247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm24, 2),
6898247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm25, 2),
6908247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm26, 2),
6918247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm27, 2),
6928247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm28, 2),
6938247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm29, 2),
6948247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm30, 2),
6958247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm31, 2),
6968247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm32, 2),
6978247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm33, 2),
6988247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm34, 2),
6998247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm35, 2),
7008247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm36, 2),
7018247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(pwm37, 2),
7028247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(i2c0, 1),
7038247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(i2c1, 1),
7048247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(i2c2, 1),
7058247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(i2c3, 1),
7068247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(i2c4, 1),
7078247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(uart0, 3),
7088247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(uart1, 3),
7098247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(uart2, 3),
7108247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(uart3, 3),
7118247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(uart4, 1),
7128247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(uart5, 1),
7138247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(uart6, 1),
7148247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(uart7, 1),
7158247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(uart8, 1),
7168247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(uart9, 1),
7178247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(uart10, 1),
7188247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(uart11, 1),
7198247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(uart12, 3),
7208247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(uart13, 3),
7218247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(uart14, 3),
7228247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(uart15, 3),
7238247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio0, 0),
7248247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio1, 0),
7258247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio2, 0),
7268247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio3, 0),
7278247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio4, 0),
7288247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio5, 0),
7298247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio6, 0),
7308247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio7, 0),
7318247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio8, 0),
7328247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio9, 0),
7338247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio10, 0),
7348247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio11, 0),
7358247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio12, 1),
7368247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio13, 1),
7378247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio14, 0),
7388247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio15, 0),
7398247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio16, 0),
7408247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio17, 0),
7418247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio18, 0),
7428247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio19, 0),
7438247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio20, 0),
7448247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio21, 0),
7458247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio22, 0),
7468247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio23, 0),
7478247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio24, 0),
7488247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio25, 0),
7498247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio26, 0),
7508247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio27, 0),
7518247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio28, 0),
7528247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio29, 0),
7538247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio30, 0),
7548247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio31, 0),
7558247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio32, 0),
7568247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio33, 0),
7578247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio34, 0),
7588247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio35, 0),
7598247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio36, 0),
7608247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio37, 0),
7618247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio38, 0),
7628247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio39, 0),
7638247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio40, 0),
7648247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio41, 0),
7658247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio42, 0),
7668247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio43, 0),
7678247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio44, 0),
7688247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio45, 0),
7698247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio46, 0),
7708247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio47, 0),
7718247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio48, 0),
7728247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio49, 0),
7738247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio50, 0),
7748247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio51, 0),
7758247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio52, 0),
7768247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio53, 0),
7778247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio54, 0),
7788247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio55, 0),
7798247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio56, 0),
7808247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio57, 0),
7818247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio58, 0),
7828247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio59, 0),
7838247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio60, 0),
7848247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio61, 0),
7858247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio62, 0),
7868247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio63, 0),
7878247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio64, 0),
7888247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio65, 0),
7898247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio66, 0),
7908247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(gpio67, 0),
7918247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(eth1, 1),
7928247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(i2s0, 2),
7938247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(i2s0_mclkin, 1),
7948247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(i2s1, 2),
7958247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(i2s1_mclkin, 1),
7968247b247SManivannan Sadhasivam 	BM1880_PINMUX_FUNCTION(spi0, 1),
7978f3f0246SManivannan Sadhasivam };
7988f3f0246SManivannan Sadhasivam 
7999f1e3c59SManivannan Sadhasivam #define BM1880_PINCONF_DAT(_width)		\
8009f1e3c59SManivannan Sadhasivam 	{					\
8019f1e3c59SManivannan Sadhasivam 		.drv_bits = _width,		\
8029f1e3c59SManivannan Sadhasivam 	}
8039f1e3c59SManivannan Sadhasivam 
8049f1e3c59SManivannan Sadhasivam static const struct bm1880_pinconf_data bm1880_pinconf[] = {
8059f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8069f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8079f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8089f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8099f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8109f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8119f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8129f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8139f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8149f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8159f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8169f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8179f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8189f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8199f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8209f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8219f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8229f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8239f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8249f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8259f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8269f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8279f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8289f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8299f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8309f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8319f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8329f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8339f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8349f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8359f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8369f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8379f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8389f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8399f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8409f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8419f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8429f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8439f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8449f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8459f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8469f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8479f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8489f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8499f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8509f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8519f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8529f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8539f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8549f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8559f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8569f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8579f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8589f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8599f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8609f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8619f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8629f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8639f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8649f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x03),
8659f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8669f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8679f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8689f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8699f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8709f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8719f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8729f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8739f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8749f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8759f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8769f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8779f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8789f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8799f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8809f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8819f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8829f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8839f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8849f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8859f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8869f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8879f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8889f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8899f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8909f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8919f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8929f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8939f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8949f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8959f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8969f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8979f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8989f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
8999f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
9009f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
9019f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
9029f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
9039f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
9049f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
9059f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
9069f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
9079f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
9089f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
9099f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
9109f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
9119f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
9129f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
9139f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
9149f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
9159f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
9169f1e3c59SManivannan Sadhasivam 	BM1880_PINCONF_DAT(0x02),
9179f1e3c59SManivannan Sadhasivam };
9189f1e3c59SManivannan Sadhasivam 
bm1880_pctrl_get_groups_count(struct pinctrl_dev * pctldev)9198f3f0246SManivannan Sadhasivam static int bm1880_pctrl_get_groups_count(struct pinctrl_dev *pctldev)
9208f3f0246SManivannan Sadhasivam {
9218f3f0246SManivannan Sadhasivam 	struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
9228f3f0246SManivannan Sadhasivam 
9238f3f0246SManivannan Sadhasivam 	return pctrl->ngroups;
9248f3f0246SManivannan Sadhasivam }
9258f3f0246SManivannan Sadhasivam 
bm1880_pctrl_get_group_name(struct pinctrl_dev * pctldev,unsigned int selector)9268f3f0246SManivannan Sadhasivam static const char *bm1880_pctrl_get_group_name(struct pinctrl_dev *pctldev,
9278f3f0246SManivannan Sadhasivam 					       unsigned int selector)
9288f3f0246SManivannan Sadhasivam {
9298f3f0246SManivannan Sadhasivam 	struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
9308f3f0246SManivannan Sadhasivam 
9318f3f0246SManivannan Sadhasivam 	return pctrl->groups[selector].name;
9328f3f0246SManivannan Sadhasivam }
9338f3f0246SManivannan Sadhasivam 
bm1880_pctrl_get_group_pins(struct pinctrl_dev * pctldev,unsigned int selector,const unsigned int ** pins,unsigned int * num_pins)9348f3f0246SManivannan Sadhasivam static int bm1880_pctrl_get_group_pins(struct pinctrl_dev *pctldev,
9358f3f0246SManivannan Sadhasivam 				       unsigned int selector,
9368f3f0246SManivannan Sadhasivam 				       const unsigned int **pins,
9378f3f0246SManivannan Sadhasivam 				       unsigned int *num_pins)
9388f3f0246SManivannan Sadhasivam {
9398f3f0246SManivannan Sadhasivam 	struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
9408f3f0246SManivannan Sadhasivam 
9418f3f0246SManivannan Sadhasivam 	*pins = pctrl->groups[selector].pins;
9428f3f0246SManivannan Sadhasivam 	*num_pins = pctrl->groups[selector].npins;
9438f3f0246SManivannan Sadhasivam 
9448f3f0246SManivannan Sadhasivam 	return 0;
9458f3f0246SManivannan Sadhasivam }
9468f3f0246SManivannan Sadhasivam 
9478f3f0246SManivannan Sadhasivam static const struct pinctrl_ops bm1880_pctrl_ops = {
9488f3f0246SManivannan Sadhasivam 	.get_groups_count = bm1880_pctrl_get_groups_count,
9498f3f0246SManivannan Sadhasivam 	.get_group_name = bm1880_pctrl_get_group_name,
9508f3f0246SManivannan Sadhasivam 	.get_group_pins = bm1880_pctrl_get_group_pins,
9518f3f0246SManivannan Sadhasivam 	.dt_node_to_map = pinconf_generic_dt_node_to_map_all,
9528f3f0246SManivannan Sadhasivam 	.dt_free_map = pinctrl_utils_free_map,
9538f3f0246SManivannan Sadhasivam };
9548f3f0246SManivannan Sadhasivam 
9558f3f0246SManivannan Sadhasivam /* pinmux */
bm1880_pmux_get_functions_count(struct pinctrl_dev * pctldev)9568f3f0246SManivannan Sadhasivam static int bm1880_pmux_get_functions_count(struct pinctrl_dev *pctldev)
9578f3f0246SManivannan Sadhasivam {
9588f3f0246SManivannan Sadhasivam 	struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
9598f3f0246SManivannan Sadhasivam 
9608f3f0246SManivannan Sadhasivam 	return pctrl->nfuncs;
9618f3f0246SManivannan Sadhasivam }
9628f3f0246SManivannan Sadhasivam 
bm1880_pmux_get_function_name(struct pinctrl_dev * pctldev,unsigned int selector)9638f3f0246SManivannan Sadhasivam static const char *bm1880_pmux_get_function_name(struct pinctrl_dev *pctldev,
9648f3f0246SManivannan Sadhasivam 						 unsigned int selector)
9658f3f0246SManivannan Sadhasivam {
9668f3f0246SManivannan Sadhasivam 	struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
9678f3f0246SManivannan Sadhasivam 
9688f3f0246SManivannan Sadhasivam 	return pctrl->funcs[selector].name;
9698f3f0246SManivannan Sadhasivam }
9708f3f0246SManivannan Sadhasivam 
bm1880_pmux_get_function_groups(struct pinctrl_dev * pctldev,unsigned int selector,const char * const ** groups,unsigned * const num_groups)9718f3f0246SManivannan Sadhasivam static int bm1880_pmux_get_function_groups(struct pinctrl_dev *pctldev,
9728f3f0246SManivannan Sadhasivam 					   unsigned int selector,
9738f3f0246SManivannan Sadhasivam 					   const char * const **groups,
9748f3f0246SManivannan Sadhasivam 					   unsigned * const num_groups)
9758f3f0246SManivannan Sadhasivam {
9768f3f0246SManivannan Sadhasivam 	struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
9778f3f0246SManivannan Sadhasivam 
9788f3f0246SManivannan Sadhasivam 	*groups = pctrl->funcs[selector].groups;
9798f3f0246SManivannan Sadhasivam 	*num_groups = pctrl->funcs[selector].ngroups;
9808f3f0246SManivannan Sadhasivam 	return 0;
9818f3f0246SManivannan Sadhasivam }
9828f3f0246SManivannan Sadhasivam 
bm1880_pinmux_set_mux(struct pinctrl_dev * pctldev,unsigned int function,unsigned int group)9838f3f0246SManivannan Sadhasivam static int bm1880_pinmux_set_mux(struct pinctrl_dev *pctldev,
9848f3f0246SManivannan Sadhasivam 				 unsigned int function,
9858f3f0246SManivannan Sadhasivam 				 unsigned int  group)
9868f3f0246SManivannan Sadhasivam {
9878f3f0246SManivannan Sadhasivam 	struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
9888f3f0246SManivannan Sadhasivam 	const struct bm1880_pctrl_group *pgrp = &pctrl->groups[group];
9898f3f0246SManivannan Sadhasivam 	const struct bm1880_pinmux_function *func = &pctrl->funcs[function];
9908f3f0246SManivannan Sadhasivam 	int i;
9918f3f0246SManivannan Sadhasivam 
9928f3f0246SManivannan Sadhasivam 	for (i = 0; i < pgrp->npins; i++) {
9938f3f0246SManivannan Sadhasivam 		unsigned int pin = pgrp->pins[i];
9948f3f0246SManivannan Sadhasivam 		u32 offset = (pin >> 1) << 2;
9958f3f0246SManivannan Sadhasivam 		u32 mux_offset = ((!((pin + 1) & 1) << 4) + 4);
9968247b247SManivannan Sadhasivam 		u32 regval = readl_relaxed(pctrl->base + BM1880_REG_MUX +
9978247b247SManivannan Sadhasivam 					   offset);
9988f3f0246SManivannan Sadhasivam 
9998247b247SManivannan Sadhasivam 		regval &= ~(0x03 << mux_offset);
10008f3f0246SManivannan Sadhasivam 		regval |= func->mux_val << mux_offset;
10018f3f0246SManivannan Sadhasivam 
10028247b247SManivannan Sadhasivam 		writel_relaxed(regval, pctrl->base + BM1880_REG_MUX + offset);
10038f3f0246SManivannan Sadhasivam 	}
10048f3f0246SManivannan Sadhasivam 
10058f3f0246SManivannan Sadhasivam 	return 0;
10068f3f0246SManivannan Sadhasivam }
10078f3f0246SManivannan Sadhasivam 
100849bd61ebSManivannan Sadhasivam #define BM1880_PINCONF(pin, idx) ((!((pin + 1) & 1) << 4) + idx)
100949bd61ebSManivannan Sadhasivam #define BM1880_PINCONF_PULLCTRL(pin)	BM1880_PINCONF(pin, 0)
101049bd61ebSManivannan Sadhasivam #define BM1880_PINCONF_PULLUP(pin)	BM1880_PINCONF(pin, 1)
101149bd61ebSManivannan Sadhasivam #define BM1880_PINCONF_PULLDOWN(pin)	BM1880_PINCONF(pin, 2)
10129f1e3c59SManivannan Sadhasivam #define BM1880_PINCONF_DRV(pin)		BM1880_PINCONF(pin, 6)
101349bd61ebSManivannan Sadhasivam #define BM1880_PINCONF_SCHMITT(pin)	BM1880_PINCONF(pin, 9)
101449bd61ebSManivannan Sadhasivam #define BM1880_PINCONF_SLEW(pin)	BM1880_PINCONF(pin, 10)
101549bd61ebSManivannan Sadhasivam 
bm1880_pinconf_drv_set(unsigned int mA,u32 width,u32 * regval,u32 bit_offset)10169f1e3c59SManivannan Sadhasivam static int bm1880_pinconf_drv_set(unsigned int mA, u32 width,
10179f1e3c59SManivannan Sadhasivam 				  u32 *regval, u32 bit_offset)
10189f1e3c59SManivannan Sadhasivam {
10199f1e3c59SManivannan Sadhasivam 	u32 _regval;
10209f1e3c59SManivannan Sadhasivam 
10219f1e3c59SManivannan Sadhasivam 	_regval = *regval;
10229f1e3c59SManivannan Sadhasivam 
10239f1e3c59SManivannan Sadhasivam 	/*
10249f1e3c59SManivannan Sadhasivam 	 * There are two sets of drive strength bit width exposed by the
10259f1e3c59SManivannan Sadhasivam 	 * SoC at 4mA step, hence we need to handle them separately.
10269f1e3c59SManivannan Sadhasivam 	 */
10279f1e3c59SManivannan Sadhasivam 	if (width == 0x03) {
10289f1e3c59SManivannan Sadhasivam 		switch (mA) {
10299f1e3c59SManivannan Sadhasivam 		case 4:
10309f1e3c59SManivannan Sadhasivam 			_regval &= ~(width << bit_offset);
10319f1e3c59SManivannan Sadhasivam 			_regval |= (0 << bit_offset);
10329f1e3c59SManivannan Sadhasivam 			break;
10339f1e3c59SManivannan Sadhasivam 		case 8:
10349f1e3c59SManivannan Sadhasivam 			_regval &= ~(width << bit_offset);
10359f1e3c59SManivannan Sadhasivam 			_regval |= (1 << bit_offset);
10369f1e3c59SManivannan Sadhasivam 			break;
10379f1e3c59SManivannan Sadhasivam 		case 12:
10389f1e3c59SManivannan Sadhasivam 			_regval &= ~(width << bit_offset);
10399f1e3c59SManivannan Sadhasivam 			_regval |= (2 << bit_offset);
10409f1e3c59SManivannan Sadhasivam 			break;
10419f1e3c59SManivannan Sadhasivam 		case 16:
10429f1e3c59SManivannan Sadhasivam 			_regval &= ~(width << bit_offset);
10439f1e3c59SManivannan Sadhasivam 			_regval |= (3 << bit_offset);
10449f1e3c59SManivannan Sadhasivam 			break;
10459f1e3c59SManivannan Sadhasivam 		case 20:
10469f1e3c59SManivannan Sadhasivam 			_regval &= ~(width << bit_offset);
10479f1e3c59SManivannan Sadhasivam 			_regval |= (4 << bit_offset);
10489f1e3c59SManivannan Sadhasivam 			break;
10499f1e3c59SManivannan Sadhasivam 		case 24:
10509f1e3c59SManivannan Sadhasivam 			_regval &= ~(width << bit_offset);
10519f1e3c59SManivannan Sadhasivam 			_regval |= (5 << bit_offset);
10529f1e3c59SManivannan Sadhasivam 			break;
10539f1e3c59SManivannan Sadhasivam 		case 28:
10549f1e3c59SManivannan Sadhasivam 			_regval &= ~(width << bit_offset);
10559f1e3c59SManivannan Sadhasivam 			_regval |= (6 << bit_offset);
10569f1e3c59SManivannan Sadhasivam 			break;
10579f1e3c59SManivannan Sadhasivam 		case 32:
10589f1e3c59SManivannan Sadhasivam 			_regval &= ~(width << bit_offset);
10599f1e3c59SManivannan Sadhasivam 			_regval |= (7 << bit_offset);
10609f1e3c59SManivannan Sadhasivam 			break;
10619f1e3c59SManivannan Sadhasivam 		default:
10629f1e3c59SManivannan Sadhasivam 			return -EINVAL;
10639f1e3c59SManivannan Sadhasivam 		}
10649f1e3c59SManivannan Sadhasivam 	} else {
10659f1e3c59SManivannan Sadhasivam 		switch (mA) {
10669f1e3c59SManivannan Sadhasivam 		case 4:
10679f1e3c59SManivannan Sadhasivam 			_regval &= ~(width << bit_offset);
10689f1e3c59SManivannan Sadhasivam 			_regval |= (0 << bit_offset);
10699f1e3c59SManivannan Sadhasivam 			break;
10709f1e3c59SManivannan Sadhasivam 		case 8:
10719f1e3c59SManivannan Sadhasivam 			_regval &= ~(width << bit_offset);
10729f1e3c59SManivannan Sadhasivam 			_regval |= (1 << bit_offset);
10739f1e3c59SManivannan Sadhasivam 			break;
10749f1e3c59SManivannan Sadhasivam 		case 12:
10759f1e3c59SManivannan Sadhasivam 			_regval &= ~(width << bit_offset);
10769f1e3c59SManivannan Sadhasivam 			_regval |= (2 << bit_offset);
10779f1e3c59SManivannan Sadhasivam 			break;
10789f1e3c59SManivannan Sadhasivam 		case 16:
10799f1e3c59SManivannan Sadhasivam 			_regval &= ~(width << bit_offset);
10809f1e3c59SManivannan Sadhasivam 			_regval |= (3 << bit_offset);
10819f1e3c59SManivannan Sadhasivam 			break;
10829f1e3c59SManivannan Sadhasivam 		default:
10839f1e3c59SManivannan Sadhasivam 			return -EINVAL;
10849f1e3c59SManivannan Sadhasivam 		}
10859f1e3c59SManivannan Sadhasivam 	}
10869f1e3c59SManivannan Sadhasivam 
10879f1e3c59SManivannan Sadhasivam 	*regval = _regval;
10889f1e3c59SManivannan Sadhasivam 
10899f1e3c59SManivannan Sadhasivam 	return 0;
10909f1e3c59SManivannan Sadhasivam }
10919f1e3c59SManivannan Sadhasivam 
bm1880_pinconf_drv_get(u32 width,u32 drv)10929f1e3c59SManivannan Sadhasivam static int bm1880_pinconf_drv_get(u32 width, u32 drv)
10939f1e3c59SManivannan Sadhasivam {
10949f1e3c59SManivannan Sadhasivam 	int ret = -ENOTSUPP;
10959f1e3c59SManivannan Sadhasivam 
10969f1e3c59SManivannan Sadhasivam 	/*
10979f1e3c59SManivannan Sadhasivam 	 * There are two sets of drive strength bit width exposed by the
10989f1e3c59SManivannan Sadhasivam 	 * SoC at 4mA step, hence we need to handle them separately.
10999f1e3c59SManivannan Sadhasivam 	 */
11009f1e3c59SManivannan Sadhasivam 	if (width == 0x03) {
11019f1e3c59SManivannan Sadhasivam 		switch (drv) {
11029f1e3c59SManivannan Sadhasivam 		case 0:
11039f1e3c59SManivannan Sadhasivam 			ret  = 4;
11049f1e3c59SManivannan Sadhasivam 			break;
11059f1e3c59SManivannan Sadhasivam 		case 1:
11069f1e3c59SManivannan Sadhasivam 			ret  = 8;
11079f1e3c59SManivannan Sadhasivam 			break;
11089f1e3c59SManivannan Sadhasivam 		case 2:
11099f1e3c59SManivannan Sadhasivam 			ret  = 12;
11109f1e3c59SManivannan Sadhasivam 			break;
11119f1e3c59SManivannan Sadhasivam 		case 3:
11129f1e3c59SManivannan Sadhasivam 			ret  = 16;
11139f1e3c59SManivannan Sadhasivam 			break;
11149f1e3c59SManivannan Sadhasivam 		case 4:
11159f1e3c59SManivannan Sadhasivam 			ret  = 20;
11169f1e3c59SManivannan Sadhasivam 			break;
11179f1e3c59SManivannan Sadhasivam 		case 5:
11189f1e3c59SManivannan Sadhasivam 			ret  = 24;
11199f1e3c59SManivannan Sadhasivam 			break;
11209f1e3c59SManivannan Sadhasivam 		case 6:
11219f1e3c59SManivannan Sadhasivam 			ret  = 28;
11229f1e3c59SManivannan Sadhasivam 			break;
11239f1e3c59SManivannan Sadhasivam 		case 7:
11249f1e3c59SManivannan Sadhasivam 			ret  = 32;
11259f1e3c59SManivannan Sadhasivam 			break;
11269f1e3c59SManivannan Sadhasivam 		default:
11279f1e3c59SManivannan Sadhasivam 			break;
11289f1e3c59SManivannan Sadhasivam 		}
11299f1e3c59SManivannan Sadhasivam 	} else {
11309f1e3c59SManivannan Sadhasivam 		switch (drv) {
11319f1e3c59SManivannan Sadhasivam 		case 0:
11329f1e3c59SManivannan Sadhasivam 			ret  = 4;
11339f1e3c59SManivannan Sadhasivam 			break;
11349f1e3c59SManivannan Sadhasivam 		case 1:
11359f1e3c59SManivannan Sadhasivam 			ret  = 8;
11369f1e3c59SManivannan Sadhasivam 			break;
11379f1e3c59SManivannan Sadhasivam 		case 2:
11389f1e3c59SManivannan Sadhasivam 			ret  = 12;
11399f1e3c59SManivannan Sadhasivam 			break;
11409f1e3c59SManivannan Sadhasivam 		case 3:
11419f1e3c59SManivannan Sadhasivam 			ret  = 16;
11429f1e3c59SManivannan Sadhasivam 			break;
11439f1e3c59SManivannan Sadhasivam 		default:
11449f1e3c59SManivannan Sadhasivam 			break;
11459f1e3c59SManivannan Sadhasivam 		}
11469f1e3c59SManivannan Sadhasivam 	}
11479f1e3c59SManivannan Sadhasivam 
11489f1e3c59SManivannan Sadhasivam 	return ret;
11499f1e3c59SManivannan Sadhasivam }
11509f1e3c59SManivannan Sadhasivam 
bm1880_pinconf_cfg_get(struct pinctrl_dev * pctldev,unsigned int pin,unsigned long * config)115149bd61ebSManivannan Sadhasivam static int bm1880_pinconf_cfg_get(struct pinctrl_dev *pctldev,
115249bd61ebSManivannan Sadhasivam 				  unsigned int pin,
115349bd61ebSManivannan Sadhasivam 				  unsigned long *config)
115449bd61ebSManivannan Sadhasivam {
115549bd61ebSManivannan Sadhasivam 	struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
115649bd61ebSManivannan Sadhasivam 	unsigned int param = pinconf_to_config_param(*config);
115749bd61ebSManivannan Sadhasivam 	unsigned int arg = 0;
115849bd61ebSManivannan Sadhasivam 	u32 regval, offset, bit_offset;
11599f1e3c59SManivannan Sadhasivam 	int ret;
116049bd61ebSManivannan Sadhasivam 
116149bd61ebSManivannan Sadhasivam 	offset = (pin >> 1) << 2;
116249bd61ebSManivannan Sadhasivam 	regval = readl_relaxed(pctrl->base + BM1880_REG_MUX + offset);
116349bd61ebSManivannan Sadhasivam 
116449bd61ebSManivannan Sadhasivam 	switch (param) {
116549bd61ebSManivannan Sadhasivam 	case PIN_CONFIG_BIAS_PULL_UP:
116649bd61ebSManivannan Sadhasivam 		bit_offset = BM1880_PINCONF_PULLUP(pin);
116749bd61ebSManivannan Sadhasivam 		arg = !!(regval & BIT(bit_offset));
116849bd61ebSManivannan Sadhasivam 		break;
116949bd61ebSManivannan Sadhasivam 	case PIN_CONFIG_BIAS_PULL_DOWN:
117049bd61ebSManivannan Sadhasivam 		bit_offset = BM1880_PINCONF_PULLDOWN(pin);
117149bd61ebSManivannan Sadhasivam 		arg = !!(regval & BIT(bit_offset));
117249bd61ebSManivannan Sadhasivam 		break;
117349bd61ebSManivannan Sadhasivam 	case PIN_CONFIG_BIAS_DISABLE:
117449bd61ebSManivannan Sadhasivam 		bit_offset = BM1880_PINCONF_PULLCTRL(pin);
117549bd61ebSManivannan Sadhasivam 		arg = !!(regval & BIT(bit_offset));
117649bd61ebSManivannan Sadhasivam 		break;
117749bd61ebSManivannan Sadhasivam 	case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
117849bd61ebSManivannan Sadhasivam 		bit_offset = BM1880_PINCONF_SCHMITT(pin);
117949bd61ebSManivannan Sadhasivam 		arg = !!(regval & BIT(bit_offset));
118049bd61ebSManivannan Sadhasivam 		break;
118149bd61ebSManivannan Sadhasivam 	case PIN_CONFIG_SLEW_RATE:
118249bd61ebSManivannan Sadhasivam 		bit_offset = BM1880_PINCONF_SLEW(pin);
118349bd61ebSManivannan Sadhasivam 		arg = !!(regval & BIT(bit_offset));
118449bd61ebSManivannan Sadhasivam 		break;
11859f1e3c59SManivannan Sadhasivam 	case PIN_CONFIG_DRIVE_STRENGTH:
11869f1e3c59SManivannan Sadhasivam 		bit_offset = BM1880_PINCONF_DRV(pin);
11879f1e3c59SManivannan Sadhasivam 		ret = bm1880_pinconf_drv_get(pctrl->pinconf[pin].drv_bits,
11889f1e3c59SManivannan Sadhasivam 					     !!(regval & BIT(bit_offset)));
11899f1e3c59SManivannan Sadhasivam 		if (ret < 0)
11909f1e3c59SManivannan Sadhasivam 			return ret;
11919f1e3c59SManivannan Sadhasivam 
11929f1e3c59SManivannan Sadhasivam 		arg = ret;
11939f1e3c59SManivannan Sadhasivam 		break;
119449bd61ebSManivannan Sadhasivam 	default:
119549bd61ebSManivannan Sadhasivam 		return -ENOTSUPP;
119649bd61ebSManivannan Sadhasivam 	}
119749bd61ebSManivannan Sadhasivam 
119849bd61ebSManivannan Sadhasivam 	*config = pinconf_to_config_packed(param, arg);
119949bd61ebSManivannan Sadhasivam 
120049bd61ebSManivannan Sadhasivam 	return 0;
120149bd61ebSManivannan Sadhasivam }
120249bd61ebSManivannan Sadhasivam 
bm1880_pinconf_cfg_set(struct pinctrl_dev * pctldev,unsigned int pin,unsigned long * configs,unsigned int num_configs)120349bd61ebSManivannan Sadhasivam static int bm1880_pinconf_cfg_set(struct pinctrl_dev *pctldev,
120449bd61ebSManivannan Sadhasivam 				  unsigned int pin,
120549bd61ebSManivannan Sadhasivam 				  unsigned long *configs,
120649bd61ebSManivannan Sadhasivam 				  unsigned int num_configs)
120749bd61ebSManivannan Sadhasivam {
120849bd61ebSManivannan Sadhasivam 	struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
120949bd61ebSManivannan Sadhasivam 	u32 regval, offset, bit_offset;
12109f1e3c59SManivannan Sadhasivam 	int i, ret;
121149bd61ebSManivannan Sadhasivam 
121249bd61ebSManivannan Sadhasivam 	offset = (pin >> 1) << 2;
121349bd61ebSManivannan Sadhasivam 	regval = readl_relaxed(pctrl->base + BM1880_REG_MUX + offset);
121449bd61ebSManivannan Sadhasivam 
121549bd61ebSManivannan Sadhasivam 	for (i = 0; i < num_configs; i++) {
121649bd61ebSManivannan Sadhasivam 		unsigned int param = pinconf_to_config_param(configs[i]);
121749bd61ebSManivannan Sadhasivam 		unsigned int arg = pinconf_to_config_argument(configs[i]);
121849bd61ebSManivannan Sadhasivam 
121949bd61ebSManivannan Sadhasivam 		switch (param) {
122049bd61ebSManivannan Sadhasivam 		case PIN_CONFIG_BIAS_PULL_UP:
122149bd61ebSManivannan Sadhasivam 			bit_offset = BM1880_PINCONF_PULLUP(pin);
122249bd61ebSManivannan Sadhasivam 			regval |= BIT(bit_offset);
122349bd61ebSManivannan Sadhasivam 			break;
122449bd61ebSManivannan Sadhasivam 		case PIN_CONFIG_BIAS_PULL_DOWN:
122549bd61ebSManivannan Sadhasivam 			bit_offset = BM1880_PINCONF_PULLDOWN(pin);
122649bd61ebSManivannan Sadhasivam 			regval |= BIT(bit_offset);
122749bd61ebSManivannan Sadhasivam 			break;
122849bd61ebSManivannan Sadhasivam 		case PIN_CONFIG_BIAS_DISABLE:
122949bd61ebSManivannan Sadhasivam 			bit_offset = BM1880_PINCONF_PULLCTRL(pin);
123049bd61ebSManivannan Sadhasivam 			regval |= BIT(bit_offset);
123149bd61ebSManivannan Sadhasivam 			break;
123249bd61ebSManivannan Sadhasivam 		case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
123349bd61ebSManivannan Sadhasivam 			bit_offset = BM1880_PINCONF_SCHMITT(pin);
123449bd61ebSManivannan Sadhasivam 			if (arg)
123549bd61ebSManivannan Sadhasivam 				regval |= BIT(bit_offset);
123649bd61ebSManivannan Sadhasivam 			else
123749bd61ebSManivannan Sadhasivam 				regval &= ~BIT(bit_offset);
123849bd61ebSManivannan Sadhasivam 			break;
123949bd61ebSManivannan Sadhasivam 		case PIN_CONFIG_SLEW_RATE:
124049bd61ebSManivannan Sadhasivam 			bit_offset = BM1880_PINCONF_SLEW(pin);
124149bd61ebSManivannan Sadhasivam 			if (arg)
124249bd61ebSManivannan Sadhasivam 				regval |= BIT(bit_offset);
124349bd61ebSManivannan Sadhasivam 			else
124449bd61ebSManivannan Sadhasivam 				regval &= ~BIT(bit_offset);
124549bd61ebSManivannan Sadhasivam 			break;
12469f1e3c59SManivannan Sadhasivam 		case PIN_CONFIG_DRIVE_STRENGTH:
12479f1e3c59SManivannan Sadhasivam 			bit_offset = BM1880_PINCONF_DRV(pin);
12489f1e3c59SManivannan Sadhasivam 			ret = bm1880_pinconf_drv_set(arg,
12499f1e3c59SManivannan Sadhasivam 						pctrl->pinconf[pin].drv_bits,
12509f1e3c59SManivannan Sadhasivam 						&regval, bit_offset);
12519f1e3c59SManivannan Sadhasivam 			if (ret < 0)
12529f1e3c59SManivannan Sadhasivam 				return ret;
12539f1e3c59SManivannan Sadhasivam 
12549f1e3c59SManivannan Sadhasivam 			break;
125549bd61ebSManivannan Sadhasivam 		default:
125649bd61ebSManivannan Sadhasivam 			dev_warn(pctldev->dev,
125749bd61ebSManivannan Sadhasivam 				 "unsupported configuration parameter '%u'\n",
125849bd61ebSManivannan Sadhasivam 				 param);
125949bd61ebSManivannan Sadhasivam 			continue;
126049bd61ebSManivannan Sadhasivam 		}
126149bd61ebSManivannan Sadhasivam 
126249bd61ebSManivannan Sadhasivam 		writel_relaxed(regval, pctrl->base + BM1880_REG_MUX + offset);
126349bd61ebSManivannan Sadhasivam 	}
126449bd61ebSManivannan Sadhasivam 
126549bd61ebSManivannan Sadhasivam 	return 0;
126649bd61ebSManivannan Sadhasivam }
126749bd61ebSManivannan Sadhasivam 
bm1880_pinconf_group_set(struct pinctrl_dev * pctldev,unsigned int selector,unsigned long * configs,unsigned int num_configs)126849bd61ebSManivannan Sadhasivam static int bm1880_pinconf_group_set(struct pinctrl_dev *pctldev,
126949bd61ebSManivannan Sadhasivam 				    unsigned int selector,
127049bd61ebSManivannan Sadhasivam 				    unsigned long *configs,
127149bd61ebSManivannan Sadhasivam 				    unsigned int  num_configs)
127249bd61ebSManivannan Sadhasivam {
127349bd61ebSManivannan Sadhasivam 	int i, ret;
127449bd61ebSManivannan Sadhasivam 	struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
127549bd61ebSManivannan Sadhasivam 	const struct bm1880_pctrl_group *pgrp = &pctrl->groups[selector];
127649bd61ebSManivannan Sadhasivam 
127749bd61ebSManivannan Sadhasivam 	for (i = 0; i < pgrp->npins; i++) {
127849bd61ebSManivannan Sadhasivam 		ret = bm1880_pinconf_cfg_set(pctldev, pgrp->pins[i], configs,
127949bd61ebSManivannan Sadhasivam 					     num_configs);
128049bd61ebSManivannan Sadhasivam 		if (ret)
128149bd61ebSManivannan Sadhasivam 			return ret;
128249bd61ebSManivannan Sadhasivam 	}
128349bd61ebSManivannan Sadhasivam 
128449bd61ebSManivannan Sadhasivam 	return 0;
128549bd61ebSManivannan Sadhasivam }
128649bd61ebSManivannan Sadhasivam 
128749bd61ebSManivannan Sadhasivam static const struct pinconf_ops bm1880_pinconf_ops = {
128849bd61ebSManivannan Sadhasivam 	.is_generic = true,
128949bd61ebSManivannan Sadhasivam 	.pin_config_get = bm1880_pinconf_cfg_get,
129049bd61ebSManivannan Sadhasivam 	.pin_config_set = bm1880_pinconf_cfg_set,
129149bd61ebSManivannan Sadhasivam 	.pin_config_group_set = bm1880_pinconf_group_set,
129249bd61ebSManivannan Sadhasivam };
129349bd61ebSManivannan Sadhasivam 
12948f3f0246SManivannan Sadhasivam static const struct pinmux_ops bm1880_pinmux_ops = {
12958f3f0246SManivannan Sadhasivam 	.get_functions_count = bm1880_pmux_get_functions_count,
12968f3f0246SManivannan Sadhasivam 	.get_function_name = bm1880_pmux_get_function_name,
12978f3f0246SManivannan Sadhasivam 	.get_function_groups = bm1880_pmux_get_function_groups,
12988f3f0246SManivannan Sadhasivam 	.set_mux = bm1880_pinmux_set_mux,
12998f3f0246SManivannan Sadhasivam };
13008f3f0246SManivannan Sadhasivam 
13018f3f0246SManivannan Sadhasivam static struct pinctrl_desc bm1880_desc = {
13028f3f0246SManivannan Sadhasivam 	.name = "bm1880_pinctrl",
13038f3f0246SManivannan Sadhasivam 	.pins = bm1880_pins,
13048f3f0246SManivannan Sadhasivam 	.npins = ARRAY_SIZE(bm1880_pins),
13058f3f0246SManivannan Sadhasivam 	.pctlops = &bm1880_pctrl_ops,
13068f3f0246SManivannan Sadhasivam 	.pmxops = &bm1880_pinmux_ops,
130749bd61ebSManivannan Sadhasivam 	.confops = &bm1880_pinconf_ops,
13088f3f0246SManivannan Sadhasivam 	.owner = THIS_MODULE,
13098f3f0246SManivannan Sadhasivam };
13108f3f0246SManivannan Sadhasivam 
bm1880_pinctrl_probe(struct platform_device * pdev)13118f3f0246SManivannan Sadhasivam static int bm1880_pinctrl_probe(struct platform_device *pdev)
13128f3f0246SManivannan Sadhasivam 
13138f3f0246SManivannan Sadhasivam {
13148f3f0246SManivannan Sadhasivam 	struct bm1880_pinctrl *pctrl;
13158f3f0246SManivannan Sadhasivam 
13168f3f0246SManivannan Sadhasivam 	pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL);
13178f3f0246SManivannan Sadhasivam 	if (!pctrl)
13188f3f0246SManivannan Sadhasivam 		return -ENOMEM;
13198f3f0246SManivannan Sadhasivam 
13204b024225SYueHaibing 	pctrl->base = devm_platform_ioremap_resource(pdev, 0);
13218f3f0246SManivannan Sadhasivam 	if (IS_ERR(pctrl->base))
13228f3f0246SManivannan Sadhasivam 		return PTR_ERR(pctrl->base);
13238f3f0246SManivannan Sadhasivam 
13248f3f0246SManivannan Sadhasivam 	pctrl->groups = bm1880_pctrl_groups;
13258f3f0246SManivannan Sadhasivam 	pctrl->ngroups = ARRAY_SIZE(bm1880_pctrl_groups);
13268f3f0246SManivannan Sadhasivam 	pctrl->funcs = bm1880_pmux_functions;
13278f3f0246SManivannan Sadhasivam 	pctrl->nfuncs = ARRAY_SIZE(bm1880_pmux_functions);
13289f1e3c59SManivannan Sadhasivam 	pctrl->pinconf = bm1880_pinconf;
13298f3f0246SManivannan Sadhasivam 
13308f3f0246SManivannan Sadhasivam 	pctrl->pctrldev = devm_pinctrl_register(&pdev->dev, &bm1880_desc,
13318f3f0246SManivannan Sadhasivam 						pctrl);
13328f3f0246SManivannan Sadhasivam 	if (IS_ERR(pctrl->pctrldev))
13338f3f0246SManivannan Sadhasivam 		return PTR_ERR(pctrl->pctrldev);
13348f3f0246SManivannan Sadhasivam 
13358f3f0246SManivannan Sadhasivam 	platform_set_drvdata(pdev, pctrl);
13368f3f0246SManivannan Sadhasivam 
13378f3f0246SManivannan Sadhasivam 	dev_info(&pdev->dev, "BM1880 pinctrl driver initialized\n");
13388f3f0246SManivannan Sadhasivam 
13398f3f0246SManivannan Sadhasivam 	return 0;
13408f3f0246SManivannan Sadhasivam }
13418f3f0246SManivannan Sadhasivam 
13428f3f0246SManivannan Sadhasivam static const struct of_device_id bm1880_pinctrl_of_match[] = {
13438f3f0246SManivannan Sadhasivam 	{ .compatible = "bitmain,bm1880-pinctrl" },
13448f3f0246SManivannan Sadhasivam 	{ }
13458f3f0246SManivannan Sadhasivam };
13468f3f0246SManivannan Sadhasivam 
13478f3f0246SManivannan Sadhasivam static struct platform_driver bm1880_pinctrl_driver = {
13488f3f0246SManivannan Sadhasivam 	.driver = {
13498f3f0246SManivannan Sadhasivam 		.name = "pinctrl-bm1880",
13508f3f0246SManivannan Sadhasivam 		.of_match_table = of_match_ptr(bm1880_pinctrl_of_match),
13518f3f0246SManivannan Sadhasivam 	},
13528f3f0246SManivannan Sadhasivam 	.probe = bm1880_pinctrl_probe,
13538f3f0246SManivannan Sadhasivam };
13548f3f0246SManivannan Sadhasivam 
bm1880_pinctrl_init(void)13558f3f0246SManivannan Sadhasivam static int __init bm1880_pinctrl_init(void)
13568f3f0246SManivannan Sadhasivam {
13578f3f0246SManivannan Sadhasivam 	return platform_driver_register(&bm1880_pinctrl_driver);
13588f3f0246SManivannan Sadhasivam }
13598f3f0246SManivannan Sadhasivam arch_initcall(bm1880_pinctrl_init);
1360