18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2020 TOSHIBA CORPORATION
48c2ecf20Sopenharmony_ci * Copyright (c) 2020 Toshiba Electronic Devices & Storage Corporation
58c2ecf20Sopenharmony_ci * Copyright (c) 2020 Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#include <linux/init.h>
98c2ecf20Sopenharmony_ci#include <linux/io.h>
108c2ecf20Sopenharmony_ci#include <linux/of.h>
118c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
128c2ecf20Sopenharmony_ci#include <linux/pinctrl/pinctrl.h>
138c2ecf20Sopenharmony_ci#include "pinctrl-common.h"
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#define tmpv7700_MAGIC_NUM 0x4932f70e
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci/* register offset */
188c2ecf20Sopenharmony_ci#define REG_KEY_CTRL	0x0000
198c2ecf20Sopenharmony_ci#define REG_KEY_CMD	0x0004
208c2ecf20Sopenharmony_ci#define REG_PINMUX1	0x3000
218c2ecf20Sopenharmony_ci#define REG_PINMUX2	0x3004
228c2ecf20Sopenharmony_ci#define REG_PINMUX3	0x3008
238c2ecf20Sopenharmony_ci#define REG_PINMUX4	0x300c
248c2ecf20Sopenharmony_ci#define REG_PINMUX5	0x3010
258c2ecf20Sopenharmony_ci#define REG_IOSET	0x3014
268c2ecf20Sopenharmony_ci#define REG_IO_VSEL	0x3018
278c2ecf20Sopenharmony_ci#define REG_IO_DSEL1	0x301c
288c2ecf20Sopenharmony_ci#define REG_IO_DSEL2	0x3020
298c2ecf20Sopenharmony_ci#define REG_IO_DSEL3	0x3024
308c2ecf20Sopenharmony_ci#define REG_IO_DSEL4	0x3028
318c2ecf20Sopenharmony_ci#define REG_IO_DSEL5	0x302c
328c2ecf20Sopenharmony_ci#define REG_IO_DSEL6	0x3030
338c2ecf20Sopenharmony_ci#define REG_IO_DSEL7	0x3034
348c2ecf20Sopenharmony_ci#define REG_IO_DSEL8	0x3038
358c2ecf20Sopenharmony_ci#define REG_IO_PUDE1	0x303c
368c2ecf20Sopenharmony_ci#define REG_IO_PUDE2	0x3040
378c2ecf20Sopenharmony_ci#define REG_IO_PUDSEL1	0x3044
388c2ecf20Sopenharmony_ci#define REG_IO_PUDSEL2	0x3048
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci/* PIN */
418c2ecf20Sopenharmony_cistatic const struct visconti_desc_pin pins_tmpv7700[] = {
428c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(0, "gpio0"), REG_IO_DSEL4, 24,
438c2ecf20Sopenharmony_ci		    REG_IO_PUDE1, REG_IO_PUDSEL1, 30),
448c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(1, "gpio1"), REG_IO_DSEL4, 28,
458c2ecf20Sopenharmony_ci		    REG_IO_PUDE1, REG_IO_PUDSEL1, 31),
468c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(2, "gpio2"), REG_IO_DSEL5, 0,
478c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 0),
488c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(3, "gpio3"), REG_IO_DSEL5, 4,
498c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 1),
508c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(4, "gpio4"), REG_IO_DSEL5, 8,
518c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 2),
528c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(5, "gpio5"), REG_IO_DSEL5, 12,
538c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 3),
548c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(6, "gpio6"), REG_IO_DSEL5, 16,
558c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 4),
568c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(7, "gpio7"), REG_IO_DSEL5, 20,
578c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 5),
588c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(8, "gpio8"), REG_IO_DSEL5, 24,
598c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 6),
608c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(9, "gpio9"), REG_IO_DSEL5, 28,
618c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 7),
628c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(10, "gpio10"), REG_IO_DSEL6, 0,
638c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 8),
648c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(11, "gpio11"), REG_IO_DSEL6, 4,
658c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 9),
668c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(12, "gpio12"), REG_IO_DSEL6, 8,
678c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 10),
688c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(13, "gpio13"), REG_IO_DSEL6, 12,
698c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 11),
708c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(14, "gpio14"), REG_IO_DSEL6, 16,
718c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 12),
728c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(15, "gpio15"), REG_IO_DSEL6, 20,
738c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 13),
748c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(16, "gpio16"), REG_IO_DSEL6, 24,
758c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 14),
768c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(17, "gpio17"), REG_IO_DSEL6, 28,
778c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 15),
788c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(18, "gpio18"), REG_IO_DSEL7, 0,
798c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 16),
808c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(19, "gpio19"), REG_IO_DSEL7, 4,
818c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 17),
828c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(20, "gpio20"), REG_IO_DSEL7, 8,
838c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 18),
848c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(21, "gpio21"), REG_IO_DSEL7, 12,
858c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 19),
868c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(22, "gpio22"), REG_IO_DSEL7, 16,
878c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 20),
888c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(23, "gpio23"), REG_IO_DSEL7, 20,
898c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 21),
908c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(24, "gpio24"), REG_IO_DSEL7, 24,
918c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 22),
928c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(25, "gpio25"), REG_IO_DSEL7, 28,
938c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 23),
948c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(26, "gpio26"), REG_IO_DSEL8, 0,
958c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 24),
968c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(27, "gpio27"), REG_IO_DSEL8, 4,
978c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 25),
988c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(28, "gpio28"), REG_IO_DSEL8, 8,
998c2ecf20Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 26),
1008c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(29, "gpio29"), REG_IO_DSEL4, 8,
1018c2ecf20Sopenharmony_ci		    REG_IO_PUDE1, REG_IO_PUDSEL1, 26),
1028c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(30, "gpio30"), REG_IO_DSEL4, 4,
1038c2ecf20Sopenharmony_ci		    REG_IO_PUDE1, REG_IO_PUDSEL1, 25),
1048c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(31, "gpio31"), REG_IO_DSEL4, 0,
1058c2ecf20Sopenharmony_ci		    REG_IO_PUDE1, REG_IO_PUDSEL1, 24),
1068c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(32, "spi_sck"), REG_IO_DSEL4, 12,
1078c2ecf20Sopenharmony_ci		    REG_IO_PUDE1, REG_IO_PUDSEL1, 27),
1088c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(33, "spi_sdo"), REG_IO_DSEL4, 16,
1098c2ecf20Sopenharmony_ci		    REG_IO_PUDE1, REG_IO_PUDSEL1, 28),
1108c2ecf20Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(34, "spi_sdi"), REG_IO_DSEL4, 20,
1118c2ecf20Sopenharmony_ci		    REG_IO_PUDE1, REG_IO_PUDSEL1, 29),
1128c2ecf20Sopenharmony_ci};
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci/* Group */
1158c2ecf20Sopenharmony_ciVISCONTI_PINS(i2c0, 0, 1);
1168c2ecf20Sopenharmony_ciVISCONTI_PINS(i2c1, 2, 3);
1178c2ecf20Sopenharmony_ciVISCONTI_PINS(i2c2, 12, 13);
1188c2ecf20Sopenharmony_ciVISCONTI_PINS(i2c3, 14, 15);
1198c2ecf20Sopenharmony_ciVISCONTI_PINS(i2c4, 16, 17);
1208c2ecf20Sopenharmony_ciVISCONTI_PINS(i2c5, 18, 19);
1218c2ecf20Sopenharmony_ciVISCONTI_PINS(i2c6, 33, 34);
1228c2ecf20Sopenharmony_ciVISCONTI_PINS(i2c7, 29, 32);
1238c2ecf20Sopenharmony_ciVISCONTI_PINS(i2c8, 30, 31);
1248c2ecf20Sopenharmony_ciVISCONTI_PINS(spi0_cs0, 29);
1258c2ecf20Sopenharmony_ciVISCONTI_PINS(spi0_cs1, 30);
1268c2ecf20Sopenharmony_ciVISCONTI_PINS(spi0_cs2, 31);
1278c2ecf20Sopenharmony_ciVISCONTI_PINS(spi1_cs, 3);
1288c2ecf20Sopenharmony_ciVISCONTI_PINS(spi2_cs, 7);
1298c2ecf20Sopenharmony_ciVISCONTI_PINS(spi3_cs, 11);
1308c2ecf20Sopenharmony_ciVISCONTI_PINS(spi4_cs, 15);
1318c2ecf20Sopenharmony_ciVISCONTI_PINS(spi5_cs, 19);
1328c2ecf20Sopenharmony_ciVISCONTI_PINS(spi6_cs, 27);
1338c2ecf20Sopenharmony_ciVISCONTI_PINS(spi0, 32, 33, 34);
1348c2ecf20Sopenharmony_ciVISCONTI_PINS(spi1, 0, 1, 2);
1358c2ecf20Sopenharmony_ciVISCONTI_PINS(spi2, 4, 5, 6);
1368c2ecf20Sopenharmony_ciVISCONTI_PINS(spi3, 8, 9, 10);
1378c2ecf20Sopenharmony_ciVISCONTI_PINS(spi4, 12, 13, 14);
1388c2ecf20Sopenharmony_ciVISCONTI_PINS(spi5, 16, 17, 18);
1398c2ecf20Sopenharmony_ciVISCONTI_PINS(spi6, 24, 25, 26);
1408c2ecf20Sopenharmony_ciVISCONTI_PINS(uart0, 4, 5, 6, 7);
1418c2ecf20Sopenharmony_ciVISCONTI_PINS(uart1, 8, 9, 10, 11);
1428c2ecf20Sopenharmony_ciVISCONTI_PINS(uart2, 12, 13, 14, 15);
1438c2ecf20Sopenharmony_ciVISCONTI_PINS(uart3, 16, 17, 18, 19);
1448c2ecf20Sopenharmony_ciVISCONTI_PINS(pwm0_gpio4, 4);
1458c2ecf20Sopenharmony_ciVISCONTI_PINS(pwm1_gpio5, 5);
1468c2ecf20Sopenharmony_ciVISCONTI_PINS(pwm2_gpio6, 6);
1478c2ecf20Sopenharmony_ciVISCONTI_PINS(pwm3_gpio7, 7);
1488c2ecf20Sopenharmony_ciVISCONTI_PINS(pwm0_gpio8, 8);
1498c2ecf20Sopenharmony_ciVISCONTI_PINS(pwm1_gpio9, 9);
1508c2ecf20Sopenharmony_ciVISCONTI_PINS(pwm2_gpio10, 10);
1518c2ecf20Sopenharmony_ciVISCONTI_PINS(pwm3_gpio11, 11);
1528c2ecf20Sopenharmony_ciVISCONTI_PINS(pwm0_gpio12, 12);
1538c2ecf20Sopenharmony_ciVISCONTI_PINS(pwm1_gpio13, 13);
1548c2ecf20Sopenharmony_ciVISCONTI_PINS(pwm2_gpio14, 14);
1558c2ecf20Sopenharmony_ciVISCONTI_PINS(pwm3_gpio15, 15);
1568c2ecf20Sopenharmony_ciVISCONTI_PINS(pwm0_gpio16, 16);
1578c2ecf20Sopenharmony_ciVISCONTI_PINS(pwm1_gpio17, 17);
1588c2ecf20Sopenharmony_ciVISCONTI_PINS(pwm2_gpio18, 18);
1598c2ecf20Sopenharmony_ciVISCONTI_PINS(pwm3_gpio19, 19);
1608c2ecf20Sopenharmony_ciVISCONTI_PINS(pcmif_out, 20, 21, 22);
1618c2ecf20Sopenharmony_ciVISCONTI_PINS(pcmif_in, 24, 25, 26);
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_cistatic const struct visconti_pin_group groups_tmpv7700[] = {
1648c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(i2c0, REG_PINMUX2, GENMASK(7, 0), 0x00000022),
1658c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(i2c1, REG_PINMUX2, GENMASK(15, 8), 0x00002200),
1668c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(i2c2, REG_PINMUX3, GENMASK(23, 16), 0x00770000),
1678c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(i2c3, REG_PINMUX3, GENMASK(31, 24), 0x77000000),
1688c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(i2c4, REG_PINMUX4, GENMASK(7, 0), 0x00000077),
1698c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(i2c5, REG_PINMUX4, GENMASK(15, 8), 0x00007700),
1708c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(i2c6, REG_PINMUX1, GENMASK(3, 0), 0x0000002),
1718c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(i2c7, REG_PINMUX5, GENMASK(23, 20), 0x00200000),
1728c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(i2c8, REG_PINMUX5, GENMASK(31, 24), 0x22000000),
1738c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(spi0_cs0, REG_PINMUX5, GENMASK(23, 20), 0x00100000),
1748c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(spi0_cs1, REG_PINMUX5, GENMASK(27, 24), 0x01000000),
1758c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(spi0_cs2, REG_PINMUX5, GENMASK(31, 28), 0x10000000),
1768c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(spi1_cs, REG_PINMUX2, GENMASK(15, 12), 0x00001000),
1778c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(spi2_cs, REG_PINMUX2, GENMASK(31, 28), 0x10000000),
1788c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(spi3_cs, REG_PINMUX3, GENMASK(15, 12), 0x00001000),
1798c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(spi4_cs, REG_PINMUX4, GENMASK(31, 28), 0x10000000),
1808c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(spi5_cs, REG_PINMUX4, GENMASK(15, 12), 0x00001000),
1818c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(spi6_cs, REG_PINMUX5, GENMASK(15, 12), 0x00001000),
1828c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(spi0, REG_PINMUX1, GENMASK(3, 0), 0x00000001),
1838c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(spi1, REG_PINMUX2, GENMASK(11, 0), 0x00000111),
1848c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(spi2, REG_PINMUX2, GENMASK(27, 16), 0x01110000),
1858c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(spi3, REG_PINMUX3, GENMASK(11, 0), 0x00000111),
1868c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(spi4, REG_PINMUX3, GENMASK(27, 16), 0x01110000),
1878c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(spi5, REG_PINMUX4, GENMASK(11, 0), 0x00000111),
1888c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(spi6, REG_PINMUX5, GENMASK(11, 0), 0x00000111),
1898c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(uart0, REG_PINMUX2, GENMASK(31, 16), 0x22220000),
1908c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(uart1, REG_PINMUX3, GENMASK(15, 0), 0x00002222),
1918c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(uart2, REG_PINMUX3, GENMASK(31, 16), 0x22220000),
1928c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(uart3, REG_PINMUX4, GENMASK(15, 0), 0x00002222),
1938c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm0_gpio4, REG_PINMUX2, GENMASK(19, 16), 0x00050000),
1948c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm1_gpio5, REG_PINMUX2, GENMASK(23, 20), 0x00500000),
1958c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm2_gpio6, REG_PINMUX2, GENMASK(27, 24), 0x05000000),
1968c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm3_gpio7, REG_PINMUX2, GENMASK(31, 28), 0x50000000),
1978c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm0_gpio8, REG_PINMUX3, GENMASK(3, 0), 0x00000005),
1988c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm1_gpio9, REG_PINMUX3, GENMASK(7, 4), 0x00000050),
1998c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm2_gpio10, REG_PINMUX3, GENMASK(11, 8), 0x00000500),
2008c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm3_gpio11, REG_PINMUX3, GENMASK(15, 12), 0x00005000),
2018c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm0_gpio12, REG_PINMUX3, GENMASK(19, 16), 0x00050000),
2028c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm1_gpio13, REG_PINMUX3, GENMASK(23, 20), 0x00500000),
2038c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm2_gpio14, REG_PINMUX3, GENMASK(27, 24), 0x05000000),
2048c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm3_gpio15, REG_PINMUX3, GENMASK(31, 28), 0x50000000),
2058c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm0_gpio16, REG_PINMUX4, GENMASK(3, 0), 0x00000005),
2068c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm1_gpio17, REG_PINMUX4, GENMASK(7, 4), 0x00000050),
2078c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm2_gpio18, REG_PINMUX4, GENMASK(11, 8), 0x00000500),
2088c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm3_gpio19, REG_PINMUX4, GENMASK(15, 12), 0x00005000),
2098c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(pcmif_out, REG_PINMUX4, GENMASK(27, 16), 0x01110000),
2108c2ecf20Sopenharmony_ci	VISCONTI_PIN_GROUP(pcmif_in, REG_PINMUX5, GENMASK(11, 0), 0x00000222),
2118c2ecf20Sopenharmony_ci};
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_ci/* MUX */
2148c2ecf20Sopenharmony_ciVISCONTI_GROUPS(i2c0, "i2c0_grp");
2158c2ecf20Sopenharmony_ciVISCONTI_GROUPS(i2c1, "i2c1_grp");
2168c2ecf20Sopenharmony_ciVISCONTI_GROUPS(i2c2, "i2c2_grp");
2178c2ecf20Sopenharmony_ciVISCONTI_GROUPS(i2c3, "i2c3_grp");
2188c2ecf20Sopenharmony_ciVISCONTI_GROUPS(i2c4, "i2c4_grp");
2198c2ecf20Sopenharmony_ciVISCONTI_GROUPS(i2c5, "i2c5_grp");
2208c2ecf20Sopenharmony_ciVISCONTI_GROUPS(i2c6, "i2c6_grp");
2218c2ecf20Sopenharmony_ciVISCONTI_GROUPS(i2c7, "i2c7_grp");
2228c2ecf20Sopenharmony_ciVISCONTI_GROUPS(i2c8, "i2c8_grp");
2238c2ecf20Sopenharmony_ciVISCONTI_GROUPS(spi0, "spi0_grp", "spi0_cs0_grp",
2248c2ecf20Sopenharmony_ci		"spi0_cs1_grp", "spi0_cs2_grp");
2258c2ecf20Sopenharmony_ciVISCONTI_GROUPS(spi1, "spi1_grp", "spi1_cs_grp");
2268c2ecf20Sopenharmony_ciVISCONTI_GROUPS(spi2, "spi2_grp", "spi2_cs_grp");
2278c2ecf20Sopenharmony_ciVISCONTI_GROUPS(spi3, "spi3_grp", "spi3_cs_grp");
2288c2ecf20Sopenharmony_ciVISCONTI_GROUPS(spi4, "spi4_grp", "spi4_cs_grp");
2298c2ecf20Sopenharmony_ciVISCONTI_GROUPS(spi5, "spi5_grp", "spi5_cs_grp");
2308c2ecf20Sopenharmony_ciVISCONTI_GROUPS(spi6, "spi6_grp", "spi6_cs_grp");
2318c2ecf20Sopenharmony_ciVISCONTI_GROUPS(uart0, "uart0_grp");
2328c2ecf20Sopenharmony_ciVISCONTI_GROUPS(uart1, "uart1_grp");
2338c2ecf20Sopenharmony_ciVISCONTI_GROUPS(uart2, "uart2_grp");
2348c2ecf20Sopenharmony_ciVISCONTI_GROUPS(uart3, "uart3_grp");
2358c2ecf20Sopenharmony_ciVISCONTI_GROUPS(pwm, "pwm0_gpio4_grp", "pwm0_gpio8_grp",
2368c2ecf20Sopenharmony_ci		"pwm0_gpio12_grp", "pwm0_gpio16_grp",
2378c2ecf20Sopenharmony_ci		"pwm1_gpio5_grp", "pwm1_gpio9_grp",
2388c2ecf20Sopenharmony_ci		"pwm1_gpio13_grp", "pwm1_gpio17_grp",
2398c2ecf20Sopenharmony_ci		"pwm2_gpio6_grp", "pwm2_gpio10_grp",
2408c2ecf20Sopenharmony_ci		"pwm2_gpio14_grp", "pwm2_gpio18_grp",
2418c2ecf20Sopenharmony_ci		"pwm3_gpio7_grp", "pwm3_gpio11_grp",
2428c2ecf20Sopenharmony_ci		"pwm3_gpio15_grp", "pwm3_gpio19_grp");
2438c2ecf20Sopenharmony_ciVISCONTI_GROUPS(pcmif_out, "pcmif_out_grp");
2448c2ecf20Sopenharmony_ciVISCONTI_GROUPS(pcmif_in, "pcmif_in_grp");
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_cistatic const struct visconti_pin_function functions_tmpv7700[] = {
2478c2ecf20Sopenharmony_ci	VISCONTI_PIN_FUNCTION(i2c0),
2488c2ecf20Sopenharmony_ci	VISCONTI_PIN_FUNCTION(i2c1),
2498c2ecf20Sopenharmony_ci	VISCONTI_PIN_FUNCTION(i2c2),
2508c2ecf20Sopenharmony_ci	VISCONTI_PIN_FUNCTION(i2c3),
2518c2ecf20Sopenharmony_ci	VISCONTI_PIN_FUNCTION(i2c4),
2528c2ecf20Sopenharmony_ci	VISCONTI_PIN_FUNCTION(i2c5),
2538c2ecf20Sopenharmony_ci	VISCONTI_PIN_FUNCTION(i2c6),
2548c2ecf20Sopenharmony_ci	VISCONTI_PIN_FUNCTION(i2c7),
2558c2ecf20Sopenharmony_ci	VISCONTI_PIN_FUNCTION(i2c8),
2568c2ecf20Sopenharmony_ci	VISCONTI_PIN_FUNCTION(spi0),
2578c2ecf20Sopenharmony_ci	VISCONTI_PIN_FUNCTION(spi1),
2588c2ecf20Sopenharmony_ci	VISCONTI_PIN_FUNCTION(spi2),
2598c2ecf20Sopenharmony_ci	VISCONTI_PIN_FUNCTION(spi3),
2608c2ecf20Sopenharmony_ci	VISCONTI_PIN_FUNCTION(spi4),
2618c2ecf20Sopenharmony_ci	VISCONTI_PIN_FUNCTION(spi5),
2628c2ecf20Sopenharmony_ci	VISCONTI_PIN_FUNCTION(spi6),
2638c2ecf20Sopenharmony_ci	VISCONTI_PIN_FUNCTION(uart0),
2648c2ecf20Sopenharmony_ci	VISCONTI_PIN_FUNCTION(uart1),
2658c2ecf20Sopenharmony_ci	VISCONTI_PIN_FUNCTION(uart2),
2668c2ecf20Sopenharmony_ci	VISCONTI_PIN_FUNCTION(uart3),
2678c2ecf20Sopenharmony_ci	VISCONTI_PIN_FUNCTION(pwm),
2688c2ecf20Sopenharmony_ci	VISCONTI_PIN_FUNCTION(pcmif_in),
2698c2ecf20Sopenharmony_ci	VISCONTI_PIN_FUNCTION(pcmif_out),
2708c2ecf20Sopenharmony_ci};
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_ci/* GPIO MUX */
2738c2ecf20Sopenharmony_ci#define tmpv7700_GPIO_MUX(off, msk)	\
2748c2ecf20Sopenharmony_ci{					\
2758c2ecf20Sopenharmony_ci	.offset = off,			\
2768c2ecf20Sopenharmony_ci	.mask = msk,			\
2778c2ecf20Sopenharmony_ci	.val = 0,			\
2788c2ecf20Sopenharmony_ci}
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_cistatic const struct visconti_mux gpio_mux_tmpv7700[] = {
2818c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX2, GENMASK(3, 0)),
2828c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX2, GENMASK(7, 4)),
2838c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX2, GENMASK(11, 8)),
2848c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX2, GENMASK(15, 12)),
2858c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX2, GENMASK(19, 16)),
2868c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX2, GENMASK(23, 20)),
2878c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX2, GENMASK(27, 24)),
2888c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX2, GENMASK(31, 28)),
2898c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX3, GENMASK(3, 0)),
2908c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX3, GENMASK(7, 4)),
2918c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX3, GENMASK(11, 8)),
2928c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX3, GENMASK(15, 12)),
2938c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX3, GENMASK(19, 16)),
2948c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX3, GENMASK(23, 20)),
2958c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX3, GENMASK(27, 24)),
2968c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX3, GENMASK(31, 28)),
2978c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX4, GENMASK(3, 0)),
2988c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX4, GENMASK(7, 4)),
2998c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX4, GENMASK(11, 8)),
3008c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX4, GENMASK(15, 12)),
3018c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX4, GENMASK(19, 16)),
3028c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX4, GENMASK(23, 20)),
3038c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX4, GENMASK(27, 24)),
3048c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX4, GENMASK(31, 28)),
3058c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX5, GENMASK(3, 0)),
3068c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX5, GENMASK(7, 4)),
3078c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX5, GENMASK(11, 8)),
3088c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX5, GENMASK(15, 12)),
3098c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX5, GENMASK(19, 16)),
3108c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX5, GENMASK(23, 20)),
3118c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX5, GENMASK(27, 24)),
3128c2ecf20Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX5, GENMASK(31, 28)),
3138c2ecf20Sopenharmony_ci};
3148c2ecf20Sopenharmony_ci
3158c2ecf20Sopenharmony_cistatic void tmpv7700_pinctrl_unlock(void __iomem *base)
3168c2ecf20Sopenharmony_ci{
3178c2ecf20Sopenharmony_ci	writel(1, base + REG_KEY_CTRL);
3188c2ecf20Sopenharmony_ci	writel(tmpv7700_MAGIC_NUM, base + REG_KEY_CMD);
3198c2ecf20Sopenharmony_ci}
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_ci/* chip dependent data */
3228c2ecf20Sopenharmony_cistatic const struct visconti_pinctrl_devdata tmpv7700_pinctrl_data = {
3238c2ecf20Sopenharmony_ci	.pins = pins_tmpv7700,
3248c2ecf20Sopenharmony_ci	.nr_pins = ARRAY_SIZE(pins_tmpv7700),
3258c2ecf20Sopenharmony_ci	.groups = groups_tmpv7700,
3268c2ecf20Sopenharmony_ci	.nr_groups = ARRAY_SIZE(groups_tmpv7700),
3278c2ecf20Sopenharmony_ci	.functions = functions_tmpv7700,
3288c2ecf20Sopenharmony_ci	.nr_functions = ARRAY_SIZE(functions_tmpv7700),
3298c2ecf20Sopenharmony_ci	.gpio_mux = gpio_mux_tmpv7700,
3308c2ecf20Sopenharmony_ci	.unlock = tmpv7700_pinctrl_unlock,
3318c2ecf20Sopenharmony_ci};
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_cistatic int tmpv7700_pinctrl_probe(struct platform_device *pdev)
3348c2ecf20Sopenharmony_ci{
3358c2ecf20Sopenharmony_ci	return visconti_pinctrl_probe(pdev, &tmpv7700_pinctrl_data);
3368c2ecf20Sopenharmony_ci}
3378c2ecf20Sopenharmony_ci
3388c2ecf20Sopenharmony_cistatic const struct of_device_id tmpv7700_pctrl_of_match[] = {
3398c2ecf20Sopenharmony_ci	{ .compatible = "toshiba,tmpv7708-pinctrl", },
3408c2ecf20Sopenharmony_ci	{},
3418c2ecf20Sopenharmony_ci};
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_cistatic struct platform_driver tmpv7700_pinctrl_driver = {
3448c2ecf20Sopenharmony_ci	.probe = tmpv7700_pinctrl_probe,
3458c2ecf20Sopenharmony_ci	.driver = {
3468c2ecf20Sopenharmony_ci		.name = "tmpv7700-pinctrl",
3478c2ecf20Sopenharmony_ci		.of_match_table = tmpv7700_pctrl_of_match,
3488c2ecf20Sopenharmony_ci	},
3498c2ecf20Sopenharmony_ci};
3508c2ecf20Sopenharmony_ci
3518c2ecf20Sopenharmony_cistatic int __init tmpv7700_pinctrl_init(void)
3528c2ecf20Sopenharmony_ci{
3538c2ecf20Sopenharmony_ci	return platform_driver_register(&tmpv7700_pinctrl_driver);
3548c2ecf20Sopenharmony_ci}
3558c2ecf20Sopenharmony_ciarch_initcall(tmpv7700_pinctrl_init);
356