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

ARM: pxa: change gpio to platform device

Remove most gpio macros and change gpio driver to platform driver.

Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>

authored by

Haojian Zhuang and committed by
Haojian Zhuang
157d2644 9bf448c6

+271 -233
+2
arch/arm/Kconfig
··· 591 591 select ARCH_REQUIRE_GPIOLIB 592 592 select CLKDEV_LOOKUP 593 593 select GENERIC_CLOCKEVENTS 594 + select GPIO_PXA 594 595 select HAVE_SCHED_CLOCK 595 596 select TICK_ONESHOT 596 597 select PLAT_PXA ··· 674 673 select CLKSRC_MMIO 675 674 select ARCH_REQUIRE_GPIOLIB 676 675 select GENERIC_CLOCKEVENTS 676 + select GPIO_PXA 677 677 select HAVE_SCHED_CLOCK 678 678 select TICK_ONESHOT 679 679 select PLAT_PXA
+1
arch/arm/mach-mmp/aspenite.c
··· 231 231 pxa168_add_nand(&aspenite_nand_info); 232 232 pxa168_add_fb(&aspenite_lcd_info); 233 233 pxa168_add_keypad(&aspenite_keypad_info); 234 + platform_device_register(&pxa168_device_gpio); 234 235 235 236 /* off-chip devices */ 236 237 platform_device_register(&smc91x_device);
+1
arch/arm/mach-mmp/avengers_lite.c
··· 38 38 39 39 /* on-chip devices */ 40 40 pxa168_add_uart(2); 41 + platform_device_register(&pxa168_device_gpio); 41 42 } 42 43 43 44 MACHINE_START(AVENGERS_LITE, "PXA168 Avengers lite Development Platform")
+1
arch/arm/mach-mmp/brownstone.c
··· 202 202 /* on-chip devices */ 203 203 mmp2_add_uart(1); 204 204 mmp2_add_uart(3); 205 + platform_device_register(&mmp2_device_gpio); 205 206 mmp2_add_twsi(1, NULL, ARRAY_AND_SIZE(brownstone_twsi1_info)); 206 207 mmp2_add_sdhost(0, &mmp2_sdh_platdata_mmc0); /* SD/MMC */ 207 208 mmp2_add_sdhost(2, &mmp2_sdh_platdata_mmc2); /* eMMC */
+1
arch/arm/mach-mmp/flint.c
··· 110 110 /* on-chip devices */ 111 111 mmp2_add_uart(1); 112 112 mmp2_add_uart(2); 113 + platform_device_register(&mmp2_device_gpio); 113 114 114 115 /* off-chip devices */ 115 116 platform_device_register(&smc91x_device);
+1
arch/arm/mach-mmp/gplugd.c
··· 184 184 pxa168_add_uart(3); 185 185 pxa168_add_ssp(0); 186 186 pxa168_add_twsi(0, NULL, ARRAY_AND_SIZE(gplugd_i2c_board_info)); 187 + platform_device_register(&pxa168_device_gpio); 187 188 188 189 pxa168_add_eth(&gplugd_eth_platform_data); 189 190 }
+1 -2
arch/arm/mach-mmp/include/mach/gpio.h
··· 3 3 4 4 #include <asm-generic/gpio.h> 5 5 6 - #define __gpio_is_inverted(gpio) (0) 7 - #define __gpio_is_occupied(gpio) (0) 6 + #include <mach/cputype.h> 8 7 9 8 #endif /* __ASM_MACH_GPIO_H */
+2
arch/arm/mach-mmp/include/mach/mmp2.h
··· 32 32 extern struct pxa_device_desc mmp2_device_asram; 33 33 extern struct pxa_device_desc mmp2_device_isram; 34 34 35 + extern struct platform_device mmp2_device_gpio; 36 + 35 37 static inline int mmp2_add_uart(int id) 36 38 { 37 39 struct pxa_device_desc *d = NULL;
+2
arch/arm/mach-mmp/include/mach/pxa168.h
··· 42 42 /* pdata can be NULL */ 43 43 int __init pxa168_add_usb_host(struct pxa168_usb_pdata *pdata); 44 44 45 + extern struct platform_device pxa168_device_gpio; 46 + 45 47 static inline int pxa168_add_uart(int id) 46 48 { 47 49 struct pxa_device_desc *d = NULL;
+2
arch/arm/mach-mmp/include/mach/pxa910.h
··· 21 21 extern struct pxa_device_desc pxa910_device_pwm4; 22 22 extern struct pxa_device_desc pxa910_device_nand; 23 23 24 + extern struct platform_device pxa910_device_gpio; 25 + 24 26 static inline int pxa910_add_uart(int id) 25 27 { 26 28 struct pxa_device_desc *d = NULL;
+19 -9
arch/arm/mach-mmp/mmp2.c
··· 13 13 #include <linux/kernel.h> 14 14 #include <linux/init.h> 15 15 #include <linux/io.h> 16 + #include <linux/platform_device.h> 16 17 17 18 #include <asm/hardware/cache-tauros2.h> 18 19 ··· 25 24 #include <mach/irqs.h> 26 25 #include <mach/dma.h> 27 26 #include <mach/mfp.h> 28 - #include <mach/gpio-pxa.h> 29 27 #include <mach/devices.h> 30 28 #include <mach/mmp2.h> 31 29 ··· 32 32 #include "clock.h" 33 33 34 34 #define MFPR_VIRT_BASE (APB_VIRT_BASE + 0x1e000) 35 - 36 - #define APMASK(i) (GPIO_REGS_VIRT + BANK_OFF(i) + 0x9c) 37 35 38 36 static struct mfp_addr_map mmp2_addr_map[] __initdata = { 39 37 ··· 99 101 100 102 /* enable GPIO clock */ 101 103 __raw_writel(APBC_APBCLK | APBC_FNCLK, APBC_MMP2_GPIO); 102 - 103 - /* unmask GPIO edge detection for all 6 banks -- APMASKx */ 104 - for (i = 0; i < 6; i++) 105 - __raw_writel(0xffffffff, APMASK(i)); 106 - 107 - pxa_init_gpio(IRQ_MMP2_GPIO, 0, 167, NULL); 108 104 } 109 105 110 106 void __init mmp2_init_irq(void) ··· 222 230 /* 0xd1000000 ~ 0xd101ffff is reserved for secure processor */ 223 231 MMP2_DEVICE(isram, "isram", -1, NONE, 0xd1020000, 0x18000); 224 232 233 + struct resource mmp2_resource_gpio[] = { 234 + { 235 + .start = 0xd4019000, 236 + .end = 0xd4019fff, 237 + .flags = IORESOURCE_MEM, 238 + }, { 239 + .start = IRQ_MMP2_GPIO, 240 + .end = IRQ_MMP2_GPIO, 241 + .flags = IORESOURCE_IRQ, 242 + }, 243 + }; 244 + 245 + struct platform_device mmp2_device_gpio = { 246 + .name = "pxa-gpio", 247 + .id = -1, 248 + .num_resources = ARRAY_SIZE(mmp2_resource_gpio), 249 + .resource = mmp2_resource_gpio, 250 + };
+20 -9
arch/arm/mach-mmp/pxa168.c
··· 13 13 #include <linux/list.h> 14 14 #include <linux/io.h> 15 15 #include <linux/clk.h> 16 + #include <linux/platform_device.h> 16 17 17 18 #include <asm/mach/time.h> 18 19 #include <mach/addr-map.h> ··· 21 20 #include <mach/regs-apbc.h> 22 21 #include <mach/regs-apmu.h> 23 22 #include <mach/irqs.h> 24 - #include <mach/gpio-pxa.h> 25 23 #include <mach/dma.h> 26 24 #include <mach/devices.h> 27 25 #include <mach/mfp.h> ··· 43 43 MFP_ADDR_END, 44 44 }; 45 45 46 - #define APMASK(i) (GPIO_REGS_VIRT + BANK_OFF(i) + 0x09c) 47 - 48 46 static void __init pxa168_init_gpio(void) 49 47 { 50 48 int i; 51 49 52 50 /* enable GPIO clock */ 53 51 __raw_writel(APBC_APBCLK | APBC_FNCLK, APBC_PXA168_GPIO); 54 - 55 - /* unmask GPIO edge detection for all 4 banks - APMASKx */ 56 - for (i = 0; i < 4; i++) 57 - __raw_writel(0xffffffff, APMASK(i)); 58 - 59 - pxa_init_gpio(IRQ_PXA168_GPIOX, 0, 127, NULL); 60 52 } 61 53 62 54 void __init pxa168_init_irq(void) ··· 165 173 PXA168_DEVICE(fb, "pxa168-fb", -1, LCD, 0xd420b000, 0x1c8); 166 174 PXA168_DEVICE(keypad, "pxa27x-keypad", -1, KEYPAD, 0xd4012000, 0x4c); 167 175 PXA168_DEVICE(eth, "pxa168-eth", -1, MFU, 0xc0800000, 0x0fff); 176 + 177 + struct resource pxa168_resource_gpio[] = { 178 + { 179 + .start = 0xd4019000, 180 + .end = 0xd4019fff, 181 + .flags = IORESOURCE_MEM, 182 + }, { 183 + .start = IRQ_PXA168_GPIOX, 184 + .end = IRQ_PXA168_GPIOX, 185 + .flags = IORESOURCE_IRQ, 186 + }, 187 + }; 188 + 189 + struct platform_device pxa168_device_gpio = { 190 + .name = "pxa-gpio", 191 + .id = -1, 192 + .num_resources = ARRAY_SIZE(pxa168_resource_gpio), 193 + .resource = pxa168_resource_gpio, 194 + }; 168 195 169 196 struct resource pxa168_usb_host_resources[] = { 170 197 /* USB Host conroller register base */
+20 -9
arch/arm/mach-mmp/pxa910.c
··· 12 12 #include <linux/init.h> 13 13 #include <linux/list.h> 14 14 #include <linux/io.h> 15 + #include <linux/platform_device.h> 15 16 16 17 #include <asm/mach/time.h> 17 18 #include <mach/addr-map.h> ··· 20 19 #include <mach/regs-apmu.h> 21 20 #include <mach/cputype.h> 22 21 #include <mach/irqs.h> 23 - #include <mach/gpio-pxa.h> 24 22 #include <mach/dma.h> 25 23 #include <mach/mfp.h> 26 24 #include <mach/devices.h> ··· 77 77 MFP_ADDR_END, 78 78 }; 79 79 80 - #define APMASK(i) (GPIO_REGS_VIRT + BANK_OFF(i) + 0x09c) 81 - 82 80 static void __init pxa910_init_gpio(void) 83 81 { 84 82 int i; 85 83 86 84 /* enable GPIO clock */ 87 85 __raw_writel(APBC_APBCLK | APBC_FNCLK, APBC_PXA910_GPIO); 88 - 89 - /* unmask GPIO edge detection for all 4 banks - APMASKx */ 90 - for (i = 0; i < 4; i++) 91 - __raw_writel(0xffffffff, APMASK(i)); 92 - 93 - pxa_init_gpio(IRQ_PXA910_AP_GPIO, 0, 127, NULL); 94 86 } 95 87 96 88 void __init pxa910_init_irq(void) ··· 171 179 PXA910_DEVICE(pwm3, "pxa910-pwm", 2, NONE, 0xd401a800, 0x10); 172 180 PXA910_DEVICE(pwm4, "pxa910-pwm", 3, NONE, 0xd401ac00, 0x10); 173 181 PXA910_DEVICE(nand, "pxa3xx-nand", -1, NAND, 0xd4283000, 0x80, 97, 99); 182 + 183 + struct resource pxa910_resource_gpio[] = { 184 + { 185 + .start = 0xd4019000, 186 + .end = 0xd4019fff, 187 + .flags = IORESOURCE_MEM, 188 + }, { 189 + .start = IRQ_PXA910_AP_GPIO, 190 + .end = IRQ_PXA910_AP_GPIO, 191 + .flags = IORESOURCE_IRQ, 192 + }, 193 + }; 194 + 195 + struct platform_device pxa910_device_gpio = { 196 + .name = "pxa-gpio", 197 + .id = -1, 198 + .num_resources = ARRAY_SIZE(pxa910_resource_gpio), 199 + .resource = pxa910_resource_gpio, 200 + };
+1
arch/arm/mach-mmp/tavorevb.c
··· 94 94 95 95 /* on-chip devices */ 96 96 pxa910_add_uart(1); 97 + platform_device_register(&pxa910_device_gpio); 97 98 98 99 /* off-chip devices */ 99 100 platform_device_register(&smc91x_device);
+1
arch/arm/mach-mmp/teton_bga.c
··· 78 78 pxa168_add_uart(1); 79 79 pxa168_add_keypad(&teton_bga_keypad_info); 80 80 pxa168_add_twsi(0, NULL, ARRAY_AND_SIZE(teton_bga_i2c_info)); 81 + platform_device_register(&pxa168_device_gpio); 81 82 } 82 83 83 84 MACHINE_START(TETON_BGA, "PXA168-based Teton BGA Development Platform")
+1
arch/arm/mach-mmp/ttc_dkb.c
··· 123 123 }; 124 124 125 125 static struct platform_device *ttc_dkb_devices[] = { 126 + &pxa910_device_gpio, 126 127 &ttc_dkb_device_onenand, 127 128 }; 128 129
+30
arch/arm/mach-pxa/devices.c
··· 1051 1051 }; 1052 1052 #endif /* CONFIG_PXA3xx || CONFIG_PXA95x */ 1053 1053 1054 + struct resource pxa_resource_gpio[] = { 1055 + { 1056 + .start = 0x40e00000, 1057 + .end = 0x40e0ffff, 1058 + .flags = IORESOURCE_MEM, 1059 + }, { 1060 + .start = IRQ_GPIO0, 1061 + .end = IRQ_GPIO0, 1062 + .name = "gpio0", 1063 + .flags = IORESOURCE_IRQ, 1064 + }, { 1065 + .start = IRQ_GPIO1, 1066 + .end = IRQ_GPIO1, 1067 + .name = "gpio1", 1068 + .flags = IORESOURCE_IRQ, 1069 + }, { 1070 + .start = IRQ_GPIO_2_x, 1071 + .end = IRQ_GPIO_2_x, 1072 + .name = "gpio_mux", 1073 + .flags = IORESOURCE_IRQ, 1074 + }, 1075 + }; 1076 + 1077 + struct platform_device pxa_device_gpio = { 1078 + .name = "pxa-gpio", 1079 + .id = -1, 1080 + .num_resources = ARRAY_SIZE(pxa_resource_gpio), 1081 + .resource = pxa_resource_gpio, 1082 + }; 1083 + 1054 1084 /* pxa2xx-spi platform-device ID equals respective SSP platform-device ID + 1. 1055 1085 * See comment in arch/arm/mach-pxa/ssp.c::ssp_probe() */ 1056 1086 void __init pxa2xx_set_spi_info(unsigned id, struct pxa2xx_spi_master *info)
+1
arch/arm/mach-pxa/devices.h
··· 16 16 extern struct platform_device sa1100_device_rtc; 17 17 extern struct platform_device pxa_device_rtc; 18 18 extern struct platform_device pxa_device_ac97; 19 + extern struct platform_device pxa_device_gpio; 19 20 20 21 extern struct platform_device pxa27x_device_i2c_power; 21 22 extern struct platform_device pxa27x_device_ohci;
-131
arch/arm/mach-pxa/include/mach/gpio-pxa.h
··· 1 - /* 2 - * Written by Philipp Zabel <philipp.zabel@gmail.com> 3 - * 4 - * This program is free software; you can redistribute it and/or modify 5 - * it under the terms of the GNU General Public License as published by 6 - * the Free Software Foundation; either version 2 of the License, or 7 - * (at your option) any later version. 8 - * 9 - * This program is distributed in the hope that it will be useful, 10 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 - * GNU General Public License for more details. 13 - * 14 - * You should have received a copy of the GNU General Public License 15 - * along with this program; if not, write to the Free Software 16 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 - * 18 - */ 19 - #ifndef __MACH_PXA_GPIO_PXA_H 20 - #define __MACH_PXA_GPIO_PXA_H 21 - 22 - #include <mach/irqs.h> 23 - #include <mach/hardware.h> 24 - 25 - #define GPIO_REGS_VIRT io_p2v(0x40E00000) 26 - 27 - #define BANK_OFF(n) (((n) < 3) ? (n) << 2 : 0x100 + (((n) - 3) << 2)) 28 - #define GPIO_REG(x) (*(volatile u32 *)(GPIO_REGS_VIRT + (x))) 29 - 30 - /* GPIO Pin Level Registers */ 31 - #define GPLR0 GPIO_REG(BANK_OFF(0) + 0x00) 32 - #define GPLR1 GPIO_REG(BANK_OFF(1) + 0x00) 33 - #define GPLR2 GPIO_REG(BANK_OFF(2) + 0x00) 34 - #define GPLR3 GPIO_REG(BANK_OFF(3) + 0x00) 35 - 36 - /* GPIO Pin Direction Registers */ 37 - #define GPDR0 GPIO_REG(BANK_OFF(0) + 0x0c) 38 - #define GPDR1 GPIO_REG(BANK_OFF(1) + 0x0c) 39 - #define GPDR2 GPIO_REG(BANK_OFF(2) + 0x0c) 40 - #define GPDR3 GPIO_REG(BANK_OFF(3) + 0x0c) 41 - 42 - /* GPIO Pin Output Set Registers */ 43 - #define GPSR0 GPIO_REG(BANK_OFF(0) + 0x18) 44 - #define GPSR1 GPIO_REG(BANK_OFF(1) + 0x18) 45 - #define GPSR2 GPIO_REG(BANK_OFF(2) + 0x18) 46 - #define GPSR3 GPIO_REG(BANK_OFF(3) + 0x18) 47 - 48 - /* GPIO Pin Output Clear Registers */ 49 - #define GPCR0 GPIO_REG(BANK_OFF(0) + 0x24) 50 - #define GPCR1 GPIO_REG(BANK_OFF(1) + 0x24) 51 - #define GPCR2 GPIO_REG(BANK_OFF(2) + 0x24) 52 - #define GPCR3 GPIO_REG(BANK_OFF(3) + 0x24) 53 - 54 - /* GPIO Rising Edge Detect Registers */ 55 - #define GRER0 GPIO_REG(BANK_OFF(0) + 0x30) 56 - #define GRER1 GPIO_REG(BANK_OFF(1) + 0x30) 57 - #define GRER2 GPIO_REG(BANK_OFF(2) + 0x30) 58 - #define GRER3 GPIO_REG(BANK_OFF(3) + 0x30) 59 - 60 - /* GPIO Falling Edge Detect Registers */ 61 - #define GFER0 GPIO_REG(BANK_OFF(0) + 0x3c) 62 - #define GFER1 GPIO_REG(BANK_OFF(1) + 0x3c) 63 - #define GFER2 GPIO_REG(BANK_OFF(2) + 0x3c) 64 - #define GFER3 GPIO_REG(BANK_OFF(3) + 0x3c) 65 - 66 - /* GPIO Edge Detect Status Registers */ 67 - #define GEDR0 GPIO_REG(BANK_OFF(0) + 0x48) 68 - #define GEDR1 GPIO_REG(BANK_OFF(1) + 0x48) 69 - #define GEDR2 GPIO_REG(BANK_OFF(2) + 0x48) 70 - #define GEDR3 GPIO_REG(BANK_OFF(3) + 0x48) 71 - 72 - /* GPIO Alternate Function Select Registers */ 73 - #define GAFR0_L GPIO_REG(0x0054) 74 - #define GAFR0_U GPIO_REG(0x0058) 75 - #define GAFR1_L GPIO_REG(0x005C) 76 - #define GAFR1_U GPIO_REG(0x0060) 77 - #define GAFR2_L GPIO_REG(0x0064) 78 - #define GAFR2_U GPIO_REG(0x0068) 79 - #define GAFR3_L GPIO_REG(0x006C) 80 - #define GAFR3_U GPIO_REG(0x0070) 81 - 82 - /* More handy macros. The argument is a literal GPIO number. */ 83 - 84 - #define GPIO_bit(x) (1 << ((x) & 0x1f)) 85 - 86 - #define GPLR(x) GPIO_REG(BANK_OFF((x) >> 5) + 0x00) 87 - #define GPDR(x) GPIO_REG(BANK_OFF((x) >> 5) + 0x0c) 88 - #define GPSR(x) GPIO_REG(BANK_OFF((x) >> 5) + 0x18) 89 - #define GPCR(x) GPIO_REG(BANK_OFF((x) >> 5) + 0x24) 90 - #define GRER(x) GPIO_REG(BANK_OFF((x) >> 5) + 0x30) 91 - #define GFER(x) GPIO_REG(BANK_OFF((x) >> 5) + 0x3c) 92 - #define GEDR(x) GPIO_REG(BANK_OFF((x) >> 5) + 0x48) 93 - #define GAFR(x) GPIO_REG(0x54 + (((x) & 0x70) >> 2)) 94 - 95 - 96 - #define gpio_to_bank(gpio) ((gpio) >> 5) 97 - 98 - #ifdef CONFIG_CPU_PXA26x 99 - /* GPIO86/87/88/89 on PXA26x have their direction bits in GPDR2 inverted, 100 - * as well as their Alternate Function value being '1' for GPIO in GAFRx. 101 - */ 102 - static inline int __gpio_is_inverted(unsigned gpio) 103 - { 104 - return cpu_is_pxa25x() && gpio > 85; 105 - } 106 - #else 107 - static inline int __gpio_is_inverted(unsigned gpio) { return 0; } 108 - #endif 109 - 110 - /* 111 - * On PXA25x and PXA27x, GAFRx and GPDRx together decide the alternate 112 - * function of a GPIO, and GPDRx cannot be altered once configured. It 113 - * is attributed as "occupied" here (I know this terminology isn't 114 - * accurate, you are welcome to propose a better one :-) 115 - */ 116 - static inline int __gpio_is_occupied(unsigned gpio) 117 - { 118 - if (cpu_is_pxa27x() || cpu_is_pxa25x()) { 119 - int af = (GAFR(gpio) >> ((gpio & 0xf) * 2)) & 0x3; 120 - int dir = GPDR(gpio) & GPIO_bit(gpio); 121 - 122 - if (__gpio_is_inverted(gpio)) 123 - return af != 1 || dir == 0; 124 - else 125 - return af != 0 || dir != 0; 126 - } else 127 - return GPDR(gpio) & GPIO_bit(gpio); 128 - } 129 - 130 - #include <plat/gpio-pxa.h> 131 - #endif /* __MACH_PXA_GPIO_PXA_H */
+3 -2
arch/arm/mach-pxa/include/mach/gpio.h
··· 25 25 #define __ASM_ARCH_PXA_GPIO_H 26 26 27 27 #include <asm-generic/gpio.h> 28 - /* The defines for the driver are needed for the accelerated accessors */ 29 - #include "gpio-pxa.h" 28 + 29 + #include <mach/irqs.h> 30 + #include <mach/hardware.h> 30 31 31 32 #endif
-2
arch/arm/mach-pxa/include/mach/idp.h
··· 131 131 #define PCC_VS2 (1 << 1) 132 132 #define PCC_VS1 (1 << 0) 133 133 134 - #define PCC_DETECT(x) (GPLR(7 + (x)) & GPIO_bit(7 + (x))) 135 - 136 134 /* A listing of interrupts used by external hardware devices */ 137 135 138 136 #define TOUCH_PANEL_IRQ PXA_GPIO_TO_IRQ(5)
-2
arch/arm/mach-pxa/include/mach/littleton.h
··· 1 1 #ifndef __ASM_ARCH_LITTLETON_H 2 2 #define __ASM_ARCH_LITTLETON_H 3 3 4 - #include <mach/gpio-pxa.h> 5 - 6 4 #define LITTLETON_ETH_PHYS 0x30000000 7 5 8 6 #define LITTLETON_GPIO_LCD_CS (17)
+1 -2
arch/arm/mach-pxa/irq.c
··· 22 22 23 23 #include <mach/hardware.h> 24 24 #include <mach/irqs.h> 25 - #include <mach/gpio-pxa.h> 26 25 27 26 #include "generic.h" 28 27 ··· 121 122 } while (1); 122 123 } 123 124 124 - void __init pxa_init_irq(int irq_nr, set_wake_t fn) 125 + void __init pxa_init_irq(int irq_nr, int (*fn)(struct irq_data *, unsigned int)) 125 126 { 126 127 int irq, i, n; 127 128
+5 -1
arch/arm/mach-pxa/mfp-pxa2xx.c
··· 13 13 * published by the Free Software Foundation. 14 14 */ 15 15 #include <linux/gpio.h> 16 + #include <linux/gpio-pxa.h> 16 17 #include <linux/module.h> 17 18 #include <linux/kernel.h> 18 19 #include <linux/init.h> ··· 21 20 22 21 #include <mach/pxa2xx-regs.h> 23 22 #include <mach/mfp-pxa2xx.h> 24 - #include <mach/gpio-pxa.h> 25 23 26 24 #include "generic.h" 27 25 ··· 28 28 #define __GAFR(u, x) __REG2((u) ? 0x40E00058 : 0x40E00054, (x) << 3) 29 29 #define GAFR_L(x) __GAFR(0, x) 30 30 #define GAFR_U(x) __GAFR(1, x) 31 + 32 + #define BANK_OFF(n) (((n) < 3) ? (n) << 2 : 0x100 + (((n) - 3) << 2)) 33 + #define GPLR(x) __REG2(0x40E00000, BANK_OFF((x) >> 5)) 34 + #define GPDR(x) __REG2(0x40E00000, BANK_OFF((x) >> 5) + 0x0c) 31 35 32 36 #define PWER_WE35 (1 << 24) 33 37
+1 -2
arch/arm/mach-pxa/pxa25x.c
··· 17 17 * need be. 18 18 */ 19 19 #include <linux/gpio.h> 20 + #include <linux/gpio-pxa.h> 20 21 #include <linux/module.h> 21 22 #include <linux/kernel.h> 22 23 #include <linux/init.h> ··· 313 312 void __init pxa25x_init_irq(void) 314 313 { 315 314 pxa_init_irq(32, pxa25x_set_wake); 316 - pxa_init_gpio(IRQ_GPIO_2_x, 2, 84, pxa25x_set_wake); 317 315 } 318 316 319 317 #ifdef CONFIG_CPU_PXA26x 320 318 void __init pxa26x_init_irq(void) 321 319 { 322 320 pxa_init_irq(32, pxa25x_set_wake); 323 - pxa_init_gpio(IRQ_GPIO_2_x, 2, 89, pxa25x_set_wake); 324 321 } 325 322 #endif 326 323
+2 -1
arch/arm/mach-pxa/pxa27x.c
··· 12 12 * published by the Free Software Foundation. 13 13 */ 14 14 #include <linux/gpio.h> 15 + #include <linux/gpio-pxa.h> 15 16 #include <linux/module.h> 16 17 #include <linux/kernel.h> 17 18 #include <linux/init.h> ··· 387 386 void __init pxa27x_init_irq(void) 388 387 { 389 388 pxa_init_irq(34, pxa27x_set_wake); 390 - pxa_init_gpio(IRQ_GPIO_2_x, 2, 120, pxa27x_set_wake); 391 389 } 392 390 393 391 static struct map_desc pxa27x_io_desc[] __initdata = { ··· 422 422 } 423 423 424 424 static struct platform_device *devices[] __initdata = { 425 + &pxa_device_gpio, 425 426 &pxa27x_device_udc, 426 427 &pxa_device_pmu, 427 428 &pxa_device_i2s,
+3 -3
arch/arm/mach-pxa/pxa3xx.c
··· 25 25 #include <asm/mach/map.h> 26 26 #include <asm/suspend.h> 27 27 #include <mach/hardware.h> 28 - #include <mach/gpio-pxa.h> 29 28 #include <mach/pxa3xx-regs.h> 30 29 #include <mach/reset.h> 31 30 #include <mach/ohci.h> ··· 364 365 .irq_set_type = pxa_set_ext_wakeup_type, 365 366 }; 366 367 367 - static void __init pxa_init_ext_wakeup_irq(set_wake_t fn) 368 + static void __init pxa_init_ext_wakeup_irq(int (*fn)(struct irq_data *, 369 + unsigned int)) 368 370 { 369 371 int irq; 370 372 ··· 388 388 389 389 pxa_init_irq(56, pxa3xx_set_wake); 390 390 pxa_init_ext_wakeup_irq(pxa3xx_set_wake); 391 - pxa_init_gpio(IRQ_GPIO_2_x, 2, 127, NULL); 392 391 } 393 392 394 393 static struct map_desc pxa3xx_io_desc[] __initdata = { ··· 416 417 } 417 418 418 419 static struct platform_device *devices[] __initdata = { 420 + &pxa_device_gpio, 419 421 &pxa27x_device_udc, 420 422 &pxa_device_pmu, 421 423 &pxa_device_i2s,
+1 -2
arch/arm/mach-pxa/pxa95x.c
··· 20 20 #include <linux/syscore_ops.h> 21 21 22 22 #include <mach/hardware.h> 23 - #include <mach/gpio-pxa.h> 24 23 #include <mach/pxa3xx-regs.h> 25 24 #include <mach/pxa930.h> 26 25 #include <mach/reset.h> ··· 234 235 void __init pxa95x_init_irq(void) 235 236 { 236 237 pxa_init_irq(96, NULL); 237 - pxa_init_gpio(IRQ_GPIO_2_x, 2, 127, NULL); 238 238 } 239 239 240 240 /* ··· 246 248 } 247 249 248 250 static struct platform_device *devices[] __initdata = { 251 + &pxa_device_gpio, 249 252 &sa1100_device_rtc, 250 253 &pxa_device_rtc, 251 254 &pxa27x_device_ssp1,
-45
arch/arm/plat-pxa/include/plat/gpio-pxa.h
··· 1 - #ifndef __PLAT_PXA_GPIO_H 2 - #define __PLAT_PXA_GPIO_H 3 - 4 - struct irq_data; 5 - 6 - /* 7 - * We handle the GPIOs by banks, each bank covers up to 32 GPIOs with 8 - * one set of registers. The register offsets are organized below: 9 - * 10 - * GPLR GPDR GPSR GPCR GRER GFER GEDR 11 - * BANK 0 - 0x0000 0x000C 0x0018 0x0024 0x0030 0x003C 0x0048 12 - * BANK 1 - 0x0004 0x0010 0x001C 0x0028 0x0034 0x0040 0x004C 13 - * BANK 2 - 0x0008 0x0014 0x0020 0x002C 0x0038 0x0044 0x0050 14 - * 15 - * BANK 3 - 0x0100 0x010C 0x0118 0x0124 0x0130 0x013C 0x0148 16 - * BANK 4 - 0x0104 0x0110 0x011C 0x0128 0x0134 0x0140 0x014C 17 - * BANK 5 - 0x0108 0x0114 0x0120 0x012C 0x0138 0x0144 0x0150 18 - * 19 - * NOTE: 20 - * BANK 3 is only available on PXA27x and later processors. 21 - * BANK 4 and 5 are only available on PXA935 22 - */ 23 - 24 - #define GPIO_BANK(n) (GPIO_REGS_VIRT + BANK_OFF(n)) 25 - 26 - #define GPLR_OFFSET 0x00 27 - #define GPDR_OFFSET 0x0C 28 - #define GPSR_OFFSET 0x18 29 - #define GPCR_OFFSET 0x24 30 - #define GRER_OFFSET 0x30 31 - #define GFER_OFFSET 0x3C 32 - #define GEDR_OFFSET 0x48 33 - 34 - /* NOTE: some PXAs have fewer on-chip GPIOs (like PXA255, with 85). 35 - * Those cases currently cause holes in the GPIO number space, the 36 - * actual number of the last GPIO is recorded by 'pxa_last_gpio'. 37 - */ 38 - extern int pxa_last_gpio; 39 - 40 - typedef int (*set_wake_t)(struct irq_data *d, unsigned int on); 41 - 42 - extern void pxa_init_gpio(int mux_irq, int start, int end, set_wake_t fn); 43 - extern int pxa_irq_to_gpio(int irq); 44 - 45 - #endif /* __PLAT_PXA_GPIO_H */
+6
drivers/gpio/Kconfig
··· 141 141 help 142 142 Say yes here to support the PrimeCell PL061 GPIO device 143 143 144 + config GPIO_PXA 145 + bool "PXA GPIO support" 146 + depends on ARCH_PXA || ARCH_MMP 147 + help 148 + Say yes here to support the PXA GPIO device 149 + 144 150 config GPIO_XILINX 145 151 bool "Xilinx GPIO support" 146 152 depends on PPC_OF || MICROBLAZE
+1 -1
drivers/gpio/Makefile
··· 40 40 obj-$(CONFIG_GPIO_PCF857X) += gpio-pcf857x.o 41 41 obj-$(CONFIG_GPIO_PCH) += gpio-pch.o 42 42 obj-$(CONFIG_GPIO_PL061) += gpio-pl061.o 43 - obj-$(CONFIG_PLAT_PXA) += gpio-pxa.o 43 + obj-$(CONFIG_GPIO_PXA) += gpio-pxa.o 44 44 obj-$(CONFIG_GPIO_RDC321X) += gpio-rdc321x.o 45 45 obj-$(CONFIG_PLAT_SAMSUNG) += gpio-samsung.o 46 46 obj-$(CONFIG_ARCH_SA1100) += gpio-sa1100.o
+125 -10
drivers/gpio/gpio-pxa.c
··· 12 12 * published by the Free Software Foundation. 13 13 */ 14 14 #include <linux/gpio.h> 15 + #include <linux/gpio-pxa.h> 15 16 #include <linux/init.h> 16 17 #include <linux/irq.h> 17 18 #include <linux/io.h> 19 + #include <linux/platform_device.h> 18 20 #include <linux/syscore_ops.h> 19 21 #include <linux/slab.h> 20 22 21 - #include <mach/gpio-pxa.h> 23 + /* 24 + * We handle the GPIOs by banks, each bank covers up to 32 GPIOs with 25 + * one set of registers. The register offsets are organized below: 26 + * 27 + * GPLR GPDR GPSR GPCR GRER GFER GEDR 28 + * BANK 0 - 0x0000 0x000C 0x0018 0x0024 0x0030 0x003C 0x0048 29 + * BANK 1 - 0x0004 0x0010 0x001C 0x0028 0x0034 0x0040 0x004C 30 + * BANK 2 - 0x0008 0x0014 0x0020 0x002C 0x0038 0x0044 0x0050 31 + * 32 + * BANK 3 - 0x0100 0x010C 0x0118 0x0124 0x0130 0x013C 0x0148 33 + * BANK 4 - 0x0104 0x0110 0x011C 0x0128 0x0134 0x0140 0x014C 34 + * BANK 5 - 0x0108 0x0114 0x0120 0x012C 0x0138 0x0144 0x0150 35 + * 36 + * NOTE: 37 + * BANK 3 is only available on PXA27x and later processors. 38 + * BANK 4 and 5 are only available on PXA935 39 + */ 40 + 41 + #define GPLR_OFFSET 0x00 42 + #define GPDR_OFFSET 0x0C 43 + #define GPSR_OFFSET 0x18 44 + #define GPCR_OFFSET 0x24 45 + #define GRER_OFFSET 0x30 46 + #define GFER_OFFSET 0x3C 47 + #define GEDR_OFFSET 0x48 48 + #define GAFR_OFFSET 0x54 49 + 50 + #define BANK_OFF(n) (((n) < 3) ? (n) << 2 : 0x100 + (((n) - 3) << 2)) 22 51 23 52 int pxa_last_gpio; 24 53 ··· 81 52 static DEFINE_SPINLOCK(gpio_lock); 82 53 static struct pxa_gpio_chip *pxa_gpio_chips; 83 54 static int gpio_type; 55 + static void __iomem *gpio_reg_base; 84 56 85 57 #define for_each_gpio_chip(i, c) \ 86 58 for (i = 0, c = &pxa_gpio_chips[0]; i <= pxa_last_gpio; i += 32, c++) ··· 104 74 static inline int gpio_is_mmp_type(int type) 105 75 { 106 76 return (type & MMP_GPIO) != 0; 77 + } 78 + 79 + /* GPIO86/87/88/89 on PXA26x have their direction bits in PXA_GPDR(2 inverted, 80 + * as well as their Alternate Function value being '1' for GPIO in GAFRx. 81 + */ 82 + static inline int __gpio_is_inverted(int gpio) 83 + { 84 + if ((gpio_type == PXA26X_GPIO) && (gpio > 85)) 85 + return 1; 86 + return 0; 87 + } 88 + 89 + /* 90 + * On PXA25x and PXA27x, GAFRx and GPDRx together decide the alternate 91 + * function of a GPIO, and GPDRx cannot be altered once configured. It 92 + * is attributed as "occupied" here (I know this terminology isn't 93 + * accurate, you are welcome to propose a better one :-) 94 + */ 95 + static inline int __gpio_is_occupied(unsigned gpio) 96 + { 97 + struct pxa_gpio_chip *pxachip; 98 + void __iomem *base; 99 + unsigned long gafr = 0, gpdr = 0; 100 + int ret, af = 0, dir = 0; 101 + 102 + pxachip = gpio_to_pxachip(gpio); 103 + base = gpio_chip_base(&pxachip->chip); 104 + gpdr = readl_relaxed(base + GPDR_OFFSET); 105 + 106 + switch (gpio_type) { 107 + case PXA25X_GPIO: 108 + case PXA26X_GPIO: 109 + case PXA27X_GPIO: 110 + gafr = readl_relaxed(base + GAFR_OFFSET); 111 + af = (gafr >> ((gpio & 0xf) * 2)) & 0x3; 112 + dir = gpdr & GPIO_bit(gpio); 113 + 114 + if (__gpio_is_inverted(gpio)) 115 + ret = (af != 1) || (dir == 0); 116 + else 117 + ret = (af != 0) || (dir != 0); 118 + break; 119 + default: 120 + ret = gpdr & GPIO_bit(gpio); 121 + break; 122 + } 123 + return ret; 107 124 } 108 125 109 126 #ifdef CONFIG_ARCH_PXA ··· 264 187 (value ? GPSR_OFFSET : GPCR_OFFSET)); 265 188 } 266 189 267 - static int __init pxa_init_gpio_chip(int gpio_end) 190 + static int __devinit pxa_init_gpio_chip(int gpio_end) 268 191 { 269 192 int i, gpio, nbanks = gpio_to_bank(gpio_end) + 1; 270 193 struct pxa_gpio_chip *chips; ··· 279 202 struct gpio_chip *c = &chips[i].chip; 280 203 281 204 sprintf(chips[i].label, "gpio-%d", i); 282 - chips[i].regbase = GPIO_BANK(i); 205 + chips[i].regbase = gpio_reg_base + BANK_OFF(i); 283 206 284 207 c->base = gpio; 285 208 c->label = chips[i].label; ··· 461 384 return count; 462 385 } 463 386 464 - void __init pxa_init_gpio(int mux_irq, int start, int end, set_wake_t fn) 387 + static int __devinit pxa_gpio_probe(struct platform_device *pdev) 465 388 { 466 389 struct pxa_gpio_chip *c; 390 + struct resource *res; 467 391 int gpio, irq; 392 + int irq0 = 0, irq1 = 0, irq_mux, gpio_offset = 0; 468 393 469 394 pxa_last_gpio = pxa_gpio_nums(); 470 395 if (!pxa_last_gpio) 471 - return; 396 + return -EINVAL; 397 + 398 + irq0 = platform_get_irq_byname(pdev, "gpio0"); 399 + irq1 = platform_get_irq_byname(pdev, "gpio1"); 400 + irq_mux = platform_get_irq_byname(pdev, "gpio_mux"); 401 + if ((irq0 > 0 && irq1 <= 0) || (irq0 <= 0 && irq1 > 0) 402 + || (irq_mux <= 0)) 403 + return -EINVAL; 404 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 405 + if (!res) 406 + return -EINVAL; 407 + gpio_reg_base = ioremap(res->start, resource_size(res)); 408 + if (!gpio_reg_base) 409 + return -EINVAL; 410 + 411 + if (irq0 > 0) 412 + gpio_offset = 2; 472 413 473 414 /* Initialize GPIO chips */ 474 - pxa_init_gpio_chip(end); 415 + pxa_init_gpio_chip(pxa_last_gpio); 475 416 476 417 /* clear all GPIO edge detects */ 477 418 for_each_gpio_chip(gpio, c) { ··· 512 417 irq_set_chained_handler(IRQ_GPIO1, pxa_gpio_demux_handler); 513 418 #endif 514 419 515 - for (irq = gpio_to_irq(start); irq <= gpio_to_irq(end); irq++) { 420 + for (irq = gpio_to_irq(gpio_offset); 421 + irq <= gpio_to_irq(pxa_last_gpio); irq++) { 516 422 irq_set_chip_and_handler(irq, &pxa_muxed_gpio_chip, 517 423 handle_edge_irq); 518 424 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); 519 425 } 520 426 521 - /* Install handler for GPIO>=2 edge detect interrupts */ 522 - irq_set_chained_handler(mux_irq, pxa_gpio_demux_handler); 523 - pxa_muxed_gpio_chip.irq_set_wake = fn; 427 + irq_set_chained_handler(irq_mux, pxa_gpio_demux_handler); 428 + return 0; 524 429 } 430 + 431 + static struct platform_driver pxa_gpio_driver = { 432 + .probe = pxa_gpio_probe, 433 + .driver = { 434 + .name = "pxa-gpio", 435 + }, 436 + }; 437 + 438 + static int __init pxa_gpio_init(void) 439 + { 440 + return platform_driver_register(&pxa_gpio_driver); 441 + } 442 + postcore_initcall(pxa_gpio_init); 525 443 526 444 #ifdef CONFIG_PM 527 445 static int pxa_gpio_suspend(void) ··· 578 470 .suspend = pxa_gpio_suspend, 579 471 .resume = pxa_gpio_resume, 580 472 }; 473 + 474 + static int __init pxa_gpio_sysinit(void) 475 + { 476 + register_syscore_ops(&pxa_gpio_syscore_ops); 477 + return 0; 478 + } 479 + postcore_initcall(pxa_gpio_sysinit);
+16
include/linux/gpio-pxa.h
··· 1 + #ifndef __GPIO_PXA_H 2 + #define __GPIO_PXA_H 3 + 4 + #define GPIO_bit(x) (1 << ((x) & 0x1f)) 5 + 6 + #define gpio_to_bank(gpio) ((gpio) >> 5) 7 + 8 + /* NOTE: some PXAs have fewer on-chip GPIOs (like PXA255, with 85). 9 + * Those cases currently cause holes in the GPIO number space, the 10 + * actual number of the last GPIO is recorded by 'pxa_last_gpio'. 11 + */ 12 + extern int pxa_last_gpio; 13 + 14 + extern int pxa_irq_to_gpio(int irq); 15 + 16 + #endif /* __GPIO_PXA_H */