162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (c) 2020 TOSHIBA CORPORATION
462306a36Sopenharmony_ci * Copyright (c) 2020 Toshiba Electronic Devices & Storage Corporation
562306a36Sopenharmony_ci * Copyright (c) 2020 Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#include <linux/init.h>
962306a36Sopenharmony_ci#include <linux/io.h>
1062306a36Sopenharmony_ci#include <linux/of.h>
1162306a36Sopenharmony_ci#include <linux/platform_device.h>
1262306a36Sopenharmony_ci#include <linux/pinctrl/pinctrl.h>
1362306a36Sopenharmony_ci#include "pinctrl-common.h"
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#define tmpv7700_MAGIC_NUM 0x4932f70e
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci/* register offset */
1862306a36Sopenharmony_ci#define REG_KEY_CTRL	0x0000
1962306a36Sopenharmony_ci#define REG_KEY_CMD	0x0004
2062306a36Sopenharmony_ci#define REG_PINMUX1	0x3000
2162306a36Sopenharmony_ci#define REG_PINMUX2	0x3004
2262306a36Sopenharmony_ci#define REG_PINMUX3	0x3008
2362306a36Sopenharmony_ci#define REG_PINMUX4	0x300c
2462306a36Sopenharmony_ci#define REG_PINMUX5	0x3010
2562306a36Sopenharmony_ci#define REG_IOSET	0x3014
2662306a36Sopenharmony_ci#define REG_IO_VSEL	0x3018
2762306a36Sopenharmony_ci#define REG_IO_DSEL1	0x301c
2862306a36Sopenharmony_ci#define REG_IO_DSEL2	0x3020
2962306a36Sopenharmony_ci#define REG_IO_DSEL3	0x3024
3062306a36Sopenharmony_ci#define REG_IO_DSEL4	0x3028
3162306a36Sopenharmony_ci#define REG_IO_DSEL5	0x302c
3262306a36Sopenharmony_ci#define REG_IO_DSEL6	0x3030
3362306a36Sopenharmony_ci#define REG_IO_DSEL7	0x3034
3462306a36Sopenharmony_ci#define REG_IO_DSEL8	0x3038
3562306a36Sopenharmony_ci#define REG_IO_PUDE1	0x303c
3662306a36Sopenharmony_ci#define REG_IO_PUDE2	0x3040
3762306a36Sopenharmony_ci#define REG_IO_PUDSEL1	0x3044
3862306a36Sopenharmony_ci#define REG_IO_PUDSEL2	0x3048
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci/* PIN */
4162306a36Sopenharmony_cistatic const struct visconti_desc_pin pins_tmpv7700[] = {
4262306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(0, "gpio0"), REG_IO_DSEL4, 24,
4362306a36Sopenharmony_ci		    REG_IO_PUDE1, REG_IO_PUDSEL1, 30),
4462306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(1, "gpio1"), REG_IO_DSEL4, 28,
4562306a36Sopenharmony_ci		    REG_IO_PUDE1, REG_IO_PUDSEL1, 31),
4662306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(2, "gpio2"), REG_IO_DSEL5, 0,
4762306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 0),
4862306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(3, "gpio3"), REG_IO_DSEL5, 4,
4962306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 1),
5062306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(4, "gpio4"), REG_IO_DSEL5, 8,
5162306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 2),
5262306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(5, "gpio5"), REG_IO_DSEL5, 12,
5362306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 3),
5462306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(6, "gpio6"), REG_IO_DSEL5, 16,
5562306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 4),
5662306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(7, "gpio7"), REG_IO_DSEL5, 20,
5762306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 5),
5862306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(8, "gpio8"), REG_IO_DSEL5, 24,
5962306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 6),
6062306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(9, "gpio9"), REG_IO_DSEL5, 28,
6162306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 7),
6262306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(10, "gpio10"), REG_IO_DSEL6, 0,
6362306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 8),
6462306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(11, "gpio11"), REG_IO_DSEL6, 4,
6562306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 9),
6662306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(12, "gpio12"), REG_IO_DSEL6, 8,
6762306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 10),
6862306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(13, "gpio13"), REG_IO_DSEL6, 12,
6962306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 11),
7062306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(14, "gpio14"), REG_IO_DSEL6, 16,
7162306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 12),
7262306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(15, "gpio15"), REG_IO_DSEL6, 20,
7362306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 13),
7462306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(16, "gpio16"), REG_IO_DSEL6, 24,
7562306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 14),
7662306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(17, "gpio17"), REG_IO_DSEL6, 28,
7762306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 15),
7862306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(18, "gpio18"), REG_IO_DSEL7, 0,
7962306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 16),
8062306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(19, "gpio19"), REG_IO_DSEL7, 4,
8162306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 17),
8262306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(20, "gpio20"), REG_IO_DSEL7, 8,
8362306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 18),
8462306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(21, "gpio21"), REG_IO_DSEL7, 12,
8562306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 19),
8662306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(22, "gpio22"), REG_IO_DSEL7, 16,
8762306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 20),
8862306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(23, "gpio23"), REG_IO_DSEL7, 20,
8962306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 21),
9062306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(24, "gpio24"), REG_IO_DSEL7, 24,
9162306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 22),
9262306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(25, "gpio25"), REG_IO_DSEL7, 28,
9362306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 23),
9462306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(26, "gpio26"), REG_IO_DSEL8, 0,
9562306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 24),
9662306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(27, "gpio27"), REG_IO_DSEL8, 4,
9762306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 25),
9862306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(28, "gpio28"), REG_IO_DSEL8, 8,
9962306a36Sopenharmony_ci		    REG_IO_PUDE2, REG_IO_PUDSEL2, 26),
10062306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(29, "gpio29"), REG_IO_DSEL4, 8,
10162306a36Sopenharmony_ci		    REG_IO_PUDE1, REG_IO_PUDSEL1, 26),
10262306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(30, "gpio30"), REG_IO_DSEL4, 4,
10362306a36Sopenharmony_ci		    REG_IO_PUDE1, REG_IO_PUDSEL1, 25),
10462306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(31, "gpio31"), REG_IO_DSEL4, 0,
10562306a36Sopenharmony_ci		    REG_IO_PUDE1, REG_IO_PUDSEL1, 24),
10662306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(32, "spi_sck"), REG_IO_DSEL4, 12,
10762306a36Sopenharmony_ci		    REG_IO_PUDE1, REG_IO_PUDSEL1, 27),
10862306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(33, "spi_sdo"), REG_IO_DSEL4, 16,
10962306a36Sopenharmony_ci		    REG_IO_PUDE1, REG_IO_PUDSEL1, 28),
11062306a36Sopenharmony_ci	VISCONTI_PIN(PINCTRL_PIN(34, "spi_sdi"), REG_IO_DSEL4, 20,
11162306a36Sopenharmony_ci		    REG_IO_PUDE1, REG_IO_PUDSEL1, 29),
11262306a36Sopenharmony_ci};
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci/* Group */
11562306a36Sopenharmony_ciVISCONTI_PINS(i2c0, 0, 1);
11662306a36Sopenharmony_ciVISCONTI_PINS(i2c1, 2, 3);
11762306a36Sopenharmony_ciVISCONTI_PINS(i2c2, 12, 13);
11862306a36Sopenharmony_ciVISCONTI_PINS(i2c3, 14, 15);
11962306a36Sopenharmony_ciVISCONTI_PINS(i2c4, 16, 17);
12062306a36Sopenharmony_ciVISCONTI_PINS(i2c5, 18, 19);
12162306a36Sopenharmony_ciVISCONTI_PINS(i2c6, 33, 34);
12262306a36Sopenharmony_ciVISCONTI_PINS(i2c7, 29, 32);
12362306a36Sopenharmony_ciVISCONTI_PINS(i2c8, 30, 31);
12462306a36Sopenharmony_ciVISCONTI_PINS(spi0_cs0, 29);
12562306a36Sopenharmony_ciVISCONTI_PINS(spi0_cs1, 30);
12662306a36Sopenharmony_ciVISCONTI_PINS(spi0_cs2, 31);
12762306a36Sopenharmony_ciVISCONTI_PINS(spi1_cs, 3);
12862306a36Sopenharmony_ciVISCONTI_PINS(spi2_cs, 7);
12962306a36Sopenharmony_ciVISCONTI_PINS(spi3_cs, 11);
13062306a36Sopenharmony_ciVISCONTI_PINS(spi4_cs, 15);
13162306a36Sopenharmony_ciVISCONTI_PINS(spi5_cs, 19);
13262306a36Sopenharmony_ciVISCONTI_PINS(spi6_cs, 27);
13362306a36Sopenharmony_ciVISCONTI_PINS(spi0, 32, 33, 34);
13462306a36Sopenharmony_ciVISCONTI_PINS(spi1, 0, 1, 2);
13562306a36Sopenharmony_ciVISCONTI_PINS(spi2, 4, 5, 6);
13662306a36Sopenharmony_ciVISCONTI_PINS(spi3, 8, 9, 10);
13762306a36Sopenharmony_ciVISCONTI_PINS(spi4, 12, 13, 14);
13862306a36Sopenharmony_ciVISCONTI_PINS(spi5, 16, 17, 18);
13962306a36Sopenharmony_ciVISCONTI_PINS(spi6, 24, 25, 26);
14062306a36Sopenharmony_ciVISCONTI_PINS(uart0, 4, 5, 6, 7);
14162306a36Sopenharmony_ciVISCONTI_PINS(uart1, 8, 9, 10, 11);
14262306a36Sopenharmony_ciVISCONTI_PINS(uart2, 12, 13, 14, 15);
14362306a36Sopenharmony_ciVISCONTI_PINS(uart3, 16, 17, 18, 19);
14462306a36Sopenharmony_ciVISCONTI_PINS(pwm0_gpio4, 4);
14562306a36Sopenharmony_ciVISCONTI_PINS(pwm1_gpio5, 5);
14662306a36Sopenharmony_ciVISCONTI_PINS(pwm2_gpio6, 6);
14762306a36Sopenharmony_ciVISCONTI_PINS(pwm3_gpio7, 7);
14862306a36Sopenharmony_ciVISCONTI_PINS(pwm0_gpio8, 8);
14962306a36Sopenharmony_ciVISCONTI_PINS(pwm1_gpio9, 9);
15062306a36Sopenharmony_ciVISCONTI_PINS(pwm2_gpio10, 10);
15162306a36Sopenharmony_ciVISCONTI_PINS(pwm3_gpio11, 11);
15262306a36Sopenharmony_ciVISCONTI_PINS(pwm0_gpio12, 12);
15362306a36Sopenharmony_ciVISCONTI_PINS(pwm1_gpio13, 13);
15462306a36Sopenharmony_ciVISCONTI_PINS(pwm2_gpio14, 14);
15562306a36Sopenharmony_ciVISCONTI_PINS(pwm3_gpio15, 15);
15662306a36Sopenharmony_ciVISCONTI_PINS(pwm0_gpio16, 16);
15762306a36Sopenharmony_ciVISCONTI_PINS(pwm1_gpio17, 17);
15862306a36Sopenharmony_ciVISCONTI_PINS(pwm2_gpio18, 18);
15962306a36Sopenharmony_ciVISCONTI_PINS(pwm3_gpio19, 19);
16062306a36Sopenharmony_ciVISCONTI_PINS(pcmif_out, 20, 21, 22);
16162306a36Sopenharmony_ciVISCONTI_PINS(pcmif_in, 24, 25, 26);
16262306a36Sopenharmony_ci
16362306a36Sopenharmony_cistatic const struct visconti_pin_group groups_tmpv7700[] = {
16462306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(i2c0, REG_PINMUX2, GENMASK(7, 0), 0x00000022),
16562306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(i2c1, REG_PINMUX2, GENMASK(15, 8), 0x00002200),
16662306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(i2c2, REG_PINMUX3, GENMASK(23, 16), 0x00770000),
16762306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(i2c3, REG_PINMUX3, GENMASK(31, 24), 0x77000000),
16862306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(i2c4, REG_PINMUX4, GENMASK(7, 0), 0x00000077),
16962306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(i2c5, REG_PINMUX4, GENMASK(15, 8), 0x00007700),
17062306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(i2c6, REG_PINMUX1, GENMASK(3, 0), 0x0000002),
17162306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(i2c7, REG_PINMUX5, GENMASK(23, 20), 0x00200000),
17262306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(i2c8, REG_PINMUX5, GENMASK(31, 24), 0x22000000),
17362306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(spi0_cs0, REG_PINMUX5, GENMASK(23, 20), 0x00100000),
17462306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(spi0_cs1, REG_PINMUX5, GENMASK(27, 24), 0x01000000),
17562306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(spi0_cs2, REG_PINMUX5, GENMASK(31, 28), 0x10000000),
17662306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(spi1_cs, REG_PINMUX2, GENMASK(15, 12), 0x00001000),
17762306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(spi2_cs, REG_PINMUX2, GENMASK(31, 28), 0x10000000),
17862306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(spi3_cs, REG_PINMUX3, GENMASK(15, 12), 0x00001000),
17962306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(spi4_cs, REG_PINMUX4, GENMASK(31, 28), 0x10000000),
18062306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(spi5_cs, REG_PINMUX4, GENMASK(15, 12), 0x00001000),
18162306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(spi6_cs, REG_PINMUX5, GENMASK(15, 12), 0x00001000),
18262306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(spi0, REG_PINMUX1, GENMASK(3, 0), 0x00000001),
18362306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(spi1, REG_PINMUX2, GENMASK(11, 0), 0x00000111),
18462306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(spi2, REG_PINMUX2, GENMASK(27, 16), 0x01110000),
18562306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(spi3, REG_PINMUX3, GENMASK(11, 0), 0x00000111),
18662306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(spi4, REG_PINMUX3, GENMASK(27, 16), 0x01110000),
18762306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(spi5, REG_PINMUX4, GENMASK(11, 0), 0x00000111),
18862306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(spi6, REG_PINMUX5, GENMASK(11, 0), 0x00000111),
18962306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(uart0, REG_PINMUX2, GENMASK(31, 16), 0x22220000),
19062306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(uart1, REG_PINMUX3, GENMASK(15, 0), 0x00002222),
19162306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(uart2, REG_PINMUX3, GENMASK(31, 16), 0x22220000),
19262306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(uart3, REG_PINMUX4, GENMASK(15, 0), 0x00002222),
19362306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm0_gpio4, REG_PINMUX2, GENMASK(19, 16), 0x00050000),
19462306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm1_gpio5, REG_PINMUX2, GENMASK(23, 20), 0x00500000),
19562306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm2_gpio6, REG_PINMUX2, GENMASK(27, 24), 0x05000000),
19662306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm3_gpio7, REG_PINMUX2, GENMASK(31, 28), 0x50000000),
19762306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm0_gpio8, REG_PINMUX3, GENMASK(3, 0), 0x00000005),
19862306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm1_gpio9, REG_PINMUX3, GENMASK(7, 4), 0x00000050),
19962306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm2_gpio10, REG_PINMUX3, GENMASK(11, 8), 0x00000500),
20062306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm3_gpio11, REG_PINMUX3, GENMASK(15, 12), 0x00005000),
20162306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm0_gpio12, REG_PINMUX3, GENMASK(19, 16), 0x00050000),
20262306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm1_gpio13, REG_PINMUX3, GENMASK(23, 20), 0x00500000),
20362306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm2_gpio14, REG_PINMUX3, GENMASK(27, 24), 0x05000000),
20462306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm3_gpio15, REG_PINMUX3, GENMASK(31, 28), 0x50000000),
20562306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm0_gpio16, REG_PINMUX4, GENMASK(3, 0), 0x00000005),
20662306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm1_gpio17, REG_PINMUX4, GENMASK(7, 4), 0x00000050),
20762306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm2_gpio18, REG_PINMUX4, GENMASK(11, 8), 0x00000500),
20862306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(pwm3_gpio19, REG_PINMUX4, GENMASK(15, 12), 0x00005000),
20962306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(pcmif_out, REG_PINMUX4, GENMASK(27, 16), 0x01110000),
21062306a36Sopenharmony_ci	VISCONTI_PIN_GROUP(pcmif_in, REG_PINMUX5, GENMASK(11, 0), 0x00000222),
21162306a36Sopenharmony_ci};
21262306a36Sopenharmony_ci
21362306a36Sopenharmony_ci/* MUX */
21462306a36Sopenharmony_ciVISCONTI_GROUPS(i2c0, "i2c0_grp");
21562306a36Sopenharmony_ciVISCONTI_GROUPS(i2c1, "i2c1_grp");
21662306a36Sopenharmony_ciVISCONTI_GROUPS(i2c2, "i2c2_grp");
21762306a36Sopenharmony_ciVISCONTI_GROUPS(i2c3, "i2c3_grp");
21862306a36Sopenharmony_ciVISCONTI_GROUPS(i2c4, "i2c4_grp");
21962306a36Sopenharmony_ciVISCONTI_GROUPS(i2c5, "i2c5_grp");
22062306a36Sopenharmony_ciVISCONTI_GROUPS(i2c6, "i2c6_grp");
22162306a36Sopenharmony_ciVISCONTI_GROUPS(i2c7, "i2c7_grp");
22262306a36Sopenharmony_ciVISCONTI_GROUPS(i2c8, "i2c8_grp");
22362306a36Sopenharmony_ciVISCONTI_GROUPS(spi0, "spi0_grp", "spi0_cs0_grp",
22462306a36Sopenharmony_ci		"spi0_cs1_grp", "spi0_cs2_grp");
22562306a36Sopenharmony_ciVISCONTI_GROUPS(spi1, "spi1_grp", "spi1_cs_grp");
22662306a36Sopenharmony_ciVISCONTI_GROUPS(spi2, "spi2_grp", "spi2_cs_grp");
22762306a36Sopenharmony_ciVISCONTI_GROUPS(spi3, "spi3_grp", "spi3_cs_grp");
22862306a36Sopenharmony_ciVISCONTI_GROUPS(spi4, "spi4_grp", "spi4_cs_grp");
22962306a36Sopenharmony_ciVISCONTI_GROUPS(spi5, "spi5_grp", "spi5_cs_grp");
23062306a36Sopenharmony_ciVISCONTI_GROUPS(spi6, "spi6_grp", "spi6_cs_grp");
23162306a36Sopenharmony_ciVISCONTI_GROUPS(uart0, "uart0_grp");
23262306a36Sopenharmony_ciVISCONTI_GROUPS(uart1, "uart1_grp");
23362306a36Sopenharmony_ciVISCONTI_GROUPS(uart2, "uart2_grp");
23462306a36Sopenharmony_ciVISCONTI_GROUPS(uart3, "uart3_grp");
23562306a36Sopenharmony_ciVISCONTI_GROUPS(pwm, "pwm0_gpio4_grp", "pwm0_gpio8_grp",
23662306a36Sopenharmony_ci		"pwm0_gpio12_grp", "pwm0_gpio16_grp",
23762306a36Sopenharmony_ci		"pwm1_gpio5_grp", "pwm1_gpio9_grp",
23862306a36Sopenharmony_ci		"pwm1_gpio13_grp", "pwm1_gpio17_grp",
23962306a36Sopenharmony_ci		"pwm2_gpio6_grp", "pwm2_gpio10_grp",
24062306a36Sopenharmony_ci		"pwm2_gpio14_grp", "pwm2_gpio18_grp",
24162306a36Sopenharmony_ci		"pwm3_gpio7_grp", "pwm3_gpio11_grp",
24262306a36Sopenharmony_ci		"pwm3_gpio15_grp", "pwm3_gpio19_grp");
24362306a36Sopenharmony_ciVISCONTI_GROUPS(pcmif_out, "pcmif_out_grp");
24462306a36Sopenharmony_ciVISCONTI_GROUPS(pcmif_in, "pcmif_in_grp");
24562306a36Sopenharmony_ci
24662306a36Sopenharmony_cistatic const struct visconti_pin_function functions_tmpv7700[] = {
24762306a36Sopenharmony_ci	VISCONTI_PIN_FUNCTION(i2c0),
24862306a36Sopenharmony_ci	VISCONTI_PIN_FUNCTION(i2c1),
24962306a36Sopenharmony_ci	VISCONTI_PIN_FUNCTION(i2c2),
25062306a36Sopenharmony_ci	VISCONTI_PIN_FUNCTION(i2c3),
25162306a36Sopenharmony_ci	VISCONTI_PIN_FUNCTION(i2c4),
25262306a36Sopenharmony_ci	VISCONTI_PIN_FUNCTION(i2c5),
25362306a36Sopenharmony_ci	VISCONTI_PIN_FUNCTION(i2c6),
25462306a36Sopenharmony_ci	VISCONTI_PIN_FUNCTION(i2c7),
25562306a36Sopenharmony_ci	VISCONTI_PIN_FUNCTION(i2c8),
25662306a36Sopenharmony_ci	VISCONTI_PIN_FUNCTION(spi0),
25762306a36Sopenharmony_ci	VISCONTI_PIN_FUNCTION(spi1),
25862306a36Sopenharmony_ci	VISCONTI_PIN_FUNCTION(spi2),
25962306a36Sopenharmony_ci	VISCONTI_PIN_FUNCTION(spi3),
26062306a36Sopenharmony_ci	VISCONTI_PIN_FUNCTION(spi4),
26162306a36Sopenharmony_ci	VISCONTI_PIN_FUNCTION(spi5),
26262306a36Sopenharmony_ci	VISCONTI_PIN_FUNCTION(spi6),
26362306a36Sopenharmony_ci	VISCONTI_PIN_FUNCTION(uart0),
26462306a36Sopenharmony_ci	VISCONTI_PIN_FUNCTION(uart1),
26562306a36Sopenharmony_ci	VISCONTI_PIN_FUNCTION(uart2),
26662306a36Sopenharmony_ci	VISCONTI_PIN_FUNCTION(uart3),
26762306a36Sopenharmony_ci	VISCONTI_PIN_FUNCTION(pwm),
26862306a36Sopenharmony_ci	VISCONTI_PIN_FUNCTION(pcmif_in),
26962306a36Sopenharmony_ci	VISCONTI_PIN_FUNCTION(pcmif_out),
27062306a36Sopenharmony_ci};
27162306a36Sopenharmony_ci
27262306a36Sopenharmony_ci/* GPIO MUX */
27362306a36Sopenharmony_ci#define tmpv7700_GPIO_MUX(off, msk)	\
27462306a36Sopenharmony_ci{					\
27562306a36Sopenharmony_ci	.offset = off,			\
27662306a36Sopenharmony_ci	.mask = msk,			\
27762306a36Sopenharmony_ci	.val = 0,			\
27862306a36Sopenharmony_ci}
27962306a36Sopenharmony_ci
28062306a36Sopenharmony_cistatic const struct visconti_mux gpio_mux_tmpv7700[] = {
28162306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX2, GENMASK(3, 0)),
28262306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX2, GENMASK(7, 4)),
28362306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX2, GENMASK(11, 8)),
28462306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX2, GENMASK(15, 12)),
28562306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX2, GENMASK(19, 16)),
28662306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX2, GENMASK(23, 20)),
28762306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX2, GENMASK(27, 24)),
28862306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX2, GENMASK(31, 28)),
28962306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX3, GENMASK(3, 0)),
29062306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX3, GENMASK(7, 4)),
29162306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX3, GENMASK(11, 8)),
29262306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX3, GENMASK(15, 12)),
29362306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX3, GENMASK(19, 16)),
29462306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX3, GENMASK(23, 20)),
29562306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX3, GENMASK(27, 24)),
29662306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX3, GENMASK(31, 28)),
29762306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX4, GENMASK(3, 0)),
29862306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX4, GENMASK(7, 4)),
29962306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX4, GENMASK(11, 8)),
30062306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX4, GENMASK(15, 12)),
30162306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX4, GENMASK(19, 16)),
30262306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX4, GENMASK(23, 20)),
30362306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX4, GENMASK(27, 24)),
30462306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX4, GENMASK(31, 28)),
30562306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX5, GENMASK(3, 0)),
30662306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX5, GENMASK(7, 4)),
30762306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX5, GENMASK(11, 8)),
30862306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX5, GENMASK(15, 12)),
30962306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX5, GENMASK(19, 16)),
31062306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX5, GENMASK(23, 20)),
31162306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX5, GENMASK(27, 24)),
31262306a36Sopenharmony_ci	tmpv7700_GPIO_MUX(REG_PINMUX5, GENMASK(31, 28)),
31362306a36Sopenharmony_ci};
31462306a36Sopenharmony_ci
31562306a36Sopenharmony_cistatic void tmpv7700_pinctrl_unlock(void __iomem *base)
31662306a36Sopenharmony_ci{
31762306a36Sopenharmony_ci	writel(1, base + REG_KEY_CTRL);
31862306a36Sopenharmony_ci	writel(tmpv7700_MAGIC_NUM, base + REG_KEY_CMD);
31962306a36Sopenharmony_ci}
32062306a36Sopenharmony_ci
32162306a36Sopenharmony_ci/* chip dependent data */
32262306a36Sopenharmony_cistatic const struct visconti_pinctrl_devdata tmpv7700_pinctrl_data = {
32362306a36Sopenharmony_ci	.pins = pins_tmpv7700,
32462306a36Sopenharmony_ci	.nr_pins = ARRAY_SIZE(pins_tmpv7700),
32562306a36Sopenharmony_ci	.groups = groups_tmpv7700,
32662306a36Sopenharmony_ci	.nr_groups = ARRAY_SIZE(groups_tmpv7700),
32762306a36Sopenharmony_ci	.functions = functions_tmpv7700,
32862306a36Sopenharmony_ci	.nr_functions = ARRAY_SIZE(functions_tmpv7700),
32962306a36Sopenharmony_ci	.gpio_mux = gpio_mux_tmpv7700,
33062306a36Sopenharmony_ci	.unlock = tmpv7700_pinctrl_unlock,
33162306a36Sopenharmony_ci};
33262306a36Sopenharmony_ci
33362306a36Sopenharmony_cistatic int tmpv7700_pinctrl_probe(struct platform_device *pdev)
33462306a36Sopenharmony_ci{
33562306a36Sopenharmony_ci	return visconti_pinctrl_probe(pdev, &tmpv7700_pinctrl_data);
33662306a36Sopenharmony_ci}
33762306a36Sopenharmony_ci
33862306a36Sopenharmony_cistatic const struct of_device_id tmpv7700_pctrl_of_match[] = {
33962306a36Sopenharmony_ci	{ .compatible = "toshiba,tmpv7708-pinctrl", },
34062306a36Sopenharmony_ci	{},
34162306a36Sopenharmony_ci};
34262306a36Sopenharmony_ci
34362306a36Sopenharmony_cistatic struct platform_driver tmpv7700_pinctrl_driver = {
34462306a36Sopenharmony_ci	.probe = tmpv7700_pinctrl_probe,
34562306a36Sopenharmony_ci	.driver = {
34662306a36Sopenharmony_ci		.name = "tmpv7700-pinctrl",
34762306a36Sopenharmony_ci		.of_match_table = tmpv7700_pctrl_of_match,
34862306a36Sopenharmony_ci	},
34962306a36Sopenharmony_ci};
35062306a36Sopenharmony_ci
35162306a36Sopenharmony_cistatic int __init tmpv7700_pinctrl_init(void)
35262306a36Sopenharmony_ci{
35362306a36Sopenharmony_ci	return platform_driver_register(&tmpv7700_pinctrl_driver);
35462306a36Sopenharmony_ci}
35562306a36Sopenharmony_ciarch_initcall(tmpv7700_pinctrl_init);
356