Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: devicetree@vger.kernel.org
Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Rabin Vincent and committed by
Linus Walleij
d705073c 91492a44

+62 -7
+2 -1
Documentation/devicetree/bindings/gpio/gpio-etraxfs.txt
··· 2 2 3 3 Required properties: 4 4 5 - - compatible: 5 + - compatible: one of: 6 6 - "axis,etraxfs-gio" 7 + - "axis,artpec3-gio" 7 8 - reg: Physical base address and length of the controller's registers. 8 9 - #gpio-cells: Should be 3 9 10 - The first cell is the gpio offset number.
+60 -6
drivers/gpio/gpio-etraxfs.c
··· 26 26 #define ETRAX_FS_r_pe_din 84 27 27 #define ETRAX_FS_rw_pe_oe 88 28 28 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 + 29 40 struct etraxfs_gpio_port { 30 41 const char *label; 31 42 unsigned int oe; ··· 93 82 .ports = etraxfs_gpio_etraxfs_ports, 94 83 }; 95 84 85 + static const struct etraxfs_gpio_port etraxfs_gpio_artpec3_ports[] = { 86 + { 87 + .label = "A", 88 + .ngpio = 32, 89 + .oe = ARTPEC3_rw_pa_oe, 90 + .dout = ARTPEC3_rw_pa_dout, 91 + .din = ARTPEC3_r_pa_din, 92 + }, 93 + { 94 + .label = "B", 95 + .ngpio = 32, 96 + .oe = ARTPEC3_rw_pb_oe, 97 + .dout = ARTPEC3_rw_pb_dout, 98 + .din = ARTPEC3_r_pb_din, 99 + }, 100 + { 101 + .label = "C", 102 + .ngpio = 16, 103 + .oe = ARTPEC3_rw_pc_oe, 104 + .dout = ARTPEC3_rw_pc_dout, 105 + .din = ARTPEC3_r_pc_din, 106 + }, 107 + { 108 + .label = "D", 109 + .ngpio = 32, 110 + .din = ARTPEC3_r_pd_din, 111 + }, 112 + }; 113 + 114 + static const struct etraxfs_gpio_info etraxfs_gpio_artpec3 = { 115 + .num_ports = ARRAY_SIZE(etraxfs_gpio_artpec3_ports), 116 + .ports = etraxfs_gpio_artpec3_ports, 117 + }; 118 + 96 119 static int etraxfs_gpio_of_xlate(struct gpio_chip *gc, 97 120 const struct of_phandle_args *gpiospec, 98 121 u32 *flags) ··· 145 100 { 146 101 .compatible = "axis,etraxfs-gio", 147 102 .data = &etraxfs_gpio_etraxfs, 103 + }, 104 + { 105 + .compatible = "axis,artpec3-gio", 106 + .data = &etraxfs_gpio_artpec3, 148 107 }, 149 108 {}, 150 109 }; ··· 182 133 for (i = 0; i < info->num_ports; i++) { 183 134 struct bgpio_chip *bgc = &chips[i]; 184 135 const struct etraxfs_gpio_port *port = &info->ports[i]; 136 + unsigned long flags = BGPIOF_READ_OUTPUT_REG_SET; 137 + void __iomem *dat = regs + port->din; 138 + void __iomem *set = regs + port->dout; 139 + void __iomem *dirout = regs + port->oe; 140 + 141 + if (dirout == set) { 142 + dirout = set = NULL; 143 + flags = BGPIOF_NO_OUTPUT; 144 + } 185 145 186 146 ret = bgpio_init(bgc, dev, 4, 187 - regs + port->din, /* dat */ 188 - regs + port->dout, /* set */ 189 - NULL, /* clr */ 190 - regs + port->oe, /* dirout */ 191 - NULL, /* dirin */ 192 - BGPIOF_READ_OUTPUT_REG_SET); 147 + dat, set, NULL, dirout, NULL, 148 + flags); 193 149 if (ret) 194 150 return ret; 195 151