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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
// SPDX-License-Identifier: (GPL-2.0 OR MIT)
/*
* Microsemi SoCs pinctrl driver
*
* Author: <gregory.clement@bootlin.com>
* License: Dual MIT/GPL
* Copyright (c) 2018 Microsemi Corporation
*/
#include <common.h>
#include <config.h>
#include <dm.h>
#include <dm/device-internal.h>
#include <dm/lists.h>
#include <dm/pinctrl.h>
#include <dm/root.h>
#include <errno.h>
#include <fdtdec.h>
#include <linux/io.h>
#include <asm/gpio.h>
#include <asm/system.h>
#include "mscc-common.h"
enum {
FUNC_NONE,
FUNC_GPIO,
FUNC_SIO,
FUNC_TACHO,
FUNC_TWI,
FUNC_PHY_LED,
FUNC_EXT_IRQ,
FUNC_SFP,
FUNC_SI,
FUNC_PWM,
FUNC_UART,
FUNC_MAX
};
static char * const luton_function_names[] = {
[FUNC_NONE] = "none",
[FUNC_GPIO] = "gpio",
[FUNC_SIO] = "sio",
[FUNC_TACHO] = "tacho",
[FUNC_TWI] = "twi",
[FUNC_PHY_LED] = "phy_led",
[FUNC_EXT_IRQ] = "ext_irq",
[FUNC_SFP] = "sfp",
[FUNC_SI] = "si",
[FUNC_PWM] = "pwm",
[FUNC_UART] = "uart",
};
MSCC_P(0, SIO, NONE, NONE);
MSCC_P(1, SIO, NONE, NONE);
MSCC_P(2, SIO, NONE, NONE);
MSCC_P(3, SIO, NONE, NONE);
MSCC_P(4, TACHO, NONE, NONE);
MSCC_P(5, TWI, PHY_LED, NONE);
MSCC_P(6, TWI, PHY_LED, NONE);
MSCC_P(7, NONE, PHY_LED, NONE);
MSCC_P(8, EXT_IRQ, PHY_LED, NONE);
MSCC_P(9, EXT_IRQ, PHY_LED, NONE);
MSCC_P(10, SFP, PHY_LED, NONE);
MSCC_P(11, SFP, PHY_LED, NONE);
MSCC_P(12, SFP, PHY_LED, NONE);
MSCC_P(13, SFP, PHY_LED, NONE);
MSCC_P(14, SI, PHY_LED, NONE);
MSCC_P(15, SI, PHY_LED, NONE);
MSCC_P(16, SI, PHY_LED, NONE);
MSCC_P(17, SFP, PHY_LED, NONE);
MSCC_P(18, SFP, PHY_LED, NONE);
MSCC_P(19, SFP, PHY_LED, NONE);
MSCC_P(20, SFP, PHY_LED, NONE);
MSCC_P(21, SFP, PHY_LED, NONE);
MSCC_P(22, SFP, PHY_LED, NONE);
MSCC_P(23, SFP, PHY_LED, NONE);
MSCC_P(24, SFP, PHY_LED, NONE);
MSCC_P(25, SFP, PHY_LED, NONE);
MSCC_P(26, SFP, PHY_LED, NONE);
MSCC_P(27, SFP, PHY_LED, NONE);
MSCC_P(28, SFP, PHY_LED, NONE);
MSCC_P(29, PWM, NONE, NONE);
MSCC_P(30, UART, NONE, NONE);
MSCC_P(31, UART, NONE, NONE);
#define LUTON_PIN(n) { \
.name = "GPIO_"#n, \
.drv_data = &mscc_pin_##n \
}
static const struct mscc_pin_data luton_pins[] = {
LUTON_PIN(0),
LUTON_PIN(1),
LUTON_PIN(2),
LUTON_PIN(3),
LUTON_PIN(4),
LUTON_PIN(5),
LUTON_PIN(6),
LUTON_PIN(7),
LUTON_PIN(8),
LUTON_PIN(9),
LUTON_PIN(10),
LUTON_PIN(11),
LUTON_PIN(12),
LUTON_PIN(13),
LUTON_PIN(14),
LUTON_PIN(15),
LUTON_PIN(16),
LUTON_PIN(17),
LUTON_PIN(18),
LUTON_PIN(19),
LUTON_PIN(20),
LUTON_PIN(21),
LUTON_PIN(22),
LUTON_PIN(23),
LUTON_PIN(24),
LUTON_PIN(25),
LUTON_PIN(26),
LUTON_PIN(27),
LUTON_PIN(28),
LUTON_PIN(29),
LUTON_PIN(30),
LUTON_PIN(31),
};
static const unsigned long luton_gpios[] = {
[MSCC_GPIO_OUT_SET] = 0x00,
[MSCC_GPIO_OUT_CLR] = 0x04,
[MSCC_GPIO_OUT] = 0x08,
[MSCC_GPIO_IN] = 0x0c,
[MSCC_GPIO_OE] = 0x10,
[MSCC_GPIO_INTR] = 0x14,
[MSCC_GPIO_INTR_ENA] = 0x18,
[MSCC_GPIO_INTR_IDENT] = 0x1c,
[MSCC_GPIO_ALT0] = 0x20,
[MSCC_GPIO_ALT1] = 0x24,
};
static int luton_gpio_probe(struct udevice *dev)
{
struct gpio_dev_priv *uc_priv;
uc_priv = dev_get_uclass_priv(dev);
uc_priv->bank_name = "luton-gpio";
uc_priv->gpio_count = ARRAY_SIZE(luton_pins);
return 0;
}
static struct driver luton_gpio_driver = {
.name = "luton-gpio",
.id = UCLASS_GPIO,
.probe = luton_gpio_probe,
.ops = &mscc_gpio_ops,
};
int luton_pinctrl_probe(struct udevice *dev)
{
int ret;
ret = mscc_pinctrl_probe(dev, FUNC_MAX, luton_pins,
ARRAY_SIZE(luton_pins), luton_function_names,
luton_gpios);
if (ret)
return ret;
ret = device_bind_offset(dev, &luton_gpio_driver, "luton-gpio", NULL,
dev_of_offset(dev), NULL);
return 0;
}
static const struct udevice_id luton_pinctrl_of_match[] = {
{.compatible = "mscc,luton-pinctrl"},
{},
};
U_BOOT_DRIVER(luton_pinctrl) = {
.name = "luton-pinctrl",
.id = UCLASS_PINCTRL,
.of_match = of_match_ptr(luton_pinctrl_of_match),
.probe = luton_pinctrl_probe,
.priv_auto_alloc_size = sizeof(struct mscc_pinctrl),
.ops = &mscc_pinctrl_ops,
};
|