Skip to content

Commit d705073

Browse files
vitkyrkalinusw
authored andcommitted
gpio: etraxfs: add support for ARTPEC-3
Add support for the GIO block in the ARTPEC-3 SoC. The basic functionality is essentialy the same as the version in the ETRAX FS, except for a different set of ports, including a read-only port. Cc: [email protected] Signed-off-by: Rabin Vincent <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
1 parent 91492a4 commit d705073

File tree

2 files changed

+62
-7
lines changed

2 files changed

+62
-7
lines changed

Documentation/devicetree/bindings/gpio/gpio-etraxfs.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ Axis ETRAX FS General I/O controller bindings
22

33
Required properties:
44

5-
- compatible:
5+
- compatible: one of:
66
- "axis,etraxfs-gio"
7+
- "axis,artpec3-gio"
78
- reg: Physical base address and length of the controller's registers.
89
- #gpio-cells: Should be 3
910
- The first cell is the gpio offset number.

drivers/gpio/gpio-etraxfs.c

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@
2626
#define ETRAX_FS_r_pe_din 84
2727
#define ETRAX_FS_rw_pe_oe 88
2828

29+
#define ARTPEC3_r_pa_din 0
30+
#define ARTPEC3_rw_pa_dout 4
31+
#define ARTPEC3_rw_pa_oe 8
32+
#define ARTPEC3_r_pb_din 44
33+
#define ARTPEC3_rw_pb_dout 48
34+
#define ARTPEC3_rw_pb_oe 52
35+
#define ARTPEC3_r_pc_din 88
36+
#define ARTPEC3_rw_pc_dout 92
37+
#define ARTPEC3_rw_pc_oe 96
38+
#define ARTPEC3_r_pd_din 116
39+
2940
struct etraxfs_gpio_port {
3041
const char *label;
3142
unsigned int oe;
@@ -82,6 +93,40 @@ static const struct etraxfs_gpio_info etraxfs_gpio_etraxfs = {
8293
.ports = etraxfs_gpio_etraxfs_ports,
8394
};
8495

96+
static const struct etraxfs_gpio_port etraxfs_gpio_artpec3_ports[] = {
97+
{
98+
.label = "A",
99+
.ngpio = 32,
100+
.oe = ARTPEC3_rw_pa_oe,
101+
.dout = ARTPEC3_rw_pa_dout,
102+
.din = ARTPEC3_r_pa_din,
103+
},
104+
{
105+
.label = "B",
106+
.ngpio = 32,
107+
.oe = ARTPEC3_rw_pb_oe,
108+
.dout = ARTPEC3_rw_pb_dout,
109+
.din = ARTPEC3_r_pb_din,
110+
},
111+
{
112+
.label = "C",
113+
.ngpio = 16,
114+
.oe = ARTPEC3_rw_pc_oe,
115+
.dout = ARTPEC3_rw_pc_dout,
116+
.din = ARTPEC3_r_pc_din,
117+
},
118+
{
119+
.label = "D",
120+
.ngpio = 32,
121+
.din = ARTPEC3_r_pd_din,
122+
},
123+
};
124+
125+
static const struct etraxfs_gpio_info etraxfs_gpio_artpec3 = {
126+
.num_ports = ARRAY_SIZE(etraxfs_gpio_artpec3_ports),
127+
.ports = etraxfs_gpio_artpec3_ports,
128+
};
129+
85130
static int etraxfs_gpio_of_xlate(struct gpio_chip *gc,
86131
const struct of_phandle_args *gpiospec,
87132
u32 *flags)
@@ -101,6 +146,10 @@ static const struct of_device_id etraxfs_gpio_of_table[] = {
101146
.compatible = "axis,etraxfs-gio",
102147
.data = &etraxfs_gpio_etraxfs,
103148
},
149+
{
150+
.compatible = "axis,artpec3-gio",
151+
.data = &etraxfs_gpio_artpec3,
152+
},
104153
{},
105154
};
106155

@@ -133,14 +182,19 @@ static int etraxfs_gpio_probe(struct platform_device *pdev)
133182
for (i = 0; i < info->num_ports; i++) {
134183
struct bgpio_chip *bgc = &chips[i];
135184
const struct etraxfs_gpio_port *port = &info->ports[i];
185+
unsigned long flags = BGPIOF_READ_OUTPUT_REG_SET;
186+
void __iomem *dat = regs + port->din;
187+
void __iomem *set = regs + port->dout;
188+
void __iomem *dirout = regs + port->oe;
189+
190+
if (dirout == set) {
191+
dirout = set = NULL;
192+
flags = BGPIOF_NO_OUTPUT;
193+
}
136194

137195
ret = bgpio_init(bgc, dev, 4,
138-
regs + port->din, /* dat */
139-
regs + port->dout, /* set */
140-
NULL, /* clr */
141-
regs + port->oe, /* dirout */
142-
NULL, /* dirin */
143-
BGPIOF_READ_OUTPUT_REG_SET);
196+
dat, set, NULL, dirout, NULL,
197+
flags);
144198
if (ret)
145199
return ret;
146200

0 commit comments

Comments
 (0)