aboutsummaryrefslogtreecommitdiffstats
path: root/arch/avr32
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 /arch/avr32
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
Diffstat (limited to 'arch/avr32')
-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
4 files changed, 132 insertions, 49 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);