162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Marvell Armada 39x pinctrl driver based on mvebu pinctrl core
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (C) 2015 Marvell
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#include <linux/err.h>
1162306a36Sopenharmony_ci#include <linux/init.h>
1262306a36Sopenharmony_ci#include <linux/io.h>
1362306a36Sopenharmony_ci#include <linux/platform_device.h>
1462306a36Sopenharmony_ci#include <linux/of.h>
1562306a36Sopenharmony_ci#include <linux/of_device.h>
1662306a36Sopenharmony_ci#include <linux/pinctrl/pinctrl.h>
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci#include "pinctrl-mvebu.h"
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_cienum {
2162306a36Sopenharmony_ci	V_88F6920 = BIT(0),
2262306a36Sopenharmony_ci	V_88F6925 = BIT(1),
2362306a36Sopenharmony_ci	V_88F6928 = BIT(2),
2462306a36Sopenharmony_ci	V_88F6920_PLUS = (V_88F6920 | V_88F6925 | V_88F6928),
2562306a36Sopenharmony_ci	V_88F6925_PLUS = (V_88F6925 | V_88F6928),
2662306a36Sopenharmony_ci};
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_cistatic struct mvebu_mpp_mode armada_39x_mpp_modes[] = {
2962306a36Sopenharmony_ci	MPP_MODE(0,
3062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
3162306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "ua0",     "rxd",      V_88F6920_PLUS)),
3262306a36Sopenharmony_ci	MPP_MODE(1,
3362306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
3462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "ua0",     "txd",      V_88F6920_PLUS)),
3562306a36Sopenharmony_ci	MPP_MODE(2,
3662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
3762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "i2c0",    "sck",      V_88F6920_PLUS)),
3862306a36Sopenharmony_ci	MPP_MODE(3,
3962306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
4062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "i2c0",    "sda",      V_88F6920_PLUS)),
4162306a36Sopenharmony_ci	MPP_MODE(4,
4262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
4362306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(2, "ua1",     "txd",      V_88F6920_PLUS),
4462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "ua0",     "rts",      V_88F6920_PLUS),
4562306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "smi",     "mdc",      V_88F6920_PLUS)),
4662306a36Sopenharmony_ci	MPP_MODE(5,
4762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
4862306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(2, "ua1",     "rxd",      V_88F6920_PLUS),
4962306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "ua0",     "cts",      V_88F6920_PLUS),
5062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "smi",     "mdio",     V_88F6920_PLUS)),
5162306a36Sopenharmony_ci	MPP_MODE(6,
5262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
5362306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "cs3",      V_88F6920_PLUS),
5462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "xsmi",    "mdio",     V_88F6920_PLUS)),
5562306a36Sopenharmony_ci	MPP_MODE(7,
5662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
5762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "ad9",      V_88F6920_PLUS),
5862306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "xsmi",    "mdc",      V_88F6920_PLUS)),
5962306a36Sopenharmony_ci	MPP_MODE(8,
6062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
6162306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "ad10",     V_88F6920_PLUS),
6262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "ptp",     "trig",     V_88F6920_PLUS)),
6362306a36Sopenharmony_ci	MPP_MODE(9,
6462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
6562306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "ad11",     V_88F6920_PLUS),
6662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "ptp",     "clk",      V_88F6920_PLUS)),
6762306a36Sopenharmony_ci	MPP_MODE(10,
6862306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
6962306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "ad12",     V_88F6920_PLUS),
7062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "ptp",     "evreq",    V_88F6920_PLUS)),
7162306a36Sopenharmony_ci	MPP_MODE(11,
7262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
7362306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "ad13",     V_88F6920_PLUS),
7462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "led",     "clk",      V_88F6920_PLUS)),
7562306a36Sopenharmony_ci	MPP_MODE(12,
7662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
7762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(2, "pcie0",   "rstout",   V_88F6920_PLUS),
7862306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "ad14",     V_88F6920_PLUS),
7962306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "led",     "stb",      V_88F6920_PLUS)),
8062306a36Sopenharmony_ci	MPP_MODE(13,
8162306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
8262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "ad15",     V_88F6920_PLUS),
8362306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(6, "pcie2",   "clkreq",   V_88F6920_PLUS),
8462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "led",     "data",     V_88F6920_PLUS)),
8562306a36Sopenharmony_ci	MPP_MODE(14,
8662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
8762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "dram",    "vttctrl",  V_88F6920_PLUS),
8862306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "we1",      V_88F6920_PLUS),
8962306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "ua1",     "txd",      V_88F6920_PLUS)),
9062306a36Sopenharmony_ci	MPP_MODE(15,
9162306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
9262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "pcie0",   "rstout",   V_88F6920_PLUS),
9362306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "spi0",    "mosi",     V_88F6920_PLUS),
9462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "i2c1",    "sck",      V_88F6920_PLUS)),
9562306a36Sopenharmony_ci	MPP_MODE(16,
9662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
9762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "dram",    "deccerr",  V_88F6920_PLUS),
9862306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "spi0",    "miso",     V_88F6920_PLUS),
9962306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "pcie0",   "clkreq",   V_88F6920_PLUS),
10062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "i2c1",    "sda",      V_88F6920_PLUS)),
10162306a36Sopenharmony_ci	MPP_MODE(17,
10262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
10362306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "ua1",     "rxd",      V_88F6920_PLUS),
10462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "spi0",    "sck",      V_88F6920_PLUS),
10562306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "sata1",   "prsnt",    V_88F6925_PLUS),
10662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(6, "sata0",   "prsnt",    V_88F6925_PLUS),
10762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "smi",     "mdio",     V_88F6920_PLUS)),
10862306a36Sopenharmony_ci	MPP_MODE(18,
10962306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
11062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "ua1",     "txd",      V_88F6920_PLUS),
11162306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "spi0",    "cs0",      V_88F6920_PLUS),
11262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "i2c2",    "sck",      V_88F6920_PLUS)),
11362306a36Sopenharmony_ci	MPP_MODE(19,
11462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
11562306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "sata1",   "prsnt",    V_88F6925_PLUS),
11662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "ua0",     "cts",      V_88F6920_PLUS),
11762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(6, "ua1",     "rxd",      V_88F6920_PLUS),
11862306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "i2c2",    "sda",      V_88F6920_PLUS)),
11962306a36Sopenharmony_ci	MPP_MODE(20,
12062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
12162306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "sata0",   "prsnt",    V_88F6925_PLUS),
12262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "ua0",     "rts",      V_88F6920_PLUS),
12362306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(6, "ua1",     "txd",      V_88F6920_PLUS),
12462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "smi",     "mdc",      V_88F6920_PLUS)),
12562306a36Sopenharmony_ci	MPP_MODE(21,
12662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
12762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "spi0",    "cs1",      V_88F6920_PLUS),
12862306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "sata0",   "prsnt",    V_88F6925_PLUS),
12962306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "sd0",     "cmd",      V_88F6920_PLUS),
13062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "bootcs",   V_88F6920_PLUS),
13162306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(6, "sata1",   "prsnt",    V_88F6925_PLUS),
13262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(8, "ge",      "rxd0",     V_88F6920_PLUS)),
13362306a36Sopenharmony_ci	MPP_MODE(22,
13462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
13562306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "spi0",    "mosi",     V_88F6920_PLUS),
13662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "ad0",      V_88F6920_PLUS)),
13762306a36Sopenharmony_ci	MPP_MODE(23,
13862306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
13962306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "spi0",    "sck",      V_88F6920_PLUS),
14062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "ad2",      V_88F6920_PLUS)),
14162306a36Sopenharmony_ci	MPP_MODE(24,
14262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
14362306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "spi0",    "miso",     V_88F6920_PLUS),
14462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(2, "ua0",     "cts",      V_88F6920_PLUS),
14562306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "ua1",     "rxd",      V_88F6920_PLUS),
14662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "sd0",     "d4",       V_88F6920_PLUS),
14762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "ready",    V_88F6920_PLUS)),
14862306a36Sopenharmony_ci	MPP_MODE(25,
14962306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
15062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "spi0",    "cs0",      V_88F6920_PLUS),
15162306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(2, "ua0",     "rts",      V_88F6920_PLUS),
15262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "ua1",     "txd",      V_88F6920_PLUS),
15362306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "sd0",     "d5",       V_88F6920_PLUS),
15462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "cs0",      V_88F6920_PLUS)),
15562306a36Sopenharmony_ci	MPP_MODE(26,
15662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
15762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "spi0",    "cs2",      V_88F6920_PLUS),
15862306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "i2c1",    "sck",      V_88F6920_PLUS),
15962306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "sd0",     "d6",       V_88F6920_PLUS),
16062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "cs1",      V_88F6920_PLUS)),
16162306a36Sopenharmony_ci	MPP_MODE(27,
16262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
16362306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "spi0",    "cs3",      V_88F6920_PLUS),
16462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "i2c1",    "sda",      V_88F6920_PLUS),
16562306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "sd0",     "d7",       V_88F6920_PLUS),
16662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "cs2",      V_88F6920_PLUS),
16762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(8, "ge",      "txclkout", V_88F6920_PLUS)),
16862306a36Sopenharmony_ci	MPP_MODE(28,
16962306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
17062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "sd0",     "clk",      V_88F6920_PLUS),
17162306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "ad5",      V_88F6920_PLUS),
17262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(8, "ge",      "txd0",     V_88F6920_PLUS)),
17362306a36Sopenharmony_ci	MPP_MODE(29,
17462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
17562306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "ale0",     V_88F6920_PLUS),
17662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(8, "ge",      "txd1",     V_88F6920_PLUS)),
17762306a36Sopenharmony_ci	MPP_MODE(30,
17862306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
17962306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "oe",       V_88F6920_PLUS),
18062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(8, "ge",      "txd2",     V_88F6920_PLUS)),
18162306a36Sopenharmony_ci	MPP_MODE(31,
18262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
18362306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "ale1",     V_88F6920_PLUS),
18462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(8, "ge",      "txd3",     V_88F6920_PLUS)),
18562306a36Sopenharmony_ci	MPP_MODE(32,
18662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
18762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "we0",      V_88F6920_PLUS),
18862306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(8, "ge",      "txctl",    V_88F6920_PLUS)),
18962306a36Sopenharmony_ci	MPP_MODE(33,
19062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
19162306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "dram",    "deccerr",  V_88F6920_PLUS),
19262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "ad3",      V_88F6920_PLUS)),
19362306a36Sopenharmony_ci	MPP_MODE(34,
19462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
19562306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "ad1",      V_88F6920_PLUS)),
19662306a36Sopenharmony_ci	MPP_MODE(35,
19762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
19862306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "ref",     "clk_out1", V_88F6920_PLUS),
19962306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "a1",       V_88F6920_PLUS)),
20062306a36Sopenharmony_ci	MPP_MODE(36,
20162306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
20262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "a0",       V_88F6920_PLUS)),
20362306a36Sopenharmony_ci	MPP_MODE(37,
20462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
20562306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "sd0",     "d3",       V_88F6920_PLUS),
20662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "ad8",      V_88F6920_PLUS),
20762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(8, "ge",      "rxclk",    V_88F6920_PLUS)),
20862306a36Sopenharmony_ci	MPP_MODE(38,
20962306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
21062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "ref",     "clk_out0", V_88F6920_PLUS),
21162306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "sd0",     "d0",       V_88F6920_PLUS),
21262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "ad4",      V_88F6920_PLUS),
21362306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(8, "ge",      "rxd1",     V_88F6920_PLUS)),
21462306a36Sopenharmony_ci	MPP_MODE(39,
21562306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
21662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "i2c1",    "sck",      V_88F6920_PLUS),
21762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "ua0",     "cts",      V_88F6920_PLUS),
21862306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "sd0",     "d1",       V_88F6920_PLUS),
21962306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "a2",       V_88F6920_PLUS),
22062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(8, "ge",      "rxd2",     V_88F6920_PLUS)),
22162306a36Sopenharmony_ci	MPP_MODE(40,
22262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
22362306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "i2c1",    "sda",      V_88F6920_PLUS),
22462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "ua0",     "rts",      V_88F6920_PLUS),
22562306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "sd0",     "d2",       V_88F6920_PLUS),
22662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "ad6",      V_88F6920_PLUS),
22762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(8, "ge",      "rxd3",     V_88F6920_PLUS)),
22862306a36Sopenharmony_ci	MPP_MODE(41,
22962306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
23062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "ua1",     "rxd",      V_88F6920_PLUS),
23162306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "ua0",     "cts",      V_88F6920_PLUS),
23262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "spi1",    "cs3",      V_88F6920_PLUS),
23362306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "burst/last", V_88F6920_PLUS),
23462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(6, "nand",    "rb0",      V_88F6920_PLUS),
23562306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(8, "ge",      "rxctl",    V_88F6920_PLUS)),
23662306a36Sopenharmony_ci	MPP_MODE(42,
23762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
23862306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "ua1",     "txd",      V_88F6920_PLUS),
23962306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "ua0",     "rts",      V_88F6920_PLUS),
24062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "ad7",      V_88F6920_PLUS)),
24162306a36Sopenharmony_ci	MPP_MODE(43,
24262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
24362306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "pcie0",   "clkreq",   V_88F6920_PLUS),
24462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(2, "dram",    "vttctrl",  V_88F6920_PLUS),
24562306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "dram",    "deccerr",  V_88F6920_PLUS),
24662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "spi1",    "cs2",      V_88F6920_PLUS),
24762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dev",     "clkout",   V_88F6920_PLUS),
24862306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(6, "nand",    "rb1",      V_88F6920_PLUS)),
24962306a36Sopenharmony_ci	MPP_MODE(44,
25062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
25162306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "sata0",   "prsnt",    V_88F6925_PLUS),
25262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(2, "sata1",   "prsnt",    V_88F6925_PLUS),
25362306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "sata2",   "prsnt",    V_88F6928),
25462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "sata3",   "prsnt",    V_88F6928),
25562306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "led",     "clk",      V_88F6920_PLUS)),
25662306a36Sopenharmony_ci	MPP_MODE(45,
25762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
25862306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "ref",     "clk_out0", V_88F6920_PLUS),
25962306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(2, "pcie0",   "rstout",   V_88F6920_PLUS),
26062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(6, "ua1",     "rxd",      V_88F6920_PLUS)),
26162306a36Sopenharmony_ci	MPP_MODE(46,
26262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
26362306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "ref",     "clk_out1", V_88F6920_PLUS),
26462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(2, "pcie0",   "rstout",   V_88F6920_PLUS),
26562306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(6, "ua1",     "txd",      V_88F6920_PLUS),
26662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "led",     "stb",      V_88F6920_PLUS)),
26762306a36Sopenharmony_ci	MPP_MODE(47,
26862306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
26962306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "sata0",   "prsnt",    V_88F6925_PLUS),
27062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(2, "sata1",   "prsnt",    V_88F6925_PLUS),
27162306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "sata2",   "prsnt",    V_88F6928),
27262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "sata3",   "prsnt",    V_88F6928),
27362306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "led",     "data",     V_88F6920_PLUS)),
27462306a36Sopenharmony_ci	MPP_MODE(48,
27562306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
27662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "sata0",   "prsnt",    V_88F6925_PLUS),
27762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(2, "dram",    "vttctrl",  V_88F6920_PLUS),
27862306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "tdm",     "pclk",     V_88F6928),
27962306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "audio",   "mclk",     V_88F6928),
28062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "sd0",     "d4",       V_88F6920_PLUS),
28162306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(6, "pcie0",   "clkreq",   V_88F6920_PLUS),
28262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "ua1",     "txd",      V_88F6920_PLUS)),
28362306a36Sopenharmony_ci	MPP_MODE(49,
28462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
28562306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "sata2",   "prsnt",    V_88F6928),
28662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(2, "sata3",   "prsnt",    V_88F6928),
28762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "tdm",     "fsync",    V_88F6928),
28862306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "audio",   "lrclk",    V_88F6928),
28962306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "sd0",     "d5",       V_88F6920_PLUS),
29062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "ua2",     "rxd",      V_88F6920_PLUS)),
29162306a36Sopenharmony_ci	MPP_MODE(50,
29262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
29362306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "pcie0",   "rstout",   V_88F6920_PLUS),
29462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "tdm",     "drx",      V_88F6928),
29562306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "audio",   "extclk",   V_88F6928),
29662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "sd0",     "cmd",      V_88F6920_PLUS),
29762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "ua2",     "rxd",      V_88F6920_PLUS)),
29862306a36Sopenharmony_ci	MPP_MODE(51,
29962306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
30062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "tdm",     "dtx",      V_88F6928),
30162306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "audio",   "sdo",      V_88F6928),
30262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "dram",    "deccerr",  V_88F6920_PLUS),
30362306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "ua2",     "txd",      V_88F6920_PLUS)),
30462306a36Sopenharmony_ci	MPP_MODE(52,
30562306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
30662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "pcie0",   "rstout",   V_88F6920_PLUS),
30762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "tdm",     "int",      V_88F6928),
30862306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "audio",   "sdi",      V_88F6928),
30962306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "sd0",     "d6",       V_88F6920_PLUS),
31062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "i2c3",    "sck",      V_88F6920_PLUS)),
31162306a36Sopenharmony_ci	MPP_MODE(53,
31262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
31362306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "sata1",   "prsnt",    V_88F6925_PLUS),
31462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(2, "sata0",   "prsnt",    V_88F6925_PLUS),
31562306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "tdm",     "rst",      V_88F6928),
31662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "audio",   "bclk",     V_88F6928),
31762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "sd0",     "d7",       V_88F6920_PLUS),
31862306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "i2c3",    "sda",      V_88F6920_PLUS)),
31962306a36Sopenharmony_ci	MPP_MODE(54,
32062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
32162306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "sata0",   "prsnt",    V_88F6925_PLUS),
32262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(2, "sata1",   "prsnt",    V_88F6925_PLUS),
32362306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "pcie0",   "rstout",   V_88F6920_PLUS),
32462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "sd0",     "d3",       V_88F6920_PLUS),
32562306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "ua3",     "txd",      V_88F6920_PLUS)),
32662306a36Sopenharmony_ci	MPP_MODE(55,
32762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
32862306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "ua1",     "cts",      V_88F6920_PLUS),
32962306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "spi1",    "cs1",      V_88F6920_PLUS),
33062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "sd0",     "d0",       V_88F6920_PLUS),
33162306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(6, "ua1",     "rxd",      V_88F6920_PLUS),
33262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(7, "ua3",     "rxd",      V_88F6920_PLUS)),
33362306a36Sopenharmony_ci	MPP_MODE(56,
33462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
33562306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "ua1",     "rts",      V_88F6920_PLUS),
33662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "dram",    "deccerr",  V_88F6920_PLUS),
33762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "spi1",    "mosi",     V_88F6920_PLUS),
33862306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(6, "ua1",     "txd",      V_88F6920_PLUS)),
33962306a36Sopenharmony_ci	MPP_MODE(57,
34062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
34162306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "spi1",    "sck",      V_88F6920_PLUS),
34262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "sd0",     "clk",      V_88F6920_PLUS),
34362306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(6, "ua1",     "txd",      V_88F6920_PLUS)),
34462306a36Sopenharmony_ci	MPP_MODE(58,
34562306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
34662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(2, "i2c1",    "sck",      V_88F6920_PLUS),
34762306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(3, "pcie2",   "clkreq",   V_88F6920_PLUS),
34862306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "spi1",    "miso",     V_88F6920_PLUS),
34962306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "sd0",     "d1",       V_88F6920_PLUS),
35062306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(6, "ua1",     "rxd",      V_88F6920_PLUS)),
35162306a36Sopenharmony_ci	MPP_MODE(59,
35262306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(0, "gpio",    NULL,       V_88F6920_PLUS),
35362306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(1, "pcie0",   "rstout",   V_88F6920_PLUS),
35462306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(2, "i2c1",    "sda",      V_88F6920_PLUS),
35562306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(4, "spi1",    "cs0",      V_88F6920_PLUS),
35662306a36Sopenharmony_ci		 MPP_VAR_FUNCTION(5, "sd0",     "d2",       V_88F6920_PLUS)),
35762306a36Sopenharmony_ci};
35862306a36Sopenharmony_ci
35962306a36Sopenharmony_cistatic struct mvebu_pinctrl_soc_info armada_39x_pinctrl_info;
36062306a36Sopenharmony_ci
36162306a36Sopenharmony_cistatic const struct of_device_id armada_39x_pinctrl_of_match[] = {
36262306a36Sopenharmony_ci	{
36362306a36Sopenharmony_ci		.compatible = "marvell,mv88f6920-pinctrl",
36462306a36Sopenharmony_ci		.data       = (void *) V_88F6920,
36562306a36Sopenharmony_ci	},
36662306a36Sopenharmony_ci	{
36762306a36Sopenharmony_ci		.compatible = "marvell,mv88f6925-pinctrl",
36862306a36Sopenharmony_ci		.data       = (void *) V_88F6925,
36962306a36Sopenharmony_ci	},
37062306a36Sopenharmony_ci	{
37162306a36Sopenharmony_ci		.compatible = "marvell,mv88f6928-pinctrl",
37262306a36Sopenharmony_ci		.data       = (void *) V_88F6928,
37362306a36Sopenharmony_ci	},
37462306a36Sopenharmony_ci	{ },
37562306a36Sopenharmony_ci};
37662306a36Sopenharmony_ci
37762306a36Sopenharmony_cistatic const struct mvebu_mpp_ctrl armada_39x_mpp_controls[] = {
37862306a36Sopenharmony_ci	MPP_FUNC_CTRL(0, 59, NULL, mvebu_mmio_mpp_ctrl),
37962306a36Sopenharmony_ci};
38062306a36Sopenharmony_ci
38162306a36Sopenharmony_cistatic struct pinctrl_gpio_range armada_39x_mpp_gpio_ranges[] = {
38262306a36Sopenharmony_ci	MPP_GPIO_RANGE(0,   0,  0, 32),
38362306a36Sopenharmony_ci	MPP_GPIO_RANGE(1,  32, 32, 28),
38462306a36Sopenharmony_ci};
38562306a36Sopenharmony_ci
38662306a36Sopenharmony_cistatic int armada_39x_pinctrl_probe(struct platform_device *pdev)
38762306a36Sopenharmony_ci{
38862306a36Sopenharmony_ci	struct mvebu_pinctrl_soc_info *soc = &armada_39x_pinctrl_info;
38962306a36Sopenharmony_ci	const struct of_device_id *match =
39062306a36Sopenharmony_ci		of_match_device(armada_39x_pinctrl_of_match, &pdev->dev);
39162306a36Sopenharmony_ci
39262306a36Sopenharmony_ci	if (!match)
39362306a36Sopenharmony_ci		return -ENODEV;
39462306a36Sopenharmony_ci
39562306a36Sopenharmony_ci	soc->variant = (unsigned) match->data & 0xff;
39662306a36Sopenharmony_ci	soc->controls = armada_39x_mpp_controls;
39762306a36Sopenharmony_ci	soc->ncontrols = ARRAY_SIZE(armada_39x_mpp_controls);
39862306a36Sopenharmony_ci	soc->gpioranges = armada_39x_mpp_gpio_ranges;
39962306a36Sopenharmony_ci	soc->ngpioranges = ARRAY_SIZE(armada_39x_mpp_gpio_ranges);
40062306a36Sopenharmony_ci	soc->modes = armada_39x_mpp_modes;
40162306a36Sopenharmony_ci	soc->nmodes = armada_39x_mpp_controls[0].npins;
40262306a36Sopenharmony_ci
40362306a36Sopenharmony_ci	pdev->dev.platform_data = soc;
40462306a36Sopenharmony_ci
40562306a36Sopenharmony_ci	return mvebu_pinctrl_simple_mmio_probe(pdev);
40662306a36Sopenharmony_ci}
40762306a36Sopenharmony_ci
40862306a36Sopenharmony_cistatic struct platform_driver armada_39x_pinctrl_driver = {
40962306a36Sopenharmony_ci	.driver = {
41062306a36Sopenharmony_ci		.name = "armada-39x-pinctrl",
41162306a36Sopenharmony_ci		.of_match_table = of_match_ptr(armada_39x_pinctrl_of_match),
41262306a36Sopenharmony_ci	},
41362306a36Sopenharmony_ci	.probe = armada_39x_pinctrl_probe,
41462306a36Sopenharmony_ci};
41562306a36Sopenharmony_cibuiltin_platform_driver(armada_39x_pinctrl_driver);
416