aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-16 11:19:44 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-16 11:19:44 -0500
commit8a03d9a498eaf02c8a118752050a5154852c13bf (patch)
tree8e8fd8ce48892e667092aea6532548a4f79f9c25
parentf8abea8f8c24ecdad6d6861bffb912f23f2741cd (diff)
parent41d8ca452f523b9245704c7dd8ef290fa7b78e6b (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] Use per-controller spi_board_info structures [AVR32] Warn, don't BUG if clk_disable is called too many times [AVR32] Make sure all genclocks have a parent [AVR32] Remove unnecessary sys_nfsservctl conditional [AVR32] Wire up the SysV IPC calls properly [AVR32] Define ioremap_nocache, ioport_map and ioport_unmap [AVR32] Fix prototypes for __raw_writesb and friends
-rw-r--r--arch/avr32/boards/atstk1000/atstk1002.c9
-rw-r--r--arch/avr32/kernel/syscall_table.S22
-rw-r--r--arch/avr32/mach-at32ap/at32ap7000.c144
-rw-r--r--arch/avr32/mach-at32ap/clock.c6
-rw-r--r--include/asm-avr32/arch-at32ap/board.h4
-rw-r--r--include/asm-avr32/io.h23
-rw-r--r--include/asm-avr32/unistd.h17
7 files changed, 167 insertions, 58 deletions
diff --git a/arch/avr32/boards/atstk1000/atstk1002.c b/arch/avr32/boards/atstk1000/atstk1002.c
index d47e39f0e971..5974768a59e5 100644
--- a/arch/avr32/boards/atstk1000/atstk1002.c
+++ b/arch/avr32/boards/atstk1000/atstk1002.c
@@ -8,7 +8,6 @@
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>
12#include <linux/etherdevice.h> 11#include <linux/etherdevice.h>
13#include <linux/init.h> 12#include <linux/init.h>
14#include <linux/kernel.h> 13#include <linux/kernel.h>
@@ -36,12 +35,11 @@ static struct eth_addr __initdata hw_addr[2];
36static struct eth_platform_data __initdata eth_data[2]; 35static struct eth_platform_data __initdata eth_data[2];
37extern struct lcdc_platform_data atstk1000_fb0_data; 36extern struct lcdc_platform_data atstk1000_fb0_data;
38 37
39static struct spi_board_info spi_board_info[] __initdata = { 38static struct spi_board_info spi0_board_info[] __initdata = {
40 { 39 {
40 /* QVGA display */
41 .modalias = "ltv350qv", 41 .modalias = "ltv350qv",
42 .controller_data = (void *)GPIO_PIN_PA(4),
43 .max_speed_hz = 16000000, 42 .max_speed_hz = 16000000,
44 .bus_num = 0,
45 .chip_select = 1, 43 .chip_select = 1,
46 }, 44 },
47}; 45};
@@ -149,8 +147,7 @@ static int __init atstk1002_init(void)
149 147
150 set_hw_addr(at32_add_device_eth(0, &eth_data[0])); 148 set_hw_addr(at32_add_device_eth(0, &eth_data[0]));
151 149
152 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info)); 150 at32_add_device_spi(0, spi0_board_info, ARRAY_SIZE(spi0_board_info));
153 at32_add_device_spi(0);
154 at32_add_device_lcdc(0, &atstk1000_fb0_data); 151 at32_add_device_lcdc(0, &atstk1000_fb0_data);
155 152
156 return 0; 153 return 0;
diff --git a/arch/avr32/kernel/syscall_table.S b/arch/avr32/kernel/syscall_table.S
index db8f8b55ffdf..7c279586fbba 100644
--- a/arch/avr32/kernel/syscall_table.S
+++ b/arch/avr32/kernel/syscall_table.S
@@ -8,14 +8,6 @@
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10 10
11#if !defined(CONFIG_NFSD) && !defined(CONFIG_NFSD_MODULE)
12#define sys_nfsservctl sys_ni_syscall
13#endif
14
15#if !defined(CONFIG_SYSV_IPC)
16# define sys_ipc sys_ni_syscall
17#endif
18
19 .section .rodata,"a",@progbits 11 .section .rodata,"a",@progbits
20 .type sys_call_table,@object 12 .type sys_call_table,@object
21 .global sys_call_table 13 .global sys_call_table
@@ -129,7 +121,7 @@ sys_call_table:
129 .long sys_getitimer /* 105 */ 121 .long sys_getitimer /* 105 */
130 .long sys_swapoff 122 .long sys_swapoff
131 .long sys_sysinfo 123 .long sys_sysinfo
132 .long sys_ipc 124 .long sys_ni_syscall /* was sys_ipc briefly */
133 .long sys_sendfile 125 .long sys_sendfile
134 .long sys_setdomainname /* 110 */ 126 .long sys_setdomainname /* 110 */
135 .long sys_newuname 127 .long sys_newuname
@@ -287,4 +279,16 @@ sys_call_table:
287 .long sys_tee 279 .long sys_tee
288 .long sys_vmsplice 280 .long sys_vmsplice
289 .long __sys_epoll_pwait /* 265 */ 281 .long __sys_epoll_pwait /* 265 */
282 .long sys_msgget
283 .long sys_msgsnd
284 .long sys_msgrcv
285 .long sys_msgctl
286 .long sys_semget /* 270 */
287 .long sys_semop
288 .long sys_semctl
289 .long sys_semtimedop
290 .long sys_shmat
291 .long sys_shmget /* 275 */
292 .long sys_shmdt
293 .long sys_shmctl
290 .long sys_ni_syscall /* r8 is saturated at nr_syscalls */ 294 .long sys_ni_syscall /* r8 is saturated at nr_syscalls */
diff --git a/arch/avr32/mach-at32ap/at32ap7000.c b/arch/avr32/mach-at32ap/at32ap7000.c
index c1e477ec7576..bc235507c5c7 100644
--- a/arch/avr32/mach-at32ap/at32ap7000.c
+++ b/arch/avr32/mach-at32ap/at32ap7000.c
@@ -8,6 +8,7 @@
8#include <linux/clk.h> 8#include <linux/clk.h>
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/platform_device.h> 10#include <linux/platform_device.h>
11#include <linux/spi/spi.h>
11 12
12#include <asm/io.h> 13#include <asm/io.h>
13 14
@@ -310,8 +311,6 @@ static void genclk_mode(struct clk *clk, int enabled)
310{ 311{
311 u32 control; 312 u32 control;
312 313
313 BUG_ON(clk->index > 7);
314
315 control = sm_readl(&system_manager, PM_GCCTRL + 4 * clk->index); 314 control = sm_readl(&system_manager, PM_GCCTRL + 4 * clk->index);
316 if (enabled) 315 if (enabled)
317 control |= SM_BIT(CEN); 316 control |= SM_BIT(CEN);
@@ -325,11 +324,6 @@ static unsigned long genclk_get_rate(struct clk *clk)
325 u32 control; 324 u32 control;
326 unsigned long div = 1; 325 unsigned long div = 1;
327 326
328 BUG_ON(clk->index > 7);
329
330 if (!clk->parent)
331 return 0;
332
333 control = sm_readl(&system_manager, PM_GCCTRL + 4 * clk->index); 327 control = sm_readl(&system_manager, PM_GCCTRL + 4 * clk->index);
334 if (control & SM_BIT(DIVEN)) 328 if (control & SM_BIT(DIVEN))
335 div = 2 * (SM_BFEXT(DIV, control) + 1); 329 div = 2 * (SM_BFEXT(DIV, control) + 1);
@@ -342,11 +336,6 @@ static long genclk_set_rate(struct clk *clk, unsigned long rate, int apply)
342 u32 control; 336 u32 control;
343 unsigned long parent_rate, actual_rate, div; 337 unsigned long parent_rate, actual_rate, div;
344 338
345 BUG_ON(clk->index > 7);
346
347 if (!clk->parent)
348 return 0;
349
350 parent_rate = clk->parent->get_rate(clk->parent); 339 parent_rate = clk->parent->get_rate(clk->parent);
351 control = sm_readl(&system_manager, PM_GCCTRL + 4 * clk->index); 340 control = sm_readl(&system_manager, PM_GCCTRL + 4 * clk->index);
352 341
@@ -373,11 +362,8 @@ int genclk_set_parent(struct clk *clk, struct clk *parent)
373{ 362{
374 u32 control; 363 u32 control;
375 364
376 BUG_ON(clk->index > 7);
377
378 printk("clk %s: new parent %s (was %s)\n", 365 printk("clk %s: new parent %s (was %s)\n",
379 clk->name, parent->name, 366 clk->name, parent->name, clk->parent->name);
380 clk->parent ? clk->parent->name : "(null)");
381 367
382 control = sm_readl(&system_manager, PM_GCCTRL + 4 * clk->index); 368 control = sm_readl(&system_manager, PM_GCCTRL + 4 * clk->index);
383 369
@@ -399,6 +385,22 @@ int genclk_set_parent(struct clk *clk, struct clk *parent)
399 return 0; 385 return 0;
400} 386}
401 387
388static void __init genclk_init_parent(struct clk *clk)
389{
390 u32 control;
391 struct clk *parent;
392
393 BUG_ON(clk->index > 7);
394
395 control = sm_readl(&system_manager, PM_GCCTRL + 4 * clk->index);
396 if (control & SM_BIT(OSCSEL))
397 parent = (control & SM_BIT(PLLSEL)) ? &pll1 : &osc1;
398 else
399 parent = (control & SM_BIT(PLLSEL)) ? &pll0 : &osc0;
400
401 clk->parent = parent;
402}
403
402/* -------------------------------------------------------------------- 404/* --------------------------------------------------------------------
403 * System peripherals 405 * System peripherals
404 * -------------------------------------------------------------------- */ 406 * -------------------------------------------------------------------- */
@@ -750,8 +752,41 @@ static struct resource atmel_spi1_resource[] = {
750DEFINE_DEV(atmel_spi, 1); 752DEFINE_DEV(atmel_spi, 1);
751DEV_CLK(spi_clk, atmel_spi1, pba, 1); 753DEV_CLK(spi_clk, atmel_spi1, pba, 1);
752 754
753struct platform_device *__init at32_add_device_spi(unsigned int id) 755static void
756at32_spi_setup_slaves(unsigned int bus_num, struct spi_board_info *b,
757 unsigned int n, const u8 *pins)
758{
759 unsigned int pin, mode;
760
761 for (; n; n--, b++) {
762 b->bus_num = bus_num;
763 if (b->chip_select >= 4)
764 continue;
765 pin = (unsigned)b->controller_data;
766 if (!pin) {
767 pin = pins[b->chip_select];
768 b->controller_data = (void *)pin;
769 }
770 mode = AT32_GPIOF_OUTPUT;
771 if (!(b->mode & SPI_CS_HIGH))
772 mode |= AT32_GPIOF_HIGH;
773 at32_select_gpio(pin, mode);
774 }
775}
776
777struct platform_device *__init
778at32_add_device_spi(unsigned int id, struct spi_board_info *b, unsigned int n)
754{ 779{
780 /*
781 * Manage the chipselects as GPIOs, normally using the same pins
782 * the SPI controller expects; but boards can use other pins.
783 */
784 static u8 __initdata spi0_pins[] =
785 { GPIO_PIN_PA(3), GPIO_PIN_PA(4),
786 GPIO_PIN_PA(5), GPIO_PIN_PA(20), };
787 static u8 __initdata spi1_pins[] =
788 { GPIO_PIN_PB(2), GPIO_PIN_PB(3),
789 GPIO_PIN_PB(4), GPIO_PIN_PA(27), };
755 struct platform_device *pdev; 790 struct platform_device *pdev;
756 791
757 switch (id) { 792 switch (id) {
@@ -760,14 +795,7 @@ struct platform_device *__init at32_add_device_spi(unsigned int id)
760 select_peripheral(PA(0), PERIPH_A, 0); /* MISO */ 795 select_peripheral(PA(0), PERIPH_A, 0); /* MISO */
761 select_peripheral(PA(1), PERIPH_A, 0); /* MOSI */ 796 select_peripheral(PA(1), PERIPH_A, 0); /* MOSI */
762 select_peripheral(PA(2), PERIPH_A, 0); /* SCK */ 797 select_peripheral(PA(2), PERIPH_A, 0); /* SCK */
763 798 at32_spi_setup_slaves(0, b, n, spi0_pins);
764 /* NPCS[2:0] */
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; 799 break;
772 800
773 case 1: 801 case 1:
@@ -775,20 +803,14 @@ struct platform_device *__init at32_add_device_spi(unsigned int id)
775 select_peripheral(PB(0), PERIPH_B, 0); /* MISO */ 803 select_peripheral(PB(0), PERIPH_B, 0); /* MISO */
776 select_peripheral(PB(1), PERIPH_B, 0); /* MOSI */ 804 select_peripheral(PB(1), PERIPH_B, 0); /* MOSI */
777 select_peripheral(PB(5), PERIPH_B, 0); /* SCK */ 805 select_peripheral(PB(5), PERIPH_B, 0); /* SCK */
778 806 at32_spi_setup_slaves(1, b, n, spi1_pins);
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);
786 break; 807 break;
787 808
788 default: 809 default:
789 return NULL; 810 return NULL;
790 } 811 }
791 812
813 spi_register_board_info(b, n);
792 platform_device_register(pdev); 814 platform_device_register(pdev);
793 return pdev; 815 return pdev;
794} 816}
@@ -872,6 +894,50 @@ at32_add_device_lcdc(unsigned int id, struct lcdc_platform_data *data)
872 return pdev; 894 return pdev;
873} 895}
874 896
897/* --------------------------------------------------------------------
898 * GCLK
899 * -------------------------------------------------------------------- */
900static struct clk gclk0 = {
901 .name = "gclk0",
902 .mode = genclk_mode,
903 .get_rate = genclk_get_rate,
904 .set_rate = genclk_set_rate,
905 .set_parent = genclk_set_parent,
906 .index = 0,
907};
908static struct clk gclk1 = {
909 .name = "gclk1",
910 .mode = genclk_mode,
911 .get_rate = genclk_get_rate,
912 .set_rate = genclk_set_rate,
913 .set_parent = genclk_set_parent,
914 .index = 1,
915};
916static struct clk gclk2 = {
917 .name = "gclk2",
918 .mode = genclk_mode,
919 .get_rate = genclk_get_rate,
920 .set_rate = genclk_set_rate,
921 .set_parent = genclk_set_parent,
922 .index = 2,
923};
924static struct clk gclk3 = {
925 .name = "gclk3",
926 .mode = genclk_mode,
927 .get_rate = genclk_get_rate,
928 .set_rate = genclk_set_rate,
929 .set_parent = genclk_set_parent,
930 .index = 3,
931};
932static struct clk gclk4 = {
933 .name = "gclk4",
934 .mode = genclk_mode,
935 .get_rate = genclk_get_rate,
936 .set_rate = genclk_set_rate,
937 .set_parent = genclk_set_parent,
938 .index = 4,
939};
940
875struct clk *at32_clock_list[] = { 941struct clk *at32_clock_list[] = {
876 &osc32k, 942 &osc32k,
877 &osc0, 943 &osc0,
@@ -908,6 +974,11 @@ struct clk *at32_clock_list[] = {
908 &atmel_spi1_spi_clk, 974 &atmel_spi1_spi_clk,
909 &lcdc0_hclk, 975 &lcdc0_hclk,
910 &lcdc0_pixclk, 976 &lcdc0_pixclk,
977 &gclk0,
978 &gclk1,
979 &gclk2,
980 &gclk3,
981 &gclk4,
911}; 982};
912unsigned int at32_nr_clocks = ARRAY_SIZE(at32_clock_list); 983unsigned int at32_nr_clocks = ARRAY_SIZE(at32_clock_list);
913 984
@@ -936,6 +1007,13 @@ void __init at32_clock_init(void)
936 if (sm_readl(sm, PM_PLL1) & SM_BIT(PLLOSC)) 1007 if (sm_readl(sm, PM_PLL1) & SM_BIT(PLLOSC))
937 pll1.parent = &osc1; 1008 pll1.parent = &osc1;
938 1009
1010 genclk_init_parent(&gclk0);
1011 genclk_init_parent(&gclk1);
1012 genclk_init_parent(&gclk2);
1013 genclk_init_parent(&gclk3);
1014 genclk_init_parent(&gclk4);
1015 genclk_init_parent(&lcdc0_pixclk);
1016
939 /* 1017 /*
940 * Turn on all clocks that have at least one user already, and 1018 * Turn on all clocks that have at least one user already, and
941 * turn off everything else. We only do this for module 1019 * turn off everything else. We only do this for module
diff --git a/arch/avr32/mach-at32ap/clock.c b/arch/avr32/mach-at32ap/clock.c
index 3d0d1097389f..49e7b12fe710 100644
--- a/arch/avr32/mach-at32ap/clock.c
+++ b/arch/avr32/mach-at32ap/clock.c
@@ -63,7 +63,11 @@ EXPORT_SYMBOL(clk_enable);
63 63
64static void __clk_disable(struct clk *clk) 64static void __clk_disable(struct clk *clk)
65{ 65{
66 BUG_ON(clk->users == 0); 66 if (clk->users == 0) {
67 printk(KERN_ERR "%s: mismatched disable\n", clk->name);
68 WARN_ON(1);
69 return;
70 }
67 71
68 if (--clk->users == 0 && clk->mode) 72 if (--clk->users == 0 && clk->mode)
69 clk->mode(clk, 0); 73 clk->mode(clk, 0);
diff --git a/include/asm-avr32/arch-at32ap/board.h b/include/asm-avr32/arch-at32ap/board.h
index b120ee030c86..1a7b07d436ff 100644
--- a/include/asm-avr32/arch-at32ap/board.h
+++ b/include/asm-avr32/arch-at32ap/board.h
@@ -26,7 +26,9 @@ struct eth_platform_data {
26struct platform_device * 26struct platform_device *
27at32_add_device_eth(unsigned int id, struct eth_platform_data *data); 27at32_add_device_eth(unsigned int id, struct eth_platform_data *data);
28 28
29struct platform_device *at32_add_device_spi(unsigned int id); 29struct spi_board_info;
30struct platform_device *
31at32_add_device_spi(unsigned int id, struct spi_board_info *b, unsigned int n);
30 32
31struct lcdc_platform_data { 33struct lcdc_platform_data {
32 unsigned long fbmem_start; 34 unsigned long fbmem_start;
diff --git a/include/asm-avr32/io.h b/include/asm-avr32/io.h
index eec47500fa66..c08e81048393 100644
--- a/include/asm-avr32/io.h
+++ b/include/asm-avr32/io.h
@@ -28,13 +28,13 @@ static __inline__ void * phys_to_virt(unsigned long address)
28 * Generic IO read/write. These perform native-endian accesses. Note 28 * Generic IO read/write. These perform native-endian accesses. Note
29 * that some architectures will want to re-define __raw_{read,write}w. 29 * that some architectures will want to re-define __raw_{read,write}w.
30 */ 30 */
31extern void __raw_writesb(unsigned int addr, const void *data, int bytelen); 31extern void __raw_writesb(void __iomem *addr, const void *data, int bytelen);
32extern void __raw_writesw(unsigned int addr, const void *data, int wordlen); 32extern void __raw_writesw(void __iomem *addr, const void *data, int wordlen);
33extern void __raw_writesl(unsigned int addr, const void *data, int longlen); 33extern void __raw_writesl(void __iomem *addr, const void *data, int longlen);
34 34
35extern void __raw_readsb(unsigned int addr, void *data, int bytelen); 35extern void __raw_readsb(const void __iomem *addr, void *data, int bytelen);
36extern void __raw_readsw(unsigned int addr, void *data, int wordlen); 36extern void __raw_readsw(const void __iomem *addr, void *data, int wordlen);
37extern void __raw_readsl(unsigned int addr, void *data, int longlen); 37extern void __raw_readsl(const void __iomem *addr, void *data, int longlen);
38 38
39static inline void writeb(unsigned char b, volatile void __iomem *addr) 39static inline void writeb(unsigned char b, volatile void __iomem *addr)
40{ 40{
@@ -252,6 +252,9 @@ extern void __iounmap(void __iomem *addr);
252#define ioremap(offset, size) \ 252#define ioremap(offset, size) \
253 __ioremap((offset), (size), 0) 253 __ioremap((offset), (size), 0)
254 254
255#define ioremap_nocache(offset, size) \
256 __ioremap((offset), (size), 0)
257
255#define iounmap(addr) \ 258#define iounmap(addr) \
256 __iounmap(addr) 259 __iounmap(addr)
257 260
@@ -263,6 +266,14 @@ extern void __iounmap(void __iomem *addr);
263#define page_to_bus page_to_phys 266#define page_to_bus page_to_phys
264#define bus_to_page phys_to_page 267#define bus_to_page phys_to_page
265 268
269/*
270 * Create a virtual mapping cookie for an IO port range. There exists
271 * no such thing as port-based I/O on AVR32, so a regular ioremap()
272 * should do what we need.
273 */
274#define ioport_map(port, nr) ioremap(port, nr)
275#define ioport_unmap(port) iounmap(port)
276
266#define dma_cache_wback_inv(_start, _size) \ 277#define dma_cache_wback_inv(_start, _size) \
267 flush_dcache_region(_start, _size) 278 flush_dcache_region(_start, _size)
268#define dma_cache_inv(_start, _size) \ 279#define dma_cache_inv(_start, _size) \
diff --git a/include/asm-avr32/unistd.h b/include/asm-avr32/unistd.h
index 56ed1f9d348a..8f5120471819 100644
--- a/include/asm-avr32/unistd.h
+++ b/include/asm-avr32/unistd.h
@@ -120,7 +120,7 @@
120#define __NR_getitimer 105 120#define __NR_getitimer 105
121#define __NR_swapoff 106 121#define __NR_swapoff 106
122#define __NR_sysinfo 107 122#define __NR_sysinfo 107
123#define __NR_ipc 108 123/* 108 was __NR_ipc for a little while */
124#define __NR_sendfile 109 124#define __NR_sendfile 109
125#define __NR_setdomainname 110 125#define __NR_setdomainname 110
126#define __NR_uname 111 126#define __NR_uname 111
@@ -282,8 +282,21 @@
282#define __NR_vmsplice 264 282#define __NR_vmsplice 264
283#define __NR_epoll_pwait 265 283#define __NR_epoll_pwait 265
284 284
285#define __NR_msgget 266
286#define __NR_msgsnd 267
287#define __NR_msgrcv 268
288#define __NR_msgctl 269
289#define __NR_semget 270
290#define __NR_semop 271
291#define __NR_semctl 272
292#define __NR_semtimedop 273
293#define __NR_shmat 274
294#define __NR_shmget 275
295#define __NR_shmdt 276
296#define __NR_shmctl 277
297
285#ifdef __KERNEL__ 298#ifdef __KERNEL__
286#define NR_syscalls 266 299#define NR_syscalls 278
287 300
288 301
289#define __ARCH_WANT_IPC_PARSE_VERSION 302#define __ARCH_WANT_IPC_PARSE_VERSION