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

Merge branch 'at91' into devel

+2794 -446
+5
Documentation/devicetree/bindings/gpio/gpio_atmel.txt
··· 9 9 unused). 10 10 - gpio-controller: Marks the device node as a GPIO controller. 11 11 12 + optional properties: 13 + - #gpio-lines: Number of gpio if absent 32. 14 + 15 + 12 16 Example: 13 17 pioA: gpio@fffff200 { 14 18 compatible = "atmel,at91rm9200-gpio"; ··· 20 16 interrupts = <2 4>; 21 17 #gpio-cells = <2>; 22 18 gpio-controller; 19 + #gpio-lines = <19>; 23 20 }; 24 21
+136
Documentation/devicetree/bindings/pinctrl/atmel,at91-pinctrl.txt
··· 1 + * Atmel AT91 Pinmux Controller 2 + 3 + The AT91 Pinmux Controler, enables the IC 4 + to share one PAD to several functional blocks. The sharing is done by 5 + multiplexing the PAD input/output signals. For each PAD there are up to 6 + 8 muxing options (called periph modes). Since different modules require 7 + different PAD settings (like pull up, keeper, etc) the contoller controls 8 + also the PAD settings parameters. 9 + 10 + Please refer to pinctrl-bindings.txt in this directory for details of the 11 + common pinctrl bindings used by client devices, including the meaning of the 12 + phrase "pin configuration node". 13 + 14 + Atmel AT91 pin configuration node is a node of a group of pins which can be 15 + used for a specific device or function. This node represents both mux and config 16 + of the pins in that group. The 'pins' selects the function mode(also named pin 17 + mode) this pin can work on and the 'config' configures various pad settings 18 + such as pull-up, multi drive, etc. 19 + 20 + Required properties for iomux controller: 21 + - compatible: "atmel,at91rm9200-pinctrl" 22 + - atmel,mux-mask: array of mask (periph per bank) to describe if a pin can be 23 + configured in this periph mode. All the periph and bank need to be describe. 24 + 25 + How to create such array: 26 + 27 + Each column will represent the possible peripheral of the pinctrl 28 + Each line will represent a pio bank 29 + 30 + Take an example on the 9260 31 + Peripheral: 2 ( A and B) 32 + Bank: 3 (A, B and C) 33 + => 34 + 35 + /* A B */ 36 + 0xffffffff 0xffc00c3b /* pioA */ 37 + 0xffffffff 0x7fff3ccf /* pioB */ 38 + 0xffffffff 0x007fffff /* pioC */ 39 + 40 + For each peripheral/bank we will descibe in a u32 if a pin can can be 41 + configured in it by putting 1 to the pin bit (1 << pin) 42 + 43 + Let's take the pioA on peripheral B 44 + From the datasheet Table 10-2. 45 + Peripheral B 46 + PA0 MCDB0 47 + PA1 MCCDB 48 + PA2 49 + PA3 MCDB3 50 + PA4 MCDB2 51 + PA5 MCDB1 52 + PA6 53 + PA7 54 + PA8 55 + PA9 56 + PA10 ETX2 57 + PA11 ETX3 58 + PA12 59 + PA13 60 + PA14 61 + PA15 62 + PA16 63 + PA17 64 + PA18 65 + PA19 66 + PA20 67 + PA21 68 + PA22 ETXER 69 + PA23 ETX2 70 + PA24 ETX3 71 + PA25 ERX2 72 + PA26 ERX3 73 + PA27 ERXCK 74 + PA28 ECRS 75 + PA29 ECOL 76 + PA30 RXD4 77 + PA31 TXD4 78 + 79 + => 0xffc00c3b 80 + 81 + Required properties for pin configuration node: 82 + - atmel,pins: 4 integers array, represents a group of pins mux and config 83 + setting. The format is atmel,pins = <PIN_BANK PIN_BANK_NUM PERIPH CONFIG>. 84 + The PERIPH 0 means gpio. 85 + 86 + Bits used for CONFIG: 87 + PULL_UP(1 << 0): indicate this pin need a pull up. 88 + MULTIDRIVE(1 << 1): indicate this pin need to be configured as multidrive. 89 + 90 + NOTE: 91 + Some requirements for using atmel,at91rm9200-pinctrl binding: 92 + 1. We have pin function node defined under at91 controller node to represent 93 + what pinmux functions this SoC supports. 94 + 2. The driver can use the function node's name and pin configuration node's 95 + name describe the pin function and group hierarchy. 96 + For example, Linux at91 pinctrl driver takes the function node's name 97 + as the function name and pin configuration node's name as group name to 98 + create the map table. 99 + 3. Each pin configuration node should have a phandle, devices can set pins 100 + configurations by referring to the phandle of that pin configuration node. 101 + 4. The gpio controller must be describe in the pinctrl simple-bus. 102 + 103 + Examples: 104 + 105 + pinctrl@fffff400 { 106 + #address-cells = <1>; 107 + #size-cells = <1>; 108 + ranges; 109 + compatible = "atmel,at91rm9200-pinctrl", "simple-bus"; 110 + reg = <0xfffff400 0x600>; 111 + 112 + atmel,mux-mask = < 113 + /* A B */ 114 + 0xffffffff 0xffc00c3b /* pioA */ 115 + 0xffffffff 0x7fff3ccf /* pioB */ 116 + 0xffffffff 0x007fffff /* pioC */ 117 + >; 118 + 119 + /* shared pinctrl settings */ 120 + dbgu { 121 + pinctrl_dbgu: dbgu-0 { 122 + atmel,pins = 123 + <1 14 0x1 0x0 /* PB14 periph A */ 124 + 1 15 0x1 0x1>; /* PB15 periph with pullup */ 125 + }; 126 + }; 127 + }; 128 + 129 + dbgu: serial@fffff200 { 130 + compatible = "atmel,at91sam9260-usart"; 131 + reg = <0xfffff200 0x200>; 132 + interrupts = <1 4 7>; 133 + pinctrl-names = "default"; 134 + pinctrl-0 = <&pinctrl_dbgu>; 135 + status = "disabled"; 136 + };
+6
MAINTAINERS
··· 5639 5639 F: drivers/pinctrl/ 5640 5640 F: include/linux/pinctrl/ 5641 5641 5642 + PIN CONTROLLER - ATMEL AT91 5643 + M: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com> 5644 + L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 5645 + S: Maintained 5646 + F: drivers/pinctrl/pinctrl-at91.c 5647 + 5642 5648 PIN CONTROLLER - ST SPEAR 5643 5649 M: Viresh Kumar <viresh.linux@gmail.com> 5644 5650 L: spear-devel@list.st.com
+2
arch/arm/Kconfig
··· 330 330 select IRQ_DOMAIN 331 331 select NEED_MACH_GPIO_H 332 332 select NEED_MACH_IO_H if PCCARD 333 + select PINCTRL 334 + select PINCTRL_AT91 if USE_OF 333 335 help 334 336 This enables support for systems based on Atmel 335 337 AT91RM9200 and AT91SAM9* processors.
+28 -16
arch/arm/boot/dts/Makefile
··· 1 1 ifeq ($(CONFIG_OF),y) 2 2 3 - dtb-$(CONFIG_ARCH_AT91) += aks-cdu.dtb \ 4 - at91sam9263ek.dtb \ 5 - at91sam9g20ek_2mmc.dtb \ 6 - at91sam9g20ek.dtb \ 7 - at91sam9g25ek.dtb \ 8 - at91sam9m10g45ek.dtb \ 9 - at91sam9n12ek.dtb \ 10 - ethernut5.dtb \ 11 - evk-pro3.dtb \ 12 - kizbox.dtb \ 13 - tny_a9260.dtb \ 14 - tny_a9263.dtb \ 15 - tny_a9g20.dtb \ 16 - usb_a9260.dtb \ 17 - usb_a9263.dtb \ 18 - usb_a9g20.dtb 3 + # Keep at91 dtb files sorted alphabetically for each SoC 4 + # sam9260 5 + dtb-$(CONFIG_ARCH_AT91) += aks-cdu.dtb 6 + dtb-$(CONFIG_ARCH_AT91) += ethernut5.dtb 7 + dtb-$(CONFIG_ARCH_AT91) += evk-pro3.dtb 8 + dtb-$(CONFIG_ARCH_AT91) += tny_a9260.dtb 9 + dtb-$(CONFIG_ARCH_AT91) += usb_a9260.dtb 10 + # sam9263 11 + dtb-$(CONFIG_ARCH_AT91) += at91sam9263ek.dtb 12 + dtb-$(CONFIG_ARCH_AT91) += tny_a9263.dtb 13 + dtb-$(CONFIG_ARCH_AT91) += usb_a9263.dtb 14 + # sam9g20 15 + dtb-$(CONFIG_ARCH_AT91) += at91sam9g20ek.dtb 16 + dtb-$(CONFIG_ARCH_AT91) += at91sam9g20ek_2mmc.dtb 17 + dtb-$(CONFIG_ARCH_AT91) += kizbox.dtb 18 + dtb-$(CONFIG_ARCH_AT91) += tny_a9g20.dtb 19 + dtb-$(CONFIG_ARCH_AT91) += usb_a9g20.dtb 20 + # sam9g45 21 + dtb-$(CONFIG_ARCH_AT91) += at91sam9m10g45ek.dtb 22 + # sam9n12 23 + dtb-$(CONFIG_ARCH_AT91) += at91sam9n12ek.dtb 24 + # sam9x5 25 + dtb-$(CONFIG_ARCH_AT91) += at91sam9g15ek.dtb 26 + dtb-$(CONFIG_ARCH_AT91) += at91sam9g25ek.dtb 27 + dtb-$(CONFIG_ARCH_AT91) += at91sam9g35ek.dtb 28 + dtb-$(CONFIG_ARCH_AT91) += at91sam9x25ek.dtb 29 + dtb-$(CONFIG_ARCH_AT91) += at91sam9x35ek.dtb 30 + 19 31 dtb-$(CONFIG_ARCH_BCM2835) += bcm2835-rpi-b.dtb 20 32 dtb-$(CONFIG_ARCH_DOVE) += dove-cm-a510.dtb \ 21 33 dove-cubox.dtb \
+161 -26
arch/arm/boot/dts/at91sam9260.dtsi
··· 98 98 interrupts = <26 4 0 27 4 0 28 4 0>; 99 99 }; 100 100 101 - pioA: gpio@fffff400 { 102 - compatible = "atmel,at91rm9200-gpio"; 103 - reg = <0xfffff400 0x100>; 104 - interrupts = <2 4 1>; 105 - #gpio-cells = <2>; 106 - gpio-controller; 107 - interrupt-controller; 108 - #interrupt-cells = <2>; 109 - }; 101 + pinctrl@fffff400 { 102 + #address-cells = <1>; 103 + #size-cells = <1>; 104 + compatible = "atmel,at91rm9200-pinctrl", "simple-bus"; 105 + ranges = <0xfffff400 0xfffff400 0x600>; 110 106 111 - pioB: gpio@fffff600 { 112 - compatible = "atmel,at91rm9200-gpio"; 113 - reg = <0xfffff600 0x100>; 114 - interrupts = <3 4 1>; 115 - #gpio-cells = <2>; 116 - gpio-controller; 117 - interrupt-controller; 118 - #interrupt-cells = <2>; 119 - }; 107 + atmel,mux-mask = < 108 + /* A B */ 109 + 0xffffffff 0xffc00c3b /* pioA */ 110 + 0xffffffff 0x7fff3ccf /* pioB */ 111 + 0xffffffff 0x007fffff /* pioC */ 112 + >; 120 113 121 - pioC: gpio@fffff800 { 122 - compatible = "atmel,at91rm9200-gpio"; 123 - reg = <0xfffff800 0x100>; 124 - interrupts = <4 4 1>; 125 - #gpio-cells = <2>; 126 - gpio-controller; 127 - interrupt-controller; 128 - #interrupt-cells = <2>; 114 + /* shared pinctrl settings */ 115 + dbgu { 116 + pinctrl_dbgu: dbgu-0 { 117 + atmel,pins = 118 + <1 14 0x1 0x0 /* PB14 periph A */ 119 + 1 15 0x1 0x1>; /* PB15 periph with pullup */ 120 + }; 121 + }; 122 + 123 + uart0 { 124 + pinctrl_uart0: uart0-0 { 125 + atmel,pins = 126 + <1 4 0x1 0x0 /* PB4 periph A */ 127 + 1 5 0x1 0x0>; /* PB5 periph A */ 128 + }; 129 + 130 + pinctrl_uart0_rts_cts: uart0_rts_cts-0 { 131 + atmel,pins = 132 + <1 26 0x1 0x0 /* PB26 periph A */ 133 + 1 27 0x1 0x0>; /* PB27 periph A */ 134 + }; 135 + 136 + pinctrl_uart0_dtr_dsr: uart0_dtr_dsr-0 { 137 + atmel,pins = 138 + <1 24 0x1 0x0 /* PB24 periph A */ 139 + 1 22 0x1 0x0>; /* PB22 periph A */ 140 + }; 141 + 142 + pinctrl_uart0_dcd: uart0_dcd-0 { 143 + atmel,pins = 144 + <1 23 0x1 0x0>; /* PB23 periph A */ 145 + }; 146 + 147 + pinctrl_uart0_ri: uart0_ri-0 { 148 + atmel,pins = 149 + <1 25 0x1 0x0>; /* PB25 periph A */ 150 + }; 151 + }; 152 + 153 + uart1 { 154 + pinctrl_uart1: uart1-0 { 155 + atmel,pins = 156 + <2 6 0x1 0x1 /* PB6 periph A with pullup */ 157 + 2 7 0x1 0x0>; /* PB7 periph A */ 158 + }; 159 + 160 + pinctrl_uart1_rts_cts: uart1_rts_cts-0 { 161 + atmel,pins = 162 + <1 28 0x1 0x0 /* PB28 periph A */ 163 + 1 29 0x1 0x0>; /* PB29 periph A */ 164 + }; 165 + }; 166 + 167 + uart2 { 168 + pinctrl_uart2: uart2-0 { 169 + atmel,pins = 170 + <1 8 0x1 0x1 /* PB8 periph A with pullup */ 171 + 1 9 0x1 0x0>; /* PB9 periph A */ 172 + }; 173 + 174 + pinctrl_uart2_rts_cts: uart2_rts_cts-0 { 175 + atmel,pins = 176 + <0 4 0x1 0x0 /* PA4 periph A */ 177 + 0 5 0x1 0x0>; /* PA5 periph A */ 178 + }; 179 + }; 180 + 181 + uart3 { 182 + pinctrl_uart3: uart3-0 { 183 + atmel,pins = 184 + <2 10 0x1 0x1 /* PB10 periph A with pullup */ 185 + 2 11 0x1 0x0>; /* PB11 periph A */ 186 + }; 187 + 188 + pinctrl_uart3_rts_cts: uart3_rts_cts-0 { 189 + atmel,pins = 190 + <3 8 0x2 0x0 /* PB8 periph B */ 191 + 3 10 0x2 0x0>; /* PB10 periph B */ 192 + }; 193 + }; 194 + 195 + uart4 { 196 + pinctrl_uart4: uart4-0 { 197 + atmel,pins = 198 + <0 31 0x2 0x1 /* PA31 periph B with pullup */ 199 + 0 30 0x2 0x0>; /* PA30 periph B */ 200 + }; 201 + }; 202 + 203 + uart5 { 204 + pinctrl_uart5: uart5-0 { 205 + atmel,pins = 206 + <2 12 0x1 0x1 /* PB12 periph A with pullup */ 207 + 2 13 0x1 0x0>; /* PB13 periph A */ 208 + }; 209 + }; 210 + 211 + nand { 212 + pinctrl_nand: nand-0 { 213 + atmel,pins = 214 + <2 13 0x0 0x1 /* PC13 gpio RDY pin pull_up */ 215 + 2 14 0x0 0x1>; /* PC14 gpio enable pin pull_up */ 216 + }; 217 + }; 218 + 219 + pioA: gpio@fffff400 { 220 + compatible = "atmel,at91rm9200-gpio"; 221 + reg = <0xfffff400 0x200>; 222 + interrupts = <2 4 1>; 223 + #gpio-cells = <2>; 224 + gpio-controller; 225 + interrupt-controller; 226 + #interrupt-cells = <2>; 227 + }; 228 + 229 + pioB: gpio@fffff600 { 230 + compatible = "atmel,at91rm9200-gpio"; 231 + reg = <0xfffff600 0x200>; 232 + interrupts = <3 4 1>; 233 + #gpio-cells = <2>; 234 + gpio-controller; 235 + interrupt-controller; 236 + #interrupt-cells = <2>; 237 + }; 238 + 239 + pioC: gpio@fffff800 { 240 + compatible = "atmel,at91rm9200-gpio"; 241 + reg = <0xfffff800 0x200>; 242 + interrupts = <4 4 1>; 243 + #gpio-cells = <2>; 244 + gpio-controller; 245 + interrupt-controller; 246 + #interrupt-cells = <2>; 247 + }; 129 248 }; 130 249 131 250 dbgu: serial@fffff200 { 132 251 compatible = "atmel,at91sam9260-usart"; 133 252 reg = <0xfffff200 0x200>; 134 253 interrupts = <1 4 7>; 254 + pinctrl-names = "default"; 255 + pinctrl-0 = <&pinctrl_dbgu>; 135 256 status = "disabled"; 136 257 }; 137 258 ··· 262 141 interrupts = <6 4 5>; 263 142 atmel,use-dma-rx; 264 143 atmel,use-dma-tx; 144 + pinctrl-names = "default"; 145 + pinctrl-0 = <&pinctrl_uart0>; 265 146 status = "disabled"; 266 147 }; 267 148 ··· 273 150 interrupts = <7 4 5>; 274 151 atmel,use-dma-rx; 275 152 atmel,use-dma-tx; 153 + pinctrl-names = "default"; 154 + pinctrl-0 = <&pinctrl_uart1>; 276 155 status = "disabled"; 277 156 }; 278 157 ··· 284 159 interrupts = <8 4 5>; 285 160 atmel,use-dma-rx; 286 161 atmel,use-dma-tx; 162 + pinctrl-names = "default"; 163 + pinctrl-0 = <&pinctrl_uart2>; 287 164 status = "disabled"; 288 165 }; 289 166 ··· 295 168 interrupts = <23 4 5>; 296 169 atmel,use-dma-rx; 297 170 atmel,use-dma-tx; 171 + pinctrl-names = "default"; 172 + pinctrl-0 = <&pinctrl_uart3>; 298 173 status = "disabled"; 299 174 }; 300 175 ··· 306 177 interrupts = <24 4 5>; 307 178 atmel,use-dma-rx; 308 179 atmel,use-dma-tx; 180 + pinctrl-names = "default"; 181 + pinctrl-0 = <&pinctrl_uart4>; 309 182 status = "disabled"; 310 183 }; 311 184 ··· 317 186 interrupts = <25 4 5>; 318 187 atmel,use-dma-rx; 319 188 atmel,use-dma-tx; 189 + pinctrl-names = "default"; 190 + pinctrl-0 = <&pinctrl_uart5>; 320 191 status = "disabled"; 321 192 }; 322 193 ··· 390 257 >; 391 258 atmel,nand-addr-offset = <21>; 392 259 atmel,nand-cmd-offset = <22>; 260 + pinctrl-names = "default"; 261 + pinctrl-0 = <&pinctrl_nand>; 393 262 gpios = <&pioC 13 0 394 263 &pioC 14 0 395 264 0
+129 -44
arch/arm/boot/dts/at91sam9263.dtsi
··· 89 89 reg = <0xfffffd10 0x10>; 90 90 }; 91 91 92 - pioA: gpio@fffff200 { 93 - compatible = "atmel,at91rm9200-gpio"; 94 - reg = <0xfffff200 0x100>; 95 - interrupts = <2 4 1>; 96 - #gpio-cells = <2>; 97 - gpio-controller; 98 - interrupt-controller; 99 - #interrupt-cells = <2>; 100 - }; 92 + pinctrl@fffff200 { 93 + #address-cells = <1>; 94 + #size-cells = <1>; 95 + compatible = "atmel,at91rm9200-pinctrl", "simple-bus"; 96 + ranges = <0xfffff200 0xfffff200 0xa00>; 101 97 102 - pioB: gpio@fffff400 { 103 - compatible = "atmel,at91rm9200-gpio"; 104 - reg = <0xfffff400 0x100>; 105 - interrupts = <3 4 1>; 106 - #gpio-cells = <2>; 107 - gpio-controller; 108 - interrupt-controller; 109 - #interrupt-cells = <2>; 110 - }; 98 + atmel,mux-mask = < 99 + /* A B */ 100 + 0xfffffffb 0xffffe07f /* pioA */ 101 + 0x0007ffff 0x39072fff /* pioB */ 102 + 0xffffffff 0x3ffffff8 /* pioC */ 103 + 0xfffffbff 0xffffffff /* pioD */ 104 + 0xffe00fff 0xfbfcff00 /* pioE */ 105 + >; 111 106 112 - pioC: gpio@fffff600 { 113 - compatible = "atmel,at91rm9200-gpio"; 114 - reg = <0xfffff600 0x100>; 115 - interrupts = <4 4 1>; 116 - #gpio-cells = <2>; 117 - gpio-controller; 118 - interrupt-controller; 119 - #interrupt-cells = <2>; 120 - }; 107 + /* shared pinctrl settings */ 108 + dbgu { 109 + pinctrl_dbgu: dbgu-0 { 110 + atmel,pins = 111 + <2 30 0x1 0x0 /* PC30 periph A */ 112 + 2 31 0x1 0x1>; /* PC31 periph with pullup */ 113 + }; 114 + }; 121 115 122 - pioD: gpio@fffff800 { 123 - compatible = "atmel,at91rm9200-gpio"; 124 - reg = <0xfffff800 0x100>; 125 - interrupts = <4 4 1>; 126 - #gpio-cells = <2>; 127 - gpio-controller; 128 - interrupt-controller; 129 - #interrupt-cells = <2>; 130 - }; 116 + uart0 { 117 + pinctrl_uart0: uart0-0 { 118 + atmel,pins = 119 + <0 26 0x1 0x1 /* PA26 periph A with pullup */ 120 + 0 27 0x1 0x0>; /* PA27 periph A */ 121 + }; 131 122 132 - pioE: gpio@fffffa00 { 133 - compatible = "atmel,at91rm9200-gpio"; 134 - reg = <0xfffffa00 0x100>; 135 - interrupts = <4 4 1>; 136 - #gpio-cells = <2>; 137 - gpio-controller; 138 - interrupt-controller; 139 - #interrupt-cells = <2>; 123 + pinctrl_uart0_rts_cts: uart0_rts_cts-0 { 124 + atmel,pins = 125 + <0 28 0x1 0x0 /* PA28 periph A */ 126 + 0 29 0x1 0x0>; /* PA29 periph A */ 127 + }; 128 + }; 129 + 130 + uart1 { 131 + pinctrl_uart1: uart1-0 { 132 + atmel,pins = 133 + <3 0 0x1 0x1 /* PD0 periph A with pullup */ 134 + 3 1 0x1 0x0>; /* PD1 periph A */ 135 + }; 136 + 137 + pinctrl_uart1_rts_cts: uart1_rts_cts-0 { 138 + atmel,pins = 139 + <3 7 0x2 0x0 /* PD7 periph B */ 140 + 3 8 0x2 0x0>; /* PD8 periph B */ 141 + }; 142 + }; 143 + 144 + uart2 { 145 + pinctrl_uart2: uart2-0 { 146 + atmel,pins = 147 + <3 2 0x1 0x1 /* PD2 periph A with pullup */ 148 + 3 3 0x1 0x0>; /* PD3 periph A */ 149 + }; 150 + 151 + pinctrl_uart2_rts_cts: uart2_rts_cts-0 { 152 + atmel,pins = 153 + <3 5 0x2 0x0 /* PD5 periph B */ 154 + 4 6 0x2 0x0>; /* PD6 periph B */ 155 + }; 156 + }; 157 + 158 + nand { 159 + pinctrl_nand: nand-0 { 160 + atmel,pins = 161 + <0 22 0x0 0x1 /* PA22 gpio RDY pin pull_up*/ 162 + 3 15 0x0 0x1>; /* PD15 gpio enable pin pull_up */ 163 + }; 164 + }; 165 + 166 + pioA: gpio@fffff200 { 167 + compatible = "atmel,at91rm9200-gpio"; 168 + reg = <0xfffff200 0x200>; 169 + interrupts = <2 4 1>; 170 + #gpio-cells = <2>; 171 + gpio-controller; 172 + interrupt-controller; 173 + #interrupt-cells = <2>; 174 + }; 175 + 176 + pioB: gpio@fffff400 { 177 + compatible = "atmel,at91rm9200-gpio"; 178 + reg = <0xfffff400 0x200>; 179 + interrupts = <3 4 1>; 180 + #gpio-cells = <2>; 181 + gpio-controller; 182 + interrupt-controller; 183 + #interrupt-cells = <2>; 184 + }; 185 + 186 + pioC: gpio@fffff600 { 187 + compatible = "atmel,at91rm9200-gpio"; 188 + reg = <0xfffff600 0x200>; 189 + interrupts = <4 4 1>; 190 + #gpio-cells = <2>; 191 + gpio-controller; 192 + interrupt-controller; 193 + #interrupt-cells = <2>; 194 + }; 195 + 196 + pioD: gpio@fffff800 { 197 + compatible = "atmel,at91rm9200-gpio"; 198 + reg = <0xfffff800 0x200>; 199 + interrupts = <4 4 1>; 200 + #gpio-cells = <2>; 201 + gpio-controller; 202 + interrupt-controller; 203 + #interrupt-cells = <2>; 204 + }; 205 + 206 + pioE: gpio@fffffa00 { 207 + compatible = "atmel,at91rm9200-gpio"; 208 + reg = <0xfffffa00 0x200>; 209 + interrupts = <4 4 1>; 210 + #gpio-cells = <2>; 211 + gpio-controller; 212 + interrupt-controller; 213 + #interrupt-cells = <2>; 214 + }; 140 215 }; 141 216 142 217 dbgu: serial@ffffee00 { 143 218 compatible = "atmel,at91sam9260-usart"; 144 219 reg = <0xffffee00 0x200>; 145 220 interrupts = <1 4 7>; 221 + pinctrl-names = "default"; 222 + pinctrl-0 = <&pinctrl_dbgu>; 146 223 status = "disabled"; 147 224 }; 148 225 ··· 229 152 interrupts = <7 4 5>; 230 153 atmel,use-dma-rx; 231 154 atmel,use-dma-tx; 155 + pinctrl-names = "default"; 156 + pinctrl-0 = <&pinctrl_uart0>; 232 157 status = "disabled"; 233 158 }; 234 159 ··· 240 161 interrupts = <8 4 5>; 241 162 atmel,use-dma-rx; 242 163 atmel,use-dma-tx; 164 + pinctrl-names = "default"; 165 + pinctrl-0 = <&pinctrl_uart1>; 243 166 status = "disabled"; 244 167 }; 245 168 ··· 251 170 interrupts = <9 4 5>; 252 171 atmel,use-dma-rx; 253 172 atmel,use-dma-tx; 173 + pinctrl-names = "default"; 174 + pinctrl-0 = <&pinctrl_uart2>; 254 175 status = "disabled"; 255 176 }; 256 177 ··· 289 206 >; 290 207 atmel,nand-addr-offset = <21>; 291 208 atmel,nand-cmd-offset = <22>; 209 + pinctrl-names = "default"; 210 + pinctrl-0 = <&pinctrl_nand>; 292 211 gpios = <&pioA 22 0 293 212 &pioD 15 0 294 213 0
+1
arch/arm/boot/dts/at91sam9263ek.dts
··· 38 38 }; 39 39 40 40 usart0: serial@fff8c000 { 41 + pinctrl-0 = <&pinctrl_uart0 &pinctrl_uart0_rts_cts>; 41 42 status = "okay"; 42 43 }; 43 44
+28
arch/arm/boot/dts/at91sam9g15.dtsi
··· 1 + /* 2 + * at91sam9g15.dtsi - Device Tree Include file for AT91SAM9G15 SoC 3 + * 4 + * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> 5 + * 6 + * Licensed under GPLv2. 7 + */ 8 + 9 + /include/ "at91sam9x5.dtsi" 10 + 11 + / { 12 + model = "Atmel AT91SAM9G15 SoC"; 13 + compatible = "atmel, at91sam9g15, atmel,at91sam9x5"; 14 + 15 + ahb { 16 + apb { 17 + pinctrl@fffff400 { 18 + atmel,mux-mask = < 19 + /* A B C */ 20 + 0xffffffff 0xffe0399f 0x00000000 /* pioA */ 21 + 0x00040000 0x00047e3f 0x00000000 /* pioB */ 22 + 0xfdffffff 0x00000000 0xb83fffff /* pioC */ 23 + 0x003fffff 0x003f8000 0x00000000 /* pioD */ 24 + >; 25 + }; 26 + }; 27 + }; 28 + };
+16
arch/arm/boot/dts/at91sam9g15ek.dts
··· 1 + /* 2 + * at91sam9g15ek.dts - Device Tree file for AT91SAM9G15-EK board 3 + * 4 + * Copyright (C) 2012 Atmel, 5 + * 2012 Nicolas Ferre <nicolas.ferre@atmel.com> 6 + * 7 + * Licensed under GPLv2 or later. 8 + */ 9 + /dts-v1/; 10 + /include/ "at91sam9g15.dtsi" 11 + /include/ "at91sam9x5ek.dtsi" 12 + 13 + / { 14 + model = "Atmel AT91SAM9G25-EK"; 15 + compatible = "atmel,at91sam9g15ek", "atmel,at91sam9x5ek", "atmel,at91sam9x5", "atmel,at91sam9"; 16 + };
+6
arch/arm/boot/dts/at91sam9g20ek_common.dtsi
··· 35 35 }; 36 36 37 37 usart0: serial@fffb0000 { 38 + pinctrl-0 = 39 + <&pinctrl_uart0 40 + &pinctrl_uart0_rts_cts 41 + &pinctrl_uart0_dtr_dsr 42 + &pinctrl_uart0_dcd 43 + &pinctrl_uart0_ri>; 38 44 status = "okay"; 39 45 }; 40 46
+28
arch/arm/boot/dts/at91sam9g25.dtsi
··· 1 + /* 2 + * at91sam9g25.dtsi - Device Tree Include file for AT91SAM9G25 SoC 3 + * 4 + * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> 5 + * 6 + * Licensed under GPLv2. 7 + */ 8 + 9 + /include/ "at91sam9x5.dtsi" 10 + 11 + / { 12 + model = "Atmel AT91SAM9G25 SoC"; 13 + compatible = "atmel, at91sam9g25, atmel,at91sam9x5"; 14 + 15 + ahb { 16 + apb { 17 + pinctrl@fffff400 { 18 + atmel,mux-mask = < 19 + /* A B C */ 20 + 0xffffffff 0xffe0399f 0xc000001c /* pioA */ 21 + 0x0007ffff 0x8000fe3f 0x00000000 /* pioB */ 22 + 0x80000000 0x07c0ffff 0xb83fffff /* pioC */ 23 + 0x003fffff 0x003f8000 0x00000000 /* pioD */ 24 + >; 25 + }; 26 + }; 27 + }; 28 + };
+2 -47
arch/arm/boot/dts/at91sam9g25ek.dts
··· 7 7 * Licensed under GPLv2 or later. 8 8 */ 9 9 /dts-v1/; 10 - /include/ "at91sam9x5.dtsi" 11 - /include/ "at91sam9x5cm.dtsi" 10 + /include/ "at91sam9g25.dtsi" 11 + /include/ "at91sam9x5ek.dtsi" 12 12 13 13 / { 14 14 model = "Atmel AT91SAM9G25-EK"; 15 15 compatible = "atmel,at91sam9g25ek", "atmel,at91sam9x5ek", "atmel,at91sam9x5", "atmel,at91sam9"; 16 - 17 - chosen { 18 - bootargs = "console=ttyS0,115200 root=/dev/mtdblock1 rw rootfstype=ubifs ubi.mtd=1 root=ubi0:rootfs"; 19 - }; 20 - 21 - ahb { 22 - apb { 23 - dbgu: serial@fffff200 { 24 - status = "okay"; 25 - }; 26 - 27 - usart0: serial@f801c000 { 28 - status = "okay"; 29 - }; 30 - 31 - macb0: ethernet@f802c000 { 32 - phy-mode = "rmii"; 33 - status = "okay"; 34 - }; 35 - 36 - i2c0: i2c@f8010000 { 37 - status = "okay"; 38 - }; 39 - 40 - i2c1: i2c@f8014000 { 41 - status = "okay"; 42 - }; 43 - 44 - i2c2: i2c@f8018000 { 45 - status = "okay"; 46 - }; 47 - }; 48 - 49 - usb0: ohci@00600000 { 50 - status = "okay"; 51 - num-ports = <2>; 52 - atmel,vbus-gpio = <&pioD 19 1 53 - &pioD 20 1 54 - >; 55 - }; 56 - 57 - usb1: ehci@00700000 { 58 - status = "okay"; 59 - }; 60 - }; 61 16 };
+28
arch/arm/boot/dts/at91sam9g35.dtsi
··· 1 + /* 2 + * at91sam9g35.dtsi - Device Tree Include file for AT91SAM9G35 SoC 3 + * 4 + * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> 5 + * 6 + * Licensed under GPLv2. 7 + */ 8 + 9 + /include/ "at91sam9x5.dtsi" 10 + 11 + / { 12 + model = "Atmel AT91SAM9G35 SoC"; 13 + compatible = "atmel, at91sam9g35, atmel,at91sam9x5"; 14 + 15 + ahb { 16 + apb { 17 + pinctrl@fffff400 { 18 + atmel,mux-mask = < 19 + /* A B C */ 20 + 0xffffffff 0xffe0399f 0xc000000c /* pioA */ 21 + 0x000406ff 0x00047e3f 0x00000000 /* pioB */ 22 + 0xfdffffff 0x00000000 0xb83fffff /* pioC */ 23 + 0x003fffff 0x003f8000 0x00000000 /* pioD */ 24 + >; 25 + }; 26 + }; 27 + }; 28 + };
+16
arch/arm/boot/dts/at91sam9g35ek.dts
··· 1 + /* 2 + * at91sam9g35ek.dts - Device Tree file for AT91SAM9G35-EK board 3 + * 4 + * Copyright (C) 2012 Atmel, 5 + * 2012 Nicolas Ferre <nicolas.ferre@atmel.com> 6 + * 7 + * Licensed under GPLv2 or later. 8 + */ 9 + /dts-v1/; 10 + /include/ "at91sam9g35.dtsi" 11 + /include/ "at91sam9x5ek.dtsi" 12 + 13 + / { 14 + model = "Atmel AT91SAM9G35-EK"; 15 + compatible = "atmel,at91sam9g35ek", "atmel,at91sam9x5ek", "atmel,at91sam9x5", "atmel,at91sam9"; 16 + };
+145 -44
arch/arm/boot/dts/at91sam9g45.dtsi
··· 108 108 interrupts = <21 4 0>; 109 109 }; 110 110 111 - pioA: gpio@fffff200 { 112 - compatible = "atmel,at91rm9200-gpio"; 113 - reg = <0xfffff200 0x100>; 114 - interrupts = <2 4 1>; 115 - #gpio-cells = <2>; 116 - gpio-controller; 117 - interrupt-controller; 118 - #interrupt-cells = <2>; 119 - }; 111 + pinctrl@fffff200 { 112 + #address-cells = <1>; 113 + #size-cells = <1>; 114 + compatible = "atmel,at91rm9200-pinctrl", "simple-bus"; 115 + ranges = <0xfffff200 0xfffff200 0xa00>; 120 116 121 - pioB: gpio@fffff400 { 122 - compatible = "atmel,at91rm9200-gpio"; 123 - reg = <0xfffff400 0x100>; 124 - interrupts = <3 4 1>; 125 - #gpio-cells = <2>; 126 - gpio-controller; 127 - interrupt-controller; 128 - #interrupt-cells = <2>; 129 - }; 117 + atmel,mux-mask = < 118 + /* A B */ 119 + 0xffffffff 0xffc003ff /* pioA */ 120 + 0xffffffff 0x800f8f00 /* pioB */ 121 + 0xffffffff 0x00000e00 /* pioC */ 122 + 0xffffffff 0xff0c1381 /* pioD */ 123 + 0xffffffff 0x81ffff81 /* pioE */ 124 + >; 130 125 131 - pioC: gpio@fffff600 { 132 - compatible = "atmel,at91rm9200-gpio"; 133 - reg = <0xfffff600 0x100>; 134 - interrupts = <4 4 1>; 135 - #gpio-cells = <2>; 136 - gpio-controller; 137 - interrupt-controller; 138 - #interrupt-cells = <2>; 139 - }; 126 + /* shared pinctrl settings */ 127 + dbgu { 128 + pinctrl_dbgu: dbgu-0 { 129 + atmel,pins = 130 + <1 12 0x1 0x0 /* PB12 periph A */ 131 + 1 13 0x1 0x0>; /* PB13 periph A */ 132 + }; 133 + }; 140 134 141 - pioD: gpio@fffff800 { 142 - compatible = "atmel,at91rm9200-gpio"; 143 - reg = <0xfffff800 0x100>; 144 - interrupts = <5 4 1>; 145 - #gpio-cells = <2>; 146 - gpio-controller; 147 - interrupt-controller; 148 - #interrupt-cells = <2>; 149 - }; 135 + uart0 { 136 + pinctrl_uart0: uart0-0 { 137 + atmel,pins = 138 + <1 19 0x1 0x1 /* PB19 periph A with pullup */ 139 + 1 18 0x1 0x0>; /* PB18 periph A */ 140 + }; 150 141 151 - pioE: gpio@fffffa00 { 152 - compatible = "atmel,at91rm9200-gpio"; 153 - reg = <0xfffffa00 0x100>; 154 - interrupts = <5 4 1>; 155 - #gpio-cells = <2>; 156 - gpio-controller; 157 - interrupt-controller; 158 - #interrupt-cells = <2>; 142 + pinctrl_uart0_rts_cts: uart0_rts_cts-0 { 143 + atmel,pins = 144 + <1 17 0x2 0x0 /* PB17 periph B */ 145 + 1 15 0x2 0x0>; /* PB15 periph B */ 146 + }; 147 + }; 148 + 149 + uart1 { 150 + pinctrl_uart1: uart1-0 { 151 + atmel,pins = 152 + <1 4 0x1 0x1 /* PB4 periph A with pullup */ 153 + 1 5 0x1 0x0>; /* PB5 periph A */ 154 + }; 155 + 156 + pinctrl_uart1_rts_cts: uart1_rts_cts-0 { 157 + atmel,pins = 158 + <3 16 0x1 0x0 /* PD16 periph A */ 159 + 3 17 0x1 0x0>; /* PD17 periph A */ 160 + }; 161 + }; 162 + 163 + uart2 { 164 + pinctrl_uart2: uart2-0 { 165 + atmel,pins = 166 + <1 6 0x1 0x1 /* PB6 periph A with pullup */ 167 + 1 7 0x1 0x0>; /* PB7 periph A */ 168 + }; 169 + 170 + pinctrl_uart2_rts_cts: uart2_rts_cts-0 { 171 + atmel,pins = 172 + <2 9 0x2 0x0 /* PC9 periph B */ 173 + 2 11 0x2 0x0>; /* PC11 periph B */ 174 + }; 175 + }; 176 + 177 + uart3 { 178 + pinctrl_uart3: uart3-0 { 179 + atmel,pins = 180 + <1 8 0x1 0x1 /* PB9 periph A with pullup */ 181 + 1 9 0x1 0x0>; /* PB8 periph A */ 182 + }; 183 + 184 + pinctrl_uart3_rts_cts: uart3_rts_cts-0 { 185 + atmel,pins = 186 + <0 23 0x2 0x0 /* PA23 periph B */ 187 + 0 24 0x2 0x0>; /* PA24 periph B */ 188 + }; 189 + }; 190 + 191 + nand { 192 + pinctrl_nand: nand-0 { 193 + atmel,pins = 194 + <2 8 0x0 0x1 /* PC8 gpio RDY pin pull_up*/ 195 + 2 14 0x0 0x1>; /* PC14 gpio enable pin pull_up */ 196 + }; 197 + }; 198 + 199 + pioA: gpio@fffff200 { 200 + compatible = "atmel,at91rm9200-gpio"; 201 + reg = <0xfffff200 0x200>; 202 + interrupts = <2 4 1>; 203 + #gpio-cells = <2>; 204 + gpio-controller; 205 + interrupt-controller; 206 + #interrupt-cells = <2>; 207 + }; 208 + 209 + pioB: gpio@fffff400 { 210 + compatible = "atmel,at91rm9200-gpio"; 211 + reg = <0xfffff400 0x200>; 212 + interrupts = <3 4 1>; 213 + #gpio-cells = <2>; 214 + gpio-controller; 215 + interrupt-controller; 216 + #interrupt-cells = <2>; 217 + }; 218 + 219 + pioC: gpio@fffff600 { 220 + compatible = "atmel,at91rm9200-gpio"; 221 + reg = <0xfffff600 0x200>; 222 + interrupts = <4 4 1>; 223 + #gpio-cells = <2>; 224 + gpio-controller; 225 + interrupt-controller; 226 + #interrupt-cells = <2>; 227 + }; 228 + 229 + pioD: gpio@fffff800 { 230 + compatible = "atmel,at91rm9200-gpio"; 231 + reg = <0xfffff800 0x200>; 232 + interrupts = <5 4 1>; 233 + #gpio-cells = <2>; 234 + gpio-controller; 235 + interrupt-controller; 236 + #interrupt-cells = <2>; 237 + }; 238 + 239 + pioE: gpio@fffffa00 { 240 + compatible = "atmel,at91rm9200-gpio"; 241 + reg = <0xfffffa00 0x200>; 242 + interrupts = <5 4 1>; 243 + #gpio-cells = <2>; 244 + gpio-controller; 245 + interrupt-controller; 246 + #interrupt-cells = <2>; 247 + }; 159 248 }; 160 249 161 250 dbgu: serial@ffffee00 { 162 251 compatible = "atmel,at91sam9260-usart"; 163 252 reg = <0xffffee00 0x200>; 164 253 interrupts = <1 4 7>; 254 + pinctrl-names = "default"; 255 + pinctrl-0 = <&pinctrl_dbgu>; 165 256 status = "disabled"; 166 257 }; 167 258 ··· 262 171 interrupts = <7 4 5>; 263 172 atmel,use-dma-rx; 264 173 atmel,use-dma-tx; 174 + pinctrl-names = "default"; 175 + pinctrl-0 = <&pinctrl_uart0>; 265 176 status = "disabled"; 266 177 }; 267 178 ··· 273 180 interrupts = <8 4 5>; 274 181 atmel,use-dma-rx; 275 182 atmel,use-dma-tx; 183 + pinctrl-names = "default"; 184 + pinctrl-0 = <&pinctrl_uart1>; 276 185 status = "disabled"; 277 186 }; 278 187 ··· 284 189 interrupts = <9 4 5>; 285 190 atmel,use-dma-rx; 286 191 atmel,use-dma-tx; 192 + pinctrl-names = "default"; 193 + pinctrl-0 = <&pinctrl_uart2>; 287 194 status = "disabled"; 288 195 }; 289 196 ··· 295 198 interrupts = <10 4 5>; 296 199 atmel,use-dma-rx; 297 200 atmel,use-dma-tx; 201 + pinctrl-names = "default"; 202 + pinctrl-0 = <&pinctrl_uart3>; 298 203 status = "disabled"; 299 204 }; 300 205 ··· 372 273 >; 373 274 atmel,nand-addr-offset = <21>; 374 275 atmel,nand-cmd-offset = <22>; 276 + pinctrl-names = "default"; 277 + pinctrl-0 = <&pinctrl_nand>; 375 278 gpios = <&pioC 8 0 376 279 &pioC 14 0 377 280 0
+1
arch/arm/boot/dts/at91sam9m10g45ek.dts
··· 39 39 }; 40 40 41 41 usart1: serial@fff90000 { 42 + pinctrl-0 = <&pinctrl_uart0 &pinctrl_uart1_rts_cts>; 42 43 status = "okay"; 43 44 }; 44 45
+145 -35
arch/arm/boot/dts/at91sam9n12.dtsi
··· 102 102 interrupts = <20 4 0>; 103 103 }; 104 104 105 - pioA: gpio@fffff400 { 106 - compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio"; 107 - reg = <0xfffff400 0x100>; 108 - interrupts = <2 4 1>; 109 - #gpio-cells = <2>; 110 - gpio-controller; 111 - interrupt-controller; 112 - #interrupt-cells = <2>; 113 - }; 105 + pinctrl@fffff400 { 106 + #address-cells = <1>; 107 + #size-cells = <1>; 108 + compatible = "atmel,at91sam9x5-pinctrl", "atmel,at91rm9200-pinctrl", "simple-bus"; 109 + ranges = <0xfffff400 0xfffff400 0x800>; 114 110 115 - pioB: gpio@fffff600 { 116 - compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio"; 117 - reg = <0xfffff600 0x100>; 118 - interrupts = <2 4 1>; 119 - #gpio-cells = <2>; 120 - gpio-controller; 121 - interrupt-controller; 122 - #interrupt-cells = <2>; 123 - }; 111 + atmel,mux-mask = < 112 + /* A B C */ 113 + 0xffffffff 0xffe07983 0x00000000 /* pioA */ 114 + 0x00040000 0x00047e0f 0x00000000 /* pioB */ 115 + 0xfdffffff 0x07c00000 0xb83fffff /* pioC */ 116 + 0x003fffff 0x003f8000 0x00000000 /* pioD */ 117 + >; 124 118 125 - pioC: gpio@fffff800 { 126 - compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio"; 127 - reg = <0xfffff800 0x100>; 128 - interrupts = <3 4 1>; 129 - #gpio-cells = <2>; 130 - gpio-controller; 131 - interrupt-controller; 132 - #interrupt-cells = <2>; 133 - }; 119 + /* shared pinctrl settings */ 120 + dbgu { 121 + pinctrl_dbgu: dbgu-0 { 122 + atmel,pins = 123 + <0 9 0x1 0x0 /* PA9 periph A */ 124 + 0 10 0x1 0x1>; /* PA10 periph with pullup */ 125 + }; 126 + }; 134 127 135 - pioD: gpio@fffffa00 { 136 - compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio"; 137 - reg = <0xfffffa00 0x100>; 138 - interrupts = <3 4 1>; 139 - #gpio-cells = <2>; 140 - gpio-controller; 141 - interrupt-controller; 142 - #interrupt-cells = <2>; 128 + uart0 { 129 + pinctrl_uart0: uart0-0 { 130 + atmel,pins = 131 + <0 1 0x1 0x1 /* PA1 periph A with pullup */ 132 + 0 0 0x1 0x0>; /* PA0 periph A */ 133 + }; 134 + 135 + pinctrl_uart0_rts_cts: uart0_rts_cts-0 { 136 + atmel,pins = 137 + <0 2 0x1 0x0 /* PA2 periph A */ 138 + 0 3 0x1 0x0>; /* PA3 periph A */ 139 + }; 140 + }; 141 + 142 + uart1 { 143 + pinctrl_uart1: uart1-0 { 144 + atmel,pins = 145 + <0 6 0x1 0x1 /* PA6 periph A with pullup */ 146 + 0 5 0x1 0x0>; /* PA5 periph A */ 147 + }; 148 + }; 149 + 150 + uart2 { 151 + pinctrl_uart2: uart2-0 { 152 + atmel,pins = 153 + <0 8 0x1 0x1 /* PA8 periph A with pullup */ 154 + 0 7 0x1 0x0>; /* PA7 periph A */ 155 + }; 156 + 157 + pinctrl_uart2_rts_cts: uart2_rts_cts-0 { 158 + atmel,pins = 159 + <1 0 0x2 0x0 /* PB0 periph B */ 160 + 1 1 0x2 0x0>; /* PB1 periph B */ 161 + }; 162 + }; 163 + 164 + uart3 { 165 + pinctrl_uart3: uart3-0 { 166 + atmel,pins = 167 + <2 23 0x2 0x1 /* PC23 periph B with pullup */ 168 + 2 22 0x2 0x0>; /* PC22 periph B */ 169 + }; 170 + 171 + pinctrl_uart3_rts_cts: uart3_rts_cts-0 { 172 + atmel,pins = 173 + <2 24 0x2 0x0 /* PC24 periph B */ 174 + 2 25 0x2 0x0>; /* PC25 periph B */ 175 + }; 176 + }; 177 + 178 + usart0 { 179 + pinctrl_usart0: usart0-0 { 180 + atmel,pins = 181 + <2 9 0x3 0x1 /* PC9 periph C with pullup */ 182 + 2 8 0x3 0x0>; /* PC8 periph C */ 183 + }; 184 + }; 185 + 186 + usart1 { 187 + pinctrl_usart1: usart1-0 { 188 + atmel,pins = 189 + <2 16 0x3 0x1 /* PC17 periph C with pullup */ 190 + 2 17 0x3 0x0>; /* PC16 periph C */ 191 + }; 192 + }; 193 + 194 + nand { 195 + pinctrl_nand: nand-0 { 196 + atmel,pins = 197 + <3 5 0x0 0x1 /* PD5 gpio RDY pin pull_up*/ 198 + 3 4 0x0 0x1>; /* PD4 gpio enable pin pull_up */ 199 + }; 200 + }; 201 + 202 + pioA: gpio@fffff400 { 203 + compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio"; 204 + reg = <0xfffff400 0x200>; 205 + interrupts = <2 4 1>; 206 + #gpio-cells = <2>; 207 + gpio-controller; 208 + interrupt-controller; 209 + #interrupt-cells = <2>; 210 + }; 211 + 212 + pioB: gpio@fffff600 { 213 + compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio"; 214 + reg = <0xfffff600 0x200>; 215 + interrupts = <2 4 1>; 216 + #gpio-cells = <2>; 217 + gpio-controller; 218 + interrupt-controller; 219 + #interrupt-cells = <2>; 220 + }; 221 + 222 + pioC: gpio@fffff800 { 223 + compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio"; 224 + reg = <0xfffff800 0x200>; 225 + interrupts = <3 4 1>; 226 + #gpio-cells = <2>; 227 + gpio-controller; 228 + interrupt-controller; 229 + #interrupt-cells = <2>; 230 + }; 231 + 232 + pioD: gpio@fffffa00 { 233 + compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio"; 234 + reg = <0xfffffa00 0x200>; 235 + interrupts = <3 4 1>; 236 + #gpio-cells = <2>; 237 + gpio-controller; 238 + interrupt-controller; 239 + #interrupt-cells = <2>; 240 + }; 143 241 }; 144 242 145 243 dbgu: serial@fffff200 { 146 244 compatible = "atmel,at91sam9260-usart"; 147 245 reg = <0xfffff200 0x200>; 148 246 interrupts = <1 4 7>; 247 + pinctrl-names = "default"; 248 + pinctrl-0 = <&pinctrl_dbgu>; 149 249 status = "disabled"; 150 250 }; 151 251 ··· 255 155 interrupts = <5 4 5>; 256 156 atmel,use-dma-rx; 257 157 atmel,use-dma-tx; 158 + pinctrl-names = "default"; 159 + pinctrl-0 = <&pinctrl_uart0>; 258 160 status = "disabled"; 259 161 }; 260 162 ··· 266 164 interrupts = <6 4 5>; 267 165 atmel,use-dma-rx; 268 166 atmel,use-dma-tx; 167 + pinctrl-names = "default"; 168 + pinctrl-0 = <&pinctrl_uart1>; 269 169 status = "disabled"; 270 170 }; 271 171 ··· 277 173 interrupts = <7 4 5>; 278 174 atmel,use-dma-rx; 279 175 atmel,use-dma-tx; 176 + pinctrl-names = "default"; 177 + pinctrl-0 = <&pinctrl_uart2>; 280 178 status = "disabled"; 281 179 }; 282 180 ··· 288 182 interrupts = <8 4 5>; 289 183 atmel,use-dma-rx; 290 184 atmel,use-dma-tx; 185 + pinctrl-names = "default"; 186 + pinctrl-0 = <&pinctrl_uart3>; 291 187 status = "disabled"; 292 188 }; 293 189 ··· 323 215 >; 324 216 atmel,nand-addr-offset = <21>; 325 217 atmel,nand-cmd-offset = <22>; 218 + pinctrl-names = "default"; 219 + pinctrl-0 = <&pinctrl_nand>; 326 220 gpios = <&pioD 5 0 327 221 &pioD 4 0 328 222 0
+28
arch/arm/boot/dts/at91sam9x25.dtsi
··· 1 + /* 2 + * at91sam9x25.dtsi - Device Tree Include file for AT91SAM9X25 SoC 3 + * 4 + * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> 5 + * 6 + * Licensed under GPLv2. 7 + */ 8 + 9 + /include/ "at91sam9x5.dtsi" 10 + 11 + / { 12 + model = "Atmel AT91SAM9X25 SoC"; 13 + compatible = "atmel, at91sam9x25, atmel,at91sam9x5"; 14 + 15 + ahb { 16 + apb { 17 + pinctrl@fffff400 { 18 + atmel,mux-mask = < 19 + /* A B C */ 20 + 0xffffffff 0xffe03fff 0xc000001c /* pioA */ 21 + 0x0007ffff 0x00047e3f 0x00000000 /* pioB */ 22 + 0x80000000 0xfffd0000 0xb83fffff /* pioC */ 23 + 0x003fffff 0x003f8000 0x00000000 /* pioD */ 24 + >; 25 + }; 26 + }; 27 + }; 28 + };
+16
arch/arm/boot/dts/at91sam9x25ek.dts
··· 1 + /* 2 + * at91sam9x25ek.dts - Device Tree file for AT91SAM9X25-EK board 3 + * 4 + * Copyright (C) 2012 Atmel, 5 + * 2012 Nicolas Ferre <nicolas.ferre@atmel.com> 6 + * 7 + * Licensed under GPLv2 or later. 8 + */ 9 + /dts-v1/; 10 + /include/ "at91sam9x25.dtsi" 11 + /include/ "at91sam9x5ek.dtsi" 12 + 13 + / { 14 + model = "Atmel AT91SAM9G25-EK"; 15 + compatible = "atmel,at91sam9x25ek", "atmel,at91sam9x5ek", "atmel,at91sam9x5", "atmel,at91sam9"; 16 + };
+28
arch/arm/boot/dts/at91sam9x35.dtsi
··· 1 + /* 2 + * at91sam9x35.dtsi - Device Tree Include file for AT91SAM9X35 SoC 3 + * 4 + * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> 5 + * 6 + * Licensed under GPLv2. 7 + */ 8 + 9 + /include/ "at91sam9x5.dtsi" 10 + 11 + / { 12 + model = "Atmel AT91SAM9X35 SoC"; 13 + compatible = "atmel, at91sam9x35, atmel,at91sam9x5"; 14 + 15 + ahb { 16 + apb { 17 + pinctrl@fffff400 { 18 + atmel,mux-mask = < 19 + /* A B C */ 20 + 0xffffffff 0xffe03fff 0xc000000c /* pioA */ 21 + 0x000406ff 0x00047e3f 0x00000000 /* pioB */ 22 + 0xfdffffff 0x00000000 0xb83fffff /* pioC */ 23 + 0x003fffff 0x003f8000 0x00000000 /* pioD */ 24 + >; 25 + }; 26 + }; 27 + }; 28 + };
+16
arch/arm/boot/dts/at91sam9x35ek.dts
··· 1 + /* 2 + * at91sam9x35ek.dts - Device Tree file for AT91SAM9X35-EK board 3 + * 4 + * Copyright (C) 2012 Atmel, 5 + * 2012 Nicolas Ferre <nicolas.ferre@atmel.com> 6 + * 7 + * Licensed under GPLv2 or later. 8 + */ 9 + /dts-v1/; 10 + /include/ "at91sam9x35.dtsi" 11 + /include/ "at91sam9x5ek.dtsi" 12 + 13 + / { 14 + model = "Atmel AT91SAM9X35-EK"; 15 + compatible = "atmel,at91sam9x35ek", "atmel,at91sam9x5ek", "atmel,at91sam9x5", "atmel,at91sam9"; 16 + };
+143 -35
arch/arm/boot/dts/at91sam9x5.dtsi
··· 111 111 interrupts = <21 4 0>; 112 112 }; 113 113 114 - pioA: gpio@fffff400 { 115 - compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio"; 116 - reg = <0xfffff400 0x100>; 117 - interrupts = <2 4 1>; 118 - #gpio-cells = <2>; 119 - gpio-controller; 120 - interrupt-controller; 121 - #interrupt-cells = <2>; 122 - }; 114 + pinctrl@fffff400 { 115 + #address-cells = <1>; 116 + #size-cells = <1>; 117 + compatible = "atmel,at91sam9x5-pinctrl", "atmel,at91rm9200-pinctrl", "simple-bus"; 118 + ranges = <0xfffff400 0xfffff400 0x800>; 123 119 124 - pioB: gpio@fffff600 { 125 - compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio"; 126 - reg = <0xfffff600 0x100>; 127 - interrupts = <2 4 1>; 128 - #gpio-cells = <2>; 129 - gpio-controller; 130 - interrupt-controller; 131 - #interrupt-cells = <2>; 132 - }; 120 + /* shared pinctrl settings */ 121 + dbgu { 122 + pinctrl_dbgu: dbgu-0 { 123 + atmel,pins = 124 + <0 9 0x1 0x0 /* PA9 periph A */ 125 + 0 10 0x1 0x1>; /* PA10 periph A with pullup */ 126 + }; 127 + }; 133 128 134 - pioC: gpio@fffff800 { 135 - compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio"; 136 - reg = <0xfffff800 0x100>; 137 - interrupts = <3 4 1>; 138 - #gpio-cells = <2>; 139 - gpio-controller; 140 - interrupt-controller; 141 - #interrupt-cells = <2>; 142 - }; 129 + uart0 { 130 + pinctrl_uart0: uart0-0 { 131 + atmel,pins = 132 + <0 0 0x1 0x1 /* PA0 periph A with pullup */ 133 + 0 1 0x1 0x0>; /* PA1 periph A */ 134 + }; 143 135 144 - pioD: gpio@fffffa00 { 145 - compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio"; 146 - reg = <0xfffffa00 0x100>; 147 - interrupts = <3 4 1>; 148 - #gpio-cells = <2>; 149 - gpio-controller; 150 - interrupt-controller; 151 - #interrupt-cells = <2>; 136 + pinctrl_uart0_rts_cts: uart0_rts_cts-0 { 137 + atmel,pins = 138 + <0 2 0x1 0x0 /* PA2 periph A */ 139 + 0 3 0x1 0x0>; /* PA3 periph A */ 140 + }; 141 + }; 142 + 143 + uart1 { 144 + pinctrl_uart1: uart1-0 { 145 + atmel,pins = 146 + <0 5 0x1 0x1 /* PA5 periph A with pullup */ 147 + 0 6 0x1 0x0>; /* PA6 periph A */ 148 + }; 149 + 150 + pinctrl_uart1_rts_cts: uart1_rts_cts-0 { 151 + atmel,pins = 152 + <3 27 0x3 0x0 /* PC27 periph C */ 153 + 3 28 0x3 0x0>; /* PC28 periph C */ 154 + }; 155 + }; 156 + 157 + uart2 { 158 + pinctrl_uart2: uart2-0 { 159 + atmel,pins = 160 + <0 7 0x1 0x1 /* PA7 periph A with pullup */ 161 + 0 8 0x1 0x0>; /* PA8 periph A */ 162 + }; 163 + 164 + pinctrl_uart2_rts_cts: uart2_rts_cts-0 { 165 + atmel,pins = 166 + <0 0 0x2 0x0 /* PB0 periph B */ 167 + 0 1 0x2 0x0>; /* PB1 periph B */ 168 + }; 169 + }; 170 + 171 + uart3 { 172 + pinctrl_uart3: uart3-0 { 173 + atmel,pins = 174 + <3 23 0x2 0x1 /* PC22 periph B with pullup */ 175 + 3 23 0x2 0x0>; /* PC23 periph B */ 176 + }; 177 + 178 + pinctrl_uart3_rts_cts: uart3_rts_cts-0 { 179 + atmel,pins = 180 + <3 24 0x2 0x0 /* PC24 periph B */ 181 + 3 25 0x2 0x0>; /* PC25 periph B */ 182 + }; 183 + }; 184 + 185 + usart0 { 186 + pinctrl_usart0: usart0-0 { 187 + atmel,pins = 188 + <3 8 0x3 0x0 /* PC8 periph C */ 189 + 3 9 0x3 0x1>; /* PC9 periph C with pullup */ 190 + }; 191 + }; 192 + 193 + usart1 { 194 + pinctrl_usart1: usart1-0 { 195 + atmel,pins = 196 + <3 16 0x3 0x0 /* PC16 periph C */ 197 + 3 17 0x3 0x1>; /* PC17 periph C with pullup */ 198 + }; 199 + }; 200 + 201 + nand { 202 + pinctrl_nand: nand-0 { 203 + atmel,pins = 204 + <3 4 0x0 0x1 /* PD5 gpio RDY pin pull_up */ 205 + 3 5 0x0 0x1>; /* PD4 gpio enable pin pull_up */ 206 + }; 207 + }; 208 + 209 + pioA: gpio@fffff400 { 210 + compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio"; 211 + reg = <0xfffff400 0x200>; 212 + interrupts = <2 4 1>; 213 + #gpio-cells = <2>; 214 + gpio-controller; 215 + interrupt-controller; 216 + #interrupt-cells = <2>; 217 + }; 218 + 219 + pioB: gpio@fffff600 { 220 + compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio"; 221 + reg = <0xfffff600 0x200>; 222 + interrupts = <2 4 1>; 223 + #gpio-cells = <2>; 224 + gpio-controller; 225 + #gpio-lines = <19>; 226 + interrupt-controller; 227 + #interrupt-cells = <2>; 228 + }; 229 + 230 + pioC: gpio@fffff800 { 231 + compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio"; 232 + reg = <0xfffff800 0x200>; 233 + interrupts = <3 4 1>; 234 + #gpio-cells = <2>; 235 + gpio-controller; 236 + interrupt-controller; 237 + #interrupt-cells = <2>; 238 + }; 239 + 240 + pioD: gpio@fffffa00 { 241 + compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio"; 242 + reg = <0xfffffa00 0x200>; 243 + interrupts = <3 4 1>; 244 + #gpio-cells = <2>; 245 + gpio-controller; 246 + #gpio-lines = <22>; 247 + interrupt-controller; 248 + #interrupt-cells = <2>; 249 + }; 152 250 }; 153 251 154 252 dbgu: serial@fffff200 { 155 253 compatible = "atmel,at91sam9260-usart"; 156 254 reg = <0xfffff200 0x200>; 157 255 interrupts = <1 4 7>; 256 + pinctrl-names = "default"; 257 + pinctrl-0 = <&pinctrl_dbgu>; 158 258 status = "disabled"; 159 259 }; 160 260 ··· 264 164 interrupts = <5 4 5>; 265 165 atmel,use-dma-rx; 266 166 atmel,use-dma-tx; 167 + pinctrl-names = "default"; 168 + pinctrl-0 = <&pinctrl_uart0>; 267 169 status = "disabled"; 268 170 }; 269 171 ··· 275 173 interrupts = <6 4 5>; 276 174 atmel,use-dma-rx; 277 175 atmel,use-dma-tx; 176 + pinctrl-names = "default"; 177 + pinctrl-0 = <&pinctrl_uart1>; 278 178 status = "disabled"; 279 179 }; 280 180 ··· 286 182 interrupts = <7 4 5>; 287 183 atmel,use-dma-rx; 288 184 atmel,use-dma-tx; 185 + pinctrl-names = "default"; 186 + pinctrl-0 = <&pinctrl_uart2>; 289 187 status = "disabled"; 290 188 }; 291 189 ··· 379 273 >; 380 274 atmel,nand-addr-offset = <21>; 381 275 atmel,nand-cmd-offset = <22>; 276 + pinctrl-names = "default"; 277 + pinctrl-0 = <&pinctrl_nand>; 382 278 gpios = <&pioD 5 0 383 279 &pioD 4 0 384 280 0
+59
arch/arm/boot/dts/at91sam9x5ek.dtsi
··· 1 + /* 2 + * at91sam9x5ek.dtsi - Device Tree file for AT91SAM9x5CM Base board 3 + * 4 + * Copyright (C) 2012 Atmel, 5 + * 2012 Nicolas Ferre <nicolas.ferre@atmel.com> 6 + * 7 + * Licensed under GPLv2 or later. 8 + */ 9 + /include/ "at91sam9x5cm.dtsi" 10 + 11 + / { 12 + model = "Atmel AT91SAM9X5-EK"; 13 + compatible = "atmel,at91sam9x5ek", "atmel,at91sam9x5", "atmel,at91sam9"; 14 + 15 + chosen { 16 + bootargs = "128M console=ttyS0,115200 root=/dev/mtdblock1 rw rootfstype=ubifs ubi.mtd=1 root=ubi0:rootfs"; 17 + }; 18 + 19 + ahb { 20 + apb { 21 + dbgu: serial@fffff200 { 22 + status = "okay"; 23 + }; 24 + 25 + usart0: serial@f801c000 { 26 + status = "okay"; 27 + }; 28 + 29 + macb0: ethernet@f802c000 { 30 + phy-mode = "rmii"; 31 + status = "okay"; 32 + }; 33 + 34 + i2c0: i2c@f8010000 { 35 + status = "okay"; 36 + }; 37 + 38 + i2c1: i2c@f8014000 { 39 + status = "okay"; 40 + }; 41 + 42 + i2c2: i2c@f8018000 { 43 + status = "okay"; 44 + }; 45 + }; 46 + 47 + usb0: ohci@00600000 { 48 + status = "okay"; 49 + num-ports = <2>; 50 + atmel,vbus-gpio = <&pioD 19 1 51 + &pioD 20 1 52 + >; 53 + }; 54 + 55 + usb1: ehci@00700000 { 56 + status = "okay"; 57 + }; 58 + }; 59 + };
+1
arch/arm/configs/at91_dt_defconfig
··· 111 111 CONFIG_I2C_GPIO=y 112 112 CONFIG_SPI=y 113 113 CONFIG_SPI_ATMEL=y 114 + CONFIG_PINCTRL_AT91=y 114 115 # CONFIG_HWMON is not set 115 116 CONFIG_WATCHDOG=y 116 117 CONFIG_AT91SAM9X_WATCHDOG=y
+2 -2
arch/arm/mach-at91/at91rm9200.c
··· 361 361 0 /* Advanced Interrupt Controller (IRQ6) */ 362 362 }; 363 363 364 - struct at91_init_soc __initdata at91rm9200_soc = { 364 + AT91_SOC_START(rm9200) 365 365 .map_io = at91rm9200_map_io, 366 366 .default_irq_priority = at91rm9200_default_irq_priority, 367 367 .ioremap_registers = at91rm9200_ioremap_registers, 368 368 .register_clocks = at91rm9200_register_clocks, 369 369 .init = at91rm9200_initialize, 370 - }; 370 + AT91_SOC_END
+5 -2
arch/arm/mach-at91/at91sam9260.c
··· 235 235 CLKDEV_CON_ID("pioA", &pioA_clk), 236 236 CLKDEV_CON_ID("pioB", &pioB_clk), 237 237 CLKDEV_CON_ID("pioC", &pioC_clk), 238 + CLKDEV_CON_DEV_ID(NULL, "fffff400.gpio", &pioA_clk), 239 + CLKDEV_CON_DEV_ID(NULL, "fffff600.gpio", &pioB_clk), 240 + CLKDEV_CON_DEV_ID(NULL, "fffff800.gpio", &pioC_clk), 238 241 }; 239 242 240 243 static struct clk_lookup usart_clocks_lookups[] = { ··· 393 390 0, /* Advanced Interrupt Controller */ 394 391 }; 395 392 396 - struct at91_init_soc __initdata at91sam9260_soc = { 393 + AT91_SOC_START(sam9260) 397 394 .map_io = at91sam9260_map_io, 398 395 .default_irq_priority = at91sam9260_default_irq_priority, 399 396 .ioremap_registers = at91sam9260_ioremap_registers, 400 397 .register_clocks = at91sam9260_register_clocks, 401 398 .init = at91sam9260_initialize, 402 - }; 399 + AT91_SOC_END
+2 -2
arch/arm/mach-at91/at91sam9261.c
··· 334 334 0, /* Advanced Interrupt Controller */ 335 335 }; 336 336 337 - struct at91_init_soc __initdata at91sam9261_soc = { 337 + AT91_SOC_START(sam9261) 338 338 .map_io = at91sam9261_map_io, 339 339 .default_irq_priority = at91sam9261_default_irq_priority, 340 340 .ioremap_registers = at91sam9261_ioremap_registers, 341 341 .register_clocks = at91sam9261_register_clocks, 342 342 .init = at91sam9261_initialize, 343 - }; 343 + AT91_SOC_END
+7 -2
arch/arm/mach-at91/at91sam9263.c
··· 212 212 CLKDEV_CON_DEV_ID("spi_clk", "fffa4000.spi", &spi0_clk), 213 213 CLKDEV_CON_DEV_ID("spi_clk", "fffa8000.spi", &spi1_clk), 214 214 CLKDEV_CON_DEV_ID(NULL, "fff88000.i2c", &twi_clk), 215 + CLKDEV_CON_DEV_ID(NULL, "fffff200.gpio", &pioA_clk), 216 + CLKDEV_CON_DEV_ID(NULL, "fffff400.gpio", &pioB_clk), 217 + CLKDEV_CON_DEV_ID(NULL, "fffff600.gpio", &pioCDE_clk), 218 + CLKDEV_CON_DEV_ID(NULL, "fffff800.gpio", &pioCDE_clk), 219 + CLKDEV_CON_DEV_ID(NULL, "fffffa00.gpio", &pioCDE_clk), 215 220 }; 216 221 217 222 static struct clk_lookup usart_clocks_lookups[] = { ··· 370 365 0, /* Advanced Interrupt Controller (IRQ1) */ 371 366 }; 372 367 373 - struct at91_init_soc __initdata at91sam9263_soc = { 368 + AT91_SOC_START(sam9263) 374 369 .map_io = at91sam9263_map_io, 375 370 .default_irq_priority = at91sam9263_default_irq_priority, 376 371 .ioremap_registers = at91sam9263_ioremap_registers, 377 372 .register_clocks = at91sam9263_register_clocks, 378 373 .init = at91sam9263_initialize, 379 - }; 374 + AT91_SOC_END
+8 -2
arch/arm/mach-at91/at91sam9g45.c
··· 260 260 CLKDEV_CON_DEV_ID(NULL, "fff88000.i2c", &twi1_clk), 261 261 /* fake hclk clock */ 262 262 CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &uhphs_clk), 263 + CLKDEV_CON_DEV_ID(NULL, "fffff200.gpio", &pioA_clk), 264 + CLKDEV_CON_DEV_ID(NULL, "fffff400.gpio", &pioB_clk), 265 + CLKDEV_CON_DEV_ID(NULL, "fffff600.gpio", &pioC_clk), 266 + CLKDEV_CON_DEV_ID(NULL, "fffff800.gpio", &pioDE_clk), 267 + CLKDEV_CON_DEV_ID(NULL, "fffffa00.gpio", &pioDE_clk), 268 + 263 269 CLKDEV_CON_ID("pioA", &pioA_clk), 264 270 CLKDEV_CON_ID("pioB", &pioB_clk), 265 271 CLKDEV_CON_ID("pioC", &pioC_clk), ··· 415 409 0, /* Advanced Interrupt Controller (IRQ0) */ 416 410 }; 417 411 418 - struct at91_init_soc __initdata at91sam9g45_soc = { 412 + AT91_SOC_START(sam9g45) 419 413 .map_io = at91sam9g45_map_io, 420 414 .default_irq_priority = at91sam9g45_default_irq_priority, 421 415 .ioremap_registers = at91sam9g45_ioremap_registers, 422 416 .register_clocks = at91sam9g45_register_clocks, 423 417 .init = at91sam9g45_initialize, 424 - }; 418 + AT91_SOC_END
+6 -9
arch/arm/mach-at91/at91sam9n12.c
··· 171 171 CLKDEV_CON_DEV_ID("dma_clk", "ffffec00.dma-controller", &dma_clk), 172 172 CLKDEV_CON_DEV_ID(NULL, "f8010000.i2c", &twi0_clk), 173 173 CLKDEV_CON_DEV_ID(NULL, "f8014000.i2c", &twi1_clk), 174 - CLKDEV_CON_ID("pioA", &pioAB_clk), 175 - CLKDEV_CON_ID("pioB", &pioAB_clk), 176 - CLKDEV_CON_ID("pioC", &pioCD_clk), 177 - CLKDEV_CON_ID("pioD", &pioCD_clk), 174 + CLKDEV_CON_DEV_ID(NULL, "fffff400.gpio", &pioAB_clk), 175 + CLKDEV_CON_DEV_ID(NULL, "fffff600.gpio", &pioAB_clk), 176 + CLKDEV_CON_DEV_ID(NULL, "fffff800.gpio", &pioCD_clk), 177 + CLKDEV_CON_DEV_ID(NULL, "fffffa00.gpio", &pioCD_clk), 178 178 /* additional fake clock for macb_hclk */ 179 179 CLKDEV_CON_DEV_ID("hclk", "500000.ohci", &uhp_clk), 180 180 CLKDEV_CON_DEV_ID("ohci_clk", "500000.ohci", &uhp_clk), ··· 223 223 void __init at91sam9n12_initialize(void) 224 224 { 225 225 at91_extern_irq = (1 << AT91SAM9N12_ID_IRQ0); 226 - 227 - /* Register GPIO subsystem (using DT) */ 228 - at91_gpio_init(NULL, 0); 229 226 } 230 227 231 - struct at91_init_soc __initdata at91sam9n12_soc = { 228 + AT91_SOC_START(sam9n12) 232 229 .map_io = at91sam9n12_map_io, 233 230 .register_clocks = at91sam9n12_register_clocks, 234 231 .init = at91sam9n12_initialize, 235 - }; 232 + AT91_SOC_END
+2 -2
arch/arm/mach-at91/at91sam9rl.c
··· 338 338 0, /* Advanced Interrupt Controller */ 339 339 }; 340 340 341 - struct at91_init_soc __initdata at91sam9rl_soc = { 341 + AT91_SOC_START(sam9rl) 342 342 .map_io = at91sam9rl_map_io, 343 343 .default_irq_priority = at91sam9rl_default_irq_priority, 344 344 .ioremap_registers = at91sam9rl_ioremap_registers, 345 345 .register_clocks = at91sam9rl_register_clocks, 346 346 .init = at91sam9rl_initialize, 347 - }; 347 + AT91_SOC_END
+6 -13
arch/arm/mach-at91/at91sam9x5.c
··· 234 234 CLKDEV_CON_DEV_ID(NULL, "f8010000.i2c", &twi0_clk), 235 235 CLKDEV_CON_DEV_ID(NULL, "f8014000.i2c", &twi1_clk), 236 236 CLKDEV_CON_DEV_ID(NULL, "f8018000.i2c", &twi2_clk), 237 - CLKDEV_CON_ID("pioA", &pioAB_clk), 238 - CLKDEV_CON_ID("pioB", &pioAB_clk), 239 - CLKDEV_CON_ID("pioC", &pioCD_clk), 240 - CLKDEV_CON_ID("pioD", &pioCD_clk), 237 + CLKDEV_CON_DEV_ID(NULL, "fffff400.gpio", &pioAB_clk), 238 + CLKDEV_CON_DEV_ID(NULL, "fffff600.gpio", &pioAB_clk), 239 + CLKDEV_CON_DEV_ID(NULL, "fffff800.gpio", &pioCD_clk), 240 + CLKDEV_CON_DEV_ID(NULL, "fffffa00.gpio", &pioCD_clk), 241 241 /* additional fake clock for macb_hclk */ 242 242 CLKDEV_CON_DEV_ID("hclk", "f802c000.ethernet", &macb0_clk), 243 243 CLKDEV_CON_DEV_ID("hclk", "f8030000.ethernet", &macb1_clk), ··· 313 313 at91_init_sram(0, AT91SAM9X5_SRAM_BASE, AT91SAM9X5_SRAM_SIZE); 314 314 } 315 315 316 - void __init at91sam9x5_initialize(void) 317 - { 318 - /* Register GPIO subsystem (using DT) */ 319 - at91_gpio_init(NULL, 0); 320 - } 321 - 322 316 /* -------------------------------------------------------------------- 323 317 * Interrupt initialization 324 318 * -------------------------------------------------------------------- */ 325 319 326 - struct at91_init_soc __initdata at91sam9x5_soc = { 320 + AT91_SOC_START(sam9x5) 327 321 .map_io = at91sam9x5_map_io, 328 322 .register_clocks = at91sam9x5_register_clocks, 329 - .init = at91sam9x5_initialize, 330 - }; 323 + AT91_SOC_END
-2
arch/arm/mach-at91/board-dt.c
··· 30 30 static const struct of_device_id irq_of_match[] __initconst = { 31 31 32 32 { .compatible = "atmel,at91rm9200-aic", .data = at91_aic_of_init }, 33 - { .compatible = "atmel,at91rm9200-gpio", .data = at91_gpio_of_irq_setup }, 34 - { .compatible = "atmel,at91sam9x5-gpio", .data = at91_gpio_of_irq_setup }, 35 33 { /*sentinel*/ } 36 34 }; 37 35
+29 -161
arch/arm/mach-at91/gpio.c
··· 23 23 #include <linux/io.h> 24 24 #include <linux/irqdomain.h> 25 25 #include <linux/of_address.h> 26 - #include <linux/of_irq.h> 27 - #include <linux/of_gpio.h> 28 26 29 27 #include <asm/mach/irq.h> 30 28 ··· 30 32 #include <mach/at91_pio.h> 31 33 32 34 #include "generic.h" 35 + 36 + #define MAX_NB_GPIO_PER_BANK 32 33 37 34 38 struct at91_gpio_chip { 35 39 struct gpio_chip chip; ··· 46 46 47 47 #define to_at91_gpio_chip(c) container_of(c, struct at91_gpio_chip, chip) 48 48 49 + static int at91_gpiolib_request(struct gpio_chip *chip, unsigned offset); 49 50 static void at91_gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip); 50 51 static void at91_gpiolib_set(struct gpio_chip *chip, unsigned offset, int val); 51 52 static int at91_gpiolib_get(struct gpio_chip *chip, unsigned offset); ··· 56 55 unsigned offset); 57 56 static int at91_gpiolib_to_irq(struct gpio_chip *chip, unsigned offset); 58 57 59 - #define AT91_GPIO_CHIP(name, nr_gpio) \ 58 + #define AT91_GPIO_CHIP(name) \ 60 59 { \ 61 60 .chip = { \ 62 61 .label = name, \ 62 + .request = at91_gpiolib_request, \ 63 63 .direction_input = at91_gpiolib_direction_input, \ 64 64 .direction_output = at91_gpiolib_direction_output, \ 65 65 .get = at91_gpiolib_get, \ 66 66 .set = at91_gpiolib_set, \ 67 67 .dbg_show = at91_gpiolib_dbg_show, \ 68 68 .to_irq = at91_gpiolib_to_irq, \ 69 - .ngpio = nr_gpio, \ 69 + .ngpio = MAX_NB_GPIO_PER_BANK, \ 70 70 }, \ 71 71 } 72 72 73 73 static struct at91_gpio_chip gpio_chip[] = { 74 - AT91_GPIO_CHIP("pioA", 32), 75 - AT91_GPIO_CHIP("pioB", 32), 76 - AT91_GPIO_CHIP("pioC", 32), 77 - AT91_GPIO_CHIP("pioD", 32), 78 - AT91_GPIO_CHIP("pioE", 32), 74 + AT91_GPIO_CHIP("pioA"), 75 + AT91_GPIO_CHIP("pioB"), 76 + AT91_GPIO_CHIP("pioC"), 77 + AT91_GPIO_CHIP("pioD"), 78 + AT91_GPIO_CHIP("pioE"), 79 79 }; 80 80 81 81 static int gpio_banks; ··· 91 89 92 90 static inline void __iomem *pin_to_controller(unsigned pin) 93 91 { 94 - pin /= 32; 92 + pin /= MAX_NB_GPIO_PER_BANK; 95 93 if (likely(pin < gpio_banks)) 96 94 return gpio_chip[pin].regbase; 97 95 ··· 100 98 101 99 static inline unsigned pin_to_mask(unsigned pin) 102 100 { 103 - return 1 << (pin % 32); 101 + return 1 << (pin % MAX_NB_GPIO_PER_BANK); 104 102 } 105 103 106 104 ··· 715 713 */ 716 714 static struct lock_class_key gpio_lock_class; 717 715 718 - #if defined(CONFIG_OF) 719 - static int at91_gpio_irq_map(struct irq_domain *h, unsigned int virq, 720 - irq_hw_number_t hw) 721 - { 722 - struct at91_gpio_chip *at91_gpio = h->host_data; 723 - 724 - irq_set_lockdep_class(virq, &gpio_lock_class); 725 - 726 - /* 727 - * Can use the "simple" and not "edge" handler since it's 728 - * shorter, and the AIC handles interrupts sanely. 729 - */ 730 - irq_set_chip_and_handler(virq, &gpio_irqchip, 731 - handle_simple_irq); 732 - set_irq_flags(virq, IRQF_VALID); 733 - irq_set_chip_data(virq, at91_gpio); 734 - 735 - return 0; 736 - } 737 - 738 - static struct irq_domain_ops at91_gpio_ops = { 739 - .map = at91_gpio_irq_map, 740 - .xlate = irq_domain_xlate_twocell, 741 - }; 742 - 743 - int __init at91_gpio_of_irq_setup(struct device_node *node, 744 - struct device_node *parent) 745 - { 746 - struct at91_gpio_chip *prev = NULL; 747 - int alias_idx = of_alias_get_id(node, "gpio"); 748 - struct at91_gpio_chip *at91_gpio = &gpio_chip[alias_idx]; 749 - 750 - /* Setup proper .irq_set_type function */ 751 - if (has_pio3()) 752 - gpio_irqchip.irq_set_type = alt_gpio_irq_type; 753 - else 754 - gpio_irqchip.irq_set_type = gpio_irq_type; 755 - 756 - /* Disable irqs of this PIO controller */ 757 - __raw_writel(~0, at91_gpio->regbase + PIO_IDR); 758 - 759 - /* Setup irq domain */ 760 - at91_gpio->domain = irq_domain_add_linear(node, at91_gpio->chip.ngpio, 761 - &at91_gpio_ops, at91_gpio); 762 - if (!at91_gpio->domain) 763 - panic("at91_gpio.%d: couldn't allocate irq domain (DT).\n", 764 - at91_gpio->pioc_idx); 765 - 766 - /* Setup chained handler */ 767 - if (at91_gpio->pioc_idx) 768 - prev = &gpio_chip[at91_gpio->pioc_idx - 1]; 769 - 770 - /* The toplevel handler handles one bank of GPIOs, except 771 - * on some SoC it can handles up to three... 772 - * We only set up the handler for the first of the list. 773 - */ 774 - if (prev && prev->next == at91_gpio) 775 - return 0; 776 - 777 - at91_gpio->pioc_virq = irq_create_mapping(irq_find_host(parent), 778 - at91_gpio->pioc_hwirq); 779 - irq_set_chip_data(at91_gpio->pioc_virq, at91_gpio); 780 - irq_set_chained_handler(at91_gpio->pioc_virq, gpio_irq_handler); 781 - 782 - return 0; 783 - } 784 - #else 785 - int __init at91_gpio_of_irq_setup(struct device_node *node, 786 - struct device_node *parent) 787 - { 788 - return -EINVAL; 789 - } 790 - #endif 791 - 792 716 /* 793 717 * irqdomain initialization: pile up irqdomains on top of AIC range 794 718 */ ··· 790 862 } 791 863 792 864 /* gpiolib support */ 865 + static int at91_gpiolib_request(struct gpio_chip *chip, unsigned offset) 866 + { 867 + struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); 868 + void __iomem *pio = at91_gpio->regbase; 869 + unsigned mask = 1 << offset; 870 + 871 + __raw_writel(mask, pio + PIO_PER); 872 + return 0; 873 + } 874 + 793 875 static int at91_gpiolib_direction_input(struct gpio_chip *chip, 794 876 unsigned offset) 795 877 { ··· 913 975 return -EINVAL; 914 976 } 915 977 916 - #ifdef CONFIG_OF_GPIO 917 - static void __init of_at91_gpio_init_one(struct device_node *np) 918 - { 919 - int alias_idx; 920 - struct at91_gpio_chip *at91_gpio; 921 - 922 - if (!np) 923 - return; 924 - 925 - alias_idx = of_alias_get_id(np, "gpio"); 926 - if (alias_idx >= MAX_GPIO_BANKS) { 927 - pr_err("at91_gpio, failed alias idx(%d) > MAX_GPIO_BANKS(%d), ignoring.\n", 928 - alias_idx, MAX_GPIO_BANKS); 929 - return; 930 - } 931 - 932 - at91_gpio = &gpio_chip[alias_idx]; 933 - at91_gpio->chip.base = alias_idx * at91_gpio->chip.ngpio; 934 - 935 - at91_gpio->regbase = of_iomap(np, 0); 936 - if (!at91_gpio->regbase) { 937 - pr_err("at91_gpio.%d, failed to map registers, ignoring.\n", 938 - alias_idx); 939 - return; 940 - } 941 - 942 - /* Get the interrupts property */ 943 - if (of_property_read_u32(np, "interrupts", &at91_gpio->pioc_hwirq)) { 944 - pr_err("at91_gpio.%d, failed to get interrupts property, ignoring.\n", 945 - alias_idx); 946 - goto ioremap_err; 947 - } 948 - 949 - /* Get capabilities from compatibility property */ 950 - if (of_device_is_compatible(np, "atmel,at91sam9x5-gpio")) 951 - at91_gpio_caps |= AT91_GPIO_CAP_PIO3; 952 - 953 - /* Setup clock */ 954 - if (at91_gpio_setup_clk(alias_idx)) 955 - goto ioremap_err; 956 - 957 - at91_gpio->chip.of_node = np; 958 - gpio_banks = max(gpio_banks, alias_idx + 1); 959 - at91_gpio->pioc_idx = alias_idx; 960 - return; 961 - 962 - ioremap_err: 963 - iounmap(at91_gpio->regbase); 964 - } 965 - 966 - static int __init of_at91_gpio_init(void) 967 - { 968 - struct device_node *np = NULL; 969 - 970 - /* 971 - * This isn't ideal, but it gets things hooked up until this 972 - * driver is converted into a platform_device 973 - */ 974 - for_each_compatible_node(np, NULL, "atmel,at91rm9200-gpio") 975 - of_at91_gpio_init_one(np); 976 - 977 - return gpio_banks > 0 ? 0 : -EINVAL; 978 - } 979 - #else 980 - static int __init of_at91_gpio_init(void) 981 - { 982 - return -EINVAL; 983 - } 984 - #endif 985 - 986 978 static void __init at91_gpio_init_one(int idx, u32 regbase, int pioc_hwirq) 987 979 { 988 980 struct at91_gpio_chip *at91_gpio = &gpio_chip[idx]; 989 981 990 - at91_gpio->chip.base = idx * at91_gpio->chip.ngpio; 982 + at91_gpio->chip.base = idx * MAX_NB_GPIO_PER_BANK; 991 983 at91_gpio->pioc_hwirq = pioc_hwirq; 992 984 at91_gpio->pioc_idx = idx; 993 985 ··· 947 1079 948 1080 BUG_ON(nr_banks > MAX_GPIO_BANKS); 949 1081 950 - if (of_at91_gpio_init() < 0) { 951 - /* No GPIO controller found in device tree */ 952 - for (i = 0; i < nr_banks; i++) 953 - at91_gpio_init_one(i, data[i].regbase, data[i].id); 954 - } 1082 + if (of_have_populated_dt()) 1083 + return; 1084 + 1085 + for (i = 0; i < nr_banks; i++) 1086 + at91_gpio_init_one(i, data[i].regbase, data[i].id); 955 1087 956 1088 for (i = 0; i < gpio_banks; i++) { 957 1089 at91_gpio = &gpio_chip[i];
+5 -1
arch/arm/mach-at91/setup.c
··· 10 10 #include <linux/mm.h> 11 11 #include <linux/pm.h> 12 12 #include <linux/of_address.h> 13 + #include <linux/pinctrl/machine.h> 13 14 14 15 #include <asm/system_misc.h> 15 16 #include <asm/mach/map.h> ··· 449 448 /* Register the processor-specific clocks */ 450 449 at91_boot_soc.register_clocks(); 451 450 452 - at91_boot_soc.init(); 451 + if (at91_boot_soc.init) 452 + at91_boot_soc.init(); 453 453 } 454 454 #endif 455 455 ··· 465 463 at91_boot_soc.register_clocks(); 466 464 467 465 at91_boot_soc.init(); 466 + 467 + pinctrl_provide_dummies(); 468 468 }
+11 -1
arch/arm/mach-at91/soc.h
··· 5 5 */ 6 6 7 7 struct at91_init_soc { 8 + int builtin; 8 9 unsigned int *default_irq_priority; 9 10 void (*map_io)(void); 10 11 void (*ioremap_registers)(void); ··· 23 22 extern struct at91_init_soc at91sam9x5_soc; 24 23 extern struct at91_init_soc at91sam9n12_soc; 25 24 25 + #define AT91_SOC_START(_name) \ 26 + struct at91_init_soc __initdata at91##_name##_soc \ 27 + __used \ 28 + = { \ 29 + .builtin = 1, \ 30 + 31 + #define AT91_SOC_END \ 32 + }; 33 + 26 34 static inline int at91_soc_is_enabled(void) 27 35 { 28 - return at91_boot_soc.init != NULL; 36 + return at91_boot_soc.builtin; 29 37 } 30 38 31 39 #if !defined(CONFIG_SOC_AT91RM9200)
+9
drivers/mtd/nand/atmel_nand.c
··· 41 41 #include <linux/gpio.h> 42 42 #include <linux/io.h> 43 43 #include <linux/platform_data/atmel.h> 44 + #include <linux/pinctrl/consumer.h> 44 45 45 46 #include <mach/cpu.h> 46 47 ··· 1371 1370 struct resource *mem; 1372 1371 struct mtd_part_parser_data ppdata = {}; 1373 1372 int res; 1373 + struct pinctrl *pinctrl; 1374 1374 1375 1375 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1376 1376 if (!mem) { ··· 1415 1413 nand_chip->IO_ADDR_R = host->io_base; 1416 1414 nand_chip->IO_ADDR_W = host->io_base; 1417 1415 nand_chip->cmd_ctrl = atmel_nand_cmd_ctrl; 1416 + 1417 + pinctrl = devm_pinctrl_get_select_default(&pdev->dev); 1418 + if (IS_ERR(pinctrl)) { 1419 + dev_err(host->dev, "Failed to request pinctrl\n"); 1420 + res = PTR_ERR(pinctrl); 1421 + goto err_ecc_ioremap; 1422 + } 1418 1423 1419 1424 if (gpio_is_valid(host->board.rdy_pin)) { 1420 1425 res = gpio_request(host->board.rdy_pin, "nand_rdy");
+9
drivers/pinctrl/Kconfig
··· 26 26 help 27 27 Say Y here to add some extra checks and diagnostics to PINCTRL calls. 28 28 29 + config PINCTRL_AT91 30 + bool "AT91 pinctrl driver" 31 + depends on OF 32 + depends on ARCH_AT91 33 + select PINMUX 34 + select PINCONF 35 + help 36 + Say Y here to enable the at91 pinctrl driver 37 + 29 38 config PINCTRL_BCM2835 30 39 bool 31 40 select PINMUX
+1
drivers/pinctrl/Makefile
··· 9 9 obj-$(CONFIG_PINCTRL) += devicetree.o 10 10 endif 11 11 obj-$(CONFIG_GENERIC_PINCONF) += pinconf-generic.o 12 + obj-$(CONFIG_PINCTRL_AT91) += pinctrl-at91.o 12 13 obj-$(CONFIG_PINCTRL_BCM2835) += pinctrl-bcm2835.o 13 14 obj-$(CONFIG_PINCTRL_IMX) += pinctrl-imx.o 14 15 obj-$(CONFIG_PINCTRL_IMX35) += pinctrl-imx35.o
+1510
drivers/pinctrl/pinctrl-at91.c
··· 1 + /* 2 + * at91 pinctrl driver based on at91 pinmux core 3 + * 4 + * Copyright (C) 2011-2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> 5 + * 6 + * Under GPLv2 only 7 + */ 8 + 9 + #include <linux/clk.h> 10 + #include <linux/err.h> 11 + #include <linux/init.h> 12 + #include <linux/module.h> 13 + #include <linux/of.h> 14 + #include <linux/of_device.h> 15 + #include <linux/of_address.h> 16 + #include <linux/of_irq.h> 17 + #include <linux/slab.h> 18 + #include <linux/interrupt.h> 19 + #include <linux/irq.h> 20 + #include <linux/irqdomain.h> 21 + #include <linux/io.h> 22 + #include <linux/gpio.h> 23 + #include <linux/pinctrl/machine.h> 24 + #include <linux/pinctrl/pinconf.h> 25 + #include <linux/pinctrl/pinctrl.h> 26 + #include <linux/pinctrl/pinmux.h> 27 + /* Since we request GPIOs from ourself */ 28 + #include <linux/pinctrl/consumer.h> 29 + 30 + #include <asm/mach/irq.h> 31 + 32 + #include <mach/hardware.h> 33 + #include <mach/at91_pio.h> 34 + 35 + #include "core.h" 36 + 37 + #define MAX_NB_GPIO_PER_BANK 32 38 + 39 + struct at91_pinctrl_mux_ops; 40 + 41 + struct at91_gpio_chip { 42 + struct gpio_chip chip; 43 + struct pinctrl_gpio_range range; 44 + struct at91_gpio_chip *next; /* Bank sharing same clock */ 45 + int pioc_hwirq; /* PIO bank interrupt identifier on AIC */ 46 + int pioc_virq; /* PIO bank Linux virtual interrupt */ 47 + int pioc_idx; /* PIO bank index */ 48 + void __iomem *regbase; /* PIO bank virtual address */ 49 + struct clk *clock; /* associated clock */ 50 + struct irq_domain *domain; /* associated irq domain */ 51 + struct at91_pinctrl_mux_ops *ops; /* ops */ 52 + }; 53 + 54 + #define to_at91_gpio_chip(c) container_of(c, struct at91_gpio_chip, chip) 55 + 56 + static struct at91_gpio_chip *gpio_chips[MAX_GPIO_BANKS]; 57 + 58 + static int gpio_banks; 59 + 60 + #define PULL_UP (1 << 0) 61 + #define MULTI_DRIVE (1 << 1) 62 + 63 + /** 64 + * struct at91_pmx_func - describes AT91 pinmux functions 65 + * @name: the name of this specific function 66 + * @groups: corresponding pin groups 67 + * @ngroups: the number of groups 68 + */ 69 + struct at91_pmx_func { 70 + const char *name; 71 + const char **groups; 72 + unsigned ngroups; 73 + }; 74 + 75 + enum at91_mux { 76 + AT91_MUX_GPIO = 0, 77 + AT91_MUX_PERIPH_A = 1, 78 + AT91_MUX_PERIPH_B = 2, 79 + AT91_MUX_PERIPH_C = 3, 80 + AT91_MUX_PERIPH_D = 4, 81 + }; 82 + 83 + /** 84 + * struct at91_pmx_pin - describes an At91 pin mux 85 + * @bank: the bank of the pin 86 + * @pin: the pin number in the @bank 87 + * @mux: the mux mode : gpio or periph_x of the pin i.e. alternate function. 88 + * @conf: the configuration of the pin: PULL_UP, MULTIDRIVE etc... 89 + */ 90 + struct at91_pmx_pin { 91 + uint32_t bank; 92 + uint32_t pin; 93 + enum at91_mux mux; 94 + unsigned long conf; 95 + }; 96 + 97 + /** 98 + * struct at91_pin_group - describes an At91 pin group 99 + * @name: the name of this specific pin group 100 + * @pins_conf: the mux mode for each pin in this group. The size of this 101 + * array is the same as pins. 102 + * @pins: an array of discrete physical pins used in this group, taken 103 + * from the driver-local pin enumeration space 104 + * @npins: the number of pins in this group array, i.e. the number of 105 + * elements in .pins so we can iterate over that array 106 + */ 107 + struct at91_pin_group { 108 + const char *name; 109 + struct at91_pmx_pin *pins_conf; 110 + unsigned int *pins; 111 + unsigned npins; 112 + }; 113 + 114 + /** 115 + * struct at91_pinctrl_mux_ops - describes an At91 mux ops group 116 + * on new IP with support for periph C and D the way to mux in 117 + * periph A and B has changed 118 + * So provide the right call back 119 + * if not present means the IP does not support it 120 + * @get_periph: return the periph mode configured 121 + * @mux_A_periph: mux as periph A 122 + * @mux_B_periph: mux as periph B 123 + * @mux_C_periph: mux as periph C 124 + * @mux_D_periph: mux as periph D 125 + * @irq_type: return irq type 126 + */ 127 + struct at91_pinctrl_mux_ops { 128 + enum at91_mux (*get_periph)(void __iomem *pio, unsigned mask); 129 + void (*mux_A_periph)(void __iomem *pio, unsigned mask); 130 + void (*mux_B_periph)(void __iomem *pio, unsigned mask); 131 + void (*mux_C_periph)(void __iomem *pio, unsigned mask); 132 + void (*mux_D_periph)(void __iomem *pio, unsigned mask); 133 + /* irq */ 134 + int (*irq_type)(struct irq_data *d, unsigned type); 135 + }; 136 + 137 + static int gpio_irq_type(struct irq_data *d, unsigned type); 138 + static int alt_gpio_irq_type(struct irq_data *d, unsigned type); 139 + 140 + struct at91_pinctrl { 141 + struct device *dev; 142 + struct pinctrl_dev *pctl; 143 + 144 + int nbanks; 145 + 146 + uint32_t *mux_mask; 147 + int nmux; 148 + 149 + struct at91_pmx_func *functions; 150 + int nfunctions; 151 + 152 + struct at91_pin_group *groups; 153 + int ngroups; 154 + 155 + struct at91_pinctrl_mux_ops *ops; 156 + }; 157 + 158 + static const inline struct at91_pin_group *at91_pinctrl_find_group_by_name( 159 + const struct at91_pinctrl *info, 160 + const char *name) 161 + { 162 + const struct at91_pin_group *grp = NULL; 163 + int i; 164 + 165 + for (i = 0; i < info->ngroups; i++) { 166 + if (strcmp(info->groups[i].name, name)) 167 + continue; 168 + 169 + grp = &info->groups[i]; 170 + dev_dbg(info->dev, "%s: %d 0:%d\n", name, grp->npins, grp->pins[0]); 171 + break; 172 + } 173 + 174 + return grp; 175 + } 176 + 177 + static int at91_get_groups_count(struct pinctrl_dev *pctldev) 178 + { 179 + struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 180 + 181 + return info->ngroups; 182 + } 183 + 184 + static const char *at91_get_group_name(struct pinctrl_dev *pctldev, 185 + unsigned selector) 186 + { 187 + struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 188 + 189 + return info->groups[selector].name; 190 + } 191 + 192 + static int at91_get_group_pins(struct pinctrl_dev *pctldev, unsigned selector, 193 + const unsigned **pins, 194 + unsigned *npins) 195 + { 196 + struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 197 + 198 + if (selector >= info->ngroups) 199 + return -EINVAL; 200 + 201 + *pins = info->groups[selector].pins; 202 + *npins = info->groups[selector].npins; 203 + 204 + return 0; 205 + } 206 + 207 + static void at91_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s, 208 + unsigned offset) 209 + { 210 + seq_printf(s, "%s", dev_name(pctldev->dev)); 211 + } 212 + 213 + static int at91_dt_node_to_map(struct pinctrl_dev *pctldev, 214 + struct device_node *np, 215 + struct pinctrl_map **map, unsigned *num_maps) 216 + { 217 + struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 218 + const struct at91_pin_group *grp; 219 + struct pinctrl_map *new_map; 220 + struct device_node *parent; 221 + int map_num = 1; 222 + int i; 223 + 224 + /* 225 + * first find the group of this node and check if we need create 226 + * config maps for pins 227 + */ 228 + grp = at91_pinctrl_find_group_by_name(info, np->name); 229 + if (!grp) { 230 + dev_err(info->dev, "unable to find group for node %s\n", 231 + np->name); 232 + return -EINVAL; 233 + } 234 + 235 + map_num += grp->npins; 236 + new_map = devm_kzalloc(pctldev->dev, sizeof(*new_map) * map_num, GFP_KERNEL); 237 + if (!new_map) 238 + return -ENOMEM; 239 + 240 + *map = new_map; 241 + *num_maps = map_num; 242 + 243 + /* create mux map */ 244 + parent = of_get_parent(np); 245 + if (!parent) { 246 + kfree(new_map); 247 + return -EINVAL; 248 + } 249 + new_map[0].type = PIN_MAP_TYPE_MUX_GROUP; 250 + new_map[0].data.mux.function = parent->name; 251 + new_map[0].data.mux.group = np->name; 252 + of_node_put(parent); 253 + 254 + /* create config map */ 255 + new_map++; 256 + for (i = 0; i < grp->npins; i++) { 257 + new_map[i].type = PIN_MAP_TYPE_CONFIGS_PIN; 258 + new_map[i].data.configs.group_or_pin = 259 + pin_get_name(pctldev, grp->pins[i]); 260 + new_map[i].data.configs.configs = &grp->pins_conf[i].conf; 261 + new_map[i].data.configs.num_configs = 1; 262 + } 263 + 264 + dev_dbg(pctldev->dev, "maps: function %s group %s num %d\n", 265 + (*map)->data.mux.function, (*map)->data.mux.group, map_num); 266 + 267 + return 0; 268 + } 269 + 270 + static void at91_dt_free_map(struct pinctrl_dev *pctldev, 271 + struct pinctrl_map *map, unsigned num_maps) 272 + { 273 + } 274 + 275 + static struct pinctrl_ops at91_pctrl_ops = { 276 + .get_groups_count = at91_get_groups_count, 277 + .get_group_name = at91_get_group_name, 278 + .get_group_pins = at91_get_group_pins, 279 + .pin_dbg_show = at91_pin_dbg_show, 280 + .dt_node_to_map = at91_dt_node_to_map, 281 + .dt_free_map = at91_dt_free_map, 282 + }; 283 + 284 + static void __iomem * pin_to_controller(struct at91_pinctrl *info, 285 + unsigned int bank) 286 + { 287 + return gpio_chips[bank]->regbase; 288 + } 289 + 290 + static inline int pin_to_bank(unsigned pin) 291 + { 292 + return pin /= MAX_NB_GPIO_PER_BANK; 293 + } 294 + 295 + static unsigned pin_to_mask(unsigned int pin) 296 + { 297 + return 1 << pin; 298 + } 299 + 300 + static void at91_mux_disable_interrupt(void __iomem *pio, unsigned mask) 301 + { 302 + writel_relaxed(mask, pio + PIO_IDR); 303 + } 304 + 305 + static unsigned at91_mux_get_pullup(void __iomem *pio, unsigned pin) 306 + { 307 + return (readl_relaxed(pio + PIO_PUSR) >> pin) & 0x1; 308 + } 309 + 310 + static void at91_mux_set_pullup(void __iomem *pio, unsigned mask, bool on) 311 + { 312 + writel_relaxed(mask, pio + (on ? PIO_PUER : PIO_PUDR)); 313 + } 314 + 315 + static unsigned at91_mux_get_multidrive(void __iomem *pio, unsigned pin) 316 + { 317 + return (readl_relaxed(pio + PIO_MDSR) >> pin) & 0x1; 318 + } 319 + 320 + static void at91_mux_set_multidrive(void __iomem *pio, unsigned mask, bool on) 321 + { 322 + writel_relaxed(mask, pio + (on ? PIO_MDER : PIO_MDDR)); 323 + } 324 + 325 + static void at91_mux_set_A_periph(void __iomem *pio, unsigned mask) 326 + { 327 + writel_relaxed(mask, pio + PIO_ASR); 328 + } 329 + 330 + static void at91_mux_set_B_periph(void __iomem *pio, unsigned mask) 331 + { 332 + writel_relaxed(mask, pio + PIO_BSR); 333 + } 334 + 335 + static void at91_mux_pio3_set_A_periph(void __iomem *pio, unsigned mask) 336 + { 337 + 338 + writel_relaxed(readl_relaxed(pio + PIO_ABCDSR1) & ~mask, 339 + pio + PIO_ABCDSR1); 340 + writel_relaxed(readl_relaxed(pio + PIO_ABCDSR2) & ~mask, 341 + pio + PIO_ABCDSR2); 342 + } 343 + 344 + static void at91_mux_pio3_set_B_periph(void __iomem *pio, unsigned mask) 345 + { 346 + writel_relaxed(readl_relaxed(pio + PIO_ABCDSR1) | mask, 347 + pio + PIO_ABCDSR1); 348 + writel_relaxed(readl_relaxed(pio + PIO_ABCDSR2) & ~mask, 349 + pio + PIO_ABCDSR2); 350 + } 351 + 352 + static void at91_mux_pio3_set_C_periph(void __iomem *pio, unsigned mask) 353 + { 354 + writel_relaxed(readl_relaxed(pio + PIO_ABCDSR1) & ~mask, pio + PIO_ABCDSR1); 355 + writel_relaxed(readl_relaxed(pio + PIO_ABCDSR2) | mask, pio + PIO_ABCDSR2); 356 + } 357 + 358 + static void at91_mux_pio3_set_D_periph(void __iomem *pio, unsigned mask) 359 + { 360 + writel_relaxed(readl_relaxed(pio + PIO_ABCDSR1) | mask, pio + PIO_ABCDSR1); 361 + writel_relaxed(readl_relaxed(pio + PIO_ABCDSR2) | mask, pio + PIO_ABCDSR2); 362 + } 363 + 364 + static enum at91_mux at91_mux_pio3_get_periph(void __iomem *pio, unsigned mask) 365 + { 366 + unsigned select; 367 + 368 + if (readl_relaxed(pio + PIO_PSR) & mask) 369 + return AT91_MUX_GPIO; 370 + 371 + select = !!(readl_relaxed(pio + PIO_ABCDSR1) & mask); 372 + select |= (!!(readl_relaxed(pio + PIO_ABCDSR2) & mask) << 1); 373 + 374 + return select + 1; 375 + } 376 + 377 + static enum at91_mux at91_mux_get_periph(void __iomem *pio, unsigned mask) 378 + { 379 + unsigned select; 380 + 381 + if (readl_relaxed(pio + PIO_PSR) & mask) 382 + return AT91_MUX_GPIO; 383 + 384 + select = readl_relaxed(pio + PIO_ABSR) & mask; 385 + 386 + return select + 1; 387 + } 388 + 389 + static struct at91_pinctrl_mux_ops at91rm9200_ops = { 390 + .get_periph = at91_mux_get_periph, 391 + .mux_A_periph = at91_mux_set_A_periph, 392 + .mux_B_periph = at91_mux_set_B_periph, 393 + .irq_type = gpio_irq_type, 394 + }; 395 + 396 + static struct at91_pinctrl_mux_ops at91sam9x5_ops = { 397 + .get_periph = at91_mux_pio3_get_periph, 398 + .mux_A_periph = at91_mux_pio3_set_A_periph, 399 + .mux_B_periph = at91_mux_pio3_set_B_periph, 400 + .mux_C_periph = at91_mux_pio3_set_C_periph, 401 + .mux_D_periph = at91_mux_pio3_set_D_periph, 402 + .irq_type = alt_gpio_irq_type, 403 + }; 404 + 405 + static void at91_pin_dbg(const struct device *dev, const struct at91_pmx_pin *pin) 406 + { 407 + if (pin->mux) { 408 + dev_dbg(dev, "pio%c%d configured as periph%c with conf = 0x%lu\n", 409 + pin->bank + 'A', pin->pin, pin->mux - 1 + 'A', pin->conf); 410 + } else { 411 + dev_dbg(dev, "pio%c%d configured as gpio with conf = 0x%lu\n", 412 + pin->bank + 'A', pin->pin, pin->conf); 413 + } 414 + } 415 + 416 + static int pin_check_config(struct at91_pinctrl *info, const char* name, 417 + int index, const struct at91_pmx_pin *pin) 418 + { 419 + int mux; 420 + 421 + /* check if it's a valid config */ 422 + if (pin->bank >= info->nbanks) { 423 + dev_err(info->dev, "%s: pin conf %d bank_id %d >= nbanks %d\n", 424 + name, index, pin->bank, info->nbanks); 425 + return -EINVAL; 426 + } 427 + 428 + if (pin->pin >= MAX_NB_GPIO_PER_BANK) { 429 + dev_err(info->dev, "%s: pin conf %d pin_bank_id %d >= %d\n", 430 + name, index, pin->pin, MAX_NB_GPIO_PER_BANK); 431 + return -EINVAL; 432 + } 433 + 434 + if (!pin->mux) 435 + return 0; 436 + 437 + mux = pin->mux - 1; 438 + 439 + if (mux >= info->nmux) { 440 + dev_err(info->dev, "%s: pin conf %d mux_id %d >= nmux %d\n", 441 + name, index, mux, info->nmux); 442 + return -EINVAL; 443 + } 444 + 445 + if (!(info->mux_mask[pin->bank * info->nmux + mux] & 1 << pin->pin)) { 446 + dev_err(info->dev, "%s: pin conf %d mux_id %d not supported for pio%c%d\n", 447 + name, index, mux, pin->bank + 'A', pin->pin); 448 + return -EINVAL; 449 + } 450 + 451 + return 0; 452 + } 453 + 454 + static void at91_mux_gpio_disable(void __iomem *pio, unsigned mask) 455 + { 456 + writel_relaxed(mask, pio + PIO_PDR); 457 + } 458 + 459 + static void at91_mux_gpio_enable(void __iomem *pio, unsigned mask, bool input) 460 + { 461 + writel_relaxed(mask, pio + PIO_PER); 462 + writel_relaxed(mask, pio + (input ? PIO_ODR : PIO_OER)); 463 + } 464 + 465 + static int at91_pmx_enable(struct pinctrl_dev *pctldev, unsigned selector, 466 + unsigned group) 467 + { 468 + struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 469 + const struct at91_pmx_pin *pins_conf = info->groups[group].pins_conf; 470 + const struct at91_pmx_pin *pin; 471 + uint32_t npins = info->groups[group].npins; 472 + int i, ret; 473 + unsigned mask; 474 + void __iomem *pio; 475 + 476 + dev_dbg(info->dev, "enable function %s group %s\n", 477 + info->functions[selector].name, info->groups[group].name); 478 + 479 + /* first check that all the pins of the group are valid with a valid 480 + * paramter */ 481 + for (i = 0; i < npins; i++) { 482 + pin = &pins_conf[i]; 483 + ret = pin_check_config(info, info->groups[group].name, i, pin); 484 + if (ret) 485 + return ret; 486 + } 487 + 488 + for (i = 0; i < npins; i++) { 489 + pin = &pins_conf[i]; 490 + at91_pin_dbg(info->dev, pin); 491 + pio = pin_to_controller(info, pin->bank); 492 + mask = pin_to_mask(pin->pin); 493 + at91_mux_disable_interrupt(pio, mask); 494 + switch(pin->mux) { 495 + case AT91_MUX_GPIO: 496 + at91_mux_gpio_enable(pio, mask, 1); 497 + break; 498 + case AT91_MUX_PERIPH_A: 499 + info->ops->mux_A_periph(pio, mask); 500 + break; 501 + case AT91_MUX_PERIPH_B: 502 + info->ops->mux_B_periph(pio, mask); 503 + break; 504 + case AT91_MUX_PERIPH_C: 505 + if (!info->ops->mux_C_periph) 506 + return -EINVAL; 507 + info->ops->mux_C_periph(pio, mask); 508 + break; 509 + case AT91_MUX_PERIPH_D: 510 + if (!info->ops->mux_D_periph) 511 + return -EINVAL; 512 + info->ops->mux_D_periph(pio, mask); 513 + break; 514 + } 515 + if (pin->mux) 516 + at91_mux_gpio_disable(pio, mask); 517 + } 518 + 519 + return 0; 520 + } 521 + 522 + static void at91_pmx_disable(struct pinctrl_dev *pctldev, unsigned selector, 523 + unsigned group) 524 + { 525 + struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 526 + const struct at91_pmx_pin *pins_conf = info->groups[group].pins_conf; 527 + const struct at91_pmx_pin *pin; 528 + uint32_t npins = info->groups[group].npins; 529 + int i; 530 + unsigned mask; 531 + void __iomem *pio; 532 + 533 + for (i = 0; i < npins; i++) { 534 + pin = &pins_conf[i]; 535 + at91_pin_dbg(info->dev, pin); 536 + pio = pin_to_controller(info, pin->bank); 537 + mask = pin_to_mask(pin->pin); 538 + at91_mux_gpio_enable(pio, mask, 1); 539 + } 540 + } 541 + 542 + static int at91_pmx_get_funcs_count(struct pinctrl_dev *pctldev) 543 + { 544 + struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 545 + 546 + return info->nfunctions; 547 + } 548 + 549 + static const char *at91_pmx_get_func_name(struct pinctrl_dev *pctldev, 550 + unsigned selector) 551 + { 552 + struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 553 + 554 + return info->functions[selector].name; 555 + } 556 + 557 + static int at91_pmx_get_groups(struct pinctrl_dev *pctldev, unsigned selector, 558 + const char * const **groups, 559 + unsigned * const num_groups) 560 + { 561 + struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 562 + 563 + *groups = info->functions[selector].groups; 564 + *num_groups = info->functions[selector].ngroups; 565 + 566 + return 0; 567 + } 568 + 569 + static int at91_gpio_request_enable(struct pinctrl_dev *pctldev, 570 + struct pinctrl_gpio_range *range, 571 + unsigned offset) 572 + { 573 + struct at91_pinctrl *npct = pinctrl_dev_get_drvdata(pctldev); 574 + struct at91_gpio_chip *at91_chip; 575 + struct gpio_chip *chip; 576 + unsigned mask; 577 + 578 + if (!range) { 579 + dev_err(npct->dev, "invalid range\n"); 580 + return -EINVAL; 581 + } 582 + if (!range->gc) { 583 + dev_err(npct->dev, "missing GPIO chip in range\n"); 584 + return -EINVAL; 585 + } 586 + chip = range->gc; 587 + at91_chip = container_of(chip, struct at91_gpio_chip, chip); 588 + 589 + dev_dbg(npct->dev, "enable pin %u as GPIO\n", offset); 590 + 591 + mask = 1 << (offset - chip->base); 592 + 593 + dev_dbg(npct->dev, "enable pin %u as PIO%c%d 0x%x\n", 594 + offset, 'A' + range->id, offset - chip->base, mask); 595 + 596 + writel_relaxed(mask, at91_chip->regbase + PIO_PER); 597 + 598 + return 0; 599 + } 600 + 601 + static void at91_gpio_disable_free(struct pinctrl_dev *pctldev, 602 + struct pinctrl_gpio_range *range, 603 + unsigned offset) 604 + { 605 + struct at91_pinctrl *npct = pinctrl_dev_get_drvdata(pctldev); 606 + 607 + dev_dbg(npct->dev, "disable pin %u as GPIO\n", offset); 608 + /* Set the pin to some default state, GPIO is usually default */ 609 + } 610 + 611 + static struct pinmux_ops at91_pmx_ops = { 612 + .get_functions_count = at91_pmx_get_funcs_count, 613 + .get_function_name = at91_pmx_get_func_name, 614 + .get_function_groups = at91_pmx_get_groups, 615 + .enable = at91_pmx_enable, 616 + .disable = at91_pmx_disable, 617 + .gpio_request_enable = at91_gpio_request_enable, 618 + .gpio_disable_free = at91_gpio_disable_free, 619 + }; 620 + 621 + static int at91_pinconf_get(struct pinctrl_dev *pctldev, 622 + unsigned pin_id, unsigned long *config) 623 + { 624 + struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 625 + void __iomem *pio; 626 + unsigned pin; 627 + 628 + dev_dbg(info->dev, "%s:%d, pin_id=%d, config=0x%lx", __func__, __LINE__, pin_id, *config); 629 + pio = pin_to_controller(info, pin_to_bank(pin_id)); 630 + pin = pin_id % MAX_NB_GPIO_PER_BANK; 631 + 632 + if (at91_mux_get_multidrive(pio, pin)) 633 + *config |= MULTI_DRIVE; 634 + 635 + if (at91_mux_get_pullup(pio, pin)) 636 + *config |= PULL_UP; 637 + 638 + return 0; 639 + } 640 + 641 + static int at91_pinconf_set(struct pinctrl_dev *pctldev, 642 + unsigned pin_id, unsigned long config) 643 + { 644 + struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 645 + unsigned mask; 646 + void __iomem *pio; 647 + 648 + dev_dbg(info->dev, "%s:%d, pin_id=%d, config=0x%lx", __func__, __LINE__, pin_id, config); 649 + pio = pin_to_controller(info, pin_to_bank(pin_id)); 650 + mask = pin_to_mask(pin_id % MAX_NB_GPIO_PER_BANK); 651 + 652 + at91_mux_set_pullup(pio, mask, config & PULL_UP); 653 + at91_mux_set_multidrive(pio, mask, config & MULTI_DRIVE); 654 + return 0; 655 + } 656 + 657 + static void at91_pinconf_dbg_show(struct pinctrl_dev *pctldev, 658 + struct seq_file *s, unsigned pin_id) 659 + { 660 + 661 + } 662 + 663 + static void at91_pinconf_group_dbg_show(struct pinctrl_dev *pctldev, 664 + struct seq_file *s, unsigned group) 665 + { 666 + } 667 + 668 + struct pinconf_ops at91_pinconf_ops = { 669 + .pin_config_get = at91_pinconf_get, 670 + .pin_config_set = at91_pinconf_set, 671 + .pin_config_dbg_show = at91_pinconf_dbg_show, 672 + .pin_config_group_dbg_show = at91_pinconf_group_dbg_show, 673 + }; 674 + 675 + static struct pinctrl_desc at91_pinctrl_desc = { 676 + .pctlops = &at91_pctrl_ops, 677 + .pmxops = &at91_pmx_ops, 678 + .confops = &at91_pinconf_ops, 679 + .owner = THIS_MODULE, 680 + }; 681 + 682 + static const char *gpio_compat = "atmel,at91rm9200-gpio"; 683 + 684 + static void __devinit at91_pinctrl_child_count(struct at91_pinctrl *info, 685 + struct device_node *np) 686 + { 687 + struct device_node *child; 688 + 689 + for_each_child_of_node(np, child) { 690 + if (of_device_is_compatible(child, gpio_compat)) { 691 + info->nbanks++; 692 + } else { 693 + info->nfunctions++; 694 + info->ngroups += of_get_child_count(child); 695 + } 696 + } 697 + } 698 + 699 + static int __devinit at91_pinctrl_mux_mask(struct at91_pinctrl *info, 700 + struct device_node *np) 701 + { 702 + int ret = 0; 703 + int size; 704 + const const __be32 *list; 705 + 706 + list = of_get_property(np, "atmel,mux-mask", &size); 707 + if (!list) { 708 + dev_err(info->dev, "can not read the mux-mask of %d\n", size); 709 + return -EINVAL; 710 + } 711 + 712 + size /= sizeof(*list); 713 + if (!size || size % info->nbanks) { 714 + dev_err(info->dev, "wrong mux mask array should be by %d\n", info->nbanks); 715 + return -EINVAL; 716 + } 717 + info->nmux = size / info->nbanks; 718 + 719 + info->mux_mask = devm_kzalloc(info->dev, sizeof(u32) * size, GFP_KERNEL); 720 + if (!info->mux_mask) { 721 + dev_err(info->dev, "could not alloc mux_mask\n"); 722 + return -ENOMEM; 723 + } 724 + 725 + ret = of_property_read_u32_array(np, "atmel,mux-mask", 726 + info->mux_mask, size); 727 + if (ret) 728 + dev_err(info->dev, "can not read the mux-mask of %d\n", size); 729 + return ret; 730 + } 731 + 732 + static int __devinit at91_pinctrl_parse_groups(struct device_node *np, 733 + struct at91_pin_group *grp, 734 + struct at91_pinctrl *info, 735 + u32 index) 736 + { 737 + struct at91_pmx_pin *pin; 738 + int size; 739 + const const __be32 *list; 740 + int i, j; 741 + 742 + dev_dbg(info->dev, "group(%d): %s\n", index, np->name); 743 + 744 + /* Initialise group */ 745 + grp->name = np->name; 746 + 747 + /* 748 + * the binding format is atmel,pins = <bank pin mux CONFIG ...>, 749 + * do sanity check and calculate pins number 750 + */ 751 + list = of_get_property(np, "atmel,pins", &size); 752 + /* we do not check return since it's safe node passed down */ 753 + size /= sizeof(*list); 754 + if (!size || size % 4) { 755 + dev_err(info->dev, "wrong pins number or pins and configs should be by 4\n"); 756 + return -EINVAL; 757 + } 758 + 759 + grp->npins = size / 4; 760 + pin = grp->pins_conf = devm_kzalloc(info->dev, grp->npins * sizeof(struct at91_pmx_pin), 761 + GFP_KERNEL); 762 + grp->pins = devm_kzalloc(info->dev, grp->npins * sizeof(unsigned int), 763 + GFP_KERNEL); 764 + if (!grp->pins_conf || !grp->pins) 765 + return -ENOMEM; 766 + 767 + for (i = 0, j = 0; i < size; i += 4, j++) { 768 + pin->bank = be32_to_cpu(*list++); 769 + pin->pin = be32_to_cpu(*list++); 770 + grp->pins[j] = pin->bank * MAX_NB_GPIO_PER_BANK + pin->pin; 771 + pin->mux = be32_to_cpu(*list++); 772 + pin->conf = be32_to_cpu(*list++); 773 + 774 + at91_pin_dbg(info->dev, pin); 775 + pin++; 776 + } 777 + 778 + return 0; 779 + } 780 + 781 + static int __devinit at91_pinctrl_parse_functions(struct device_node *np, 782 + struct at91_pinctrl *info, u32 index) 783 + { 784 + struct device_node *child; 785 + struct at91_pmx_func *func; 786 + struct at91_pin_group *grp; 787 + int ret; 788 + static u32 grp_index; 789 + u32 i = 0; 790 + 791 + dev_dbg(info->dev, "parse function(%d): %s\n", index, np->name); 792 + 793 + func = &info->functions[index]; 794 + 795 + /* Initialise function */ 796 + func->name = np->name; 797 + func->ngroups = of_get_child_count(np); 798 + if (func->ngroups <= 0) { 799 + dev_err(info->dev, "no groups defined\n"); 800 + return -EINVAL; 801 + } 802 + func->groups = devm_kzalloc(info->dev, 803 + func->ngroups * sizeof(char *), GFP_KERNEL); 804 + if (!func->groups) 805 + return -ENOMEM; 806 + 807 + for_each_child_of_node(np, child) { 808 + func->groups[i] = child->name; 809 + grp = &info->groups[grp_index++]; 810 + ret = at91_pinctrl_parse_groups(child, grp, info, i++); 811 + if (ret) 812 + return ret; 813 + } 814 + 815 + return 0; 816 + } 817 + 818 + static struct of_device_id at91_pinctrl_of_match[] __devinitdata = { 819 + { .compatible = "atmel,at91sam9x5-pinctrl", .data = &at91sam9x5_ops }, 820 + { .compatible = "atmel,at91rm9200-pinctrl", .data = &at91rm9200_ops }, 821 + { /* sentinel */ } 822 + }; 823 + 824 + static int __devinit at91_pinctrl_probe_dt(struct platform_device *pdev, 825 + struct at91_pinctrl *info) 826 + { 827 + int ret = 0; 828 + int i, j; 829 + uint32_t *tmp; 830 + struct device_node *np = pdev->dev.of_node; 831 + struct device_node *child; 832 + 833 + if (!np) 834 + return -ENODEV; 835 + 836 + info->dev = &pdev->dev; 837 + info->ops = (struct at91_pinctrl_mux_ops*) 838 + of_match_device(at91_pinctrl_of_match, &pdev->dev)->data; 839 + at91_pinctrl_child_count(info, np); 840 + 841 + if (info->nbanks < 1) { 842 + dev_err(&pdev->dev, "you need to specify atleast one gpio-controller\n"); 843 + return -EINVAL; 844 + } 845 + 846 + ret = at91_pinctrl_mux_mask(info, np); 847 + if (ret) 848 + return ret; 849 + 850 + dev_dbg(&pdev->dev, "nmux = %d\n", info->nmux); 851 + 852 + dev_dbg(&pdev->dev, "mux-mask\n"); 853 + tmp = info->mux_mask; 854 + for (i = 0; i < info->nbanks; i++) { 855 + for (j = 0; j < info->nmux; j++, tmp++) { 856 + dev_dbg(&pdev->dev, "%d:%d\t0x%x\n", i, j, tmp[0]); 857 + } 858 + } 859 + 860 + dev_dbg(&pdev->dev, "nfunctions = %d\n", info->nfunctions); 861 + dev_dbg(&pdev->dev, "ngroups = %d\n", info->ngroups); 862 + info->functions = devm_kzalloc(&pdev->dev, info->nfunctions * sizeof(struct at91_pmx_func), 863 + GFP_KERNEL); 864 + if (!info->functions) 865 + return -ENOMEM; 866 + 867 + info->groups = devm_kzalloc(&pdev->dev, info->ngroups * sizeof(struct at91_pin_group), 868 + GFP_KERNEL); 869 + if (!info->groups) 870 + return -ENOMEM; 871 + 872 + dev_dbg(&pdev->dev, "nbanks = %d\n", info->nbanks); 873 + dev_dbg(&pdev->dev, "nfunctions = %d\n", info->nfunctions); 874 + dev_dbg(&pdev->dev, "ngroups = %d\n", info->ngroups); 875 + 876 + i = 0; 877 + 878 + for_each_child_of_node(np, child) { 879 + if (of_device_is_compatible(child, gpio_compat)) 880 + continue; 881 + ret = at91_pinctrl_parse_functions(child, info, i++); 882 + if (ret) { 883 + dev_err(&pdev->dev, "failed to parse function\n"); 884 + return ret; 885 + } 886 + } 887 + 888 + return 0; 889 + } 890 + 891 + static int __devinit at91_pinctrl_probe(struct platform_device *pdev) 892 + { 893 + struct at91_pinctrl *info; 894 + struct pinctrl_pin_desc *pdesc; 895 + int ret, i, j ,k; 896 + 897 + info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); 898 + if (!info) 899 + return -ENOMEM; 900 + 901 + ret = at91_pinctrl_probe_dt(pdev, info); 902 + if (ret) 903 + return ret; 904 + 905 + /* 906 + * We need all the GPIO drivers to probe FIRST, or we will not be able 907 + * to obtain references to the struct gpio_chip * for them, and we 908 + * need this to proceed. 909 + */ 910 + for (i = 0; i < info->nbanks; i++) { 911 + if (!gpio_chips[i]) { 912 + dev_warn(&pdev->dev, "GPIO chip %d not registered yet\n", i); 913 + devm_kfree(&pdev->dev, info); 914 + return -EPROBE_DEFER; 915 + } 916 + } 917 + 918 + at91_pinctrl_desc.name = dev_name(&pdev->dev); 919 + at91_pinctrl_desc.npins = info->nbanks * MAX_NB_GPIO_PER_BANK; 920 + at91_pinctrl_desc.pins = pdesc = 921 + devm_kzalloc(&pdev->dev, sizeof(*pdesc) * at91_pinctrl_desc.npins, GFP_KERNEL); 922 + 923 + if (!at91_pinctrl_desc.pins) 924 + return -ENOMEM; 925 + 926 + for (i = 0 , k = 0; i < info->nbanks; i++) { 927 + for (j = 0; j < MAX_NB_GPIO_PER_BANK; j++, k++) { 928 + pdesc->number = k; 929 + pdesc->name = kasprintf(GFP_KERNEL, "pio%c%d", i + 'A', j); 930 + pdesc++; 931 + } 932 + } 933 + 934 + platform_set_drvdata(pdev, info); 935 + info->pctl = pinctrl_register(&at91_pinctrl_desc, &pdev->dev, info); 936 + 937 + if (!info->pctl) { 938 + dev_err(&pdev->dev, "could not register AT91 pinctrl driver\n"); 939 + ret = -EINVAL; 940 + goto err; 941 + } 942 + 943 + /* We will handle a range of GPIO pins */ 944 + for (i = 0; i < info->nbanks; i++) 945 + pinctrl_add_gpio_range(info->pctl, &gpio_chips[i]->range); 946 + 947 + dev_info(&pdev->dev, "initialized AT91 pinctrl driver\n"); 948 + 949 + return 0; 950 + 951 + err: 952 + return ret; 953 + } 954 + 955 + static int __devexit at91_pinctrl_remove(struct platform_device *pdev) 956 + { 957 + struct at91_pinctrl *info = platform_get_drvdata(pdev); 958 + 959 + pinctrl_unregister(info->pctl); 960 + 961 + return 0; 962 + } 963 + 964 + static int at91_gpio_request(struct gpio_chip *chip, unsigned offset) 965 + { 966 + /* 967 + * Map back to global GPIO space and request muxing, the direction 968 + * parameter does not matter for this controller. 969 + */ 970 + int gpio = chip->base + offset; 971 + int bank = chip->base / chip->ngpio; 972 + 973 + dev_dbg(chip->dev, "%s:%d pio%c%d(%d)\n", __func__, __LINE__, 974 + 'A' + bank, offset, gpio); 975 + 976 + return pinctrl_request_gpio(gpio); 977 + } 978 + 979 + static void at91_gpio_free(struct gpio_chip *chip, unsigned offset) 980 + { 981 + int gpio = chip->base + offset; 982 + 983 + pinctrl_free_gpio(gpio); 984 + } 985 + 986 + static int at91_gpio_direction_input(struct gpio_chip *chip, unsigned offset) 987 + { 988 + struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); 989 + void __iomem *pio = at91_gpio->regbase; 990 + unsigned mask = 1 << offset; 991 + 992 + writel_relaxed(mask, pio + PIO_ODR); 993 + return 0; 994 + } 995 + 996 + static int at91_gpio_get(struct gpio_chip *chip, unsigned offset) 997 + { 998 + struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); 999 + void __iomem *pio = at91_gpio->regbase; 1000 + unsigned mask = 1 << offset; 1001 + u32 pdsr; 1002 + 1003 + pdsr = readl_relaxed(pio + PIO_PDSR); 1004 + return (pdsr & mask) != 0; 1005 + } 1006 + 1007 + static void at91_gpio_set(struct gpio_chip *chip, unsigned offset, 1008 + int val) 1009 + { 1010 + struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); 1011 + void __iomem *pio = at91_gpio->regbase; 1012 + unsigned mask = 1 << offset; 1013 + 1014 + writel_relaxed(mask, pio + (val ? PIO_SODR : PIO_CODR)); 1015 + } 1016 + 1017 + static int at91_gpio_direction_output(struct gpio_chip *chip, unsigned offset, 1018 + int val) 1019 + { 1020 + struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); 1021 + void __iomem *pio = at91_gpio->regbase; 1022 + unsigned mask = 1 << offset; 1023 + 1024 + writel_relaxed(mask, pio + (val ? PIO_SODR : PIO_CODR)); 1025 + writel_relaxed(mask, pio + PIO_OER); 1026 + 1027 + return 0; 1028 + } 1029 + 1030 + static int at91_gpio_to_irq(struct gpio_chip *chip, unsigned offset) 1031 + { 1032 + struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); 1033 + int virq; 1034 + 1035 + if (offset < chip->ngpio) 1036 + virq = irq_create_mapping(at91_gpio->domain, offset); 1037 + else 1038 + virq = -ENXIO; 1039 + 1040 + dev_dbg(chip->dev, "%s: request IRQ for GPIO %d, return %d\n", 1041 + chip->label, offset + chip->base, virq); 1042 + return virq; 1043 + } 1044 + 1045 + #ifdef CONFIG_DEBUG_FS 1046 + static void at91_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) 1047 + { 1048 + enum at91_mux mode; 1049 + int i; 1050 + struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); 1051 + void __iomem *pio = at91_gpio->regbase; 1052 + 1053 + for (i = 0; i < chip->ngpio; i++) { 1054 + unsigned pin = chip->base + i; 1055 + unsigned mask = pin_to_mask(pin); 1056 + const char *gpio_label; 1057 + u32 pdsr; 1058 + 1059 + gpio_label = gpiochip_is_requested(chip, i); 1060 + if (!gpio_label) 1061 + continue; 1062 + mode = at91_gpio->ops->get_periph(pio, mask); 1063 + seq_printf(s, "[%s] GPIO%s%d: ", 1064 + gpio_label, chip->label, i); 1065 + if (mode == AT91_MUX_GPIO) { 1066 + pdsr = readl_relaxed(pio + PIO_PDSR); 1067 + 1068 + seq_printf(s, "[gpio] %s\n", 1069 + pdsr & mask ? 1070 + "set" : "clear"); 1071 + } else { 1072 + seq_printf(s, "[periph %c]\n", 1073 + mode + 'A' - 1); 1074 + } 1075 + } 1076 + } 1077 + #else 1078 + #define at91_gpio_dbg_show NULL 1079 + #endif 1080 + 1081 + /* Several AIC controller irqs are dispatched through this GPIO handler. 1082 + * To use any AT91_PIN_* as an externally triggered IRQ, first call 1083 + * at91_set_gpio_input() then maybe enable its glitch filter. 1084 + * Then just request_irq() with the pin ID; it works like any ARM IRQ 1085 + * handler. 1086 + * First implementation always triggers on rising and falling edges 1087 + * whereas the newer PIO3 can be additionally configured to trigger on 1088 + * level, edge with any polarity. 1089 + * 1090 + * Alternatively, certain pins may be used directly as IRQ0..IRQ6 after 1091 + * configuring them with at91_set_a_periph() or at91_set_b_periph(). 1092 + * IRQ0..IRQ6 should be configurable, e.g. level vs edge triggering. 1093 + */ 1094 + 1095 + static void gpio_irq_mask(struct irq_data *d) 1096 + { 1097 + struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d); 1098 + void __iomem *pio = at91_gpio->regbase; 1099 + unsigned mask = 1 << d->hwirq; 1100 + 1101 + if (pio) 1102 + writel_relaxed(mask, pio + PIO_IDR); 1103 + } 1104 + 1105 + static void gpio_irq_unmask(struct irq_data *d) 1106 + { 1107 + struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d); 1108 + void __iomem *pio = at91_gpio->regbase; 1109 + unsigned mask = 1 << d->hwirq; 1110 + 1111 + if (pio) 1112 + writel_relaxed(mask, pio + PIO_IER); 1113 + } 1114 + 1115 + static int gpio_irq_type(struct irq_data *d, unsigned type) 1116 + { 1117 + switch (type) { 1118 + case IRQ_TYPE_NONE: 1119 + case IRQ_TYPE_EDGE_BOTH: 1120 + return 0; 1121 + default: 1122 + return -EINVAL; 1123 + } 1124 + } 1125 + 1126 + /* Alternate irq type for PIO3 support */ 1127 + static int alt_gpio_irq_type(struct irq_data *d, unsigned type) 1128 + { 1129 + struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d); 1130 + void __iomem *pio = at91_gpio->regbase; 1131 + unsigned mask = 1 << d->hwirq; 1132 + 1133 + switch (type) { 1134 + case IRQ_TYPE_EDGE_RISING: 1135 + writel_relaxed(mask, pio + PIO_ESR); 1136 + writel_relaxed(mask, pio + PIO_REHLSR); 1137 + break; 1138 + case IRQ_TYPE_EDGE_FALLING: 1139 + writel_relaxed(mask, pio + PIO_ESR); 1140 + writel_relaxed(mask, pio + PIO_FELLSR); 1141 + break; 1142 + case IRQ_TYPE_LEVEL_LOW: 1143 + writel_relaxed(mask, pio + PIO_LSR); 1144 + writel_relaxed(mask, pio + PIO_FELLSR); 1145 + break; 1146 + case IRQ_TYPE_LEVEL_HIGH: 1147 + writel_relaxed(mask, pio + PIO_LSR); 1148 + writel_relaxed(mask, pio + PIO_REHLSR); 1149 + break; 1150 + case IRQ_TYPE_EDGE_BOTH: 1151 + /* 1152 + * disable additional interrupt modes: 1153 + * fall back to default behavior 1154 + */ 1155 + writel_relaxed(mask, pio + PIO_AIMDR); 1156 + return 0; 1157 + case IRQ_TYPE_NONE: 1158 + default: 1159 + pr_warn("AT91: No type for irq %d\n", gpio_to_irq(d->irq)); 1160 + return -EINVAL; 1161 + } 1162 + 1163 + /* enable additional interrupt modes */ 1164 + writel_relaxed(mask, pio + PIO_AIMER); 1165 + 1166 + return 0; 1167 + } 1168 + 1169 + #ifdef CONFIG_PM 1170 + static int gpio_irq_set_wake(struct irq_data *d, unsigned state) 1171 + { 1172 + struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d); 1173 + unsigned bank = at91_gpio->pioc_idx; 1174 + 1175 + if (unlikely(bank >= MAX_GPIO_BANKS)) 1176 + return -EINVAL; 1177 + 1178 + irq_set_irq_wake(at91_gpio->pioc_virq, state); 1179 + 1180 + return 0; 1181 + } 1182 + #else 1183 + #define gpio_irq_set_wake NULL 1184 + #endif 1185 + 1186 + static struct irq_chip gpio_irqchip = { 1187 + .name = "GPIO", 1188 + .irq_disable = gpio_irq_mask, 1189 + .irq_mask = gpio_irq_mask, 1190 + .irq_unmask = gpio_irq_unmask, 1191 + /* .irq_set_type is set dynamically */ 1192 + .irq_set_wake = gpio_irq_set_wake, 1193 + }; 1194 + 1195 + static void gpio_irq_handler(unsigned irq, struct irq_desc *desc) 1196 + { 1197 + struct irq_chip *chip = irq_desc_get_chip(desc); 1198 + struct irq_data *idata = irq_desc_get_irq_data(desc); 1199 + struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(idata); 1200 + void __iomem *pio = at91_gpio->regbase; 1201 + unsigned long isr; 1202 + int n; 1203 + 1204 + chained_irq_enter(chip, desc); 1205 + for (;;) { 1206 + /* Reading ISR acks pending (edge triggered) GPIO interrupts. 1207 + * When there none are pending, we're finished unless we need 1208 + * to process multiple banks (like ID_PIOCDE on sam9263). 1209 + */ 1210 + isr = readl_relaxed(pio + PIO_ISR) & readl_relaxed(pio + PIO_IMR); 1211 + if (!isr) { 1212 + if (!at91_gpio->next) 1213 + break; 1214 + at91_gpio = at91_gpio->next; 1215 + pio = at91_gpio->regbase; 1216 + continue; 1217 + } 1218 + 1219 + for_each_set_bit(n, &isr, BITS_PER_LONG) { 1220 + generic_handle_irq(irq_find_mapping(at91_gpio->domain, n)); 1221 + } 1222 + } 1223 + chained_irq_exit(chip, desc); 1224 + /* now it may re-trigger */ 1225 + } 1226 + 1227 + /* 1228 + * This lock class tells lockdep that GPIO irqs are in a different 1229 + * category than their parents, so it won't report false recursion. 1230 + */ 1231 + static struct lock_class_key gpio_lock_class; 1232 + 1233 + static int at91_gpio_irq_map(struct irq_domain *h, unsigned int virq, 1234 + irq_hw_number_t hw) 1235 + { 1236 + struct at91_gpio_chip *at91_gpio = h->host_data; 1237 + 1238 + irq_set_lockdep_class(virq, &gpio_lock_class); 1239 + 1240 + /* 1241 + * Can use the "simple" and not "edge" handler since it's 1242 + * shorter, and the AIC handles interrupts sanely. 1243 + */ 1244 + irq_set_chip_and_handler(virq, &gpio_irqchip, 1245 + handle_simple_irq); 1246 + set_irq_flags(virq, IRQF_VALID); 1247 + irq_set_chip_data(virq, at91_gpio); 1248 + 1249 + return 0; 1250 + } 1251 + 1252 + static int at91_gpio_irq_domain_xlate(struct irq_domain *d, 1253 + struct device_node *ctrlr, 1254 + const u32 *intspec, unsigned int intsize, 1255 + irq_hw_number_t *out_hwirq, 1256 + unsigned int *out_type) 1257 + { 1258 + struct at91_gpio_chip *at91_gpio = d->host_data; 1259 + int ret; 1260 + int pin = at91_gpio->chip.base + intspec[0]; 1261 + 1262 + if (WARN_ON(intsize < 2)) 1263 + return -EINVAL; 1264 + *out_hwirq = intspec[0]; 1265 + *out_type = intspec[1] & IRQ_TYPE_SENSE_MASK; 1266 + 1267 + ret = gpio_request(pin, ctrlr->full_name); 1268 + if (ret) 1269 + return ret; 1270 + 1271 + ret = gpio_direction_input(pin); 1272 + if (ret) 1273 + return ret; 1274 + 1275 + return 0; 1276 + } 1277 + 1278 + static struct irq_domain_ops at91_gpio_ops = { 1279 + .map = at91_gpio_irq_map, 1280 + .xlate = at91_gpio_irq_domain_xlate, 1281 + }; 1282 + 1283 + static int at91_gpio_of_irq_setup(struct device_node *node, 1284 + struct at91_gpio_chip *at91_gpio) 1285 + { 1286 + struct at91_gpio_chip *prev = NULL; 1287 + struct irq_data *d = irq_get_irq_data(at91_gpio->pioc_virq); 1288 + 1289 + at91_gpio->pioc_hwirq = irqd_to_hwirq(d); 1290 + 1291 + /* Setup proper .irq_set_type function */ 1292 + gpio_irqchip.irq_set_type = at91_gpio->ops->irq_type; 1293 + 1294 + /* Disable irqs of this PIO controller */ 1295 + writel_relaxed(~0, at91_gpio->regbase + PIO_IDR); 1296 + 1297 + /* Setup irq domain */ 1298 + at91_gpio->domain = irq_domain_add_linear(node, at91_gpio->chip.ngpio, 1299 + &at91_gpio_ops, at91_gpio); 1300 + if (!at91_gpio->domain) 1301 + panic("at91_gpio.%d: couldn't allocate irq domain (DT).\n", 1302 + at91_gpio->pioc_idx); 1303 + 1304 + /* Setup chained handler */ 1305 + if (at91_gpio->pioc_idx) 1306 + prev = gpio_chips[at91_gpio->pioc_idx - 1]; 1307 + 1308 + /* The toplevel handler handles one bank of GPIOs, except 1309 + * on some SoC it can handles up to three... 1310 + * We only set up the handler for the first of the list. 1311 + */ 1312 + if (prev && prev->next == at91_gpio) 1313 + return 0; 1314 + 1315 + irq_set_chip_data(at91_gpio->pioc_virq, at91_gpio); 1316 + irq_set_chained_handler(at91_gpio->pioc_virq, gpio_irq_handler); 1317 + 1318 + return 0; 1319 + } 1320 + 1321 + /* This structure is replicated for each GPIO block allocated at probe time */ 1322 + static struct gpio_chip at91_gpio_template = { 1323 + .request = at91_gpio_request, 1324 + .free = at91_gpio_free, 1325 + .direction_input = at91_gpio_direction_input, 1326 + .get = at91_gpio_get, 1327 + .direction_output = at91_gpio_direction_output, 1328 + .set = at91_gpio_set, 1329 + .to_irq = at91_gpio_to_irq, 1330 + .dbg_show = at91_gpio_dbg_show, 1331 + .can_sleep = 0, 1332 + .ngpio = MAX_NB_GPIO_PER_BANK, 1333 + }; 1334 + 1335 + static void __devinit at91_gpio_probe_fixup(void) 1336 + { 1337 + unsigned i; 1338 + struct at91_gpio_chip *at91_gpio, *last = NULL; 1339 + 1340 + for (i = 0; i < gpio_banks; i++) { 1341 + at91_gpio = gpio_chips[i]; 1342 + 1343 + /* 1344 + * GPIO controller are grouped on some SoC: 1345 + * PIOC, PIOD and PIOE can share the same IRQ line 1346 + */ 1347 + if (last && last->pioc_virq == at91_gpio->pioc_virq) 1348 + last->next = at91_gpio; 1349 + last = at91_gpio; 1350 + } 1351 + } 1352 + 1353 + static struct of_device_id at91_gpio_of_match[] __devinitdata = { 1354 + { .compatible = "atmel,at91sam9x5-gpio", .data = &at91sam9x5_ops, }, 1355 + { .compatible = "atmel,at91rm9200-gpio", .data = &at91rm9200_ops }, 1356 + { /* sentinel */ } 1357 + }; 1358 + 1359 + static int __devinit at91_gpio_probe(struct platform_device *pdev) 1360 + { 1361 + struct device_node *np = pdev->dev.of_node; 1362 + struct resource *res; 1363 + struct at91_gpio_chip *at91_chip = NULL; 1364 + struct gpio_chip *chip; 1365 + struct pinctrl_gpio_range *range; 1366 + int ret = 0; 1367 + int irq; 1368 + int alias_idx = of_alias_get_id(np, "gpio"); 1369 + uint32_t ngpio; 1370 + 1371 + BUG_ON(alias_idx >= ARRAY_SIZE(gpio_chips)); 1372 + if (gpio_chips[alias_idx]) { 1373 + ret = -EBUSY; 1374 + goto err; 1375 + } 1376 + 1377 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1378 + if (!res) { 1379 + ret = -ENOENT; 1380 + goto err; 1381 + } 1382 + 1383 + irq = platform_get_irq(pdev, 0); 1384 + if (irq < 0) { 1385 + ret = irq; 1386 + goto err; 1387 + } 1388 + 1389 + at91_chip = devm_kzalloc(&pdev->dev, sizeof(*at91_chip), GFP_KERNEL); 1390 + if (!at91_chip) { 1391 + ret = -ENOMEM; 1392 + goto err; 1393 + } 1394 + 1395 + at91_chip->regbase = devm_request_and_ioremap(&pdev->dev, res); 1396 + if (!at91_chip->regbase) { 1397 + dev_err(&pdev->dev, "failed to map registers, ignoring.\n"); 1398 + ret = -EBUSY; 1399 + goto err; 1400 + } 1401 + 1402 + at91_chip->ops = (struct at91_pinctrl_mux_ops*) 1403 + of_match_device(at91_gpio_of_match, &pdev->dev)->data; 1404 + at91_chip->pioc_virq = irq; 1405 + at91_chip->pioc_idx = alias_idx; 1406 + 1407 + at91_chip->clock = clk_get(&pdev->dev, NULL); 1408 + if (IS_ERR(at91_chip->clock)) { 1409 + dev_err(&pdev->dev, "failed to get clock, ignoring.\n"); 1410 + goto err; 1411 + } 1412 + 1413 + if (clk_prepare(at91_chip->clock)) 1414 + goto clk_prep_err; 1415 + 1416 + /* enable PIO controller's clock */ 1417 + if (clk_enable(at91_chip->clock)) { 1418 + dev_err(&pdev->dev, "failed to enable clock, ignoring.\n"); 1419 + goto clk_err; 1420 + } 1421 + 1422 + at91_chip->chip = at91_gpio_template; 1423 + 1424 + chip = &at91_chip->chip; 1425 + chip->of_node = np; 1426 + chip->label = dev_name(&pdev->dev); 1427 + chip->dev = &pdev->dev; 1428 + chip->owner = THIS_MODULE; 1429 + chip->base = alias_idx * MAX_NB_GPIO_PER_BANK; 1430 + 1431 + if (!of_property_read_u32(np, "#gpio-lines", &ngpio)) { 1432 + if (ngpio >= MAX_NB_GPIO_PER_BANK) 1433 + pr_err("at91_gpio.%d, gpio-nb >= %d failback to %d\n", 1434 + alias_idx, MAX_NB_GPIO_PER_BANK, MAX_NB_GPIO_PER_BANK); 1435 + else 1436 + chip->ngpio = ngpio; 1437 + } 1438 + 1439 + range = &at91_chip->range; 1440 + range->name = chip->label; 1441 + range->id = alias_idx; 1442 + range->pin_base = range->base = range->id * MAX_NB_GPIO_PER_BANK; 1443 + 1444 + range->npins = chip->ngpio; 1445 + range->gc = chip; 1446 + 1447 + ret = gpiochip_add(chip); 1448 + if (ret) 1449 + goto clk_err; 1450 + 1451 + gpio_chips[alias_idx] = at91_chip; 1452 + gpio_banks = max(gpio_banks, alias_idx + 1); 1453 + 1454 + at91_gpio_probe_fixup(); 1455 + 1456 + at91_gpio_of_irq_setup(np, at91_chip); 1457 + 1458 + dev_info(&pdev->dev, "at address %p\n", at91_chip->regbase); 1459 + 1460 + return 0; 1461 + 1462 + clk_err: 1463 + clk_unprepare(at91_chip->clock); 1464 + clk_prep_err: 1465 + clk_put(at91_chip->clock); 1466 + err: 1467 + dev_err(&pdev->dev, "Failure %i for GPIO %i\n", ret, alias_idx); 1468 + 1469 + return ret; 1470 + } 1471 + 1472 + static struct platform_driver at91_gpio_driver = { 1473 + .driver = { 1474 + .name = "gpio-at91", 1475 + .owner = THIS_MODULE, 1476 + .of_match_table = of_match_ptr(at91_gpio_of_match), 1477 + }, 1478 + .probe = at91_gpio_probe, 1479 + }; 1480 + 1481 + static struct platform_driver at91_pinctrl_driver = { 1482 + .driver = { 1483 + .name = "pinctrl-at91", 1484 + .owner = THIS_MODULE, 1485 + .of_match_table = of_match_ptr(at91_pinctrl_of_match), 1486 + }, 1487 + .probe = at91_pinctrl_probe, 1488 + .remove = __devexit_p(at91_pinctrl_remove), 1489 + }; 1490 + 1491 + static int __init at91_pinctrl_init(void) 1492 + { 1493 + int ret; 1494 + 1495 + ret = platform_driver_register(&at91_gpio_driver); 1496 + if (ret) 1497 + return ret; 1498 + return platform_driver_register(&at91_pinctrl_driver); 1499 + } 1500 + arch_initcall(at91_pinctrl_init); 1501 + 1502 + static void __exit at91_pinctrl_exit(void) 1503 + { 1504 + platform_driver_unregister(&at91_pinctrl_driver); 1505 + } 1506 + 1507 + module_exit(at91_pinctrl_exit); 1508 + MODULE_AUTHOR("Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>"); 1509 + MODULE_DESCRIPTION("Atmel AT91 pinctrl driver"); 1510 + MODULE_LICENSE("GPL v2");
+8
drivers/tty/serial/atmel_serial.c
··· 39 39 #include <linux/atmel_pdc.h> 40 40 #include <linux/atmel_serial.h> 41 41 #include <linux/uaccess.h> 42 + #include <linux/pinctrl/consumer.h> 42 43 43 44 #include <asm/io.h> 44 45 #include <asm/ioctls.h> ··· 1774 1773 struct atmel_uart_data *pdata = pdev->dev.platform_data; 1775 1774 void *data; 1776 1775 int ret = -ENODEV; 1776 + struct pinctrl *pinctrl; 1777 1777 1778 1778 BUILD_BUG_ON(ATMEL_SERIAL_RINGSIZE & (ATMEL_SERIAL_RINGSIZE - 1)); 1779 1779 ··· 1806 1804 port->uart.line = ret; 1807 1805 1808 1806 atmel_init_port(port, pdev); 1807 + 1808 + pinctrl = devm_pinctrl_get_select_default(&pdev->dev); 1809 + if (IS_ERR(pinctrl)) { 1810 + ret = PTR_ERR(pinctrl); 1811 + goto err; 1812 + } 1809 1813 1810 1814 if (!atmel_use_dma_rx(&port->uart)) { 1811 1815 ret = -ENOMEM;