diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-02-09 11:09:05 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-02-09 11:09:05 -0500 |
commit | d27146dd5b72ab7d7e641f56f4bee1484dabd0b7 (patch) | |
tree | 88b5833ec3d8f4ee19426ed2c23f95edcdf190fb /arch | |
parent | 62045305c20a194127ae87ccf963cfe6ffde7c4e (diff) | |
parent | 4ffabefb456f140eb47c7294e9158a9027a64ccc (diff) |
Merge branch 'for-linus' of git://www.atmel.no/~hskinnemoen/linux/kernel/avr32
* 'for-linus' of git://www.atmel.no/~hskinnemoen/linux/kernel/avr32:
[AVR32] Add missing #include <linux/module.h>
[AVR32] ssize_t should be long, not int
[AVR32] Remove last remains of libgcc
[AVR32] SPI platform code update
[AVR32] Add PIOE device and reserve SDRAM pins
[AVR32] Introduce at32_reserve_pin()
[AVR32] Don't reset PIO state at bootup
[AVR32] GPIO API implementation
[AVR32] Use ARRAY_SIZE macro when appropriate
[AVR32] Implement dma_mapping_error()
[AVR32] Fix incorrect invalidation of shared cachelines
[AVR32] ext int fixes
[AVR32] fix serial port setup on ATSTK1000
[AVR32] /proc/interrupts display
Remove a couple final references to obsolete verify_area().
Diffstat (limited to 'arch')
-rw-r--r-- | arch/avr32/boards/atstk1000/Makefile | 2 | ||||
-rw-r--r-- | arch/avr32/boards/atstk1000/atstk1002.c | 53 | ||||
-rw-r--r-- | arch/avr32/boards/atstk1000/spi.c | 27 | ||||
-rw-r--r-- | arch/avr32/kernel/cpu.c | 1 | ||||
-rw-r--r-- | arch/avr32/kernel/irq.c | 1 | ||||
-rw-r--r-- | arch/avr32/kernel/setup.c | 4 | ||||
-rw-r--r-- | arch/avr32/lib/libgcc.h | 33 | ||||
-rw-r--r-- | arch/avr32/lib/longlong.h | 98 | ||||
-rw-r--r-- | arch/avr32/mach-at32ap/Makefile | 2 | ||||
-rw-r--r-- | arch/avr32/mach-at32ap/at32ap7000.c | 60 | ||||
-rw-r--r-- | arch/avr32/mach-at32ap/extint.c | 36 | ||||
-rw-r--r-- | arch/avr32/mach-at32ap/pio.c | 255 | ||||
-rw-r--r-- | arch/avr32/mm/cache.c | 32 |
13 files changed, 385 insertions, 219 deletions
diff --git a/arch/avr32/boards/atstk1000/Makefile b/arch/avr32/boards/atstk1000/Makefile index df9499480530..8e0992201bb9 100644 --- a/arch/avr32/boards/atstk1000/Makefile +++ b/arch/avr32/boards/atstk1000/Makefile | |||
@@ -1,2 +1,2 @@ | |||
1 | obj-y += setup.o spi.o flash.o | 1 | obj-y += setup.o flash.o |
2 | obj-$(CONFIG_BOARD_ATSTK1002) += atstk1002.o | 2 | obj-$(CONFIG_BOARD_ATSTK1002) += atstk1002.o |
diff --git a/arch/avr32/boards/atstk1000/atstk1002.c b/arch/avr32/boards/atstk1000/atstk1002.c index 32b361f31c2c..d47e39f0e971 100644 --- a/arch/avr32/boards/atstk1000/atstk1002.c +++ b/arch/avr32/boards/atstk1000/atstk1002.c | |||
@@ -8,17 +8,24 @@ | |||
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
9 | */ | 9 | */ |
10 | #include <linux/clk.h> | 10 | #include <linux/clk.h> |
11 | #include <linux/device.h> | ||
11 | #include <linux/etherdevice.h> | 12 | #include <linux/etherdevice.h> |
12 | #include <linux/init.h> | 13 | #include <linux/init.h> |
13 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
14 | #include <linux/platform_device.h> | 15 | #include <linux/platform_device.h> |
15 | #include <linux/string.h> | 16 | #include <linux/string.h> |
16 | #include <linux/types.h> | 17 | #include <linux/types.h> |
18 | #include <linux/spi/spi.h> | ||
17 | 19 | ||
18 | #include <asm/io.h> | 20 | #include <asm/io.h> |
19 | #include <asm/setup.h> | 21 | #include <asm/setup.h> |
22 | #include <asm/arch/at32ap7000.h> | ||
20 | #include <asm/arch/board.h> | 23 | #include <asm/arch/board.h> |
21 | #include <asm/arch/init.h> | 24 | #include <asm/arch/init.h> |
25 | #include <asm/arch/portmux.h> | ||
26 | |||
27 | |||
28 | #define SW2_DEFAULT /* MMCI and UART_A available */ | ||
22 | 29 | ||
23 | struct eth_addr { | 30 | struct eth_addr { |
24 | u8 addr[6]; | 31 | u8 addr[6]; |
@@ -29,6 +36,16 @@ static struct eth_addr __initdata hw_addr[2]; | |||
29 | static struct eth_platform_data __initdata eth_data[2]; | 36 | static struct eth_platform_data __initdata eth_data[2]; |
30 | extern struct lcdc_platform_data atstk1000_fb0_data; | 37 | extern struct lcdc_platform_data atstk1000_fb0_data; |
31 | 38 | ||
39 | static struct spi_board_info spi_board_info[] __initdata = { | ||
40 | { | ||
41 | .modalias = "ltv350qv", | ||
42 | .controller_data = (void *)GPIO_PIN_PA(4), | ||
43 | .max_speed_hz = 16000000, | ||
44 | .bus_num = 0, | ||
45 | .chip_select = 1, | ||
46 | }, | ||
47 | }; | ||
48 | |||
32 | /* | 49 | /* |
33 | * The next two functions should go away as the boot loader is | 50 | * The next two functions should go away as the boot loader is |
34 | * supposed to initialize the macb address registers with a valid | 51 | * supposed to initialize the macb address registers with a valid |
@@ -86,23 +103,53 @@ static void __init set_hw_addr(struct platform_device *pdev) | |||
86 | 103 | ||
87 | void __init setup_board(void) | 104 | void __init setup_board(void) |
88 | { | 105 | { |
89 | at32_map_usart(1, 0); /* /dev/ttyS0 */ | 106 | #ifdef SW2_DEFAULT |
90 | at32_map_usart(2, 1); /* /dev/ttyS1 */ | 107 | at32_map_usart(1, 0); /* USART 1/A: /dev/ttyS0, DB9 */ |
91 | at32_map_usart(3, 2); /* /dev/ttyS2 */ | 108 | #else |
109 | at32_map_usart(0, 1); /* USART 0/B: /dev/ttyS1, IRDA */ | ||
110 | #endif | ||
111 | /* USART 2/unused: expansion connector */ | ||
112 | at32_map_usart(3, 2); /* USART 3/C: /dev/ttyS2, DB9 */ | ||
92 | 113 | ||
93 | at32_setup_serial_console(0); | 114 | at32_setup_serial_console(0); |
94 | } | 115 | } |
95 | 116 | ||
96 | static int __init atstk1002_init(void) | 117 | static int __init atstk1002_init(void) |
97 | { | 118 | { |
119 | /* | ||
120 | * ATSTK1000 uses 32-bit SDRAM interface. Reserve the | ||
121 | * SDRAM-specific pins so that nobody messes with them. | ||
122 | */ | ||
123 | at32_reserve_pin(GPIO_PIN_PE(0)); /* DATA[16] */ | ||
124 | at32_reserve_pin(GPIO_PIN_PE(1)); /* DATA[17] */ | ||
125 | at32_reserve_pin(GPIO_PIN_PE(2)); /* DATA[18] */ | ||
126 | at32_reserve_pin(GPIO_PIN_PE(3)); /* DATA[19] */ | ||
127 | at32_reserve_pin(GPIO_PIN_PE(4)); /* DATA[20] */ | ||
128 | at32_reserve_pin(GPIO_PIN_PE(5)); /* DATA[21] */ | ||
129 | at32_reserve_pin(GPIO_PIN_PE(6)); /* DATA[22] */ | ||
130 | at32_reserve_pin(GPIO_PIN_PE(7)); /* DATA[23] */ | ||
131 | at32_reserve_pin(GPIO_PIN_PE(8)); /* DATA[24] */ | ||
132 | at32_reserve_pin(GPIO_PIN_PE(9)); /* DATA[25] */ | ||
133 | at32_reserve_pin(GPIO_PIN_PE(10)); /* DATA[26] */ | ||
134 | at32_reserve_pin(GPIO_PIN_PE(11)); /* DATA[27] */ | ||
135 | at32_reserve_pin(GPIO_PIN_PE(12)); /* DATA[28] */ | ||
136 | at32_reserve_pin(GPIO_PIN_PE(13)); /* DATA[29] */ | ||
137 | at32_reserve_pin(GPIO_PIN_PE(14)); /* DATA[30] */ | ||
138 | at32_reserve_pin(GPIO_PIN_PE(15)); /* DATA[31] */ | ||
139 | at32_reserve_pin(GPIO_PIN_PE(26)); /* SDCS */ | ||
140 | |||
98 | at32_add_system_devices(); | 141 | at32_add_system_devices(); |
99 | 142 | ||
143 | #ifdef SW2_DEFAULT | ||
100 | at32_add_device_usart(0); | 144 | at32_add_device_usart(0); |
145 | #else | ||
101 | at32_add_device_usart(1); | 146 | at32_add_device_usart(1); |
147 | #endif | ||
102 | at32_add_device_usart(2); | 148 | at32_add_device_usart(2); |
103 | 149 | ||
104 | set_hw_addr(at32_add_device_eth(0, ð_data[0])); | 150 | set_hw_addr(at32_add_device_eth(0, ð_data[0])); |
105 | 151 | ||
152 | spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info)); | ||
106 | at32_add_device_spi(0); | 153 | at32_add_device_spi(0); |
107 | at32_add_device_lcdc(0, &atstk1000_fb0_data); | 154 | at32_add_device_lcdc(0, &atstk1000_fb0_data); |
108 | 155 | ||
diff --git a/arch/avr32/boards/atstk1000/spi.c b/arch/avr32/boards/atstk1000/spi.c deleted file mode 100644 index 567726c82c6e..000000000000 --- a/arch/avr32/boards/atstk1000/spi.c +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | /* | ||
2 | * ATSTK1000 SPI devices | ||
3 | * | ||
4 | * Copyright (C) 2005 Atmel Norway | ||
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 version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | #include <linux/device.h> | ||
11 | #include <linux/spi/spi.h> | ||
12 | |||
13 | static struct spi_board_info spi_board_info[] __initdata = { | ||
14 | { | ||
15 | .modalias = "ltv350qv", | ||
16 | .max_speed_hz = 16000000, | ||
17 | .bus_num = 0, | ||
18 | .chip_select = 1, | ||
19 | }, | ||
20 | }; | ||
21 | |||
22 | static int board_init_spi(void) | ||
23 | { | ||
24 | spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info)); | ||
25 | return 0; | ||
26 | } | ||
27 | arch_initcall(board_init_spi); | ||
diff --git a/arch/avr32/kernel/cpu.c b/arch/avr32/kernel/cpu.c index 342452ba2049..2e72fd2699df 100644 --- a/arch/avr32/kernel/cpu.c +++ b/arch/avr32/kernel/cpu.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/sysdev.h> | 9 | #include <linux/sysdev.h> |
10 | #include <linux/seq_file.h> | 10 | #include <linux/seq_file.h> |
11 | #include <linux/cpu.h> | 11 | #include <linux/cpu.h> |
12 | #include <linux/module.h> | ||
12 | #include <linux/percpu.h> | 13 | #include <linux/percpu.h> |
13 | #include <linux/param.h> | 14 | #include <linux/param.h> |
14 | #include <linux/errno.h> | 15 | #include <linux/errno.h> |
diff --git a/arch/avr32/kernel/irq.c b/arch/avr32/kernel/irq.c index 856f3548e664..fd311248c143 100644 --- a/arch/avr32/kernel/irq.c +++ b/arch/avr32/kernel/irq.c | |||
@@ -57,6 +57,7 @@ int show_interrupts(struct seq_file *p, void *v) | |||
57 | seq_printf(p, "%3d: ", i); | 57 | seq_printf(p, "%3d: ", i); |
58 | for_each_online_cpu(cpu) | 58 | for_each_online_cpu(cpu) |
59 | seq_printf(p, "%10u ", kstat_cpu(cpu).irqs[i]); | 59 | seq_printf(p, "%10u ", kstat_cpu(cpu).irqs[i]); |
60 | seq_printf(p, " %8s", irq_desc[i].chip->name ? : "-"); | ||
60 | seq_printf(p, " %s", action->name); | 61 | seq_printf(p, " %s", action->name); |
61 | for (action = action->next; action; action = action->next) | 62 | for (action = action->next; action; action = action->next) |
62 | seq_printf(p, ", %s", action->name); | 63 | seq_printf(p, ", %s", action->name); |
diff --git a/arch/avr32/kernel/setup.c b/arch/avr32/kernel/setup.c index a34211601008..c6734aefb559 100644 --- a/arch/avr32/kernel/setup.c +++ b/arch/avr32/kernel/setup.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/root_dev.h> | 17 | #include <linux/root_dev.h> |
18 | #include <linux/cpu.h> | 18 | #include <linux/cpu.h> |
19 | #include <linux/kernel.h> | ||
19 | 20 | ||
20 | #include <asm/sections.h> | 21 | #include <asm/sections.h> |
21 | #include <asm/processor.h> | 22 | #include <asm/processor.h> |
@@ -174,8 +175,7 @@ static int __init parse_tag_mem_range(struct tag *tag, | |||
174 | * Copy the data so the bootmem init code doesn't need to care | 175 | * Copy the data so the bootmem init code doesn't need to care |
175 | * about it. | 176 | * about it. |
176 | */ | 177 | */ |
177 | if (mem_range_next_free >= | 178 | if (mem_range_next_free >= ARRAY_SIZE(mem_range_cache)) |
178 | (sizeof(mem_range_cache) / sizeof(mem_range_cache[0]))) | ||
179 | panic("Physical memory map too complex!\n"); | 179 | panic("Physical memory map too complex!\n"); |
180 | 180 | ||
181 | new = &mem_range_cache[mem_range_next_free++]; | 181 | new = &mem_range_cache[mem_range_next_free++]; |
diff --git a/arch/avr32/lib/libgcc.h b/arch/avr32/lib/libgcc.h deleted file mode 100644 index 5a091b5e3618..000000000000 --- a/arch/avr32/lib/libgcc.h +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | /* Definitions for various functions 'borrowed' from gcc-3.4.3 */ | ||
2 | |||
3 | #define BITS_PER_UNIT 8 | ||
4 | |||
5 | typedef int QItype __attribute__ ((mode (QI))); | ||
6 | typedef unsigned int UQItype __attribute__ ((mode (QI))); | ||
7 | typedef int HItype __attribute__ ((mode (HI))); | ||
8 | typedef unsigned int UHItype __attribute__ ((mode (HI))); | ||
9 | typedef int SItype __attribute__ ((mode (SI))); | ||
10 | typedef unsigned int USItype __attribute__ ((mode (SI))); | ||
11 | typedef int DItype __attribute__ ((mode (DI))); | ||
12 | typedef unsigned int UDItype __attribute__ ((mode (DI))); | ||
13 | typedef float SFtype __attribute__ ((mode (SF))); | ||
14 | typedef float DFtype __attribute__ ((mode (DF))); | ||
15 | typedef int word_type __attribute__ ((mode (__word__))); | ||
16 | |||
17 | #define W_TYPE_SIZE (4 * BITS_PER_UNIT) | ||
18 | #define Wtype SItype | ||
19 | #define UWtype USItype | ||
20 | #define HWtype SItype | ||
21 | #define UHWtype USItype | ||
22 | #define DWtype DItype | ||
23 | #define UDWtype UDItype | ||
24 | #define __NW(a,b) __ ## a ## si ## b | ||
25 | #define __NDW(a,b) __ ## a ## di ## b | ||
26 | |||
27 | struct DWstruct {Wtype high, low;}; | ||
28 | |||
29 | typedef union | ||
30 | { | ||
31 | struct DWstruct s; | ||
32 | DWtype ll; | ||
33 | } DWunion; | ||
diff --git a/arch/avr32/lib/longlong.h b/arch/avr32/lib/longlong.h deleted file mode 100644 index cd5e369ac437..000000000000 --- a/arch/avr32/lib/longlong.h +++ /dev/null | |||
@@ -1,98 +0,0 @@ | |||
1 | /* longlong.h -- definitions for mixed size 32/64 bit arithmetic. | ||
2 | Copyright (C) 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000 | ||
3 | Free Software Foundation, Inc. | ||
4 | |||
5 | This definition file is free software; you can redistribute it | ||
6 | and/or modify it under the terms of the GNU General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2, or (at your option) any later version. | ||
9 | |||
10 | This definition file is distributed in the hope that it will be | ||
11 | useful, but WITHOUT ANY WARRANTY; without even the implied | ||
12 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | See the GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. */ | ||
19 | |||
20 | /* Borrowed from gcc-3.4.3 */ | ||
21 | |||
22 | #define __BITS4 (W_TYPE_SIZE / 4) | ||
23 | #define __ll_B ((UWtype) 1 << (W_TYPE_SIZE / 2)) | ||
24 | #define __ll_lowpart(t) ((UWtype) (t) & (__ll_B - 1)) | ||
25 | #define __ll_highpart(t) ((UWtype) (t) >> (W_TYPE_SIZE / 2)) | ||
26 | |||
27 | #define count_leading_zeros(count, x) ((count) = __builtin_clz(x)) | ||
28 | |||
29 | #define __udiv_qrnnd_c(q, r, n1, n0, d) \ | ||
30 | do { \ | ||
31 | UWtype __d1, __d0, __q1, __q0; \ | ||
32 | UWtype __r1, __r0, __m; \ | ||
33 | __d1 = __ll_highpart (d); \ | ||
34 | __d0 = __ll_lowpart (d); \ | ||
35 | \ | ||
36 | __r1 = (n1) % __d1; \ | ||
37 | __q1 = (n1) / __d1; \ | ||
38 | __m = (UWtype) __q1 * __d0; \ | ||
39 | __r1 = __r1 * __ll_B | __ll_highpart (n0); \ | ||
40 | if (__r1 < __m) \ | ||
41 | { \ | ||
42 | __q1--, __r1 += (d); \ | ||
43 | if (__r1 >= (d)) /* i.e. we didn't get carry when adding to __r1 */\ | ||
44 | if (__r1 < __m) \ | ||
45 | __q1--, __r1 += (d); \ | ||
46 | } \ | ||
47 | __r1 -= __m; \ | ||
48 | \ | ||
49 | __r0 = __r1 % __d1; \ | ||
50 | __q0 = __r1 / __d1; \ | ||
51 | __m = (UWtype) __q0 * __d0; \ | ||
52 | __r0 = __r0 * __ll_B | __ll_lowpart (n0); \ | ||
53 | if (__r0 < __m) \ | ||
54 | { \ | ||
55 | __q0--, __r0 += (d); \ | ||
56 | if (__r0 >= (d)) \ | ||
57 | if (__r0 < __m) \ | ||
58 | __q0--, __r0 += (d); \ | ||
59 | } \ | ||
60 | __r0 -= __m; \ | ||
61 | \ | ||
62 | (q) = (UWtype) __q1 * __ll_B | __q0; \ | ||
63 | (r) = __r0; \ | ||
64 | } while (0) | ||
65 | |||
66 | #define udiv_qrnnd __udiv_qrnnd_c | ||
67 | |||
68 | #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ | ||
69 | do { \ | ||
70 | UWtype __x; \ | ||
71 | __x = (al) - (bl); \ | ||
72 | (sh) = (ah) - (bh) - (__x > (al)); \ | ||
73 | (sl) = __x; \ | ||
74 | } while (0) | ||
75 | |||
76 | #define umul_ppmm(w1, w0, u, v) \ | ||
77 | do { \ | ||
78 | UWtype __x0, __x1, __x2, __x3; \ | ||
79 | UHWtype __ul, __vl, __uh, __vh; \ | ||
80 | \ | ||
81 | __ul = __ll_lowpart (u); \ | ||
82 | __uh = __ll_highpart (u); \ | ||
83 | __vl = __ll_lowpart (v); \ | ||
84 | __vh = __ll_highpart (v); \ | ||
85 | \ | ||
86 | __x0 = (UWtype) __ul * __vl; \ | ||
87 | __x1 = (UWtype) __ul * __vh; \ | ||
88 | __x2 = (UWtype) __uh * __vl; \ | ||
89 | __x3 = (UWtype) __uh * __vh; \ | ||
90 | \ | ||
91 | __x1 += __ll_highpart (__x0);/* this can't give carry */ \ | ||
92 | __x1 += __x2; /* but this indeed can */ \ | ||
93 | if (__x1 < __x2) /* did we get it? */ \ | ||
94 | __x3 += __ll_B; /* yes, add it in the proper pos. */ \ | ||
95 | \ | ||
96 | (w1) = __x3 + __ll_highpart (__x1); \ | ||
97 | (w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0); \ | ||
98 | } while (0) | ||
diff --git a/arch/avr32/mach-at32ap/Makefile b/arch/avr32/mach-at32ap/Makefile index f62eb6915510..b21bea9af8b1 100644 --- a/arch/avr32/mach-at32ap/Makefile +++ b/arch/avr32/mach-at32ap/Makefile | |||
@@ -1,2 +1,2 @@ | |||
1 | obj-y += at32ap.o clock.o pio.o intc.o extint.o hsmc.o | 1 | obj-y += at32ap.o clock.o intc.o extint.o pio.o hsmc.o |
2 | obj-$(CONFIG_CPU_AT32AP7000) += at32ap7000.o | 2 | obj-$(CONFIG_CPU_AT32AP7000) += at32ap7000.o |
diff --git a/arch/avr32/mach-at32ap/at32ap7000.c b/arch/avr32/mach-at32ap/at32ap7000.c index 48f4ef38c70e..c1e477ec7576 100644 --- a/arch/avr32/mach-at32ap/at32ap7000.c +++ b/arch/avr32/mach-at32ap/at32ap7000.c | |||
@@ -496,9 +496,16 @@ static struct resource pio3_resource[] = { | |||
496 | DEFINE_DEV(pio, 3); | 496 | DEFINE_DEV(pio, 3); |
497 | DEV_CLK(mck, pio3, pba, 13); | 497 | DEV_CLK(mck, pio3, pba, 13); |
498 | 498 | ||
499 | static struct resource pio4_resource[] = { | ||
500 | PBMEM(0xffe03800), | ||
501 | IRQ(17), | ||
502 | }; | ||
503 | DEFINE_DEV(pio, 4); | ||
504 | DEV_CLK(mck, pio4, pba, 14); | ||
505 | |||
499 | void __init at32_add_system_devices(void) | 506 | void __init at32_add_system_devices(void) |
500 | { | 507 | { |
501 | system_manager.eim_first_irq = NR_INTERNAL_IRQS; | 508 | system_manager.eim_first_irq = EIM_IRQ_BASE; |
502 | 509 | ||
503 | platform_device_register(&at32_sm_device); | 510 | platform_device_register(&at32_sm_device); |
504 | platform_device_register(&at32_intc0_device); | 511 | platform_device_register(&at32_intc0_device); |
@@ -509,6 +516,7 @@ void __init at32_add_system_devices(void) | |||
509 | platform_device_register(&pio1_device); | 516 | platform_device_register(&pio1_device); |
510 | platform_device_register(&pio2_device); | 517 | platform_device_register(&pio2_device); |
511 | platform_device_register(&pio3_device); | 518 | platform_device_register(&pio3_device); |
519 | platform_device_register(&pio4_device); | ||
512 | } | 520 | } |
513 | 521 | ||
514 | /* -------------------------------------------------------------------- | 522 | /* -------------------------------------------------------------------- |
@@ -521,7 +529,7 @@ static struct atmel_uart_data atmel_usart0_data = { | |||
521 | }; | 529 | }; |
522 | static struct resource atmel_usart0_resource[] = { | 530 | static struct resource atmel_usart0_resource[] = { |
523 | PBMEM(0xffe00c00), | 531 | PBMEM(0xffe00c00), |
524 | IRQ(7), | 532 | IRQ(6), |
525 | }; | 533 | }; |
526 | DEFINE_DEV_DATA(atmel_usart, 0); | 534 | DEFINE_DEV_DATA(atmel_usart, 0); |
527 | DEV_CLK(usart, atmel_usart0, pba, 4); | 535 | DEV_CLK(usart, atmel_usart0, pba, 4); |
@@ -583,7 +591,7 @@ static inline void configure_usart3_pins(void) | |||
583 | select_peripheral(PB(17), PERIPH_B, 0); /* TXD */ | 591 | select_peripheral(PB(17), PERIPH_B, 0); /* TXD */ |
584 | } | 592 | } |
585 | 593 | ||
586 | static struct platform_device *at32_usarts[4]; | 594 | static struct platform_device *__initdata at32_usarts[4]; |
587 | 595 | ||
588 | void __init at32_map_usart(unsigned int hw_id, unsigned int line) | 596 | void __init at32_map_usart(unsigned int hw_id, unsigned int line) |
589 | { | 597 | { |
@@ -728,12 +736,19 @@ at32_add_device_eth(unsigned int id, struct eth_platform_data *data) | |||
728 | /* -------------------------------------------------------------------- | 736 | /* -------------------------------------------------------------------- |
729 | * SPI | 737 | * SPI |
730 | * -------------------------------------------------------------------- */ | 738 | * -------------------------------------------------------------------- */ |
731 | static struct resource spi0_resource[] = { | 739 | static struct resource atmel_spi0_resource[] = { |
732 | PBMEM(0xffe00000), | 740 | PBMEM(0xffe00000), |
733 | IRQ(3), | 741 | IRQ(3), |
734 | }; | 742 | }; |
735 | DEFINE_DEV(spi, 0); | 743 | DEFINE_DEV(atmel_spi, 0); |
736 | DEV_CLK(mck, spi0, pba, 0); | 744 | DEV_CLK(spi_clk, atmel_spi0, pba, 0); |
745 | |||
746 | static struct resource atmel_spi1_resource[] = { | ||
747 | PBMEM(0xffe00400), | ||
748 | IRQ(4), | ||
749 | }; | ||
750 | DEFINE_DEV(atmel_spi, 1); | ||
751 | DEV_CLK(spi_clk, atmel_spi1, pba, 1); | ||
737 | 752 | ||
738 | struct platform_device *__init at32_add_device_spi(unsigned int id) | 753 | struct platform_device *__init at32_add_device_spi(unsigned int id) |
739 | { | 754 | { |
@@ -741,13 +756,33 @@ struct platform_device *__init at32_add_device_spi(unsigned int id) | |||
741 | 756 | ||
742 | switch (id) { | 757 | switch (id) { |
743 | case 0: | 758 | case 0: |
744 | pdev = &spi0_device; | 759 | pdev = &atmel_spi0_device; |
745 | select_peripheral(PA(0), PERIPH_A, 0); /* MISO */ | 760 | select_peripheral(PA(0), PERIPH_A, 0); /* MISO */ |
746 | select_peripheral(PA(1), PERIPH_A, 0); /* MOSI */ | 761 | select_peripheral(PA(1), PERIPH_A, 0); /* MOSI */ |
747 | select_peripheral(PA(2), PERIPH_A, 0); /* SCK */ | 762 | select_peripheral(PA(2), PERIPH_A, 0); /* SCK */ |
748 | select_peripheral(PA(3), PERIPH_A, 0); /* NPCS0 */ | 763 | |
749 | select_peripheral(PA(4), PERIPH_A, 0); /* NPCS1 */ | 764 | /* NPCS[2:0] */ |
750 | select_peripheral(PA(5), PERIPH_A, 0); /* NPCS2 */ | 765 | at32_select_gpio(GPIO_PIN_PA(3), |
766 | AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH); | ||
767 | at32_select_gpio(GPIO_PIN_PA(4), | ||
768 | AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH); | ||
769 | at32_select_gpio(GPIO_PIN_PA(5), | ||
770 | AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH); | ||
771 | break; | ||
772 | |||
773 | case 1: | ||
774 | pdev = &atmel_spi1_device; | ||
775 | select_peripheral(PB(0), PERIPH_B, 0); /* MISO */ | ||
776 | select_peripheral(PB(1), PERIPH_B, 0); /* MOSI */ | ||
777 | select_peripheral(PB(5), PERIPH_B, 0); /* SCK */ | ||
778 | |||
779 | /* NPCS[2:0] */ | ||
780 | at32_select_gpio(GPIO_PIN_PB(2), | ||
781 | AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH); | ||
782 | at32_select_gpio(GPIO_PIN_PB(3), | ||
783 | AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH); | ||
784 | at32_select_gpio(GPIO_PIN_PB(4), | ||
785 | AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH); | ||
751 | break; | 786 | break; |
752 | 787 | ||
753 | default: | 788 | default: |
@@ -860,6 +895,7 @@ struct clk *at32_clock_list[] = { | |||
860 | &pio1_mck, | 895 | &pio1_mck, |
861 | &pio2_mck, | 896 | &pio2_mck, |
862 | &pio3_mck, | 897 | &pio3_mck, |
898 | &pio4_mck, | ||
863 | &atmel_usart0_usart, | 899 | &atmel_usart0_usart, |
864 | &atmel_usart1_usart, | 900 | &atmel_usart1_usart, |
865 | &atmel_usart2_usart, | 901 | &atmel_usart2_usart, |
@@ -868,7 +904,8 @@ struct clk *at32_clock_list[] = { | |||
868 | &macb0_pclk, | 904 | &macb0_pclk, |
869 | &macb1_hclk, | 905 | &macb1_hclk, |
870 | &macb1_pclk, | 906 | &macb1_pclk, |
871 | &spi0_mck, | 907 | &atmel_spi0_spi_clk, |
908 | &atmel_spi1_spi_clk, | ||
872 | &lcdc0_hclk, | 909 | &lcdc0_hclk, |
873 | &lcdc0_pixclk, | 910 | &lcdc0_pixclk, |
874 | }; | 911 | }; |
@@ -880,6 +917,7 @@ void __init at32_portmux_init(void) | |||
880 | at32_init_pio(&pio1_device); | 917 | at32_init_pio(&pio1_device); |
881 | at32_init_pio(&pio2_device); | 918 | at32_init_pio(&pio2_device); |
882 | at32_init_pio(&pio3_device); | 919 | at32_init_pio(&pio3_device); |
920 | at32_init_pio(&pio4_device); | ||
883 | } | 921 | } |
884 | 922 | ||
885 | void __init at32_clock_init(void) | 923 | void __init at32_clock_init(void) |
diff --git a/arch/avr32/mach-at32ap/extint.c b/arch/avr32/mach-at32ap/extint.c index b59272e81b9a..4a60eccfebd2 100644 --- a/arch/avr32/mach-at32ap/extint.c +++ b/arch/avr32/mach-at32ap/extint.c | |||
@@ -55,20 +55,11 @@ static int eim_set_irq_type(unsigned int irq, unsigned int flow_type) | |||
55 | unsigned long flags; | 55 | unsigned long flags; |
56 | int ret = 0; | 56 | int ret = 0; |
57 | 57 | ||
58 | flow_type &= IRQ_TYPE_SENSE_MASK; | ||
58 | if (flow_type == IRQ_TYPE_NONE) | 59 | if (flow_type == IRQ_TYPE_NONE) |
59 | flow_type = IRQ_TYPE_LEVEL_LOW; | 60 | flow_type = IRQ_TYPE_LEVEL_LOW; |
60 | 61 | ||
61 | desc = &irq_desc[irq]; | 62 | desc = &irq_desc[irq]; |
62 | desc->status &= ~(IRQ_TYPE_SENSE_MASK | IRQ_LEVEL); | ||
63 | desc->status |= flow_type & IRQ_TYPE_SENSE_MASK; | ||
64 | |||
65 | if (flow_type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH)) { | ||
66 | desc->status |= IRQ_LEVEL; | ||
67 | set_irq_handler(irq, handle_level_irq); | ||
68 | } else { | ||
69 | set_irq_handler(irq, handle_edge_irq); | ||
70 | } | ||
71 | |||
72 | spin_lock_irqsave(&sm->lock, flags); | 63 | spin_lock_irqsave(&sm->lock, flags); |
73 | 64 | ||
74 | mode = sm_readl(sm, EIM_MODE); | 65 | mode = sm_readl(sm, EIM_MODE); |
@@ -97,9 +88,16 @@ static int eim_set_irq_type(unsigned int irq, unsigned int flow_type) | |||
97 | break; | 88 | break; |
98 | } | 89 | } |
99 | 90 | ||
100 | sm_writel(sm, EIM_MODE, mode); | 91 | if (ret == 0) { |
101 | sm_writel(sm, EIM_EDGE, edge); | 92 | sm_writel(sm, EIM_MODE, mode); |
102 | sm_writel(sm, EIM_LEVEL, level); | 93 | sm_writel(sm, EIM_EDGE, edge); |
94 | sm_writel(sm, EIM_LEVEL, level); | ||
95 | |||
96 | if (flow_type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH)) | ||
97 | flow_type |= IRQ_LEVEL; | ||
98 | desc->status &= ~(IRQ_TYPE_SENSE_MASK | IRQ_LEVEL); | ||
99 | desc->status |= flow_type; | ||
100 | } | ||
103 | 101 | ||
104 | spin_unlock_irqrestore(&sm->lock, flags); | 102 | spin_unlock_irqrestore(&sm->lock, flags); |
105 | 103 | ||
@@ -122,8 +120,6 @@ static void demux_eim_irq(unsigned int irq, struct irq_desc *desc) | |||
122 | unsigned long status, pending; | 120 | unsigned long status, pending; |
123 | unsigned int i, ext_irq; | 121 | unsigned int i, ext_irq; |
124 | 122 | ||
125 | spin_lock(&sm->lock); | ||
126 | |||
127 | status = sm_readl(sm, EIM_ISR); | 123 | status = sm_readl(sm, EIM_ISR); |
128 | pending = status & sm_readl(sm, EIM_IMR); | 124 | pending = status & sm_readl(sm, EIM_IMR); |
129 | 125 | ||
@@ -133,10 +129,11 @@ static void demux_eim_irq(unsigned int irq, struct irq_desc *desc) | |||
133 | 129 | ||
134 | ext_irq = i + sm->eim_first_irq; | 130 | ext_irq = i + sm->eim_first_irq; |
135 | ext_desc = irq_desc + ext_irq; | 131 | ext_desc = irq_desc + ext_irq; |
136 | ext_desc->handle_irq(ext_irq, ext_desc); | 132 | if (ext_desc->status & IRQ_LEVEL) |
133 | handle_level_irq(ext_irq, ext_desc); | ||
134 | else | ||
135 | handle_edge_irq(ext_irq, ext_desc); | ||
137 | } | 136 | } |
138 | |||
139 | spin_unlock(&sm->lock); | ||
140 | } | 137 | } |
141 | 138 | ||
142 | static int __init eim_init(void) | 139 | static int __init eim_init(void) |
@@ -168,8 +165,9 @@ static int __init eim_init(void) | |||
168 | sm->eim_chip = &eim_chip; | 165 | sm->eim_chip = &eim_chip; |
169 | 166 | ||
170 | for (i = 0; i < nr_irqs; i++) { | 167 | for (i = 0; i < nr_irqs; i++) { |
168 | /* NOTE the handler we set here is ignored by the demux */ | ||
171 | set_irq_chip_and_handler(sm->eim_first_irq + i, &eim_chip, | 169 | set_irq_chip_and_handler(sm->eim_first_irq + i, &eim_chip, |
172 | handle_edge_irq); | 170 | handle_level_irq); |
173 | set_irq_chip_data(sm->eim_first_irq + i, sm); | 171 | set_irq_chip_data(sm->eim_first_irq + i, sm); |
174 | } | 172 | } |
175 | 173 | ||
diff --git a/arch/avr32/mach-at32ap/pio.c b/arch/avr32/mach-at32ap/pio.c index f1280ed8ed6d..9ba5654cde11 100644 --- a/arch/avr32/mach-at32ap/pio.c +++ b/arch/avr32/mach-at32ap/pio.c | |||
@@ -12,7 +12,9 @@ | |||
12 | #include <linux/debugfs.h> | 12 | #include <linux/debugfs.h> |
13 | #include <linux/fs.h> | 13 | #include <linux/fs.h> |
14 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
15 | #include <linux/irq.h> | ||
15 | 16 | ||
17 | #include <asm/gpio.h> | ||
16 | #include <asm/io.h> | 18 | #include <asm/io.h> |
17 | 19 | ||
18 | #include <asm/arch/portmux.h> | 20 | #include <asm/arch/portmux.h> |
@@ -26,7 +28,8 @@ struct pio_device { | |||
26 | const struct platform_device *pdev; | 28 | const struct platform_device *pdev; |
27 | struct clk *clk; | 29 | struct clk *clk; |
28 | u32 pinmux_mask; | 30 | u32 pinmux_mask; |
29 | char name[32]; | 31 | u32 gpio_mask; |
32 | char name[8]; | ||
30 | }; | 33 | }; |
31 | 34 | ||
32 | static struct pio_device pio_dev[MAX_NR_PIO_DEVICES]; | 35 | static struct pio_device pio_dev[MAX_NR_PIO_DEVICES]; |
@@ -76,6 +79,9 @@ void __init at32_select_periph(unsigned int pin, unsigned int periph, | |||
76 | if (!(flags & AT32_GPIOF_PULLUP)) | 79 | if (!(flags & AT32_GPIOF_PULLUP)) |
77 | pio_writel(pio, PUDR, mask); | 80 | pio_writel(pio, PUDR, mask); |
78 | 81 | ||
82 | /* gpio_request NOT allowed */ | ||
83 | set_bit(pin_index, &pio->gpio_mask); | ||
84 | |||
79 | return; | 85 | return; |
80 | 86 | ||
81 | fail: | 87 | fail: |
@@ -99,19 +105,52 @@ void __init at32_select_gpio(unsigned int pin, unsigned long flags) | |||
99 | goto fail; | 105 | goto fail; |
100 | } | 106 | } |
101 | 107 | ||
102 | pio_writel(pio, PUER, mask); | 108 | if (flags & AT32_GPIOF_OUTPUT) { |
103 | if (flags & AT32_GPIOF_HIGH) | 109 | if (flags & AT32_GPIOF_HIGH) |
104 | pio_writel(pio, SODR, mask); | 110 | pio_writel(pio, SODR, mask); |
105 | else | 111 | else |
106 | pio_writel(pio, CODR, mask); | 112 | pio_writel(pio, CODR, mask); |
107 | if (flags & AT32_GPIOF_OUTPUT) | 113 | pio_writel(pio, PUDR, mask); |
108 | pio_writel(pio, OER, mask); | 114 | pio_writel(pio, OER, mask); |
109 | else | 115 | } else { |
116 | if (flags & AT32_GPIOF_PULLUP) | ||
117 | pio_writel(pio, PUER, mask); | ||
118 | else | ||
119 | pio_writel(pio, PUDR, mask); | ||
120 | if (flags & AT32_GPIOF_DEGLITCH) | ||
121 | pio_writel(pio, IFER, mask); | ||
122 | else | ||
123 | pio_writel(pio, IFDR, mask); | ||
110 | pio_writel(pio, ODR, mask); | 124 | pio_writel(pio, ODR, mask); |
125 | } | ||
111 | 126 | ||
112 | pio_writel(pio, PER, mask); | 127 | pio_writel(pio, PER, mask); |
113 | if (!(flags & AT32_GPIOF_PULLUP)) | 128 | |
114 | pio_writel(pio, PUDR, mask); | 129 | /* gpio_request now allowed */ |
130 | clear_bit(pin_index, &pio->gpio_mask); | ||
131 | |||
132 | return; | ||
133 | |||
134 | fail: | ||
135 | dump_stack(); | ||
136 | } | ||
137 | |||
138 | /* Reserve a pin, preventing anyone else from changing its configuration. */ | ||
139 | void __init at32_reserve_pin(unsigned int pin) | ||
140 | { | ||
141 | struct pio_device *pio; | ||
142 | unsigned int pin_index = pin & 0x1f; | ||
143 | |||
144 | pio = gpio_to_pio(pin); | ||
145 | if (unlikely(!pio)) { | ||
146 | printk("pio: invalid pin %u\n", pin); | ||
147 | goto fail; | ||
148 | } | ||
149 | |||
150 | if (unlikely(test_and_set_bit(pin_index, &pio->pinmux_mask))) { | ||
151 | printk("%s: pin %u is busy\n", pio->name, pin_index); | ||
152 | goto fail; | ||
153 | } | ||
115 | 154 | ||
116 | return; | 155 | return; |
117 | 156 | ||
@@ -119,20 +158,197 @@ fail: | |||
119 | dump_stack(); | 158 | dump_stack(); |
120 | } | 159 | } |
121 | 160 | ||
161 | /*--------------------------------------------------------------------------*/ | ||
162 | |||
163 | /* GPIO API */ | ||
164 | |||
165 | int gpio_request(unsigned int gpio, const char *label) | ||
166 | { | ||
167 | struct pio_device *pio; | ||
168 | unsigned int pin; | ||
169 | |||
170 | pio = gpio_to_pio(gpio); | ||
171 | if (!pio) | ||
172 | return -ENODEV; | ||
173 | |||
174 | pin = gpio & 0x1f; | ||
175 | if (test_and_set_bit(pin, &pio->gpio_mask)) | ||
176 | return -EBUSY; | ||
177 | |||
178 | return 0; | ||
179 | } | ||
180 | EXPORT_SYMBOL(gpio_request); | ||
181 | |||
182 | void gpio_free(unsigned int gpio) | ||
183 | { | ||
184 | struct pio_device *pio; | ||
185 | unsigned int pin; | ||
186 | |||
187 | pio = gpio_to_pio(gpio); | ||
188 | if (!pio) { | ||
189 | printk(KERN_ERR | ||
190 | "gpio: attempted to free invalid pin %u\n", gpio); | ||
191 | return; | ||
192 | } | ||
193 | |||
194 | pin = gpio & 0x1f; | ||
195 | if (!test_and_clear_bit(pin, &pio->gpio_mask)) | ||
196 | printk(KERN_ERR "gpio: freeing free or non-gpio pin %s-%u\n", | ||
197 | pio->name, pin); | ||
198 | } | ||
199 | EXPORT_SYMBOL(gpio_free); | ||
200 | |||
201 | int gpio_direction_input(unsigned int gpio) | ||
202 | { | ||
203 | struct pio_device *pio; | ||
204 | unsigned int pin; | ||
205 | |||
206 | pio = gpio_to_pio(gpio); | ||
207 | if (!pio) | ||
208 | return -ENODEV; | ||
209 | |||
210 | pin = gpio & 0x1f; | ||
211 | pio_writel(pio, ODR, 1 << pin); | ||
212 | |||
213 | return 0; | ||
214 | } | ||
215 | EXPORT_SYMBOL(gpio_direction_input); | ||
216 | |||
217 | int gpio_direction_output(unsigned int gpio) | ||
218 | { | ||
219 | struct pio_device *pio; | ||
220 | unsigned int pin; | ||
221 | |||
222 | pio = gpio_to_pio(gpio); | ||
223 | if (!pio) | ||
224 | return -ENODEV; | ||
225 | |||
226 | pin = gpio & 0x1f; | ||
227 | pio_writel(pio, OER, 1 << pin); | ||
228 | |||
229 | return 0; | ||
230 | } | ||
231 | EXPORT_SYMBOL(gpio_direction_output); | ||
232 | |||
233 | int gpio_get_value(unsigned int gpio) | ||
234 | { | ||
235 | struct pio_device *pio = &pio_dev[gpio >> 5]; | ||
236 | |||
237 | return (pio_readl(pio, PDSR) >> (gpio & 0x1f)) & 1; | ||
238 | } | ||
239 | EXPORT_SYMBOL(gpio_get_value); | ||
240 | |||
241 | void gpio_set_value(unsigned int gpio, int value) | ||
242 | { | ||
243 | struct pio_device *pio = &pio_dev[gpio >> 5]; | ||
244 | u32 mask; | ||
245 | |||
246 | mask = 1 << (gpio & 0x1f); | ||
247 | if (value) | ||
248 | pio_writel(pio, SODR, mask); | ||
249 | else | ||
250 | pio_writel(pio, CODR, mask); | ||
251 | } | ||
252 | EXPORT_SYMBOL(gpio_set_value); | ||
253 | |||
254 | /*--------------------------------------------------------------------------*/ | ||
255 | |||
256 | /* GPIO IRQ support */ | ||
257 | |||
258 | static void gpio_irq_mask(unsigned irq) | ||
259 | { | ||
260 | unsigned gpio = irq_to_gpio(irq); | ||
261 | struct pio_device *pio = &pio_dev[gpio >> 5]; | ||
262 | |||
263 | pio_writel(pio, IDR, 1 << (gpio & 0x1f)); | ||
264 | } | ||
265 | |||
266 | static void gpio_irq_unmask(unsigned irq) | ||
267 | { | ||
268 | unsigned gpio = irq_to_gpio(irq); | ||
269 | struct pio_device *pio = &pio_dev[gpio >> 5]; | ||
270 | |||
271 | pio_writel(pio, IER, 1 << (gpio & 0x1f)); | ||
272 | } | ||
273 | |||
274 | static int gpio_irq_type(unsigned irq, unsigned type) | ||
275 | { | ||
276 | if (type != IRQ_TYPE_EDGE_BOTH && type != IRQ_TYPE_NONE) | ||
277 | return -EINVAL; | ||
278 | |||
279 | return 0; | ||
280 | } | ||
281 | |||
282 | static struct irq_chip gpio_irqchip = { | ||
283 | .name = "gpio", | ||
284 | .mask = gpio_irq_mask, | ||
285 | .unmask = gpio_irq_unmask, | ||
286 | .set_type = gpio_irq_type, | ||
287 | }; | ||
288 | |||
289 | static void gpio_irq_handler(unsigned irq, struct irq_desc *desc) | ||
290 | { | ||
291 | struct pio_device *pio = get_irq_chip_data(irq); | ||
292 | unsigned gpio_irq; | ||
293 | |||
294 | gpio_irq = (unsigned) get_irq_data(irq); | ||
295 | for (;;) { | ||
296 | u32 isr; | ||
297 | struct irq_desc *d; | ||
298 | |||
299 | /* ack pending GPIO interrupts */ | ||
300 | isr = pio_readl(pio, ISR) & pio_readl(pio, IMR); | ||
301 | if (!isr) | ||
302 | break; | ||
303 | do { | ||
304 | int i; | ||
305 | |||
306 | i = ffs(isr) - 1; | ||
307 | isr &= ~(1 << i); | ||
308 | |||
309 | i += gpio_irq; | ||
310 | d = &irq_desc[i]; | ||
311 | |||
312 | d->handle_irq(i, d); | ||
313 | } while (isr); | ||
314 | } | ||
315 | } | ||
316 | |||
317 | static void __init | ||
318 | gpio_irq_setup(struct pio_device *pio, int irq, int gpio_irq) | ||
319 | { | ||
320 | unsigned i; | ||
321 | |||
322 | set_irq_chip_data(irq, pio); | ||
323 | set_irq_data(irq, (void *) gpio_irq); | ||
324 | |||
325 | for (i = 0; i < 32; i++, gpio_irq++) { | ||
326 | set_irq_chip_data(gpio_irq, pio); | ||
327 | set_irq_chip_and_handler(gpio_irq, &gpio_irqchip, | ||
328 | handle_simple_irq); | ||
329 | } | ||
330 | |||
331 | set_irq_chained_handler(irq, gpio_irq_handler); | ||
332 | } | ||
333 | |||
334 | /*--------------------------------------------------------------------------*/ | ||
335 | |||
122 | static int __init pio_probe(struct platform_device *pdev) | 336 | static int __init pio_probe(struct platform_device *pdev) |
123 | { | 337 | { |
124 | struct pio_device *pio = NULL; | 338 | struct pio_device *pio = NULL; |
339 | int irq = platform_get_irq(pdev, 0); | ||
340 | int gpio_irq_base = GPIO_IRQ_BASE + pdev->id * 32; | ||
125 | 341 | ||
126 | BUG_ON(pdev->id >= MAX_NR_PIO_DEVICES); | 342 | BUG_ON(pdev->id >= MAX_NR_PIO_DEVICES); |
127 | pio = &pio_dev[pdev->id]; | 343 | pio = &pio_dev[pdev->id]; |
128 | BUG_ON(!pio->regs); | 344 | BUG_ON(!pio->regs); |
129 | 345 | ||
130 | /* TODO: Interrupts */ | 346 | gpio_irq_setup(pio, irq, gpio_irq_base); |
131 | 347 | ||
132 | platform_set_drvdata(pdev, pio); | 348 | platform_set_drvdata(pdev, pio); |
133 | 349 | ||
134 | printk(KERN_INFO "%s: Atmel Port Multiplexer at 0x%p (irq %d)\n", | 350 | printk(KERN_DEBUG "%s: base 0x%p, irq %d chains %d..%d\n", |
135 | pio->name, pio->regs, platform_get_irq(pdev, 0)); | 351 | pio->name, pio->regs, irq, gpio_irq_base, gpio_irq_base + 31); |
136 | 352 | ||
137 | return 0; | 353 | return 0; |
138 | } | 354 | } |
@@ -148,7 +364,7 @@ static int __init pio_init(void) | |||
148 | { | 364 | { |
149 | return platform_driver_register(&pio_driver); | 365 | return platform_driver_register(&pio_driver); |
150 | } | 366 | } |
151 | subsys_initcall(pio_init); | 367 | postcore_initcall(pio_init); |
152 | 368 | ||
153 | void __init at32_init_pio(struct platform_device *pdev) | 369 | void __init at32_init_pio(struct platform_device *pdev) |
154 | { | 370 | { |
@@ -184,6 +400,13 @@ void __init at32_init_pio(struct platform_device *pdev) | |||
184 | pio->pdev = pdev; | 400 | pio->pdev = pdev; |
185 | pio->regs = ioremap(regs->start, regs->end - regs->start + 1); | 401 | pio->regs = ioremap(regs->start, regs->end - regs->start + 1); |
186 | 402 | ||
187 | pio_writel(pio, ODR, ~0UL); | 403 | /* |
188 | pio_writel(pio, PER, ~0UL); | 404 | * request_gpio() is only valid for pins that have been |
405 | * explicitly configured as GPIO and not previously requested | ||
406 | */ | ||
407 | pio->gpio_mask = ~0UL; | ||
408 | |||
409 | /* start with irqs disabled and acked */ | ||
410 | pio_writel(pio, IDR, ~0UL); | ||
411 | (void) pio_readl(pio, ISR); | ||
189 | } | 412 | } |
diff --git a/arch/avr32/mm/cache.c b/arch/avr32/mm/cache.c index 450515b245a0..fb13f72e9a02 100644 --- a/arch/avr32/mm/cache.c +++ b/arch/avr32/mm/cache.c | |||
@@ -22,18 +22,34 @@ | |||
22 | 22 | ||
23 | void invalidate_dcache_region(void *start, size_t size) | 23 | void invalidate_dcache_region(void *start, size_t size) |
24 | { | 24 | { |
25 | unsigned long v, begin, end, linesz; | 25 | unsigned long v, begin, end, linesz, mask; |
26 | int flush = 0; | ||
26 | 27 | ||
27 | linesz = boot_cpu_data.dcache.linesz; | 28 | linesz = boot_cpu_data.dcache.linesz; |
29 | mask = linesz - 1; | ||
30 | |||
31 | /* when first and/or last cachelines are shared, flush them | ||
32 | * instead of invalidating ... never discard valid data! | ||
33 | */ | ||
34 | begin = (unsigned long)start; | ||
35 | end = begin + size - 1; | ||
36 | |||
37 | if (begin & mask) { | ||
38 | flush_dcache_line(start); | ||
39 | begin += linesz; | ||
40 | flush = 1; | ||
41 | } | ||
42 | if ((end & mask) != mask) { | ||
43 | flush_dcache_line((void *)end); | ||
44 | end -= linesz; | ||
45 | flush = 1; | ||
46 | } | ||
28 | 47 | ||
29 | //printk("invalidate dcache: %p + %u\n", start, size); | 48 | /* remaining cachelines only need invalidation */ |
30 | 49 | for (v = begin; v <= end; v += linesz) | |
31 | /* You asked for it, you got it */ | ||
32 | begin = (unsigned long)start & ~(linesz - 1); | ||
33 | end = ((unsigned long)start + size + linesz - 1) & ~(linesz - 1); | ||
34 | |||
35 | for (v = begin; v < end; v += linesz) | ||
36 | invalidate_dcache_line((void *)v); | 50 | invalidate_dcache_line((void *)v); |
51 | if (flush) | ||
52 | flush_write_buffer(); | ||
37 | } | 53 | } |
38 | 54 | ||
39 | void clean_dcache_region(void *start, size_t size) | 55 | void clean_dcache_region(void *start, size_t size) |