diff options
author | Olof Johansson <olof@lixom.net> | 2013-10-07 12:29:10 -0400 |
---|---|---|
committer | Olof Johansson <olof@lixom.net> | 2013-10-07 12:29:10 -0400 |
commit | 3d729d33ee89a3e63bee14bdd516af0662490fab (patch) | |
tree | ca851636c3c3ea8bd510d70f4657631fff24260d | |
parent | 4a10c2ac2f368583138b774ca41fac4207911983 (diff) | |
parent | f1a4c52ff5913378b7baf05ac71f10282b341cf7 (diff) |
Merge tag 'davinci-for-v3.13/gpio' of git://git.kernel.org/pub/scm/linux/kernel/git/nsekhar/linux-davinci into next/drivers
From Sekhar Nori, GPIO driver updates for DaVinci:
This pull request moves DaVinci GPIO driver to use platform device
framework and the corresponding changes needed to keep GPIO working on
existing DaVinci boards. This is a pre-requisite to DT support for GPIO.
* tag 'davinci-for-v3.13/gpio' of git://git.kernel.org/pub/scm/linux/kernel/git/nsekhar/linux-davinci:
ARM: davinci: gpio: use gpiolib API instead of inline functions
ARM: davinci: board: gpio device creation
ARM: davinci: da8xx boards: gpio device creation
ARM: davinci: support gpio platform device
ARM: davinci: da8xx: support gpio platform device
gpio: davinci: move to platform device
gpio: davinci: coding style correction
Signed-off-by: Olof Johansson <olof@lixom.net>
25 files changed, 402 insertions, 277 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 3f7714d8d2d2..ad3767095422 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig | |||
@@ -847,7 +847,6 @@ config ARCH_DAVINCI | |||
847 | select GENERIC_CLOCKEVENTS | 847 | select GENERIC_CLOCKEVENTS |
848 | select GENERIC_IRQ_CHIP | 848 | select GENERIC_IRQ_CHIP |
849 | select HAVE_IDE | 849 | select HAVE_IDE |
850 | select NEED_MACH_GPIO_H | ||
851 | select TI_PRIV_EDMA | 850 | select TI_PRIV_EDMA |
852 | select USE_OF | 851 | select USE_OF |
853 | select ZONE_DMA | 852 | select ZONE_DMA |
diff --git a/arch/arm/mach-davinci/board-da830-evm.c b/arch/arm/mach-davinci/board-da830-evm.c index c4bdc0a1c36e..67df6f6bee49 100644 --- a/arch/arm/mach-davinci/board-da830-evm.c +++ b/arch/arm/mach-davinci/board-da830-evm.c | |||
@@ -22,17 +22,19 @@ | |||
22 | #include <linux/mtd/partitions.h> | 22 | #include <linux/mtd/partitions.h> |
23 | #include <linux/spi/spi.h> | 23 | #include <linux/spi/spi.h> |
24 | #include <linux/spi/flash.h> | 24 | #include <linux/spi/flash.h> |
25 | #include <linux/platform_data/gpio-davinci.h> | ||
26 | #include <linux/platform_data/mtd-davinci.h> | ||
27 | #include <linux/platform_data/mtd-davinci-aemif.h> | ||
28 | #include <linux/platform_data/spi-davinci.h> | ||
29 | #include <linux/platform_data/usb-davinci.h> | ||
25 | 30 | ||
26 | #include <asm/mach-types.h> | 31 | #include <asm/mach-types.h> |
27 | #include <asm/mach/arch.h> | 32 | #include <asm/mach/arch.h> |
28 | 33 | ||
34 | #include <mach/common.h> | ||
29 | #include <mach/cp_intc.h> | 35 | #include <mach/cp_intc.h> |
30 | #include <mach/mux.h> | 36 | #include <mach/mux.h> |
31 | #include <linux/platform_data/mtd-davinci.h> | ||
32 | #include <mach/da8xx.h> | 37 | #include <mach/da8xx.h> |
33 | #include <linux/platform_data/usb-davinci.h> | ||
34 | #include <linux/platform_data/mtd-davinci-aemif.h> | ||
35 | #include <linux/platform_data/spi-davinci.h> | ||
36 | 38 | ||
37 | #define DA830_EVM_PHY_ID "" | 39 | #define DA830_EVM_PHY_ID "" |
38 | /* | 40 | /* |
@@ -591,6 +593,10 @@ static __init void da830_evm_init(void) | |||
591 | struct davinci_soc_info *soc_info = &davinci_soc_info; | 593 | struct davinci_soc_info *soc_info = &davinci_soc_info; |
592 | int ret; | 594 | int ret; |
593 | 595 | ||
596 | ret = da830_register_gpio(); | ||
597 | if (ret) | ||
598 | pr_warn("da830_evm_init: GPIO init failed: %d\n", ret); | ||
599 | |||
594 | ret = da830_register_edma(da830_edma_rsv); | 600 | ret = da830_register_edma(da830_edma_rsv); |
595 | if (ret) | 601 | if (ret) |
596 | pr_warning("da830_evm_init: edma registration failed: %d\n", | 602 | pr_warning("da830_evm_init: edma registration failed: %d\n", |
diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c index dd1fb24521aa..df16cb88a26b 100644 --- a/arch/arm/mach-davinci/board-da850-evm.c +++ b/arch/arm/mach-davinci/board-da850-evm.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/mtd/partitions.h> | 28 | #include <linux/mtd/partitions.h> |
29 | #include <linux/mtd/physmap.h> | 29 | #include <linux/mtd/physmap.h> |
30 | #include <linux/platform_device.h> | 30 | #include <linux/platform_device.h> |
31 | #include <linux/platform_data/gpio-davinci.h> | ||
31 | #include <linux/platform_data/mtd-davinci.h> | 32 | #include <linux/platform_data/mtd-davinci.h> |
32 | #include <linux/platform_data/mtd-davinci-aemif.h> | 33 | #include <linux/platform_data/mtd-davinci-aemif.h> |
33 | #include <linux/platform_data/spi-davinci.h> | 34 | #include <linux/platform_data/spi-davinci.h> |
@@ -38,6 +39,7 @@ | |||
38 | #include <linux/spi/flash.h> | 39 | #include <linux/spi/flash.h> |
39 | #include <linux/wl12xx.h> | 40 | #include <linux/wl12xx.h> |
40 | 41 | ||
42 | #include <mach/common.h> | ||
41 | #include <mach/cp_intc.h> | 43 | #include <mach/cp_intc.h> |
42 | #include <mach/da8xx.h> | 44 | #include <mach/da8xx.h> |
43 | #include <mach/mux.h> | 45 | #include <mach/mux.h> |
@@ -1437,6 +1439,10 @@ static __init void da850_evm_init(void) | |||
1437 | { | 1439 | { |
1438 | int ret; | 1440 | int ret; |
1439 | 1441 | ||
1442 | ret = da850_register_gpio(); | ||
1443 | if (ret) | ||
1444 | pr_warn("%s: GPIO init failed: %d\n", __func__, ret); | ||
1445 | |||
1440 | ret = pmic_tps65070_init(); | 1446 | ret = pmic_tps65070_init(); |
1441 | if (ret) | 1447 | if (ret) |
1442 | pr_warn("%s: TPS65070 PMIC init failed: %d\n", __func__, ret); | 1448 | pr_warn("%s: TPS65070 PMIC init failed: %d\n", __func__, ret); |
diff --git a/arch/arm/mach-davinci/board-dm355-evm.c b/arch/arm/mach-davinci/board-dm355-evm.c index 42b23a3194a0..ecdc7d44fa70 100644 --- a/arch/arm/mach-davinci/board-dm355-evm.c +++ b/arch/arm/mach-davinci/board-dm355-evm.c | |||
@@ -22,15 +22,17 @@ | |||
22 | #include <media/tvp514x.h> | 22 | #include <media/tvp514x.h> |
23 | #include <linux/spi/spi.h> | 23 | #include <linux/spi/spi.h> |
24 | #include <linux/spi/eeprom.h> | 24 | #include <linux/spi/eeprom.h> |
25 | #include <linux/platform_data/gpio-davinci.h> | ||
26 | #include <linux/platform_data/i2c-davinci.h> | ||
27 | #include <linux/platform_data/mtd-davinci.h> | ||
28 | #include <linux/platform_data/mmc-davinci.h> | ||
29 | #include <linux/platform_data/usb-davinci.h> | ||
25 | 30 | ||
26 | #include <asm/mach-types.h> | 31 | #include <asm/mach-types.h> |
27 | #include <asm/mach/arch.h> | 32 | #include <asm/mach/arch.h> |
28 | 33 | ||
29 | #include <linux/platform_data/i2c-davinci.h> | ||
30 | #include <mach/serial.h> | 34 | #include <mach/serial.h> |
31 | #include <linux/platform_data/mtd-davinci.h> | 35 | #include <mach/common.h> |
32 | #include <linux/platform_data/mmc-davinci.h> | ||
33 | #include <linux/platform_data/usb-davinci.h> | ||
34 | 36 | ||
35 | #include "davinci.h" | 37 | #include "davinci.h" |
36 | 38 | ||
@@ -375,6 +377,11 @@ static struct spi_board_info dm355_evm_spi_info[] __initconst = { | |||
375 | static __init void dm355_evm_init(void) | 377 | static __init void dm355_evm_init(void) |
376 | { | 378 | { |
377 | struct clk *aemif; | 379 | struct clk *aemif; |
380 | int ret; | ||
381 | |||
382 | ret = dm355_gpio_register(); | ||
383 | if (ret) | ||
384 | pr_warn("%s: GPIO init failed: %d\n", __func__, ret); | ||
378 | 385 | ||
379 | gpio_request(1, "dm9000"); | 386 | gpio_request(1, "dm9000"); |
380 | gpio_direction_input(1); | 387 | gpio_direction_input(1); |
diff --git a/arch/arm/mach-davinci/board-dm355-leopard.c b/arch/arm/mach-davinci/board-dm355-leopard.c index 65a984c52df6..43bacbf15314 100644 --- a/arch/arm/mach-davinci/board-dm355-leopard.c +++ b/arch/arm/mach-davinci/board-dm355-leopard.c | |||
@@ -19,15 +19,16 @@ | |||
19 | #include <linux/clk.h> | 19 | #include <linux/clk.h> |
20 | #include <linux/spi/spi.h> | 20 | #include <linux/spi/spi.h> |
21 | #include <linux/spi/eeprom.h> | 21 | #include <linux/spi/eeprom.h> |
22 | #include <linux/platform_data/i2c-davinci.h> | ||
23 | #include <linux/platform_data/mmc-davinci.h> | ||
24 | #include <linux/platform_data/mtd-davinci.h> | ||
25 | #include <linux/platform_data/usb-davinci.h> | ||
22 | 26 | ||
23 | #include <asm/mach-types.h> | 27 | #include <asm/mach-types.h> |
24 | #include <asm/mach/arch.h> | 28 | #include <asm/mach/arch.h> |
25 | 29 | ||
26 | #include <linux/platform_data/i2c-davinci.h> | 30 | #include <mach/common.h> |
27 | #include <mach/serial.h> | 31 | #include <mach/serial.h> |
28 | #include <linux/platform_data/mtd-davinci.h> | ||
29 | #include <linux/platform_data/mmc-davinci.h> | ||
30 | #include <linux/platform_data/usb-davinci.h> | ||
31 | 32 | ||
32 | #include "davinci.h" | 33 | #include "davinci.h" |
33 | 34 | ||
@@ -234,6 +235,11 @@ static struct spi_board_info dm355_leopard_spi_info[] __initconst = { | |||
234 | static __init void dm355_leopard_init(void) | 235 | static __init void dm355_leopard_init(void) |
235 | { | 236 | { |
236 | struct clk *aemif; | 237 | struct clk *aemif; |
238 | int ret; | ||
239 | |||
240 | ret = dm355_gpio_register(); | ||
241 | if (ret) | ||
242 | pr_warn("%s: GPIO init failed: %d\n", __func__, ret); | ||
237 | 243 | ||
238 | gpio_request(9, "dm9000"); | 244 | gpio_request(9, "dm9000"); |
239 | gpio_direction_input(9); | 245 | gpio_direction_input(9); |
diff --git a/arch/arm/mach-davinci/board-dm365-evm.c b/arch/arm/mach-davinci/board-dm365-evm.c index 92b7f770615a..c2aed66f284d 100644 --- a/arch/arm/mach-davinci/board-dm365-evm.c +++ b/arch/arm/mach-davinci/board-dm365-evm.c | |||
@@ -743,6 +743,12 @@ static struct spi_board_info dm365_evm_spi_info[] __initconst = { | |||
743 | 743 | ||
744 | static __init void dm365_evm_init(void) | 744 | static __init void dm365_evm_init(void) |
745 | { | 745 | { |
746 | int ret; | ||
747 | |||
748 | ret = dm365_gpio_register(); | ||
749 | if (ret) | ||
750 | pr_warn("%s: GPIO init failed: %d\n", __func__, ret); | ||
751 | |||
746 | evm_init_i2c(); | 752 | evm_init_i2c(); |
747 | davinci_serial_init(dm365_serial_device); | 753 | davinci_serial_init(dm365_serial_device); |
748 | 754 | ||
diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c index 40bb9b5b87e8..9cc32c283b8b 100644 --- a/arch/arm/mach-davinci/board-dm644x-evm.c +++ b/arch/arm/mach-davinci/board-dm644x-evm.c | |||
@@ -754,9 +754,14 @@ static int davinci_phy_fixup(struct phy_device *phydev) | |||
754 | 754 | ||
755 | static __init void davinci_evm_init(void) | 755 | static __init void davinci_evm_init(void) |
756 | { | 756 | { |
757 | int ret; | ||
757 | struct clk *aemif_clk; | 758 | struct clk *aemif_clk; |
758 | struct davinci_soc_info *soc_info = &davinci_soc_info; | 759 | struct davinci_soc_info *soc_info = &davinci_soc_info; |
759 | 760 | ||
761 | ret = dm644x_gpio_register(); | ||
762 | if (ret) | ||
763 | pr_warn("%s: GPIO init failed: %d\n", __func__, ret); | ||
764 | |||
760 | aemif_clk = clk_get(NULL, "aemif"); | 765 | aemif_clk = clk_get(NULL, "aemif"); |
761 | clk_prepare_enable(aemif_clk); | 766 | clk_prepare_enable(aemif_clk); |
762 | 767 | ||
diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c index 2bc3651d56cc..44b20191a9fe 100644 --- a/arch/arm/mach-davinci/board-dm646x-evm.c +++ b/arch/arm/mach-davinci/board-dm646x-evm.c | |||
@@ -33,17 +33,19 @@ | |||
33 | #include <linux/mtd/partitions.h> | 33 | #include <linux/mtd/partitions.h> |
34 | #include <linux/clk.h> | 34 | #include <linux/clk.h> |
35 | #include <linux/export.h> | 35 | #include <linux/export.h> |
36 | #include <linux/platform_data/gpio-davinci.h> | ||
37 | #include <linux/platform_data/i2c-davinci.h> | ||
38 | #include <linux/platform_data/mtd-davinci.h> | ||
39 | #include <linux/platform_data/mtd-davinci-aemif.h> | ||
36 | 40 | ||
37 | #include <asm/mach-types.h> | 41 | #include <asm/mach-types.h> |
38 | #include <asm/mach/arch.h> | 42 | #include <asm/mach/arch.h> |
39 | 43 | ||
40 | #include <mach/common.h> | 44 | #include <mach/common.h> |
45 | #include <mach/irqs.h> | ||
41 | #include <mach/serial.h> | 46 | #include <mach/serial.h> |
42 | #include <linux/platform_data/i2c-davinci.h> | ||
43 | #include <linux/platform_data/mtd-davinci.h> | ||
44 | #include <mach/clock.h> | 47 | #include <mach/clock.h> |
45 | #include <mach/cdce949.h> | 48 | #include <mach/cdce949.h> |
46 | #include <linux/platform_data/mtd-davinci-aemif.h> | ||
47 | 49 | ||
48 | #include "davinci.h" | 50 | #include "davinci.h" |
49 | #include "clock.h" | 51 | #include "clock.h" |
@@ -786,8 +788,13 @@ static struct edma_rsv_info dm646x_edma_rsv[] = { | |||
786 | 788 | ||
787 | static __init void evm_init(void) | 789 | static __init void evm_init(void) |
788 | { | 790 | { |
791 | int ret; | ||
789 | struct davinci_soc_info *soc_info = &davinci_soc_info; | 792 | struct davinci_soc_info *soc_info = &davinci_soc_info; |
790 | 793 | ||
794 | ret = dm646x_gpio_register(); | ||
795 | if (ret) | ||
796 | pr_warn("%s: GPIO init failed: %d\n", __func__, ret); | ||
797 | |||
791 | evm_init_i2c(); | 798 | evm_init_i2c(); |
792 | davinci_serial_init(dm646x_serial_device); | 799 | davinci_serial_init(dm646x_serial_device); |
793 | dm646x_init_mcasp0(&dm646x_evm_snd_data[0]); | 800 | dm646x_init_mcasp0(&dm646x_evm_snd_data[0]); |
diff --git a/arch/arm/mach-davinci/board-neuros-osd2.c b/arch/arm/mach-davinci/board-neuros-osd2.c index 46f336fca803..bb680af98374 100644 --- a/arch/arm/mach-davinci/board-neuros-osd2.c +++ b/arch/arm/mach-davinci/board-neuros-osd2.c | |||
@@ -26,17 +26,18 @@ | |||
26 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
27 | #include <linux/gpio.h> | 27 | #include <linux/gpio.h> |
28 | #include <linux/mtd/partitions.h> | 28 | #include <linux/mtd/partitions.h> |
29 | #include <linux/platform_data/gpio-davinci.h> | ||
30 | #include <linux/platform_data/i2c-davinci.h> | ||
31 | #include <linux/platform_data/mmc-davinci.h> | ||
32 | #include <linux/platform_data/mtd-davinci.h> | ||
33 | #include <linux/platform_data/usb-davinci.h> | ||
29 | 34 | ||
30 | #include <asm/mach-types.h> | 35 | #include <asm/mach-types.h> |
31 | #include <asm/mach/arch.h> | 36 | #include <asm/mach/arch.h> |
32 | 37 | ||
33 | #include <mach/common.h> | 38 | #include <mach/common.h> |
34 | #include <linux/platform_data/i2c-davinci.h> | ||
35 | #include <mach/serial.h> | 39 | #include <mach/serial.h> |
36 | #include <mach/mux.h> | 40 | #include <mach/mux.h> |
37 | #include <linux/platform_data/mtd-davinci.h> | ||
38 | #include <linux/platform_data/mmc-davinci.h> | ||
39 | #include <linux/platform_data/usb-davinci.h> | ||
40 | 41 | ||
41 | #include "davinci.h" | 42 | #include "davinci.h" |
42 | 43 | ||
@@ -169,9 +170,14 @@ static struct davinci_mmc_config davinci_ntosd2_mmc_config = { | |||
169 | 170 | ||
170 | static __init void davinci_ntosd2_init(void) | 171 | static __init void davinci_ntosd2_init(void) |
171 | { | 172 | { |
173 | int ret; | ||
172 | struct clk *aemif_clk; | 174 | struct clk *aemif_clk; |
173 | struct davinci_soc_info *soc_info = &davinci_soc_info; | 175 | struct davinci_soc_info *soc_info = &davinci_soc_info; |
174 | 176 | ||
177 | ret = dm644x_gpio_register(); | ||
178 | if (ret) | ||
179 | pr_warn("%s: GPIO init failed: %d\n", __func__, ret); | ||
180 | |||
175 | aemif_clk = clk_get(NULL, "aemif"); | 181 | aemif_clk = clk_get(NULL, "aemif"); |
176 | clk_prepare_enable(aemif_clk); | 182 | clk_prepare_enable(aemif_clk); |
177 | 183 | ||
diff --git a/arch/arm/mach-davinci/board-omapl138-hawk.c b/arch/arm/mach-davinci/board-omapl138-hawk.c index ab98c75cabb4..d0d9da0b0a94 100644 --- a/arch/arm/mach-davinci/board-omapl138-hawk.c +++ b/arch/arm/mach-davinci/board-omapl138-hawk.c | |||
@@ -13,10 +13,12 @@ | |||
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/console.h> | 14 | #include <linux/console.h> |
15 | #include <linux/gpio.h> | 15 | #include <linux/gpio.h> |
16 | #include <linux/platform_data/gpio-davinci.h> | ||
16 | 17 | ||
17 | #include <asm/mach-types.h> | 18 | #include <asm/mach-types.h> |
18 | #include <asm/mach/arch.h> | 19 | #include <asm/mach/arch.h> |
19 | 20 | ||
21 | #include <mach/common.h> | ||
20 | #include <mach/cp_intc.h> | 22 | #include <mach/cp_intc.h> |
21 | #include <mach/da8xx.h> | 23 | #include <mach/da8xx.h> |
22 | #include <mach/mux.h> | 24 | #include <mach/mux.h> |
@@ -290,6 +292,10 @@ static __init void omapl138_hawk_init(void) | |||
290 | { | 292 | { |
291 | int ret; | 293 | int ret; |
292 | 294 | ||
295 | ret = da850_register_gpio(); | ||
296 | if (ret) | ||
297 | pr_warn("%s: GPIO init failed: %d\n", __func__, ret); | ||
298 | |||
293 | davinci_serial_init(da8xx_serial_device); | 299 | davinci_serial_init(da8xx_serial_device); |
294 | 300 | ||
295 | omapl138_hawk_config_emac(); | 301 | omapl138_hawk_config_emac(); |
diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c index d6c746e35ad9..0813b5167e05 100644 --- a/arch/arm/mach-davinci/da830.c +++ b/arch/arm/mach-davinci/da830.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/gpio.h> | 11 | #include <linux/gpio.h> |
12 | #include <linux/init.h> | 12 | #include <linux/init.h> |
13 | #include <linux/clk.h> | 13 | #include <linux/clk.h> |
14 | #include <linux/platform_data/gpio-davinci.h> | ||
14 | 15 | ||
15 | #include <asm/mach/map.h> | 16 | #include <asm/mach/map.h> |
16 | 17 | ||
@@ -20,7 +21,6 @@ | |||
20 | #include <mach/common.h> | 21 | #include <mach/common.h> |
21 | #include <mach/time.h> | 22 | #include <mach/time.h> |
22 | #include <mach/da8xx.h> | 23 | #include <mach/da8xx.h> |
23 | #include <mach/gpio-davinci.h> | ||
24 | 24 | ||
25 | #include "clock.h" | 25 | #include "clock.h" |
26 | #include "mux.h" | 26 | #include "mux.h" |
@@ -1151,6 +1151,16 @@ static struct davinci_id da830_ids[] = { | |||
1151 | }, | 1151 | }, |
1152 | }; | 1152 | }; |
1153 | 1153 | ||
1154 | static struct davinci_gpio_platform_data da830_gpio_platform_data = { | ||
1155 | .ngpio = 128, | ||
1156 | .intc_irq_num = DA830_N_CP_INTC_IRQ, | ||
1157 | }; | ||
1158 | |||
1159 | int __init da830_register_gpio(void) | ||
1160 | { | ||
1161 | return da8xx_register_gpio(&da830_gpio_platform_data); | ||
1162 | } | ||
1163 | |||
1154 | static struct davinci_timer_instance da830_timer_instance[2] = { | 1164 | static struct davinci_timer_instance da830_timer_instance[2] = { |
1155 | { | 1165 | { |
1156 | .base = DA8XX_TIMER64P0_BASE, | 1166 | .base = DA8XX_TIMER64P0_BASE, |
@@ -1196,10 +1206,6 @@ static struct davinci_soc_info davinci_soc_info_da830 = { | |||
1196 | .intc_irq_prios = da830_default_priorities, | 1206 | .intc_irq_prios = da830_default_priorities, |
1197 | .intc_irq_num = DA830_N_CP_INTC_IRQ, | 1207 | .intc_irq_num = DA830_N_CP_INTC_IRQ, |
1198 | .timer_info = &da830_timer_info, | 1208 | .timer_info = &da830_timer_info, |
1199 | .gpio_type = GPIO_TYPE_DAVINCI, | ||
1200 | .gpio_base = DA8XX_GPIO_BASE, | ||
1201 | .gpio_num = 128, | ||
1202 | .gpio_irq = IRQ_DA8XX_GPIO0, | ||
1203 | .emac_pdata = &da8xx_emac_pdata, | 1209 | .emac_pdata = &da8xx_emac_pdata, |
1204 | }; | 1210 | }; |
1205 | 1211 | ||
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c index f56e5fbfa2fd..352984e1528a 100644 --- a/arch/arm/mach-davinci/da850.c +++ b/arch/arm/mach-davinci/da850.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/cpufreq.h> | 18 | #include <linux/cpufreq.h> |
19 | #include <linux/regulator/consumer.h> | 19 | #include <linux/regulator/consumer.h> |
20 | #include <linux/platform_data/gpio-davinci.h> | ||
20 | 21 | ||
21 | #include <asm/mach/map.h> | 22 | #include <asm/mach/map.h> |
22 | 23 | ||
@@ -28,7 +29,6 @@ | |||
28 | #include <mach/da8xx.h> | 29 | #include <mach/da8xx.h> |
29 | #include <mach/cpufreq.h> | 30 | #include <mach/cpufreq.h> |
30 | #include <mach/pm.h> | 31 | #include <mach/pm.h> |
31 | #include <mach/gpio-davinci.h> | ||
32 | 32 | ||
33 | #include "clock.h" | 33 | #include "clock.h" |
34 | #include "mux.h" | 34 | #include "mux.h" |
@@ -1281,6 +1281,16 @@ int __init da850_register_vpif_capture(struct vpif_capture_config | |||
1281 | return platform_device_register(&da850_vpif_capture_dev); | 1281 | return platform_device_register(&da850_vpif_capture_dev); |
1282 | } | 1282 | } |
1283 | 1283 | ||
1284 | static struct davinci_gpio_platform_data da850_gpio_platform_data = { | ||
1285 | .ngpio = 144, | ||
1286 | .intc_irq_num = DA850_N_CP_INTC_IRQ, | ||
1287 | }; | ||
1288 | |||
1289 | int __init da850_register_gpio(void) | ||
1290 | { | ||
1291 | return da8xx_register_gpio(&da850_gpio_platform_data); | ||
1292 | } | ||
1293 | |||
1284 | static struct davinci_soc_info davinci_soc_info_da850 = { | 1294 | static struct davinci_soc_info davinci_soc_info_da850 = { |
1285 | .io_desc = da850_io_desc, | 1295 | .io_desc = da850_io_desc, |
1286 | .io_desc_num = ARRAY_SIZE(da850_io_desc), | 1296 | .io_desc_num = ARRAY_SIZE(da850_io_desc), |
@@ -1298,10 +1308,6 @@ static struct davinci_soc_info davinci_soc_info_da850 = { | |||
1298 | .intc_irq_prios = da850_default_priorities, | 1308 | .intc_irq_prios = da850_default_priorities, |
1299 | .intc_irq_num = DA850_N_CP_INTC_IRQ, | 1309 | .intc_irq_num = DA850_N_CP_INTC_IRQ, |
1300 | .timer_info = &da850_timer_info, | 1310 | .timer_info = &da850_timer_info, |
1301 | .gpio_type = GPIO_TYPE_DAVINCI, | ||
1302 | .gpio_base = DA8XX_GPIO_BASE, | ||
1303 | .gpio_num = 144, | ||
1304 | .gpio_irq = IRQ_DA8XX_GPIO0, | ||
1305 | .emac_pdata = &da8xx_emac_pdata, | 1311 | .emac_pdata = &da8xx_emac_pdata, |
1306 | .sram_dma = DA8XX_SHARED_RAM_BASE, | 1312 | .sram_dma = DA8XX_SHARED_RAM_BASE, |
1307 | .sram_len = SZ_128K, | 1313 | .sram_len = SZ_128K, |
diff --git a/arch/arm/mach-davinci/davinci.h b/arch/arm/mach-davinci/davinci.h index 2ab5d577186f..2eebc4338802 100644 --- a/arch/arm/mach-davinci/davinci.h +++ b/arch/arm/mach-davinci/davinci.h | |||
@@ -53,6 +53,9 @@ extern void __iomem *davinci_sysmod_base; | |||
53 | #define DAVINCI_SYSMOD_VIRT(x) (davinci_sysmod_base + (x)) | 53 | #define DAVINCI_SYSMOD_VIRT(x) (davinci_sysmod_base + (x)) |
54 | void davinci_map_sysmod(void); | 54 | void davinci_map_sysmod(void); |
55 | 55 | ||
56 | #define DAVINCI_GPIO_BASE 0x01C67000 | ||
57 | int davinci_gpio_register(struct resource *res, int size, void *pdata); | ||
58 | |||
56 | /* DM355 base addresses */ | 59 | /* DM355 base addresses */ |
57 | #define DM355_ASYNC_EMIF_CONTROL_BASE 0x01e10000 | 60 | #define DM355_ASYNC_EMIF_CONTROL_BASE 0x01e10000 |
58 | #define DM355_ASYNC_EMIF_DATA_CE0_BASE 0x02000000 | 61 | #define DM355_ASYNC_EMIF_DATA_CE0_BASE 0x02000000 |
@@ -82,6 +85,7 @@ void dm355_init_spi0(unsigned chipselect_mask, | |||
82 | const struct spi_board_info *info, unsigned len); | 85 | const struct spi_board_info *info, unsigned len); |
83 | void dm355_init_asp1(u32 evt_enable, struct snd_platform_data *pdata); | 86 | void dm355_init_asp1(u32 evt_enable, struct snd_platform_data *pdata); |
84 | int dm355_init_video(struct vpfe_config *, struct vpbe_config *); | 87 | int dm355_init_video(struct vpfe_config *, struct vpbe_config *); |
88 | int dm355_gpio_register(void); | ||
85 | 89 | ||
86 | /* DM365 function declarations */ | 90 | /* DM365 function declarations */ |
87 | void dm365_init(void); | 91 | void dm365_init(void); |
@@ -92,11 +96,13 @@ void dm365_init_rtc(void); | |||
92 | void dm365_init_spi0(unsigned chipselect_mask, | 96 | void dm365_init_spi0(unsigned chipselect_mask, |
93 | const struct spi_board_info *info, unsigned len); | 97 | const struct spi_board_info *info, unsigned len); |
94 | int dm365_init_video(struct vpfe_config *, struct vpbe_config *); | 98 | int dm365_init_video(struct vpfe_config *, struct vpbe_config *); |
99 | int dm365_gpio_register(void); | ||
95 | 100 | ||
96 | /* DM644x function declarations */ | 101 | /* DM644x function declarations */ |
97 | void dm644x_init(void); | 102 | void dm644x_init(void); |
98 | void dm644x_init_asp(struct snd_platform_data *pdata); | 103 | void dm644x_init_asp(struct snd_platform_data *pdata); |
99 | int dm644x_init_video(struct vpfe_config *, struct vpbe_config *); | 104 | int dm644x_init_video(struct vpfe_config *, struct vpbe_config *); |
105 | int dm644x_gpio_register(void); | ||
100 | 106 | ||
101 | /* DM646x function declarations */ | 107 | /* DM646x function declarations */ |
102 | void dm646x_init(void); | 108 | void dm646x_init(void); |
@@ -106,6 +112,7 @@ int dm646x_init_edma(struct edma_rsv_info *rsv); | |||
106 | void dm646x_video_init(void); | 112 | void dm646x_video_init(void); |
107 | void dm646x_setup_vpif(struct vpif_display_config *, | 113 | void dm646x_setup_vpif(struct vpif_display_config *, |
108 | struct vpif_capture_config *); | 114 | struct vpif_capture_config *); |
115 | int dm646x_gpio_register(void); | ||
109 | 116 | ||
110 | extern struct platform_device dm365_serial_device[]; | 117 | extern struct platform_device dm365_serial_device[]; |
111 | extern struct platform_device dm355_serial_device[]; | 118 | extern struct platform_device dm355_serial_device[]; |
diff --git a/arch/arm/mach-davinci/devices-da8xx.c b/arch/arm/mach-davinci/devices-da8xx.c index 2e473fefd71e..c46eccbbd512 100644 --- a/arch/arm/mach-davinci/devices-da8xx.c +++ b/arch/arm/mach-davinci/devices-da8xx.c | |||
@@ -665,6 +665,32 @@ int __init da8xx_register_lcdc(struct da8xx_lcdc_platform_data *pdata) | |||
665 | return platform_device_register(&da8xx_lcdc_device); | 665 | return platform_device_register(&da8xx_lcdc_device); |
666 | } | 666 | } |
667 | 667 | ||
668 | static struct resource da8xx_gpio_resources[] = { | ||
669 | { /* registers */ | ||
670 | .start = DA8XX_GPIO_BASE, | ||
671 | .end = DA8XX_GPIO_BASE + SZ_4K - 1, | ||
672 | .flags = IORESOURCE_MEM, | ||
673 | }, | ||
674 | { /* interrupt */ | ||
675 | .start = IRQ_DA8XX_GPIO0, | ||
676 | .end = IRQ_DA8XX_GPIO8, | ||
677 | .flags = IORESOURCE_IRQ, | ||
678 | }, | ||
679 | }; | ||
680 | |||
681 | static struct platform_device da8xx_gpio_device = { | ||
682 | .name = "davinci_gpio", | ||
683 | .id = -1, | ||
684 | .num_resources = ARRAY_SIZE(da8xx_gpio_resources), | ||
685 | .resource = da8xx_gpio_resources, | ||
686 | }; | ||
687 | |||
688 | int __init da8xx_register_gpio(void *pdata) | ||
689 | { | ||
690 | da8xx_gpio_device.dev.platform_data = pdata; | ||
691 | return platform_device_register(&da8xx_gpio_device); | ||
692 | } | ||
693 | |||
668 | static struct resource da8xx_mmcsd0_resources[] = { | 694 | static struct resource da8xx_mmcsd0_resources[] = { |
669 | { /* registers */ | 695 | { /* registers */ |
670 | .start = DA8XX_MMCSD0_BASE, | 696 | .start = DA8XX_MMCSD0_BASE, |
diff --git a/arch/arm/mach-davinci/devices.c b/arch/arm/mach-davinci/devices.c index 111573c0aad1..3996e98f52fb 100644 --- a/arch/arm/mach-davinci/devices.c +++ b/arch/arm/mach-davinci/devices.c | |||
@@ -318,6 +318,19 @@ static void davinci_init_wdt(void) | |||
318 | platform_device_register(&davinci_wdt_device); | 318 | platform_device_register(&davinci_wdt_device); |
319 | } | 319 | } |
320 | 320 | ||
321 | static struct platform_device davinci_gpio_device = { | ||
322 | .name = "davinci_gpio", | ||
323 | .id = -1, | ||
324 | }; | ||
325 | |||
326 | int davinci_gpio_register(struct resource *res, int size, void *pdata) | ||
327 | { | ||
328 | davinci_gpio_device.resource = res; | ||
329 | davinci_gpio_device.num_resources = size; | ||
330 | davinci_gpio_device.dev.platform_data = pdata; | ||
331 | return platform_device_register(&davinci_gpio_device); | ||
332 | } | ||
333 | |||
321 | /*-------------------------------------------------------------------------*/ | 334 | /*-------------------------------------------------------------------------*/ |
322 | 335 | ||
323 | /*-------------------------------------------------------------------------*/ | 336 | /*-------------------------------------------------------------------------*/ |
diff --git a/arch/arm/mach-davinci/dm355.c b/arch/arm/mach-davinci/dm355.c index 3eaa5f6b2160..ef9ff1fb6f52 100644 --- a/arch/arm/mach-davinci/dm355.c +++ b/arch/arm/mach-davinci/dm355.c | |||
@@ -13,8 +13,10 @@ | |||
13 | #include <linux/serial_8250.h> | 13 | #include <linux/serial_8250.h> |
14 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
15 | #include <linux/dma-mapping.h> | 15 | #include <linux/dma-mapping.h> |
16 | |||
17 | #include <linux/spi/spi.h> | 16 | #include <linux/spi/spi.h> |
17 | #include <linux/platform_data/edma.h> | ||
18 | #include <linux/platform_data/gpio-davinci.h> | ||
19 | #include <linux/platform_data/spi-davinci.h> | ||
18 | 20 | ||
19 | #include <asm/mach/map.h> | 21 | #include <asm/mach/map.h> |
20 | 22 | ||
@@ -25,9 +27,6 @@ | |||
25 | #include <mach/time.h> | 27 | #include <mach/time.h> |
26 | #include <mach/serial.h> | 28 | #include <mach/serial.h> |
27 | #include <mach/common.h> | 29 | #include <mach/common.h> |
28 | #include <linux/platform_data/spi-davinci.h> | ||
29 | #include <mach/gpio-davinci.h> | ||
30 | #include <linux/platform_data/edma.h> | ||
31 | 30 | ||
32 | #include "davinci.h" | 31 | #include "davinci.h" |
33 | #include "clock.h" | 32 | #include "clock.h" |
@@ -886,6 +885,30 @@ static struct platform_device dm355_vpbe_dev = { | |||
886 | }, | 885 | }, |
887 | }; | 886 | }; |
888 | 887 | ||
888 | static struct resource dm355_gpio_resources[] = { | ||
889 | { /* registers */ | ||
890 | .start = DAVINCI_GPIO_BASE, | ||
891 | .end = DAVINCI_GPIO_BASE + SZ_4K - 1, | ||
892 | .flags = IORESOURCE_MEM, | ||
893 | }, | ||
894 | { /* interrupt */ | ||
895 | .start = IRQ_DM355_GPIOBNK0, | ||
896 | .end = IRQ_DM355_GPIOBNK6, | ||
897 | .flags = IORESOURCE_IRQ, | ||
898 | }, | ||
899 | }; | ||
900 | |||
901 | static struct davinci_gpio_platform_data dm355_gpio_platform_data = { | ||
902 | .ngpio = 104, | ||
903 | .intc_irq_num = DAVINCI_N_AINTC_IRQ, | ||
904 | }; | ||
905 | |||
906 | int __init dm355_gpio_register(void) | ||
907 | { | ||
908 | return davinci_gpio_register(dm355_gpio_resources, | ||
909 | sizeof(dm355_gpio_resources), | ||
910 | &dm355_gpio_platform_data); | ||
911 | } | ||
889 | /*----------------------------------------------------------------------*/ | 912 | /*----------------------------------------------------------------------*/ |
890 | 913 | ||
891 | static struct map_desc dm355_io_desc[] = { | 914 | static struct map_desc dm355_io_desc[] = { |
@@ -1005,10 +1028,6 @@ static struct davinci_soc_info davinci_soc_info_dm355 = { | |||
1005 | .intc_irq_prios = dm355_default_priorities, | 1028 | .intc_irq_prios = dm355_default_priorities, |
1006 | .intc_irq_num = DAVINCI_N_AINTC_IRQ, | 1029 | .intc_irq_num = DAVINCI_N_AINTC_IRQ, |
1007 | .timer_info = &dm355_timer_info, | 1030 | .timer_info = &dm355_timer_info, |
1008 | .gpio_type = GPIO_TYPE_DAVINCI, | ||
1009 | .gpio_base = DAVINCI_GPIO_BASE, | ||
1010 | .gpio_num = 104, | ||
1011 | .gpio_irq = IRQ_DM355_GPIOBNK0, | ||
1012 | .sram_dma = 0x00010000, | 1031 | .sram_dma = 0x00010000, |
1013 | .sram_len = SZ_32K, | 1032 | .sram_len = SZ_32K, |
1014 | }; | 1033 | }; |
diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c index c29e324eb0bb..1511a0680f9a 100644 --- a/arch/arm/mach-davinci/dm365.c +++ b/arch/arm/mach-davinci/dm365.c | |||
@@ -19,6 +19,9 @@ | |||
19 | #include <linux/dma-mapping.h> | 19 | #include <linux/dma-mapping.h> |
20 | #include <linux/spi/spi.h> | 20 | #include <linux/spi/spi.h> |
21 | #include <linux/platform_data/edma.h> | 21 | #include <linux/platform_data/edma.h> |
22 | #include <linux/platform_data/gpio-davinci.h> | ||
23 | #include <linux/platform_data/keyscan-davinci.h> | ||
24 | #include <linux/platform_data/spi-davinci.h> | ||
22 | 25 | ||
23 | #include <asm/mach/map.h> | 26 | #include <asm/mach/map.h> |
24 | 27 | ||
@@ -29,9 +32,6 @@ | |||
29 | #include <mach/time.h> | 32 | #include <mach/time.h> |
30 | #include <mach/serial.h> | 33 | #include <mach/serial.h> |
31 | #include <mach/common.h> | 34 | #include <mach/common.h> |
32 | #include <linux/platform_data/keyscan-davinci.h> | ||
33 | #include <linux/platform_data/spi-davinci.h> | ||
34 | #include <mach/gpio-davinci.h> | ||
35 | 35 | ||
36 | #include "davinci.h" | 36 | #include "davinci.h" |
37 | #include "clock.h" | 37 | #include "clock.h" |
@@ -698,6 +698,32 @@ void __init dm365_init_spi0(unsigned chipselect_mask, | |||
698 | platform_device_register(&dm365_spi0_device); | 698 | platform_device_register(&dm365_spi0_device); |
699 | } | 699 | } |
700 | 700 | ||
701 | static struct resource dm365_gpio_resources[] = { | ||
702 | { /* registers */ | ||
703 | .start = DAVINCI_GPIO_BASE, | ||
704 | .end = DAVINCI_GPIO_BASE + SZ_4K - 1, | ||
705 | .flags = IORESOURCE_MEM, | ||
706 | }, | ||
707 | { /* interrupt */ | ||
708 | .start = IRQ_DM365_GPIO0, | ||
709 | .end = IRQ_DM365_GPIO7, | ||
710 | .flags = IORESOURCE_IRQ, | ||
711 | }, | ||
712 | }; | ||
713 | |||
714 | static struct davinci_gpio_platform_data dm365_gpio_platform_data = { | ||
715 | .ngpio = 104, | ||
716 | .intc_irq_num = DAVINCI_N_AINTC_IRQ, | ||
717 | .gpio_unbanked = 8, | ||
718 | }; | ||
719 | |||
720 | int __init dm365_gpio_register(void) | ||
721 | { | ||
722 | return davinci_gpio_register(dm365_gpio_resources, | ||
723 | sizeof(dm365_gpio_resources), | ||
724 | &dm365_gpio_platform_data); | ||
725 | } | ||
726 | |||
701 | static struct emac_platform_data dm365_emac_pdata = { | 727 | static struct emac_platform_data dm365_emac_pdata = { |
702 | .ctrl_reg_offset = DM365_EMAC_CNTRL_OFFSET, | 728 | .ctrl_reg_offset = DM365_EMAC_CNTRL_OFFSET, |
703 | .ctrl_mod_reg_offset = DM365_EMAC_CNTRL_MOD_OFFSET, | 729 | .ctrl_mod_reg_offset = DM365_EMAC_CNTRL_MOD_OFFSET, |
@@ -1105,11 +1131,6 @@ static struct davinci_soc_info davinci_soc_info_dm365 = { | |||
1105 | .intc_irq_prios = dm365_default_priorities, | 1131 | .intc_irq_prios = dm365_default_priorities, |
1106 | .intc_irq_num = DAVINCI_N_AINTC_IRQ, | 1132 | .intc_irq_num = DAVINCI_N_AINTC_IRQ, |
1107 | .timer_info = &dm365_timer_info, | 1133 | .timer_info = &dm365_timer_info, |
1108 | .gpio_type = GPIO_TYPE_DAVINCI, | ||
1109 | .gpio_base = DAVINCI_GPIO_BASE, | ||
1110 | .gpio_num = 104, | ||
1111 | .gpio_irq = IRQ_DM365_GPIO0, | ||
1112 | .gpio_unbanked = 8, /* really 16 ... skip muxed GPIOs */ | ||
1113 | .emac_pdata = &dm365_emac_pdata, | 1134 | .emac_pdata = &dm365_emac_pdata, |
1114 | .sram_dma = 0x00010000, | 1135 | .sram_dma = 0x00010000, |
1115 | .sram_len = SZ_32K, | 1136 | .sram_len = SZ_32K, |
diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c index 4f74682293d6..143a3217e8ef 100644 --- a/arch/arm/mach-davinci/dm644x.c +++ b/arch/arm/mach-davinci/dm644x.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/serial_8250.h> | 13 | #include <linux/serial_8250.h> |
14 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
15 | #include <linux/platform_data/edma.h> | 15 | #include <linux/platform_data/edma.h> |
16 | #include <linux/platform_data/gpio-davinci.h> | ||
16 | 17 | ||
17 | #include <asm/mach/map.h> | 18 | #include <asm/mach/map.h> |
18 | 19 | ||
@@ -23,7 +24,6 @@ | |||
23 | #include <mach/time.h> | 24 | #include <mach/time.h> |
24 | #include <mach/serial.h> | 25 | #include <mach/serial.h> |
25 | #include <mach/common.h> | 26 | #include <mach/common.h> |
26 | #include <mach/gpio-davinci.h> | ||
27 | 27 | ||
28 | #include "davinci.h" | 28 | #include "davinci.h" |
29 | #include "clock.h" | 29 | #include "clock.h" |
@@ -771,6 +771,30 @@ static struct platform_device dm644x_vpbe_dev = { | |||
771 | }, | 771 | }, |
772 | }; | 772 | }; |
773 | 773 | ||
774 | static struct resource dm644_gpio_resources[] = { | ||
775 | { /* registers */ | ||
776 | .start = DAVINCI_GPIO_BASE, | ||
777 | .end = DAVINCI_GPIO_BASE + SZ_4K - 1, | ||
778 | .flags = IORESOURCE_MEM, | ||
779 | }, | ||
780 | { /* interrupt */ | ||
781 | .start = IRQ_GPIOBNK0, | ||
782 | .end = IRQ_GPIOBNK4, | ||
783 | .flags = IORESOURCE_IRQ, | ||
784 | }, | ||
785 | }; | ||
786 | |||
787 | static struct davinci_gpio_platform_data dm644_gpio_platform_data = { | ||
788 | .ngpio = 71, | ||
789 | .intc_irq_num = DAVINCI_N_AINTC_IRQ, | ||
790 | }; | ||
791 | |||
792 | int __init dm644x_gpio_register(void) | ||
793 | { | ||
794 | return davinci_gpio_register(dm644_gpio_resources, | ||
795 | sizeof(dm644_gpio_resources), | ||
796 | &dm644_gpio_platform_data); | ||
797 | } | ||
774 | /*----------------------------------------------------------------------*/ | 798 | /*----------------------------------------------------------------------*/ |
775 | 799 | ||
776 | static struct map_desc dm644x_io_desc[] = { | 800 | static struct map_desc dm644x_io_desc[] = { |
@@ -897,10 +921,6 @@ static struct davinci_soc_info davinci_soc_info_dm644x = { | |||
897 | .intc_irq_prios = dm644x_default_priorities, | 921 | .intc_irq_prios = dm644x_default_priorities, |
898 | .intc_irq_num = DAVINCI_N_AINTC_IRQ, | 922 | .intc_irq_num = DAVINCI_N_AINTC_IRQ, |
899 | .timer_info = &dm644x_timer_info, | 923 | .timer_info = &dm644x_timer_info, |
900 | .gpio_type = GPIO_TYPE_DAVINCI, | ||
901 | .gpio_base = DAVINCI_GPIO_BASE, | ||
902 | .gpio_num = 71, | ||
903 | .gpio_irq = IRQ_GPIOBNK0, | ||
904 | .emac_pdata = &dm644x_emac_pdata, | 924 | .emac_pdata = &dm644x_emac_pdata, |
905 | .sram_dma = 0x00008000, | 925 | .sram_dma = 0x00008000, |
906 | .sram_len = SZ_16K, | 926 | .sram_len = SZ_16K, |
diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c index 68f8d1f1aca1..2a73f299c1d0 100644 --- a/arch/arm/mach-davinci/dm646x.c +++ b/arch/arm/mach-davinci/dm646x.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/serial_8250.h> | 14 | #include <linux/serial_8250.h> |
15 | #include <linux/platform_device.h> | 15 | #include <linux/platform_device.h> |
16 | #include <linux/platform_data/edma.h> | 16 | #include <linux/platform_data/edma.h> |
17 | #include <linux/platform_data/gpio-davinci.h> | ||
17 | 18 | ||
18 | #include <asm/mach/map.h> | 19 | #include <asm/mach/map.h> |
19 | 20 | ||
@@ -24,7 +25,6 @@ | |||
24 | #include <mach/time.h> | 25 | #include <mach/time.h> |
25 | #include <mach/serial.h> | 26 | #include <mach/serial.h> |
26 | #include <mach/common.h> | 27 | #include <mach/common.h> |
27 | #include <mach/gpio-davinci.h> | ||
28 | 28 | ||
29 | #include "davinci.h" | 29 | #include "davinci.h" |
30 | #include "clock.h" | 30 | #include "clock.h" |
@@ -748,6 +748,30 @@ static struct platform_device vpif_capture_dev = { | |||
748 | .num_resources = ARRAY_SIZE(vpif_capture_resource), | 748 | .num_resources = ARRAY_SIZE(vpif_capture_resource), |
749 | }; | 749 | }; |
750 | 750 | ||
751 | static struct resource dm646x_gpio_resources[] = { | ||
752 | { /* registers */ | ||
753 | .start = DAVINCI_GPIO_BASE, | ||
754 | .end = DAVINCI_GPIO_BASE + SZ_4K - 1, | ||
755 | .flags = IORESOURCE_MEM, | ||
756 | }, | ||
757 | { /* interrupt */ | ||
758 | .start = IRQ_DM646X_GPIOBNK0, | ||
759 | .end = IRQ_DM646X_GPIOBNK2, | ||
760 | .flags = IORESOURCE_IRQ, | ||
761 | }, | ||
762 | }; | ||
763 | |||
764 | static struct davinci_gpio_platform_data dm646x_gpio_platform_data = { | ||
765 | .ngpio = 43, | ||
766 | .intc_irq_num = DAVINCI_N_AINTC_IRQ, | ||
767 | }; | ||
768 | |||
769 | int __init dm646x_gpio_register(void) | ||
770 | { | ||
771 | return davinci_gpio_register(dm646x_gpio_resources, | ||
772 | sizeof(dm646x_gpio_resources), | ||
773 | &dm646x_gpio_platform_data); | ||
774 | } | ||
751 | /*----------------------------------------------------------------------*/ | 775 | /*----------------------------------------------------------------------*/ |
752 | 776 | ||
753 | static struct map_desc dm646x_io_desc[] = { | 777 | static struct map_desc dm646x_io_desc[] = { |
@@ -874,10 +898,6 @@ static struct davinci_soc_info davinci_soc_info_dm646x = { | |||
874 | .intc_irq_prios = dm646x_default_priorities, | 898 | .intc_irq_prios = dm646x_default_priorities, |
875 | .intc_irq_num = DAVINCI_N_AINTC_IRQ, | 899 | .intc_irq_num = DAVINCI_N_AINTC_IRQ, |
876 | .timer_info = &dm646x_timer_info, | 900 | .timer_info = &dm646x_timer_info, |
877 | .gpio_type = GPIO_TYPE_DAVINCI, | ||
878 | .gpio_base = DAVINCI_GPIO_BASE, | ||
879 | .gpio_num = 43, /* Only 33 usable */ | ||
880 | .gpio_irq = IRQ_DM646X_GPIOBNK0, | ||
881 | .emac_pdata = &dm646x_emac_pdata, | 901 | .emac_pdata = &dm646x_emac_pdata, |
882 | .sram_dma = 0x10010000, | 902 | .sram_dma = 0x10010000, |
883 | .sram_len = SZ_32K, | 903 | .sram_len = SZ_32K, |
diff --git a/arch/arm/mach-davinci/include/mach/da8xx.h b/arch/arm/mach-davinci/include/mach/da8xx.h index aae53072c0eb..39e58b48e826 100644 --- a/arch/arm/mach-davinci/include/mach/da8xx.h +++ b/arch/arm/mach-davinci/include/mach/da8xx.h | |||
@@ -97,6 +97,7 @@ int da8xx_register_mmcsd0(struct davinci_mmc_config *config); | |||
97 | int da850_register_mmcsd1(struct davinci_mmc_config *config); | 97 | int da850_register_mmcsd1(struct davinci_mmc_config *config); |
98 | void da8xx_register_mcasp(int id, struct snd_platform_data *pdata); | 98 | void da8xx_register_mcasp(int id, struct snd_platform_data *pdata); |
99 | int da8xx_register_rtc(void); | 99 | int da8xx_register_rtc(void); |
100 | int da8xx_register_gpio(void *pdata); | ||
100 | int da850_register_cpufreq(char *async_clk); | 101 | int da850_register_cpufreq(char *async_clk); |
101 | int da8xx_register_cpuidle(void); | 102 | int da8xx_register_cpuidle(void); |
102 | void __iomem *da8xx_get_mem_ctlr(void); | 103 | void __iomem *da8xx_get_mem_ctlr(void); |
@@ -110,6 +111,8 @@ int da850_register_vpif_capture | |||
110 | void da8xx_restart(enum reboot_mode mode, const char *cmd); | 111 | void da8xx_restart(enum reboot_mode mode, const char *cmd); |
111 | void da8xx_rproc_reserve_cma(void); | 112 | void da8xx_rproc_reserve_cma(void); |
112 | int da8xx_register_rproc(void); | 113 | int da8xx_register_rproc(void); |
114 | int da850_register_gpio(void); | ||
115 | int da830_register_gpio(void); | ||
113 | 116 | ||
114 | extern struct platform_device da8xx_serial_device[]; | 117 | extern struct platform_device da8xx_serial_device[]; |
115 | extern struct emac_platform_data da8xx_emac_pdata; | 118 | extern struct emac_platform_data da8xx_emac_pdata; |
diff --git a/arch/arm/mach-davinci/include/mach/gpio-davinci.h b/arch/arm/mach-davinci/include/mach/gpio-davinci.h deleted file mode 100644 index 1fdd1fd35448..000000000000 --- a/arch/arm/mach-davinci/include/mach/gpio-davinci.h +++ /dev/null | |||
@@ -1,91 +0,0 @@ | |||
1 | /* | ||
2 | * TI DaVinci GPIO Support | ||
3 | * | ||
4 | * Copyright (c) 2006 David Brownell | ||
5 | * Copyright (c) 2007, MontaVista Software, Inc. <source@mvista.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | */ | ||
12 | |||
13 | #ifndef __DAVINCI_DAVINCI_GPIO_H | ||
14 | #define __DAVINCI_DAVINCI_GPIO_H | ||
15 | |||
16 | #include <linux/io.h> | ||
17 | #include <linux/spinlock.h> | ||
18 | |||
19 | #include <asm-generic/gpio.h> | ||
20 | |||
21 | #include <mach/irqs.h> | ||
22 | #include <mach/common.h> | ||
23 | |||
24 | #define DAVINCI_GPIO_BASE 0x01C67000 | ||
25 | |||
26 | enum davinci_gpio_type { | ||
27 | GPIO_TYPE_DAVINCI = 0, | ||
28 | GPIO_TYPE_TNETV107X, | ||
29 | }; | ||
30 | |||
31 | /* | ||
32 | * basic gpio routines | ||
33 | * | ||
34 | * board-specific init should be done by arch/.../.../board-XXX.c (maybe | ||
35 | * initializing banks together) rather than boot loaders; kexec() won't | ||
36 | * go through boot loaders. | ||
37 | * | ||
38 | * the gpio clock will be turned on when gpios are used, and you may also | ||
39 | * need to pay attention to PINMUX registers to be sure those pins are | ||
40 | * used as gpios, not with other peripherals. | ||
41 | * | ||
42 | * On-chip GPIOs are numbered 0..(DAVINCI_N_GPIO-1). For documentation, | ||
43 | * and maybe for later updates, code may write GPIO(N). These may be | ||
44 | * all 1.8V signals, all 3.3V ones, or a mix of the two. A given chip | ||
45 | * may not support all the GPIOs in that range. | ||
46 | * | ||
47 | * GPIOs can also be on external chips, numbered after the ones built-in | ||
48 | * to the DaVinci chip. For now, they won't be usable as IRQ sources. | ||
49 | */ | ||
50 | #define GPIO(X) (X) /* 0 <= X <= (DAVINCI_N_GPIO - 1) */ | ||
51 | |||
52 | /* Convert GPIO signal to GPIO pin number */ | ||
53 | #define GPIO_TO_PIN(bank, gpio) (16 * (bank) + (gpio)) | ||
54 | |||
55 | struct davinci_gpio_controller { | ||
56 | struct gpio_chip chip; | ||
57 | int irq_base; | ||
58 | spinlock_t lock; | ||
59 | void __iomem *regs; | ||
60 | void __iomem *set_data; | ||
61 | void __iomem *clr_data; | ||
62 | void __iomem *in_data; | ||
63 | }; | ||
64 | |||
65 | /* The __gpio_to_controller() and __gpio_mask() functions inline to constants | ||
66 | * with constant parameters; or in outlined code they execute at runtime. | ||
67 | * | ||
68 | * You'd access the controller directly when reading or writing more than | ||
69 | * one gpio value at a time, and to support wired logic where the value | ||
70 | * being driven by the cpu need not match the value read back. | ||
71 | * | ||
72 | * These are NOT part of the cross-platform GPIO interface | ||
73 | */ | ||
74 | static inline struct davinci_gpio_controller * | ||
75 | __gpio_to_controller(unsigned gpio) | ||
76 | { | ||
77 | struct davinci_gpio_controller *ctlrs = davinci_soc_info.gpio_ctlrs; | ||
78 | int index = gpio / 32; | ||
79 | |||
80 | if (!ctlrs || index >= davinci_soc_info.gpio_ctlrs_num) | ||
81 | return NULL; | ||
82 | |||
83 | return ctlrs + index; | ||
84 | } | ||
85 | |||
86 | static inline u32 __gpio_mask(unsigned gpio) | ||
87 | { | ||
88 | return 1 << (gpio % 32); | ||
89 | } | ||
90 | |||
91 | #endif /* __DAVINCI_DAVINCI_GPIO_H */ | ||
diff --git a/arch/arm/mach-davinci/include/mach/gpio.h b/arch/arm/mach-davinci/include/mach/gpio.h deleted file mode 100644 index 960e9de47e1e..000000000000 --- a/arch/arm/mach-davinci/include/mach/gpio.h +++ /dev/null | |||
@@ -1,88 +0,0 @@ | |||
1 | /* | ||
2 | * TI DaVinci GPIO Support | ||
3 | * | ||
4 | * Copyright (c) 2006 David Brownell | ||
5 | * Copyright (c) 2007, MontaVista Software, Inc. <source@mvista.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | */ | ||
12 | |||
13 | #ifndef __DAVINCI_GPIO_H | ||
14 | #define __DAVINCI_GPIO_H | ||
15 | |||
16 | #include <asm-generic/gpio.h> | ||
17 | |||
18 | #define __ARM_GPIOLIB_COMPLEX | ||
19 | |||
20 | /* The inline versions use the static inlines in the driver header */ | ||
21 | #include "gpio-davinci.h" | ||
22 | |||
23 | /* | ||
24 | * The get/set/clear functions will inline when called with constant | ||
25 | * parameters referencing built-in GPIOs, for low-overhead bitbanging. | ||
26 | * | ||
27 | * gpio_set_value() will inline only on traditional Davinci style controllers | ||
28 | * with distinct set/clear registers. | ||
29 | * | ||
30 | * Otherwise, calls with variable parameters or referencing external | ||
31 | * GPIOs (e.g. on GPIO expander chips) use outlined functions. | ||
32 | */ | ||
33 | static inline void gpio_set_value(unsigned gpio, int value) | ||
34 | { | ||
35 | if (__builtin_constant_p(value) && gpio < davinci_soc_info.gpio_num) { | ||
36 | struct davinci_gpio_controller *ctlr; | ||
37 | u32 mask; | ||
38 | |||
39 | ctlr = __gpio_to_controller(gpio); | ||
40 | |||
41 | if (ctlr->set_data != ctlr->clr_data) { | ||
42 | mask = __gpio_mask(gpio); | ||
43 | if (value) | ||
44 | __raw_writel(mask, ctlr->set_data); | ||
45 | else | ||
46 | __raw_writel(mask, ctlr->clr_data); | ||
47 | return; | ||
48 | } | ||
49 | } | ||
50 | |||
51 | __gpio_set_value(gpio, value); | ||
52 | } | ||
53 | |||
54 | /* Returns zero or nonzero; works for gpios configured as inputs OR | ||
55 | * as outputs, at least for built-in GPIOs. | ||
56 | * | ||
57 | * NOTE: for built-in GPIOs, changes in reported values are synchronized | ||
58 | * to the GPIO clock. This is easily seen after calling gpio_set_value() | ||
59 | * and then immediately gpio_get_value(), where the gpio_get_value() will | ||
60 | * return the old value until the GPIO clock ticks and the new value gets | ||
61 | * latched. | ||
62 | */ | ||
63 | static inline int gpio_get_value(unsigned gpio) | ||
64 | { | ||
65 | struct davinci_gpio_controller *ctlr; | ||
66 | |||
67 | if (!__builtin_constant_p(gpio) || gpio >= davinci_soc_info.gpio_num) | ||
68 | return __gpio_get_value(gpio); | ||
69 | |||
70 | ctlr = __gpio_to_controller(gpio); | ||
71 | return __gpio_mask(gpio) & __raw_readl(ctlr->in_data); | ||
72 | } | ||
73 | |||
74 | static inline int gpio_cansleep(unsigned gpio) | ||
75 | { | ||
76 | if (__builtin_constant_p(gpio) && gpio < davinci_soc_info.gpio_num) | ||
77 | return 0; | ||
78 | else | ||
79 | return __gpio_cansleep(gpio); | ||
80 | } | ||
81 | |||
82 | static inline int irq_to_gpio(unsigned irq) | ||
83 | { | ||
84 | /* don't support the reverse mapping */ | ||
85 | return -ENOSYS; | ||
86 | } | ||
87 | |||
88 | #endif /* __DAVINCI_GPIO_H */ | ||
diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index 17df6db5dca7..8847adf392b7 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c | |||
@@ -15,8 +15,9 @@ | |||
15 | #include <linux/clk.h> | 15 | #include <linux/clk.h> |
16 | #include <linux/err.h> | 16 | #include <linux/err.h> |
17 | #include <linux/io.h> | 17 | #include <linux/io.h> |
18 | 18 | #include <linux/irq.h> | |
19 | #include <asm/mach/irq.h> | 19 | #include <linux/platform_device.h> |
20 | #include <linux/platform_data/gpio-davinci.h> | ||
20 | 21 | ||
21 | struct davinci_gpio_regs { | 22 | struct davinci_gpio_regs { |
22 | u32 dir; | 23 | u32 dir; |
@@ -31,13 +32,14 @@ struct davinci_gpio_regs { | |||
31 | u32 intstat; | 32 | u32 intstat; |
32 | }; | 33 | }; |
33 | 34 | ||
35 | #define BINTEN 0x8 /* GPIO Interrupt Per-Bank Enable Register */ | ||
36 | |||
34 | #define chip2controller(chip) \ | 37 | #define chip2controller(chip) \ |
35 | container_of(chip, struct davinci_gpio_controller, chip) | 38 | container_of(chip, struct davinci_gpio_controller, chip) |
36 | 39 | ||
37 | static struct davinci_gpio_controller chips[DIV_ROUND_UP(DAVINCI_N_GPIO, 32)]; | ||
38 | static void __iomem *gpio_base; | 40 | static void __iomem *gpio_base; |
39 | 41 | ||
40 | static struct davinci_gpio_regs __iomem __init *gpio2regs(unsigned gpio) | 42 | static struct davinci_gpio_regs __iomem *gpio2regs(unsigned gpio) |
41 | { | 43 | { |
42 | void __iomem *ptr; | 44 | void __iomem *ptr; |
43 | 45 | ||
@@ -65,7 +67,7 @@ static inline struct davinci_gpio_regs __iomem *irq2regs(int irq) | |||
65 | return g; | 67 | return g; |
66 | } | 68 | } |
67 | 69 | ||
68 | static int __init davinci_gpio_irq_setup(void); | 70 | static int davinci_gpio_irq_setup(struct platform_device *pdev); |
69 | 71 | ||
70 | /*--------------------------------------------------------------------------*/ | 72 | /*--------------------------------------------------------------------------*/ |
71 | 73 | ||
@@ -131,33 +133,53 @@ davinci_gpio_set(struct gpio_chip *chip, unsigned offset, int value) | |||
131 | __raw_writel((1 << offset), value ? &g->set_data : &g->clr_data); | 133 | __raw_writel((1 << offset), value ? &g->set_data : &g->clr_data); |
132 | } | 134 | } |
133 | 135 | ||
134 | static int __init davinci_gpio_setup(void) | 136 | static int davinci_gpio_probe(struct platform_device *pdev) |
135 | { | 137 | { |
136 | int i, base; | 138 | int i, base; |
137 | unsigned ngpio; | 139 | unsigned ngpio; |
138 | struct davinci_soc_info *soc_info = &davinci_soc_info; | 140 | struct davinci_gpio_controller *chips; |
139 | struct davinci_gpio_regs *regs; | 141 | struct davinci_gpio_platform_data *pdata; |
140 | 142 | struct davinci_gpio_regs __iomem *regs; | |
141 | if (soc_info->gpio_type != GPIO_TYPE_DAVINCI) | 143 | struct device *dev = &pdev->dev; |
142 | return 0; | 144 | struct resource *res; |
145 | |||
146 | pdata = dev->platform_data; | ||
147 | if (!pdata) { | ||
148 | dev_err(dev, "No platform data found\n"); | ||
149 | return -EINVAL; | ||
150 | } | ||
143 | 151 | ||
144 | /* | 152 | /* |
145 | * The gpio banks conceptually expose a segmented bitmap, | 153 | * The gpio banks conceptually expose a segmented bitmap, |
146 | * and "ngpio" is one more than the largest zero-based | 154 | * and "ngpio" is one more than the largest zero-based |
147 | * bit index that's valid. | 155 | * bit index that's valid. |
148 | */ | 156 | */ |
149 | ngpio = soc_info->gpio_num; | 157 | ngpio = pdata->ngpio; |
150 | if (ngpio == 0) { | 158 | if (ngpio == 0) { |
151 | pr_err("GPIO setup: how many GPIOs?\n"); | 159 | dev_err(dev, "How many GPIOs?\n"); |
152 | return -EINVAL; | 160 | return -EINVAL; |
153 | } | 161 | } |
154 | 162 | ||
155 | if (WARN_ON(DAVINCI_N_GPIO < ngpio)) | 163 | if (WARN_ON(DAVINCI_N_GPIO < ngpio)) |
156 | ngpio = DAVINCI_N_GPIO; | 164 | ngpio = DAVINCI_N_GPIO; |
157 | 165 | ||
158 | gpio_base = ioremap(soc_info->gpio_base, SZ_4K); | 166 | chips = devm_kzalloc(dev, |
159 | if (WARN_ON(!gpio_base)) | 167 | ngpio * sizeof(struct davinci_gpio_controller), |
168 | GFP_KERNEL); | ||
169 | if (!chips) { | ||
170 | dev_err(dev, "Memory allocation failed\n"); | ||
160 | return -ENOMEM; | 171 | return -ENOMEM; |
172 | } | ||
173 | |||
174 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
175 | if (!res) { | ||
176 | dev_err(dev, "Invalid memory resource\n"); | ||
177 | return -EBUSY; | ||
178 | } | ||
179 | |||
180 | gpio_base = devm_ioremap_resource(dev, res); | ||
181 | if (IS_ERR(gpio_base)) | ||
182 | return PTR_ERR(gpio_base); | ||
161 | 183 | ||
162 | for (i = 0, base = 0; base < ngpio; i++, base += 32) { | 184 | for (i = 0, base = 0; base < ngpio; i++, base += 32) { |
163 | chips[i].chip.label = "DaVinci"; | 185 | chips[i].chip.label = "DaVinci"; |
@@ -183,13 +205,10 @@ static int __init davinci_gpio_setup(void) | |||
183 | gpiochip_add(&chips[i].chip); | 205 | gpiochip_add(&chips[i].chip); |
184 | } | 206 | } |
185 | 207 | ||
186 | soc_info->gpio_ctlrs = chips; | 208 | platform_set_drvdata(pdev, chips); |
187 | soc_info->gpio_ctlrs_num = DIV_ROUND_UP(ngpio, 32); | 209 | davinci_gpio_irq_setup(pdev); |
188 | |||
189 | davinci_gpio_irq_setup(); | ||
190 | return 0; | 210 | return 0; |
191 | } | 211 | } |
192 | pure_initcall(davinci_gpio_setup); | ||
193 | 212 | ||
194 | /*--------------------------------------------------------------------------*/ | 213 | /*--------------------------------------------------------------------------*/ |
195 | /* | 214 | /* |
@@ -302,13 +321,14 @@ static int gpio_to_irq_banked(struct gpio_chip *chip, unsigned offset) | |||
302 | 321 | ||
303 | static int gpio_to_irq_unbanked(struct gpio_chip *chip, unsigned offset) | 322 | static int gpio_to_irq_unbanked(struct gpio_chip *chip, unsigned offset) |
304 | { | 323 | { |
305 | struct davinci_soc_info *soc_info = &davinci_soc_info; | 324 | struct davinci_gpio_controller *d = chip2controller(chip); |
306 | 325 | ||
307 | /* NOTE: we assume for now that only irqs in the first gpio_chip | 326 | /* |
327 | * NOTE: we assume for now that only irqs in the first gpio_chip | ||
308 | * can provide direct-mapped IRQs to AINTC (up to 32 GPIOs). | 328 | * can provide direct-mapped IRQs to AINTC (up to 32 GPIOs). |
309 | */ | 329 | */ |
310 | if (offset < soc_info->gpio_unbanked) | 330 | if (offset < d->irq_base) |
311 | return soc_info->gpio_irq + offset; | 331 | return d->gpio_irq + offset; |
312 | else | 332 | else |
313 | return -ENODEV; | 333 | return -ENODEV; |
314 | } | 334 | } |
@@ -317,12 +337,11 @@ static int gpio_irq_type_unbanked(struct irq_data *data, unsigned trigger) | |||
317 | { | 337 | { |
318 | struct davinci_gpio_controller *d; | 338 | struct davinci_gpio_controller *d; |
319 | struct davinci_gpio_regs __iomem *g; | 339 | struct davinci_gpio_regs __iomem *g; |
320 | struct davinci_soc_info *soc_info = &davinci_soc_info; | ||
321 | u32 mask; | 340 | u32 mask; |
322 | 341 | ||
323 | d = (struct davinci_gpio_controller *)data->handler_data; | 342 | d = (struct davinci_gpio_controller *)data->handler_data; |
324 | g = (struct davinci_gpio_regs __iomem *)d->regs; | 343 | g = (struct davinci_gpio_regs __iomem *)d->regs; |
325 | mask = __gpio_mask(data->irq - soc_info->gpio_irq); | 344 | mask = __gpio_mask(data->irq - d->gpio_irq); |
326 | 345 | ||
327 | if (trigger & ~(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)) | 346 | if (trigger & ~(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)) |
328 | return -EINVAL; | 347 | return -EINVAL; |
@@ -343,24 +362,33 @@ static int gpio_irq_type_unbanked(struct irq_data *data, unsigned trigger) | |||
343 | * (dm6446) can be set appropriately for GPIOV33 pins. | 362 | * (dm6446) can be set appropriately for GPIOV33 pins. |
344 | */ | 363 | */ |
345 | 364 | ||
346 | static int __init davinci_gpio_irq_setup(void) | 365 | static int davinci_gpio_irq_setup(struct platform_device *pdev) |
347 | { | 366 | { |
348 | unsigned gpio, irq, bank; | 367 | unsigned gpio, irq, bank; |
349 | struct clk *clk; | 368 | struct clk *clk; |
350 | u32 binten = 0; | 369 | u32 binten = 0; |
351 | unsigned ngpio, bank_irq; | 370 | unsigned ngpio, bank_irq; |
352 | struct davinci_soc_info *soc_info = &davinci_soc_info; | 371 | struct device *dev = &pdev->dev; |
353 | struct davinci_gpio_regs __iomem *g; | 372 | struct resource *res; |
373 | struct davinci_gpio_controller *chips = platform_get_drvdata(pdev); | ||
374 | struct davinci_gpio_platform_data *pdata = dev->platform_data; | ||
375 | struct davinci_gpio_regs __iomem *g; | ||
354 | 376 | ||
355 | ngpio = soc_info->gpio_num; | 377 | ngpio = pdata->ngpio; |
378 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | ||
379 | if (!res) { | ||
380 | dev_err(dev, "Invalid IRQ resource\n"); | ||
381 | return -EBUSY; | ||
382 | } | ||
356 | 383 | ||
357 | bank_irq = soc_info->gpio_irq; | 384 | bank_irq = res->start; |
358 | if (bank_irq == 0) { | 385 | |
359 | printk(KERN_ERR "Don't know first GPIO bank IRQ.\n"); | 386 | if (!bank_irq) { |
360 | return -EINVAL; | 387 | dev_err(dev, "Invalid IRQ resource\n"); |
388 | return -ENODEV; | ||
361 | } | 389 | } |
362 | 390 | ||
363 | clk = clk_get(NULL, "gpio"); | 391 | clk = devm_clk_get(dev, "gpio"); |
364 | if (IS_ERR(clk)) { | 392 | if (IS_ERR(clk)) { |
365 | printk(KERN_ERR "Error %ld getting gpio clock?\n", | 393 | printk(KERN_ERR "Error %ld getting gpio clock?\n", |
366 | PTR_ERR(clk)); | 394 | PTR_ERR(clk)); |
@@ -368,16 +396,17 @@ static int __init davinci_gpio_irq_setup(void) | |||
368 | } | 396 | } |
369 | clk_prepare_enable(clk); | 397 | clk_prepare_enable(clk); |
370 | 398 | ||
371 | /* Arrange gpio_to_irq() support, handling either direct IRQs or | 399 | /* |
400 | * Arrange gpio_to_irq() support, handling either direct IRQs or | ||
372 | * banked IRQs. Having GPIOs in the first GPIO bank use direct | 401 | * banked IRQs. Having GPIOs in the first GPIO bank use direct |
373 | * IRQs, while the others use banked IRQs, would need some setup | 402 | * IRQs, while the others use banked IRQs, would need some setup |
374 | * tweaks to recognize hardware which can do that. | 403 | * tweaks to recognize hardware which can do that. |
375 | */ | 404 | */ |
376 | for (gpio = 0, bank = 0; gpio < ngpio; bank++, gpio += 32) { | 405 | for (gpio = 0, bank = 0; gpio < ngpio; bank++, gpio += 32) { |
377 | chips[bank].chip.to_irq = gpio_to_irq_banked; | 406 | chips[bank].chip.to_irq = gpio_to_irq_banked; |
378 | chips[bank].irq_base = soc_info->gpio_unbanked | 407 | chips[bank].irq_base = pdata->gpio_unbanked |
379 | ? -EINVAL | 408 | ? -EINVAL |
380 | : (soc_info->intc_irq_num + gpio); | 409 | : (pdata->intc_irq_num + gpio); |
381 | } | 410 | } |
382 | 411 | ||
383 | /* | 412 | /* |
@@ -385,7 +414,7 @@ static int __init davinci_gpio_irq_setup(void) | |||
385 | * controller only handling trigger modes. We currently assume no | 414 | * controller only handling trigger modes. We currently assume no |
386 | * IRQ mux conflicts; gpio_irq_type_unbanked() is only for GPIOs. | 415 | * IRQ mux conflicts; gpio_irq_type_unbanked() is only for GPIOs. |
387 | */ | 416 | */ |
388 | if (soc_info->gpio_unbanked) { | 417 | if (pdata->gpio_unbanked) { |
389 | static struct irq_chip_type gpio_unbanked; | 418 | static struct irq_chip_type gpio_unbanked; |
390 | 419 | ||
391 | /* pass "bank 0" GPIO IRQs to AINTC */ | 420 | /* pass "bank 0" GPIO IRQs to AINTC */ |
@@ -405,7 +434,7 @@ static int __init davinci_gpio_irq_setup(void) | |||
405 | __raw_writel(~0, &g->set_rising); | 434 | __raw_writel(~0, &g->set_rising); |
406 | 435 | ||
407 | /* set the direct IRQs up to use that irqchip */ | 436 | /* set the direct IRQs up to use that irqchip */ |
408 | for (gpio = 0; gpio < soc_info->gpio_unbanked; gpio++, irq++) { | 437 | for (gpio = 0; gpio < pdata->gpio_unbanked; gpio++, irq++) { |
409 | irq_set_chip(irq, &gpio_unbanked.chip); | 438 | irq_set_chip(irq, &gpio_unbanked.chip); |
410 | irq_set_handler_data(irq, &chips[gpio / 32]); | 439 | irq_set_handler_data(irq, &chips[gpio / 32]); |
411 | irq_set_status_flags(irq, IRQ_TYPE_EDGE_BOTH); | 440 | irq_set_status_flags(irq, IRQ_TYPE_EDGE_BOTH); |
@@ -450,12 +479,31 @@ static int __init davinci_gpio_irq_setup(void) | |||
450 | } | 479 | } |
451 | 480 | ||
452 | done: | 481 | done: |
453 | /* BINTEN -- per-bank interrupt enable. genirq would also let these | 482 | /* |
483 | * BINTEN -- per-bank interrupt enable. genirq would also let these | ||
454 | * bits be set/cleared dynamically. | 484 | * bits be set/cleared dynamically. |
455 | */ | 485 | */ |
456 | __raw_writel(binten, gpio_base + 0x08); | 486 | __raw_writel(binten, gpio_base + BINTEN); |
457 | 487 | ||
458 | printk(KERN_INFO "DaVinci: %d gpio irqs\n", irq - gpio_to_irq(0)); | 488 | printk(KERN_INFO "DaVinci: %d gpio irqs\n", irq - gpio_to_irq(0)); |
459 | 489 | ||
460 | return 0; | 490 | return 0; |
461 | } | 491 | } |
492 | |||
493 | static struct platform_driver davinci_gpio_driver = { | ||
494 | .probe = davinci_gpio_probe, | ||
495 | .driver = { | ||
496 | .name = "davinci_gpio", | ||
497 | .owner = THIS_MODULE, | ||
498 | }, | ||
499 | }; | ||
500 | |||
501 | /** | ||
502 | * GPIO driver registration needs to be done before machine_init functions | ||
503 | * access GPIO. Hence davinci_gpio_drv_reg() is a postcore_initcall. | ||
504 | */ | ||
505 | static int __init davinci_gpio_drv_reg(void) | ||
506 | { | ||
507 | return platform_driver_register(&davinci_gpio_driver); | ||
508 | } | ||
509 | postcore_initcall(davinci_gpio_drv_reg); | ||
diff --git a/drivers/gpio/gpio-tnetv107x.c b/drivers/gpio/gpio-tnetv107x.c index 3fa3e2867e19..58445bb69106 100644 --- a/drivers/gpio/gpio-tnetv107x.c +++ b/drivers/gpio/gpio-tnetv107x.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/gpio.h> | 17 | #include <linux/gpio.h> |
18 | #include <linux/platform_data/gpio-davinci.h> | ||
18 | 19 | ||
19 | #include <mach/common.h> | 20 | #include <mach/common.h> |
20 | #include <mach/tnetv107x.h> | 21 | #include <mach/tnetv107x.h> |
diff --git a/include/linux/platform_data/gpio-davinci.h b/include/linux/platform_data/gpio-davinci.h new file mode 100644 index 000000000000..6efd20264585 --- /dev/null +++ b/include/linux/platform_data/gpio-davinci.h | |||
@@ -0,0 +1,60 @@ | |||
1 | /* | ||
2 | * DaVinci GPIO Platform Related Defines | ||
3 | * | ||
4 | * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/ | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License as | ||
8 | * published by the Free Software Foundation version 2. | ||
9 | * | ||
10 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
11 | * kind, whether express or implied; without even the implied warranty | ||
12 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | */ | ||
15 | |||
16 | #ifndef __DAVINCI_GPIO_PLATFORM_H | ||
17 | #define __DAVINCI_GPIO_PLATFORM_H | ||
18 | |||
19 | #include <linux/io.h> | ||
20 | #include <linux/spinlock.h> | ||
21 | |||
22 | #include <asm-generic/gpio.h> | ||
23 | |||
24 | enum davinci_gpio_type { | ||
25 | GPIO_TYPE_TNETV107X = 0, | ||
26 | }; | ||
27 | |||
28 | struct davinci_gpio_platform_data { | ||
29 | u32 ngpio; | ||
30 | u32 gpio_unbanked; | ||
31 | u32 intc_irq_num; | ||
32 | }; | ||
33 | |||
34 | |||
35 | struct davinci_gpio_controller { | ||
36 | struct gpio_chip chip; | ||
37 | int irq_base; | ||
38 | /* Serialize access to GPIO registers */ | ||
39 | spinlock_t lock; | ||
40 | void __iomem *regs; | ||
41 | void __iomem *set_data; | ||
42 | void __iomem *clr_data; | ||
43 | void __iomem *in_data; | ||
44 | int gpio_unbanked; | ||
45 | unsigned gpio_irq; | ||
46 | }; | ||
47 | |||
48 | /* | ||
49 | * basic gpio routines | ||
50 | */ | ||
51 | #define GPIO(X) (X) /* 0 <= X <= (DAVINCI_N_GPIO - 1) */ | ||
52 | |||
53 | /* Convert GPIO signal to GPIO pin number */ | ||
54 | #define GPIO_TO_PIN(bank, gpio) (16 * (bank) + (gpio)) | ||
55 | |||
56 | static inline u32 __gpio_mask(unsigned gpio) | ||
57 | { | ||
58 | return 1 << (gpio % 32); | ||
59 | } | ||
60 | #endif | ||