summaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/mvebu/pinctrl-armada-ap806.c
blob: 7becf2781a0b9f69d69f849bc2f69f84769c0f40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Marvell Armada ap806 pinctrl driver based on mvebu pinctrl core
 *
 * Copyright (C) 2017 Marvell
 *
 * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
 * Hanna Hawa <hannah@marvell.com>
 */

#include <linux/err.h>
#include <linux/init.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#include <linux/of.h>
#include <linux/pinctrl/pinctrl.h>

#include "pinctrl-mvebu.h"

static struct mvebu_mpp_mode armada_ap806_mpp_modes[] = {
	MPP_MODE(0,
		 MPP_FUNCTION(0, "gpio",    NULL),
		 MPP_FUNCTION(1, "sdio",    "clk"),
		 MPP_FUNCTION(3, "spi0",    "clk")),
	MPP_MODE(1,
		 MPP_FUNCTION(0, "gpio",    NULL),
		 MPP_FUNCTION(1, "sdio",    "cmd"),
		 MPP_FUNCTION(3, "spi0",    "miso")),
	MPP_MODE(2,
		 MPP_FUNCTION(0, "gpio",    NULL),
		 MPP_FUNCTION(1, "sdio",    "d0"),
		 MPP_FUNCTION(3, "spi0",    "mosi")),
	MPP_MODE(3,
		 MPP_FUNCTION(0, "gpio",    NULL),
		 MPP_FUNCTION(1, "sdio",    "d1"),
		 MPP_FUNCTION(3, "spi0",    "cs0n")),
	MPP_MODE(4,
		 MPP_FUNCTION(0, "gpio",    NULL),
		 MPP_FUNCTION(1, "sdio",    "d2"),
		 MPP_FUNCTION(3, "i2c0",    "sda")),
	MPP_MODE(5,
		 MPP_FUNCTION(0, "gpio",    NULL),
		 MPP_FUNCTION(1, "sdio",    "d3"),
		 MPP_FUNCTION(3, "i2c0",    "sdk")),
	MPP_MODE(6,
		 MPP_FUNCTION(0, "gpio",    NULL),
		 MPP_FUNCTION(1, "sdio",    "ds")),
	MPP_MODE(7,
		 MPP_FUNCTION(0, "gpio",    NULL),
		 MPP_FUNCTION(1, "sdio",    "d4"),
		 MPP_FUNCTION(3, "uart1",   "rxd")),
	MPP_MODE(8,
		 MPP_FUNCTION(0, "gpio",    NULL),
		 MPP_FUNCTION(1, "sdio",    "d5"),
		 MPP_FUNCTION(3, "uart1",   "txd")),
	MPP_MODE(9,
		 MPP_FUNCTION(0, "gpio",    NULL),
		 MPP_FUNCTION(1, "sdio",    "d6"),
		 MPP_FUNCTION(3, "spi0",    "cs1n")),
	MPP_MODE(10,
		 MPP_FUNCTION(0, "gpio",    NULL),
		 MPP_FUNCTION(1, "sdio",    "d7")),
	MPP_MODE(11,
		 MPP_FUNCTION(0, "gpio",    NULL),
		 MPP_FUNCTION(3, "uart0",   "txd")),
	MPP_MODE(12,
		 MPP_FUNCTION(0, "gpio",    NULL),
		 MPP_FUNCTION(1, "sdio",    "pw_off"),
		 MPP_FUNCTION(2, "sdio",    "hw_rst")),
	MPP_MODE(13,
		 MPP_FUNCTION(0, "gpio",    NULL)),
	MPP_MODE(14,
		 MPP_FUNCTION(0, "gpio",    NULL)),
	MPP_MODE(15,
		 MPP_FUNCTION(0, "gpio",    NULL)),
	MPP_MODE(16,
		 MPP_FUNCTION(0, "gpio",    NULL)),
	MPP_MODE(17,
		 MPP_FUNCTION(0, "gpio",    NULL)),
	MPP_MODE(18,
		 MPP_FUNCTION(0, "gpio",    NULL)),
	MPP_MODE(19,
		 MPP_FUNCTION(0, "gpio",    NULL),
		 MPP_FUNCTION(3, "uart0",   "rxd"),
		 MPP_FUNCTION(4, "sdio",    "pw_off")),
};

static struct mvebu_pinctrl_soc_info armada_ap806_pinctrl_info;

static const struct of_device_id armada_ap806_pinctrl_of_match[] = {
	{
		.compatible = "marvell,ap806-pinctrl",
	},
	{ },
};

static const struct mvebu_mpp_ctrl armada_ap806_mpp_controls[] = {
	MPP_FUNC_CTRL(0, 19, NULL, mvebu_regmap_mpp_ctrl),
};

static struct pinctrl_gpio_range armada_ap806_mpp_gpio_ranges[] = {
	MPP_GPIO_RANGE(0,   0,  0, 20),
};

static int armada_ap806_pinctrl_probe(struct platform_device *pdev)
{
	struct mvebu_pinctrl_soc_info *soc = &armada_ap806_pinctrl_info;

	if (!pdev->dev.parent)
		return -ENODEV;

	soc->variant = 0; /* no variants for Armada AP806 */
	soc->controls = armada_ap806_mpp_controls;
	soc->ncontrols = ARRAY_SIZE(armada_ap806_mpp_controls);
	soc->gpioranges = armada_ap806_mpp_gpio_ranges;
	soc->ngpioranges = ARRAY_SIZE(armada_ap806_mpp_gpio_ranges);
	soc->modes = armada_ap806_mpp_modes;
	soc->nmodes = armada_ap806_mpp_controls[0].npins;

	pdev->dev.platform_data = soc;

	return mvebu_pinctrl_simple_regmap_probe(pdev, pdev->dev.parent, 0);
}

static struct platform_driver armada_ap806_pinctrl_driver = {
	.driver = {
		.name = "armada-ap806-pinctrl",
		.of_match_table = of_match_ptr(armada_ap806_pinctrl_of_match),
	},
	.probe = armada_ap806_pinctrl_probe,
};

builtin_platform_driver(armada_ap806_pinctrl_driver);