aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-at91/Kconfig14
-rw-r--r--arch/arm/mach-at91/Makefile5
-rw-r--r--arch/arm/mach-at91/at91_tc.h146
-rw-r--r--arch/arm/mach-at91/at91rm9200_time.c23
-rw-r--r--arch/arm/mach-at91/board-dt-rm9200.c2
-rw-r--r--arch/arm/mach-at91/board-dt-sam9.c1
-rw-r--r--arch/arm/mach-at91/board.h123
-rw-r--r--arch/arm/mach-at91/generic.h33
-rw-r--r--arch/arm/mach-at91/gpio.c982
-rw-r--r--arch/arm/mach-at91/gpio.h214
-rw-r--r--arch/arm/mach-at91/gsia18s.h33
-rw-r--r--arch/arm/mach-at91/include/mach/hardware.h5
-rw-r--r--arch/arm/mach-at91/leds.c56
-rw-r--r--arch/arm/mach-at91/pm.c11
-rw-r--r--arch/arm/mach-at91/setup.c54
-rw-r--r--arch/arm/mach-at91/soc.h6
-rw-r--r--drivers/clocksource/timer-atmel-pit.c32
17 files changed, 5 insertions, 1735 deletions
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 231893d71658..2395c68b3e32 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -174,21 +174,11 @@ config SOC_AT91SAM9N12
174# ---------------------------------------------------------- 174# ----------------------------------------------------------
175endif # SOC_SAM_V4_V5 175endif # SOC_SAM_V4_V5
176 176
177comment "Generic Board Type"
178
179config MACH_AT91RM9200_DT 177config MACH_AT91RM9200_DT
180 bool "Atmel AT91RM9200 Evaluation Kits with device-tree support" 178 def_bool SOC_AT91RM9200
181 depends on SOC_AT91RM9200
182 help
183 Select this if you want to experiment device-tree with
184 an Atmel RM9200 Evaluation Kit.
185 179
186config MACH_AT91SAM9_DT 180config MACH_AT91SAM9_DT
187 bool "Atmel AT91SAM Evaluation Kits with device-tree support" 181 def_bool SOC_AT91SAM9
188 depends on SOC_AT91SAM9
189 help
190 Select this if you want to experiment device-tree with
191 an Atmel Evaluation Kit.
192 182
193# ---------------------------------------------------------- 183# ----------------------------------------------------------
194 184
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index 2371b8845bf5..7b6424d40764 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the linux kernel. 2# Makefile for the linux kernel.
3# 3#
4 4
5obj-y := gpio.o setup.o sysirq_mask.o 5obj-y := setup.o sysirq_mask.o
6 6
7obj-$(CONFIG_SOC_AT91SAM9) += sam9_smc.o 7obj-$(CONFIG_SOC_AT91SAM9) += sam9_smc.o
8 8
@@ -25,9 +25,6 @@ obj-$(CONFIG_MACH_AT91SAM9_DT) += board-dt-sam9.o
25# SAMA5 board with device-tree 25# SAMA5 board with device-tree
26obj-$(CONFIG_SOC_SAMA5) += board-dt-sama5.o 26obj-$(CONFIG_SOC_SAMA5) += board-dt-sama5.o
27 27
28# Drivers
29obj-y += leds.o
30
31# Power Management 28# Power Management
32obj-$(CONFIG_PM) += pm.o 29obj-$(CONFIG_PM) += pm.o
33obj-$(CONFIG_AT91_SLOW_CLOCK) += pm_slowclock.o 30obj-$(CONFIG_AT91_SLOW_CLOCK) += pm_slowclock.o
diff --git a/arch/arm/mach-at91/at91_tc.h b/arch/arm/mach-at91/at91_tc.h
deleted file mode 100644
index 46a317fd7164..000000000000
--- a/arch/arm/mach-at91/at91_tc.h
+++ /dev/null
@@ -1,146 +0,0 @@
1/*
2 * arch/arm/mach-at91/include/mach/at91_tc.h
3 *
4 * Copyright (C) SAN People
5 *
6 * Timer/Counter Unit (TC) registers.
7 * Based on AT91RM9200 datasheet revision E.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 */
14
15#ifndef AT91_TC_H
16#define AT91_TC_H
17
18#define AT91_TC_BCR 0xc0 /* TC Block Control Register */
19#define AT91_TC_SYNC (1 << 0) /* Synchro Command */
20
21#define AT91_TC_BMR 0xc4 /* TC Block Mode Register */
22#define AT91_TC_TC0XC0S (3 << 0) /* External Clock Signal 0 Selection */
23#define AT91_TC_TC0XC0S_TCLK0 (0 << 0)
24#define AT91_TC_TC0XC0S_NONE (1 << 0)
25#define AT91_TC_TC0XC0S_TIOA1 (2 << 0)
26#define AT91_TC_TC0XC0S_TIOA2 (3 << 0)
27#define AT91_TC_TC1XC1S (3 << 2) /* External Clock Signal 1 Selection */
28#define AT91_TC_TC1XC1S_TCLK1 (0 << 2)
29#define AT91_TC_TC1XC1S_NONE (1 << 2)
30#define AT91_TC_TC1XC1S_TIOA0 (2 << 2)
31#define AT91_TC_TC1XC1S_TIOA2 (3 << 2)
32#define AT91_TC_TC2XC2S (3 << 4) /* External Clock Signal 2 Selection */
33#define AT91_TC_TC2XC2S_TCLK2 (0 << 4)
34#define AT91_TC_TC2XC2S_NONE (1 << 4)
35#define AT91_TC_TC2XC2S_TIOA0 (2 << 4)
36#define AT91_TC_TC2XC2S_TIOA1 (3 << 4)
37
38
39#define AT91_TC_CCR 0x00 /* Channel Control Register */
40#define AT91_TC_CLKEN (1 << 0) /* Counter Clock Enable Command */
41#define AT91_TC_CLKDIS (1 << 1) /* Counter CLock Disable Command */
42#define AT91_TC_SWTRG (1 << 2) /* Software Trigger Command */
43
44#define AT91_TC_CMR 0x04 /* Channel Mode Register */
45#define AT91_TC_TCCLKS (7 << 0) /* Capture/Waveform Mode: Clock Selection */
46#define AT91_TC_TIMER_CLOCK1 (0 << 0)
47#define AT91_TC_TIMER_CLOCK2 (1 << 0)
48#define AT91_TC_TIMER_CLOCK3 (2 << 0)
49#define AT91_TC_TIMER_CLOCK4 (3 << 0)
50#define AT91_TC_TIMER_CLOCK5 (4 << 0)
51#define AT91_TC_XC0 (5 << 0)
52#define AT91_TC_XC1 (6 << 0)
53#define AT91_TC_XC2 (7 << 0)
54#define AT91_TC_CLKI (1 << 3) /* Capture/Waveform Mode: Clock Invert */
55#define AT91_TC_BURST (3 << 4) /* Capture/Waveform Mode: Burst Signal Selection */
56#define AT91_TC_LDBSTOP (1 << 6) /* Capture Mode: Counter Clock Stopped with TB Loading */
57#define AT91_TC_LDBDIS (1 << 7) /* Capture Mode: Counter Clock Disable with RB Loading */
58#define AT91_TC_ETRGEDG (3 << 8) /* Capture Mode: External Trigger Edge Selection */
59#define AT91_TC_ABETRG (1 << 10) /* Capture Mode: TIOA or TIOB External Trigger Selection */
60#define AT91_TC_CPCTRG (1 << 14) /* Capture Mode: RC Compare Trigger Enable */
61#define AT91_TC_WAVE (1 << 15) /* Capture/Waveform mode */
62#define AT91_TC_LDRA (3 << 16) /* Capture Mode: RA Loading Selection */
63#define AT91_TC_LDRB (3 << 18) /* Capture Mode: RB Loading Selection */
64
65#define AT91_TC_CPCSTOP (1 << 6) /* Waveform Mode: Counter Clock Stopped with RC Compare */
66#define AT91_TC_CPCDIS (1 << 7) /* Waveform Mode: Counter Clock Disable with RC Compare */
67#define AT91_TC_EEVTEDG (3 << 8) /* Waveform Mode: External Event Edge Selection */
68#define AT91_TC_EEVTEDG_NONE (0 << 8)
69#define AT91_TC_EEVTEDG_RISING (1 << 8)
70#define AT91_TC_EEVTEDG_FALLING (2 << 8)
71#define AT91_TC_EEVTEDG_BOTH (3 << 8)
72#define AT91_TC_EEVT (3 << 10) /* Waveform Mode: External Event Selection */
73#define AT91_TC_EEVT_TIOB (0 << 10)
74#define AT91_TC_EEVT_XC0 (1 << 10)
75#define AT91_TC_EEVT_XC1 (2 << 10)
76#define AT91_TC_EEVT_XC2 (3 << 10)
77#define AT91_TC_ENETRG (1 << 12) /* Waveform Mode: External Event Trigger Enable */
78#define AT91_TC_WAVESEL (3 << 13) /* Waveform Mode: Waveform Selection */
79#define AT91_TC_WAVESEL_UP (0 << 13)
80#define AT91_TC_WAVESEL_UP_AUTO (2 << 13)
81#define AT91_TC_WAVESEL_UPDOWN (1 << 13)
82#define AT91_TC_WAVESEL_UPDOWN_AUTO (3 << 13)
83#define AT91_TC_ACPA (3 << 16) /* Waveform Mode: RA Compare Effect on TIOA */
84#define AT91_TC_ACPA_NONE (0 << 16)
85#define AT91_TC_ACPA_SET (1 << 16)
86#define AT91_TC_ACPA_CLEAR (2 << 16)
87#define AT91_TC_ACPA_TOGGLE (3 << 16)
88#define AT91_TC_ACPC (3 << 18) /* Waveform Mode: RC Compre Effect on TIOA */
89#define AT91_TC_ACPC_NONE (0 << 18)
90#define AT91_TC_ACPC_SET (1 << 18)
91#define AT91_TC_ACPC_CLEAR (2 << 18)
92#define AT91_TC_ACPC_TOGGLE (3 << 18)
93#define AT91_TC_AEEVT (3 << 20) /* Waveform Mode: External Event Effect on TIOA */
94#define AT91_TC_AEEVT_NONE (0 << 20)
95#define AT91_TC_AEEVT_SET (1 << 20)
96#define AT91_TC_AEEVT_CLEAR (2 << 20)
97#define AT91_TC_AEEVT_TOGGLE (3 << 20)
98#define AT91_TC_ASWTRG (3 << 22) /* Waveform Mode: Software Trigger Effect on TIOA */
99#define AT91_TC_ASWTRG_NONE (0 << 22)
100#define AT91_TC_ASWTRG_SET (1 << 22)
101#define AT91_TC_ASWTRG_CLEAR (2 << 22)
102#define AT91_TC_ASWTRG_TOGGLE (3 << 22)
103#define AT91_TC_BCPB (3 << 24) /* Waveform Mode: RB Compare Effect on TIOB */
104#define AT91_TC_BCPB_NONE (0 << 24)
105#define AT91_TC_BCPB_SET (1 << 24)
106#define AT91_TC_BCPB_CLEAR (2 << 24)
107#define AT91_TC_BCPB_TOGGLE (3 << 24)
108#define AT91_TC_BCPC (3 << 26) /* Waveform Mode: RC Compare Effect on TIOB */
109#define AT91_TC_BCPC_NONE (0 << 26)
110#define AT91_TC_BCPC_SET (1 << 26)
111#define AT91_TC_BCPC_CLEAR (2 << 26)
112#define AT91_TC_BCPC_TOGGLE (3 << 26)
113#define AT91_TC_BEEVT (3 << 28) /* Waveform Mode: External Event Effect on TIOB */
114#define AT91_TC_BEEVT_NONE (0 << 28)
115#define AT91_TC_BEEVT_SET (1 << 28)
116#define AT91_TC_BEEVT_CLEAR (2 << 28)
117#define AT91_TC_BEEVT_TOGGLE (3 << 28)
118#define AT91_TC_BSWTRG (3 << 30) /* Waveform Mode: Software Trigger Effect on TIOB */
119#define AT91_TC_BSWTRG_NONE (0 << 30)
120#define AT91_TC_BSWTRG_SET (1 << 30)
121#define AT91_TC_BSWTRG_CLEAR (2 << 30)
122#define AT91_TC_BSWTRG_TOGGLE (3 << 30)
123
124#define AT91_TC_CV 0x10 /* Counter Value */
125#define AT91_TC_RA 0x14 /* Register A */
126#define AT91_TC_RB 0x18 /* Register B */
127#define AT91_TC_RC 0x1c /* Register C */
128
129#define AT91_TC_SR 0x20 /* Status Register */
130#define AT91_TC_COVFS (1 << 0) /* Counter Overflow Status */
131#define AT91_TC_LOVRS (1 << 1) /* Load Overrun Status */
132#define AT91_TC_CPAS (1 << 2) /* RA Compare Status */
133#define AT91_TC_CPBS (1 << 3) /* RB Compare Status */
134#define AT91_TC_CPCS (1 << 4) /* RC Compare Status */
135#define AT91_TC_LDRAS (1 << 5) /* RA Loading Status */
136#define AT91_TC_LDRBS (1 << 6) /* RB Loading Status */
137#define AT91_TC_ETRGS (1 << 7) /* External Trigger Status */
138#define AT91_TC_CLKSTA (1 << 16) /* Clock Enabling Status */
139#define AT91_TC_MTIOA (1 << 17) /* TIOA Mirror */
140#define AT91_TC_MTIOB (1 << 18) /* TIOB Mirror */
141
142#define AT91_TC_IER 0x24 /* Interrupt Enable Register */
143#define AT91_TC_IDR 0x28 /* Interrupt Disable Register */
144#define AT91_TC_IMR 0x2c /* Interrupt Mask Register */
145
146#endif
diff --git a/arch/arm/mach-at91/at91rm9200_time.c b/arch/arm/mach-at91/at91rm9200_time.c
index 7fd13aef9827..51761f8927b7 100644
--- a/arch/arm/mach-at91/at91rm9200_time.c
+++ b/arch/arm/mach-at91/at91rm9200_time.c
@@ -183,7 +183,6 @@ static struct clock_event_device clkevt = {
183void __iomem *at91_st_base; 183void __iomem *at91_st_base;
184EXPORT_SYMBOL_GPL(at91_st_base); 184EXPORT_SYMBOL_GPL(at91_st_base);
185 185
186#ifdef CONFIG_OF
187static struct of_device_id at91rm9200_st_timer_ids[] = { 186static struct of_device_id at91rm9200_st_timer_ids[] = {
188 { .compatible = "atmel,at91rm9200-st" }, 187 { .compatible = "atmel,at91rm9200-st" },
189 { /* sentinel */ } 188 { /* sentinel */ }
@@ -219,28 +218,6 @@ node_err:
219err: 218err:
220 return -EINVAL; 219 return -EINVAL;
221} 220}
222#else
223static int __init of_at91rm9200_st_init(void)
224{
225 return -EINVAL;
226}
227#endif
228
229void __init at91rm9200_ioremap_st(u32 addr)
230{
231#ifdef CONFIG_OF
232 struct device_node *np;
233
234 np = of_find_matching_node(NULL, at91rm9200_st_timer_ids);
235 if (np) {
236 of_node_put(np);
237 return;
238 }
239#endif
240 at91_st_base = ioremap(addr, 256);
241 if (!at91_st_base)
242 panic("Impossible to ioremap ST\n");
243}
244 221
245/* 222/*
246 * ST (system timer) module supports both clockevents and clocksource. 223 * ST (system timer) module supports both clockevents and clocksource.
diff --git a/arch/arm/mach-at91/board-dt-rm9200.c b/arch/arm/mach-at91/board-dt-rm9200.c
index feeb1a0f258e..76dfe8f9af50 100644
--- a/arch/arm/mach-at91/board-dt-rm9200.c
+++ b/arch/arm/mach-at91/board-dt-rm9200.c
@@ -26,9 +26,7 @@
26 26
27static void __init at91rm9200_dt_timer_init(void) 27static void __init at91rm9200_dt_timer_init(void)
28{ 28{
29#if defined(CONFIG_COMMON_CLK)
30 of_clk_init(NULL); 29 of_clk_init(NULL);
31#endif
32 at91rm9200_timer_init(); 30 at91rm9200_timer_init();
33} 31}
34 32
diff --git a/arch/arm/mach-at91/board-dt-sam9.c b/arch/arm/mach-at91/board-dt-sam9.c
index 67c1bcbf0ed9..f99246aa9b38 100644
--- a/arch/arm/mach-at91/board-dt-sam9.c
+++ b/arch/arm/mach-at91/board-dt-sam9.c
@@ -21,7 +21,6 @@
21#include <asm/mach/map.h> 21#include <asm/mach/map.h>
22#include <asm/mach/irq.h> 22#include <asm/mach/irq.h>
23 23
24#include "board.h"
25#include "generic.h" 24#include "generic.h"
26 25
27static const char *at91_dt_board_compat[] __initdata = { 26static const char *at91_dt_board_compat[] __initdata = {
diff --git a/arch/arm/mach-at91/board.h b/arch/arm/mach-at91/board.h
deleted file mode 100644
index d268ec3781dd..000000000000
--- a/arch/arm/mach-at91/board.h
+++ /dev/null
@@ -1,123 +0,0 @@
1/*
2 * arch/arm/mach-at91/include/mach/board.h
3 *
4 * Copyright (C) 2005 HP Labs
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21/*
22 * These are data structures found in platform_device.dev.platform_data,
23 * and describing board-specific data needed by drivers. For example,
24 * which pin is used for a given GPIO role.
25 *
26 * In 2.6, drivers should strongly avoid board-specific knowledge so
27 * that supporting new boards normally won't require driver patches.
28 * Most board-specific knowledge should be in arch/.../board-*.c files.
29 */
30
31#ifndef __ASM_ARCH_BOARD_H
32#define __ASM_ARCH_BOARD_H
33
34#include <linux/platform_data/atmel.h>
35
36 /* USB Device */
37extern void __init at91_add_device_udc(struct at91_udc_data *data);
38
39 /* USB High Speed Device */
40extern void __init at91_add_device_usba(struct usba_platform_data *data);
41
42 /* Compact Flash */
43extern void __init at91_add_device_cf(struct at91_cf_data *data);
44
45 /* MMC / SD */
46 /* atmel-mci platform config */
47extern void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data);
48
49extern void __init at91_add_device_eth(struct macb_platform_data *data);
50
51 /* USB Host */
52extern void __init at91_add_device_usbh(struct at91_usbh_data *data);
53extern void __init at91_add_device_usbh_ohci(struct at91_usbh_data *data);
54extern void __init at91_add_device_usbh_ehci(struct at91_usbh_data *data);
55
56extern void __init at91_add_device_nand(struct atmel_nand_data *data);
57
58 /* I2C*/
59extern void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices);
60
61 /* SPI */
62extern void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices);
63
64 /* Serial */
65#define ATMEL_UART_CTS 0x01
66#define ATMEL_UART_RTS 0x02
67#define ATMEL_UART_DSR 0x04
68#define ATMEL_UART_DTR 0x08
69#define ATMEL_UART_DCD 0x10
70#define ATMEL_UART_RI 0x20
71
72extern void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins);
73
74extern struct platform_device *atmel_default_console_device;
75
76extern void __init at91_add_device_serial(void);
77
78/*
79 * PWM
80 */
81#define AT91_PWM0 0
82#define AT91_PWM1 1
83#define AT91_PWM2 2
84#define AT91_PWM3 3
85
86extern void __init at91_add_device_pwm(u32 mask);
87
88/*
89 * SSC -- accessed through ssc_request(id). Drivers don't bind to SSC
90 * platform devices. Their SSC ID is part of their configuration data,
91 * along with information about which SSC signals they should use.
92 */
93#define ATMEL_SSC_TK 0x01
94#define ATMEL_SSC_TF 0x02
95#define ATMEL_SSC_TD 0x04
96#define ATMEL_SSC_TX (ATMEL_SSC_TK | ATMEL_SSC_TF | ATMEL_SSC_TD)
97
98#define ATMEL_SSC_RK 0x10
99#define ATMEL_SSC_RF 0x20
100#define ATMEL_SSC_RD 0x40
101#define ATMEL_SSC_RX (ATMEL_SSC_RK | ATMEL_SSC_RF | ATMEL_SSC_RD)
102
103extern void __init at91_add_device_ssc(unsigned id, unsigned pins);
104
105 /* LCD Controller */
106struct atmel_lcdfb_pdata;
107extern void __init at91_add_device_lcdc(struct atmel_lcdfb_pdata *data);
108
109 /* AC97 */
110extern void __init at91_add_device_ac97(struct ac97c_platform_data *data);
111
112 /* ISI */
113struct isi_platform_data;
114extern void __init at91_add_device_isi(struct isi_platform_data *data,
115 bool use_pck_as_mck);
116
117/* CAN */
118extern void __init at91_add_device_can(struct at91_can_data *data);
119
120 /* LEDs */
121extern void __init at91_gpio_leds(struct gpio_led *leds, int nr);
122
123#endif
diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h
index eb81940f9848..d53324210adf 100644
--- a/arch/arm/mach-at91/generic.h
+++ b/arch/arm/mach-at91/generic.h
@@ -22,52 +22,19 @@ extern void __init at91_init_sram(int bank, unsigned long base,
22 22
23 /* Processors */ 23 /* Processors */
24extern void __init at91rm9200_set_type(int type); 24extern void __init at91rm9200_set_type(int type);
25extern void __init at91_initialize(unsigned long main_clock);
26extern void __init at91rm9200_dt_initialize(void); 25extern void __init at91rm9200_dt_initialize(void);
27extern void __init at91_dt_initialize(void); 26extern void __init at91_dt_initialize(void);
28 27
29 /* Interrupts */ 28 /* Interrupts */
30extern void __init at91_init_irq_default(void);
31extern void __init at91_init_interrupts(unsigned int priority[]);
32extern void __init at91_sysirq_mask_rtc(u32 rtc_base); 29extern void __init at91_sysirq_mask_rtc(u32 rtc_base);
33extern void __init at91_sysirq_mask_rtt(u32 rtt_base); 30extern void __init at91_sysirq_mask_rtt(u32 rtt_base);
34 31
35 /* Devices */
36extern void __init at91_register_devices(void);
37
38 /* Timer */ 32 /* Timer */
39extern void __init at91_init_time(void);
40extern void at91rm9200_ioremap_st(u32 addr);
41extern void at91rm9200_timer_init(void); 33extern void at91rm9200_timer_init(void);
42extern void at91sam926x_ioremap_pit(u32 addr);
43extern void at91sam926x_pit_init(int irq);
44
45 /* Power Management */
46extern void at91_irq_suspend(void);
47extern void at91_irq_resume(void);
48 34
49/* idle */ 35/* idle */
50extern void at91sam9_idle(void); 36extern void at91sam9_idle(void);
51 37
52/* Matrix */ 38/* Matrix */
53extern void at91_ioremap_matrix(u32 base_addr); 39extern void at91_ioremap_matrix(u32 base_addr);
54
55/* Ram Controler */
56extern void at91_ioremap_ramc(int id, u32 addr, u32 size);
57
58 /* GPIO */
59#define AT91RM9200_PQFP 3 /* AT91RM9200 PQFP package has 3 banks */
60#define AT91RM9200_BGA 4 /* AT91RM9200 BGA package has 4 banks */
61
62struct at91_gpio_bank {
63 unsigned short id; /* peripheral ID */
64 unsigned long regbase; /* offset from system peripheral base */
65};
66extern void __init at91_gpio_init(struct at91_gpio_bank *, int nr_banks);
67extern void __init at91_gpio_irq_setup(void);
68extern int __init at91_gpio_of_irq_setup(struct device_node *node,
69 struct device_node *parent);
70
71extern u32 at91_get_extern_irq(void);
72
73#endif /* _AT91_GENERIC_H */ 40#endif /* _AT91_GENERIC_H */
diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c
deleted file mode 100644
index d3f05aaad8ba..000000000000
--- a/arch/arm/mach-at91/gpio.c
+++ /dev/null
@@ -1,982 +0,0 @@
1/*
2 * linux/arch/arm/mach-at91/gpio.c
3 *
4 * Copyright (C) 2005 HP Labs
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#include <linux/clk.h>
13#include <linux/errno.h>
14#include <linux/device.h>
15#include <linux/gpio.h>
16#include <linux/interrupt.h>
17#include <linux/irq.h>
18#include <linux/debugfs.h>
19#include <linux/seq_file.h>
20#include <linux/kernel.h>
21#include <linux/list.h>
22#include <linux/module.h>
23#include <linux/io.h>
24#include <linux/irqdomain.h>
25#include <linux/irqchip/chained_irq.h>
26#include <linux/of_address.h>
27
28#include <mach/hardware.h>
29#include <mach/at91_pio.h>
30
31#include "generic.h"
32#include "gpio.h"
33
34#define MAX_NB_GPIO_PER_BANK 32
35
36struct at91_gpio_chip {
37 struct gpio_chip chip;
38 struct at91_gpio_chip *next; /* Bank sharing same clock */
39 int pioc_hwirq; /* PIO bank interrupt identifier on AIC */
40 int pioc_virq; /* PIO bank Linux virtual interrupt */
41 int pioc_idx; /* PIO bank index */
42 void __iomem *regbase; /* PIO bank virtual address */
43 struct clk *clock; /* associated clock */
44 struct irq_domain *domain; /* associated irq domain */
45};
46
47#define to_at91_gpio_chip(c) container_of(c, struct at91_gpio_chip, chip)
48
49static int at91_gpiolib_request(struct gpio_chip *chip, unsigned offset);
50static void at91_gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip);
51static void at91_gpiolib_set(struct gpio_chip *chip, unsigned offset, int val);
52static int at91_gpiolib_get(struct gpio_chip *chip, unsigned offset);
53static int at91_gpiolib_get_direction(struct gpio_chip *chip, unsigned offset);
54static int at91_gpiolib_direction_output(struct gpio_chip *chip,
55 unsigned offset, int val);
56static int at91_gpiolib_direction_input(struct gpio_chip *chip,
57 unsigned offset);
58static int at91_gpiolib_to_irq(struct gpio_chip *chip, unsigned offset);
59
60#define AT91_GPIO_CHIP(name) \
61 { \
62 .chip = { \
63 .label = name, \
64 .request = at91_gpiolib_request, \
65 .get_direction = at91_gpiolib_get_direction, \
66 .direction_input = at91_gpiolib_direction_input, \
67 .direction_output = at91_gpiolib_direction_output, \
68 .get = at91_gpiolib_get, \
69 .set = at91_gpiolib_set, \
70 .dbg_show = at91_gpiolib_dbg_show, \
71 .to_irq = at91_gpiolib_to_irq, \
72 .ngpio = MAX_NB_GPIO_PER_BANK, \
73 }, \
74 }
75
76static struct at91_gpio_chip gpio_chip[] = {
77 AT91_GPIO_CHIP("pioA"),
78 AT91_GPIO_CHIP("pioB"),
79 AT91_GPIO_CHIP("pioC"),
80 AT91_GPIO_CHIP("pioD"),
81 AT91_GPIO_CHIP("pioE"),
82};
83
84static int gpio_banks;
85static unsigned long at91_gpio_caps;
86
87/* All PIO controllers support PIO3 features */
88#define AT91_GPIO_CAP_PIO3 (1 << 0)
89
90#define has_pio3() (at91_gpio_caps & AT91_GPIO_CAP_PIO3)
91
92/*--------------------------------------------------------------------------*/
93
94static inline void __iomem *pin_to_controller(unsigned pin)
95{
96 pin /= MAX_NB_GPIO_PER_BANK;
97 if (likely(pin < gpio_banks))
98 return gpio_chip[pin].regbase;
99
100 return NULL;
101}
102
103static inline unsigned pin_to_mask(unsigned pin)
104{
105 return 1 << (pin % MAX_NB_GPIO_PER_BANK);
106}
107
108
109static char peripheral_function(void __iomem *pio, unsigned mask)
110{
111 char ret = 'X';
112 u8 select;
113
114 if (pio) {
115 if (has_pio3()) {
116 select = !!(__raw_readl(pio + PIO_ABCDSR1) & mask);
117 select |= (!!(__raw_readl(pio + PIO_ABCDSR2) & mask) << 1);
118 ret = 'A' + select;
119 } else {
120 ret = __raw_readl(pio + PIO_ABSR) & mask ?
121 'B' : 'A';
122 }
123 }
124
125 return ret;
126}
127
128/*--------------------------------------------------------------------------*/
129
130/* Not all hardware capabilities are exposed through these calls; they
131 * only encapsulate the most common features and modes. (So if you
132 * want to change signals in groups, do it directly.)
133 *
134 * Bootloaders will usually handle some of the pin multiplexing setup.
135 * The intent is certainly that by the time Linux is fully booted, all
136 * pins should have been fully initialized. These setup calls should
137 * only be used by board setup routines, or possibly in driver probe().
138 *
139 * For bootloaders doing all that setup, these calls could be inlined
140 * as NOPs so Linux won't duplicate any setup code
141 */
142
143
144/*
145 * mux the pin to the "GPIO" peripheral role.
146 */
147int __init_or_module at91_set_GPIO_periph(unsigned pin, int use_pullup)
148{
149 void __iomem *pio = pin_to_controller(pin);
150 unsigned mask = pin_to_mask(pin);
151
152 if (!pio)
153 return -EINVAL;
154 __raw_writel(mask, pio + PIO_IDR);
155 __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
156 __raw_writel(mask, pio + PIO_PER);
157 return 0;
158}
159EXPORT_SYMBOL(at91_set_GPIO_periph);
160
161
162/*
163 * mux the pin to the "A" internal peripheral role.
164 */
165int __init_or_module at91_set_A_periph(unsigned pin, int use_pullup)
166{
167 void __iomem *pio = pin_to_controller(pin);
168 unsigned mask = pin_to_mask(pin);
169
170 if (!pio)
171 return -EINVAL;
172
173 __raw_writel(mask, pio + PIO_IDR);
174 __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
175 if (has_pio3()) {
176 __raw_writel(__raw_readl(pio + PIO_ABCDSR1) & ~mask,
177 pio + PIO_ABCDSR1);
178 __raw_writel(__raw_readl(pio + PIO_ABCDSR2) & ~mask,
179 pio + PIO_ABCDSR2);
180 } else {
181 __raw_writel(mask, pio + PIO_ASR);
182 }
183 __raw_writel(mask, pio + PIO_PDR);
184 return 0;
185}
186EXPORT_SYMBOL(at91_set_A_periph);
187
188
189/*
190 * mux the pin to the "B" internal peripheral role.
191 */
192int __init_or_module at91_set_B_periph(unsigned pin, int use_pullup)
193{
194 void __iomem *pio = pin_to_controller(pin);
195 unsigned mask = pin_to_mask(pin);
196
197 if (!pio)
198 return -EINVAL;
199
200 __raw_writel(mask, pio + PIO_IDR);
201 __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
202 if (has_pio3()) {
203 __raw_writel(__raw_readl(pio + PIO_ABCDSR1) | mask,
204 pio + PIO_ABCDSR1);
205 __raw_writel(__raw_readl(pio + PIO_ABCDSR2) & ~mask,
206 pio + PIO_ABCDSR2);
207 } else {
208 __raw_writel(mask, pio + PIO_BSR);
209 }
210 __raw_writel(mask, pio + PIO_PDR);
211 return 0;
212}
213EXPORT_SYMBOL(at91_set_B_periph);
214
215
216/*
217 * mux the pin to the "C" internal peripheral role.
218 */
219int __init_or_module at91_set_C_periph(unsigned pin, int use_pullup)
220{
221 void __iomem *pio = pin_to_controller(pin);
222 unsigned mask = pin_to_mask(pin);
223
224 if (!pio || !has_pio3())
225 return -EINVAL;
226
227 __raw_writel(mask, pio + PIO_IDR);
228 __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
229 __raw_writel(__raw_readl(pio + PIO_ABCDSR1) & ~mask, pio + PIO_ABCDSR1);
230 __raw_writel(__raw_readl(pio + PIO_ABCDSR2) | mask, pio + PIO_ABCDSR2);
231 __raw_writel(mask, pio + PIO_PDR);
232 return 0;
233}
234EXPORT_SYMBOL(at91_set_C_periph);
235
236
237/*
238 * mux the pin to the "D" internal peripheral role.
239 */
240int __init_or_module at91_set_D_periph(unsigned pin, int use_pullup)
241{
242 void __iomem *pio = pin_to_controller(pin);
243 unsigned mask = pin_to_mask(pin);
244
245 if (!pio || !has_pio3())
246 return -EINVAL;
247
248 __raw_writel(mask, pio + PIO_IDR);
249 __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
250 __raw_writel(__raw_readl(pio + PIO_ABCDSR1) | mask, pio + PIO_ABCDSR1);
251 __raw_writel(__raw_readl(pio + PIO_ABCDSR2) | mask, pio + PIO_ABCDSR2);
252 __raw_writel(mask, pio + PIO_PDR);
253 return 0;
254}
255EXPORT_SYMBOL(at91_set_D_periph);
256
257
258/*
259 * mux the pin to the gpio controller (instead of "A", "B", "C"
260 * or "D" peripheral), and configure it for an input.
261 */
262int __init_or_module at91_set_gpio_input(unsigned pin, int use_pullup)
263{
264 void __iomem *pio = pin_to_controller(pin);
265 unsigned mask = pin_to_mask(pin);
266
267 if (!pio)
268 return -EINVAL;
269
270 __raw_writel(mask, pio + PIO_IDR);
271 __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
272 __raw_writel(mask, pio + PIO_ODR);
273 __raw_writel(mask, pio + PIO_PER);
274 return 0;
275}
276EXPORT_SYMBOL(at91_set_gpio_input);
277
278
279/*
280 * mux the pin to the gpio controller (instead of "A", "B", "C"
281 * or "D" peripheral), and configure it for an output.
282 */
283int __init_or_module at91_set_gpio_output(unsigned pin, int value)
284{
285 void __iomem *pio = pin_to_controller(pin);
286 unsigned mask = pin_to_mask(pin);
287
288 if (!pio)
289 return -EINVAL;
290
291 __raw_writel(mask, pio + PIO_IDR);
292 __raw_writel(mask, pio + PIO_PUDR);
293 __raw_writel(mask, pio + (value ? PIO_SODR : PIO_CODR));
294 __raw_writel(mask, pio + PIO_OER);
295 __raw_writel(mask, pio + PIO_PER);
296 return 0;
297}
298EXPORT_SYMBOL(at91_set_gpio_output);
299
300
301/*
302 * enable/disable the glitch filter; mostly used with IRQ handling.
303 */
304int __init_or_module at91_set_deglitch(unsigned pin, int is_on)
305{
306 void __iomem *pio = pin_to_controller(pin);
307 unsigned mask = pin_to_mask(pin);
308
309 if (!pio)
310 return -EINVAL;
311
312 if (has_pio3() && is_on)
313 __raw_writel(mask, pio + PIO_IFSCDR);
314 __raw_writel(mask, pio + (is_on ? PIO_IFER : PIO_IFDR));
315 return 0;
316}
317EXPORT_SYMBOL(at91_set_deglitch);
318
319/*
320 * enable/disable the debounce filter;
321 */
322int __init_or_module at91_set_debounce(unsigned pin, int is_on, int div)
323{
324 void __iomem *pio = pin_to_controller(pin);
325 unsigned mask = pin_to_mask(pin);
326
327 if (!pio || !has_pio3())
328 return -EINVAL;
329
330 if (is_on) {
331 __raw_writel(mask, pio + PIO_IFSCER);
332 __raw_writel(div & PIO_SCDR_DIV, pio + PIO_SCDR);
333 __raw_writel(mask, pio + PIO_IFER);
334 } else {
335 __raw_writel(mask, pio + PIO_IFDR);
336 }
337 return 0;
338}
339EXPORT_SYMBOL(at91_set_debounce);
340
341/*
342 * enable/disable the multi-driver; This is only valid for output and
343 * allows the output pin to run as an open collector output.
344 */
345int __init_or_module at91_set_multi_drive(unsigned pin, int is_on)
346{
347 void __iomem *pio = pin_to_controller(pin);
348 unsigned mask = pin_to_mask(pin);
349
350 if (!pio)
351 return -EINVAL;
352
353 __raw_writel(mask, pio + (is_on ? PIO_MDER : PIO_MDDR));
354 return 0;
355}
356EXPORT_SYMBOL(at91_set_multi_drive);
357
358/*
359 * enable/disable the pull-down.
360 * If pull-up already enabled while calling the function, we disable it.
361 */
362int __init_or_module at91_set_pulldown(unsigned pin, int is_on)
363{
364 void __iomem *pio = pin_to_controller(pin);
365 unsigned mask = pin_to_mask(pin);
366
367 if (!pio || !has_pio3())
368 return -EINVAL;
369
370 /* Disable pull-up anyway */
371 __raw_writel(mask, pio + PIO_PUDR);
372 __raw_writel(mask, pio + (is_on ? PIO_PPDER : PIO_PPDDR));
373 return 0;
374}
375EXPORT_SYMBOL(at91_set_pulldown);
376
377/*
378 * disable Schmitt trigger
379 */
380int __init_or_module at91_disable_schmitt_trig(unsigned pin)
381{
382 void __iomem *pio = pin_to_controller(pin);
383 unsigned mask = pin_to_mask(pin);
384
385 if (!pio || !has_pio3())
386 return -EINVAL;
387
388 __raw_writel(__raw_readl(pio + PIO_SCHMITT) | mask, pio + PIO_SCHMITT);
389 return 0;
390}
391EXPORT_SYMBOL(at91_disable_schmitt_trig);
392
393/*
394 * assuming the pin is muxed as a gpio output, set its value.
395 */
396int at91_set_gpio_value(unsigned pin, int value)
397{
398 void __iomem *pio = pin_to_controller(pin);
399 unsigned mask = pin_to_mask(pin);
400
401 if (!pio)
402 return -EINVAL;
403 __raw_writel(mask, pio + (value ? PIO_SODR : PIO_CODR));
404 return 0;
405}
406EXPORT_SYMBOL(at91_set_gpio_value);
407
408
409/*
410 * read the pin's value (works even if it's not muxed as a gpio).
411 */
412int at91_get_gpio_value(unsigned pin)
413{
414 void __iomem *pio = pin_to_controller(pin);
415 unsigned mask = pin_to_mask(pin);
416 u32 pdsr;
417
418 if (!pio)
419 return -EINVAL;
420 pdsr = __raw_readl(pio + PIO_PDSR);
421 return (pdsr & mask) != 0;
422}
423EXPORT_SYMBOL(at91_get_gpio_value);
424
425/*--------------------------------------------------------------------------*/
426
427#ifdef CONFIG_PM
428
429static u32 wakeups[MAX_GPIO_BANKS];
430static u32 backups[MAX_GPIO_BANKS];
431
432static int gpio_irq_set_wake(struct irq_data *d, unsigned state)
433{
434 struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
435 unsigned mask = 1 << d->hwirq;
436 unsigned bank = at91_gpio->pioc_idx;
437
438 if (unlikely(bank >= MAX_GPIO_BANKS))
439 return -EINVAL;
440
441 if (state)
442 wakeups[bank] |= mask;
443 else
444 wakeups[bank] &= ~mask;
445
446 irq_set_irq_wake(at91_gpio->pioc_virq, state);
447
448 return 0;
449}
450
451void at91_gpio_suspend(void)
452{
453 int i;
454
455 for (i = 0; i < gpio_banks; i++) {
456 void __iomem *pio = gpio_chip[i].regbase;
457
458 backups[i] = __raw_readl(pio + PIO_IMR);
459 __raw_writel(backups[i], pio + PIO_IDR);
460 __raw_writel(wakeups[i], pio + PIO_IER);
461
462 if (!wakeups[i]) {
463 clk_unprepare(gpio_chip[i].clock);
464 clk_disable(gpio_chip[i].clock);
465 } else {
466#ifdef CONFIG_PM_DEBUG
467 printk(KERN_DEBUG "GPIO-%c may wake for %08x\n", 'A'+i, wakeups[i]);
468#endif
469 }
470 }
471}
472
473void at91_gpio_resume(void)
474{
475 int i;
476
477 for (i = 0; i < gpio_banks; i++) {
478 void __iomem *pio = gpio_chip[i].regbase;
479
480 if (!wakeups[i]) {
481 if (clk_prepare(gpio_chip[i].clock) == 0)
482 clk_enable(gpio_chip[i].clock);
483 }
484
485 __raw_writel(wakeups[i], pio + PIO_IDR);
486 __raw_writel(backups[i], pio + PIO_IER);
487 }
488}
489
490#else
491#define gpio_irq_set_wake NULL
492#endif
493
494
495/* Several AIC controller irqs are dispatched through this GPIO handler.
496 * To use any AT91_PIN_* as an externally triggered IRQ, first call
497 * at91_set_gpio_input() then maybe enable its glitch filter.
498 * Then just request_irq() with the pin ID; it works like any ARM IRQ
499 * handler.
500 * First implementation always triggers on rising and falling edges
501 * whereas the newer PIO3 can be additionally configured to trigger on
502 * level, edge with any polarity.
503 *
504 * Alternatively, certain pins may be used directly as IRQ0..IRQ6 after
505 * configuring them with at91_set_a_periph() or at91_set_b_periph().
506 * IRQ0..IRQ6 should be configurable, e.g. level vs edge triggering.
507 */
508
509static void gpio_irq_mask(struct irq_data *d)
510{
511 struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
512 void __iomem *pio = at91_gpio->regbase;
513 unsigned mask = 1 << d->hwirq;
514
515 if (pio)
516 __raw_writel(mask, pio + PIO_IDR);
517}
518
519static void gpio_irq_unmask(struct irq_data *d)
520{
521 struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
522 void __iomem *pio = at91_gpio->regbase;
523 unsigned mask = 1 << d->hwirq;
524
525 if (pio)
526 __raw_writel(mask, pio + PIO_IER);
527}
528
529static int gpio_irq_type(struct irq_data *d, unsigned type)
530{
531 switch (type) {
532 case IRQ_TYPE_NONE:
533 case IRQ_TYPE_EDGE_BOTH:
534 return 0;
535 default:
536 return -EINVAL;
537 }
538}
539
540/* Alternate irq type for PIO3 support */
541static int alt_gpio_irq_type(struct irq_data *d, unsigned type)
542{
543 struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
544 void __iomem *pio = at91_gpio->regbase;
545 unsigned mask = 1 << d->hwirq;
546
547 switch (type) {
548 case IRQ_TYPE_EDGE_RISING:
549 __raw_writel(mask, pio + PIO_ESR);
550 __raw_writel(mask, pio + PIO_REHLSR);
551 break;
552 case IRQ_TYPE_EDGE_FALLING:
553 __raw_writel(mask, pio + PIO_ESR);
554 __raw_writel(mask, pio + PIO_FELLSR);
555 break;
556 case IRQ_TYPE_LEVEL_LOW:
557 __raw_writel(mask, pio + PIO_LSR);
558 __raw_writel(mask, pio + PIO_FELLSR);
559 break;
560 case IRQ_TYPE_LEVEL_HIGH:
561 __raw_writel(mask, pio + PIO_LSR);
562 __raw_writel(mask, pio + PIO_REHLSR);
563 break;
564 case IRQ_TYPE_EDGE_BOTH:
565 /*
566 * disable additional interrupt modes:
567 * fall back to default behavior
568 */
569 __raw_writel(mask, pio + PIO_AIMDR);
570 return 0;
571 case IRQ_TYPE_NONE:
572 default:
573 pr_warn("AT91: No type for irq %d\n", gpio_to_irq(d->irq));
574 return -EINVAL;
575 }
576
577 /* enable additional interrupt modes */
578 __raw_writel(mask, pio + PIO_AIMER);
579
580 return 0;
581}
582
583static struct irq_chip gpio_irqchip = {
584 .name = "GPIO",
585 .irq_disable = gpio_irq_mask,
586 .irq_mask = gpio_irq_mask,
587 .irq_unmask = gpio_irq_unmask,
588 /* .irq_set_type is set dynamically */
589 .irq_set_wake = gpio_irq_set_wake,
590};
591
592static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
593{
594 struct irq_chip *chip = irq_desc_get_chip(desc);
595 struct irq_data *idata = irq_desc_get_irq_data(desc);
596 struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(idata);
597 void __iomem *pio = at91_gpio->regbase;
598 unsigned long isr;
599 int n;
600
601 chained_irq_enter(chip, desc);
602 for (;;) {
603 /* Reading ISR acks pending (edge triggered) GPIO interrupts.
604 * When there none are pending, we're finished unless we need
605 * to process multiple banks (like ID_PIOCDE on sam9263).
606 */
607 isr = __raw_readl(pio + PIO_ISR) & __raw_readl(pio + PIO_IMR);
608 if (!isr) {
609 if (!at91_gpio->next)
610 break;
611 at91_gpio = at91_gpio->next;
612 pio = at91_gpio->regbase;
613 continue;
614 }
615
616 n = find_first_bit(&isr, BITS_PER_LONG);
617 while (n < BITS_PER_LONG) {
618 generic_handle_irq(irq_find_mapping(at91_gpio->domain, n));
619 n = find_next_bit(&isr, BITS_PER_LONG, n + 1);
620 }
621 }
622 chained_irq_exit(chip, desc);
623 /* now it may re-trigger */
624}
625
626/*--------------------------------------------------------------------------*/
627
628#ifdef CONFIG_DEBUG_FS
629
630static void gpio_printf(struct seq_file *s, void __iomem *pio, unsigned mask)
631{
632 char *trigger = NULL;
633 char *polarity = NULL;
634
635 if (__raw_readl(pio + PIO_IMR) & mask) {
636 if (!has_pio3() || !(__raw_readl(pio + PIO_AIMMR) & mask )) {
637 trigger = "edge";
638 polarity = "both";
639 } else {
640 if (__raw_readl(pio + PIO_ELSR) & mask) {
641 trigger = "level";
642 polarity = __raw_readl(pio + PIO_FRLHSR) & mask ?
643 "high" : "low";
644 } else {
645 trigger = "edge";
646 polarity = __raw_readl(pio + PIO_FRLHSR) & mask ?
647 "rising" : "falling";
648 }
649 }
650 seq_printf(s, "IRQ:%s-%s\t", trigger, polarity);
651 } else {
652 seq_printf(s, "GPIO:%s\t\t",
653 __raw_readl(pio + PIO_PDSR) & mask ? "1" : "0");
654 }
655}
656
657static int at91_gpio_show(struct seq_file *s, void *unused)
658{
659 int bank, j;
660
661 /* print heading */
662 seq_printf(s, "Pin\t");
663 for (bank = 0; bank < gpio_banks; bank++) {
664 seq_printf(s, "PIO%c\t\t", 'A' + bank);
665 };
666 seq_printf(s, "\n\n");
667
668 /* print pin status */
669 for (j = 0; j < 32; j++) {
670 seq_printf(s, "%i:\t", j);
671
672 for (bank = 0; bank < gpio_banks; bank++) {
673 unsigned pin = (32 * bank) + j;
674 void __iomem *pio = pin_to_controller(pin);
675 unsigned mask = pin_to_mask(pin);
676
677 if (__raw_readl(pio + PIO_PSR) & mask)
678 gpio_printf(s, pio, mask);
679 else
680 seq_printf(s, "%c\t\t",
681 peripheral_function(pio, mask));
682 }
683
684 seq_printf(s, "\n");
685 }
686
687 return 0;
688}
689
690static int at91_gpio_open(struct inode *inode, struct file *file)
691{
692 return single_open(file, at91_gpio_show, NULL);
693}
694
695static const struct file_operations at91_gpio_operations = {
696 .open = at91_gpio_open,
697 .read = seq_read,
698 .llseek = seq_lseek,
699 .release = single_release,
700};
701
702static int __init at91_gpio_debugfs_init(void)
703{
704 /* /sys/kernel/debug/at91_gpio */
705 (void) debugfs_create_file("at91_gpio", S_IFREG | S_IRUGO, NULL, NULL, &at91_gpio_operations);
706 return 0;
707}
708postcore_initcall(at91_gpio_debugfs_init);
709
710#endif
711
712/*--------------------------------------------------------------------------*/
713
714/*
715 * This lock class tells lockdep that GPIO irqs are in a different
716 * category than their parents, so it won't report false recursion.
717 */
718static struct lock_class_key gpio_lock_class;
719
720/*
721 * irqdomain initialization: pile up irqdomains on top of AIC range
722 */
723static void __init at91_gpio_irqdomain(struct at91_gpio_chip *at91_gpio)
724{
725 int irq_base;
726
727 irq_base = irq_alloc_descs(-1, 0, at91_gpio->chip.ngpio, 0);
728 if (irq_base < 0)
729 panic("at91_gpio.%d: error %d: couldn't allocate IRQ numbers.\n",
730 at91_gpio->pioc_idx, irq_base);
731 at91_gpio->domain = irq_domain_add_legacy(NULL, at91_gpio->chip.ngpio,
732 irq_base, 0,
733 &irq_domain_simple_ops, NULL);
734 if (!at91_gpio->domain)
735 panic("at91_gpio.%d: couldn't allocate irq domain.\n",
736 at91_gpio->pioc_idx);
737}
738
739/*
740 * Called from the processor-specific init to enable GPIO interrupt support.
741 */
742void __init at91_gpio_irq_setup(void)
743{
744 unsigned pioc;
745 int gpio_irqnbr = 0;
746 struct at91_gpio_chip *this, *prev;
747
748 /* Setup proper .irq_set_type function */
749 if (has_pio3())
750 gpio_irqchip.irq_set_type = alt_gpio_irq_type;
751 else
752 gpio_irqchip.irq_set_type = gpio_irq_type;
753
754 for (pioc = 0, this = gpio_chip, prev = NULL;
755 pioc++ < gpio_banks;
756 prev = this, this++) {
757 int offset;
758
759 __raw_writel(~0, this->regbase + PIO_IDR);
760
761 /* setup irq domain for this GPIO controller */
762 at91_gpio_irqdomain(this);
763
764 for (offset = 0; offset < this->chip.ngpio; offset++) {
765 unsigned int virq = irq_find_mapping(this->domain, offset);
766 irq_set_lockdep_class(virq, &gpio_lock_class);
767
768 /*
769 * Can use the "simple" and not "edge" handler since it's
770 * shorter, and the AIC handles interrupts sanely.
771 */
772 irq_set_chip_and_handler(virq, &gpio_irqchip,
773 handle_simple_irq);
774 set_irq_flags(virq, IRQF_VALID);
775 irq_set_chip_data(virq, this);
776
777 gpio_irqnbr++;
778 }
779
780 /* The toplevel handler handles one bank of GPIOs, except
781 * on some SoC it can handles up to three...
782 * We only set up the handler for the first of the list.
783 */
784 if (prev && prev->next == this)
785 continue;
786
787 this->pioc_virq = irq_create_mapping(NULL, this->pioc_hwirq);
788 irq_set_chip_data(this->pioc_virq, this);
789 irq_set_chained_handler(this->pioc_virq, gpio_irq_handler);
790 }
791 pr_info("AT91: %d gpio irqs in %d banks\n", gpio_irqnbr, gpio_banks);
792}
793
794/* gpiolib support */
795static int at91_gpiolib_request(struct gpio_chip *chip, unsigned offset)
796{
797 struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip);
798 void __iomem *pio = at91_gpio->regbase;
799 unsigned mask = 1 << offset;
800
801 __raw_writel(mask, pio + PIO_PER);
802 return 0;
803}
804
805static int at91_gpiolib_get_direction(struct gpio_chip *chip, unsigned offset)
806{
807 struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip);
808 void __iomem *pio = at91_gpio->regbase;
809 unsigned mask = 1 << offset;
810 u32 osr;
811
812 osr = __raw_readl(pio + PIO_OSR);
813 return !(osr & mask);
814}
815
816static int at91_gpiolib_direction_input(struct gpio_chip *chip,
817 unsigned offset)
818{
819 struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip);
820 void __iomem *pio = at91_gpio->regbase;
821 unsigned mask = 1 << offset;
822
823 __raw_writel(mask, pio + PIO_ODR);
824 return 0;
825}
826
827static int at91_gpiolib_direction_output(struct gpio_chip *chip,
828 unsigned offset, int val)
829{
830 struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip);
831 void __iomem *pio = at91_gpio->regbase;
832 unsigned mask = 1 << offset;
833
834 __raw_writel(mask, pio + (val ? PIO_SODR : PIO_CODR));
835 __raw_writel(mask, pio + PIO_OER);
836 return 0;
837}
838
839static int at91_gpiolib_get(struct gpio_chip *chip, unsigned offset)
840{
841 struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip);
842 void __iomem *pio = at91_gpio->regbase;
843 unsigned mask = 1 << offset;
844 u32 pdsr;
845
846 pdsr = __raw_readl(pio + PIO_PDSR);
847 return (pdsr & mask) != 0;
848}
849
850static void at91_gpiolib_set(struct gpio_chip *chip, unsigned offset, int val)
851{
852 struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip);
853 void __iomem *pio = at91_gpio->regbase;
854 unsigned mask = 1 << offset;
855
856 __raw_writel(mask, pio + (val ? PIO_SODR : PIO_CODR));
857}
858
859static void at91_gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip)
860{
861 int i;
862
863 for (i = 0; i < chip->ngpio; i++) {
864 unsigned pin = chip->base + i;
865 void __iomem *pio = pin_to_controller(pin);
866 unsigned mask = pin_to_mask(pin);
867 const char *gpio_label;
868
869 gpio_label = gpiochip_is_requested(chip, i);
870 if (gpio_label) {
871 seq_printf(s, "[%s] GPIO%s%d: ",
872 gpio_label, chip->label, i);
873 if (__raw_readl(pio + PIO_PSR) & mask)
874 seq_printf(s, "[gpio] %s\n",
875 at91_get_gpio_value(pin) ?
876 "set" : "clear");
877 else
878 seq_printf(s, "[periph %c]\n",
879 peripheral_function(pio, mask));
880 }
881 }
882}
883
884static int at91_gpiolib_to_irq(struct gpio_chip *chip, unsigned offset)
885{
886 struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip);
887 int virq;
888
889 if (offset < chip->ngpio)
890 virq = irq_create_mapping(at91_gpio->domain, offset);
891 else
892 virq = -ENXIO;
893
894 dev_dbg(chip->dev, "%s: request IRQ for GPIO %d, return %d\n",
895 chip->label, offset + chip->base, virq);
896 return virq;
897}
898
899static int __init at91_gpio_setup_clk(int idx)
900{
901 struct at91_gpio_chip *at91_gpio = &gpio_chip[idx];
902
903 /* retreive PIO controller's clock */
904 at91_gpio->clock = clk_get_sys(NULL, at91_gpio->chip.label);
905 if (IS_ERR(at91_gpio->clock)) {
906 pr_err("at91_gpio.%d, failed to get clock, ignoring.\n", idx);
907 goto err;
908 }
909
910 if (clk_prepare(at91_gpio->clock))
911 goto clk_prep_err;
912
913 /* enable PIO controller's clock */
914 if (clk_enable(at91_gpio->clock)) {
915 pr_err("at91_gpio.%d, failed to enable clock, ignoring.\n", idx);
916 goto clk_err;
917 }
918
919 return 0;
920
921clk_err:
922 clk_unprepare(at91_gpio->clock);
923clk_prep_err:
924 clk_put(at91_gpio->clock);
925err:
926 return -EINVAL;
927}
928
929static void __init at91_gpio_init_one(int idx, u32 regbase, int pioc_hwirq)
930{
931 struct at91_gpio_chip *at91_gpio = &gpio_chip[idx];
932
933 at91_gpio->chip.base = idx * MAX_NB_GPIO_PER_BANK;
934 at91_gpio->pioc_hwirq = pioc_hwirq;
935 at91_gpio->pioc_idx = idx;
936
937 at91_gpio->regbase = ioremap(regbase, 512);
938 if (!at91_gpio->regbase) {
939 pr_err("at91_gpio.%d, failed to map registers, ignoring.\n", idx);
940 return;
941 }
942
943 if (at91_gpio_setup_clk(idx))
944 goto ioremap_err;
945
946 gpio_banks = max(gpio_banks, idx + 1);
947 return;
948
949ioremap_err:
950 iounmap(at91_gpio->regbase);
951}
952
953/*
954 * Called from the processor-specific init to enable GPIO pin support.
955 */
956void __init at91_gpio_init(struct at91_gpio_bank *data, int nr_banks)
957{
958 unsigned i;
959 struct at91_gpio_chip *at91_gpio, *last = NULL;
960
961 BUG_ON(nr_banks > MAX_GPIO_BANKS);
962
963 if (of_have_populated_dt())
964 return;
965
966 for (i = 0; i < nr_banks; i++)
967 at91_gpio_init_one(i, data[i].regbase, data[i].id);
968
969 for (i = 0; i < gpio_banks; i++) {
970 at91_gpio = &gpio_chip[i];
971
972 /*
973 * GPIO controller are grouped on some SoC:
974 * PIOC, PIOD and PIOE can share the same IRQ line
975 */
976 if (last && last->pioc_hwirq == at91_gpio->pioc_hwirq)
977 last->next = at91_gpio;
978 last = at91_gpio;
979
980 gpiochip_add(&at91_gpio->chip);
981 }
982}
diff --git a/arch/arm/mach-at91/gpio.h b/arch/arm/mach-at91/gpio.h
deleted file mode 100644
index eed465ab0dd7..000000000000
--- a/arch/arm/mach-at91/gpio.h
+++ /dev/null
@@ -1,214 +0,0 @@
1/*
2 * arch/arm/mach-at91/include/mach/gpio.h
3 *
4 * Copyright (C) 2005 HP Labs
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 */
12
13#ifndef __ASM_ARCH_AT91RM9200_GPIO_H
14#define __ASM_ARCH_AT91RM9200_GPIO_H
15
16#include <linux/kernel.h>
17#include <asm/irq.h>
18
19#define MAX_GPIO_BANKS 5
20#define NR_BUILTIN_GPIO (MAX_GPIO_BANKS * 32)
21
22/* these pin numbers double as IRQ numbers, like AT91xxx_ID_* values */
23
24#define AT91_PIN_PA0 (0x00 + 0)
25#define AT91_PIN_PA1 (0x00 + 1)
26#define AT91_PIN_PA2 (0x00 + 2)
27#define AT91_PIN_PA3 (0x00 + 3)
28#define AT91_PIN_PA4 (0x00 + 4)
29#define AT91_PIN_PA5 (0x00 + 5)
30#define AT91_PIN_PA6 (0x00 + 6)
31#define AT91_PIN_PA7 (0x00 + 7)
32#define AT91_PIN_PA8 (0x00 + 8)
33#define AT91_PIN_PA9 (0x00 + 9)
34#define AT91_PIN_PA10 (0x00 + 10)
35#define AT91_PIN_PA11 (0x00 + 11)
36#define AT91_PIN_PA12 (0x00 + 12)
37#define AT91_PIN_PA13 (0x00 + 13)
38#define AT91_PIN_PA14 (0x00 + 14)
39#define AT91_PIN_PA15 (0x00 + 15)
40#define AT91_PIN_PA16 (0x00 + 16)
41#define AT91_PIN_PA17 (0x00 + 17)
42#define AT91_PIN_PA18 (0x00 + 18)
43#define AT91_PIN_PA19 (0x00 + 19)
44#define AT91_PIN_PA20 (0x00 + 20)
45#define AT91_PIN_PA21 (0x00 + 21)
46#define AT91_PIN_PA22 (0x00 + 22)
47#define AT91_PIN_PA23 (0x00 + 23)
48#define AT91_PIN_PA24 (0x00 + 24)
49#define AT91_PIN_PA25 (0x00 + 25)
50#define AT91_PIN_PA26 (0x00 + 26)
51#define AT91_PIN_PA27 (0x00 + 27)
52#define AT91_PIN_PA28 (0x00 + 28)
53#define AT91_PIN_PA29 (0x00 + 29)
54#define AT91_PIN_PA30 (0x00 + 30)
55#define AT91_PIN_PA31 (0x00 + 31)
56
57#define AT91_PIN_PB0 (0x20 + 0)
58#define AT91_PIN_PB1 (0x20 + 1)
59#define AT91_PIN_PB2 (0x20 + 2)
60#define AT91_PIN_PB3 (0x20 + 3)
61#define AT91_PIN_PB4 (0x20 + 4)
62#define AT91_PIN_PB5 (0x20 + 5)
63#define AT91_PIN_PB6 (0x20 + 6)
64#define AT91_PIN_PB7 (0x20 + 7)
65#define AT91_PIN_PB8 (0x20 + 8)
66#define AT91_PIN_PB9 (0x20 + 9)
67#define AT91_PIN_PB10 (0x20 + 10)
68#define AT91_PIN_PB11 (0x20 + 11)
69#define AT91_PIN_PB12 (0x20 + 12)
70#define AT91_PIN_PB13 (0x20 + 13)
71#define AT91_PIN_PB14 (0x20 + 14)
72#define AT91_PIN_PB15 (0x20 + 15)
73#define AT91_PIN_PB16 (0x20 + 16)
74#define AT91_PIN_PB17 (0x20 + 17)
75#define AT91_PIN_PB18 (0x20 + 18)
76#define AT91_PIN_PB19 (0x20 + 19)
77#define AT91_PIN_PB20 (0x20 + 20)
78#define AT91_PIN_PB21 (0x20 + 21)
79#define AT91_PIN_PB22 (0x20 + 22)
80#define AT91_PIN_PB23 (0x20 + 23)
81#define AT91_PIN_PB24 (0x20 + 24)
82#define AT91_PIN_PB25 (0x20 + 25)
83#define AT91_PIN_PB26 (0x20 + 26)
84#define AT91_PIN_PB27 (0x20 + 27)
85#define AT91_PIN_PB28 (0x20 + 28)
86#define AT91_PIN_PB29 (0x20 + 29)
87#define AT91_PIN_PB30 (0x20 + 30)
88#define AT91_PIN_PB31 (0x20 + 31)
89
90#define AT91_PIN_PC0 (0x40 + 0)
91#define AT91_PIN_PC1 (0x40 + 1)
92#define AT91_PIN_PC2 (0x40 + 2)
93#define AT91_PIN_PC3 (0x40 + 3)
94#define AT91_PIN_PC4 (0x40 + 4)
95#define AT91_PIN_PC5 (0x40 + 5)
96#define AT91_PIN_PC6 (0x40 + 6)
97#define AT91_PIN_PC7 (0x40 + 7)
98#define AT91_PIN_PC8 (0x40 + 8)
99#define AT91_PIN_PC9 (0x40 + 9)
100#define AT91_PIN_PC10 (0x40 + 10)
101#define AT91_PIN_PC11 (0x40 + 11)
102#define AT91_PIN_PC12 (0x40 + 12)
103#define AT91_PIN_PC13 (0x40 + 13)
104#define AT91_PIN_PC14 (0x40 + 14)
105#define AT91_PIN_PC15 (0x40 + 15)
106#define AT91_PIN_PC16 (0x40 + 16)
107#define AT91_PIN_PC17 (0x40 + 17)
108#define AT91_PIN_PC18 (0x40 + 18)
109#define AT91_PIN_PC19 (0x40 + 19)
110#define AT91_PIN_PC20 (0x40 + 20)
111#define AT91_PIN_PC21 (0x40 + 21)
112#define AT91_PIN_PC22 (0x40 + 22)
113#define AT91_PIN_PC23 (0x40 + 23)
114#define AT91_PIN_PC24 (0x40 + 24)
115#define AT91_PIN_PC25 (0x40 + 25)
116#define AT91_PIN_PC26 (0x40 + 26)
117#define AT91_PIN_PC27 (0x40 + 27)
118#define AT91_PIN_PC28 (0x40 + 28)
119#define AT91_PIN_PC29 (0x40 + 29)
120#define AT91_PIN_PC30 (0x40 + 30)
121#define AT91_PIN_PC31 (0x40 + 31)
122
123#define AT91_PIN_PD0 (0x60 + 0)
124#define AT91_PIN_PD1 (0x60 + 1)
125#define AT91_PIN_PD2 (0x60 + 2)
126#define AT91_PIN_PD3 (0x60 + 3)
127#define AT91_PIN_PD4 (0x60 + 4)
128#define AT91_PIN_PD5 (0x60 + 5)
129#define AT91_PIN_PD6 (0x60 + 6)
130#define AT91_PIN_PD7 (0x60 + 7)
131#define AT91_PIN_PD8 (0x60 + 8)
132#define AT91_PIN_PD9 (0x60 + 9)
133#define AT91_PIN_PD10 (0x60 + 10)
134#define AT91_PIN_PD11 (0x60 + 11)
135#define AT91_PIN_PD12 (0x60 + 12)
136#define AT91_PIN_PD13 (0x60 + 13)
137#define AT91_PIN_PD14 (0x60 + 14)
138#define AT91_PIN_PD15 (0x60 + 15)
139#define AT91_PIN_PD16 (0x60 + 16)
140#define AT91_PIN_PD17 (0x60 + 17)
141#define AT91_PIN_PD18 (0x60 + 18)
142#define AT91_PIN_PD19 (0x60 + 19)
143#define AT91_PIN_PD20 (0x60 + 20)
144#define AT91_PIN_PD21 (0x60 + 21)
145#define AT91_PIN_PD22 (0x60 + 22)
146#define AT91_PIN_PD23 (0x60 + 23)
147#define AT91_PIN_PD24 (0x60 + 24)
148#define AT91_PIN_PD25 (0x60 + 25)
149#define AT91_PIN_PD26 (0x60 + 26)
150#define AT91_PIN_PD27 (0x60 + 27)
151#define AT91_PIN_PD28 (0x60 + 28)
152#define AT91_PIN_PD29 (0x60 + 29)
153#define AT91_PIN_PD30 (0x60 + 30)
154#define AT91_PIN_PD31 (0x60 + 31)
155
156#define AT91_PIN_PE0 (0x80 + 0)
157#define AT91_PIN_PE1 (0x80 + 1)
158#define AT91_PIN_PE2 (0x80 + 2)
159#define AT91_PIN_PE3 (0x80 + 3)
160#define AT91_PIN_PE4 (0x80 + 4)
161#define AT91_PIN_PE5 (0x80 + 5)
162#define AT91_PIN_PE6 (0x80 + 6)
163#define AT91_PIN_PE7 (0x80 + 7)
164#define AT91_PIN_PE8 (0x80 + 8)
165#define AT91_PIN_PE9 (0x80 + 9)
166#define AT91_PIN_PE10 (0x80 + 10)
167#define AT91_PIN_PE11 (0x80 + 11)
168#define AT91_PIN_PE12 (0x80 + 12)
169#define AT91_PIN_PE13 (0x80 + 13)
170#define AT91_PIN_PE14 (0x80 + 14)
171#define AT91_PIN_PE15 (0x80 + 15)
172#define AT91_PIN_PE16 (0x80 + 16)
173#define AT91_PIN_PE17 (0x80 + 17)
174#define AT91_PIN_PE18 (0x80 + 18)
175#define AT91_PIN_PE19 (0x80 + 19)
176#define AT91_PIN_PE20 (0x80 + 20)
177#define AT91_PIN_PE21 (0x80 + 21)
178#define AT91_PIN_PE22 (0x80 + 22)
179#define AT91_PIN_PE23 (0x80 + 23)
180#define AT91_PIN_PE24 (0x80 + 24)
181#define AT91_PIN_PE25 (0x80 + 25)
182#define AT91_PIN_PE26 (0x80 + 26)
183#define AT91_PIN_PE27 (0x80 + 27)
184#define AT91_PIN_PE28 (0x80 + 28)
185#define AT91_PIN_PE29 (0x80 + 29)
186#define AT91_PIN_PE30 (0x80 + 30)
187#define AT91_PIN_PE31 (0x80 + 31)
188
189#ifndef __ASSEMBLY__
190/* setup setup routines, called from board init or driver probe() */
191extern int __init_or_module at91_set_GPIO_periph(unsigned pin, int use_pullup);
192extern int __init_or_module at91_set_A_periph(unsigned pin, int use_pullup);
193extern int __init_or_module at91_set_B_periph(unsigned pin, int use_pullup);
194extern int __init_or_module at91_set_C_periph(unsigned pin, int use_pullup);
195extern int __init_or_module at91_set_D_periph(unsigned pin, int use_pullup);
196extern int __init_or_module at91_set_gpio_input(unsigned pin, int use_pullup);
197extern int __init_or_module at91_set_gpio_output(unsigned pin, int value);
198extern int __init_or_module at91_set_deglitch(unsigned pin, int is_on);
199extern int __init_or_module at91_set_debounce(unsigned pin, int is_on, int div);
200extern int __init_or_module at91_set_multi_drive(unsigned pin, int is_on);
201extern int __init_or_module at91_set_pulldown(unsigned pin, int is_on);
202extern int __init_or_module at91_disable_schmitt_trig(unsigned pin);
203
204/* callable at any time */
205extern int at91_set_gpio_value(unsigned pin, int value);
206extern int at91_get_gpio_value(unsigned pin);
207
208/* callable only from core power-management code */
209extern void at91_gpio_suspend(void);
210extern void at91_gpio_resume(void);
211
212#endif /* __ASSEMBLY__ */
213
214#endif
diff --git a/arch/arm/mach-at91/gsia18s.h b/arch/arm/mach-at91/gsia18s.h
deleted file mode 100644
index 307c194926f9..000000000000
--- a/arch/arm/mach-at91/gsia18s.h
+++ /dev/null
@@ -1,33 +0,0 @@
1/* Buttons */
2#define GPIO_TRIG_NET_IN AT91_PIN_PB21
3#define GPIO_CARD_UNMOUNT_0 AT91_PIN_PB13
4#define GPIO_CARD_UNMOUNT_1 AT91_PIN_PB12
5#define GPIO_KEY_POWER AT91_PIN_PA25
6
7/* PCF8574 0x20 GPIO - U1 on the GS_IA18-CB_V3 board */
8#define GS_IA18_S_PCF_GPIO_BASE0 NR_BUILTIN_GPIO
9#define PCF_GPIO_HDC_POWER (GS_IA18_S_PCF_GPIO_BASE0 + 0)
10#define PCF_GPIO_WIFI_SETUP (GS_IA18_S_PCF_GPIO_BASE0 + 1)
11#define PCF_GPIO_WIFI_ENABLE (GS_IA18_S_PCF_GPIO_BASE0 + 2)
12#define PCF_GPIO_WIFI_RESET (GS_IA18_S_PCF_GPIO_BASE0 + 3)
13#define PCF_GPIO_ETH_DETECT 4 /* this is a GPI */
14#define PCF_GPIO_GPS_SETUP (GS_IA18_S_PCF_GPIO_BASE0 + 5)
15#define PCF_GPIO_GPS_STANDBY (GS_IA18_S_PCF_GPIO_BASE0 + 6)
16#define PCF_GPIO_GPS_POWER (GS_IA18_S_PCF_GPIO_BASE0 + 7)
17
18/* PCF8574 0x22 GPIO - U1 on the GS_2G_OPT1-A_V0 board (Alarm) */
19#define GS_IA18_S_PCF_GPIO_BASE1 (GS_IA18_S_PCF_GPIO_BASE0 + 8)
20#define PCF_GPIO_ALARM1 (GS_IA18_S_PCF_GPIO_BASE1 + 0)
21#define PCF_GPIO_ALARM2 (GS_IA18_S_PCF_GPIO_BASE1 + 1)
22#define PCF_GPIO_ALARM3 (GS_IA18_S_PCF_GPIO_BASE1 + 2)
23#define PCF_GPIO_ALARM4 (GS_IA18_S_PCF_GPIO_BASE1 + 3)
24/* bits 4, 5, 6 not used */
25#define PCF_GPIO_ALARM_V_RELAY_ON (GS_IA18_S_PCF_GPIO_BASE1 + 7)
26
27/* PCF8574 0x24 GPIO U1 on the GS_2G-OPT23-A_V0 board (Modem) */
28#define GS_IA18_S_PCF_GPIO_BASE2 (GS_IA18_S_PCF_GPIO_BASE1 + 8)
29#define PCF_GPIO_MODEM_POWER (GS_IA18_S_PCF_GPIO_BASE2 + 0)
30#define PCF_GPIO_MODEM_RESET (GS_IA18_S_PCF_GPIO_BASE2 + 3)
31/* bits 1, 2, 4, 5 not used */
32#define PCF_GPIO_TRX_RESET (GS_IA18_S_PCF_GPIO_BASE2 + 6)
33/* bit 7 not used */
diff --git a/arch/arm/mach-at91/include/mach/hardware.h b/arch/arm/mach-at91/include/mach/hardware.h
index a57c1c52a574..cacbaa52418f 100644
--- a/arch/arm/mach-at91/include/mach/hardware.h
+++ b/arch/arm/mach-at91/include/mach/hardware.h
@@ -127,13 +127,8 @@
127 * called as part of the generic suspend/resume path. 127 * called as part of the generic suspend/resume path.
128 */ 128 */
129#ifndef __ASSEMBLY__ 129#ifndef __ASSEMBLY__
130#ifdef CONFIG_PINCTRL_AT91
131extern void at91_pinctrl_gpio_suspend(void); 130extern void at91_pinctrl_gpio_suspend(void);
132extern void at91_pinctrl_gpio_resume(void); 131extern void at91_pinctrl_gpio_resume(void);
133#else
134static inline void at91_pinctrl_gpio_suspend(void) {}
135static inline void at91_pinctrl_gpio_resume(void) {}
136#endif
137#endif 132#endif
138 133
139#endif 134#endif
diff --git a/arch/arm/mach-at91/leds.c b/arch/arm/mach-at91/leds.c
deleted file mode 100644
index eb22e3357e87..000000000000
--- a/arch/arm/mach-at91/leds.c
+++ /dev/null
@@ -1,56 +0,0 @@
1/*
2 * LED driver for Atmel AT91-based boards.
3 *
4 * Copyright (C) SAN People (Pty) Ltd
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
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10*/
11
12#include <linux/gpio.h>
13#include <linux/kernel.h>
14#include <linux/module.h>
15#include <linux/init.h>
16#include <linux/platform_device.h>
17
18#include "board.h"
19#include "gpio.h"
20
21
22/* ------------------------------------------------------------------------- */
23
24#if defined(CONFIG_NEW_LEDS)
25
26/*
27 * New cross-platform LED support.
28 */
29
30static struct gpio_led_platform_data led_data;
31
32static struct platform_device at91_gpio_leds_device = {
33 .name = "leds-gpio",
34 .id = -1,
35 .dev.platform_data = &led_data,
36};
37
38void __init at91_gpio_leds(struct gpio_led *leds, int nr)
39{
40 int i;
41
42 if (!nr)
43 return;
44
45 for (i = 0; i < nr; i++)
46 at91_set_gpio_output(leds[i].gpio, leds[i].active_low);
47
48 led_data.leds = leds;
49 led_data.num_leds = nr;
50 platform_device_register(&at91_gpio_leds_device);
51}
52
53#else
54void __init at91_gpio_leds(struct gpio_led *leds, int nr) {}
55#endif
56
diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index a42360f69127..9b15169a1c62 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -31,7 +31,6 @@
31 31
32#include "generic.h" 32#include "generic.h"
33#include "pm.h" 33#include "pm.h"
34#include "gpio.h"
35 34
36static void (*at91_pm_standby)(void); 35static void (*at91_pm_standby)(void);
37 36
@@ -130,10 +129,7 @@ extern u32 at91_slow_clock_sz;
130 129
131static int at91_pm_enter(suspend_state_t state) 130static int at91_pm_enter(suspend_state_t state)
132{ 131{
133 if (of_have_populated_dt()) 132 at91_pinctrl_gpio_suspend();
134 at91_pinctrl_gpio_suspend();
135 else
136 at91_gpio_suspend();
137 133
138 switch (state) { 134 switch (state) {
139 /* 135 /*
@@ -201,10 +197,7 @@ static int at91_pm_enter(suspend_state_t state)
201error: 197error:
202 target_state = PM_SUSPEND_ON; 198 target_state = PM_SUSPEND_ON;
203 199
204 if (of_have_populated_dt()) 200 at91_pinctrl_gpio_resume();
205 at91_pinctrl_gpio_resume();
206 else
207 at91_gpio_resume();
208 return 0; 201 return 0;
209} 202}
210 203
diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c
index 6c3013e3309b..ce25e85720fb 100644
--- a/arch/arm/mach-at91/setup.c
+++ b/arch/arm/mach-at91/setup.c
@@ -42,31 +42,9 @@ void __init at91rm9200_set_type(int type)
42 at91_get_soc_subtype(&at91_soc_initdata)); 42 at91_get_soc_subtype(&at91_soc_initdata));
43} 43}
44 44
45void __init at91_init_irq_default(void)
46{
47 at91_init_interrupts(at91_boot_soc.default_irq_priority);
48}
49
50void __init at91_init_interrupts(unsigned int *priority)
51{
52 /* Enable GPIO interrupts */
53 at91_gpio_irq_setup();
54}
55
56void __iomem *at91_ramc_base[2]; 45void __iomem *at91_ramc_base[2];
57EXPORT_SYMBOL_GPL(at91_ramc_base); 46EXPORT_SYMBOL_GPL(at91_ramc_base);
58 47
59void __init at91_ioremap_ramc(int id, u32 addr, u32 size)
60{
61 if (id < 0 || id > 1) {
62 pr_emerg("Wrong RAM controller id (%d), cannot continue\n", id);
63 BUG();
64 }
65 at91_ramc_base[id] = ioremap(addr, size);
66 if (!at91_ramc_base[id])
67 panic(pr_fmt("Impossible to ioremap ramc.%d 0x%x\n"), id, addr);
68}
69
70static struct map_desc sram_desc[2] __initdata; 48static struct map_desc sram_desc[2] __initdata;
71 49
72void __init at91_init_sram(int bank, unsigned long base, unsigned int length) 50void __init at91_init_sram(int bank, unsigned long base, unsigned int length)
@@ -414,7 +392,6 @@ void __init at91_ioremap_matrix(u32 base_addr)
414 panic(pr_fmt("Impossible to ioremap at91_matrix_base\n")); 392 panic(pr_fmt("Impossible to ioremap at91_matrix_base\n"));
415} 393}
416 394
417#if defined(CONFIG_OF)
418static struct of_device_id ramc_ids[] = { 395static struct of_device_id ramc_ids[] = {
419 { .compatible = "atmel,at91rm9200-sdramc", .data = at91rm9200_standby }, 396 { .compatible = "atmel,at91rm9200-sdramc", .data = at91rm9200_standby },
420 { .compatible = "atmel,at91sam9260-sdramc", .data = at91sam9_sdram_standby }, 397 { .compatible = "atmel,at91sam9260-sdramc", .data = at91sam9_sdram_standby },
@@ -456,10 +433,6 @@ void __init at91rm9200_dt_initialize(void)
456{ 433{
457 at91_dt_ramc(); 434 at91_dt_ramc();
458 435
459 /* Register the processor-specific clocks */
460 if (at91_boot_soc.register_clocks)
461 at91_boot_soc.register_clocks();
462
463 at91_boot_soc.init(); 436 at91_boot_soc.init();
464} 437}
465 438
@@ -467,33 +440,6 @@ void __init at91_dt_initialize(void)
467{ 440{
468 at91_dt_ramc(); 441 at91_dt_ramc();
469 442
470 /* Register the processor-specific clocks */
471 if (at91_boot_soc.register_clocks)
472 at91_boot_soc.register_clocks();
473
474 if (at91_boot_soc.init) 443 if (at91_boot_soc.init)
475 at91_boot_soc.init(); 444 at91_boot_soc.init();
476} 445}
477#endif
478
479void __init at91_initialize(unsigned long main_clock)
480{
481 at91_boot_soc.ioremap_registers();
482
483 /* Register the processor-specific clocks */
484 at91_boot_soc.register_clocks();
485
486 at91_boot_soc.init();
487
488 pinctrl_provide_dummies();
489}
490
491void __init at91_register_devices(void)
492{
493 at91_boot_soc.register_devices();
494}
495
496void __init at91_init_time(void)
497{
498 at91_boot_soc.init_time();
499}
diff --git a/arch/arm/mach-at91/soc.h b/arch/arm/mach-at91/soc.h
index 9a8fd97a8bef..ae6c0b2f1146 100644
--- a/arch/arm/mach-at91/soc.h
+++ b/arch/arm/mach-at91/soc.h
@@ -6,14 +6,8 @@
6 6
7struct at91_init_soc { 7struct at91_init_soc {
8 int builtin; 8 int builtin;
9 u32 extern_irq;
10 unsigned int *default_irq_priority;
11 void (*map_io)(void); 9 void (*map_io)(void);
12 void (*ioremap_registers)(void);
13 void (*register_clocks)(void);
14 void (*register_devices)(void);
15 void (*init)(void); 10 void (*init)(void);
16 void (*init_time)(void);
17}; 11};
18 12
19extern struct at91_init_soc at91_boot_soc; 13extern struct at91_init_soc at91_boot_soc;
diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c
index d5289098b3df..b5b4d4585c9a 100644
--- a/drivers/clocksource/timer-atmel-pit.c
+++ b/drivers/clocksource/timer-atmel-pit.c
@@ -262,35 +262,3 @@ static void __init at91sam926x_pit_dt_init(struct device_node *node)
262} 262}
263CLOCKSOURCE_OF_DECLARE(at91sam926x_pit, "atmel,at91sam9260-pit", 263CLOCKSOURCE_OF_DECLARE(at91sam926x_pit, "atmel,at91sam9260-pit",
264 at91sam926x_pit_dt_init); 264 at91sam926x_pit_dt_init);
265
266static void __iomem *pit_base_addr;
267
268void __init at91sam926x_pit_init(int irq)
269{
270 struct pit_data *data;
271
272 data = kzalloc(sizeof(*data), GFP_KERNEL);
273 if (!data)
274 panic(pr_fmt("Unable to allocate memory\n"));
275
276 data->base = pit_base_addr;
277
278 data->mck = clk_get(NULL, "mck");
279 if (IS_ERR(data->mck))
280 panic(pr_fmt("Unable to get mck clk\n"));
281
282 data->irq = irq;
283
284 at91sam926x_pit_common_init(data);
285}
286
287void __init at91sam926x_ioremap_pit(u32 addr)
288{
289 if (of_have_populated_dt())
290 return;
291
292 pit_base_addr = ioremap(addr, 16);
293
294 if (!pit_base_addr)
295 panic(pr_fmt("Impossible to ioremap PIT\n"));
296}