Skip to content

Commit bbeddc4

Browse files
Russell KingRussell King
authored andcommitted
[ARM] versatile: add PL061 gpiolib support
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent 28d0325 commit bbeddc4

5 files changed

Lines changed: 43 additions & 5 deletions

File tree

‎arch/arm/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ config ARCH_VERSATILE
229229
select ICST307
230230
select GENERIC_TIME
231231
select GENERIC_CLOCKEVENTS
232+
select ARCH_WANT_OPTIONAL_GPIOLIB
232233
help
233234
This enables support for ARM Ltd Versatile board.
234235

‎arch/arm/mach-versatile/core.c‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/interrupt.h>
2727
#include <linux/amba/bus.h>
2828
#include <linux/amba/clcd.h>
29+
#include <linux/amba/pl061.h>
2930
#include <linux/clocksource.h>
3031
#include <linux/clockchips.h>
3132
#include <linux/cnt32_to_63.h>
@@ -706,6 +707,16 @@ static struct clcd_board clcd_plat_data = {
706707
.remove = versatile_clcd_remove,
707708
};
708709

710+
static struct pl061_platform_data gpio0_plat_data = {
711+
.gpio_base = 0,
712+
.irq_base = IRQ_GPIO0_START,
713+
};
714+
715+
static struct pl061_platform_data gpio1_plat_data = {
716+
.gpio_base = 8,
717+
.irq_base = IRQ_GPIO1_START,
718+
};
719+
709720
#define AACI_IRQ { IRQ_AACI, NO_IRQ }
710721
#define AACI_DMA { 0x80, 0x81 }
711722
#define MMCI0_IRQ { IRQ_MMCI0A,IRQ_SIC_MMCI0B }
@@ -768,8 +779,8 @@ AMBA_DEVICE(clcd, "dev:20", CLCD, &clcd_plat_data);
768779
AMBA_DEVICE(dmac, "dev:30", DMAC, NULL);
769780
AMBA_DEVICE(sctl, "dev:e0", SCTL, NULL);
770781
AMBA_DEVICE(wdog, "dev:e1", WATCHDOG, NULL);
771-
AMBA_DEVICE(gpio0, "dev:e4", GPIO0, NULL);
772-
AMBA_DEVICE(gpio1, "dev:e5", GPIO1, NULL);
782+
AMBA_DEVICE(gpio0, "dev:e4", GPIO0, &gpio0_plat_data);
783+
AMBA_DEVICE(gpio1, "dev:e5", GPIO1, &gpio1_plat_data);
773784
AMBA_DEVICE(rtc, "dev:e8", RTC, NULL);
774785
AMBA_DEVICE(sci0, "dev:f0", SCI, NULL);
775786
AMBA_DEVICE(uart0, "dev:f1", UART0, NULL);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <asm-generic/gpio.h>
2+
3+
#define gpio_get_value __gpio_get_value
4+
#define gpio_set_value __gpio_set_value
5+
#define gpio_cansleep __gpio_cansleep
6+
#define gpio_to_irq __gpio_to_irq

‎arch/arm/mach-versatile/include/mach/irqs.h‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,13 @@
122122
#define IRQ_SIC_PCI3 (IRQ_SIC_START + SIC_INT_PCI3)
123123
#define IRQ_SIC_END 63
124124

125-
#define NR_IRQS 64
125+
#define IRQ_GPIO0_START (IRQ_SIC_END + 1)
126+
#define IRQ_GPIO0_END (IRQ_GPIO0_START + 31)
127+
#define IRQ_GPIO1_START (IRQ_GPIO0_END + 1)
128+
#define IRQ_GPIO1_END (IRQ_GPIO1_START + 31)
129+
#define IRQ_GPIO2_START (IRQ_GPIO1_END + 1)
130+
#define IRQ_GPIO2_END (IRQ_GPIO2_START + 31)
131+
#define IRQ_GPIO3_START (IRQ_GPIO2_END + 1)
132+
#define IRQ_GPIO3_END (IRQ_GPIO3_START + 31)
133+
134+
#define NR_IRQS (IRQ_GPIO3_END + 1)

‎arch/arm/mach-versatile/versatile_pb.c‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/device.h>
2424
#include <linux/sysdev.h>
2525
#include <linux/amba/bus.h>
26+
#include <linux/amba/pl061.h>
2627
#include <linux/io.h>
2728

2829
#include <mach/hardware.h>
@@ -45,6 +46,16 @@ static struct mmc_platform_data mmc1_plat_data = {
4546
.status = mmc_status,
4647
};
4748

49+
static struct pl061_platform_data gpio2_plat_data = {
50+
.gpio_base = 16,
51+
.irq_base = IRQ_GPIO2_START,
52+
};
53+
54+
static struct pl061_platform_data gpio3_plat_data = {
55+
.gpio_base = 24,
56+
.irq_base = IRQ_GPIO3_START,
57+
};
58+
4859
#define UART3_IRQ { IRQ_SIC_UART3, NO_IRQ }
4960
#define UART3_DMA { 0x86, 0x87 }
5061
#define SCI1_IRQ { IRQ_SIC_SCI3, NO_IRQ }
@@ -70,8 +81,8 @@ AMBA_DEVICE(sci1, "fpga:0a", SCI1, NULL);
7081
AMBA_DEVICE(mmc1, "fpga:0b", MMCI1, &mmc1_plat_data);
7182

7283
/* DevChip Primecells */
73-
AMBA_DEVICE(gpio2, "dev:e6", GPIO2, NULL);
74-
AMBA_DEVICE(gpio3, "dev:e7", GPIO3, NULL);
84+
AMBA_DEVICE(gpio2, "dev:e6", GPIO2, &gpio2_plat_data);
85+
AMBA_DEVICE(gpio3, "dev:e7", GPIO3, &gpio3_plat_data);
7586

7687
static struct amba_device *amba_devs[] __initdata = {
7788
&uart3_device,

0 commit comments

Comments
 (0)