2 +++ b/arch/avr32/boards/atngw100/Kconfig
4 +# NGW100 customization
6 +config BOARD_ATNGW100_I2C_GPIO
7 + bool "Use GPIO for i2c instead of built-in TWI module"
9 + The driver for the built-in TWI module has been plagued by
10 + various problems, while the i2c-gpio driver is based on the
11 + trusty old i2c-algo-bit bitbanging engine, making it work
12 + on pretty much any setup.
14 + Choose 'Y' here if you're having i2c-related problems and
15 + want to rule out the i2c bus driver.
16 --- a/arch/avr32/boards/atngw100/setup.c
17 +++ b/arch/avr32/boards/atngw100/setup.c
20 #include <asm/setup.h>
22 -#include <asm/arch/at32ap7000.h>
23 +#include <asm/arch/at32ap700x.h>
24 #include <asm/arch/board.h>
25 #include <asm/arch/init.h>
26 #include <asm/arch/portmux.h>
28 static struct spi_board_info spi0_board_info[] __initdata = {
30 .modalias = "mtd_dataflash",
31 - .max_speed_hz = 10000000,
32 + .max_speed_hz = 8000000,
37 +static struct mci_platform_data __initdata mci0_data = {
38 + .detect_pin = GPIO_PIN_PC(25),
39 + .wp_pin = GPIO_PIN_PE(0),
43 * The next two functions should go away as the boot loader is
44 * supposed to initialize the macb address registers with a valid
49 +#ifdef CONFIG_BOARD_ATNGW100_I2C_GPIO
50 static struct i2c_gpio_platform_data i2c_gpio_data = {
51 .sda_pin = GPIO_PIN_PA(6),
52 .scl_pin = GPIO_PIN_PA(7),
54 .platform_data = &i2c_gpio_data,
59 static int __init atngw100_init(void)
62 set_hw_addr(at32_add_device_eth(1, ð_data[1]));
64 at32_add_device_spi(0, spi0_board_info, ARRAY_SIZE(spi0_board_info));
65 + at32_add_device_mci(0, &mci0_data);
66 at32_add_device_usba(0, NULL);
68 for (i = 0; i < ARRAY_SIZE(ngw_leds); i++) {
71 platform_device_register(&ngw_gpio_leds);
73 +#ifdef CONFIG_BOARD_ATNGW100_I2C_GPIO
74 at32_select_gpio(i2c_gpio_data.sda_pin,
75 AT32_GPIOF_MULTIDRV | AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
76 at32_select_gpio(i2c_gpio_data.scl_pin,
77 AT32_GPIOF_MULTIDRV | AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
78 platform_device_register(&i2c_gpio_device);
80 + at32_add_device_twi(0, NULL, 0);
85 --- a/arch/avr32/boards/atstk1000/atstk1000.h
86 +++ b/arch/avr32/boards/atstk1000/atstk1000.h
89 extern struct atmel_lcdfb_info atstk1000_lcdc_data;
91 +void atstk1000_setup_j2_leds(void);
93 #endif /* __ARCH_AVR32_BOARDS_ATSTK1000_ATSTK1000_H */
94 --- a/arch/avr32/boards/atstk1000/atstk1002.c
95 +++ b/arch/avr32/boards/atstk1000/atstk1002.c
97 #include <linux/etherdevice.h>
98 #include <linux/init.h>
99 #include <linux/kernel.h>
100 -#include <linux/leds.h>
101 #include <linux/platform_device.h>
102 #include <linux/string.h>
103 #include <linux/types.h>
107 #include <asm/setup.h>
108 -#include <asm/arch/at32ap7000.h>
109 +#include <asm/arch/at32ap700x.h>
110 #include <asm/arch/board.h>
111 #include <asm/arch/init.h>
112 #include <asm/arch/portmux.h>
117 -#ifndef CONFIG_BOARD_ATSTK1002_SW1_CUSTOM
118 -#ifndef CONFIG_BOARD_ATSTK1002_SW3_CUSTOM
119 +#ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
120 static struct at73c213_board_info at73c213_data = {
122 .shortname = "AVR32 STK1000 external DAC",
127 -#ifndef CONFIG_BOARD_ATSTK1002_SW1_CUSTOM
128 +#ifndef CONFIG_BOARD_ATSTK100X_SW1_CUSTOM
129 static struct spi_board_info spi0_board_info[] __initdata = {
130 -#ifndef CONFIG_BOARD_ATSTK1002_SW3_CUSTOM
131 +#ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
134 .modalias = "at73c213",
139 -#ifdef CONFIG_BOARD_ATSTK1002_SPI1
140 +#ifdef CONFIG_BOARD_ATSTK100X_SPI1
141 static struct spi_board_info spi1_board_info[] __initdata = { {
142 /* patch in custom entries here */
146 +static struct cf_platform_data __initdata cf0_data = {
147 +#ifdef CONFIG_BOARD_ATSTK1000_CF_HACKS
148 + .detect_pin = CONFIG_BOARD_ATSTK1000_CF_DETECT_PIN,
149 + .reset_pin = CONFIG_BOARD_ATSTK1000_CF_RESET_PIN,
151 + .detect_pin = GPIO_PIN_NONE,
152 + .reset_pin = GPIO_PIN_NONE,
154 + .vcc_pin = GPIO_PIN_NONE,
155 + .ready_pin = GPIO_PIN_PB(27),
160 * The next two functions should go away as the boot loader is
161 * supposed to initialize the macb address registers with a valid
166 -#ifdef CONFIG_BOARD_ATSTK1002_J2_LED
168 -static struct gpio_led stk_j2_led[] = {
169 -#ifdef CONFIG_BOARD_ATSTK1002_J2_LED8
170 -#define LEDSTRING "J2 jumpered to LED8"
171 - { .name = "led0:amber", .gpio = GPIO_PIN_PB( 8), },
172 - { .name = "led1:amber", .gpio = GPIO_PIN_PB( 9), },
173 - { .name = "led2:amber", .gpio = GPIO_PIN_PB(10), },
174 - { .name = "led3:amber", .gpio = GPIO_PIN_PB(13), },
175 - { .name = "led4:amber", .gpio = GPIO_PIN_PB(14), },
176 - { .name = "led5:amber", .gpio = GPIO_PIN_PB(15), },
177 - { .name = "led6:amber", .gpio = GPIO_PIN_PB(16), },
178 - { .name = "led7:amber", .gpio = GPIO_PIN_PB(30),
179 - .default_trigger = "heartbeat", },
181 -#define LEDSTRING "J2 jumpered to RGB LEDs"
182 - { .name = "r1:red", .gpio = GPIO_PIN_PB( 8), },
183 - { .name = "g1:green", .gpio = GPIO_PIN_PB(10), },
184 - { .name = "b1:blue", .gpio = GPIO_PIN_PB(14), },
186 - { .name = "r2:red", .gpio = GPIO_PIN_PB( 9),
187 - .default_trigger = "heartbeat", },
188 - { .name = "g2:green", .gpio = GPIO_PIN_PB(13), },
189 - { .name = "b2:blue", .gpio = GPIO_PIN_PB(15),
190 - .default_trigger = "heartbeat", },
191 - /* PB16, PB30 unused */
195 -static struct gpio_led_platform_data stk_j2_led_data = {
196 - .num_leds = ARRAY_SIZE(stk_j2_led),
197 - .leds = stk_j2_led,
200 -static struct platform_device stk_j2_led_dev = {
201 - .name = "leds-gpio",
202 - .id = 2, /* gpio block J2 */
204 - .platform_data = &stk_j2_led_data,
208 -static void setup_j2_leds(void)
212 - for (i = 0; i < ARRAY_SIZE(stk_j2_led); i++)
213 - at32_select_gpio(stk_j2_led[i].gpio, AT32_GPIOF_OUTPUT);
215 - printk("STK1002: " LEDSTRING "\n");
216 - platform_device_register(&stk_j2_led_dev);
220 -static void setup_j2_leds(void)
225 -#ifndef CONFIG_BOARD_ATSTK1002_SW1_CUSTOM
226 -#ifndef CONFIG_BOARD_ATSTK1002_SW3_CUSTOM
227 -static void __init at73c213_set_clk(struct at73c213_board_info *info)
228 +#ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
229 +static void __init atstk1002_setup_extdac(void)
236 at32_select_periph(GPIO_PIN_PA(30), GPIO_PERIPH_A, 0);
237 - info->dac_clk = gclk;
238 + at73c213_data.dac_clk = gclk;
242 @@ -229,12 +179,16 @@
249 +static void __init atstk1002_setup_extdac(void)
253 +#endif /* CONFIG_BOARD_ATSTK1000_EXTDAC */
255 void __init setup_board(void)
257 -#ifdef CONFIG_BOARD_ATSTK1002_SW2_CUSTOM
258 +#ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
259 at32_map_usart(0, 1); /* USART 0/B: /dev/ttyS1, IRDA */
261 at32_map_usart(1, 0); /* USART 1/A: /dev/ttyS0, DB9 */
264 at32_add_system_devices();
266 -#ifdef CONFIG_BOARD_ATSTK1002_SW2_CUSTOM
267 +#ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
268 at32_add_device_usart(1);
270 at32_add_device_usart(0);
271 @@ -281,12 +235,16 @@
272 #ifndef CONFIG_BOARD_ATSTK1002_SW6_CUSTOM
273 set_hw_addr(at32_add_device_eth(0, ð_data[0]));
275 -#ifndef CONFIG_BOARD_ATSTK1002_SW1_CUSTOM
276 +#ifndef CONFIG_BOARD_ATSTK100X_SW1_CUSTOM
277 at32_add_device_spi(0, spi0_board_info, ARRAY_SIZE(spi0_board_info));
279 -#ifdef CONFIG_BOARD_ATSTK1002_SPI1
280 +#ifdef CONFIG_BOARD_ATSTK100X_SPI1
281 at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info));
283 + at32_add_device_twi(0, NULL, 0);
284 +#ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
285 + at32_add_device_mci(0, NULL);
287 #ifdef CONFIG_BOARD_ATSTK1002_SW5_CUSTOM
288 set_hw_addr(at32_add_device_eth(1, ð_data[1]));
290 @@ -294,18 +252,23 @@
291 fbmem_start, fbmem_size);
293 at32_add_device_usba(0, NULL);
294 -#ifndef CONFIG_BOARD_ATSTK1002_SW3_CUSTOM
295 - at32_add_device_ssc(0, ATMEL_SSC_TX);
296 +#ifdef CONFIG_BOARD_ATSTK100X_ENABLE_AC97
297 + at32_add_device_ac97c(0);
299 + at32_add_device_abdac(0);
304 -#ifndef CONFIG_BOARD_ATSTK1002_SW3_CUSTOM
305 -#ifndef CONFIG_BOARD_ATSTK1002_SW1_CUSTOM
306 - at73c213_set_clk(&at73c213_data);
307 +#ifndef CONFIG_BOARD_ATSTK100X_SW3_CUSTOM
308 + at32_add_device_ssc(0, ATMEL_SSC_TX);
310 + at32_add_device_cf(0, 2, &cf0_data);
311 +#ifdef CONFIG_BOARD_ATSTK100X_ENABLE_PSIF
312 + at32_add_device_psif(0);
313 + at32_add_device_psif(1);
316 + atstk1000_setup_j2_leds();
317 + atstk1002_setup_extdac();
321 postcore_initcall(atstk1002_init);
323 +++ b/arch/avr32/boards/atstk1000/atstk1003.c
326 + * ATSTK1003 daughterboard-specific init code
328 + * Copyright (C) 2007 Atmel Corporation
330 + * This program is free software; you can redistribute it and/or modify
331 + * it under the terms of the GNU General Public License version 2 as
332 + * published by the Free Software Foundation.
334 +#include <linux/clk.h>
335 +#include <linux/err.h>
336 +#include <linux/init.h>
337 +#include <linux/kernel.h>
338 +#include <linux/platform_device.h>
339 +#include <linux/string.h>
340 +#include <linux/types.h>
342 +#include <linux/spi/at73c213.h>
343 +#include <linux/spi/spi.h>
345 +#include <asm/setup.h>
347 +#include <asm/arch/at32ap700x.h>
348 +#include <asm/arch/board.h>
349 +#include <asm/arch/init.h>
350 +#include <asm/arch/portmux.h>
352 +#include "atstk1000.h"
354 +#ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
355 +static struct at73c213_board_info at73c213_data = {
357 + .shortname = "AVR32 STK1000 external DAC",
361 +#ifndef CONFIG_BOARD_ATSTK100X_SW1_CUSTOM
362 +static struct spi_board_info spi0_board_info[] __initdata = {
363 +#ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
366 + .modalias = "at73c213",
367 + .max_speed_hz = 200000,
369 + .mode = SPI_MODE_1,
370 + .platform_data = &at73c213_data,
374 + * We can control the LTV350QV LCD panel, but it isn't much
375 + * point since we don't have an LCD controller...
380 +#ifdef CONFIG_BOARD_ATSTK100X_SPI1
381 +static struct spi_board_info spi1_board_info[] __initdata = { {
382 + /* patch in custom entries here */
386 +static struct cf_platform_data __initdata cf0_data = {
387 +#ifdef CONFIG_BOARD_ATSTK1000_CF_HACKS
388 + .detect_pin = CONFIG_BOARD_ATSTK1000_CF_DETECT_PIN,
389 + .reset_pin = CONFIG_BOARD_ATSTK1000_CF_RESET_PIN,
391 + .detect_pin = GPIO_PIN_NONE,
392 + .reset_pin = GPIO_PIN_NONE,
394 + .vcc_pin = GPIO_PIN_NONE,
395 + .ready_pin = GPIO_PIN_PB(27),
399 +#ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
400 +static void __init atstk1003_setup_extdac(void)
405 + gclk = clk_get(NULL, "gclk0");
408 + pll = clk_get(NULL, "pll0");
412 + if (clk_set_parent(gclk, pll)) {
413 + pr_debug("STK1000: failed to set pll0 as parent for DAC clock\n");
417 + at32_select_periph(GPIO_PIN_PA(30), GPIO_PERIPH_A, 0);
418 + at73c213_data.dac_clk = gclk;
428 +static void __init atstk1003_setup_extdac(void)
432 +#endif /* CONFIG_BOARD_ATSTK1000_EXTDAC */
434 +void __init setup_board(void)
436 +#ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
437 + at32_map_usart(0, 1); /* USART 0/B: /dev/ttyS1, IRDA */
439 + at32_map_usart(1, 0); /* USART 1/A: /dev/ttyS0, DB9 */
441 + /* USART 2/unused: expansion connector */
442 + at32_map_usart(3, 2); /* USART 3/C: /dev/ttyS2, DB9 */
444 + at32_setup_serial_console(0);
447 +static int __init atstk1003_init(void)
450 + * ATSTK1000 uses 32-bit SDRAM interface. Reserve the
451 + * SDRAM-specific pins so that nobody messes with them.
453 + at32_reserve_pin(GPIO_PIN_PE(0)); /* DATA[16] */
454 + at32_reserve_pin(GPIO_PIN_PE(1)); /* DATA[17] */
455 + at32_reserve_pin(GPIO_PIN_PE(2)); /* DATA[18] */
456 + at32_reserve_pin(GPIO_PIN_PE(3)); /* DATA[19] */
457 + at32_reserve_pin(GPIO_PIN_PE(4)); /* DATA[20] */
458 + at32_reserve_pin(GPIO_PIN_PE(5)); /* DATA[21] */
459 + at32_reserve_pin(GPIO_PIN_PE(6)); /* DATA[22] */
460 + at32_reserve_pin(GPIO_PIN_PE(7)); /* DATA[23] */
461 + at32_reserve_pin(GPIO_PIN_PE(8)); /* DATA[24] */
462 + at32_reserve_pin(GPIO_PIN_PE(9)); /* DATA[25] */
463 + at32_reserve_pin(GPIO_PIN_PE(10)); /* DATA[26] */
464 + at32_reserve_pin(GPIO_PIN_PE(11)); /* DATA[27] */
465 + at32_reserve_pin(GPIO_PIN_PE(12)); /* DATA[28] */
466 + at32_reserve_pin(GPIO_PIN_PE(13)); /* DATA[29] */
467 + at32_reserve_pin(GPIO_PIN_PE(14)); /* DATA[30] */
468 + at32_reserve_pin(GPIO_PIN_PE(15)); /* DATA[31] */
469 + at32_reserve_pin(GPIO_PIN_PE(26)); /* SDCS */
471 + at32_add_system_devices();
473 +#ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
474 + at32_add_device_usart(1);
476 + at32_add_device_usart(0);
478 + at32_add_device_usart(2);
480 +#ifndef CONFIG_BOARD_ATSTK100X_SW1_CUSTOM
481 + at32_add_device_spi(0, spi0_board_info, ARRAY_SIZE(spi0_board_info));
483 +#ifdef CONFIG_BOARD_ATSTK100X_SPI1
484 + at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info));
486 +#ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
487 + at32_add_device_mci(0, NULL);
489 + at32_add_device_usba(0, NULL);
490 +#ifdef CONFIG_BOARD_ATSTK100X_ENABLE_AC97
491 + at32_add_device_ac97c(0);
493 + at32_add_device_abdac(0);
495 +#ifndef CONFIG_BOARD_ATSTK100X_SW3_CUSTOM
496 + at32_add_device_ssc(0, ATMEL_SSC_TX);
498 + at32_add_device_cf(0, 2, &cf0_data);
499 +#ifdef CONFIG_BOARD_ATSTK100X_ENABLE_PSIF
500 + at32_add_device_psif(0);
501 + at32_add_device_psif(1);
504 + atstk1000_setup_j2_leds();
505 + atstk1003_setup_extdac();
509 +postcore_initcall(atstk1003_init);
511 +++ b/arch/avr32/boards/atstk1000/atstk1004.c
514 + * ATSTK1003 daughterboard-specific init code
516 + * Copyright (C) 2007 Atmel Corporation
518 + * This program is free software; you can redistribute it and/or modify
519 + * it under the terms of the GNU General Public License version 2 as
520 + * published by the Free Software Foundation.
522 +#include <linux/clk.h>
523 +#include <linux/err.h>
524 +#include <linux/init.h>
525 +#include <linux/kernel.h>
526 +#include <linux/platform_device.h>
527 +#include <linux/string.h>
528 +#include <linux/types.h>
530 +#include <linux/spi/at73c213.h>
531 +#include <linux/spi/spi.h>
533 +#include <video/atmel_lcdc.h>
535 +#include <asm/setup.h>
537 +#include <asm/arch/at32ap700x.h>
538 +#include <asm/arch/board.h>
539 +#include <asm/arch/init.h>
540 +#include <asm/arch/portmux.h>
542 +#include "atstk1000.h"
544 +#ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
545 +static struct at73c213_board_info at73c213_data = {
547 + .shortname = "AVR32 STK1000 external DAC",
551 +#ifndef CONFIG_BOARD_ATSTK100X_SW1_CUSTOM
552 +static struct spi_board_info spi0_board_info[] __initdata = {
553 +#ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
556 + .modalias = "at73c213",
557 + .max_speed_hz = 200000,
559 + .mode = SPI_MODE_1,
560 + .platform_data = &at73c213_data,
565 + .modalias = "ltv350qv",
566 + .max_speed_hz = 16000000,
568 + .mode = SPI_MODE_3,
573 +#ifdef CONFIG_BOARD_ATSTK100X_SPI1
574 +static struct spi_board_info spi1_board_info[] __initdata = { {
575 + /* patch in custom entries here */
579 +#ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
580 +static void __init atstk1004_setup_extdac(void)
585 + gclk = clk_get(NULL, "gclk0");
588 + pll = clk_get(NULL, "pll0");
592 + if (clk_set_parent(gclk, pll)) {
593 + pr_debug("STK1000: failed to set pll0 as parent for DAC clock\n");
597 + at32_select_periph(GPIO_PIN_PA(30), GPIO_PERIPH_A, 0);
598 + at73c213_data.dac_clk = gclk;
608 +static void __init atstk1004_setup_extdac(void)
612 +#endif /* CONFIG_BOARD_ATSTK1000_EXTDAC */
614 +void __init setup_board(void)
616 +#ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
617 + at32_map_usart(0, 1); /* USART 0/B: /dev/ttyS1, IRDA */
619 + at32_map_usart(1, 0); /* USART 1/A: /dev/ttyS0, DB9 */
621 + /* USART 2/unused: expansion connector */
622 + at32_map_usart(3, 2); /* USART 3/C: /dev/ttyS2, DB9 */
624 + at32_setup_serial_console(0);
627 +static int __init atstk1004_init(void)
629 + at32_add_system_devices();
631 +#ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
632 + at32_add_device_usart(1);
634 + at32_add_device_usart(0);
636 + at32_add_device_usart(2);
638 +#ifndef CONFIG_BOARD_ATSTK100X_SW1_CUSTOM
639 + at32_add_device_spi(0, spi0_board_info, ARRAY_SIZE(spi0_board_info));
641 +#ifdef CONFIG_BOARD_ATSTK100X_SPI1
642 + at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info));
644 +#ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
645 + at32_add_device_mci(0, NULL);
647 + at32_add_device_lcdc(0, &atstk1000_lcdc_data,
648 + fbmem_start, fbmem_size);
649 + at32_add_device_usba(0, NULL);
650 +#ifdef CONFIG_BOARD_ATSTK100X_ENABLE_AC97
651 + at32_add_device_ac97c(0);
653 + at32_add_device_abdac(0);
655 +#ifndef CONFIG_BOARD_ATSTK100X_SW3_CUSTOM
656 + at32_add_device_ssc(0, ATMEL_SSC_TX);
658 +#ifdef CONFIG_BOARD_ATSTK100X_ENABLE_PSIF
659 + at32_add_device_psif(0);
660 + at32_add_device_psif(1);
663 + atstk1000_setup_j2_leds();
664 + atstk1004_setup_extdac();
668 +postcore_initcall(atstk1004_init);
669 --- a/arch/avr32/boards/atstk1000/Kconfig
670 +++ b/arch/avr32/boards/atstk1000/Kconfig
672 # STK1000 customization
677 -config BOARD_ATSTK1002_CUSTOM
678 - bool "Non-default STK-1002 jumper settings"
680 + prompt "ATSTK1000 CPU daughterboard type"
681 + default BOARD_ATSTK1002
683 +config BOARD_ATSTK1002
685 + select CPU_AT32AP7000
687 +config BOARD_ATSTK1003
689 + select CPU_AT32AP7001
691 +config BOARD_ATSTK1004
693 + select CPU_AT32AP7002
698 +config BOARD_ATSTK100X_CUSTOM
699 + bool "Non-default STK1002/STK1003/STK1004 jumper settings"
701 You will normally leave the jumpers on the CPU card at their
702 default settings. If you need to use certain peripherals,
703 you will need to change some of those jumpers.
705 -if BOARD_ATSTK1002_CUSTOM
706 +if BOARD_ATSTK100X_CUSTOM
708 -config BOARD_ATSTK1002_SW1_CUSTOM
709 +config BOARD_ATSTK100X_SW1_CUSTOM
710 bool "SW1: use SSC1 (not SPI0)"
712 This also prevents using the external DAC as an audio interface,
713 and means you can't initialize the on-board QVGA display.
715 -config BOARD_ATSTK1002_SW2_CUSTOM
716 +config BOARD_ATSTK100X_SW2_CUSTOM
717 bool "SW2: use IRDA or TIMER0 (not UART-A, MMC/SD, and PS2-A)"
719 If you change this you'll want an updated boot loader putting
720 the console on UART-C not UART-A.
722 -config BOARD_ATSTK1002_SW3_CUSTOM
723 +config BOARD_ATSTK100X_SW3_CUSTOM
724 bool "SW3: use TIMER1 (not SSC0 and GCLK)"
726 This also prevents using the external DAC as an audio interface.
728 -config BOARD_ATSTK1002_SW4_CUSTOM
729 +config BOARD_ATSTK100X_SW4_CUSTOM
730 bool "SW4: use ISI/Camera (not GPIOs, SPI1, and PS2-B)"
732 To use the camera interface you'll need a custom card (on the
735 config BOARD_ATSTK1002_SW5_CUSTOM
736 bool "SW5: use MACB1 (not LCDC)"
737 + depends on BOARD_ATSTK1002
739 config BOARD_ATSTK1002_SW6_CUSTOM
740 bool "SW6: more GPIOs (not MACB0)"
741 + depends on BOARD_ATSTK1002
745 -config BOARD_ATSTK1002_SPI1
746 +config BOARD_ATSTK100X_SPI1
747 bool "Configure SPI1 controller"
748 - depends on !BOARD_ATSTK1002_SW4_CUSTOM
749 + depends on !BOARD_ATSTK100X_SW4_CUSTOM
751 All the signals for the second SPI controller are available on
752 GPIO lines and accessed through the J1 jumper block. Say "y"
753 here to configure that SPI controller.
755 -config BOARD_ATSTK1002_J2_LED
756 +config BOARD_ATSTK1000_J2_LED
758 - default BOARD_ATSTK1002_J2_LED8 || BOARD_ATSTK1002_J2_RGB
759 + default BOARD_ATSTK1000_J2_LED8 || BOARD_ATSTK1000_J2_RGB
762 prompt "LEDs connected to J2:"
763 - depends on LEDS_GPIO && !BOARD_ATSTK1002_SW4_CUSTOM
764 + depends on LEDS_GPIO && !BOARD_ATSTK100X_SW4_CUSTOM
767 Select this if you have jumpered the J2 jumper block to the
769 IDC cable. A default "heartbeat" trigger is provided, but
770 you can of course override this.
772 -config BOARD_ATSTK1002_J2_LED8
773 +config BOARD_ATSTK1000_J2_LED8
776 Select this if J2 is jumpered to LED0..LED7 amber leds.
778 -config BOARD_ATSTK1002_J2_RGB
779 +config BOARD_ATSTK1000_J2_RGB
782 Select this if J2 is jumpered to the RGB leds.
787 +config BOARD_ATSTK1000_EXTDAC
789 + depends on !BOARD_ATSTK100X_SW1_CUSTOM && !BOARD_ATSTK100X_SW3_CUSTOM
792 +config BOARD_ATSTK100X_ENABLE_AC97
793 + bool "Use AC97C instead of ABDAC"
795 + Select this if you want to use the built-in AC97 controller
796 + instead of the built-in Audio Bitstream DAC. These share
797 + the same I/O pins on the AP7000, so both can't be enabled
800 + Note that the STK1000 kit doesn't ship with an AC97 codec on
801 + board, so say N unless you've got an expansion board with an
802 + AC97 codec on it that you want to use.
804 +config BOARD_ATSTK1000_CF_HACKS
805 + bool "ATSTK1000 CompactFlash hacks"
806 + depends on !BOARD_ATSTK100X_SW4_CUSTOM
808 + Select this if you have re-routed the CompactFlash RESET and
809 + CD signals to GPIOs on your STK1000. This is necessary for
810 + reset and card detection to work properly, although some CF
811 + cards may be able to cope without reset.
813 +config BOARD_ATSTK1000_CF_RESET_PIN
814 + hex "CompactFlash RESET pin"
816 + depends on BOARD_ATSTK1000_CF_HACKS
818 + Select which GPIO pin to use for the CompactFlash RESET
819 + signal. This is specified as a hexadecimal number and should
820 + be defined as 0x20 * gpio_port + pin.
822 + The default is 0x30, which is pin 16 on PIOB, aka GPIO14.
824 +config BOARD_ATSTK1000_CF_DETECT_PIN
825 + hex "CompactFlash DETECT pin"
827 + depends on BOARD_ATSTK1000_CF_HACKS
829 + Select which GPIO pin to use for the CompactFlash CD
830 + signal. This is specified as a hexadecimal number and should
831 + be defined as 0x20 * gpio_port + pin.
833 + The default is 0x3e, which is pin 30 on PIOB, aka GPIO15.
835 +config BOARD_ATSTK100X_ENABLE_PSIF
836 + bool "Enable PSIF peripheral (PS/2 support)"
839 + Select this if you want to use the PSIF peripheral to hook up PS/2
840 + devices to your STK1000. This will require a hardware modification to
841 + work correctly, since PS/2 devices require 5 volt power and signals,
842 + while the STK1000 only provides 3.3 volt.
844 + Say N if you have not modified the hardware to boost the voltage, say
845 + Y if you have level convertion hardware or a PS/2 device capable of
846 + operating on 3.3 volt.
849 --- a/arch/avr32/boards/atstk1000/Makefile
850 +++ b/arch/avr32/boards/atstk1000/Makefile
852 obj-y += setup.o flash.o
853 obj-$(CONFIG_BOARD_ATSTK1002) += atstk1002.o
854 +obj-$(CONFIG_BOARD_ATSTK1003) += atstk1003.o
855 +obj-$(CONFIG_BOARD_ATSTK1004) += atstk1004.o
856 --- a/arch/avr32/boards/atstk1000/setup.c
857 +++ b/arch/avr32/boards/atstk1000/setup.c
859 #include <linux/bootmem.h>
860 #include <linux/fb.h>
861 #include <linux/init.h>
862 +#include <linux/platform_device.h>
863 #include <linux/types.h>
864 #include <linux/linkage.h>
866 #include <video/atmel_lcdc.h>
868 #include <asm/setup.h>
870 +#include <asm/arch/at32ap700x.h>
871 #include <asm/arch/board.h>
872 +#include <asm/arch/portmux.h>
874 #include "atstk1000.h"
877 .default_monspecs = &atstk1000_default_monspecs,
881 +#ifdef CONFIG_BOARD_ATSTK1000_J2_LED
882 +#include <linux/leds.h>
884 +static struct gpio_led stk1000_j2_led[] = {
885 +#ifdef CONFIG_BOARD_ATSTK1000_J2_LED8
886 +#define LEDSTRING "J2 jumpered to LED8"
887 + { .name = "led0:amber", .gpio = GPIO_PIN_PB( 8), },
888 + { .name = "led1:amber", .gpio = GPIO_PIN_PB( 9), },
889 + { .name = "led2:amber", .gpio = GPIO_PIN_PB(10), },
890 + { .name = "led3:amber", .gpio = GPIO_PIN_PB(13), },
891 + { .name = "led4:amber", .gpio = GPIO_PIN_PB(14), },
892 + { .name = "led5:amber", .gpio = GPIO_PIN_PB(15), },
893 + { .name = "led6:amber", .gpio = GPIO_PIN_PB(16), },
894 + { .name = "led7:amber", .gpio = GPIO_PIN_PB(30),
895 + .default_trigger = "heartbeat", },
897 +#define LEDSTRING "J2 jumpered to RGB LEDs"
898 + { .name = "r1:red", .gpio = GPIO_PIN_PB( 8), },
899 + { .name = "g1:green", .gpio = GPIO_PIN_PB(10), },
900 + { .name = "b1:blue", .gpio = GPIO_PIN_PB(14), },
902 + { .name = "r2:red", .gpio = GPIO_PIN_PB( 9),
903 + .default_trigger = "heartbeat", },
904 + { .name = "g2:green", .gpio = GPIO_PIN_PB(13), },
905 + { .name = "b2:blue", .gpio = GPIO_PIN_PB(15),
906 + .default_trigger = "heartbeat", },
907 + /* PB16, PB30 unused */
911 +static struct gpio_led_platform_data stk1000_j2_led_data = {
912 + .num_leds = ARRAY_SIZE(stk1000_j2_led),
913 + .leds = stk1000_j2_led,
916 +static struct platform_device stk1000_j2_led_dev = {
917 + .name = "leds-gpio",
918 + .id = 2, /* gpio block J2 */
920 + .platform_data = &stk1000_j2_led_data,
924 +void __init atstk1000_setup_j2_leds(void)
928 + for (i = 0; i < ARRAY_SIZE(stk1000_j2_led); i++)
929 + at32_select_gpio(stk1000_j2_led[i].gpio, AT32_GPIOF_OUTPUT);
931 + printk("STK1000: " LEDSTRING "\n");
932 + platform_device_register(&stk1000_j2_led_dev);
934 +#else /* CONFIG_BOARD_ATSTK1000_J2_LED */
935 +void __init atstk1000_setup_j2_leds(void)
939 +#endif /* CONFIG_BOARD_ATSTK1000_J2_LED */
940 --- a/arch/avr32/configs/atngw100_defconfig
941 +++ b/arch/avr32/configs/atngw100_defconfig
944 # Automatically generated make config: don't edit
945 -# Linux kernel version: 2.6.22-rc5
946 -# Sat Jun 23 15:40:05 2007
947 +# Linux kernel version: 2.6.24
948 +# Thu Mar 6 12:49:54 2008
951 CONFIG_GENERIC_GPIO=y
952 CONFIG_GENERIC_HARDIRQS=y
953 +CONFIG_STACKTRACE_SUPPORT=y
954 +CONFIG_LOCKDEP_SUPPORT=y
955 +CONFIG_TRACE_IRQFLAGS_SUPPORT=y
956 CONFIG_HARDIRQS_SW_RESEND=y
957 CONFIG_GENERIC_IRQ_PROBE=y
958 CONFIG_RWSEM_GENERIC_SPINLOCK=y
959 CONFIG_GENERIC_TIME=y
960 +CONFIG_GENERIC_CLOCKEVENTS=y
961 +# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
962 # CONFIG_ARCH_HAS_ILOG2_U32 is not set
963 # CONFIG_ARCH_HAS_ILOG2_U64 is not set
964 +CONFIG_ARCH_SUPPORTS_OPROFILE=y
965 CONFIG_GENERIC_HWEIGHT=y
966 CONFIG_GENERIC_CALIBRATE_DELAY=y
968 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
971 -# Code maturity level options
974 CONFIG_EXPERIMENTAL=y
975 CONFIG_BROKEN_ON_SMP=y
976 CONFIG_INIT_ENV_ARG_LIMIT=32
981 CONFIG_LOCALVERSION=""
982 # CONFIG_LOCALVERSION_AUTO is not set
985 -# CONFIG_IPC_NS is not set
986 CONFIG_SYSVIPC_SYSCTL=y
987 CONFIG_POSIX_MQUEUE=y
988 CONFIG_BSD_PROCESS_ACCT=y
989 CONFIG_BSD_PROCESS_ACCT_V3=y
990 # CONFIG_TASKSTATS is not set
991 -# CONFIG_UTS_NS is not set
992 +# CONFIG_USER_NS is not set
993 +# CONFIG_PID_NS is not set
994 # CONFIG_AUDIT is not set
995 # CONFIG_IKCONFIG is not set
996 CONFIG_LOG_BUF_SHIFT=14
997 +# CONFIG_CGROUPS is not set
998 +CONFIG_FAIR_GROUP_SCHED=y
999 +CONFIG_FAIR_USER_SCHED=y
1000 +# CONFIG_FAIR_CGROUP_SCHED is not set
1001 CONFIG_SYSFS_DEPRECATED=y
1002 # CONFIG_RELAY is not set
1003 CONFIG_BLK_DEV_INITRD=y
1005 CONFIG_ANON_INODES=y
1011 CONFIG_VM_EVENT_COUNTERS=y
1012 -# CONFIG_SLUB_DEBUG is not set
1013 +CONFIG_SLUB_DEBUG=y
1014 # CONFIG_SLAB is not set
1016 # CONFIG_SLOB is not set
1019 # CONFIG_TINY_SHMEM is not set
1023 -# Loadable module support
1026 CONFIG_MODULE_UNLOAD=y
1027 CONFIG_MODULE_FORCE_UNLOAD=y
1028 # CONFIG_MODVERSIONS is not set
1029 # CONFIG_MODULE_SRCVERSION_ALL is not set
1036 # CONFIG_LBD is not set
1037 # CONFIG_BLK_DEV_IO_TRACE is not set
1038 # CONFIG_LSF is not set
1039 +# CONFIG_BLK_DEV_BSG is not set
1043 @@ -107,21 +106,28 @@
1045 # System Type and features
1047 +CONFIG_TICK_ONESHOT=y
1049 +CONFIG_HIGH_RES_TIMERS=y
1050 +CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
1051 CONFIG_SUBARCH_AVR32B=y
1053 CONFIG_PERFORMANCE_COUNTERS=y
1054 CONFIG_PLATFORM_AT32AP=y
1055 +CONFIG_CPU_AT32AP700X=y
1056 CONFIG_CPU_AT32AP7000=y
1057 # CONFIG_BOARD_ATSTK1000 is not set
1058 CONFIG_BOARD_ATNGW100=y
1059 +CONFIG_BOARD_ATNGW100_I2C_GPIO=y
1060 CONFIG_LOADER_U_BOOT=y
1063 # Atmel AVR32 AP options
1065 -# CONFIG_AP7000_32_BIT_SMC is not set
1066 -CONFIG_AP7000_16_BIT_SMC=y
1067 -# CONFIG_AP7000_8_BIT_SMC is not set
1068 +# CONFIG_AP700X_32_BIT_SMC is not set
1069 +CONFIG_AP700X_16_BIT_SMC=y
1070 +# CONFIG_AP700X_8_BIT_SMC is not set
1072 CONFIG_LOAD_ADDRESS=0x10000000
1073 CONFIG_ENTRY_ADDRESS=0x90000000
1074 CONFIG_PHYS_OFFSET=0x10000000
1075 @@ -141,10 +147,14 @@
1077 CONFIG_FLAT_NODE_MEM_MAP=y
1078 # CONFIG_SPARSEMEM_STATIC is not set
1079 +# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
1080 CONFIG_SPLIT_PTLOCK_CPUS=4
1081 # CONFIG_RESOURCES_64BIT is not set
1082 CONFIG_ZONE_DMA_FLAG=0
1083 +CONFIG_VIRT_TO_BUS=y
1084 # CONFIG_OWNERSHIP_TRACE is not set
1085 +# CONFIG_NMI_DEBUGGING is not set
1087 # CONFIG_HZ_100 is not set
1089 # CONFIG_HZ_300 is not set
1090 @@ -153,13 +163,31 @@
1095 +# Power management options
1097 -# CONFIG_ARCH_SUPPORTS_MSI is not set
1100 -# PCCARD (PCMCIA/CardBus) support
1101 +# CPU Frequency scaling
1104 +CONFIG_CPU_FREQ_TABLE=y
1105 +# CONFIG_CPU_FREQ_DEBUG is not set
1106 +# CONFIG_CPU_FREQ_STAT is not set
1107 +CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
1108 +# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
1109 +# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
1110 +# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
1111 +CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
1112 +# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
1113 +CONFIG_CPU_FREQ_GOV_USERSPACE=y
1114 +CONFIG_CPU_FREQ_GOV_ONDEMAND=y
1115 +# CONFIG_CPU_FREQ_GOV_CONSERVATIVE is not set
1116 +CONFIG_CPU_FREQ_AT32AP=y
1121 +# CONFIG_ARCH_SUPPORTS_MSI is not set
1122 # CONFIG_PCCARD is not set
1126 CONFIG_INET_XFRM_MODE_TRANSPORT=y
1127 CONFIG_INET_XFRM_MODE_TUNNEL=y
1128 CONFIG_INET_XFRM_MODE_BEET=y
1129 +# CONFIG_INET_LRO is not set
1131 CONFIG_INET_TCP_DIAG=y
1132 # CONFIG_TCP_CONG_ADVANCED is not set
1134 # CONFIG_NETWORK_SECMARK is not set
1136 # CONFIG_NETFILTER_DEBUG is not set
1137 +CONFIG_BRIDGE_NETFILTER=y
1140 # Core Netfilter Configuration
1142 # CONFIG_NF_CONNTRACK_EVENTS is not set
1143 CONFIG_NF_CT_PROTO_GRE=m
1144 # CONFIG_NF_CT_PROTO_SCTP is not set
1145 +# CONFIG_NF_CT_PROTO_UDPLITE is not set
1146 CONFIG_NF_CONNTRACK_AMANDA=m
1147 CONFIG_NF_CONNTRACK_FTP=m
1148 CONFIG_NF_CONNTRACK_H323=m
1149 @@ -269,9 +300,11 @@
1150 CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m
1151 CONFIG_NETFILTER_XT_TARGET_NFLOG=m
1152 # CONFIG_NETFILTER_XT_TARGET_NOTRACK is not set
1153 +# CONFIG_NETFILTER_XT_TARGET_TRACE is not set
1154 CONFIG_NETFILTER_XT_TARGET_TCPMSS=m
1155 CONFIG_NETFILTER_XT_MATCH_COMMENT=m
1156 CONFIG_NETFILTER_XT_MATCH_CONNBYTES=m
1157 +# CONFIG_NETFILTER_XT_MATCH_CONNLIMIT is not set
1158 CONFIG_NETFILTER_XT_MATCH_CONNMARK=m
1159 CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
1160 # CONFIG_NETFILTER_XT_MATCH_DCCP is not set
1162 CONFIG_NETFILTER_XT_MATCH_MARK=m
1163 CONFIG_NETFILTER_XT_MATCH_POLICY=m
1164 CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
1165 +# CONFIG_NETFILTER_XT_MATCH_PHYSDEV is not set
1166 CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m
1167 CONFIG_NETFILTER_XT_MATCH_QUOTA=m
1168 CONFIG_NETFILTER_XT_MATCH_REALM=m
1170 CONFIG_NETFILTER_XT_MATCH_STATISTIC=m
1171 CONFIG_NETFILTER_XT_MATCH_STRING=m
1172 CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
1173 +# CONFIG_NETFILTER_XT_MATCH_TIME is not set
1174 +# CONFIG_NETFILTER_XT_MATCH_U32 is not set
1175 CONFIG_NETFILTER_XT_MATCH_HASHLIMIT=m
1178 @@ -359,13 +395,19 @@
1179 CONFIG_IP6_NF_MANGLE=m
1180 CONFIG_IP6_NF_TARGET_HL=m
1184 +# Bridge: Netfilter Configuration
1186 +# CONFIG_BRIDGE_NF_EBTABLES is not set
1187 # CONFIG_IP_DCCP is not set
1188 # CONFIG_IP_SCTP is not set
1189 # CONFIG_TIPC is not set
1190 # CONFIG_ATM is not set
1191 -# CONFIG_BRIDGE is not set
1194 # CONFIG_DECNET is not set
1196 # CONFIG_LLC2 is not set
1197 # CONFIG_IPX is not set
1198 # CONFIG_ATALK is not set
1199 @@ -373,10 +415,6 @@
1200 # CONFIG_LAPB is not set
1201 # CONFIG_ECONET is not set
1202 # CONFIG_WAN_ROUTER is not set
1205 -# QoS and/or fair queueing
1207 # CONFIG_NET_SCHED is not set
1208 CONFIG_NET_CLS_ROUTE=y
1213 # CONFIG_NET_PKTGEN is not set
1214 +# CONFIG_NET_TCPPROBE is not set
1215 # CONFIG_HAMRADIO is not set
1216 # CONFIG_IRDA is not set
1217 # CONFIG_BT is not set
1219 # CONFIG_MAC80211 is not set
1220 # CONFIG_IEEE80211 is not set
1221 # CONFIG_RFKILL is not set
1222 +# CONFIG_NET_9P is not set
1226 @@ -405,16 +445,13 @@
1228 # Generic Driver Options
1230 +CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
1232 # CONFIG_PREVENT_FIRMWARE_BUILD is not set
1233 # CONFIG_FW_LOADER is not set
1234 # CONFIG_DEBUG_DRIVER is not set
1235 # CONFIG_DEBUG_DEVRES is not set
1236 # CONFIG_SYS_HYPERVISOR is not set
1239 -# Connector - unified userspace <-> kernelspace linker
1241 # CONFIG_CONNECTOR is not set
1243 # CONFIG_MTD_DEBUG is not set
1245 # CONFIG_INFTL is not set
1246 # CONFIG_RFD_FTL is not set
1247 # CONFIG_SSFDC is not set
1248 +# CONFIG_MTD_OOPS is not set
1251 # RAM/ROM/Flash chip drivers
1252 @@ -493,20 +531,8 @@
1253 # UBI - Unsorted block images
1255 # CONFIG_MTD_UBI is not set
1258 -# Parallel port support
1260 # CONFIG_PARPORT is not set
1263 -# Plug and Play support
1265 -# CONFIG_PNPACPI is not set
1271 # CONFIG_BLK_DEV_COW_COMMON is not set
1272 CONFIG_BLK_DEV_LOOP=m
1273 # CONFIG_BLK_DEV_CRYPTOLOOP is not set
1274 @@ -517,11 +543,13 @@
1275 CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
1276 # CONFIG_CDROM_PKTCDVD is not set
1277 # CONFIG_ATA_OVER_ETH is not set
1282 -# CONFIG_BLINK is not set
1283 +CONFIG_MISC_DEVICES=y
1284 +# CONFIG_ATMEL_PWM is not set
1285 +CONFIG_ATMEL_TCLIB=y
1286 +CONFIG_ATMEL_TCB_CLKSRC=y
1287 +CONFIG_ATMEL_TCB_CLKSRC_BLOCK=0
1288 +# CONFIG_EEPROM_93CX6 is not set
1289 +# CONFIG_ATMEL_SSC is not set
1290 # CONFIG_IDE is not set
1293 @@ -529,30 +557,42 @@
1295 # CONFIG_RAID_ATTRS is not set
1296 # CONFIG_SCSI is not set
1297 +# CONFIG_SCSI_DMA is not set
1298 # CONFIG_SCSI_NETLINK is not set
1299 # CONFIG_ATA is not set
1302 -# Multi-device support (RAID and LVM)
1304 # CONFIG_MD is not set
1307 -# Network device support
1310 +# CONFIG_NETDEVICES_MULTIQUEUE is not set
1311 # CONFIG_DUMMY is not set
1312 # CONFIG_BONDING is not set
1313 +# CONFIG_MACVLAN is not set
1314 # CONFIG_EQUALIZER is not set
1316 -# CONFIG_PHYLIB is not set
1317 +# CONFIG_VETH is not set
1321 -# Ethernet (10 or 100Mbit)
1322 +# MII PHY device drivers
1324 +# CONFIG_MARVELL_PHY is not set
1325 +# CONFIG_DAVICOM_PHY is not set
1326 +# CONFIG_QSEMI_PHY is not set
1327 +# CONFIG_LXT_PHY is not set
1328 +# CONFIG_CICADA_PHY is not set
1329 +# CONFIG_VITESSE_PHY is not set
1330 +# CONFIG_SMSC_PHY is not set
1331 +# CONFIG_BROADCOM_PHY is not set
1332 +# CONFIG_ICPLUS_PHY is not set
1333 +# CONFIG_FIXED_PHY is not set
1334 +# CONFIG_MDIO_BITBANG is not set
1335 CONFIG_NET_ETHERNET=y
1337 +# CONFIG_MII is not set
1339 +# CONFIG_IBM_NEW_EMAC_ZMII is not set
1340 +# CONFIG_IBM_NEW_EMAC_RGMII is not set
1341 +# CONFIG_IBM_NEW_EMAC_TAH is not set
1342 +# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
1343 +# CONFIG_B44 is not set
1344 # CONFIG_NETDEV_1000 is not set
1345 # CONFIG_NETDEV_10000 is not set
1347 @@ -571,21 +611,14 @@
1348 CONFIG_PPP_BSDCOMP=m
1351 +# CONFIG_PPPOL2TP is not set
1352 # CONFIG_SLIP is not set
1354 # CONFIG_SHAPER is not set
1355 # CONFIG_NETCONSOLE is not set
1356 # CONFIG_NETPOLL is not set
1357 # CONFIG_NET_POLL_CONTROLLER is not set
1362 # CONFIG_ISDN is not set
1365 -# Telephony Support
1367 # CONFIG_PHONE is not set
1370 @@ -615,28 +648,57 @@
1372 CONFIG_SERIAL_ATMEL=y
1373 CONFIG_SERIAL_ATMEL_CONSOLE=y
1374 +CONFIG_SERIAL_ATMEL_PDC=y
1375 # CONFIG_SERIAL_ATMEL_TTYAT is not set
1376 CONFIG_SERIAL_CORE=y
1377 CONFIG_SERIAL_CORE_CONSOLE=y
1378 CONFIG_UNIX98_PTYS=y
1379 # CONFIG_LEGACY_PTYS is not set
1384 # CONFIG_IPMI_HANDLER is not set
1385 -# CONFIG_WATCHDOG is not set
1386 # CONFIG_HW_RANDOM is not set
1387 # CONFIG_RTC is not set
1388 # CONFIG_GEN_RTC is not set
1389 # CONFIG_R3964 is not set
1390 # CONFIG_RAW_DRIVER is not set
1395 # CONFIG_TCG_TPM is not set
1396 -# CONFIG_I2C is not set
1398 +CONFIG_I2C_BOARDINFO=y
1399 +CONFIG_I2C_CHARDEV=m
1404 +CONFIG_I2C_ALGOBIT=m
1405 +# CONFIG_I2C_ALGOPCF is not set
1406 +# CONFIG_I2C_ALGOPCA is not set
1409 +# I2C Hardware Bus support
1411 +CONFIG_I2C_ATMELTWI=m
1413 +# CONFIG_I2C_OCORES is not set
1414 +# CONFIG_I2C_PARPORT_LIGHT is not set
1415 +# CONFIG_I2C_SIMTEC is not set
1416 +# CONFIG_I2C_TAOS_EVM is not set
1417 +# CONFIG_I2C_STUB is not set
1420 +# Miscellaneous I2C Chip support
1422 +# CONFIG_SENSORS_DS1337 is not set
1423 +# CONFIG_SENSORS_DS1374 is not set
1424 +# CONFIG_DS1682 is not set
1425 +# CONFIG_SENSORS_EEPROM is not set
1426 +# CONFIG_SENSORS_PCF8574 is not set
1427 +# CONFIG_SENSORS_PCA9539 is not set
1428 +# CONFIG_SENSORS_PCF8591 is not set
1429 +# CONFIG_SENSORS_MAX6875 is not set
1430 +# CONFIG_SENSORS_TSL2550 is not set
1431 +# CONFIG_I2C_DEBUG_CORE is not set
1432 +# CONFIG_I2C_DEBUG_ALGO is not set
1433 +# CONFIG_I2C_DEBUG_BUS is not set
1434 +# CONFIG_I2C_DEBUG_CHIP is not set
1438 @@ -655,13 +717,25 @@
1439 # SPI Protocol Masters
1441 # CONFIG_SPI_AT25 is not set
1442 -# CONFIG_SPI_SPIDEV is not set
1443 +CONFIG_SPI_SPIDEV=m
1444 +# CONFIG_SPI_TLE62X0 is not set
1445 +# CONFIG_W1 is not set
1446 +# CONFIG_POWER_SUPPLY is not set
1447 +# CONFIG_HWMON is not set
1449 +# CONFIG_WATCHDOG_NOWAYOUT is not set
1452 -# Dallas's 1-wire bus
1453 +# Watchdog Device Drivers
1455 -# CONFIG_W1 is not set
1456 -# CONFIG_HWMON is not set
1457 +# CONFIG_SOFT_WATCHDOG is not set
1458 +CONFIG_AT32AP700X_WDT=y
1461 +# Sonics Silicon Backplane
1463 +CONFIG_SSB_POSSIBLE=y
1464 +# CONFIG_SSB is not set
1467 # Multifunction device drivers
1468 @@ -678,23 +752,21 @@
1472 +# CONFIG_VGASTATE is not set
1473 +# CONFIG_VIDEO_OUTPUT_CONTROL is not set
1474 +# CONFIG_FB is not set
1475 # CONFIG_BACKLIGHT_LCD_SUPPORT is not set
1478 # Display device support
1480 # CONFIG_DISPLAY_SUPPORT is not set
1481 -# CONFIG_VGASTATE is not set
1482 -# CONFIG_FB is not set
1487 # CONFIG_SOUND is not set
1492 +CONFIG_USB_SUPPORT=y
1493 # CONFIG_USB_ARCH_HAS_HCD is not set
1494 # CONFIG_USB_ARCH_HAS_OHCI is not set
1495 # CONFIG_USB_ARCH_HAS_EHCI is not set
1496 @@ -706,12 +778,48 @@
1498 # USB Gadget Support
1500 -# CONFIG_USB_GADGET is not set
1501 -# CONFIG_MMC is not set
1502 +CONFIG_USB_GADGET=y
1503 +# CONFIG_USB_GADGET_DEBUG is not set
1504 +# CONFIG_USB_GADGET_DEBUG_FILES is not set
1505 +CONFIG_USB_GADGET_SELECTED=y
1506 +# CONFIG_USB_GADGET_AMD5536UDC is not set
1507 +CONFIG_USB_GADGET_ATMEL_USBA=y
1508 +CONFIG_USB_ATMEL_USBA=y
1509 +# CONFIG_USB_GADGET_FSL_USB2 is not set
1510 +# CONFIG_USB_GADGET_NET2280 is not set
1511 +# CONFIG_USB_GADGET_PXA2XX is not set
1512 +# CONFIG_USB_GADGET_M66592 is not set
1513 +# CONFIG_USB_GADGET_GOKU is not set
1514 +# CONFIG_USB_GADGET_LH7A40X is not set
1515 +# CONFIG_USB_GADGET_OMAP is not set
1516 +# CONFIG_USB_GADGET_S3C2410 is not set
1517 +# CONFIG_USB_GADGET_AT91 is not set
1518 +# CONFIG_USB_GADGET_DUMMY_HCD is not set
1519 +CONFIG_USB_GADGET_DUALSPEED=y
1522 +CONFIG_USB_ETH_RNDIS=y
1523 +CONFIG_USB_GADGETFS=m
1524 +CONFIG_USB_FILE_STORAGE=m
1525 +# CONFIG_USB_FILE_STORAGE_TEST is not set
1526 +CONFIG_USB_G_SERIAL=m
1527 +# CONFIG_USB_MIDI_GADGET is not set
1529 +# CONFIG_MMC_DEBUG is not set
1530 +# CONFIG_MMC_UNSAFE_RESUME is not set
1533 +# MMC/SD Card Drivers
1536 +# CONFIG_MMC_BLOCK_BOUNCE is not set
1537 +# CONFIG_SDIO_UART is not set
1541 +# MMC/SD Host Controller Drivers
1543 +CONFIG_MMC_ATMELMCI=y
1548 @@ -726,53 +834,71 @@
1549 CONFIG_LEDS_TRIGGERS=y
1550 CONFIG_LEDS_TRIGGER_TIMER=y
1551 CONFIG_LEDS_TRIGGER_HEARTBEAT=y
1555 +CONFIG_RTC_HCTOSYS=y
1556 +CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
1557 +# CONFIG_RTC_DEBUG is not set
1568 -# InfiniBand support
1571 +CONFIG_RTC_INTF_SYSFS=y
1572 +CONFIG_RTC_INTF_PROC=y
1573 +CONFIG_RTC_INTF_DEV=y
1574 +# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
1575 +# CONFIG_RTC_DRV_TEST is not set
1578 -# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
1581 +# CONFIG_RTC_DRV_DS1307 is not set
1582 +# CONFIG_RTC_DRV_DS1374 is not set
1583 +# CONFIG_RTC_DRV_DS1672 is not set
1584 +# CONFIG_RTC_DRV_MAX6900 is not set
1585 +# CONFIG_RTC_DRV_RS5C372 is not set
1586 +# CONFIG_RTC_DRV_ISL1208 is not set
1587 +# CONFIG_RTC_DRV_X1205 is not set
1588 +# CONFIG_RTC_DRV_PCF8563 is not set
1589 +# CONFIG_RTC_DRV_PCF8583 is not set
1590 +# CONFIG_RTC_DRV_M41T80 is not set
1596 -# CONFIG_RTC_CLASS is not set
1597 +# CONFIG_RTC_DRV_RS5C348 is not set
1598 +# CONFIG_RTC_DRV_MAX6902 is not set
1601 -# DMA Engine support
1602 +# Platform RTC drivers
1604 -# CONFIG_DMA_ENGINE is not set
1605 +# CONFIG_RTC_DRV_DS1553 is not set
1606 +# CONFIG_RTC_DRV_STK17TA8 is not set
1607 +# CONFIG_RTC_DRV_DS1742 is not set
1608 +# CONFIG_RTC_DRV_M48T86 is not set
1609 +# CONFIG_RTC_DRV_M48T59 is not set
1610 +# CONFIG_RTC_DRV_V3020 is not set
1614 +# on-CPU RTC drivers
1616 +CONFIG_RTC_DRV_AT32AP700X=y
1622 +# CONFIG_UIO is not set
1629 # CONFIG_EXT2_FS_XATTR is not set
1630 # CONFIG_EXT2_FS_XIP is not set
1633 # CONFIG_EXT3_FS_XATTR is not set
1634 # CONFIG_EXT4DEV_FS is not set
1636 -# CONFIG_JBD_DEBUG is not set
1638 # CONFIG_REISERFS_FS is not set
1639 # CONFIG_JFS_FS is not set
1640 # CONFIG_FS_POSIX_ACL is not set
1642 # CONFIG_OCFS2_FS is not set
1643 # CONFIG_MINIX_FS is not set
1644 # CONFIG_ROMFS_FS is not set
1645 -# CONFIG_INOTIFY is not set
1647 +CONFIG_INOTIFY_USER=y
1648 # CONFIG_QUOTA is not set
1649 # CONFIG_DNOTIFY is not set
1650 # CONFIG_AUTOFS_FS is not set
1653 # CONFIG_TMPFS_POSIX_ACL is not set
1654 # CONFIG_HUGETLB_PAGE is not set
1656 CONFIG_CONFIGFS_FS=y
1659 @@ -830,10 +956,12 @@
1661 CONFIG_JFFS2_FS_DEBUG=0
1662 CONFIG_JFFS2_FS_WRITEBUFFER=y
1663 +# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
1664 # CONFIG_JFFS2_SUMMARY is not set
1665 # CONFIG_JFFS2_FS_XATTR is not set
1666 # CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
1668 +# CONFIG_JFFS2_LZO is not set
1669 CONFIG_JFFS2_RTIME=y
1670 # CONFIG_JFFS2_RUBIN is not set
1671 # CONFIG_CRAMFS is not set
1672 @@ -842,19 +970,21 @@
1673 # CONFIG_QNX4FS_FS is not set
1674 # CONFIG_SYSV_FS is not set
1675 # CONFIG_UFS_FS is not set
1678 -# Network File Systems
1680 +CONFIG_NETWORK_FILESYSTEMS=y
1683 # CONFIG_NFS_V3_ACL is not set
1684 # CONFIG_NFS_V4 is not set
1685 # CONFIG_NFS_DIRECTIO is not set
1686 -# CONFIG_NFSD is not set
1689 +# CONFIG_NFSD_V3_ACL is not set
1690 +# CONFIG_NFSD_V4 is not set
1698 # CONFIG_SUNRPC_BIND34 is not set
1699 @@ -871,23 +1001,18 @@
1700 # CONFIG_NCP_FS is not set
1701 # CONFIG_CODA_FS is not set
1702 # CONFIG_AFS_FS is not set
1703 -# CONFIG_9P_FS is not set
1708 # CONFIG_PARTITION_ADVANCED is not set
1709 CONFIG_MSDOS_PARTITION=y
1712 -# Native Language Support
1716 CONFIG_NLS_DEFAULT="iso8859-1"
1717 -# CONFIG_NLS_CODEPAGE_437 is not set
1718 +CONFIG_NLS_CODEPAGE_437=m
1719 # CONFIG_NLS_CODEPAGE_737 is not set
1720 # CONFIG_NLS_CODEPAGE_775 is not set
1721 -CONFIG_NLS_CODEPAGE_850=y
1722 +CONFIG_NLS_CODEPAGE_850=m
1723 # CONFIG_NLS_CODEPAGE_852 is not set
1724 # CONFIG_NLS_CODEPAGE_855 is not set
1725 # CONFIG_NLS_CODEPAGE_857 is not set
1726 @@ -908,7 +1033,7 @@
1727 # CONFIG_NLS_CODEPAGE_1250 is not set
1728 # CONFIG_NLS_CODEPAGE_1251 is not set
1729 # CONFIG_NLS_ASCII is not set
1730 -CONFIG_NLS_ISO8859_1=y
1731 +CONFIG_NLS_ISO8859_1=m
1732 # CONFIG_NLS_ISO8859_2 is not set
1733 # CONFIG_NLS_ISO8859_3 is not set
1734 # CONFIG_NLS_ISO8859_4 is not set
1735 @@ -921,18 +1046,19 @@
1736 # CONFIG_NLS_ISO8859_15 is not set
1737 # CONFIG_NLS_KOI8_R is not set
1738 # CONFIG_NLS_KOI8_U is not set
1742 -# Distributed Lock Manager
1745 # CONFIG_DLM is not set
1746 +CONFIG_INSTRUMENTATION=y
1750 +# CONFIG_MARKERS is not set
1755 -CONFIG_TRACE_IRQFLAGS_SUPPORT=y
1756 # CONFIG_PRINTK_TIME is not set
1757 +CONFIG_ENABLE_WARN_DEPRECATED=y
1758 CONFIG_ENABLE_MUST_CHECK=y
1759 CONFIG_MAGIC_SYSRQ=y
1760 # CONFIG_UNUSED_SYMBOLS is not set
1761 @@ -941,12 +1067,17 @@
1762 CONFIG_DEBUG_KERNEL=y
1763 # CONFIG_DEBUG_SHIRQ is not set
1764 CONFIG_DETECT_SOFTLOCKUP=y
1765 +CONFIG_SCHED_DEBUG=y
1766 # CONFIG_SCHEDSTATS is not set
1767 # CONFIG_TIMER_STATS is not set
1768 +# CONFIG_SLUB_DEBUG_ON is not set
1769 # CONFIG_DEBUG_RT_MUTEXES is not set
1770 # CONFIG_RT_MUTEX_TESTER is not set
1771 # CONFIG_DEBUG_SPINLOCK is not set
1772 # CONFIG_DEBUG_MUTEXES is not set
1773 +# CONFIG_DEBUG_LOCK_ALLOC is not set
1774 +# CONFIG_PROVE_LOCKING is not set
1775 +# CONFIG_LOCK_STAT is not set
1776 # CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1777 # CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1778 # CONFIG_DEBUG_KOBJECT is not set
1779 @@ -954,21 +1085,21 @@
1780 # CONFIG_DEBUG_INFO is not set
1781 # CONFIG_DEBUG_VM is not set
1782 # CONFIG_DEBUG_LIST is not set
1783 +# CONFIG_DEBUG_SG is not set
1784 CONFIG_FRAME_POINTER=y
1785 # CONFIG_FORCED_INLINING is not set
1786 +# CONFIG_BOOT_PRINTK_DELAY is not set
1787 # CONFIG_RCU_TORTURE_TEST is not set
1788 +# CONFIG_LKDTM is not set
1789 # CONFIG_FAULT_INJECTION is not set
1790 -# CONFIG_KPROBES is not set
1791 +# CONFIG_SAMPLES is not set
1796 # CONFIG_KEYS is not set
1797 # CONFIG_SECURITY is not set
1800 -# Cryptographic options
1802 +# CONFIG_SECURITY_FILE_CAPABILITIES is not set
1804 CONFIG_CRYPTO_ALGAPI=y
1805 CONFIG_CRYPTO_BLKCIPHER=y
1806 @@ -989,6 +1120,7 @@
1808 CONFIG_CRYPTO_PCBC=m
1809 # CONFIG_CRYPTO_LRW is not set
1810 +# CONFIG_CRYPTO_XTS is not set
1811 # CONFIG_CRYPTO_CRYPTD is not set
1813 # CONFIG_CRYPTO_FCRYPT is not set
1814 @@ -1002,15 +1134,14 @@
1815 CONFIG_CRYPTO_ARC4=m
1816 # CONFIG_CRYPTO_KHAZAD is not set
1817 # CONFIG_CRYPTO_ANUBIS is not set
1818 +# CONFIG_CRYPTO_SEED is not set
1819 CONFIG_CRYPTO_DEFLATE=y
1820 # CONFIG_CRYPTO_MICHAEL_MIC is not set
1821 # CONFIG_CRYPTO_CRC32C is not set
1822 # CONFIG_CRYPTO_CAMELLIA is not set
1823 # CONFIG_CRYPTO_TEST is not set
1826 -# Hardware crypto devices
1828 +# CONFIG_CRYPTO_AUTHENC is not set
1833 @@ -1018,8 +1149,9 @@
1836 # CONFIG_CRC16 is not set
1837 -# CONFIG_CRC_ITU_T is not set
1841 # CONFIG_LIBCRC32C is not set
1842 CONFIG_ZLIB_INFLATE=y
1843 CONFIG_ZLIB_DEFLATE=y
1844 --- a/arch/avr32/configs/atstk1002_defconfig
1845 +++ b/arch/avr32/configs/atstk1002_defconfig
1848 # Automatically generated make config: don't edit
1849 -# Linux kernel version: 2.6.22-rc5
1850 -# Sat Jun 23 15:32:08 2007
1851 +# Linux kernel version: 2.6.24
1852 +# Thu Mar 6 12:49:17 2008
1855 CONFIG_GENERIC_GPIO=y
1856 CONFIG_GENERIC_HARDIRQS=y
1857 +CONFIG_STACKTRACE_SUPPORT=y
1858 +CONFIG_LOCKDEP_SUPPORT=y
1859 +CONFIG_TRACE_IRQFLAGS_SUPPORT=y
1860 CONFIG_HARDIRQS_SW_RESEND=y
1861 CONFIG_GENERIC_IRQ_PROBE=y
1862 CONFIG_RWSEM_GENERIC_SPINLOCK=y
1863 CONFIG_GENERIC_TIME=y
1864 +CONFIG_GENERIC_CLOCKEVENTS=y
1865 +# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
1866 # CONFIG_ARCH_HAS_ILOG2_U32 is not set
1867 # CONFIG_ARCH_HAS_ILOG2_U64 is not set
1868 +CONFIG_ARCH_SUPPORTS_OPROFILE=y
1869 CONFIG_GENERIC_HWEIGHT=y
1870 CONFIG_GENERIC_CALIBRATE_DELAY=y
1871 CONFIG_GENERIC_BUG=y
1872 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
1875 -# Code maturity level options
1878 CONFIG_EXPERIMENTAL=y
1879 CONFIG_BROKEN_ON_SMP=y
1880 CONFIG_INIT_ENV_ARG_LIMIT=32
1885 CONFIG_LOCALVERSION=""
1886 # CONFIG_LOCALVERSION_AUTO is not set
1889 -# CONFIG_IPC_NS is not set
1890 CONFIG_SYSVIPC_SYSCTL=y
1891 CONFIG_POSIX_MQUEUE=y
1892 -CONFIG_BSD_PROCESS_ACCT=y
1893 -CONFIG_BSD_PROCESS_ACCT_V3=y
1895 -CONFIG_TASK_DELAY_ACCT=y
1896 -# CONFIG_TASK_XACCT is not set
1897 -# CONFIG_UTS_NS is not set
1899 +# CONFIG_BSD_PROCESS_ACCT is not set
1900 +# CONFIG_TASKSTATS is not set
1901 +# CONFIG_USER_NS is not set
1902 +# CONFIG_PID_NS is not set
1903 +# CONFIG_AUDIT is not set
1904 # CONFIG_IKCONFIG is not set
1905 CONFIG_LOG_BUF_SHIFT=14
1906 +# CONFIG_CGROUPS is not set
1907 +# CONFIG_FAIR_GROUP_SCHED is not set
1908 CONFIG_SYSFS_DEPRECATED=y
1910 CONFIG_BLK_DEV_INITRD=y
1912 CONFIG_ANON_INODES=y
1918 CONFIG_VM_EVENT_COUNTERS=y
1919 -# CONFIG_SLUB_DEBUG is not set
1920 +CONFIG_SLUB_DEBUG=y
1921 # CONFIG_SLAB is not set
1923 # CONFIG_SLOB is not set
1926 # CONFIG_TINY_SHMEM is not set
1930 -# Loadable module support
1933 CONFIG_MODULE_UNLOAD=y
1934 # CONFIG_MODULE_FORCE_UNLOAD is not set
1935 # CONFIG_MODVERSIONS is not set
1936 # CONFIG_MODULE_SRCVERSION_ALL is not set
1937 # CONFIG_KMOD is not set
1943 # CONFIG_LBD is not set
1944 # CONFIG_BLK_DEV_IO_TRACE is not set
1945 # CONFIG_LSF is not set
1946 +# CONFIG_BLK_DEV_BSG is not set
1951 CONFIG_IOSCHED_NOOP=y
1952 # CONFIG_IOSCHED_AS is not set
1953 # CONFIG_IOSCHED_DEADLINE is not set
1954 -# CONFIG_IOSCHED_CFQ is not set
1955 +CONFIG_IOSCHED_CFQ=y
1956 # CONFIG_DEFAULT_AS is not set
1957 # CONFIG_DEFAULT_DEADLINE is not set
1958 -# CONFIG_DEFAULT_CFQ is not set
1959 -CONFIG_DEFAULT_NOOP=y
1960 -CONFIG_DEFAULT_IOSCHED="noop"
1961 +CONFIG_DEFAULT_CFQ=y
1962 +# CONFIG_DEFAULT_NOOP is not set
1963 +CONFIG_DEFAULT_IOSCHED="cfq"
1966 # System Type and features
1968 +CONFIG_TICK_ONESHOT=y
1970 +CONFIG_HIGH_RES_TIMERS=y
1971 +CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
1972 CONFIG_SUBARCH_AVR32B=y
1974 CONFIG_PERFORMANCE_COUNTERS=y
1975 CONFIG_PLATFORM_AT32AP=y
1976 +CONFIG_CPU_AT32AP700X=y
1977 CONFIG_CPU_AT32AP7000=y
1978 -CONFIG_BOARD_ATSTK1002=y
1979 CONFIG_BOARD_ATSTK1000=y
1980 # CONFIG_BOARD_ATNGW100 is not set
1981 +CONFIG_BOARD_ATSTK1002=y
1982 +# CONFIG_BOARD_ATSTK1003 is not set
1983 +# CONFIG_BOARD_ATSTK1004 is not set
1984 +# CONFIG_BOARD_ATSTK100X_CUSTOM is not set
1985 +# CONFIG_BOARD_ATSTK100X_SPI1 is not set
1986 +# CONFIG_BOARD_ATSTK1000_J2_LED is not set
1987 +# CONFIG_BOARD_ATSTK1000_J2_LED8 is not set
1988 +# CONFIG_BOARD_ATSTK1000_J2_RGB is not set
1989 +CONFIG_BOARD_ATSTK1000_EXTDAC=y
1990 +# CONFIG_BOARD_ATSTK100X_ENABLE_AC97 is not set
1991 +# CONFIG_BOARD_ATSTK1000_CF_HACKS is not set
1992 +# CONFIG_BOARD_ATSTK100X_ENABLE_PSIF is not set
1993 CONFIG_LOADER_U_BOOT=y
1996 # Atmel AVR32 AP options
1998 -# CONFIG_AP7000_32_BIT_SMC is not set
1999 -CONFIG_AP7000_16_BIT_SMC=y
2000 -# CONFIG_AP7000_8_BIT_SMC is not set
2001 +# CONFIG_AP700X_32_BIT_SMC is not set
2002 +CONFIG_AP700X_16_BIT_SMC=y
2003 +# CONFIG_AP700X_8_BIT_SMC is not set
2005 CONFIG_LOAD_ADDRESS=0x10000000
2006 CONFIG_ENTRY_ADDRESS=0x90000000
2007 CONFIG_PHYS_OFFSET=0x10000000
2008 @@ -144,10 +155,14 @@
2010 CONFIG_FLAT_NODE_MEM_MAP=y
2011 # CONFIG_SPARSEMEM_STATIC is not set
2012 +# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
2013 CONFIG_SPLIT_PTLOCK_CPUS=4
2014 # CONFIG_RESOURCES_64BIT is not set
2015 CONFIG_ZONE_DMA_FLAG=0
2016 +CONFIG_VIRT_TO_BUS=y
2017 # CONFIG_OWNERSHIP_TRACE is not set
2018 +CONFIG_NMI_DEBUGGING=y
2020 # CONFIG_HZ_100 is not set
2022 # CONFIG_HZ_300 is not set
2023 @@ -156,13 +171,31 @@
2028 +# Power management options
2030 -# CONFIG_ARCH_SUPPORTS_MSI is not set
2033 -# PCCARD (PCMCIA/CardBus) support
2034 +# CPU Frequency scaling
2037 +CONFIG_CPU_FREQ_TABLE=y
2038 +# CONFIG_CPU_FREQ_DEBUG is not set
2039 +# CONFIG_CPU_FREQ_STAT is not set
2040 +CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
2041 +# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
2042 +# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
2043 +# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
2044 +CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
2045 +# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
2046 +CONFIG_CPU_FREQ_GOV_USERSPACE=y
2047 +CONFIG_CPU_FREQ_GOV_ONDEMAND=y
2048 +# CONFIG_CPU_FREQ_GOV_CONSERVATIVE is not set
2049 +CONFIG_CPU_FREQ_AT32AP=y
2054 +# CONFIG_ARCH_SUPPORTS_MSI is not set
2055 # CONFIG_PCCARD is not set
2058 @@ -182,7 +215,12 @@
2060 CONFIG_PACKET_MMAP=y
2062 -# CONFIG_NET_KEY is not set
2065 +# CONFIG_XFRM_SUB_POLICY is not set
2066 +# CONFIG_XFRM_MIGRATE is not set
2068 +# CONFIG_NET_KEY_MIGRATE is not set
2070 # CONFIG_IP_MULTICAST is not set
2071 # CONFIG_IP_ADVANCED_ROUTER is not set
2072 @@ -191,36 +229,52 @@
2073 CONFIG_IP_PNP_DHCP=y
2074 # CONFIG_IP_PNP_BOOTP is not set
2075 # CONFIG_IP_PNP_RARP is not set
2076 -# CONFIG_NET_IPIP is not set
2077 -# CONFIG_NET_IPGRE is not set
2080 # CONFIG_ARPD is not set
2081 # CONFIG_SYN_COOKIES is not set
2082 -# CONFIG_INET_AH is not set
2083 -# CONFIG_INET_ESP is not set
2086 # CONFIG_INET_IPCOMP is not set
2087 # CONFIG_INET_XFRM_TUNNEL is not set
2088 -# CONFIG_INET_TUNNEL is not set
2089 -# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
2090 -# CONFIG_INET_XFRM_MODE_TUNNEL is not set
2091 -# CONFIG_INET_XFRM_MODE_BEET is not set
2092 +CONFIG_INET_TUNNEL=m
2093 +CONFIG_INET_XFRM_MODE_TRANSPORT=m
2094 +CONFIG_INET_XFRM_MODE_TUNNEL=m
2095 +CONFIG_INET_XFRM_MODE_BEET=m
2096 +# CONFIG_INET_LRO is not set
2098 CONFIG_INET_TCP_DIAG=y
2099 # CONFIG_TCP_CONG_ADVANCED is not set
2100 CONFIG_TCP_CONG_CUBIC=y
2101 CONFIG_DEFAULT_TCP_CONG="cubic"
2102 # CONFIG_TCP_MD5SIG is not set
2103 -# CONFIG_IPV6 is not set
2104 -# CONFIG_INET6_XFRM_TUNNEL is not set
2105 -# CONFIG_INET6_TUNNEL is not set
2107 +# CONFIG_IPV6_PRIVACY is not set
2108 +# CONFIG_IPV6_ROUTER_PREF is not set
2109 +# CONFIG_IPV6_OPTIMISTIC_DAD is not set
2112 +CONFIG_INET6_IPCOMP=m
2113 +# CONFIG_IPV6_MIP6 is not set
2114 +CONFIG_INET6_XFRM_TUNNEL=m
2115 +CONFIG_INET6_TUNNEL=m
2116 +CONFIG_INET6_XFRM_MODE_TRANSPORT=m
2117 +CONFIG_INET6_XFRM_MODE_TUNNEL=m
2118 +CONFIG_INET6_XFRM_MODE_BEET=m
2119 +# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
2121 +CONFIG_IPV6_TUNNEL=m
2122 +# CONFIG_IPV6_MULTIPLE_TABLES is not set
2123 # CONFIG_NETWORK_SECMARK is not set
2124 # CONFIG_NETFILTER is not set
2125 # CONFIG_IP_DCCP is not set
2126 # CONFIG_IP_SCTP is not set
2127 # CONFIG_TIPC is not set
2128 # CONFIG_ATM is not set
2129 -# CONFIG_BRIDGE is not set
2131 # CONFIG_VLAN_8021Q is not set
2132 # CONFIG_DECNET is not set
2134 # CONFIG_LLC2 is not set
2135 # CONFIG_IPX is not set
2136 # CONFIG_ATALK is not set
2137 @@ -228,16 +282,13 @@
2138 # CONFIG_LAPB is not set
2139 # CONFIG_ECONET is not set
2140 # CONFIG_WAN_ROUTER is not set
2143 -# QoS and/or fair queueing
2145 # CONFIG_NET_SCHED is not set
2150 # CONFIG_NET_PKTGEN is not set
2151 +# CONFIG_NET_TCPPROBE is not set
2152 # CONFIG_HAMRADIO is not set
2153 # CONFIG_IRDA is not set
2154 # CONFIG_BT is not set
2156 # CONFIG_MAC80211 is not set
2157 # CONFIG_IEEE80211 is not set
2158 # CONFIG_RFKILL is not set
2159 +# CONFIG_NET_9P is not set
2163 @@ -259,16 +311,13 @@
2165 # Generic Driver Options
2167 +CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
2169 # CONFIG_PREVENT_FIRMWARE_BUILD is not set
2170 # CONFIG_FW_LOADER is not set
2171 # CONFIG_DEBUG_DRIVER is not set
2172 # CONFIG_DEBUG_DEVRES is not set
2173 # CONFIG_SYS_HYPERVISOR is not set
2176 -# Connector - unified userspace <-> kernelspace linker
2178 # CONFIG_CONNECTOR is not set
2180 # CONFIG_MTD_DEBUG is not set
2182 # CONFIG_INFTL is not set
2183 # CONFIG_RFD_FTL is not set
2184 # CONFIG_SSFDC is not set
2185 +# CONFIG_MTD_OOPS is not set
2188 # RAM/ROM/Flash chip drivers
2191 # Self-contained MTD device drivers
2193 +CONFIG_MTD_DATAFLASH=m
2194 +CONFIG_MTD_M25P80=m
2195 # CONFIG_MTD_SLRAM is not set
2196 # CONFIG_MTD_PHRAM is not set
2197 # CONFIG_MTD_MTDRAM is not set
2198 @@ -345,20 +397,8 @@
2199 # UBI - Unsorted block images
2201 # CONFIG_MTD_UBI is not set
2204 -# Parallel port support
2206 # CONFIG_PARPORT is not set
2209 -# Plug and Play support
2211 -# CONFIG_PNPACPI is not set
2217 # CONFIG_BLK_DEV_COW_COMMON is not set
2218 CONFIG_BLK_DEV_LOOP=m
2219 # CONFIG_BLK_DEV_CRYPTOLOOP is not set
2220 @@ -369,42 +409,91 @@
2221 CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
2222 # CONFIG_CDROM_PKTCDVD is not set
2223 # CONFIG_ATA_OVER_ETH is not set
2228 -# CONFIG_BLINK is not set
2229 +CONFIG_MISC_DEVICES=y
2231 +CONFIG_ATMEL_TCLIB=y
2232 +CONFIG_ATMEL_TCB_CLKSRC=y
2233 +CONFIG_ATMEL_TCB_CLKSRC_BLOCK=0
2234 +# CONFIG_EEPROM_93CX6 is not set
2236 # CONFIG_IDE is not set
2239 # SCSI device support
2241 # CONFIG_RAID_ATTRS is not set
2242 -# CONFIG_SCSI is not set
2245 +# CONFIG_SCSI_TGT is not set
2246 # CONFIG_SCSI_NETLINK is not set
2247 -# CONFIG_ATA is not set
2248 +# CONFIG_SCSI_PROC_FS is not set
2251 -# Multi-device support (RAID and LVM)
2252 +# SCSI support type (disk, tape, CD-ROM)
2254 -# CONFIG_MD is not set
2255 +CONFIG_BLK_DEV_SD=m
2256 +# CONFIG_CHR_DEV_ST is not set
2257 +# CONFIG_CHR_DEV_OSST is not set
2258 +CONFIG_BLK_DEV_SR=m
2259 +# CONFIG_BLK_DEV_SR_VENDOR is not set
2260 +# CONFIG_CHR_DEV_SG is not set
2261 +# CONFIG_CHR_DEV_SCH is not set
2264 +# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
2266 +# CONFIG_SCSI_MULTI_LUN is not set
2267 +# CONFIG_SCSI_CONSTANTS is not set
2268 +# CONFIG_SCSI_LOGGING is not set
2269 +# CONFIG_SCSI_SCAN_ASYNC is not set
2270 +CONFIG_SCSI_WAIT_SCAN=m
2273 -# Network device support
2276 +# CONFIG_SCSI_SPI_ATTRS is not set
2277 +# CONFIG_SCSI_FC_ATTRS is not set
2278 +# CONFIG_SCSI_ISCSI_ATTRS is not set
2279 +# CONFIG_SCSI_SAS_LIBSAS is not set
2280 +# CONFIG_SCSI_SRP_ATTRS is not set
2281 +# CONFIG_SCSI_LOWLEVEL is not set
2283 +# CONFIG_ATA_NONSTANDARD is not set
2285 +# CONFIG_PATA_PLATFORM is not set
2286 +# CONFIG_MD is not set
2289 +# CONFIG_NETDEVICES_MULTIQUEUE is not set
2290 +# CONFIG_DUMMY is not set
2291 # CONFIG_BONDING is not set
2292 +# CONFIG_MACVLAN is not set
2293 # CONFIG_EQUALIZER is not set
2295 -# CONFIG_PHYLIB is not set
2296 +# CONFIG_VETH is not set
2300 -# Ethernet (10 or 100Mbit)
2301 +# MII PHY device drivers
2303 +# CONFIG_MARVELL_PHY is not set
2304 +# CONFIG_DAVICOM_PHY is not set
2305 +# CONFIG_QSEMI_PHY is not set
2306 +# CONFIG_LXT_PHY is not set
2307 +# CONFIG_CICADA_PHY is not set
2308 +# CONFIG_VITESSE_PHY is not set
2309 +# CONFIG_SMSC_PHY is not set
2310 +# CONFIG_BROADCOM_PHY is not set
2311 +# CONFIG_ICPLUS_PHY is not set
2312 +# CONFIG_FIXED_PHY is not set
2313 +# CONFIG_MDIO_BITBANG is not set
2314 CONFIG_NET_ETHERNET=y
2316 +# CONFIG_MII is not set
2318 +# CONFIG_IBM_NEW_EMAC_ZMII is not set
2319 +# CONFIG_IBM_NEW_EMAC_RGMII is not set
2320 +# CONFIG_IBM_NEW_EMAC_TAH is not set
2321 +# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
2322 +# CONFIG_B44 is not set
2323 # CONFIG_NETDEV_1000 is not set
2324 # CONFIG_NETDEV_10000 is not set
2326 @@ -423,27 +512,54 @@
2327 CONFIG_PPP_BSDCOMP=m
2328 # CONFIG_PPP_MPPE is not set
2329 # CONFIG_PPPOE is not set
2330 +# CONFIG_PPPOL2TP is not set
2331 # CONFIG_SLIP is not set
2333 # CONFIG_SHAPER is not set
2334 # CONFIG_NETCONSOLE is not set
2335 # CONFIG_NETPOLL is not set
2336 # CONFIG_NET_POLL_CONTROLLER is not set
2341 # CONFIG_ISDN is not set
2344 -# Telephony Support
2346 # CONFIG_PHONE is not set
2349 # Input device support
2351 -# CONFIG_INPUT is not set
2353 +# CONFIG_INPUT_FF_MEMLESS is not set
2354 +CONFIG_INPUT_POLLDEV=m
2357 +# Userland interfaces
2359 +CONFIG_INPUT_MOUSEDEV=m
2360 +CONFIG_INPUT_MOUSEDEV_PSAUX=y
2361 +CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
2362 +CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
2363 +# CONFIG_INPUT_JOYDEV is not set
2364 +CONFIG_INPUT_EVDEV=m
2365 +# CONFIG_INPUT_EVBUG is not set
2368 +# Input Device Drivers
2370 +CONFIG_INPUT_KEYBOARD=y
2371 +# CONFIG_KEYBOARD_ATKBD is not set
2372 +# CONFIG_KEYBOARD_SUNKBD is not set
2373 +# CONFIG_KEYBOARD_LKKBD is not set
2374 +# CONFIG_KEYBOARD_XTKBD is not set
2375 +# CONFIG_KEYBOARD_NEWTON is not set
2376 +# CONFIG_KEYBOARD_STOWAWAY is not set
2377 +CONFIG_KEYBOARD_GPIO=m
2378 +CONFIG_INPUT_MOUSE=y
2379 +# CONFIG_MOUSE_PS2 is not set
2380 +# CONFIG_MOUSE_SERIAL is not set
2381 +# CONFIG_MOUSE_VSXXXAA is not set
2382 +CONFIG_MOUSE_GPIO=m
2383 +# CONFIG_INPUT_JOYSTICK is not set
2384 +# CONFIG_INPUT_TABLET is not set
2385 +# CONFIG_INPUT_TOUCHSCREEN is not set
2386 +# CONFIG_INPUT_MISC is not set
2389 # Hardware I/O ports
2390 @@ -467,40 +583,94 @@
2392 CONFIG_SERIAL_ATMEL=y
2393 CONFIG_SERIAL_ATMEL_CONSOLE=y
2394 +CONFIG_SERIAL_ATMEL_PDC=y
2395 # CONFIG_SERIAL_ATMEL_TTYAT is not set
2396 CONFIG_SERIAL_CORE=y
2397 CONFIG_SERIAL_CORE_CONSOLE=y
2398 CONFIG_UNIX98_PTYS=y
2399 # CONFIG_LEGACY_PTYS is not set
2404 # CONFIG_IPMI_HANDLER is not set
2405 -# CONFIG_WATCHDOG is not set
2406 # CONFIG_HW_RANDOM is not set
2407 # CONFIG_RTC is not set
2408 # CONFIG_GEN_RTC is not set
2409 # CONFIG_R3964 is not set
2410 # CONFIG_RAW_DRIVER is not set
2411 +# CONFIG_TCG_TPM is not set
2413 +CONFIG_I2C_BOARDINFO=y
2414 +CONFIG_I2C_CHARDEV=m
2419 +CONFIG_I2C_ALGOBIT=m
2420 +# CONFIG_I2C_ALGOPCF is not set
2421 +# CONFIG_I2C_ALGOPCA is not set
2424 +# I2C Hardware Bus support
2426 +CONFIG_I2C_ATMELTWI=m
2428 +# CONFIG_I2C_OCORES is not set
2429 +# CONFIG_I2C_PARPORT_LIGHT is not set
2430 +# CONFIG_I2C_SIMTEC is not set
2431 +# CONFIG_I2C_TAOS_EVM is not set
2432 +# CONFIG_I2C_STUB is not set
2435 +# Miscellaneous I2C Chip support
2437 +# CONFIG_SENSORS_DS1337 is not set
2438 +# CONFIG_SENSORS_DS1374 is not set
2439 +# CONFIG_DS1682 is not set
2440 +# CONFIG_SENSORS_EEPROM is not set
2441 +# CONFIG_SENSORS_PCF8574 is not set
2442 +# CONFIG_SENSORS_PCA9539 is not set
2443 +# CONFIG_SENSORS_PCF8591 is not set
2444 +# CONFIG_SENSORS_MAX6875 is not set
2445 +# CONFIG_SENSORS_TSL2550 is not set
2446 +# CONFIG_I2C_DEBUG_CORE is not set
2447 +# CONFIG_I2C_DEBUG_ALGO is not set
2448 +# CONFIG_I2C_DEBUG_BUS is not set
2449 +# CONFIG_I2C_DEBUG_CHIP is not set
2455 -# CONFIG_TCG_TPM is not set
2456 -# CONFIG_I2C is not set
2458 +# CONFIG_SPI_DEBUG is not set
2459 +CONFIG_SPI_MASTER=y
2463 +# SPI Master Controller Drivers
2465 -# CONFIG_SPI is not set
2466 -# CONFIG_SPI_MASTER is not set
2468 +# CONFIG_SPI_BITBANG is not set
2471 -# Dallas's 1-wire bus
2472 +# SPI Protocol Masters
2474 +# CONFIG_SPI_AT25 is not set
2475 +CONFIG_SPI_SPIDEV=m
2476 +# CONFIG_SPI_TLE62X0 is not set
2477 # CONFIG_W1 is not set
2478 +# CONFIG_POWER_SUPPLY is not set
2479 # CONFIG_HWMON is not set
2481 +# CONFIG_WATCHDOG_NOWAYOUT is not set
2484 +# Watchdog Device Drivers
2486 +# CONFIG_SOFT_WATCHDOG is not set
2487 +CONFIG_AT32AP700X_WDT=y
2490 +# Sonics Silicon Backplane
2492 +CONFIG_SSB_POSSIBLE=y
2493 +# CONFIG_SSB is not set
2496 # Multifunction device drivers
2497 @@ -517,23 +687,104 @@
2501 -# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
2502 +# CONFIG_VGASTATE is not set
2503 +# CONFIG_VIDEO_OUTPUT_CONTROL is not set
2505 +# CONFIG_FIRMWARE_EDID is not set
2506 +# CONFIG_FB_DDC is not set
2507 +CONFIG_FB_CFB_FILLRECT=y
2508 +CONFIG_FB_CFB_COPYAREA=y
2509 +CONFIG_FB_CFB_IMAGEBLIT=y
2510 +# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
2511 +# CONFIG_FB_SYS_FILLRECT is not set
2512 +# CONFIG_FB_SYS_COPYAREA is not set
2513 +# CONFIG_FB_SYS_IMAGEBLIT is not set
2514 +# CONFIG_FB_SYS_FOPS is not set
2515 +CONFIG_FB_DEFERRED_IO=y
2516 +# CONFIG_FB_SVGALIB is not set
2517 +# CONFIG_FB_MACMODES is not set
2518 +# CONFIG_FB_BACKLIGHT is not set
2519 +# CONFIG_FB_MODE_HELPERS is not set
2520 +# CONFIG_FB_TILEBLITTING is not set
2523 +# Frame buffer hardware drivers
2525 +# CONFIG_FB_S1D13XXX is not set
2527 +# CONFIG_FB_VIRTUAL is not set
2528 +CONFIG_BACKLIGHT_LCD_SUPPORT=y
2529 +CONFIG_LCD_CLASS_DEVICE=y
2530 +CONFIG_LCD_LTV350QV=y
2531 +# CONFIG_BACKLIGHT_CLASS_DEVICE is not set
2534 # Display device support
2536 # CONFIG_DISPLAY_SUPPORT is not set
2537 -# CONFIG_VGASTATE is not set
2538 -# CONFIG_FB is not set
2539 +# CONFIG_LOGO is not set
2544 -# CONFIG_SOUND is not set
2548 +# Advanced Linux Sound Architecture
2553 +# CONFIG_SND_SEQUENCER is not set
2554 +CONFIG_SND_OSSEMUL=y
2555 +CONFIG_SND_MIXER_OSS=m
2556 +CONFIG_SND_PCM_OSS=m
2557 +CONFIG_SND_PCM_OSS_PLUGINS=y
2558 +# CONFIG_SND_DYNAMIC_MINORS is not set
2559 +# CONFIG_SND_SUPPORT_OLD_API is not set
2560 +# CONFIG_SND_VERBOSE_PROCFS is not set
2561 +# CONFIG_SND_VERBOSE_PRINTK is not set
2562 +# CONFIG_SND_DEBUG is not set
2567 +CONFIG_SND_AC97_CODEC=m
2568 +# CONFIG_SND_DUMMY is not set
2569 +# CONFIG_SND_MTPAV is not set
2570 +# CONFIG_SND_SERIAL_U16550 is not set
2571 +# CONFIG_SND_MPU401 is not set
2576 +CONFIG_SND_ATMEL_AC97=m
2582 +CONFIG_SND_AT73C213=m
2583 +CONFIG_SND_AT73C213_TARGET_BITRATE=48000
2586 +# System on Chip audio support
2588 +# CONFIG_SND_SOC is not set
2591 +# SoC Audio support for SuperH
2595 +# Open Sound System
2597 +CONFIG_SOUND_PRIME=m
2598 +# CONFIG_SOUND_MSNDCLAS is not set
2599 +# CONFIG_SOUND_MSNDPIN is not set
2600 +CONFIG_SOUND_AT32_ABDAC=m
2602 +# CONFIG_HID_SUPPORT is not set
2603 +CONFIG_USB_SUPPORT=y
2604 # CONFIG_USB_ARCH_HAS_HCD is not set
2605 # CONFIG_USB_ARCH_HAS_OHCI is not set
2606 # CONFIG_USB_ARCH_HAS_EHCI is not set
2607 @@ -545,63 +796,137 @@
2609 # USB Gadget Support
2611 -# CONFIG_USB_GADGET is not set
2612 -# CONFIG_MMC is not set
2617 -# CONFIG_NEW_LEDS is not set
2618 +CONFIG_USB_GADGET=y
2619 +# CONFIG_USB_GADGET_DEBUG is not set
2620 +# CONFIG_USB_GADGET_DEBUG_FILES is not set
2621 +# CONFIG_USB_GADGET_DEBUG_FS is not set
2622 +CONFIG_USB_GADGET_SELECTED=y
2623 +# CONFIG_USB_GADGET_AMD5536UDC is not set
2624 +CONFIG_USB_GADGET_ATMEL_USBA=y
2625 +CONFIG_USB_ATMEL_USBA=y
2626 +# CONFIG_USB_GADGET_FSL_USB2 is not set
2627 +# CONFIG_USB_GADGET_NET2280 is not set
2628 +# CONFIG_USB_GADGET_PXA2XX is not set
2629 +# CONFIG_USB_GADGET_M66592 is not set
2630 +# CONFIG_USB_GADGET_GOKU is not set
2631 +# CONFIG_USB_GADGET_LH7A40X is not set
2632 +# CONFIG_USB_GADGET_OMAP is not set
2633 +# CONFIG_USB_GADGET_S3C2410 is not set
2634 +# CONFIG_USB_GADGET_AT91 is not set
2635 +# CONFIG_USB_GADGET_DUMMY_HCD is not set
2636 +CONFIG_USB_GADGET_DUALSPEED=y
2639 +CONFIG_USB_ETH_RNDIS=y
2640 +CONFIG_USB_GADGETFS=m
2641 +CONFIG_USB_FILE_STORAGE=m
2642 +# CONFIG_USB_FILE_STORAGE_TEST is not set
2643 +CONFIG_USB_G_SERIAL=m
2644 +# CONFIG_USB_MIDI_GADGET is not set
2646 +# CONFIG_MMC_DEBUG is not set
2647 +# CONFIG_MMC_UNSAFE_RESUME is not set
2650 +# MMC/SD Card Drivers
2653 +# CONFIG_MMC_BLOCK_BOUNCE is not set
2654 +# CONFIG_SDIO_UART is not set
2657 +# MMC/SD Host Controller Drivers
2659 +CONFIG_MMC_ATMELMCI=y
2662 +CONFIG_LEDS_CLASS=m
2667 +CONFIG_LEDS_ATMEL_PWM=m
2673 +CONFIG_LEDS_TRIGGERS=y
2674 +CONFIG_LEDS_TRIGGER_TIMER=m
2675 +CONFIG_LEDS_TRIGGER_HEARTBEAT=m
2678 +CONFIG_RTC_HCTOSYS=y
2679 +CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
2680 +# CONFIG_RTC_DEBUG is not set
2683 -# InfiniBand support
2686 +CONFIG_RTC_INTF_SYSFS=y
2687 +CONFIG_RTC_INTF_PROC=y
2688 +CONFIG_RTC_INTF_DEV=y
2689 +# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
2690 +# CONFIG_RTC_DRV_TEST is not set
2693 -# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
2696 +# CONFIG_RTC_DRV_DS1307 is not set
2697 +# CONFIG_RTC_DRV_DS1374 is not set
2698 +# CONFIG_RTC_DRV_DS1672 is not set
2699 +# CONFIG_RTC_DRV_MAX6900 is not set
2700 +# CONFIG_RTC_DRV_RS5C372 is not set
2701 +# CONFIG_RTC_DRV_ISL1208 is not set
2702 +# CONFIG_RTC_DRV_X1205 is not set
2703 +# CONFIG_RTC_DRV_PCF8563 is not set
2704 +# CONFIG_RTC_DRV_PCF8583 is not set
2705 +# CONFIG_RTC_DRV_M41T80 is not set
2711 -# CONFIG_RTC_CLASS is not set
2712 +# CONFIG_RTC_DRV_RS5C348 is not set
2713 +# CONFIG_RTC_DRV_MAX6902 is not set
2716 -# DMA Engine support
2717 +# Platform RTC drivers
2719 -# CONFIG_DMA_ENGINE is not set
2720 +# CONFIG_RTC_DRV_DS1553 is not set
2721 +# CONFIG_RTC_DRV_STK17TA8 is not set
2722 +# CONFIG_RTC_DRV_DS1742 is not set
2723 +# CONFIG_RTC_DRV_M48T86 is not set
2724 +# CONFIG_RTC_DRV_M48T59 is not set
2725 +# CONFIG_RTC_DRV_V3020 is not set
2729 +# on-CPU RTC drivers
2731 +CONFIG_RTC_DRV_AT32AP700X=y
2737 +# CONFIG_UIO is not set
2744 # CONFIG_EXT2_FS_XATTR is not set
2745 # CONFIG_EXT2_FS_XIP is not set
2746 -# CONFIG_EXT3_FS is not set
2748 +# CONFIG_EXT3_FS_XATTR is not set
2749 # CONFIG_EXT4DEV_FS is not set
2751 +# CONFIG_JBD_DEBUG is not set
2752 # CONFIG_REISERFS_FS is not set
2753 # CONFIG_JFS_FS is not set
2754 # CONFIG_FS_POSIX_ACL is not set
2755 # CONFIG_XFS_FS is not set
2756 # CONFIG_GFS2_FS is not set
2757 # CONFIG_OCFS2_FS is not set
2759 +# CONFIG_MINIX_FS is not set
2760 # CONFIG_ROMFS_FS is not set
2762 CONFIG_INOTIFY_USER=y
2764 # CONFIG_DNOTIFY is not set
2765 # CONFIG_AUTOFS_FS is not set
2766 # CONFIG_AUTOFS4_FS is not set
2767 -# CONFIG_FUSE_FS is not set
2771 # CD-ROM/DVD Filesystems
2774 # CONFIG_TMPFS_POSIX_ACL is not set
2775 # CONFIG_HUGETLB_PAGE is not set
2777 -CONFIG_CONFIGFS_FS=m
2778 +CONFIG_CONFIGFS_FS=y
2781 # Miscellaneous filesystems
2782 @@ -652,11 +976,12 @@
2783 # CONFIG_EFS_FS is not set
2785 CONFIG_JFFS2_FS_DEBUG=0
2786 -CONFIG_JFFS2_FS_WRITEBUFFER=y
2787 +# CONFIG_JFFS2_FS_WRITEBUFFER is not set
2788 # CONFIG_JFFS2_SUMMARY is not set
2789 # CONFIG_JFFS2_FS_XATTR is not set
2790 # CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
2792 +# CONFIG_JFFS2_LZO is not set
2793 CONFIG_JFFS2_RTIME=y
2794 # CONFIG_JFFS2_RUBIN is not set
2795 # CONFIG_CRAMFS is not set
2796 @@ -665,10 +990,7 @@
2797 # CONFIG_QNX4FS_FS is not set
2798 # CONFIG_SYSV_FS is not set
2799 # CONFIG_UFS_FS is not set
2802 -# Network File Systems
2804 +CONFIG_NETWORK_FILESYSTEMS=y
2807 # CONFIG_NFS_V3_ACL is not set
2808 @@ -688,17 +1010,12 @@
2809 # CONFIG_NCP_FS is not set
2810 # CONFIG_CODA_FS is not set
2811 # CONFIG_AFS_FS is not set
2812 -# CONFIG_9P_FS is not set
2817 # CONFIG_PARTITION_ADVANCED is not set
2818 CONFIG_MSDOS_PARTITION=y
2821 -# Native Language Support
2824 CONFIG_NLS_DEFAULT="iso8859-1"
2825 CONFIG_NLS_CODEPAGE_437=m
2826 @@ -739,17 +1056,18 @@
2827 # CONFIG_NLS_KOI8_R is not set
2828 # CONFIG_NLS_KOI8_U is not set
2832 -# Distributed Lock Manager
2834 # CONFIG_DLM is not set
2835 +CONFIG_INSTRUMENTATION=y
2839 +# CONFIG_MARKERS is not set
2844 -CONFIG_TRACE_IRQFLAGS_SUPPORT=y
2845 # CONFIG_PRINTK_TIME is not set
2846 +CONFIG_ENABLE_WARN_DEPRECATED=y
2847 CONFIG_ENABLE_MUST_CHECK=y
2848 CONFIG_MAGIC_SYSRQ=y
2849 # CONFIG_UNUSED_SYMBOLS is not set
2850 @@ -758,12 +1076,17 @@
2851 CONFIG_DEBUG_KERNEL=y
2852 # CONFIG_DEBUG_SHIRQ is not set
2853 CONFIG_DETECT_SOFTLOCKUP=y
2854 +CONFIG_SCHED_DEBUG=y
2855 # CONFIG_SCHEDSTATS is not set
2856 # CONFIG_TIMER_STATS is not set
2857 +# CONFIG_SLUB_DEBUG_ON is not set
2858 # CONFIG_DEBUG_RT_MUTEXES is not set
2859 # CONFIG_RT_MUTEX_TESTER is not set
2860 # CONFIG_DEBUG_SPINLOCK is not set
2861 # CONFIG_DEBUG_MUTEXES is not set
2862 +# CONFIG_DEBUG_LOCK_ALLOC is not set
2863 +# CONFIG_PROVE_LOCKING is not set
2864 +# CONFIG_LOCK_STAT is not set
2865 # CONFIG_DEBUG_SPINLOCK_SLEEP is not set
2866 # CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
2867 # CONFIG_DEBUG_KOBJECT is not set
2868 @@ -771,22 +1094,63 @@
2869 # CONFIG_DEBUG_INFO is not set
2870 # CONFIG_DEBUG_VM is not set
2871 # CONFIG_DEBUG_LIST is not set
2872 +# CONFIG_DEBUG_SG is not set
2873 CONFIG_FRAME_POINTER=y
2874 CONFIG_FORCED_INLINING=y
2875 +# CONFIG_BOOT_PRINTK_DELAY is not set
2876 # CONFIG_RCU_TORTURE_TEST is not set
2877 +# CONFIG_LKDTM is not set
2878 # CONFIG_FAULT_INJECTION is not set
2879 -# CONFIG_KPROBES is not set
2880 +# CONFIG_SAMPLES is not set
2885 # CONFIG_KEYS is not set
2886 # CONFIG_SECURITY is not set
2889 -# Cryptographic options
2891 -# CONFIG_CRYPTO is not set
2892 +# CONFIG_SECURITY_FILE_CAPABILITIES is not set
2894 +CONFIG_CRYPTO_ALGAPI=m
2895 +CONFIG_CRYPTO_BLKCIPHER=m
2896 +CONFIG_CRYPTO_HASH=m
2897 +CONFIG_CRYPTO_MANAGER=m
2898 +CONFIG_CRYPTO_HMAC=m
2899 +# CONFIG_CRYPTO_XCBC is not set
2900 +# CONFIG_CRYPTO_NULL is not set
2901 +# CONFIG_CRYPTO_MD4 is not set
2902 +CONFIG_CRYPTO_MD5=m
2903 +CONFIG_CRYPTO_SHA1=m
2904 +# CONFIG_CRYPTO_SHA256 is not set
2905 +# CONFIG_CRYPTO_SHA512 is not set
2906 +# CONFIG_CRYPTO_WP512 is not set
2907 +# CONFIG_CRYPTO_TGR192 is not set
2908 +# CONFIG_CRYPTO_GF128MUL is not set
2909 +# CONFIG_CRYPTO_ECB is not set
2910 +CONFIG_CRYPTO_CBC=m
2911 +# CONFIG_CRYPTO_PCBC is not set
2912 +# CONFIG_CRYPTO_LRW is not set
2913 +# CONFIG_CRYPTO_XTS is not set
2914 +# CONFIG_CRYPTO_CRYPTD is not set
2915 +CONFIG_CRYPTO_DES=m
2916 +# CONFIG_CRYPTO_FCRYPT is not set
2917 +# CONFIG_CRYPTO_BLOWFISH is not set
2918 +# CONFIG_CRYPTO_TWOFISH is not set
2919 +# CONFIG_CRYPTO_SERPENT is not set
2920 +# CONFIG_CRYPTO_AES is not set
2921 +# CONFIG_CRYPTO_CAST5 is not set
2922 +# CONFIG_CRYPTO_CAST6 is not set
2923 +# CONFIG_CRYPTO_TEA is not set
2924 +# CONFIG_CRYPTO_ARC4 is not set
2925 +# CONFIG_CRYPTO_KHAZAD is not set
2926 +# CONFIG_CRYPTO_ANUBIS is not set
2927 +# CONFIG_CRYPTO_SEED is not set
2928 +CONFIG_CRYPTO_DEFLATE=m
2929 +# CONFIG_CRYPTO_MICHAEL_MIC is not set
2930 +# CONFIG_CRYPTO_CRC32C is not set
2931 +# CONFIG_CRYPTO_CAMELLIA is not set
2932 +# CONFIG_CRYPTO_TEST is not set
2933 +# CONFIG_CRYPTO_AUTHENC is not set
2934 +# CONFIG_CRYPTO_HW is not set
2938 @@ -794,10 +1158,10 @@
2941 # CONFIG_CRC16 is not set
2942 -# CONFIG_CRC_ITU_T is not set
2946 # CONFIG_LIBCRC32C is not set
2947 -CONFIG_AUDIT_GENERIC=y
2948 CONFIG_ZLIB_INFLATE=y
2949 CONFIG_ZLIB_DEFLATE=y
2952 +++ b/arch/avr32/configs/atstk1003_defconfig
2955 +# Automatically generated make config: don't edit
2956 +# Linux kernel version: 2.6.24
2957 +# Thu Mar 6 12:50:27 2008
2960 +CONFIG_GENERIC_GPIO=y
2961 +CONFIG_GENERIC_HARDIRQS=y
2962 +CONFIG_STACKTRACE_SUPPORT=y
2963 +CONFIG_LOCKDEP_SUPPORT=y
2964 +CONFIG_TRACE_IRQFLAGS_SUPPORT=y
2965 +CONFIG_HARDIRQS_SW_RESEND=y
2966 +CONFIG_GENERIC_IRQ_PROBE=y
2967 +CONFIG_RWSEM_GENERIC_SPINLOCK=y
2968 +CONFIG_GENERIC_TIME=y
2969 +CONFIG_GENERIC_CLOCKEVENTS=y
2970 +# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
2971 +# CONFIG_ARCH_HAS_ILOG2_U32 is not set
2972 +# CONFIG_ARCH_HAS_ILOG2_U64 is not set
2973 +CONFIG_ARCH_SUPPORTS_OPROFILE=y
2974 +CONFIG_GENERIC_HWEIGHT=y
2975 +CONFIG_GENERIC_CALIBRATE_DELAY=y
2976 +CONFIG_GENERIC_BUG=y
2977 +CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
2982 +CONFIG_EXPERIMENTAL=y
2983 +CONFIG_BROKEN_ON_SMP=y
2984 +CONFIG_INIT_ENV_ARG_LIMIT=32
2985 +CONFIG_LOCALVERSION=""
2986 +# CONFIG_LOCALVERSION_AUTO is not set
2989 +CONFIG_SYSVIPC_SYSCTL=y
2990 +CONFIG_POSIX_MQUEUE=y
2991 +CONFIG_BSD_PROCESS_ACCT=y
2992 +CONFIG_BSD_PROCESS_ACCT_V3=y
2994 +CONFIG_TASK_DELAY_ACCT=y
2995 +# CONFIG_TASK_XACCT is not set
2996 +# CONFIG_USER_NS is not set
2997 +# CONFIG_PID_NS is not set
2999 +# CONFIG_IKCONFIG is not set
3000 +CONFIG_LOG_BUF_SHIFT=14
3001 +# CONFIG_CGROUPS is not set
3002 +CONFIG_FAIR_GROUP_SCHED=y
3003 +CONFIG_FAIR_USER_SCHED=y
3004 +# CONFIG_FAIR_CGROUP_SCHED is not set
3005 +CONFIG_SYSFS_DEPRECATED=y
3007 +CONFIG_BLK_DEV_INITRD=y
3008 +CONFIG_INITRAMFS_SOURCE=""
3009 +CONFIG_CC_OPTIMIZE_FOR_SIZE=y
3012 +# CONFIG_SYSCTL_SYSCALL is not set
3014 +# CONFIG_KALLSYMS_ALL is not set
3015 +# CONFIG_KALLSYMS_EXTRA_PASS is not set
3020 +# CONFIG_BASE_FULL is not set
3022 +CONFIG_ANON_INODES=y
3027 +CONFIG_VM_EVENT_COUNTERS=y
3028 +# CONFIG_SLUB_DEBUG is not set
3029 +# CONFIG_SLAB is not set
3031 +# CONFIG_SLOB is not set
3033 +CONFIG_RT_MUTEXES=y
3034 +# CONFIG_TINY_SHMEM is not set
3035 +CONFIG_BASE_SMALL=1
3037 +CONFIG_MODULE_UNLOAD=y
3038 +# CONFIG_MODULE_FORCE_UNLOAD is not set
3039 +# CONFIG_MODVERSIONS is not set
3040 +# CONFIG_MODULE_SRCVERSION_ALL is not set
3041 +# CONFIG_KMOD is not set
3043 +# CONFIG_LBD is not set
3044 +# CONFIG_BLK_DEV_IO_TRACE is not set
3045 +# CONFIG_LSF is not set
3046 +# CONFIG_BLK_DEV_BSG is not set
3051 +CONFIG_IOSCHED_NOOP=y
3052 +# CONFIG_IOSCHED_AS is not set
3053 +# CONFIG_IOSCHED_DEADLINE is not set
3054 +CONFIG_IOSCHED_CFQ=y
3055 +# CONFIG_DEFAULT_AS is not set
3056 +# CONFIG_DEFAULT_DEADLINE is not set
3057 +CONFIG_DEFAULT_CFQ=y
3058 +# CONFIG_DEFAULT_NOOP is not set
3059 +CONFIG_DEFAULT_IOSCHED="cfq"
3062 +# System Type and features
3064 +CONFIG_TICK_ONESHOT=y
3066 +CONFIG_HIGH_RES_TIMERS=y
3067 +CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
3068 +CONFIG_SUBARCH_AVR32B=y
3070 +CONFIG_PERFORMANCE_COUNTERS=y
3071 +CONFIG_PLATFORM_AT32AP=y
3072 +CONFIG_CPU_AT32AP700X=y
3073 +CONFIG_CPU_AT32AP7001=y
3074 +CONFIG_BOARD_ATSTK1000=y
3075 +# CONFIG_BOARD_ATNGW100 is not set
3076 +# CONFIG_BOARD_ATSTK1002 is not set
3077 +CONFIG_BOARD_ATSTK1003=y
3078 +# CONFIG_BOARD_ATSTK1004 is not set
3079 +# CONFIG_BOARD_ATSTK100X_CUSTOM is not set
3080 +# CONFIG_BOARD_ATSTK100X_SPI1 is not set
3081 +# CONFIG_BOARD_ATSTK1000_J2_LED is not set
3082 +# CONFIG_BOARD_ATSTK1000_J2_LED8 is not set
3083 +# CONFIG_BOARD_ATSTK1000_J2_RGB is not set
3084 +CONFIG_BOARD_ATSTK1000_EXTDAC=y
3085 +# CONFIG_BOARD_ATSTK100X_ENABLE_AC97 is not set
3086 +# CONFIG_BOARD_ATSTK1000_CF_HACKS is not set
3087 +# CONFIG_BOARD_ATSTK100X_ENABLE_PSIF is not set
3088 +CONFIG_LOADER_U_BOOT=y
3091 +# Atmel AVR32 AP options
3093 +# CONFIG_AP700X_32_BIT_SMC is not set
3094 +CONFIG_AP700X_16_BIT_SMC=y
3095 +# CONFIG_AP700X_8_BIT_SMC is not set
3097 +CONFIG_LOAD_ADDRESS=0x10000000
3098 +CONFIG_ENTRY_ADDRESS=0x90000000
3099 +CONFIG_PHYS_OFFSET=0x10000000
3100 +CONFIG_PREEMPT_NONE=y
3101 +# CONFIG_PREEMPT_VOLUNTARY is not set
3102 +# CONFIG_PREEMPT is not set
3103 +# CONFIG_HAVE_ARCH_BOOTMEM_NODE is not set
3104 +# CONFIG_ARCH_HAVE_MEMORY_PRESENT is not set
3105 +# CONFIG_NEED_NODE_MEMMAP_SIZE is not set
3106 +CONFIG_ARCH_FLATMEM_ENABLE=y
3107 +# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
3108 +# CONFIG_ARCH_SPARSEMEM_ENABLE is not set
3109 +CONFIG_SELECT_MEMORY_MODEL=y
3110 +CONFIG_FLATMEM_MANUAL=y
3111 +# CONFIG_DISCONTIGMEM_MANUAL is not set
3112 +# CONFIG_SPARSEMEM_MANUAL is not set
3114 +CONFIG_FLAT_NODE_MEM_MAP=y
3115 +# CONFIG_SPARSEMEM_STATIC is not set
3116 +# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
3117 +CONFIG_SPLIT_PTLOCK_CPUS=4
3118 +# CONFIG_RESOURCES_64BIT is not set
3119 +CONFIG_ZONE_DMA_FLAG=0
3120 +CONFIG_VIRT_TO_BUS=y
3121 +# CONFIG_OWNERSHIP_TRACE is not set
3122 +CONFIG_NMI_DEBUGGING=y
3124 +# CONFIG_HZ_100 is not set
3126 +# CONFIG_HZ_300 is not set
3127 +# CONFIG_HZ_1000 is not set
3132 +# Power management options
3136 +# CPU Frequency scaling
3139 +CONFIG_CPU_FREQ_TABLE=y
3140 +# CONFIG_CPU_FREQ_DEBUG is not set
3141 +# CONFIG_CPU_FREQ_STAT is not set
3142 +CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
3143 +# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
3144 +# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
3145 +# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
3146 +CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
3147 +# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
3148 +CONFIG_CPU_FREQ_GOV_USERSPACE=y
3149 +CONFIG_CPU_FREQ_GOV_ONDEMAND=y
3150 +# CONFIG_CPU_FREQ_GOV_CONSERVATIVE is not set
3151 +CONFIG_CPU_FREQ_AT32AP=y
3156 +# CONFIG_ARCH_SUPPORTS_MSI is not set
3157 +# CONFIG_PCCARD is not set
3160 +# Executable file formats
3162 +CONFIG_BINFMT_ELF=y
3163 +# CONFIG_BINFMT_MISC is not set
3171 +# Networking options
3174 +CONFIG_PACKET_MMAP=y
3176 +# CONFIG_NET_KEY is not set
3178 +# CONFIG_IP_MULTICAST is not set
3179 +# CONFIG_IP_ADVANCED_ROUTER is not set
3180 +CONFIG_IP_FIB_HASH=y
3181 +# CONFIG_IP_PNP is not set
3182 +# CONFIG_NET_IPIP is not set
3183 +# CONFIG_NET_IPGRE is not set
3184 +# CONFIG_ARPD is not set
3185 +# CONFIG_SYN_COOKIES is not set
3186 +# CONFIG_INET_AH is not set
3187 +# CONFIG_INET_ESP is not set
3188 +# CONFIG_INET_IPCOMP is not set
3189 +# CONFIG_INET_XFRM_TUNNEL is not set
3190 +# CONFIG_INET_TUNNEL is not set
3191 +# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
3192 +# CONFIG_INET_XFRM_MODE_TUNNEL is not set
3193 +# CONFIG_INET_XFRM_MODE_BEET is not set
3194 +# CONFIG_INET_LRO is not set
3195 +# CONFIG_INET_DIAG is not set
3196 +# CONFIG_TCP_CONG_ADVANCED is not set
3197 +CONFIG_TCP_CONG_CUBIC=y
3198 +CONFIG_DEFAULT_TCP_CONG="cubic"
3199 +# CONFIG_TCP_MD5SIG is not set
3200 +# CONFIG_IPV6 is not set
3201 +# CONFIG_INET6_XFRM_TUNNEL is not set
3202 +# CONFIG_INET6_TUNNEL is not set
3203 +# CONFIG_NETWORK_SECMARK is not set
3204 +# CONFIG_NETFILTER is not set
3205 +# CONFIG_IP_DCCP is not set
3206 +# CONFIG_IP_SCTP is not set
3207 +# CONFIG_TIPC is not set
3208 +# CONFIG_ATM is not set
3209 +# CONFIG_BRIDGE is not set
3210 +# CONFIG_VLAN_8021Q is not set
3211 +# CONFIG_DECNET is not set
3212 +# CONFIG_LLC2 is not set
3213 +# CONFIG_IPX is not set
3214 +# CONFIG_ATALK is not set
3215 +# CONFIG_X25 is not set
3216 +# CONFIG_LAPB is not set
3217 +# CONFIG_ECONET is not set
3218 +# CONFIG_WAN_ROUTER is not set
3219 +# CONFIG_NET_SCHED is not set
3224 +# CONFIG_NET_PKTGEN is not set
3225 +# CONFIG_NET_TCPPROBE is not set
3226 +# CONFIG_HAMRADIO is not set
3227 +# CONFIG_IRDA is not set
3228 +# CONFIG_BT is not set
3229 +# CONFIG_AF_RXRPC is not set
3234 +# CONFIG_CFG80211 is not set
3235 +# CONFIG_WIRELESS_EXT is not set
3236 +# CONFIG_MAC80211 is not set
3237 +# CONFIG_IEEE80211 is not set
3238 +# CONFIG_RFKILL is not set
3239 +# CONFIG_NET_9P is not set
3246 +# Generic Driver Options
3248 +CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
3249 +CONFIG_STANDALONE=y
3250 +# CONFIG_PREVENT_FIRMWARE_BUILD is not set
3251 +# CONFIG_FW_LOADER is not set
3252 +# CONFIG_DEBUG_DRIVER is not set
3253 +# CONFIG_DEBUG_DEVRES is not set
3254 +# CONFIG_SYS_HYPERVISOR is not set
3255 +# CONFIG_CONNECTOR is not set
3257 +# CONFIG_MTD_DEBUG is not set
3258 +# CONFIG_MTD_CONCAT is not set
3259 +CONFIG_MTD_PARTITIONS=y
3260 +# CONFIG_MTD_REDBOOT_PARTS is not set
3261 +CONFIG_MTD_CMDLINE_PARTS=y
3264 +# User Modules And Translation Layers
3267 +CONFIG_MTD_BLKDEVS=y
3269 +# CONFIG_FTL is not set
3270 +# CONFIG_NFTL is not set
3271 +# CONFIG_INFTL is not set
3272 +# CONFIG_RFD_FTL is not set
3273 +# CONFIG_SSFDC is not set
3274 +# CONFIG_MTD_OOPS is not set
3277 +# RAM/ROM/Flash chip drivers
3280 +# CONFIG_MTD_JEDECPROBE is not set
3281 +CONFIG_MTD_GEN_PROBE=y
3282 +# CONFIG_MTD_CFI_ADV_OPTIONS is not set
3283 +CONFIG_MTD_MAP_BANK_WIDTH_1=y
3284 +CONFIG_MTD_MAP_BANK_WIDTH_2=y
3285 +CONFIG_MTD_MAP_BANK_WIDTH_4=y
3286 +# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
3287 +# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
3288 +# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
3289 +CONFIG_MTD_CFI_I1=y
3290 +CONFIG_MTD_CFI_I2=y
3291 +# CONFIG_MTD_CFI_I4 is not set
3292 +# CONFIG_MTD_CFI_I8 is not set
3293 +# CONFIG_MTD_CFI_INTELEXT is not set
3294 +CONFIG_MTD_CFI_AMDSTD=y
3295 +# CONFIG_MTD_CFI_STAA is not set
3296 +CONFIG_MTD_CFI_UTIL=y
3297 +# CONFIG_MTD_RAM is not set
3298 +# CONFIG_MTD_ROM is not set
3299 +# CONFIG_MTD_ABSENT is not set
3302 +# Mapping drivers for chip access
3304 +# CONFIG_MTD_COMPLEX_MAPPINGS is not set
3305 +CONFIG_MTD_PHYSMAP=y
3306 +CONFIG_MTD_PHYSMAP_START=0x8000000
3307 +CONFIG_MTD_PHYSMAP_LEN=0x0
3308 +CONFIG_MTD_PHYSMAP_BANKWIDTH=2
3309 +# CONFIG_MTD_PLATRAM is not set
3312 +# Self-contained MTD device drivers
3314 +CONFIG_MTD_DATAFLASH=m
3315 +CONFIG_MTD_M25P80=m
3316 +# CONFIG_MTD_SLRAM is not set
3317 +# CONFIG_MTD_PHRAM is not set
3318 +# CONFIG_MTD_MTDRAM is not set
3319 +# CONFIG_MTD_BLOCK2MTD is not set
3322 +# Disk-On-Chip Device Drivers
3324 +# CONFIG_MTD_DOC2000 is not set
3325 +# CONFIG_MTD_DOC2001 is not set
3326 +# CONFIG_MTD_DOC2001PLUS is not set
3327 +# CONFIG_MTD_NAND is not set
3328 +# CONFIG_MTD_ONENAND is not set
3331 +# UBI - Unsorted block images
3333 +# CONFIG_MTD_UBI is not set
3334 +# CONFIG_PARPORT is not set
3336 +# CONFIG_BLK_DEV_COW_COMMON is not set
3337 +CONFIG_BLK_DEV_LOOP=m
3338 +# CONFIG_BLK_DEV_CRYPTOLOOP is not set
3339 +CONFIG_BLK_DEV_NBD=m
3340 +CONFIG_BLK_DEV_RAM=m
3341 +CONFIG_BLK_DEV_RAM_COUNT=16
3342 +CONFIG_BLK_DEV_RAM_SIZE=4096
3343 +CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
3344 +# CONFIG_CDROM_PKTCDVD is not set
3345 +# CONFIG_ATA_OVER_ETH is not set
3346 +CONFIG_MISC_DEVICES=y
3348 +CONFIG_ATMEL_TCLIB=y
3349 +CONFIG_ATMEL_TCB_CLKSRC=y
3350 +CONFIG_ATMEL_TCB_CLKSRC_BLOCK=0
3351 +# CONFIG_EEPROM_93CX6 is not set
3353 +# CONFIG_IDE is not set
3356 +# SCSI device support
3358 +# CONFIG_RAID_ATTRS is not set
3361 +# CONFIG_SCSI_TGT is not set
3362 +# CONFIG_SCSI_NETLINK is not set
3363 +# CONFIG_SCSI_PROC_FS is not set
3366 +# SCSI support type (disk, tape, CD-ROM)
3368 +CONFIG_BLK_DEV_SD=m
3369 +# CONFIG_CHR_DEV_ST is not set
3370 +# CONFIG_CHR_DEV_OSST is not set
3371 +CONFIG_BLK_DEV_SR=m
3372 +# CONFIG_BLK_DEV_SR_VENDOR is not set
3373 +# CONFIG_CHR_DEV_SG is not set
3374 +# CONFIG_CHR_DEV_SCH is not set
3377 +# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
3379 +# CONFIG_SCSI_MULTI_LUN is not set
3380 +# CONFIG_SCSI_CONSTANTS is not set
3381 +# CONFIG_SCSI_LOGGING is not set
3382 +# CONFIG_SCSI_SCAN_ASYNC is not set
3383 +CONFIG_SCSI_WAIT_SCAN=m
3388 +# CONFIG_SCSI_SPI_ATTRS is not set
3389 +# CONFIG_SCSI_FC_ATTRS is not set
3390 +# CONFIG_SCSI_ISCSI_ATTRS is not set
3391 +# CONFIG_SCSI_SAS_LIBSAS is not set
3392 +# CONFIG_SCSI_SRP_ATTRS is not set
3393 +CONFIG_SCSI_LOWLEVEL=y
3394 +# CONFIG_ISCSI_TCP is not set
3395 +# CONFIG_SCSI_DEBUG is not set
3397 +# CONFIG_ATA_NONSTANDARD is not set
3399 +# CONFIG_PATA_PLATFORM is not set
3400 +# CONFIG_MD is not set
3401 +CONFIG_NETDEVICES=y
3402 +# CONFIG_NETDEVICES_MULTIQUEUE is not set
3403 +# CONFIG_DUMMY is not set
3404 +# CONFIG_BONDING is not set
3405 +# CONFIG_MACVLAN is not set
3406 +# CONFIG_EQUALIZER is not set
3407 +# CONFIG_TUN is not set
3408 +# CONFIG_VETH is not set
3409 +# CONFIG_NET_ETHERNET is not set
3410 +# CONFIG_NETDEV_1000 is not set
3411 +# CONFIG_NETDEV_10000 is not set
3416 +# CONFIG_WLAN_PRE80211 is not set
3417 +# CONFIG_WLAN_80211 is not set
3418 +# CONFIG_WAN is not set
3420 +# CONFIG_PPP_MULTILINK is not set
3421 +# CONFIG_PPP_FILTER is not set
3423 +# CONFIG_PPP_SYNC_TTY is not set
3424 +CONFIG_PPP_DEFLATE=m
3425 +CONFIG_PPP_BSDCOMP=m
3426 +# CONFIG_PPP_MPPE is not set
3427 +# CONFIG_PPPOE is not set
3428 +# CONFIG_PPPOL2TP is not set
3429 +# CONFIG_SLIP is not set
3431 +# CONFIG_SHAPER is not set
3432 +# CONFIG_NETCONSOLE is not set
3433 +# CONFIG_NETPOLL is not set
3434 +# CONFIG_NET_POLL_CONTROLLER is not set
3435 +# CONFIG_ISDN is not set
3436 +# CONFIG_PHONE is not set
3439 +# Input device support
3442 +# CONFIG_INPUT_FF_MEMLESS is not set
3443 +CONFIG_INPUT_POLLDEV=m
3446 +# Userland interfaces
3448 +CONFIG_INPUT_MOUSEDEV=m
3449 +CONFIG_INPUT_MOUSEDEV_PSAUX=y
3450 +CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
3451 +CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
3452 +# CONFIG_INPUT_JOYDEV is not set
3453 +# CONFIG_INPUT_EVDEV is not set
3454 +# CONFIG_INPUT_EVBUG is not set
3457 +# Input Device Drivers
3459 +CONFIG_INPUT_KEYBOARD=y
3460 +# CONFIG_KEYBOARD_ATKBD is not set
3461 +# CONFIG_KEYBOARD_SUNKBD is not set
3462 +# CONFIG_KEYBOARD_LKKBD is not set
3463 +# CONFIG_KEYBOARD_XTKBD is not set
3464 +# CONFIG_KEYBOARD_NEWTON is not set
3465 +# CONFIG_KEYBOARD_STOWAWAY is not set
3466 +CONFIG_KEYBOARD_GPIO=m
3467 +CONFIG_INPUT_MOUSE=y
3468 +# CONFIG_MOUSE_PS2 is not set
3469 +# CONFIG_MOUSE_SERIAL is not set
3470 +# CONFIG_MOUSE_VSXXXAA is not set
3471 +CONFIG_MOUSE_GPIO=m
3472 +# CONFIG_INPUT_JOYSTICK is not set
3473 +# CONFIG_INPUT_TABLET is not set
3474 +# CONFIG_INPUT_TOUCHSCREEN is not set
3475 +# CONFIG_INPUT_MISC is not set
3478 +# Hardware I/O ports
3480 +# CONFIG_SERIO is not set
3481 +# CONFIG_GAMEPORT is not set
3484 +# Character devices
3486 +# CONFIG_VT is not set
3487 +# CONFIG_SERIAL_NONSTANDARD is not set
3492 +# CONFIG_SERIAL_8250 is not set
3495 +# Non-8250 serial port support
3497 +CONFIG_SERIAL_ATMEL=y
3498 +CONFIG_SERIAL_ATMEL_CONSOLE=y
3499 +CONFIG_SERIAL_ATMEL_PDC=y
3500 +# CONFIG_SERIAL_ATMEL_TTYAT is not set
3501 +CONFIG_SERIAL_CORE=y
3502 +CONFIG_SERIAL_CORE_CONSOLE=y
3503 +CONFIG_UNIX98_PTYS=y
3504 +# CONFIG_LEGACY_PTYS is not set
3505 +# CONFIG_IPMI_HANDLER is not set
3506 +# CONFIG_HW_RANDOM is not set
3507 +# CONFIG_RTC is not set
3508 +# CONFIG_GEN_RTC is not set
3509 +# CONFIG_R3964 is not set
3510 +# CONFIG_RAW_DRIVER is not set
3511 +# CONFIG_TCG_TPM is not set
3513 +CONFIG_I2C_BOARDINFO=y
3514 +CONFIG_I2C_CHARDEV=m
3519 +CONFIG_I2C_ALGOBIT=m
3520 +# CONFIG_I2C_ALGOPCF is not set
3521 +# CONFIG_I2C_ALGOPCA is not set
3524 +# I2C Hardware Bus support
3526 +CONFIG_I2C_ATMELTWI=m
3528 +# CONFIG_I2C_OCORES is not set
3529 +# CONFIG_I2C_PARPORT_LIGHT is not set
3530 +# CONFIG_I2C_SIMTEC is not set
3531 +# CONFIG_I2C_TAOS_EVM is not set
3532 +# CONFIG_I2C_STUB is not set
3535 +# Miscellaneous I2C Chip support
3537 +# CONFIG_SENSORS_DS1337 is not set
3538 +# CONFIG_SENSORS_DS1374 is not set
3539 +# CONFIG_DS1682 is not set
3540 +# CONFIG_SENSORS_EEPROM is not set
3541 +# CONFIG_SENSORS_PCF8574 is not set
3542 +# CONFIG_SENSORS_PCA9539 is not set
3543 +# CONFIG_SENSORS_PCF8591 is not set
3544 +# CONFIG_SENSORS_MAX6875 is not set
3545 +# CONFIG_SENSORS_TSL2550 is not set
3546 +# CONFIG_I2C_DEBUG_CORE is not set
3547 +# CONFIG_I2C_DEBUG_ALGO is not set
3548 +# CONFIG_I2C_DEBUG_BUS is not set
3549 +# CONFIG_I2C_DEBUG_CHIP is not set
3555 +# CONFIG_SPI_DEBUG is not set
3556 +CONFIG_SPI_MASTER=y
3559 +# SPI Master Controller Drivers
3562 +# CONFIG_SPI_BITBANG is not set
3565 +# SPI Protocol Masters
3567 +# CONFIG_SPI_AT25 is not set
3568 +CONFIG_SPI_SPIDEV=m
3569 +# CONFIG_SPI_TLE62X0 is not set
3570 +# CONFIG_W1 is not set
3571 +# CONFIG_POWER_SUPPLY is not set
3572 +# CONFIG_HWMON is not set
3574 +# CONFIG_WATCHDOG_NOWAYOUT is not set
3577 +# Watchdog Device Drivers
3579 +# CONFIG_SOFT_WATCHDOG is not set
3580 +CONFIG_AT32AP700X_WDT=y
3583 +# Sonics Silicon Backplane
3585 +CONFIG_SSB_POSSIBLE=y
3586 +# CONFIG_SSB is not set
3589 +# Multifunction device drivers
3591 +# CONFIG_MFD_SM501 is not set
3594 +# Multimedia devices
3596 +# CONFIG_VIDEO_DEV is not set
3597 +# CONFIG_DVB_CORE is not set
3598 +# CONFIG_DAB is not set
3603 +# CONFIG_VGASTATE is not set
3604 +# CONFIG_VIDEO_OUTPUT_CONTROL is not set
3605 +# CONFIG_FB is not set
3606 +# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
3609 +# Display device support
3611 +# CONFIG_DISPLAY_SUPPORT is not set
3619 +# Advanced Linux Sound Architecture
3624 +# CONFIG_SND_SEQUENCER is not set
3625 +CONFIG_SND_OSSEMUL=y
3626 +CONFIG_SND_MIXER_OSS=m
3627 +CONFIG_SND_PCM_OSS=m
3628 +CONFIG_SND_PCM_OSS_PLUGINS=y
3629 +# CONFIG_SND_DYNAMIC_MINORS is not set
3630 +CONFIG_SND_SUPPORT_OLD_API=y
3631 +CONFIG_SND_VERBOSE_PROCFS=y
3632 +# CONFIG_SND_VERBOSE_PRINTK is not set
3633 +# CONFIG_SND_DEBUG is not set
3638 +CONFIG_SND_AC97_CODEC=m
3639 +# CONFIG_SND_DUMMY is not set
3640 +# CONFIG_SND_MTPAV is not set
3641 +# CONFIG_SND_SERIAL_U16550 is not set
3642 +# CONFIG_SND_MPU401 is not set
3647 +CONFIG_SND_ATMEL_AC97=m
3652 +CONFIG_SND_AT73C213=m
3653 +CONFIG_SND_AT73C213_TARGET_BITRATE=48000
3656 +# System on Chip audio support
3658 +# CONFIG_SND_SOC is not set
3661 +# SoC Audio support for SuperH
3665 +# Open Sound System
3667 +# CONFIG_SOUND_PRIME is not set
3669 +# CONFIG_HID_SUPPORT is not set
3670 +CONFIG_USB_SUPPORT=y
3671 +# CONFIG_USB_ARCH_HAS_HCD is not set
3672 +# CONFIG_USB_ARCH_HAS_OHCI is not set
3673 +# CONFIG_USB_ARCH_HAS_EHCI is not set
3676 +# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
3680 +# USB Gadget Support
3682 +CONFIG_USB_GADGET=y
3683 +# CONFIG_USB_GADGET_DEBUG is not set
3684 +# CONFIG_USB_GADGET_DEBUG_FILES is not set
3685 +CONFIG_USB_GADGET_DEBUG_FS=y
3686 +CONFIG_USB_GADGET_SELECTED=y
3687 +# CONFIG_USB_GADGET_AMD5536UDC is not set
3688 +CONFIG_USB_GADGET_ATMEL_USBA=y
3689 +CONFIG_USB_ATMEL_USBA=y
3690 +# CONFIG_USB_GADGET_FSL_USB2 is not set
3691 +# CONFIG_USB_GADGET_NET2280 is not set
3692 +# CONFIG_USB_GADGET_PXA2XX is not set
3693 +# CONFIG_USB_GADGET_M66592 is not set
3694 +# CONFIG_USB_GADGET_GOKU is not set
3695 +# CONFIG_USB_GADGET_LH7A40X is not set
3696 +# CONFIG_USB_GADGET_OMAP is not set
3697 +# CONFIG_USB_GADGET_S3C2410 is not set
3698 +# CONFIG_USB_GADGET_AT91 is not set
3699 +# CONFIG_USB_GADGET_DUMMY_HCD is not set
3700 +CONFIG_USB_GADGET_DUALSPEED=y
3703 +CONFIG_USB_ETH_RNDIS=y
3704 +CONFIG_USB_GADGETFS=m
3705 +CONFIG_USB_FILE_STORAGE=m
3706 +# CONFIG_USB_FILE_STORAGE_TEST is not set
3707 +CONFIG_USB_G_SERIAL=m
3708 +# CONFIG_USB_MIDI_GADGET is not set
3710 +# CONFIG_MMC_DEBUG is not set
3711 +# CONFIG_MMC_UNSAFE_RESUME is not set
3714 +# MMC/SD Card Drivers
3717 +# CONFIG_MMC_BLOCK_BOUNCE is not set
3718 +# CONFIG_SDIO_UART is not set
3721 +# MMC/SD Host Controller Drivers
3723 +CONFIG_MMC_ATMELMCI=y
3726 +CONFIG_LEDS_CLASS=y
3731 +CONFIG_LEDS_ATMEL_PWM=m
3737 +CONFIG_LEDS_TRIGGERS=y
3738 +CONFIG_LEDS_TRIGGER_TIMER=y
3739 +CONFIG_LEDS_TRIGGER_HEARTBEAT=y
3742 +CONFIG_RTC_HCTOSYS=y
3743 +CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
3744 +# CONFIG_RTC_DEBUG is not set
3749 +CONFIG_RTC_INTF_SYSFS=y
3750 +CONFIG_RTC_INTF_PROC=y
3751 +CONFIG_RTC_INTF_DEV=y
3752 +# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
3753 +# CONFIG_RTC_DRV_TEST is not set
3758 +# CONFIG_RTC_DRV_DS1307 is not set
3759 +# CONFIG_RTC_DRV_DS1374 is not set
3760 +# CONFIG_RTC_DRV_DS1672 is not set
3761 +# CONFIG_RTC_DRV_MAX6900 is not set
3762 +# CONFIG_RTC_DRV_RS5C372 is not set
3763 +# CONFIG_RTC_DRV_ISL1208 is not set
3764 +# CONFIG_RTC_DRV_X1205 is not set
3765 +# CONFIG_RTC_DRV_PCF8563 is not set
3766 +# CONFIG_RTC_DRV_PCF8583 is not set
3767 +# CONFIG_RTC_DRV_M41T80 is not set
3772 +# CONFIG_RTC_DRV_RS5C348 is not set
3773 +# CONFIG_RTC_DRV_MAX6902 is not set
3776 +# Platform RTC drivers
3778 +# CONFIG_RTC_DRV_DS1553 is not set
3779 +# CONFIG_RTC_DRV_STK17TA8 is not set
3780 +# CONFIG_RTC_DRV_DS1742 is not set
3781 +# CONFIG_RTC_DRV_M48T86 is not set
3782 +# CONFIG_RTC_DRV_M48T59 is not set
3783 +# CONFIG_RTC_DRV_V3020 is not set
3786 +# on-CPU RTC drivers
3788 +CONFIG_RTC_DRV_AT32AP700X=y
3799 +# CONFIG_EXT2_FS_XATTR is not set
3800 +# CONFIG_EXT2_FS_XIP is not set
3802 +# CONFIG_EXT3_FS_XATTR is not set
3803 +# CONFIG_EXT4DEV_FS is not set
3805 +# CONFIG_JBD_DEBUG is not set
3806 +# CONFIG_REISERFS_FS is not set
3807 +# CONFIG_JFS_FS is not set
3808 +# CONFIG_FS_POSIX_ACL is not set
3809 +# CONFIG_XFS_FS is not set
3810 +# CONFIG_GFS2_FS is not set
3811 +# CONFIG_OCFS2_FS is not set
3812 +# CONFIG_MINIX_FS is not set
3813 +# CONFIG_ROMFS_FS is not set
3815 +CONFIG_INOTIFY_USER=y
3816 +# CONFIG_QUOTA is not set
3817 +# CONFIG_DNOTIFY is not set
3818 +# CONFIG_AUTOFS_FS is not set
3819 +# CONFIG_AUTOFS4_FS is not set
3823 +# CD-ROM/DVD Filesystems
3825 +# CONFIG_ISO9660_FS is not set
3826 +# CONFIG_UDF_FS is not set
3829 +# DOS/FAT/NT Filesystems
3834 +CONFIG_FAT_DEFAULT_CODEPAGE=437
3835 +CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
3836 +# CONFIG_NTFS_FS is not set
3839 +# Pseudo filesystems
3842 +CONFIG_PROC_KCORE=y
3843 +CONFIG_PROC_SYSCTL=y
3846 +# CONFIG_TMPFS_POSIX_ACL is not set
3847 +# CONFIG_HUGETLB_PAGE is not set
3848 +CONFIG_CONFIGFS_FS=y
3851 +# Miscellaneous filesystems
3853 +# CONFIG_ADFS_FS is not set
3854 +# CONFIG_AFFS_FS is not set
3855 +# CONFIG_HFS_FS is not set
3856 +# CONFIG_HFSPLUS_FS is not set
3857 +# CONFIG_BEFS_FS is not set
3858 +# CONFIG_BFS_FS is not set
3859 +# CONFIG_EFS_FS is not set
3861 +CONFIG_JFFS2_FS_DEBUG=0
3862 +CONFIG_JFFS2_FS_WRITEBUFFER=y
3863 +# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
3864 +# CONFIG_JFFS2_SUMMARY is not set
3865 +# CONFIG_JFFS2_FS_XATTR is not set
3866 +# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
3867 +CONFIG_JFFS2_ZLIB=y
3868 +# CONFIG_JFFS2_LZO is not set
3869 +CONFIG_JFFS2_RTIME=y
3870 +# CONFIG_JFFS2_RUBIN is not set
3871 +# CONFIG_CRAMFS is not set
3872 +# CONFIG_VXFS_FS is not set
3873 +# CONFIG_HPFS_FS is not set
3874 +# CONFIG_QNX4FS_FS is not set
3875 +# CONFIG_SYSV_FS is not set
3876 +# CONFIG_UFS_FS is not set
3877 +# CONFIG_NETWORK_FILESYSTEMS is not set
3882 +# CONFIG_PARTITION_ADVANCED is not set
3883 +CONFIG_MSDOS_PARTITION=y
3885 +CONFIG_NLS_DEFAULT="iso8859-1"
3886 +CONFIG_NLS_CODEPAGE_437=m
3887 +# CONFIG_NLS_CODEPAGE_737 is not set
3888 +# CONFIG_NLS_CODEPAGE_775 is not set
3889 +# CONFIG_NLS_CODEPAGE_850 is not set
3890 +# CONFIG_NLS_CODEPAGE_852 is not set
3891 +# CONFIG_NLS_CODEPAGE_855 is not set
3892 +# CONFIG_NLS_CODEPAGE_857 is not set
3893 +# CONFIG_NLS_CODEPAGE_860 is not set
3894 +# CONFIG_NLS_CODEPAGE_861 is not set
3895 +# CONFIG_NLS_CODEPAGE_862 is not set
3896 +# CONFIG_NLS_CODEPAGE_863 is not set
3897 +# CONFIG_NLS_CODEPAGE_864 is not set
3898 +# CONFIG_NLS_CODEPAGE_865 is not set
3899 +# CONFIG_NLS_CODEPAGE_866 is not set
3900 +# CONFIG_NLS_CODEPAGE_869 is not set
3901 +# CONFIG_NLS_CODEPAGE_936 is not set
3902 +# CONFIG_NLS_CODEPAGE_950 is not set
3903 +# CONFIG_NLS_CODEPAGE_932 is not set
3904 +# CONFIG_NLS_CODEPAGE_949 is not set
3905 +# CONFIG_NLS_CODEPAGE_874 is not set
3906 +# CONFIG_NLS_ISO8859_8 is not set
3907 +# CONFIG_NLS_CODEPAGE_1250 is not set
3908 +# CONFIG_NLS_CODEPAGE_1251 is not set
3909 +# CONFIG_NLS_ASCII is not set
3910 +CONFIG_NLS_ISO8859_1=m
3911 +# CONFIG_NLS_ISO8859_2 is not set
3912 +# CONFIG_NLS_ISO8859_3 is not set
3913 +# CONFIG_NLS_ISO8859_4 is not set
3914 +# CONFIG_NLS_ISO8859_5 is not set
3915 +# CONFIG_NLS_ISO8859_6 is not set
3916 +# CONFIG_NLS_ISO8859_7 is not set
3917 +# CONFIG_NLS_ISO8859_9 is not set
3918 +# CONFIG_NLS_ISO8859_13 is not set
3919 +# CONFIG_NLS_ISO8859_14 is not set
3920 +# CONFIG_NLS_ISO8859_15 is not set
3921 +# CONFIG_NLS_KOI8_R is not set
3922 +# CONFIG_NLS_KOI8_U is not set
3924 +# CONFIG_DLM is not set
3925 +CONFIG_INSTRUMENTATION=y
3929 +# CONFIG_MARKERS is not set
3934 +# CONFIG_PRINTK_TIME is not set
3935 +CONFIG_ENABLE_WARN_DEPRECATED=y
3936 +CONFIG_ENABLE_MUST_CHECK=y
3937 +CONFIG_MAGIC_SYSRQ=y
3938 +# CONFIG_UNUSED_SYMBOLS is not set
3940 +# CONFIG_HEADERS_CHECK is not set
3941 +CONFIG_DEBUG_KERNEL=y
3942 +# CONFIG_DEBUG_SHIRQ is not set
3943 +CONFIG_DETECT_SOFTLOCKUP=y
3944 +CONFIG_SCHED_DEBUG=y
3945 +# CONFIG_SCHEDSTATS is not set
3946 +# CONFIG_TIMER_STATS is not set
3947 +# CONFIG_DEBUG_RT_MUTEXES is not set
3948 +# CONFIG_RT_MUTEX_TESTER is not set
3949 +# CONFIG_DEBUG_SPINLOCK is not set
3950 +# CONFIG_DEBUG_MUTEXES is not set
3951 +# CONFIG_DEBUG_LOCK_ALLOC is not set
3952 +# CONFIG_PROVE_LOCKING is not set
3953 +# CONFIG_LOCK_STAT is not set
3954 +# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
3955 +# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
3956 +# CONFIG_DEBUG_KOBJECT is not set
3957 +CONFIG_DEBUG_BUGVERBOSE=y
3958 +# CONFIG_DEBUG_INFO is not set
3959 +# CONFIG_DEBUG_VM is not set
3960 +# CONFIG_DEBUG_LIST is not set
3961 +# CONFIG_DEBUG_SG is not set
3962 +CONFIG_FRAME_POINTER=y
3963 +CONFIG_FORCED_INLINING=y
3964 +# CONFIG_BOOT_PRINTK_DELAY is not set
3965 +# CONFIG_RCU_TORTURE_TEST is not set
3966 +# CONFIG_LKDTM is not set
3967 +# CONFIG_FAULT_INJECTION is not set
3968 +# CONFIG_SAMPLES is not set
3973 +# CONFIG_KEYS is not set
3974 +# CONFIG_SECURITY is not set
3975 +# CONFIG_SECURITY_FILE_CAPABILITIES is not set
3976 +# CONFIG_CRYPTO is not set
3981 +CONFIG_BITREVERSE=y
3983 +# CONFIG_CRC16 is not set
3987 +# CONFIG_LIBCRC32C is not set
3988 +CONFIG_AUDIT_GENERIC=y
3989 +CONFIG_ZLIB_INFLATE=y
3990 +CONFIG_ZLIB_DEFLATE=y
3993 +CONFIG_HAS_IOPORT=y
3996 +++ b/arch/avr32/configs/atstk1004_defconfig
3999 +# Automatically generated make config: don't edit
4000 +# Linux kernel version: 2.6.24
4001 +# Thu Mar 6 12:51:05 2008
4004 +CONFIG_GENERIC_GPIO=y
4005 +CONFIG_GENERIC_HARDIRQS=y
4006 +CONFIG_STACKTRACE_SUPPORT=y
4007 +CONFIG_LOCKDEP_SUPPORT=y
4008 +CONFIG_TRACE_IRQFLAGS_SUPPORT=y
4009 +CONFIG_HARDIRQS_SW_RESEND=y
4010 +CONFIG_GENERIC_IRQ_PROBE=y
4011 +CONFIG_RWSEM_GENERIC_SPINLOCK=y
4012 +CONFIG_GENERIC_TIME=y
4013 +CONFIG_GENERIC_CLOCKEVENTS=y
4014 +# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
4015 +# CONFIG_ARCH_HAS_ILOG2_U32 is not set
4016 +# CONFIG_ARCH_HAS_ILOG2_U64 is not set
4017 +CONFIG_ARCH_SUPPORTS_OPROFILE=y
4018 +CONFIG_GENERIC_HWEIGHT=y
4019 +CONFIG_GENERIC_CALIBRATE_DELAY=y
4020 +CONFIG_GENERIC_BUG=y
4021 +CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
4026 +CONFIG_EXPERIMENTAL=y
4027 +CONFIG_BROKEN_ON_SMP=y
4028 +CONFIG_INIT_ENV_ARG_LIMIT=32
4029 +CONFIG_LOCALVERSION=""
4030 +# CONFIG_LOCALVERSION_AUTO is not set
4031 +# CONFIG_SYSVIPC is not set
4032 +# CONFIG_POSIX_MQUEUE is not set
4033 +# CONFIG_BSD_PROCESS_ACCT is not set
4034 +# CONFIG_TASKSTATS is not set
4035 +# CONFIG_USER_NS is not set
4036 +# CONFIG_PID_NS is not set
4037 +# CONFIG_AUDIT is not set
4038 +# CONFIG_IKCONFIG is not set
4039 +CONFIG_LOG_BUF_SHIFT=14
4040 +# CONFIG_CGROUPS is not set
4041 +# CONFIG_FAIR_GROUP_SCHED is not set
4042 +CONFIG_SYSFS_DEPRECATED=y
4043 +# CONFIG_RELAY is not set
4044 +# CONFIG_BLK_DEV_INITRD is not set
4045 +CONFIG_CC_OPTIMIZE_FOR_SIZE=y
4048 +# CONFIG_SYSCTL_SYSCALL is not set
4050 +# CONFIG_KALLSYMS_EXTRA_PASS is not set
4055 +# CONFIG_BASE_FULL is not set
4056 +# CONFIG_FUTEX is not set
4057 +# CONFIG_EPOLL is not set
4058 +# CONFIG_SIGNALFD is not set
4059 +# CONFIG_EVENTFD is not set
4061 +CONFIG_VM_EVENT_COUNTERS=y
4062 +# CONFIG_SLAB is not set
4063 +# CONFIG_SLUB is not set
4065 +# CONFIG_TINY_SHMEM is not set
4066 +CONFIG_BASE_SMALL=1
4067 +# CONFIG_MODULES is not set
4068 +# CONFIG_BLOCK is not set
4071 +# System Type and features
4073 +CONFIG_TICK_ONESHOT=y
4075 +CONFIG_HIGH_RES_TIMERS=y
4076 +CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
4077 +CONFIG_SUBARCH_AVR32B=y
4079 +CONFIG_PERFORMANCE_COUNTERS=y
4080 +CONFIG_PLATFORM_AT32AP=y
4081 +CONFIG_CPU_AT32AP700X=y
4082 +CONFIG_CPU_AT32AP7002=y
4083 +CONFIG_BOARD_ATSTK1000=y
4084 +# CONFIG_BOARD_ATNGW100 is not set
4085 +# CONFIG_BOARD_ATSTK1002 is not set
4086 +# CONFIG_BOARD_ATSTK1003 is not set
4087 +CONFIG_BOARD_ATSTK1004=y
4088 +# CONFIG_BOARD_ATSTK100X_CUSTOM is not set
4089 +# CONFIG_BOARD_ATSTK100X_SPI1 is not set
4090 +# CONFIG_BOARD_ATSTK1000_J2_LED is not set
4091 +CONFIG_BOARD_ATSTK1000_EXTDAC=y
4092 +# CONFIG_BOARD_ATSTK100X_ENABLE_AC97 is not set
4093 +# CONFIG_BOARD_ATSTK1000_CF_HACKS is not set
4094 +# CONFIG_BOARD_ATSTK100X_ENABLE_PSIF is not set
4095 +CONFIG_LOADER_U_BOOT=y
4098 +# Atmel AVR32 AP options
4100 +# CONFIG_AP700X_32_BIT_SMC is not set
4101 +CONFIG_AP700X_16_BIT_SMC=y
4102 +# CONFIG_AP700X_8_BIT_SMC is not set
4103 +# CONFIG_GPIO_DEV is not set
4104 +CONFIG_LOAD_ADDRESS=0x10000000
4105 +CONFIG_ENTRY_ADDRESS=0x90000000
4106 +CONFIG_PHYS_OFFSET=0x10000000
4107 +CONFIG_PREEMPT_NONE=y
4108 +# CONFIG_PREEMPT_VOLUNTARY is not set
4109 +# CONFIG_PREEMPT is not set
4110 +# CONFIG_HAVE_ARCH_BOOTMEM_NODE is not set
4111 +# CONFIG_ARCH_HAVE_MEMORY_PRESENT is not set
4112 +# CONFIG_NEED_NODE_MEMMAP_SIZE is not set
4113 +CONFIG_ARCH_FLATMEM_ENABLE=y
4114 +# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
4115 +# CONFIG_ARCH_SPARSEMEM_ENABLE is not set
4116 +CONFIG_SELECT_MEMORY_MODEL=y
4117 +CONFIG_FLATMEM_MANUAL=y
4118 +# CONFIG_DISCONTIGMEM_MANUAL is not set
4119 +# CONFIG_SPARSEMEM_MANUAL is not set
4121 +CONFIG_FLAT_NODE_MEM_MAP=y
4122 +# CONFIG_SPARSEMEM_STATIC is not set
4123 +# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
4124 +CONFIG_SPLIT_PTLOCK_CPUS=4
4125 +# CONFIG_RESOURCES_64BIT is not set
4126 +CONFIG_ZONE_DMA_FLAG=0
4127 +CONFIG_VIRT_TO_BUS=y
4128 +# CONFIG_OWNERSHIP_TRACE is not set
4129 +# CONFIG_NMI_DEBUGGING is not set
4130 +# CONFIG_DW_DMAC is not set
4131 +# CONFIG_HZ_100 is not set
4133 +# CONFIG_HZ_300 is not set
4134 +# CONFIG_HZ_1000 is not set
4139 +# Power management options
4143 +# CPU Frequency scaling
4146 +CONFIG_CPU_FREQ_TABLE=y
4147 +# CONFIG_CPU_FREQ_DEBUG is not set
4148 +# CONFIG_CPU_FREQ_STAT is not set
4149 +CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
4150 +# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
4151 +# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
4152 +# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
4153 +CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
4154 +# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
4155 +CONFIG_CPU_FREQ_GOV_USERSPACE=y
4156 +CONFIG_CPU_FREQ_GOV_ONDEMAND=y
4157 +# CONFIG_CPU_FREQ_GOV_CONSERVATIVE is not set
4158 +CONFIG_CPU_FREQ_AT32AP=y
4163 +# CONFIG_ARCH_SUPPORTS_MSI is not set
4164 +# CONFIG_PCCARD is not set
4167 +# Executable file formats
4169 +CONFIG_BINFMT_ELF=y
4170 +# CONFIG_BINFMT_MISC is not set
4178 +# Networking options
4181 +CONFIG_PACKET_MMAP=y
4183 +# CONFIG_NET_KEY is not set
4185 +# CONFIG_IP_MULTICAST is not set
4186 +# CONFIG_IP_ADVANCED_ROUTER is not set
4187 +CONFIG_IP_FIB_HASH=y
4188 +# CONFIG_IP_PNP is not set
4189 +# CONFIG_NET_IPIP is not set
4190 +# CONFIG_NET_IPGRE is not set
4191 +# CONFIG_ARPD is not set
4192 +# CONFIG_SYN_COOKIES is not set
4193 +# CONFIG_INET_AH is not set
4194 +# CONFIG_INET_ESP is not set
4195 +# CONFIG_INET_IPCOMP is not set
4196 +# CONFIG_INET_XFRM_TUNNEL is not set
4197 +# CONFIG_INET_TUNNEL is not set
4198 +# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
4199 +# CONFIG_INET_XFRM_MODE_TUNNEL is not set
4200 +# CONFIG_INET_XFRM_MODE_BEET is not set
4201 +# CONFIG_INET_LRO is not set
4202 +# CONFIG_INET_DIAG is not set
4203 +# CONFIG_TCP_CONG_ADVANCED is not set
4204 +CONFIG_TCP_CONG_CUBIC=y
4205 +CONFIG_DEFAULT_TCP_CONG="cubic"
4206 +# CONFIG_TCP_MD5SIG is not set
4207 +# CONFIG_IPV6 is not set
4208 +# CONFIG_INET6_XFRM_TUNNEL is not set
4209 +# CONFIG_INET6_TUNNEL is not set
4210 +# CONFIG_NETWORK_SECMARK is not set
4211 +# CONFIG_NETFILTER is not set
4212 +# CONFIG_IP_DCCP is not set
4213 +# CONFIG_IP_SCTP is not set
4214 +# CONFIG_TIPC is not set
4215 +# CONFIG_ATM is not set
4216 +# CONFIG_BRIDGE is not set
4217 +# CONFIG_VLAN_8021Q is not set
4218 +# CONFIG_DECNET is not set
4219 +# CONFIG_LLC2 is not set
4220 +# CONFIG_IPX is not set
4221 +# CONFIG_ATALK is not set
4222 +# CONFIG_X25 is not set
4223 +# CONFIG_LAPB is not set
4224 +# CONFIG_ECONET is not set
4225 +# CONFIG_WAN_ROUTER is not set
4226 +# CONFIG_NET_SCHED is not set
4231 +# CONFIG_NET_PKTGEN is not set
4232 +# CONFIG_HAMRADIO is not set
4233 +# CONFIG_IRDA is not set
4234 +# CONFIG_BT is not set
4235 +# CONFIG_AF_RXRPC is not set
4240 +# CONFIG_CFG80211 is not set
4241 +# CONFIG_WIRELESS_EXT is not set
4242 +# CONFIG_MAC80211 is not set
4243 +# CONFIG_IEEE80211 is not set
4244 +# CONFIG_RFKILL is not set
4245 +# CONFIG_NET_9P is not set
4252 +# Generic Driver Options
4254 +CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
4255 +CONFIG_STANDALONE=y
4256 +# CONFIG_PREVENT_FIRMWARE_BUILD is not set
4257 +# CONFIG_FW_LOADER is not set
4258 +# CONFIG_SYS_HYPERVISOR is not set
4259 +# CONFIG_CONNECTOR is not set
4261 +# CONFIG_MTD_DEBUG is not set
4262 +# CONFIG_MTD_CONCAT is not set
4263 +CONFIG_MTD_PARTITIONS=y
4264 +# CONFIG_MTD_REDBOOT_PARTS is not set
4265 +CONFIG_MTD_CMDLINE_PARTS=y
4268 +# User Modules And Translation Layers
4271 +# CONFIG_MTD_OOPS is not set
4274 +# RAM/ROM/Flash chip drivers
4277 +# CONFIG_MTD_JEDECPROBE is not set
4278 +CONFIG_MTD_GEN_PROBE=y
4279 +# CONFIG_MTD_CFI_ADV_OPTIONS is not set
4280 +CONFIG_MTD_MAP_BANK_WIDTH_1=y
4281 +CONFIG_MTD_MAP_BANK_WIDTH_2=y
4282 +CONFIG_MTD_MAP_BANK_WIDTH_4=y
4283 +# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
4284 +# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
4285 +# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
4286 +CONFIG_MTD_CFI_I1=y
4287 +CONFIG_MTD_CFI_I2=y
4288 +# CONFIG_MTD_CFI_I4 is not set
4289 +# CONFIG_MTD_CFI_I8 is not set
4290 +# CONFIG_MTD_CFI_INTELEXT is not set
4291 +CONFIG_MTD_CFI_AMDSTD=y
4292 +# CONFIG_MTD_CFI_STAA is not set
4293 +CONFIG_MTD_CFI_UTIL=y
4294 +# CONFIG_MTD_RAM is not set
4295 +# CONFIG_MTD_ROM is not set
4296 +# CONFIG_MTD_ABSENT is not set
4299 +# Mapping drivers for chip access
4301 +# CONFIG_MTD_COMPLEX_MAPPINGS is not set
4302 +CONFIG_MTD_PHYSMAP=y
4303 +CONFIG_MTD_PHYSMAP_START=0x8000000
4304 +CONFIG_MTD_PHYSMAP_LEN=0x0
4305 +CONFIG_MTD_PHYSMAP_BANKWIDTH=2
4306 +# CONFIG_MTD_PLATRAM is not set
4309 +# Self-contained MTD device drivers
4311 +# CONFIG_MTD_DATAFLASH is not set
4312 +# CONFIG_MTD_M25P80 is not set
4313 +# CONFIG_MTD_SLRAM is not set
4314 +# CONFIG_MTD_PHRAM is not set
4315 +# CONFIG_MTD_MTDRAM is not set
4318 +# Disk-On-Chip Device Drivers
4320 +# CONFIG_MTD_DOC2000 is not set
4321 +# CONFIG_MTD_DOC2001 is not set
4322 +# CONFIG_MTD_DOC2001PLUS is not set
4323 +# CONFIG_MTD_NAND is not set
4324 +# CONFIG_MTD_ONENAND is not set
4327 +# UBI - Unsorted block images
4329 +# CONFIG_MTD_UBI is not set
4330 +# CONFIG_PARPORT is not set
4331 +CONFIG_MISC_DEVICES=y
4332 +# CONFIG_ATMEL_PWM is not set
4333 +CONFIG_ATMEL_TCLIB=y
4334 +CONFIG_ATMEL_TCB_CLKSRC=y
4335 +CONFIG_ATMEL_TCB_CLKSRC_BLOCK=0
4336 +# CONFIG_EEPROM_93CX6 is not set
4337 +# CONFIG_ATMEL_SSC is not set
4340 +# SCSI device support
4342 +# CONFIG_SCSI_DMA is not set
4343 +# CONFIG_SCSI_NETLINK is not set
4344 +# CONFIG_NETDEVICES is not set
4345 +# CONFIG_ISDN is not set
4346 +# CONFIG_PHONE is not set
4349 +# Input device support
4351 +# CONFIG_INPUT is not set
4354 +# Hardware I/O ports
4356 +# CONFIG_SERIO is not set
4357 +# CONFIG_GAMEPORT is not set
4360 +# Character devices
4362 +# CONFIG_VT is not set
4363 +# CONFIG_SERIAL_NONSTANDARD is not set
4368 +# CONFIG_SERIAL_8250 is not set
4371 +# Non-8250 serial port support
4373 +CONFIG_SERIAL_ATMEL=y
4374 +CONFIG_SERIAL_ATMEL_CONSOLE=y
4375 +# CONFIG_SERIAL_ATMEL_PDC is not set
4376 +# CONFIG_SERIAL_ATMEL_TTYAT is not set
4377 +CONFIG_SERIAL_CORE=y
4378 +CONFIG_SERIAL_CORE_CONSOLE=y
4379 +CONFIG_UNIX98_PTYS=y
4380 +# CONFIG_LEGACY_PTYS is not set
4381 +# CONFIG_IPMI_HANDLER is not set
4382 +# CONFIG_HW_RANDOM is not set
4383 +# CONFIG_RTC is not set
4384 +# CONFIG_GEN_RTC is not set
4385 +# CONFIG_R3964 is not set
4386 +# CONFIG_TCG_TPM is not set
4387 +# CONFIG_I2C is not set
4393 +CONFIG_SPI_MASTER=y
4396 +# SPI Master Controller Drivers
4399 +# CONFIG_SPI_BITBANG is not set
4402 +# SPI Protocol Masters
4404 +# CONFIG_SPI_AT25 is not set
4405 +# CONFIG_SPI_SPIDEV is not set
4406 +# CONFIG_SPI_TLE62X0 is not set
4407 +# CONFIG_W1 is not set
4408 +# CONFIG_POWER_SUPPLY is not set
4409 +# CONFIG_HWMON is not set
4411 +# CONFIG_WATCHDOG_NOWAYOUT is not set
4414 +# Watchdog Device Drivers
4416 +# CONFIG_SOFT_WATCHDOG is not set
4417 +CONFIG_AT32AP700X_WDT=y
4420 +# Sonics Silicon Backplane
4422 +CONFIG_SSB_POSSIBLE=y
4423 +# CONFIG_SSB is not set
4426 +# Multifunction device drivers
4428 +# CONFIG_MFD_SM501 is not set
4431 +# Multimedia devices
4433 +# CONFIG_VIDEO_DEV is not set
4434 +# CONFIG_DVB_CORE is not set
4435 +# CONFIG_DAB is not set
4440 +# CONFIG_VGASTATE is not set
4441 +# CONFIG_VIDEO_OUTPUT_CONTROL is not set
4443 +# CONFIG_FIRMWARE_EDID is not set
4444 +# CONFIG_FB_DDC is not set
4445 +CONFIG_FB_CFB_FILLRECT=y
4446 +CONFIG_FB_CFB_COPYAREA=y
4447 +CONFIG_FB_CFB_IMAGEBLIT=y
4448 +# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
4449 +# CONFIG_FB_SYS_FILLRECT is not set
4450 +# CONFIG_FB_SYS_COPYAREA is not set
4451 +# CONFIG_FB_SYS_IMAGEBLIT is not set
4452 +# CONFIG_FB_SYS_FOPS is not set
4453 +CONFIG_FB_DEFERRED_IO=y
4454 +# CONFIG_FB_SVGALIB is not set
4455 +# CONFIG_FB_MACMODES is not set
4456 +# CONFIG_FB_BACKLIGHT is not set
4457 +# CONFIG_FB_MODE_HELPERS is not set
4458 +# CONFIG_FB_TILEBLITTING is not set
4461 +# Frame buffer hardware drivers
4463 +# CONFIG_FB_S1D13XXX is not set
4465 +# CONFIG_FB_VIRTUAL is not set
4466 +CONFIG_BACKLIGHT_LCD_SUPPORT=y
4467 +CONFIG_LCD_CLASS_DEVICE=y
4468 +CONFIG_LCD_LTV350QV=y
4469 +# CONFIG_BACKLIGHT_CLASS_DEVICE is not set
4472 +# Display device support
4474 +# CONFIG_DISPLAY_SUPPORT is not set
4475 +# CONFIG_LOGO is not set
4480 +# CONFIG_SOUND is not set
4481 +CONFIG_USB_SUPPORT=y
4482 +# CONFIG_USB_ARCH_HAS_HCD is not set
4483 +# CONFIG_USB_ARCH_HAS_OHCI is not set
4484 +# CONFIG_USB_ARCH_HAS_EHCI is not set
4487 +# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
4491 +# USB Gadget Support
4493 +CONFIG_USB_GADGET=y
4494 +# CONFIG_USB_GADGET_DEBUG_FILES is not set
4495 +CONFIG_USB_GADGET_SELECTED=y
4496 +# CONFIG_USB_GADGET_AMD5536UDC is not set
4497 +CONFIG_USB_GADGET_ATMEL_USBA=y
4498 +CONFIG_USB_ATMEL_USBA=y
4499 +# CONFIG_USB_GADGET_FSL_USB2 is not set
4500 +# CONFIG_USB_GADGET_NET2280 is not set
4501 +# CONFIG_USB_GADGET_PXA2XX is not set
4502 +# CONFIG_USB_GADGET_M66592 is not set
4503 +# CONFIG_USB_GADGET_GOKU is not set
4504 +# CONFIG_USB_GADGET_LH7A40X is not set
4505 +# CONFIG_USB_GADGET_OMAP is not set
4506 +# CONFIG_USB_GADGET_S3C2410 is not set
4507 +# CONFIG_USB_GADGET_AT91 is not set
4508 +# CONFIG_USB_GADGET_DUMMY_HCD is not set
4509 +CONFIG_USB_GADGET_DUALSPEED=y
4510 +# CONFIG_USB_ZERO is not set
4512 +# CONFIG_USB_ETH_RNDIS is not set
4513 +# CONFIG_USB_GADGETFS is not set
4514 +# CONFIG_USB_FILE_STORAGE is not set
4515 +# CONFIG_USB_G_SERIAL is not set
4516 +# CONFIG_USB_MIDI_GADGET is not set
4517 +# CONFIG_MMC is not set
4518 +# CONFIG_NEW_LEDS is not set
4521 +CONFIG_RTC_HCTOSYS=y
4522 +CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
4523 +# CONFIG_RTC_DEBUG is not set
4528 +CONFIG_RTC_INTF_SYSFS=y
4529 +# CONFIG_RTC_INTF_PROC is not set
4530 +CONFIG_RTC_INTF_DEV=y
4531 +# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
4532 +# CONFIG_RTC_DRV_TEST is not set
4537 +# CONFIG_RTC_DRV_RS5C348 is not set
4538 +# CONFIG_RTC_DRV_MAX6902 is not set
4541 +# Platform RTC drivers
4543 +# CONFIG_RTC_DRV_DS1553 is not set
4544 +# CONFIG_RTC_DRV_STK17TA8 is not set
4545 +# CONFIG_RTC_DRV_DS1742 is not set
4546 +# CONFIG_RTC_DRV_M48T86 is not set
4547 +# CONFIG_RTC_DRV_M48T59 is not set
4548 +# CONFIG_RTC_DRV_V3020 is not set
4551 +# on-CPU RTC drivers
4553 +CONFIG_RTC_DRV_AT32AP700X=y
4558 +# CONFIG_UIO is not set
4563 +# CONFIG_INOTIFY is not set
4564 +# CONFIG_QUOTA is not set
4565 +# CONFIG_DNOTIFY is not set
4566 +# CONFIG_AUTOFS_FS is not set
4567 +# CONFIG_AUTOFS4_FS is not set
4568 +# CONFIG_FUSE_FS is not set
4571 +# Pseudo filesystems
4574 +CONFIG_PROC_KCORE=y
4575 +CONFIG_PROC_SYSCTL=y
4578 +# CONFIG_TMPFS_POSIX_ACL is not set
4579 +# CONFIG_HUGETLB_PAGE is not set
4580 +# CONFIG_CONFIGFS_FS is not set
4583 +# Miscellaneous filesystems
4586 +CONFIG_JFFS2_FS_DEBUG=0
4587 +# CONFIG_JFFS2_FS_WRITEBUFFER is not set
4588 +# CONFIG_JFFS2_SUMMARY is not set
4589 +# CONFIG_JFFS2_FS_XATTR is not set
4590 +# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
4591 +CONFIG_JFFS2_ZLIB=y
4592 +# CONFIG_JFFS2_LZO is not set
4593 +CONFIG_JFFS2_RTIME=y
4594 +# CONFIG_JFFS2_RUBIN is not set
4595 +# CONFIG_NETWORK_FILESYSTEMS is not set
4596 +# CONFIG_NLS is not set
4597 +# CONFIG_DLM is not set
4598 +# CONFIG_INSTRUMENTATION is not set
4603 +# CONFIG_PRINTK_TIME is not set
4604 +CONFIG_ENABLE_WARN_DEPRECATED=y
4605 +CONFIG_ENABLE_MUST_CHECK=y
4606 +CONFIG_MAGIC_SYSRQ=y
4607 +# CONFIG_UNUSED_SYMBOLS is not set
4608 +# CONFIG_DEBUG_FS is not set
4609 +# CONFIG_HEADERS_CHECK is not set
4610 +# CONFIG_DEBUG_KERNEL is not set
4611 +# CONFIG_DEBUG_BUGVERBOSE is not set
4612 +# CONFIG_SAMPLES is not set
4617 +# CONFIG_KEYS is not set
4618 +# CONFIG_SECURITY is not set
4619 +# CONFIG_SECURITY_FILE_CAPABILITIES is not set
4620 +# CONFIG_CRYPTO is not set
4625 +CONFIG_BITREVERSE=y
4626 +# CONFIG_CRC_CCITT is not set
4627 +# CONFIG_CRC16 is not set
4628 +# CONFIG_CRC_ITU_T is not set
4630 +# CONFIG_CRC7 is not set
4631 +# CONFIG_LIBCRC32C is not set
4632 +CONFIG_ZLIB_INFLATE=y
4633 +CONFIG_ZLIB_DEFLATE=y
4635 +CONFIG_HAS_IOPORT=y
4638 +++ b/arch/avr32/drivers/dw-dmac.c
4641 + * Driver for the Synopsys DesignWare DMA Controller
4643 + * Copyright (C) 2005-2006 Atmel Corporation
4645 + * This program is free software; you can redistribute it and/or modify
4646 + * it under the terms of the GNU General Public License version 2 as
4647 + * published by the Free Software Foundation.
4649 +#include <linux/clk.h>
4650 +#include <linux/device.h>
4651 +#include <linux/dma-mapping.h>
4652 +#include <linux/dmapool.h>
4653 +#include <linux/init.h>
4654 +#include <linux/interrupt.h>
4655 +#include <linux/module.h>
4656 +#include <linux/platform_device.h>
4658 +#include <asm/dma-controller.h>
4659 +#include <asm/io.h>
4661 +#include "dw-dmac.h"
4663 +#define DMAC_NR_CHANNELS 3
4664 +#define DMAC_MAX_BLOCKSIZE 4095
4667 + CH_STATE_FREE = 0,
4668 + CH_STATE_ALLOCATED,
4672 +struct dw_dma_lli {
4682 +struct dw_dma_block {
4683 + struct dw_dma_lli *lli_vaddr;
4684 + dma_addr_t lli_dma_addr;
4687 +struct dw_dma_channel {
4688 + unsigned int state;
4690 + struct dma_request_sg *req_sg;
4691 + struct dma_request_cyclic *req_cyclic;
4692 + unsigned int nr_blocks;
4694 + struct dw_dma_block *block;
4697 +struct dw_dma_controller {
4699 + void * __iomem regs;
4700 + struct dma_pool *lli_pool;
4702 + struct dma_controller dma;
4703 + struct dw_dma_channel channel[DMAC_NR_CHANNELS];
4705 +#define to_dw_dmac(dmac) container_of(dmac, struct dw_dma_controller, dma)
4707 +#define dmac_writel_hi(dmac, reg, value) \
4708 + __raw_writel((value), (dmac)->regs + DW_DMAC_##reg + 4)
4709 +#define dmac_readl_hi(dmac, reg) \
4710 + __raw_readl((dmac)->regs + DW_DMAC_##reg + 4)
4711 +#define dmac_writel_lo(dmac, reg, value) \
4712 + __raw_writel((value), (dmac)->regs + DW_DMAC_##reg)
4713 +#define dmac_readl_lo(dmac, reg) \
4714 + __raw_readl((dmac)->regs + DW_DMAC_##reg)
4715 +#define dmac_chan_writel_hi(dmac, chan, reg, value) \
4716 + __raw_writel((value), ((dmac)->regs + 0x58 * (chan) \
4717 + + DW_DMAC_CHAN_##reg + 4))
4718 +#define dmac_chan_readl_hi(dmac, chan, reg) \
4719 + __raw_readl((dmac)->regs + 0x58 * (chan) + DW_DMAC_CHAN_##reg + 4)
4720 +#define dmac_chan_writel_lo(dmac, chan, reg, value) \
4721 + __raw_writel((value), (dmac)->regs + 0x58 * (chan) + DW_DMAC_CHAN_##reg)
4722 +#define dmac_chan_readl_lo(dmac, chan, reg) \
4723 + __raw_readl((dmac)->regs + 0x58 * (chan) + DW_DMAC_CHAN_##reg)
4724 +#define set_channel_bit(dmac, reg, chan) \
4725 + dmac_writel_lo(dmac, reg, (1 << (chan)) | (1 << ((chan) + 8)))
4726 +#define clear_channel_bit(dmac, reg, chan) \
4727 + dmac_writel_lo(dmac, reg, (0 << (chan)) | (1 << ((chan) + 8)))
4729 +static int dmac_alloc_channel(struct dma_controller *_dmac)
4731 + struct dw_dma_controller *dmac = to_dw_dmac(_dmac);
4732 + struct dw_dma_channel *chan;
4733 + unsigned long flags;
4736 + spin_lock_irqsave(&dmac->lock, flags);
4737 + for (i = 0; i < DMAC_NR_CHANNELS; i++)
4738 + if (dmac->channel[i].state == CH_STATE_FREE)
4741 + if (i < DMAC_NR_CHANNELS) {
4742 + chan = &dmac->channel[i];
4743 + chan->state = CH_STATE_ALLOCATED;
4748 + spin_unlock_irqrestore(&dmac->lock, flags);
4753 +static void dmac_release_channel(struct dma_controller *_dmac, int channel)
4755 + struct dw_dma_controller *dmac = to_dw_dmac(_dmac);
4757 + BUG_ON(channel >= DMAC_NR_CHANNELS
4758 + || dmac->channel[channel].state != CH_STATE_ALLOCATED);
4760 + dmac->channel[channel].state = CH_STATE_FREE;
4763 +static struct dw_dma_block *allocate_blocks(struct dw_dma_controller *dmac,
4764 + unsigned int nr_blocks)
4766 + struct dw_dma_block *block;
4770 + block = kmalloc(nr_blocks * sizeof(*block),
4772 + if (unlikely(!block))
4775 + for (i = 0; i < nr_blocks; i++) {
4776 + p = dma_pool_alloc(dmac->lli_pool, GFP_KERNEL,
4777 + &block[i].lli_dma_addr);
4778 + block[i].lli_vaddr = p;
4786 + for (i = 0; i < nr_blocks; i++) {
4787 + if (!block[i].lli_vaddr)
4789 + dma_pool_free(dmac->lli_pool, block[i].lli_vaddr,
4790 + block[i].lli_dma_addr);
4796 +static void cleanup_channel(struct dw_dma_controller *dmac,
4797 + struct dw_dma_channel *chan)
4801 + if (chan->nr_blocks > 1) {
4802 + for (i = 0; i < chan->nr_blocks; i++)
4803 + dma_pool_free(dmac->lli_pool, chan->block[i].lli_vaddr,
4804 + chan->block[i].lli_dma_addr);
4805 + kfree(chan->block);
4808 + chan->state = CH_STATE_ALLOCATED;
4811 +static int dmac_prepare_request_sg(struct dma_controller *_dmac,
4812 + struct dma_request_sg *req)
4814 + struct dw_dma_controller *dmac = to_dw_dmac(_dmac);
4815 + struct dw_dma_channel *chan;
4816 + unsigned long ctlhi, ctllo, cfghi, cfglo;
4817 + unsigned long block_size;
4818 + unsigned int nr_blocks;
4819 + int ret, i, direction;
4820 + unsigned long flags;
4822 + spin_lock_irqsave(&dmac->lock, flags);
4825 + if (req->req.channel >= DMAC_NR_CHANNELS
4826 + || dmac->channel[req->req.channel].state != CH_STATE_ALLOCATED
4827 + || req->block_size > DMAC_MAX_BLOCKSIZE) {
4828 + spin_unlock_irqrestore(&dmac->lock, flags);
4832 + chan = &dmac->channel[req->req.channel];
4833 + chan->state = CH_STATE_BUSY;
4834 + chan->req_sg = req;
4835 + chan->is_cyclic = 0;
4838 + * We have marked the channel as busy, so no need to keep the
4839 + * lock as long as we only touch the channel-specific
4842 + spin_unlock_irqrestore(&dmac->lock, flags);
4845 + * There may be limitations in the driver and/or the DMA
4846 + * controller that prevents us from sending a whole
4847 + * scatterlist item in one go. Taking this into account,
4848 + * calculate the number of block transfers we need to set up.
4850 + * FIXME: Let the peripheral driver know about the maximum
4851 + * block size we support. We really don't want to use a
4852 + * different block size than what was suggested by the
4855 + * Each block will get its own Linked List Item (LLI) below.
4857 + block_size = req->block_size;
4858 + nr_blocks = req->nr_blocks;
4859 + pr_debug("block_size %lu, nr_blocks %u nr_sg = %u\n",
4860 + block_size, nr_blocks, req->nr_sg);
4862 + BUG_ON(nr_blocks == 0);
4863 + chan->nr_blocks = nr_blocks;
4866 + cfglo = cfghi = 0;
4867 + switch (req->direction) {
4868 + case DMA_DIR_MEM_TO_PERIPH:
4869 + direction = DMA_TO_DEVICE;
4870 + cfghi = req->periph_id << (43 - 32);
4873 + case DMA_DIR_PERIPH_TO_MEM:
4874 + direction = DMA_FROM_DEVICE;
4875 + cfghi = req->periph_id << (39 - 32);
4878 + goto out_unclaim_channel;
4881 + chan->direction = direction;
4883 + dmac_chan_writel_hi(dmac, req->req.channel, CFG, cfghi);
4884 + dmac_chan_writel_lo(dmac, req->req.channel, CFG, cfglo);
4886 + ctlhi = block_size >> req->width;
4887 + ctllo = ((req->direction << 20)
4888 + // | (1 << 14) | (1 << 11) // source/dest burst trans len
4889 + | (req->width << 4) | (req->width << 1)
4890 + | (1 << 0)); // interrupt enable
4892 + if (nr_blocks == 1) {
4893 + /* Only one block: No need to use block chaining */
4894 + if (direction == DMA_TO_DEVICE) {
4895 + dmac_chan_writel_lo(dmac, req->req.channel, SAR,
4896 + req->sg->dma_address);
4897 + dmac_chan_writel_lo(dmac, req->req.channel, DAR,
4899 + ctllo |= 2 << 7; // no dst increment
4901 + dmac_chan_writel_lo(dmac, req->req.channel, SAR,
4903 + dmac_chan_writel_lo(dmac, req->req.channel, DAR,
4904 + req->sg->dma_address);
4905 + ctllo |= 2 << 9; // no src increment
4907 + dmac_chan_writel_lo(dmac, req->req.channel, CTL, ctllo);
4908 + dmac_chan_writel_hi(dmac, req->req.channel, CTL, ctlhi);
4909 + pr_debug("ctl hi:lo 0x%lx:%lx\n", ctlhi, ctllo);
4911 + struct dw_dma_lli *lli, *lli_prev = NULL;
4912 + int j = 0, offset = 0;
4915 + chan->block = allocate_blocks(dmac, nr_blocks);
4917 + goto out_unclaim_channel;
4919 + if (direction == DMA_TO_DEVICE)
4920 + ctllo |= 1 << 28 | 1 << 27 | 2 << 7;
4922 + ctllo |= 1 << 28 | 1 << 27 | 2 << 9;
4925 + * Map scatterlist items to blocks. One scatterlist
4926 + * item may need more than one block for the reasons
4927 + * mentioned above.
4929 + for (i = 0; i < nr_blocks; i++) {
4930 + lli = chan->block[i].lli_vaddr;
4932 + lli_prev->llp = chan->block[i].lli_dma_addr;
4933 + pr_debug("lli[%d] (0x%p/0x%x): 0x%x 0x%x 0x%x 0x%x 0x%x\n",
4934 + i - 1, chan->block[i - 1].lli_vaddr,
4935 + chan->block[i - 1].lli_dma_addr,
4936 + lli_prev->sar, lli_prev->dar, lli_prev->llp,
4937 + lli_prev->ctllo, lli_prev->ctlhi);
4940 + lli->ctllo = ctllo;
4941 + lli->ctlhi = ctlhi;
4942 + if (direction == DMA_TO_DEVICE) {
4943 + lli->sar = req->sg[j].dma_address + offset;
4944 + lli->dar = req->data_reg;
4946 + lli->sar = req->data_reg;
4947 + lli->dar = req->sg[j].dma_address + offset;
4951 + offset += block_size;
4952 + if (offset > req->sg[j].length) {
4958 + pr_debug("lli[%d] (0x%p/0x%x): 0x%x 0x%x 0x%x 0x%x 0x%x\n",
4959 + i - 1, chan->block[i - 1].lli_vaddr,
4960 + chan->block[i - 1].lli_dma_addr, lli_prev->sar,
4961 + lli_prev->dar, lli_prev->llp,
4962 + lli_prev->ctllo, lli_prev->ctlhi);
4965 + * SAR, DAR and CTL are initialized from the LLI. We
4966 + * only have to enable the LLI bits in CTL.
4968 + dmac_chan_writel_hi(dmac, req->req.channel, CTL, 0);
4969 + dmac_chan_writel_lo(dmac, req->req.channel, LLP,
4970 + chan->block[0].lli_dma_addr);
4971 + dmac_chan_writel_lo(dmac, req->req.channel, CTL, 1 << 28 | 1 << 27);
4974 + set_channel_bit(dmac, MASK_XFER, req->req.channel);
4975 + set_channel_bit(dmac, MASK_ERROR, req->req.channel);
4976 + if (req->req.block_complete)
4977 + set_channel_bit(dmac, MASK_BLOCK, req->req.channel);
4979 + clear_channel_bit(dmac, MASK_BLOCK, req->req.channel);
4983 +out_unclaim_channel:
4984 + chan->state = CH_STATE_ALLOCATED;
4988 +static int dmac_prepare_request_cyclic(struct dma_controller *_dmac,
4989 + struct dma_request_cyclic *req)
4991 + struct dw_dma_controller *dmac = to_dw_dmac(_dmac);
4992 + struct dw_dma_channel *chan;
4993 + unsigned long ctlhi, ctllo, cfghi, cfglo;
4994 + unsigned long block_size;
4995 + int ret, i, direction;
4996 + unsigned long flags;
4998 + spin_lock_irqsave(&dmac->lock, flags);
5000 + block_size = (req->buffer_size/req->periods) >> req->width;
5003 + if (req->req.channel >= DMAC_NR_CHANNELS
5004 + || dmac->channel[req->req.channel].state != CH_STATE_ALLOCATED
5005 + || (req->periods == 0)
5006 + || block_size > DMAC_MAX_BLOCKSIZE) {
5007 + spin_unlock_irqrestore(&dmac->lock, flags);
5011 + chan = &dmac->channel[req->req.channel];
5012 + chan->state = CH_STATE_BUSY;
5013 + chan->is_cyclic = 1;
5014 + chan->req_cyclic = req;
5017 + * We have marked the channel as busy, so no need to keep the
5018 + * lock as long as we only touch the channel-specific
5021 + spin_unlock_irqrestore(&dmac->lock, flags);
5026 + BUG_ON(req->buffer_size % req->periods);
5027 + /* printk(KERN_INFO "block_size = %lu, periods = %u\n", block_size, req->periods); */
5029 + chan->nr_blocks = req->periods;
5032 + cfglo = cfghi = 0;
5033 + switch (req->direction) {
5034 + case DMA_DIR_MEM_TO_PERIPH:
5035 + direction = DMA_TO_DEVICE;
5036 + cfghi = req->periph_id << (43 - 32);
5039 + case DMA_DIR_PERIPH_TO_MEM:
5040 + direction = DMA_FROM_DEVICE;
5041 + cfghi = req->periph_id << (39 - 32);
5044 + goto out_unclaim_channel;
5047 + chan->direction = direction;
5049 + dmac_chan_writel_hi(dmac, req->req.channel, CFG, cfghi);
5050 + dmac_chan_writel_lo(dmac, req->req.channel, CFG, cfglo);
5052 + ctlhi = block_size;
5053 + ctllo = ((req->direction << 20)
5054 + | (req->width << 4) | (req->width << 1)
5055 + | (1 << 0)); // interrupt enable
5058 + struct dw_dma_lli *lli = NULL, *lli_prev = NULL;
5061 + chan->block = allocate_blocks(dmac, req->periods);
5063 + goto out_unclaim_channel;
5065 + if (direction == DMA_TO_DEVICE)
5066 + ctllo |= 1 << 28 | 1 << 27 | 2 << 7;
5068 + ctllo |= 1 << 28 | 1 << 27 | 2 << 9;
5071 + * Set up a linked list items where each period gets
5072 + * an item. The linked list item for the last period
5073 + * points back to the star of the buffer making a
5076 + for (i = 0; i < req->periods; i++) {
5077 + lli = chan->block[i].lli_vaddr;
5079 + lli_prev->llp = chan->block[i].lli_dma_addr;
5080 + /* printk(KERN_INFO "lli[%d] (0x%p/0x%x): 0x%x 0x%x 0x%x 0x%x 0x%x\n",
5081 + i - 1, chan->block[i - 1].lli_vaddr,
5082 + chan->block[i - 1].lli_dma_addr,
5083 + lli_prev->sar, lli_prev->dar, lli_prev->llp,
5084 + lli_prev->ctllo, lli_prev->ctlhi);*/
5087 + lli->ctllo = ctllo;
5088 + lli->ctlhi = ctlhi;
5089 + if (direction == DMA_TO_DEVICE) {
5090 + lli->sar = req->buffer_start + i*(block_size << req->width);
5091 + lli->dar = req->data_reg;
5093 + lli->sar = req->data_reg;
5094 + lli->dar = req->buffer_start + i*(block_size << req->width);
5098 + lli->llp = chan->block[0].lli_dma_addr;
5100 + /*printk(KERN_INFO "lli[%d] (0x%p/0x%x): 0x%x 0x%x 0x%x 0x%x 0x%x\n",
5101 + i - 1, chan->block[i - 1].lli_vaddr,
5102 + chan->block[i - 1].lli_dma_addr, lli_prev->sar,
5103 + lli_prev->dar, lli_prev->llp,
5104 + lli_prev->ctllo, lli_prev->ctlhi); */
5107 + * SAR, DAR and CTL are initialized from the LLI. We
5108 + * only have to enable the LLI bits in CTL.
5110 + dmac_chan_writel_lo(dmac, req->req.channel, LLP,
5111 + chan->block[0].lli_dma_addr);
5112 + dmac_chan_writel_lo(dmac, req->req.channel, CTL, 1 << 28 | 1 << 27);
5115 + clear_channel_bit(dmac, MASK_XFER, req->req.channel);
5116 + set_channel_bit(dmac, MASK_ERROR, req->req.channel);
5117 + if (req->req.block_complete)
5118 + set_channel_bit(dmac, MASK_BLOCK, req->req.channel);
5120 + clear_channel_bit(dmac, MASK_BLOCK, req->req.channel);
5124 +out_unclaim_channel:
5125 + chan->state = CH_STATE_ALLOCATED;
5129 +static int dmac_start_request(struct dma_controller *_dmac,
5130 + unsigned int channel)
5132 + struct dw_dma_controller *dmac = to_dw_dmac(_dmac);
5134 + BUG_ON(channel >= DMAC_NR_CHANNELS);
5136 + set_channel_bit(dmac, CH_EN, channel);
5141 +static dma_addr_t dmac_get_current_pos(struct dma_controller *_dmac,
5142 + unsigned int channel)
5144 + struct dw_dma_controller *dmac = to_dw_dmac(_dmac);
5145 + struct dw_dma_channel *chan;
5146 + dma_addr_t current_pos;
5148 + BUG_ON(channel >= DMAC_NR_CHANNELS);
5150 + chan = &dmac->channel[channel];
5152 + switch (chan->direction) {
5153 + case DMA_TO_DEVICE:
5154 + current_pos = dmac_chan_readl_lo(dmac, channel, SAR);
5156 + case DMA_FROM_DEVICE:
5157 + current_pos = dmac_chan_readl_lo(dmac, channel, DAR);
5164 + if (!current_pos) {
5165 + if (chan->is_cyclic) {
5166 + current_pos = chan->req_cyclic->buffer_start;
5168 + current_pos = chan->req_sg->sg->dma_address;
5172 + return current_pos;
5176 +static int dmac_stop_request(struct dma_controller *_dmac,
5177 + unsigned int channel)
5179 + struct dw_dma_controller *dmac = to_dw_dmac(_dmac);
5180 + struct dw_dma_channel *chan;
5182 + BUG_ON(channel >= DMAC_NR_CHANNELS);
5184 + chan = &dmac->channel[channel];
5185 + pr_debug("stop: st%u s%08x d%08x l%08x ctl0x%08x:0x%08x\n",
5186 + chan->state, dmac_chan_readl_lo(dmac, channel, SAR),
5187 + dmac_chan_readl_lo(dmac, channel, DAR),
5188 + dmac_chan_readl_lo(dmac, channel, LLP),
5189 + dmac_chan_readl_hi(dmac, channel, CTL),
5190 + dmac_chan_readl_lo(dmac, channel, CTL));
5192 + if (chan->state == CH_STATE_BUSY) {
5193 + clear_channel_bit(dmac, CH_EN, channel);
5194 + cleanup_channel(dmac, &dmac->channel[channel]);
5201 +static void dmac_block_complete(struct dw_dma_controller *dmac)
5203 + struct dw_dma_channel *chan;
5204 + unsigned long status, chanid;
5206 + status = dmac_readl_lo(dmac, STATUS_BLOCK);
5209 + struct dma_request *req;
5210 + chanid = __ffs(status);
5211 + chan = &dmac->channel[chanid];
5213 + if (chan->is_cyclic) {
5214 + BUG_ON(!chan->req_cyclic
5215 + || !chan->req_cyclic->req.block_complete);
5216 + req = &chan->req_cyclic->req;
5218 + BUG_ON(!chan->req_sg || !chan->req_sg->req.block_complete);
5219 + req = &chan->req_sg->req;
5221 + dmac_writel_lo(dmac, CLEAR_BLOCK, 1 << chanid);
5222 + req->block_complete(req);
5223 + status = dmac_readl_lo(dmac, STATUS_BLOCK);
5227 +static void dmac_xfer_complete(struct dw_dma_controller *dmac)
5229 + struct dw_dma_channel *chan;
5230 + struct dma_request *req;
5231 + unsigned long status, chanid;
5233 + status = dmac_readl_lo(dmac, STATUS_XFER);
5236 + chanid = __ffs(status);
5237 + chan = &dmac->channel[chanid];
5239 + dmac_writel_lo(dmac, CLEAR_XFER, 1 << chanid);
5241 + req = &chan->req_sg->req;
5243 + cleanup_channel(dmac, chan);
5244 + if (req->xfer_complete)
5245 + req->xfer_complete(req);
5247 + status = dmac_readl_lo(dmac, STATUS_XFER);
5251 +static void dmac_error(struct dw_dma_controller *dmac)
5253 + struct dw_dma_channel *chan;
5254 + unsigned long status, chanid;
5256 + status = dmac_readl_lo(dmac, STATUS_ERROR);
5259 + struct dma_request *req;
5261 + chanid = __ffs(status);
5262 + chan = &dmac->channel[chanid];
5264 + dmac_writel_lo(dmac, CLEAR_ERROR, 1 << chanid);
5265 + clear_channel_bit(dmac, CH_EN, chanid);
5267 + if (chan->is_cyclic) {
5268 + BUG_ON(!chan->req_cyclic);
5269 + req = &chan->req_cyclic->req;
5271 + BUG_ON(!chan->req_sg);
5272 + req = &chan->req_sg->req;
5275 + cleanup_channel(dmac, chan);
5279 + status = dmac_readl_lo(dmac, STATUS_XFER);
5283 +static irqreturn_t dmac_interrupt(int irq, void *dev_id)
5285 + struct dw_dma_controller *dmac = dev_id;
5286 + unsigned long status;
5287 + int ret = IRQ_NONE;
5289 + spin_lock(&dmac->lock);
5291 + status = dmac_readl_lo(dmac, STATUS_INT);
5294 + ret = IRQ_HANDLED;
5295 + if (status & 0x10)
5297 + if (status & 0x02)
5298 + dmac_block_complete(dmac);
5299 + if (status & 0x01)
5300 + dmac_xfer_complete(dmac);
5302 + status = dmac_readl_lo(dmac, STATUS_INT);
5305 + spin_unlock(&dmac->lock);
5309 +static int __devinit dmac_probe(struct platform_device *pdev)
5311 + struct dw_dma_controller *dmac;
5312 + struct resource *regs;
5315 + regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
5319 + dmac = kmalloc(sizeof(*dmac), GFP_KERNEL);
5322 + memset(dmac, 0, sizeof(*dmac));
5324 + dmac->hclk = clk_get(&pdev->dev, "hclk");
5325 + if (IS_ERR(dmac->hclk)) {
5326 + ret = PTR_ERR(dmac->hclk);
5327 + goto out_free_dmac;
5329 + clk_enable(dmac->hclk);
5332 + dmac->lli_pool = dma_pool_create("dmac", &pdev->dev,
5333 + sizeof(struct dw_dma_lli), 4, 0);
5334 + if (!dmac->lli_pool)
5335 + goto out_disable_clk;
5337 + spin_lock_init(&dmac->lock);
5338 + dmac->dma.dev = &pdev->dev;
5339 + dmac->dma.alloc_channel = dmac_alloc_channel;
5340 + dmac->dma.release_channel = dmac_release_channel;
5341 + dmac->dma.prepare_request_sg = dmac_prepare_request_sg;
5342 + dmac->dma.prepare_request_cyclic = dmac_prepare_request_cyclic;
5343 + dmac->dma.start_request = dmac_start_request;
5344 + dmac->dma.stop_request = dmac_stop_request;
5345 + dmac->dma.get_current_pos = dmac_get_current_pos;
5347 + dmac->regs = ioremap(regs->start, regs->end - regs->start + 1);
5349 + goto out_free_pool;
5351 + ret = request_irq(platform_get_irq(pdev, 0), dmac_interrupt,
5352 + IRQF_SAMPLE_RANDOM, pdev->name, dmac);
5354 + goto out_unmap_regs;
5356 + /* Enable the DMA controller */
5357 + dmac_writel_lo(dmac, CFG, 1);
5359 + register_dma_controller(&dmac->dma);
5362 + "dmac%d: DesignWare DMA controller at 0x%p irq %d\n",
5363 + dmac->dma.id, dmac->regs, platform_get_irq(pdev, 0));
5368 + iounmap(dmac->regs);
5370 + dma_pool_destroy(dmac->lli_pool);
5372 + clk_disable(dmac->hclk);
5373 + clk_put(dmac->hclk);
5379 +static struct platform_driver dmac_driver = {
5380 + .probe = dmac_probe,
5386 +static int __init dmac_init(void)
5388 + return platform_driver_register(&dmac_driver);
5390 +subsys_initcall(dmac_init);
5392 +static void __exit dmac_exit(void)
5394 + platform_driver_unregister(&dmac_driver);
5396 +module_exit(dmac_exit);
5398 +MODULE_DESCRIPTION("Synopsys DesignWare DMA Controller driver");
5399 +MODULE_AUTHOR("Haavard Skinnemoen <hskinnemoen@atmel.com>");
5400 +MODULE_LICENSE("GPL");
5402 +++ b/arch/avr32/drivers/dw-dmac.h
5405 + * Driver for the Synopsys DesignWare DMA Controller
5407 + * Copyright (C) 2005-2006 Atmel Corporation
5409 + * This program is free software; you can redistribute it and/or modify
5410 + * it under the terms of the GNU General Public License version 2 as
5411 + * published by the Free Software Foundation.
5413 +#ifndef __AVR32_DW_DMAC_H__
5414 +#define __AVR32_DW_DMAC_H__
5416 +#define DW_DMAC_CFG 0x398
5417 +#define DW_DMAC_CH_EN 0x3a0
5419 +#define DW_DMAC_STATUS_XFER 0x2e8
5420 +#define DW_DMAC_STATUS_BLOCK 0x2f0
5421 +#define DW_DMAC_STATUS_ERROR 0x308
5423 +#define DW_DMAC_MASK_XFER 0x310
5424 +#define DW_DMAC_MASK_BLOCK 0x318
5425 +#define DW_DMAC_MASK_ERROR 0x330
5427 +#define DW_DMAC_CLEAR_XFER 0x338
5428 +#define DW_DMAC_CLEAR_BLOCK 0x340
5429 +#define DW_DMAC_CLEAR_ERROR 0x358
5431 +#define DW_DMAC_STATUS_INT 0x360
5433 +#define DW_DMAC_CHAN_SAR 0x000
5434 +#define DW_DMAC_CHAN_DAR 0x008
5435 +#define DW_DMAC_CHAN_LLP 0x010
5436 +#define DW_DMAC_CHAN_CTL 0x018
5437 +#define DW_DMAC_CHAN_SSTAT 0x020
5438 +#define DW_DMAC_CHAN_DSTAT 0x028
5439 +#define DW_DMAC_CHAN_SSTATAR 0x030
5440 +#define DW_DMAC_CHAN_DSTATAR 0x038
5441 +#define DW_DMAC_CHAN_CFG 0x040
5442 +#define DW_DMAC_CHAN_SGR 0x048
5443 +#define DW_DMAC_CHAN_DSR 0x050
5445 +#endif /* __AVR32_DW_DMAC_H__ */
5447 +++ b/arch/avr32/drivers/Makefile
5449 +obj-$(CONFIG_DW_DMAC) += dw-dmac.o
5450 --- a/arch/avr32/Kconfig
5451 +++ b/arch/avr32/Kconfig
5456 +config GENERIC_CLOCKEVENTS
5459 config RWSEM_XCHGADD_ALGORITHM
5463 config ARCH_HAS_ILOG2_U64
5466 +config ARCH_SUPPORTS_OPROFILE
5469 config GENERIC_HWEIGHT
5474 menu "System Type and features"
5476 +source "kernel/time/Kconfig"
5478 config SUBARCH_AVR32B
5483 select PERFORMANCE_COUNTERS
5486 - prompt "AVR32 CPU type"
5487 - default CPU_AT32AP7000
5492 -config CPU_AT32AP7000
5494 +# AP7000 derivatives
5495 +config CPU_AT32AP700X
5497 select PLATFORM_AT32AP
5501 -# CPU Daughterboards for ATSTK1000
5502 -config BOARD_ATSTK1002
5503 +config CPU_AT32AP7000
5505 + select CPU_AT32AP700X
5506 +config CPU_AT32AP7001
5508 + select CPU_AT32AP700X
5509 +config CPU_AT32AP7002
5511 + select CPU_AT32AP700X
5514 prompt "AVR32 board type"
5515 @@ -101,15 +113,18 @@
5517 config BOARD_ATSTK1000
5518 bool "ATSTK1000 evaluation board"
5519 - select BOARD_ATSTK1002 if CPU_AT32AP7000
5521 config BOARD_ATNGW100
5522 bool "ATNGW100 Network Gateway"
5523 + select CPU_AT32AP7000
5527 source "arch/avr32/boards/atstk1000/Kconfig"
5530 +source "arch/avr32/boards/atngw100/Kconfig"
5534 prompt "Boot loader type"
5535 @@ -123,15 +138,15 @@
5539 - default 0x10000000 if LOADER_U_BOOT=y && CPU_AT32AP7000=y
5540 + default 0x10000000 if LOADER_U_BOOT=y && CPU_AT32AP700X=y
5542 config ENTRY_ADDRESS
5544 - default 0x90000000 if LOADER_U_BOOT=y && CPU_AT32AP7000=y
5545 + default 0x90000000 if LOADER_U_BOOT=y && CPU_AT32AP700X=y
5549 - default 0x10000000 if CPU_AT32AP7000=y
5550 + default 0x10000000 if CPU_AT32AP700X=y
5552 source "kernel/Kconfig.preempt"
5554 @@ -163,6 +178,20 @@
5555 enabling Nexus-compliant debuggers to keep track of the PID of the
5556 currently executing task.
5558 +config NMI_DEBUGGING
5559 + bool "NMI Debugging"
5562 + Say Y here and pass the nmi_debug command-line parameter to
5563 + the kernel to turn on NMI debugging. Depending on the value
5564 + of the nmi_debug option, various pieces of information will
5565 + be dumped to the console when a Non-Maskable Interrupt
5569 + tristate "Synopsys DesignWare DMA Controller support"
5570 + default y if CPU_AT32AP7000
5572 # FPU emulation goes here
5574 source "kernel/Kconfig.hz"
5579 +source "kernel/Kconfig.instrumentation"
5581 source "arch/avr32/Kconfig.debug"
5583 source "security/Kconfig"
5584 --- a/arch/avr32/Kconfig.debug
5585 +++ b/arch/avr32/Kconfig.debug
5588 source "lib/Kconfig.debug"
5592 - depends on DEBUG_KERNEL
5594 - Kprobes allows you to trap at almost any kernel address and
5595 - execute a callback function. register_kprobe() establishes
5596 - a probepoint and specifies the callback. Kprobes is useful
5597 - for kernel debugging, non-intrusive instrumentation and testing.
5598 - If in doubt, say "N".
5601 --- a/arch/avr32/kernel/cpu.c
5602 +++ b/arch/avr32/kernel/cpu.c
5604 #include <linux/percpu.h>
5605 #include <linux/param.h>
5606 #include <linux/errno.h>
5607 +#include <linux/clk.h>
5609 #include <asm/setup.h>
5610 #include <asm/sysreg.h>
5611 @@ -187,9 +188,20 @@
5613 subsys_initcall(topology_init);
5615 +struct chip_id_map {
5621 +static const struct chip_id_map chip_names[] = {
5622 + { .mid = 0x1f, .pn = 0x1e82, .name = "AT32AP700x" },
5624 +#define NR_CHIP_NAMES ARRAY_SIZE(chip_names)
5626 static const char *cpu_names[] = {
5631 #define NR_CPU_NAMES ARRAY_SIZE(cpu_names)
5633 @@ -206,12 +218,32 @@
5637 +static const char *cpu_feature_flags[] = {
5638 + "rmw", "dsp", "simd", "ocd", "perfctr", "java", "fpu",
5641 +static const char *get_chip_name(struct avr32_cpuinfo *cpu)
5644 + unsigned int mid = avr32_get_manufacturer_id(cpu);
5645 + unsigned int pn = avr32_get_product_number(cpu);
5647 + for (i = 0; i < NR_CHIP_NAMES; i++) {
5648 + if (chip_names[i].mid == mid && chip_names[i].pn == pn)
5649 + return chip_names[i].name;
5652 + return "(unknown)";
5655 void __init setup_processor(void)
5657 unsigned long config0, config1;
5658 unsigned long features;
5659 unsigned cpu_id, cpu_rev, arch_id, arch_rev, mmu_type;
5660 + unsigned device_id;
5664 config0 = sysreg_read(CONFIG0);
5665 config1 = sysreg_read(CONFIG1);
5666 @@ -221,11 +253,14 @@
5667 arch_rev = SYSREG_BFEXT(AR, config0);
5668 mmu_type = SYSREG_BFEXT(MMUT, config0);
5670 + device_id = ocd_read(DID);
5672 boot_cpu_data.arch_type = arch_id;
5673 boot_cpu_data.cpu_type = cpu_id;
5674 boot_cpu_data.arch_revision = arch_rev;
5675 boot_cpu_data.cpu_revision = cpu_rev;
5676 boot_cpu_data.tlb_config = mmu_type;
5677 + boot_cpu_data.device_id = device_id;
5679 tmp = SYSREG_BFEXT(ILSZ, config1);
5681 @@ -247,41 +282,34 @@
5685 - printk ("CPU: %s [%02x] revision %d (%s revision %d)\n",
5686 + printk ("CPU: %s chip revision %c\n", get_chip_name(&boot_cpu_data),
5687 + avr32_get_chip_revision(&boot_cpu_data) + 'A');
5688 + printk ("CPU: %s [%02x] core revision %d (%s arch revision %d)\n",
5689 cpu_names[cpu_id], cpu_id, cpu_rev,
5690 arch_names[arch_id], arch_rev);
5691 printk ("CPU: MMU configuration: %s\n", mmu_types[mmu_type]);
5693 printk ("CPU: features:");
5695 - if (config0 & SYSREG_BIT(CONFIG0_R)) {
5696 + if (config0 & SYSREG_BIT(CONFIG0_R))
5697 features |= AVR32_FEATURE_RMW;
5700 - if (config0 & SYSREG_BIT(CONFIG0_D)) {
5701 + if (config0 & SYSREG_BIT(CONFIG0_D))
5702 features |= AVR32_FEATURE_DSP;
5705 - if (config0 & SYSREG_BIT(CONFIG0_S)) {
5706 + if (config0 & SYSREG_BIT(CONFIG0_S))
5707 features |= AVR32_FEATURE_SIMD;
5710 - if (config0 & SYSREG_BIT(CONFIG0_O)) {
5711 + if (config0 & SYSREG_BIT(CONFIG0_O))
5712 features |= AVR32_FEATURE_OCD;
5715 - if (config0 & SYSREG_BIT(CONFIG0_P)) {
5716 + if (config0 & SYSREG_BIT(CONFIG0_P))
5717 features |= AVR32_FEATURE_PCTR;
5718 - printk(" perfctr");
5720 - if (config0 & SYSREG_BIT(CONFIG0_J)) {
5721 + if (config0 & SYSREG_BIT(CONFIG0_J))
5722 features |= AVR32_FEATURE_JAVA;
5725 - if (config0 & SYSREG_BIT(CONFIG0_F)) {
5726 + if (config0 & SYSREG_BIT(CONFIG0_F))
5727 features |= AVR32_FEATURE_FPU;
5731 + for (i = 0; i < ARRAY_SIZE(cpu_feature_flags); i++)
5732 + if (features & (1 << i))
5733 + printk(" %s", cpu_feature_flags[i]);
5736 boot_cpu_data.features = features;
5740 unsigned int icache_size, dcache_size;
5741 unsigned int cpu = smp_processor_id();
5742 + unsigned int freq;
5745 icache_size = boot_cpu_data.icache.ways *
5746 boot_cpu_data.icache.sets *
5747 @@ -301,15 +331,21 @@
5749 seq_printf(m, "processor\t: %d\n", cpu);
5751 + seq_printf(m, "chip type\t: %s revision %c\n",
5752 + get_chip_name(&boot_cpu_data),
5753 + avr32_get_chip_revision(&boot_cpu_data) + 'A');
5754 if (boot_cpu_data.arch_type < NR_ARCH_NAMES)
5755 - seq_printf(m, "cpu family\t: %s revision %d\n",
5756 + seq_printf(m, "cpu arch\t: %s revision %d\n",
5757 arch_names[boot_cpu_data.arch_type],
5758 boot_cpu_data.arch_revision);
5759 if (boot_cpu_data.cpu_type < NR_CPU_NAMES)
5760 - seq_printf(m, "cpu type\t: %s revision %d\n",
5761 + seq_printf(m, "cpu core\t: %s revision %d\n",
5762 cpu_names[boot_cpu_data.cpu_type],
5763 boot_cpu_data.cpu_revision);
5765 + freq = (clk_get_rate(boot_cpu_data.clk) + 500) / 1000;
5766 + seq_printf(m, "cpu MHz\t\t: %u.%03u\n", freq / 1000, freq % 1000);
5768 seq_printf(m, "i-cache\t\t: %dK (%u ways x %u sets x %u)\n",
5770 boot_cpu_data.icache.ways,
5771 @@ -320,7 +356,13 @@
5772 boot_cpu_data.dcache.ways,
5773 boot_cpu_data.dcache.sets,
5774 boot_cpu_data.dcache.linesz);
5775 - seq_printf(m, "bogomips\t: %lu.%02lu\n",
5777 + seq_printf(m, "features\t:");
5778 + for (i = 0; i < ARRAY_SIZE(cpu_feature_flags); i++)
5779 + if (boot_cpu_data.features & (1 << i))
5780 + seq_printf(m, " %s", cpu_feature_flags[i]);
5782 + seq_printf(m, "\nbogomips\t: %lu.%02lu\n",
5783 boot_cpu_data.loops_per_jiffy / (500000/HZ),
5784 (boot_cpu_data.loops_per_jiffy / (5000/HZ)) % 100);
5790 -struct seq_operations cpuinfo_op = {
5791 +const struct seq_operations cpuinfo_op = {
5796 +++ b/arch/avr32/kernel/dma-controller.c
5799 + * Preliminary DMA controller framework for AVR32
5801 + * Copyright (C) 2005-2006 Atmel Corporation
5803 + * This program is free software; you can redistribute it and/or modify
5804 + * it under the terms of the GNU General Public License version 2 as
5805 + * published by the Free Software Foundation.
5807 +#include <asm/dma-controller.h>
5809 +static LIST_HEAD(controllers);
5811 +int register_dma_controller(struct dma_controller *dmac)
5813 + static int next_id;
5815 + dmac->id = next_id++;
5816 + list_add_tail(&dmac->list, &controllers);
5820 +EXPORT_SYMBOL(register_dma_controller);
5822 +struct dma_controller *find_dma_controller(int id)
5824 + struct dma_controller *dmac;
5826 + list_for_each_entry(dmac, &controllers, list)
5827 + if (dmac->id == id)
5831 +EXPORT_SYMBOL(find_dma_controller);
5832 --- a/arch/avr32/kernel/entry-avr32b.S
5833 +++ b/arch/avr32/kernel/entry-avr32b.S
5834 @@ -741,26 +741,6 @@
5836 .section .irq.text,"ax",@progbits
5838 -.global cpu_idle_sleep
5841 - get_thread_info r8
5842 - ld.w r9, r8[TI_flags]
5843 - bld r9, TIF_NEED_RESCHED
5844 - brcs cpu_idle_enable_int_and_exit
5845 - sbr r9, TIF_CPU_GOING_TO_SLEEP
5846 - st.w r8[TI_flags], r9
5849 -cpu_idle_skip_sleep:
5851 - ld.w r9, r8[TI_flags]
5852 - cbr r9, TIF_CPU_GOING_TO_SLEEP
5853 - st.w r8[TI_flags], r9
5854 -cpu_idle_enable_int_and_exit:
5861 --- a/arch/avr32/kernel/irq.c
5862 +++ b/arch/avr32/kernel/irq.c
5864 printk("unexpected IRQ %u\n", irq);
5867 +/* May be overridden by platform code */
5868 +int __weak nmi_enable(void)
5873 +void __weak nmi_disable(void)
5878 #ifdef CONFIG_PROC_FS
5879 int show_interrupts(struct seq_file *p, void *v)
5881 --- a/arch/avr32/kernel/kprobes.c
5882 +++ b/arch/avr32/kernel/kprobes.c
5884 void __kprobes arch_arm_kprobe(struct kprobe *p)
5886 pr_debug("arming kprobe at %p\n", p->addr);
5888 *p->addr = BREAKPOINT_INSTRUCTION;
5889 flush_icache_range((unsigned long)p->addr,
5890 (unsigned long)p->addr + sizeof(kprobe_opcode_t));
5892 void __kprobes arch_disarm_kprobe(struct kprobe *p)
5894 pr_debug("disarming kprobe at %p\n", p->addr);
5895 + ocd_disable(NULL);
5896 *p->addr = p->opcode;
5897 flush_icache_range((unsigned long)p->addr,
5898 (unsigned long)p->addr + sizeof(kprobe_opcode_t));
5901 int __init arch_init_kprobes(void)
5903 - printk("KPROBES: Enabling monitor mode (MM|DBE)...\n");
5904 - ocd_write(DC, (1 << OCD_DC_MM_BIT) | (1 << OCD_DC_DBE_BIT));
5906 /* TODO: Register kretprobe trampoline */
5909 --- a/arch/avr32/kernel/Makefile
5910 +++ b/arch/avr32/kernel/Makefile
5913 obj-$(CONFIG_SUBARCH_AVR32B) += entry-avr32b.o
5914 obj-y += syscall_table.o syscall-stubs.o irq.o
5915 -obj-y += setup.o traps.o semaphore.o ptrace.o
5916 +obj-y += setup.o traps.o semaphore.o ocd.o ptrace.o
5917 obj-y += signal.o sys_avr32.o process.o time.o
5918 obj-y += init_task.o switch_to.o cpu.o
5919 +obj-y += dma-controller.o
5920 obj-$(CONFIG_MODULES) += module.o avr32_ksyms.o
5921 obj-$(CONFIG_KPROBES) += kprobes.o
5922 obj-$(CONFIG_STACKTRACE) += stacktrace.o
5923 +obj-$(CONFIG_NMI_DEBUGGING) += nmi_debug.o
5925 +++ b/arch/avr32/kernel/nmi_debug.c
5928 + * Copyright (C) 2007 Atmel Corporation
5930 + * This program is free software; you can redistribute it and/or modify
5931 + * it under the terms of the GNU General Public License version 2 as
5932 + * published by the Free Software Foundation.
5934 +#include <linux/delay.h>
5935 +#include <linux/kdebug.h>
5936 +#include <linux/notifier.h>
5937 +#include <linux/sched.h>
5939 +#include <asm/irq.h>
5942 + NMI_SHOW_STATE = 1 << 0,
5943 + NMI_SHOW_REGS = 1 << 1,
5945 + NMI_DEBOUNCE = 1 << 3,
5948 +static unsigned long nmi_actions;
5950 +static int nmi_debug_notify(struct notifier_block *self,
5951 + unsigned long val, void *data)
5953 + struct die_args *args = data;
5955 + if (likely(val != DIE_NMI))
5956 + return NOTIFY_DONE;
5958 + if (nmi_actions & NMI_SHOW_STATE)
5960 + if (nmi_actions & NMI_SHOW_REGS)
5961 + show_regs(args->regs);
5962 + if (nmi_actions & NMI_DEBOUNCE)
5964 + if (nmi_actions & NMI_DIE)
5965 + return NOTIFY_BAD;
5970 +static struct notifier_block nmi_debug_nb = {
5971 + .notifier_call = nmi_debug_notify,
5974 +static int __init nmi_debug_setup(char *str)
5978 + register_die_notifier(&nmi_debug_nb);
5979 + if (nmi_enable()) {
5980 + printk(KERN_WARNING "Unable to enable NMI.\n");
5987 + for (p = str + 1; *p; p = sep + 1) {
5988 + sep = strchr(p, ',');
5991 + if (strcmp(p, "state") == 0)
5992 + nmi_actions |= NMI_SHOW_STATE;
5993 + else if (strcmp(p, "regs") == 0)
5994 + nmi_actions |= NMI_SHOW_REGS;
5995 + else if (strcmp(p, "debounce") == 0)
5996 + nmi_actions |= NMI_DEBOUNCE;
5997 + else if (strcmp(p, "die") == 0)
5998 + nmi_actions |= NMI_DIE;
6000 + printk(KERN_WARNING "NMI: Unrecognized action `%s'\n",
6008 +__setup("nmi_debug", nmi_debug_setup);
6010 +++ b/arch/avr32/kernel/ocd.c
6013 + * Copyright (C) 2007 Atmel Corporation
6015 + * This program is free software; you can redistribute it and/or modify
6016 + * it under the terms of the GNU General Public License version 2 as
6017 + * published by the Free Software Foundation.
6019 +#include <linux/init.h>
6020 +#include <linux/sched.h>
6021 +#include <linux/spinlock.h>
6023 +#include <asm/ocd.h>
6025 +static long ocd_count;
6026 +static spinlock_t ocd_lock;
6029 + * ocd_enable - enable on-chip debugging
6030 + * @child: task to be debugged
6032 + * If @child is non-NULL, ocd_enable() first checks if debugging has
6033 + * already been enabled for @child, and if it has, does nothing.
6035 + * If @child is NULL (e.g. when debugging the kernel), or debugging
6036 + * has not already been enabled for it, ocd_enable() increments the
6037 + * reference count and enables the debugging hardware.
6039 +void ocd_enable(struct task_struct *child)
6044 + pr_debug("ocd_enable: child=%s [%u]\n",
6045 + child->comm, child->pid);
6047 + pr_debug("ocd_enable (no child)\n");
6049 + if (!child || !test_and_set_tsk_thread_flag(child, TIF_DEBUG)) {
6050 + spin_lock(&ocd_lock);
6052 + dc = ocd_read(DC);
6053 + dc |= (1 << OCD_DC_MM_BIT) | (1 << OCD_DC_DBE_BIT);
6054 + ocd_write(DC, dc);
6055 + spin_unlock(&ocd_lock);
6060 + * ocd_disable - disable on-chip debugging
6061 + * @child: task that was being debugged, but isn't anymore
6063 + * If @child is non-NULL, ocd_disable() checks if debugging is enabled
6064 + * for @child, and if it isn't, does nothing.
6066 + * If @child is NULL (e.g. when debugging the kernel), or debugging is
6067 + * enabled, ocd_disable() decrements the reference count, and if it
6068 + * reaches zero, disables the debugging hardware.
6070 +void ocd_disable(struct task_struct *child)
6075 + pr_debug("ocd_disable (no child)\n");
6076 + else if (test_tsk_thread_flag(child, TIF_DEBUG))
6077 + pr_debug("ocd_disable: child=%s [%u]\n",
6078 + child->comm, child->pid);
6080 + if (!child || test_and_clear_tsk_thread_flag(child, TIF_DEBUG)) {
6081 + spin_lock(&ocd_lock);
6084 + WARN_ON(ocd_count < 0);
6086 + if (ocd_count <= 0) {
6087 + dc = ocd_read(DC);
6088 + dc &= ~((1 << OCD_DC_MM_BIT) | (1 << OCD_DC_DBE_BIT));
6089 + ocd_write(DC, dc);
6091 + spin_unlock(&ocd_lock);
6095 +#ifdef CONFIG_DEBUG_FS
6096 +#include <linux/debugfs.h>
6097 +#include <linux/module.h>
6099 +static struct dentry *ocd_debugfs_root;
6100 +static struct dentry *ocd_debugfs_DC;
6101 +static struct dentry *ocd_debugfs_DS;
6102 +static struct dentry *ocd_debugfs_count;
6104 +static u64 ocd_DC_get(void *data)
6106 + return ocd_read(DC);
6108 +static void ocd_DC_set(void *data, u64 val)
6110 + ocd_write(DC, val);
6112 +DEFINE_SIMPLE_ATTRIBUTE(fops_DC, ocd_DC_get, ocd_DC_set, "0x%08llx\n");
6114 +static u64 ocd_DS_get(void *data)
6116 + return ocd_read(DS);
6118 +DEFINE_SIMPLE_ATTRIBUTE(fops_DS, ocd_DS_get, NULL, "0x%08llx\n");
6120 +static u64 ocd_count_get(void *data)
6124 +DEFINE_SIMPLE_ATTRIBUTE(fops_count, ocd_count_get, NULL, "%lld\n");
6126 +static void ocd_debugfs_init(void)
6128 + struct dentry *root;
6130 + root = debugfs_create_dir("ocd", NULL);
6131 + if (IS_ERR(root) || !root)
6133 + ocd_debugfs_root = root;
6135 + ocd_debugfs_DC = debugfs_create_file("DC", S_IRUSR | S_IWUSR,
6136 + root, NULL, &fops_DC);
6137 + if (!ocd_debugfs_DC)
6140 + ocd_debugfs_DS = debugfs_create_file("DS", S_IRUSR, root,
6142 + if (!ocd_debugfs_DS)
6145 + ocd_debugfs_count = debugfs_create_file("count", S_IRUSR, root,
6146 + NULL, &fops_count);
6147 + if (!ocd_debugfs_count)
6153 + debugfs_remove(ocd_debugfs_DS);
6155 + debugfs_remove(ocd_debugfs_DC);
6157 + debugfs_remove(ocd_debugfs_root);
6159 + printk(KERN_WARNING "OCD: Failed to create debugfs entries\n");
6162 +static inline void ocd_debugfs_init(void)
6168 +static int __init ocd_init(void)
6170 + spin_lock_init(&ocd_lock);
6171 + ocd_debugfs_init();
6174 +arch_initcall(ocd_init);
6175 --- a/arch/avr32/kernel/process.c
6176 +++ b/arch/avr32/kernel/process.c
6178 #include <linux/fs.h>
6179 #include <linux/ptrace.h>
6180 #include <linux/reboot.h>
6181 +#include <linux/tick.h>
6182 #include <linux/uaccess.h>
6183 #include <linux/unistd.h>
6185 #include <asm/sysreg.h>
6186 #include <asm/ocd.h>
6188 +#include <asm/arch/pm.h>
6190 void (*pm_power_off)(void) = NULL;
6191 EXPORT_SYMBOL(pm_power_off);
6193 -extern void cpu_idle_sleep(void);
6196 * This file handles the architecture-dependent parts of process handling..
6200 /* endless idle loop with no priority at all */
6202 + tick_nohz_stop_sched_tick();
6203 while (!need_resched())
6205 + tick_nohz_restart_sched_tick();
6206 preempt_enable_no_resched();
6211 void exit_thread(void)
6213 - /* nothing to do */
6214 + ocd_disable(current);
6217 void flush_thread(void)
6218 @@ -345,6 +348,10 @@
6219 p->thread.cpu_context.ksp = (unsigned long)childregs;
6220 p->thread.cpu_context.pc = (unsigned long)ret_from_fork;
6222 + clear_tsk_thread_flag(p, TIF_DEBUG);
6223 + if ((clone_flags & CLONE_PTRACE) && test_thread_flag(TIF_DEBUG))
6229 --- a/arch/avr32/kernel/ptrace.c
6230 +++ b/arch/avr32/kernel/ptrace.c
6233 clear_tsk_thread_flag(child, TIF_SINGLE_STEP);
6234 clear_tsk_thread_flag(child, TIF_BREAKPOINT);
6235 + ocd_disable(child);
6239 @@ -144,10 +145,6 @@
6243 - pr_debug("ptrace: Enabling monitor mode...\n");
6244 - ocd_write(DC, ocd_read(DC) | (1 << OCD_DC_MM_BIT)
6245 - | (1 << OCD_DC_DBE_BIT));
6248 /* Read the word at location addr in the child process */
6249 case PTRACE_PEEKTEXT:
6250 --- a/arch/avr32/kernel/setup.c
6251 +++ b/arch/avr32/kernel/setup.c
6254 "Failed to allocate framebuffer memory\n");
6257 + memset(__va(fbmem_start), 0, fbmem_size);
6261 --- a/arch/avr32/kernel/signal.c
6262 +++ b/arch/avr32/kernel/signal.c
6263 @@ -270,19 +270,12 @@
6264 if (!user_mode(regs))
6267 - if (try_to_freeze()) {
6269 - if (!signal_pending(current))
6273 if (test_thread_flag(TIF_RESTORE_SIGMASK))
6274 oldset = ¤t->saved_sigmask;
6276 oldset = ¤t->blocked;
6278 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
6281 switch (regs->r12) {
6282 case -ERESTART_RESTARTBLOCK:
6283 --- a/arch/avr32/kernel/time.c
6284 +++ b/arch/avr32/kernel/time.c
6287 * Copyright (C) 2004-2007 Atmel Corporation
6289 - * Based on MIPS implementation arch/mips/kernel/time.c
6290 - * Copyright 2001 MontaVista Software Inc.
6292 * This program is free software; you can redistribute it and/or modify
6293 * it under the terms of the GNU General Public License version 2 as
6294 * published by the Free Software Foundation.
6297 #include <linux/clk.h>
6298 -#include <linux/clocksource.h>
6299 +#include <linux/clockchips.h>
6300 #include <linux/time.h>
6301 #include <linux/module.h>
6302 #include <linux/interrupt.h>
6303 @@ -27,207 +23,133 @@
6305 #include <asm/sections.h>
6307 -/* how many counter cycles in a jiffy? */
6308 -static u32 cycles_per_jiffy;
6309 +#include <asm/arch/pm.h>
6311 -/* the count value for the next timer interrupt */
6312 -static u32 expirelo;
6314 -cycle_t __weak read_cycle_count(void)
6315 +static cycle_t read_cycle_count(void)
6317 return (cycle_t)sysreg_read(COUNT);
6320 -struct clocksource __weak clocksource_avr32 = {
6324 + * The architectural cycle count registers are a fine clocksource unless
6325 + * the system idle loop use sleep states like "idle": the CPU cycles
6326 + * measured by COUNT (and COMPARE) don't happen during sleep states.
6327 + * Their duration also changes if cpufreq changes the CPU clock rate.
6328 + * So we rate the clocksource using COUNT as very low quality.
6330 +static struct clocksource counter = {
6331 + .name = "avr32_counter",
6333 .read = read_cycle_count,
6334 .mask = CLOCKSOURCE_MASK(32),
6336 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
6339 -irqreturn_t __weak timer_interrupt(int irq, void *dev_id);
6341 -struct irqaction timer_irqaction = {
6342 - .handler = timer_interrupt,
6343 - .flags = IRQF_DISABLED,
6348 - * By default we provide the null RTC ops
6350 -static unsigned long null_rtc_get_time(void)
6351 +static irqreturn_t timer_interrupt(int irq, void *dev_id)
6353 - return mktime(2007, 1, 1, 0, 0, 0);
6356 -static int null_rtc_set_time(unsigned long sec)
6360 + struct clock_event_device *evdev = dev_id;
6362 -static unsigned long (*rtc_get_time)(void) = null_rtc_get_time;
6363 -static int (*rtc_set_time)(unsigned long) = null_rtc_set_time;
6365 -static void avr32_timer_ack(void)
6369 - /* Ack this timer interrupt and set the next one */
6370 - expirelo += cycles_per_jiffy;
6371 - /* setting COMPARE to 0 stops the COUNT-COMPARE */
6372 - if (expirelo == 0) {
6373 - sysreg_write(COMPARE, expirelo + 1);
6375 - sysreg_write(COMPARE, expirelo);
6378 + * Disable the interrupt until the clockevent subsystem
6381 + sysreg_write(COMPARE, 0);
6383 - /* Check to see if we have missed any timer interrupts */
6384 - count = sysreg_read(COUNT);
6385 - if ((count - expirelo) < 0x7fffffff) {
6386 - expirelo = count + cycles_per_jiffy;
6387 - sysreg_write(COMPARE, expirelo);
6389 + evdev->event_handler(evdev);
6390 + return IRQ_HANDLED;
6393 -int __weak avr32_hpt_init(void)
6396 - unsigned long mult, shift, count_hz;
6398 - count_hz = clk_get_rate(boot_cpu_data.clk);
6399 - shift = clocksource_avr32.shift;
6400 - mult = clocksource_hz2mult(count_hz, shift);
6401 - clocksource_avr32.mult = mult;
6409 - do_div(tmp, mult);
6411 - cycles_per_jiffy = tmp;
6413 +static struct irqaction timer_irqaction = {
6414 + .handler = timer_interrupt,
6415 + .flags = IRQF_TIMER | IRQF_DISABLED,
6416 + .name = "avr32_comparator",
6419 - ret = setup_irq(0, &timer_irqaction);
6421 - pr_debug("timer: could not request IRQ 0: %d\n", ret);
6424 +static int comparator_next_event(unsigned long delta,
6425 + struct clock_event_device *evdev)
6427 + unsigned long flags;
6429 - printk(KERN_INFO "timer: AT32AP COUNT-COMPARE at irq 0, "
6430 - "%lu.%03lu MHz\n",
6431 - ((count_hz + 500) / 1000) / 1000,
6432 - ((count_hz + 500) / 1000) % 1000);
6433 + raw_local_irq_save(flags);
6437 + /* The time to read COUNT then update COMPARE must be less
6438 + * than the min_delta_ns value for this clockevent source.
6440 + sysreg_write(COMPARE, (sysreg_read(COUNT) + delta) ? : 1);
6443 - * Taken from MIPS c0_hpt_timer_init().
6445 - * The reason COUNT is written twice is probably to make sure we don't get any
6446 - * timer interrupts while we are messing with the counter.
6448 -int __weak avr32_hpt_start(void)
6450 - u32 count = sysreg_read(COUNT);
6451 - expirelo = (count / cycles_per_jiffy + 1) * cycles_per_jiffy;
6452 - sysreg_write(COUNT, expirelo - cycles_per_jiffy);
6453 - sysreg_write(COMPARE, expirelo);
6454 - sysreg_write(COUNT, count);
6455 + raw_local_irq_restore(flags);
6461 - * local_timer_interrupt() does profiling and process accounting on a
6464 - * In UP mode, it is invoked from the (global) timer_interrupt.
6466 -void local_timer_interrupt(int irq, void *dev_id)
6467 +static void comparator_mode(enum clock_event_mode mode,
6468 + struct clock_event_device *evdev)
6471 - profile_tick(CPU_PROFILING);
6472 - update_process_times(user_mode(get_irq_regs()));
6474 + case CLOCK_EVT_MODE_ONESHOT:
6475 + pr_debug("%s: start\n", evdev->name);
6477 + case CLOCK_EVT_MODE_RESUME:
6478 + cpu_disable_idle_sleep();
6480 + case CLOCK_EVT_MODE_UNUSED:
6481 + case CLOCK_EVT_MODE_SHUTDOWN:
6482 + sysreg_write(COMPARE, 0);
6483 + pr_debug("%s: stop\n", evdev->name);
6484 + cpu_enable_idle_sleep();
6491 -irqreturn_t __weak timer_interrupt(int irq, void *dev_id)
6493 - /* ack timer interrupt and try to set next interrupt */
6494 - avr32_timer_ack();
6497 - * Call the generic timer interrupt handler
6499 - write_seqlock(&xtime_lock);
6501 - write_sequnlock(&xtime_lock);
6504 - * In UP mode, we call local_timer_interrupt() to do profiling
6505 - * and process accounting.
6507 - * SMP is not supported yet.
6509 - local_timer_interrupt(irq, dev_id);
6511 - return IRQ_HANDLED;
6513 +static struct clock_event_device comparator = {
6514 + .name = "avr32_comparator",
6515 + .features = CLOCK_EVT_FEAT_ONESHOT,
6518 + .cpumask = CPU_MASK_CPU0,
6519 + .set_next_event = comparator_next_event,
6520 + .set_mode = comparator_mode,
6523 void __init time_init(void)
6525 + unsigned long counter_hz;
6529 - * Make sure we don't get any COMPARE interrupts before we can
6532 - sysreg_write(COMPARE, 0);
6534 - xtime.tv_sec = rtc_get_time();
6535 + xtime.tv_sec = mktime(2007, 1, 1, 0, 0, 0);
6538 set_normalized_timespec(&wall_to_monotonic,
6539 -xtime.tv_sec, -xtime.tv_nsec);
6541 - ret = avr32_hpt_init();
6543 - pr_debug("timer: failed setup: %d\n", ret);
6546 + /* figure rate for counter */
6547 + counter_hz = clk_get_rate(boot_cpu_data.clk);
6548 + counter.mult = clocksource_hz2mult(counter_hz, counter.shift);
6550 - ret = clocksource_register(&clocksource_avr32);
6551 + ret = clocksource_register(&counter);
6553 pr_debug("timer: could not register clocksource: %d\n", ret);
6555 - ret = avr32_hpt_start();
6557 - pr_debug("timer: failed starting: %d\n", ret);
6561 + /* setup COMPARE clockevent */
6562 + comparator.mult = div_sc(counter_hz, NSEC_PER_SEC, comparator.shift);
6563 + comparator.max_delta_ns = clockevent_delta2ns((u32)~0, &comparator);
6564 + comparator.min_delta_ns = clockevent_delta2ns(50, &comparator) + 1;
6566 -static struct sysdev_class timer_class = {
6567 - set_kset_name("timer"),
6569 + sysreg_write(COMPARE, 0);
6570 + timer_irqaction.dev_id = &comparator;
6572 -static struct sys_device timer_device = {
6574 - .cls = &timer_class,
6576 + ret = setup_irq(0, &timer_irqaction);
6578 + pr_debug("timer: could not request IRQ 0: %d\n", ret);
6580 + clockevents_register_device(&comparator);
6582 -static int __init init_timer_sysfs(void)
6584 - int err = sysdev_class_register(&timer_class);
6586 - err = sysdev_register(&timer_device);
6588 + pr_info("%s: irq 0, %lu.%03lu MHz\n", comparator.name,
6589 + ((counter_hz + 500) / 1000) / 1000,
6590 + ((counter_hz + 500) / 1000) % 1000);
6594 -device_initcall(init_timer_sysfs);
6595 --- a/arch/avr32/kernel/traps.c
6596 +++ b/arch/avr32/kernel/traps.c
6598 #include <linux/bug.h>
6599 #include <linux/init.h>
6600 #include <linux/kallsyms.h>
6601 +#include <linux/kdebug.h>
6602 #include <linux/module.h>
6603 #include <linux/notifier.h>
6604 #include <linux/sched.h>
6605 @@ -107,9 +108,23 @@
6607 asmlinkage void do_nmi(unsigned long ecr, struct pt_regs *regs)
6609 - printk(KERN_ALERT "Got Non-Maskable Interrupt, dumping regs\n");
6610 - show_regs_log_lvl(regs, KERN_ALERT);
6611 - show_stack_log_lvl(current, regs->sp, regs, KERN_ALERT);
6616 + ret = notify_die(DIE_NMI, "NMI", regs, 0, ecr, SIGINT);
6622 + die("Fatal Non-Maskable Interrupt", regs, SIGINT);
6627 + printk(KERN_ALERT "Got NMI, but nobody cared. Disabling...\n");
6631 asmlinkage void do_critical_exception(unsigned long ecr, struct pt_regs *regs)
6632 --- a/arch/avr32/mach-at32ap/at32ap7000.c
6636 - * Copyright (C) 2005-2006 Atmel Corporation
6638 - * This program is free software; you can redistribute it and/or modify
6639 - * it under the terms of the GNU General Public License version 2 as
6640 - * published by the Free Software Foundation.
6642 -#include <linux/clk.h>
6643 -#include <linux/fb.h>
6644 -#include <linux/init.h>
6645 -#include <linux/platform_device.h>
6646 -#include <linux/dma-mapping.h>
6647 -#include <linux/spi/spi.h>
6649 -#include <asm/io.h>
6651 -#include <asm/arch/at32ap7000.h>
6652 -#include <asm/arch/board.h>
6653 -#include <asm/arch/portmux.h>
6655 -#include <video/atmel_lcdc.h>
6658 -#include "hmatrix.h"
6663 -#define PBMEM(base) \
6666 - .end = base + 0x3ff, \
6667 - .flags = IORESOURCE_MEM, \
6673 - .flags = IORESOURCE_IRQ, \
6675 -#define NAMED_IRQ(num, _name) \
6680 - .flags = IORESOURCE_IRQ, \
6683 -/* REVISIT these assume *every* device supports DMA, but several
6684 - * don't ... tc, smc, pio, rtc, watchdog, pwm, ps2, and more.
6686 -#define DEFINE_DEV(_name, _id) \
6687 -static u64 _name##_id##_dma_mask = DMA_32BIT_MASK; \
6688 -static struct platform_device _name##_id##_device = { \
6692 - .dma_mask = &_name##_id##_dma_mask, \
6693 - .coherent_dma_mask = DMA_32BIT_MASK, \
6695 - .resource = _name##_id##_resource, \
6696 - .num_resources = ARRAY_SIZE(_name##_id##_resource), \
6698 -#define DEFINE_DEV_DATA(_name, _id) \
6699 -static u64 _name##_id##_dma_mask = DMA_32BIT_MASK; \
6700 -static struct platform_device _name##_id##_device = { \
6704 - .dma_mask = &_name##_id##_dma_mask, \
6705 - .platform_data = &_name##_id##_data, \
6706 - .coherent_dma_mask = DMA_32BIT_MASK, \
6708 - .resource = _name##_id##_resource, \
6709 - .num_resources = ARRAY_SIZE(_name##_id##_resource), \
6712 -#define select_peripheral(pin, periph, flags) \
6713 - at32_select_periph(GPIO_PIN_##pin, GPIO_##periph, flags)
6715 -#define DEV_CLK(_name, devname, bus, _index) \
6716 -static struct clk devname##_##_name = { \
6718 - .dev = &devname##_device.dev, \
6719 - .parent = &bus##_clk, \
6720 - .mode = bus##_clk_mode, \
6721 - .get_rate = bus##_clk_get_rate, \
6722 - .index = _index, \
6725 -static DEFINE_SPINLOCK(pm_lock);
6727 -unsigned long at32ap7000_osc_rates[3] = {
6729 - /* FIXME: these are ATSTK1002-specific */
6734 -static unsigned long osc_get_rate(struct clk *clk)
6736 - return at32ap7000_osc_rates[clk->index];
6739 -static unsigned long pll_get_rate(struct clk *clk, unsigned long control)
6741 - unsigned long div, mul, rate;
6743 - if (!(control & PM_BIT(PLLEN)))
6746 - div = PM_BFEXT(PLLDIV, control) + 1;
6747 - mul = PM_BFEXT(PLLMUL, control) + 1;
6749 - rate = clk->parent->get_rate(clk->parent);
6750 - rate = (rate + div / 2) / div;
6756 -static unsigned long pll0_get_rate(struct clk *clk)
6760 - control = pm_readl(PLL0);
6762 - return pll_get_rate(clk, control);
6765 -static unsigned long pll1_get_rate(struct clk *clk)
6769 - control = pm_readl(PLL1);
6771 - return pll_get_rate(clk, control);
6775 - * The AT32AP7000 has five primary clock sources: One 32kHz
6776 - * oscillator, two crystal oscillators and two PLLs.
6778 -static struct clk osc32k = {
6780 - .get_rate = osc_get_rate,
6784 -static struct clk osc0 = {
6786 - .get_rate = osc_get_rate,
6790 -static struct clk osc1 = {
6792 - .get_rate = osc_get_rate,
6795 -static struct clk pll0 = {
6797 - .get_rate = pll0_get_rate,
6800 -static struct clk pll1 = {
6802 - .get_rate = pll1_get_rate,
6807 - * The main clock can be either osc0 or pll0. The boot loader may
6808 - * have chosen one for us, so we don't really know which one until we
6809 - * have a look at the SM.
6811 -static struct clk *main_clock;
6814 - * Synchronous clocks are generated from the main clock. The clocks
6815 - * must satisfy the constraint
6816 - * fCPU >= fHSB >= fPB
6817 - * i.e. each clock must not be faster than its parent.
6819 -static unsigned long bus_clk_get_rate(struct clk *clk, unsigned int shift)
6821 - return main_clock->get_rate(main_clock) >> shift;
6824 -static void cpu_clk_mode(struct clk *clk, int enabled)
6826 - unsigned long flags;
6829 - spin_lock_irqsave(&pm_lock, flags);
6830 - mask = pm_readl(CPU_MASK);
6832 - mask |= 1 << clk->index;
6834 - mask &= ~(1 << clk->index);
6835 - pm_writel(CPU_MASK, mask);
6836 - spin_unlock_irqrestore(&pm_lock, flags);
6839 -static unsigned long cpu_clk_get_rate(struct clk *clk)
6841 - unsigned long cksel, shift = 0;
6843 - cksel = pm_readl(CKSEL);
6844 - if (cksel & PM_BIT(CPUDIV))
6845 - shift = PM_BFEXT(CPUSEL, cksel) + 1;
6847 - return bus_clk_get_rate(clk, shift);
6850 -static long cpu_clk_set_rate(struct clk *clk, unsigned long rate, int apply)
6853 - unsigned long parent_rate, child_div, actual_rate, div;
6855 - parent_rate = clk->parent->get_rate(clk->parent);
6856 - control = pm_readl(CKSEL);
6858 - if (control & PM_BIT(HSBDIV))
6859 - child_div = 1 << (PM_BFEXT(HSBSEL, control) + 1);
6863 - if (rate > 3 * (parent_rate / 4) || child_div == 1) {
6864 - actual_rate = parent_rate;
6865 - control &= ~PM_BIT(CPUDIV);
6867 - unsigned int cpusel;
6868 - div = (parent_rate + rate / 2) / rate;
6869 - if (div > child_div)
6871 - cpusel = (div > 1) ? (fls(div) - 2) : 0;
6872 - control = PM_BIT(CPUDIV) | PM_BFINS(CPUSEL, cpusel, control);
6873 - actual_rate = parent_rate / (1 << (cpusel + 1));
6876 - pr_debug("clk %s: new rate %lu (actual rate %lu)\n",
6877 - clk->name, rate, actual_rate);
6880 - pm_writel(CKSEL, control);
6882 - return actual_rate;
6885 -static void hsb_clk_mode(struct clk *clk, int enabled)
6887 - unsigned long flags;
6890 - spin_lock_irqsave(&pm_lock, flags);
6891 - mask = pm_readl(HSB_MASK);
6893 - mask |= 1 << clk->index;
6895 - mask &= ~(1 << clk->index);
6896 - pm_writel(HSB_MASK, mask);
6897 - spin_unlock_irqrestore(&pm_lock, flags);
6900 -static unsigned long hsb_clk_get_rate(struct clk *clk)
6902 - unsigned long cksel, shift = 0;
6904 - cksel = pm_readl(CKSEL);
6905 - if (cksel & PM_BIT(HSBDIV))
6906 - shift = PM_BFEXT(HSBSEL, cksel) + 1;
6908 - return bus_clk_get_rate(clk, shift);
6911 -static void pba_clk_mode(struct clk *clk, int enabled)
6913 - unsigned long flags;
6916 - spin_lock_irqsave(&pm_lock, flags);
6917 - mask = pm_readl(PBA_MASK);
6919 - mask |= 1 << clk->index;
6921 - mask &= ~(1 << clk->index);
6922 - pm_writel(PBA_MASK, mask);
6923 - spin_unlock_irqrestore(&pm_lock, flags);
6926 -static unsigned long pba_clk_get_rate(struct clk *clk)
6928 - unsigned long cksel, shift = 0;
6930 - cksel = pm_readl(CKSEL);
6931 - if (cksel & PM_BIT(PBADIV))
6932 - shift = PM_BFEXT(PBASEL, cksel) + 1;
6934 - return bus_clk_get_rate(clk, shift);
6937 -static void pbb_clk_mode(struct clk *clk, int enabled)
6939 - unsigned long flags;
6942 - spin_lock_irqsave(&pm_lock, flags);
6943 - mask = pm_readl(PBB_MASK);
6945 - mask |= 1 << clk->index;
6947 - mask &= ~(1 << clk->index);
6948 - pm_writel(PBB_MASK, mask);
6949 - spin_unlock_irqrestore(&pm_lock, flags);
6952 -static unsigned long pbb_clk_get_rate(struct clk *clk)
6954 - unsigned long cksel, shift = 0;
6956 - cksel = pm_readl(CKSEL);
6957 - if (cksel & PM_BIT(PBBDIV))
6958 - shift = PM_BFEXT(PBBSEL, cksel) + 1;
6960 - return bus_clk_get_rate(clk, shift);
6963 -static struct clk cpu_clk = {
6965 - .get_rate = cpu_clk_get_rate,
6966 - .set_rate = cpu_clk_set_rate,
6969 -static struct clk hsb_clk = {
6971 - .parent = &cpu_clk,
6972 - .get_rate = hsb_clk_get_rate,
6974 -static struct clk pba_clk = {
6976 - .parent = &hsb_clk,
6977 - .mode = hsb_clk_mode,
6978 - .get_rate = pba_clk_get_rate,
6981 -static struct clk pbb_clk = {
6983 - .parent = &hsb_clk,
6984 - .mode = hsb_clk_mode,
6985 - .get_rate = pbb_clk_get_rate,
6990 -/* --------------------------------------------------------------------
6991 - * Generic Clock operations
6992 - * -------------------------------------------------------------------- */
6994 -static void genclk_mode(struct clk *clk, int enabled)
6998 - control = pm_readl(GCCTRL(clk->index));
7000 - control |= PM_BIT(CEN);
7002 - control &= ~PM_BIT(CEN);
7003 - pm_writel(GCCTRL(clk->index), control);
7006 -static unsigned long genclk_get_rate(struct clk *clk)
7009 - unsigned long div = 1;
7011 - control = pm_readl(GCCTRL(clk->index));
7012 - if (control & PM_BIT(DIVEN))
7013 - div = 2 * (PM_BFEXT(DIV, control) + 1);
7015 - return clk->parent->get_rate(clk->parent) / div;
7018 -static long genclk_set_rate(struct clk *clk, unsigned long rate, int apply)
7021 - unsigned long parent_rate, actual_rate, div;
7023 - parent_rate = clk->parent->get_rate(clk->parent);
7024 - control = pm_readl(GCCTRL(clk->index));
7026 - if (rate > 3 * parent_rate / 4) {
7027 - actual_rate = parent_rate;
7028 - control &= ~PM_BIT(DIVEN);
7030 - div = (parent_rate + rate) / (2 * rate) - 1;
7031 - control = PM_BFINS(DIV, div, control) | PM_BIT(DIVEN);
7032 - actual_rate = parent_rate / (2 * (div + 1));
7035 - dev_dbg(clk->dev, "clk %s: new rate %lu (actual rate %lu)\n",
7036 - clk->name, rate, actual_rate);
7039 - pm_writel(GCCTRL(clk->index), control);
7041 - return actual_rate;
7044 -int genclk_set_parent(struct clk *clk, struct clk *parent)
7048 - dev_dbg(clk->dev, "clk %s: new parent %s (was %s)\n",
7049 - clk->name, parent->name, clk->parent->name);
7051 - control = pm_readl(GCCTRL(clk->index));
7053 - if (parent == &osc1 || parent == &pll1)
7054 - control |= PM_BIT(OSCSEL);
7055 - else if (parent == &osc0 || parent == &pll0)
7056 - control &= ~PM_BIT(OSCSEL);
7060 - if (parent == &pll0 || parent == &pll1)
7061 - control |= PM_BIT(PLLSEL);
7063 - control &= ~PM_BIT(PLLSEL);
7065 - pm_writel(GCCTRL(clk->index), control);
7066 - clk->parent = parent;
7071 -static void __init genclk_init_parent(struct clk *clk)
7074 - struct clk *parent;
7076 - BUG_ON(clk->index > 7);
7078 - control = pm_readl(GCCTRL(clk->index));
7079 - if (control & PM_BIT(OSCSEL))
7080 - parent = (control & PM_BIT(PLLSEL)) ? &pll1 : &osc1;
7082 - parent = (control & PM_BIT(PLLSEL)) ? &pll0 : &osc0;
7084 - clk->parent = parent;
7087 -/* --------------------------------------------------------------------
7088 - * System peripherals
7089 - * -------------------------------------------------------------------- */
7090 -static struct resource at32_pm0_resource[] = {
7092 - .start = 0xfff00000,
7093 - .end = 0xfff0007f,
7094 - .flags = IORESOURCE_MEM,
7099 -static struct resource at32ap700x_rtc0_resource[] = {
7101 - .start = 0xfff00080,
7102 - .end = 0xfff000af,
7103 - .flags = IORESOURCE_MEM,
7108 -static struct resource at32_wdt0_resource[] = {
7110 - .start = 0xfff000b0,
7111 - .end = 0xfff000cf,
7112 - .flags = IORESOURCE_MEM,
7116 -static struct resource at32_eic0_resource[] = {
7118 - .start = 0xfff00100,
7119 - .end = 0xfff0013f,
7120 - .flags = IORESOURCE_MEM,
7125 -DEFINE_DEV(at32_pm, 0);
7126 -DEFINE_DEV(at32ap700x_rtc, 0);
7127 -DEFINE_DEV(at32_wdt, 0);
7128 -DEFINE_DEV(at32_eic, 0);
7131 - * Peripheral clock for PM, RTC, WDT and EIC. PM will ensure that this
7132 - * is always running.
7134 -static struct clk at32_pm_pclk = {
7136 - .dev = &at32_pm0_device.dev,
7137 - .parent = &pbb_clk,
7138 - .mode = pbb_clk_mode,
7139 - .get_rate = pbb_clk_get_rate,
7144 -static struct resource intc0_resource[] = {
7145 - PBMEM(0xfff00400),
7147 -struct platform_device at32_intc0_device = {
7150 - .resource = intc0_resource,
7151 - .num_resources = ARRAY_SIZE(intc0_resource),
7153 -DEV_CLK(pclk, at32_intc0, pbb, 1);
7155 -static struct clk ebi_clk = {
7157 - .parent = &hsb_clk,
7158 - .mode = hsb_clk_mode,
7159 - .get_rate = hsb_clk_get_rate,
7162 -static struct clk hramc_clk = {
7164 - .parent = &hsb_clk,
7165 - .mode = hsb_clk_mode,
7166 - .get_rate = hsb_clk_get_rate,
7171 -static struct resource smc0_resource[] = {
7172 - PBMEM(0xfff03400),
7174 -DEFINE_DEV(smc, 0);
7175 -DEV_CLK(pclk, smc0, pbb, 13);
7176 -DEV_CLK(mck, smc0, hsb, 0);
7178 -static struct platform_device pdc_device = {
7182 -DEV_CLK(hclk, pdc, hsb, 4);
7183 -DEV_CLK(pclk, pdc, pba, 16);
7185 -static struct clk pico_clk = {
7187 - .parent = &cpu_clk,
7188 - .mode = cpu_clk_mode,
7189 - .get_rate = cpu_clk_get_rate,
7193 -static struct resource dmaca0_resource[] = {
7195 - .start = 0xff200000,
7196 - .end = 0xff20ffff,
7197 - .flags = IORESOURCE_MEM,
7201 -DEFINE_DEV(dmaca, 0);
7202 -DEV_CLK(hclk, dmaca0, hsb, 10);
7204 -/* --------------------------------------------------------------------
7206 - * -------------------------------------------------------------------- */
7208 -static struct clk hmatrix_clk = {
7209 - .name = "hmatrix_clk",
7210 - .parent = &pbb_clk,
7211 - .mode = pbb_clk_mode,
7212 - .get_rate = pbb_clk_get_rate,
7216 -#define HMATRIX_BASE ((void __iomem *)0xfff00800)
7218 -#define hmatrix_readl(reg) \
7219 - __raw_readl((HMATRIX_BASE) + HMATRIX_##reg)
7220 -#define hmatrix_writel(reg,value) \
7221 - __raw_writel((value), (HMATRIX_BASE) + HMATRIX_##reg)
7224 - * Set bits in the HMATRIX Special Function Register (SFR) used by the
7225 - * External Bus Interface (EBI). This can be used to enable special
7226 - * features like CompactFlash support, NAND Flash support, etc. on
7227 - * certain chipselects.
7229 -static inline void set_ebi_sfr_bits(u32 mask)
7233 - clk_enable(&hmatrix_clk);
7234 - sfr = hmatrix_readl(SFR4);
7236 - hmatrix_writel(SFR4, sfr);
7237 - clk_disable(&hmatrix_clk);
7240 -/* --------------------------------------------------------------------
7241 - * System Timer/Counter (TC)
7242 - * -------------------------------------------------------------------- */
7243 -static struct resource at32_systc0_resource[] = {
7244 - PBMEM(0xfff00c00),
7247 -struct platform_device at32_systc0_device = {
7250 - .resource = at32_systc0_resource,
7251 - .num_resources = ARRAY_SIZE(at32_systc0_resource),
7253 -DEV_CLK(pclk, at32_systc0, pbb, 3);
7255 -/* --------------------------------------------------------------------
7257 - * -------------------------------------------------------------------- */
7259 -static struct resource pio0_resource[] = {
7260 - PBMEM(0xffe02800),
7263 -DEFINE_DEV(pio, 0);
7264 -DEV_CLK(mck, pio0, pba, 10);
7266 -static struct resource pio1_resource[] = {
7267 - PBMEM(0xffe02c00),
7270 -DEFINE_DEV(pio, 1);
7271 -DEV_CLK(mck, pio1, pba, 11);
7273 -static struct resource pio2_resource[] = {
7274 - PBMEM(0xffe03000),
7277 -DEFINE_DEV(pio, 2);
7278 -DEV_CLK(mck, pio2, pba, 12);
7280 -static struct resource pio3_resource[] = {
7281 - PBMEM(0xffe03400),
7284 -DEFINE_DEV(pio, 3);
7285 -DEV_CLK(mck, pio3, pba, 13);
7287 -static struct resource pio4_resource[] = {
7288 - PBMEM(0xffe03800),
7291 -DEFINE_DEV(pio, 4);
7292 -DEV_CLK(mck, pio4, pba, 14);
7294 -void __init at32_add_system_devices(void)
7296 - platform_device_register(&at32_pm0_device);
7297 - platform_device_register(&at32_intc0_device);
7298 - platform_device_register(&at32ap700x_rtc0_device);
7299 - platform_device_register(&at32_wdt0_device);
7300 - platform_device_register(&at32_eic0_device);
7301 - platform_device_register(&smc0_device);
7302 - platform_device_register(&pdc_device);
7303 - platform_device_register(&dmaca0_device);
7305 - platform_device_register(&at32_systc0_device);
7307 - platform_device_register(&pio0_device);
7308 - platform_device_register(&pio1_device);
7309 - platform_device_register(&pio2_device);
7310 - platform_device_register(&pio3_device);
7311 - platform_device_register(&pio4_device);
7314 -/* --------------------------------------------------------------------
7316 - * -------------------------------------------------------------------- */
7318 -static struct atmel_uart_data atmel_usart0_data = {
7322 -static struct resource atmel_usart0_resource[] = {
7323 - PBMEM(0xffe00c00),
7326 -DEFINE_DEV_DATA(atmel_usart, 0);
7327 -DEV_CLK(usart, atmel_usart0, pba, 3);
7329 -static struct atmel_uart_data atmel_usart1_data = {
7333 -static struct resource atmel_usart1_resource[] = {
7334 - PBMEM(0xffe01000),
7337 -DEFINE_DEV_DATA(atmel_usart, 1);
7338 -DEV_CLK(usart, atmel_usart1, pba, 4);
7340 -static struct atmel_uart_data atmel_usart2_data = {
7344 -static struct resource atmel_usart2_resource[] = {
7345 - PBMEM(0xffe01400),
7348 -DEFINE_DEV_DATA(atmel_usart, 2);
7349 -DEV_CLK(usart, atmel_usart2, pba, 5);
7351 -static struct atmel_uart_data atmel_usart3_data = {
7355 -static struct resource atmel_usart3_resource[] = {
7356 - PBMEM(0xffe01800),
7359 -DEFINE_DEV_DATA(atmel_usart, 3);
7360 -DEV_CLK(usart, atmel_usart3, pba, 6);
7362 -static inline void configure_usart0_pins(void)
7364 - select_peripheral(PA(8), PERIPH_B, 0); /* RXD */
7365 - select_peripheral(PA(9), PERIPH_B, 0); /* TXD */
7368 -static inline void configure_usart1_pins(void)
7370 - select_peripheral(PA(17), PERIPH_A, 0); /* RXD */
7371 - select_peripheral(PA(18), PERIPH_A, 0); /* TXD */
7374 -static inline void configure_usart2_pins(void)
7376 - select_peripheral(PB(26), PERIPH_B, 0); /* RXD */
7377 - select_peripheral(PB(27), PERIPH_B, 0); /* TXD */
7380 -static inline void configure_usart3_pins(void)
7382 - select_peripheral(PB(18), PERIPH_B, 0); /* RXD */
7383 - select_peripheral(PB(17), PERIPH_B, 0); /* TXD */
7386 -static struct platform_device *__initdata at32_usarts[4];
7388 -void __init at32_map_usart(unsigned int hw_id, unsigned int line)
7390 - struct platform_device *pdev;
7394 - pdev = &atmel_usart0_device;
7395 - configure_usart0_pins();
7398 - pdev = &atmel_usart1_device;
7399 - configure_usart1_pins();
7402 - pdev = &atmel_usart2_device;
7403 - configure_usart2_pins();
7406 - pdev = &atmel_usart3_device;
7407 - configure_usart3_pins();
7413 - if (PXSEG(pdev->resource[0].start) == P4SEG) {
7414 - /* Addresses in the P4 segment are permanently mapped 1:1 */
7415 - struct atmel_uart_data *data = pdev->dev.platform_data;
7416 - data->regs = (void __iomem *)pdev->resource[0].start;
7420 - at32_usarts[line] = pdev;
7423 -struct platform_device *__init at32_add_device_usart(unsigned int id)
7425 - platform_device_register(at32_usarts[id]);
7426 - return at32_usarts[id];
7429 -struct platform_device *atmel_default_console_device;
7431 -void __init at32_setup_serial_console(unsigned int usart_id)
7433 - atmel_default_console_device = at32_usarts[usart_id];
7436 -/* --------------------------------------------------------------------
7438 - * -------------------------------------------------------------------- */
7440 -static struct eth_platform_data macb0_data;
7441 -static struct resource macb0_resource[] = {
7442 - PBMEM(0xfff01800),
7445 -DEFINE_DEV_DATA(macb, 0);
7446 -DEV_CLK(hclk, macb0, hsb, 8);
7447 -DEV_CLK(pclk, macb0, pbb, 6);
7449 -static struct eth_platform_data macb1_data;
7450 -static struct resource macb1_resource[] = {
7451 - PBMEM(0xfff01c00),
7454 -DEFINE_DEV_DATA(macb, 1);
7455 -DEV_CLK(hclk, macb1, hsb, 9);
7456 -DEV_CLK(pclk, macb1, pbb, 7);
7458 -struct platform_device *__init
7459 -at32_add_device_eth(unsigned int id, struct eth_platform_data *data)
7461 - struct platform_device *pdev;
7465 - pdev = &macb0_device;
7467 - select_peripheral(PC(3), PERIPH_A, 0); /* TXD0 */
7468 - select_peripheral(PC(4), PERIPH_A, 0); /* TXD1 */
7469 - select_peripheral(PC(7), PERIPH_A, 0); /* TXEN */
7470 - select_peripheral(PC(8), PERIPH_A, 0); /* TXCK */
7471 - select_peripheral(PC(9), PERIPH_A, 0); /* RXD0 */
7472 - select_peripheral(PC(10), PERIPH_A, 0); /* RXD1 */
7473 - select_peripheral(PC(13), PERIPH_A, 0); /* RXER */
7474 - select_peripheral(PC(15), PERIPH_A, 0); /* RXDV */
7475 - select_peripheral(PC(16), PERIPH_A, 0); /* MDC */
7476 - select_peripheral(PC(17), PERIPH_A, 0); /* MDIO */
7478 - if (!data->is_rmii) {
7479 - select_peripheral(PC(0), PERIPH_A, 0); /* COL */
7480 - select_peripheral(PC(1), PERIPH_A, 0); /* CRS */
7481 - select_peripheral(PC(2), PERIPH_A, 0); /* TXER */
7482 - select_peripheral(PC(5), PERIPH_A, 0); /* TXD2 */
7483 - select_peripheral(PC(6), PERIPH_A, 0); /* TXD3 */
7484 - select_peripheral(PC(11), PERIPH_A, 0); /* RXD2 */
7485 - select_peripheral(PC(12), PERIPH_A, 0); /* RXD3 */
7486 - select_peripheral(PC(14), PERIPH_A, 0); /* RXCK */
7487 - select_peripheral(PC(18), PERIPH_A, 0); /* SPD */
7492 - pdev = &macb1_device;
7494 - select_peripheral(PD(13), PERIPH_B, 0); /* TXD0 */
7495 - select_peripheral(PD(14), PERIPH_B, 0); /* TXD1 */
7496 - select_peripheral(PD(11), PERIPH_B, 0); /* TXEN */
7497 - select_peripheral(PD(12), PERIPH_B, 0); /* TXCK */
7498 - select_peripheral(PD(10), PERIPH_B, 0); /* RXD0 */
7499 - select_peripheral(PD(6), PERIPH_B, 0); /* RXD1 */
7500 - select_peripheral(PD(5), PERIPH_B, 0); /* RXER */
7501 - select_peripheral(PD(4), PERIPH_B, 0); /* RXDV */
7502 - select_peripheral(PD(3), PERIPH_B, 0); /* MDC */
7503 - select_peripheral(PD(2), PERIPH_B, 0); /* MDIO */
7505 - if (!data->is_rmii) {
7506 - select_peripheral(PC(19), PERIPH_B, 0); /* COL */
7507 - select_peripheral(PC(23), PERIPH_B, 0); /* CRS */
7508 - select_peripheral(PC(26), PERIPH_B, 0); /* TXER */
7509 - select_peripheral(PC(27), PERIPH_B, 0); /* TXD2 */
7510 - select_peripheral(PC(28), PERIPH_B, 0); /* TXD3 */
7511 - select_peripheral(PC(29), PERIPH_B, 0); /* RXD2 */
7512 - select_peripheral(PC(30), PERIPH_B, 0); /* RXD3 */
7513 - select_peripheral(PC(24), PERIPH_B, 0); /* RXCK */
7514 - select_peripheral(PD(15), PERIPH_B, 0); /* SPD */
7522 - memcpy(pdev->dev.platform_data, data, sizeof(struct eth_platform_data));
7523 - platform_device_register(pdev);
7528 -/* --------------------------------------------------------------------
7530 - * -------------------------------------------------------------------- */
7531 -static struct resource atmel_spi0_resource[] = {
7532 - PBMEM(0xffe00000),
7535 -DEFINE_DEV(atmel_spi, 0);
7536 -DEV_CLK(spi_clk, atmel_spi0, pba, 0);
7538 -static struct resource atmel_spi1_resource[] = {
7539 - PBMEM(0xffe00400),
7542 -DEFINE_DEV(atmel_spi, 1);
7543 -DEV_CLK(spi_clk, atmel_spi1, pba, 1);
7546 -at32_spi_setup_slaves(unsigned int bus_num, struct spi_board_info *b,
7547 - unsigned int n, const u8 *pins)
7549 - unsigned int pin, mode;
7551 - for (; n; n--, b++) {
7552 - b->bus_num = bus_num;
7553 - if (b->chip_select >= 4)
7555 - pin = (unsigned)b->controller_data;
7557 - pin = pins[b->chip_select];
7558 - b->controller_data = (void *)pin;
7560 - mode = AT32_GPIOF_OUTPUT;
7561 - if (!(b->mode & SPI_CS_HIGH))
7562 - mode |= AT32_GPIOF_HIGH;
7563 - at32_select_gpio(pin, mode);
7567 -struct platform_device *__init
7568 -at32_add_device_spi(unsigned int id, struct spi_board_info *b, unsigned int n)
7571 - * Manage the chipselects as GPIOs, normally using the same pins
7572 - * the SPI controller expects; but boards can use other pins.
7574 - static u8 __initdata spi0_pins[] =
7575 - { GPIO_PIN_PA(3), GPIO_PIN_PA(4),
7576 - GPIO_PIN_PA(5), GPIO_PIN_PA(20), };
7577 - static u8 __initdata spi1_pins[] =
7578 - { GPIO_PIN_PB(2), GPIO_PIN_PB(3),
7579 - GPIO_PIN_PB(4), GPIO_PIN_PA(27), };
7580 - struct platform_device *pdev;
7584 - pdev = &atmel_spi0_device;
7585 - select_peripheral(PA(0), PERIPH_A, 0); /* MISO */
7586 - select_peripheral(PA(1), PERIPH_A, 0); /* MOSI */
7587 - select_peripheral(PA(2), PERIPH_A, 0); /* SCK */
7588 - at32_spi_setup_slaves(0, b, n, spi0_pins);
7592 - pdev = &atmel_spi1_device;
7593 - select_peripheral(PB(0), PERIPH_B, 0); /* MISO */
7594 - select_peripheral(PB(1), PERIPH_B, 0); /* MOSI */
7595 - select_peripheral(PB(5), PERIPH_B, 0); /* SCK */
7596 - at32_spi_setup_slaves(1, b, n, spi1_pins);
7603 - spi_register_board_info(b, n);
7604 - platform_device_register(pdev);
7608 -/* --------------------------------------------------------------------
7610 - * -------------------------------------------------------------------- */
7611 -static struct resource atmel_twi0_resource[] __initdata = {
7612 - PBMEM(0xffe00800),
7615 -static struct clk atmel_twi0_pclk = {
7616 - .name = "twi_pclk",
7617 - .parent = &pba_clk,
7618 - .mode = pba_clk_mode,
7619 - .get_rate = pba_clk_get_rate,
7623 -struct platform_device *__init at32_add_device_twi(unsigned int id)
7625 - struct platform_device *pdev;
7630 - pdev = platform_device_alloc("atmel_twi", id);
7634 - if (platform_device_add_resources(pdev, atmel_twi0_resource,
7635 - ARRAY_SIZE(atmel_twi0_resource)))
7636 - goto err_add_resources;
7638 - select_peripheral(PA(6), PERIPH_A, 0); /* SDA */
7639 - select_peripheral(PA(7), PERIPH_A, 0); /* SDL */
7641 - atmel_twi0_pclk.dev = &pdev->dev;
7643 - platform_device_add(pdev);
7647 - platform_device_put(pdev);
7651 -/* --------------------------------------------------------------------
7653 - * -------------------------------------------------------------------- */
7654 -static struct resource atmel_mci0_resource[] __initdata = {
7655 - PBMEM(0xfff02400),
7658 -static struct clk atmel_mci0_pclk = {
7659 - .name = "mci_clk",
7660 - .parent = &pbb_clk,
7661 - .mode = pbb_clk_mode,
7662 - .get_rate = pbb_clk_get_rate,
7666 -struct platform_device *__init at32_add_device_mci(unsigned int id)
7668 - struct platform_device *pdev;
7673 - pdev = platform_device_alloc("atmel_mci", id);
7677 - if (platform_device_add_resources(pdev, atmel_mci0_resource,
7678 - ARRAY_SIZE(atmel_mci0_resource)))
7679 - goto err_add_resources;
7681 - select_peripheral(PA(10), PERIPH_A, 0); /* CLK */
7682 - select_peripheral(PA(11), PERIPH_A, 0); /* CMD */
7683 - select_peripheral(PA(12), PERIPH_A, 0); /* DATA0 */
7684 - select_peripheral(PA(13), PERIPH_A, 0); /* DATA1 */
7685 - select_peripheral(PA(14), PERIPH_A, 0); /* DATA2 */
7686 - select_peripheral(PA(15), PERIPH_A, 0); /* DATA3 */
7688 - atmel_mci0_pclk.dev = &pdev->dev;
7690 - platform_device_add(pdev);
7694 - platform_device_put(pdev);
7698 -/* --------------------------------------------------------------------
7700 - * -------------------------------------------------------------------- */
7701 -static struct atmel_lcdfb_info atmel_lcdfb0_data;
7702 -static struct resource atmel_lcdfb0_resource[] = {
7704 - .start = 0xff000000,
7705 - .end = 0xff000fff,
7706 - .flags = IORESOURCE_MEM,
7710 - /* Placeholder for pre-allocated fb memory */
7711 - .start = 0x00000000,
7712 - .end = 0x00000000,
7716 -DEFINE_DEV_DATA(atmel_lcdfb, 0);
7717 -DEV_CLK(hck1, atmel_lcdfb0, hsb, 7);
7718 -static struct clk atmel_lcdfb0_pixclk = {
7719 - .name = "lcdc_clk",
7720 - .dev = &atmel_lcdfb0_device.dev,
7721 - .mode = genclk_mode,
7722 - .get_rate = genclk_get_rate,
7723 - .set_rate = genclk_set_rate,
7724 - .set_parent = genclk_set_parent,
7728 -struct platform_device *__init
7729 -at32_add_device_lcdc(unsigned int id, struct atmel_lcdfb_info *data,
7730 - unsigned long fbmem_start, unsigned long fbmem_len)
7732 - struct platform_device *pdev;
7733 - struct atmel_lcdfb_info *info;
7734 - struct fb_monspecs *monspecs;
7735 - struct fb_videomode *modedb;
7736 - unsigned int modedb_size;
7739 - * Do a deep copy of the fb data, monspecs and modedb. Make
7740 - * sure all allocations are done before setting up the
7743 - monspecs = kmemdup(data->default_monspecs,
7744 - sizeof(struct fb_monspecs), GFP_KERNEL);
7748 - modedb_size = sizeof(struct fb_videomode) * monspecs->modedb_len;
7749 - modedb = kmemdup(monspecs->modedb, modedb_size, GFP_KERNEL);
7751 - goto err_dup_modedb;
7752 - monspecs->modedb = modedb;
7756 - pdev = &atmel_lcdfb0_device;
7757 - select_peripheral(PC(19), PERIPH_A, 0); /* CC */
7758 - select_peripheral(PC(20), PERIPH_A, 0); /* HSYNC */
7759 - select_peripheral(PC(21), PERIPH_A, 0); /* PCLK */
7760 - select_peripheral(PC(22), PERIPH_A, 0); /* VSYNC */
7761 - select_peripheral(PC(23), PERIPH_A, 0); /* DVAL */
7762 - select_peripheral(PC(24), PERIPH_A, 0); /* MODE */
7763 - select_peripheral(PC(25), PERIPH_A, 0); /* PWR */
7764 - select_peripheral(PC(26), PERIPH_A, 0); /* DATA0 */
7765 - select_peripheral(PC(27), PERIPH_A, 0); /* DATA1 */
7766 - select_peripheral(PC(28), PERIPH_A, 0); /* DATA2 */
7767 - select_peripheral(PC(29), PERIPH_A, 0); /* DATA3 */
7768 - select_peripheral(PC(30), PERIPH_A, 0); /* DATA4 */
7769 - select_peripheral(PC(31), PERIPH_A, 0); /* DATA5 */
7770 - select_peripheral(PD(0), PERIPH_A, 0); /* DATA6 */
7771 - select_peripheral(PD(1), PERIPH_A, 0); /* DATA7 */
7772 - select_peripheral(PD(2), PERIPH_A, 0); /* DATA8 */
7773 - select_peripheral(PD(3), PERIPH_A, 0); /* DATA9 */
7774 - select_peripheral(PD(4), PERIPH_A, 0); /* DATA10 */
7775 - select_peripheral(PD(5), PERIPH_A, 0); /* DATA11 */
7776 - select_peripheral(PD(6), PERIPH_A, 0); /* DATA12 */
7777 - select_peripheral(PD(7), PERIPH_A, 0); /* DATA13 */
7778 - select_peripheral(PD(8), PERIPH_A, 0); /* DATA14 */
7779 - select_peripheral(PD(9), PERIPH_A, 0); /* DATA15 */
7780 - select_peripheral(PD(10), PERIPH_A, 0); /* DATA16 */
7781 - select_peripheral(PD(11), PERIPH_A, 0); /* DATA17 */
7782 - select_peripheral(PD(12), PERIPH_A, 0); /* DATA18 */
7783 - select_peripheral(PD(13), PERIPH_A, 0); /* DATA19 */
7784 - select_peripheral(PD(14), PERIPH_A, 0); /* DATA20 */
7785 - select_peripheral(PD(15), PERIPH_A, 0); /* DATA21 */
7786 - select_peripheral(PD(16), PERIPH_A, 0); /* DATA22 */
7787 - select_peripheral(PD(17), PERIPH_A, 0); /* DATA23 */
7789 - clk_set_parent(&atmel_lcdfb0_pixclk, &pll0);
7790 - clk_set_rate(&atmel_lcdfb0_pixclk, clk_get_rate(&pll0));
7794 - goto err_invalid_id;
7798 - pdev->resource[2].start = fbmem_start;
7799 - pdev->resource[2].end = fbmem_start + fbmem_len - 1;
7800 - pdev->resource[2].flags = IORESOURCE_MEM;
7803 - info = pdev->dev.platform_data;
7804 - memcpy(info, data, sizeof(struct atmel_lcdfb_info));
7805 - info->default_monspecs = monspecs;
7807 - platform_device_register(pdev);
7817 -/* --------------------------------------------------------------------
7819 - * -------------------------------------------------------------------- */
7820 -static struct resource ssc0_resource[] = {
7821 - PBMEM(0xffe01c00),
7824 -DEFINE_DEV(ssc, 0);
7825 -DEV_CLK(pclk, ssc0, pba, 7);
7827 -static struct resource ssc1_resource[] = {
7828 - PBMEM(0xffe02000),
7831 -DEFINE_DEV(ssc, 1);
7832 -DEV_CLK(pclk, ssc1, pba, 8);
7834 -static struct resource ssc2_resource[] = {
7835 - PBMEM(0xffe02400),
7838 -DEFINE_DEV(ssc, 2);
7839 -DEV_CLK(pclk, ssc2, pba, 9);
7841 -struct platform_device *__init
7842 -at32_add_device_ssc(unsigned int id, unsigned int flags)
7844 - struct platform_device *pdev;
7848 - pdev = &ssc0_device;
7849 - if (flags & ATMEL_SSC_RF)
7850 - select_peripheral(PA(21), PERIPH_A, 0); /* RF */
7851 - if (flags & ATMEL_SSC_RK)
7852 - select_peripheral(PA(22), PERIPH_A, 0); /* RK */
7853 - if (flags & ATMEL_SSC_TK)
7854 - select_peripheral(PA(23), PERIPH_A, 0); /* TK */
7855 - if (flags & ATMEL_SSC_TF)
7856 - select_peripheral(PA(24), PERIPH_A, 0); /* TF */
7857 - if (flags & ATMEL_SSC_TD)
7858 - select_peripheral(PA(25), PERIPH_A, 0); /* TD */
7859 - if (flags & ATMEL_SSC_RD)
7860 - select_peripheral(PA(26), PERIPH_A, 0); /* RD */
7863 - pdev = &ssc1_device;
7864 - if (flags & ATMEL_SSC_RF)
7865 - select_peripheral(PA(0), PERIPH_B, 0); /* RF */
7866 - if (flags & ATMEL_SSC_RK)
7867 - select_peripheral(PA(1), PERIPH_B, 0); /* RK */
7868 - if (flags & ATMEL_SSC_TK)
7869 - select_peripheral(PA(2), PERIPH_B, 0); /* TK */
7870 - if (flags & ATMEL_SSC_TF)
7871 - select_peripheral(PA(3), PERIPH_B, 0); /* TF */
7872 - if (flags & ATMEL_SSC_TD)
7873 - select_peripheral(PA(4), PERIPH_B, 0); /* TD */
7874 - if (flags & ATMEL_SSC_RD)
7875 - select_peripheral(PA(5), PERIPH_B, 0); /* RD */
7878 - pdev = &ssc2_device;
7879 - if (flags & ATMEL_SSC_TD)
7880 - select_peripheral(PB(13), PERIPH_A, 0); /* TD */
7881 - if (flags & ATMEL_SSC_RD)
7882 - select_peripheral(PB(14), PERIPH_A, 0); /* RD */
7883 - if (flags & ATMEL_SSC_TK)
7884 - select_peripheral(PB(15), PERIPH_A, 0); /* TK */
7885 - if (flags & ATMEL_SSC_TF)
7886 - select_peripheral(PB(16), PERIPH_A, 0); /* TF */
7887 - if (flags & ATMEL_SSC_RF)
7888 - select_peripheral(PB(17), PERIPH_A, 0); /* RF */
7889 - if (flags & ATMEL_SSC_RK)
7890 - select_peripheral(PB(18), PERIPH_A, 0); /* RK */
7896 - platform_device_register(pdev);
7900 -/* --------------------------------------------------------------------
7901 - * USB Device Controller
7902 - * -------------------------------------------------------------------- */
7903 -static struct resource usba0_resource[] __initdata = {
7905 - .start = 0xff300000,
7906 - .end = 0xff3fffff,
7907 - .flags = IORESOURCE_MEM,
7909 - .start = 0xfff03000,
7910 - .end = 0xfff033ff,
7911 - .flags = IORESOURCE_MEM,
7915 -static struct clk usba0_pclk = {
7917 - .parent = &pbb_clk,
7918 - .mode = pbb_clk_mode,
7919 - .get_rate = pbb_clk_get_rate,
7922 -static struct clk usba0_hclk = {
7924 - .parent = &hsb_clk,
7925 - .mode = hsb_clk_mode,
7926 - .get_rate = hsb_clk_get_rate,
7930 -struct platform_device *__init
7931 -at32_add_device_usba(unsigned int id, struct usba_platform_data *data)
7933 - struct platform_device *pdev;
7938 - pdev = platform_device_alloc("atmel_usba_udc", 0);
7942 - if (platform_device_add_resources(pdev, usba0_resource,
7943 - ARRAY_SIZE(usba0_resource)))
7944 - goto out_free_pdev;
7947 - if (platform_device_add_data(pdev, data, sizeof(*data)))
7948 - goto out_free_pdev;
7950 - if (data->vbus_pin != GPIO_PIN_NONE)
7951 - at32_select_gpio(data->vbus_pin, 0);
7954 - usba0_pclk.dev = &pdev->dev;
7955 - usba0_hclk.dev = &pdev->dev;
7957 - platform_device_add(pdev);
7962 - platform_device_put(pdev);
7966 -/* --------------------------------------------------------------------
7967 - * IDE / CompactFlash
7968 - * -------------------------------------------------------------------- */
7969 -static struct resource at32_smc_cs4_resource[] __initdata = {
7971 - .start = 0x04000000,
7972 - .end = 0x07ffffff,
7973 - .flags = IORESOURCE_MEM,
7975 - IRQ(~0UL), /* Magic IRQ will be overridden */
7977 -static struct resource at32_smc_cs5_resource[] __initdata = {
7979 - .start = 0x20000000,
7980 - .end = 0x23ffffff,
7981 - .flags = IORESOURCE_MEM,
7983 - IRQ(~0UL), /* Magic IRQ will be overridden */
7986 -static int __init at32_init_ide_or_cf(struct platform_device *pdev,
7987 - unsigned int cs, unsigned int extint)
7989 - static unsigned int extint_pin_map[4] __initdata = {
7995 - static bool common_pins_initialized __initdata = false;
7996 - unsigned int extint_pin;
7999 - if (extint >= ARRAY_SIZE(extint_pin_map))
8001 - extint_pin = extint_pin_map[extint];
8005 - ret = platform_device_add_resources(pdev,
8006 - at32_smc_cs4_resource,
8007 - ARRAY_SIZE(at32_smc_cs4_resource));
8011 - select_peripheral(PE(21), PERIPH_A, 0); /* NCS4 -> OE_N */
8012 - set_ebi_sfr_bits(HMATRIX_BIT(CS4A));
8015 - ret = platform_device_add_resources(pdev,
8016 - at32_smc_cs5_resource,
8017 - ARRAY_SIZE(at32_smc_cs5_resource));
8021 - select_peripheral(PE(22), PERIPH_A, 0); /* NCS5 -> OE_N */
8022 - set_ebi_sfr_bits(HMATRIX_BIT(CS5A));
8028 - if (!common_pins_initialized) {
8029 - select_peripheral(PE(19), PERIPH_A, 0); /* CFCE1 -> CS0_N */
8030 - select_peripheral(PE(20), PERIPH_A, 0); /* CFCE2 -> CS1_N */
8031 - select_peripheral(PE(23), PERIPH_A, 0); /* CFRNW -> DIR */
8032 - select_peripheral(PE(24), PERIPH_A, 0); /* NWAIT <- IORDY */
8033 - common_pins_initialized = true;
8036 - at32_select_periph(extint_pin, GPIO_PERIPH_A, AT32_GPIOF_DEGLITCH);
8038 - pdev->resource[1].start = EIM_IRQ_BASE + extint;
8039 - pdev->resource[1].end = pdev->resource[1].start;
8044 -struct platform_device *__init
8045 -at32_add_device_ide(unsigned int id, unsigned int extint,
8046 - struct ide_platform_data *data)
8048 - struct platform_device *pdev;
8050 - pdev = platform_device_alloc("at32_ide", id);
8054 - if (platform_device_add_data(pdev, data,
8055 - sizeof(struct ide_platform_data)))
8058 - if (at32_init_ide_or_cf(pdev, data->cs, extint))
8061 - platform_device_add(pdev);
8065 - platform_device_put(pdev);
8069 -struct platform_device *__init
8070 -at32_add_device_cf(unsigned int id, unsigned int extint,
8071 - struct cf_platform_data *data)
8073 - struct platform_device *pdev;
8075 - pdev = platform_device_alloc("at32_cf", id);
8079 - if (platform_device_add_data(pdev, data,
8080 - sizeof(struct cf_platform_data)))
8083 - if (at32_init_ide_or_cf(pdev, data->cs, extint))
8086 - if (data->detect_pin != GPIO_PIN_NONE)
8087 - at32_select_gpio(data->detect_pin, AT32_GPIOF_DEGLITCH);
8088 - if (data->reset_pin != GPIO_PIN_NONE)
8089 - at32_select_gpio(data->reset_pin, 0);
8090 - if (data->vcc_pin != GPIO_PIN_NONE)
8091 - at32_select_gpio(data->vcc_pin, 0);
8092 - /* READY is used as extint, so we can't select it as gpio */
8094 - platform_device_add(pdev);
8098 - platform_device_put(pdev);
8102 -/* --------------------------------------------------------------------
8104 - * -------------------------------------------------------------------- */
8105 -static struct resource atmel_ac97c0_resource[] __initdata = {
8106 - PBMEM(0xfff02800),
8109 -static struct clk atmel_ac97c0_pclk = {
8111 - .parent = &pbb_clk,
8112 - .mode = pbb_clk_mode,
8113 - .get_rate = pbb_clk_get_rate,
8117 -struct platform_device *__init at32_add_device_ac97c(unsigned int id)
8119 - struct platform_device *pdev;
8124 - pdev = platform_device_alloc("atmel_ac97c", id);
8128 - if (platform_device_add_resources(pdev, atmel_ac97c0_resource,
8129 - ARRAY_SIZE(atmel_ac97c0_resource)))
8130 - goto err_add_resources;
8132 - select_peripheral(PB(20), PERIPH_B, 0); /* SYNC */
8133 - select_peripheral(PB(21), PERIPH_B, 0); /* SDO */
8134 - select_peripheral(PB(22), PERIPH_B, 0); /* SDI */
8135 - select_peripheral(PB(23), PERIPH_B, 0); /* SCLK */
8137 - atmel_ac97c0_pclk.dev = &pdev->dev;
8139 - platform_device_add(pdev);
8143 - platform_device_put(pdev);
8147 -/* --------------------------------------------------------------------
8149 - * -------------------------------------------------------------------- */
8150 -static struct resource abdac0_resource[] __initdata = {
8151 - PBMEM(0xfff02000),
8154 -static struct clk abdac0_pclk = {
8156 - .parent = &pbb_clk,
8157 - .mode = pbb_clk_mode,
8158 - .get_rate = pbb_clk_get_rate,
8161 -static struct clk abdac0_sample_clk = {
8162 - .name = "sample_clk",
8163 - .mode = genclk_mode,
8164 - .get_rate = genclk_get_rate,
8165 - .set_rate = genclk_set_rate,
8166 - .set_parent = genclk_set_parent,
8170 -struct platform_device *__init at32_add_device_abdac(unsigned int id)
8172 - struct platform_device *pdev;
8177 - pdev = platform_device_alloc("abdac", id);
8181 - if (platform_device_add_resources(pdev, abdac0_resource,
8182 - ARRAY_SIZE(abdac0_resource)))
8183 - goto err_add_resources;
8185 - select_peripheral(PB(20), PERIPH_A, 0); /* DATA1 */
8186 - select_peripheral(PB(21), PERIPH_A, 0); /* DATA0 */
8187 - select_peripheral(PB(22), PERIPH_A, 0); /* DATAN1 */
8188 - select_peripheral(PB(23), PERIPH_A, 0); /* DATAN0 */
8190 - abdac0_pclk.dev = &pdev->dev;
8191 - abdac0_sample_clk.dev = &pdev->dev;
8193 - platform_device_add(pdev);
8197 - platform_device_put(pdev);
8201 -/* --------------------------------------------------------------------
8203 - * -------------------------------------------------------------------- */
8204 -static struct clk gclk0 = {
8206 - .mode = genclk_mode,
8207 - .get_rate = genclk_get_rate,
8208 - .set_rate = genclk_set_rate,
8209 - .set_parent = genclk_set_parent,
8212 -static struct clk gclk1 = {
8214 - .mode = genclk_mode,
8215 - .get_rate = genclk_get_rate,
8216 - .set_rate = genclk_set_rate,
8217 - .set_parent = genclk_set_parent,
8220 -static struct clk gclk2 = {
8222 - .mode = genclk_mode,
8223 - .get_rate = genclk_get_rate,
8224 - .set_rate = genclk_set_rate,
8225 - .set_parent = genclk_set_parent,
8228 -static struct clk gclk3 = {
8230 - .mode = genclk_mode,
8231 - .get_rate = genclk_get_rate,
8232 - .set_rate = genclk_set_rate,
8233 - .set_parent = genclk_set_parent,
8236 -static struct clk gclk4 = {
8238 - .mode = genclk_mode,
8239 - .get_rate = genclk_get_rate,
8240 - .set_rate = genclk_set_rate,
8241 - .set_parent = genclk_set_parent,
8245 -struct clk *at32_clock_list[] = {
8271 - &at32_systc0_pclk,
8272 - &atmel_usart0_usart,
8273 - &atmel_usart1_usart,
8274 - &atmel_usart2_usart,
8275 - &atmel_usart3_usart,
8280 - &atmel_spi0_spi_clk,
8281 - &atmel_spi1_spi_clk,
8284 - &atmel_lcdfb0_hck1,
8285 - &atmel_lcdfb0_pixclk,
8291 - &atmel_ac97c0_pclk,
8293 - &abdac0_sample_clk,
8300 -unsigned int at32_nr_clocks = ARRAY_SIZE(at32_clock_list);
8302 -void __init at32_portmux_init(void)
8304 - at32_init_pio(&pio0_device);
8305 - at32_init_pio(&pio1_device);
8306 - at32_init_pio(&pio2_device);
8307 - at32_init_pio(&pio3_device);
8308 - at32_init_pio(&pio4_device);
8311 -void __init at32_clock_init(void)
8313 - u32 cpu_mask = 0, hsb_mask = 0, pba_mask = 0, pbb_mask = 0;
8316 - if (pm_readl(MCCTRL) & PM_BIT(PLLSEL)) {
8317 - main_clock = &pll0;
8318 - cpu_clk.parent = &pll0;
8320 - main_clock = &osc0;
8321 - cpu_clk.parent = &osc0;
8324 - if (pm_readl(PLL0) & PM_BIT(PLLOSC))
8325 - pll0.parent = &osc1;
8326 - if (pm_readl(PLL1) & PM_BIT(PLLOSC))
8327 - pll1.parent = &osc1;
8329 - genclk_init_parent(&gclk0);
8330 - genclk_init_parent(&gclk1);
8331 - genclk_init_parent(&gclk2);
8332 - genclk_init_parent(&gclk3);
8333 - genclk_init_parent(&gclk4);
8334 - genclk_init_parent(&atmel_lcdfb0_pixclk);
8335 - genclk_init_parent(&abdac0_sample_clk);
8338 - * Turn on all clocks that have at least one user already, and
8339 - * turn off everything else. We only do this for module
8340 - * clocks, and even though it isn't particularly pretty to
8341 - * check the address of the mode function, it should do the
8344 - for (i = 0; i < ARRAY_SIZE(at32_clock_list); i++) {
8345 - struct clk *clk = at32_clock_list[i];
8347 - if (clk->users == 0)
8350 - if (clk->mode == &cpu_clk_mode)
8351 - cpu_mask |= 1 << clk->index;
8352 - else if (clk->mode == &hsb_clk_mode)
8353 - hsb_mask |= 1 << clk->index;
8354 - else if (clk->mode == &pba_clk_mode)
8355 - pba_mask |= 1 << clk->index;
8356 - else if (clk->mode == &pbb_clk_mode)
8357 - pbb_mask |= 1 << clk->index;
8360 - pm_writel(CPU_MASK, cpu_mask);
8361 - pm_writel(HSB_MASK, hsb_mask);
8362 - pm_writel(PBA_MASK, pba_mask);
8363 - pm_writel(PBB_MASK, pbb_mask);
8366 +++ b/arch/avr32/mach-at32ap/at32ap700x.c
8369 + * Copyright (C) 2005-2006 Atmel Corporation
8371 + * This program is free software; you can redistribute it and/or modify
8372 + * it under the terms of the GNU General Public License version 2 as
8373 + * published by the Free Software Foundation.
8375 +#include <linux/clk.h>
8376 +#include <linux/fb.h>
8377 +#include <linux/init.h>
8378 +#include <linux/platform_device.h>
8379 +#include <linux/dma-mapping.h>
8380 +#include <linux/spi/spi.h>
8381 +#include <linux/usb/atmel_usba_udc.h>
8383 +#include <asm/io.h>
8384 +#include <asm/irq.h>
8386 +#include <asm/arch/at32ap700x.h>
8387 +#include <asm/arch/board.h>
8388 +#include <asm/arch/portmux.h>
8390 +#include <video/atmel_lcdc.h>
8393 +#include "hmatrix.h"
8398 +#define PBMEM(base) \
8401 + .end = base + 0x3ff, \
8402 + .flags = IORESOURCE_MEM, \
8408 + .flags = IORESOURCE_IRQ, \
8410 +#define NAMED_IRQ(num, _name) \
8415 + .flags = IORESOURCE_IRQ, \
8418 +/* REVISIT these assume *every* device supports DMA, but several
8419 + * don't ... tc, smc, pio, rtc, watchdog, pwm, ps2, and more.
8421 +#define DEFINE_DEV(_name, _id) \
8422 +static u64 _name##_id##_dma_mask = DMA_32BIT_MASK; \
8423 +static struct platform_device _name##_id##_device = { \
8427 + .dma_mask = &_name##_id##_dma_mask, \
8428 + .coherent_dma_mask = DMA_32BIT_MASK, \
8430 + .resource = _name##_id##_resource, \
8431 + .num_resources = ARRAY_SIZE(_name##_id##_resource), \
8433 +#define DEFINE_DEV_DATA(_name, _id) \
8434 +static u64 _name##_id##_dma_mask = DMA_32BIT_MASK; \
8435 +static struct platform_device _name##_id##_device = { \
8439 + .dma_mask = &_name##_id##_dma_mask, \
8440 + .platform_data = &_name##_id##_data, \
8441 + .coherent_dma_mask = DMA_32BIT_MASK, \
8443 + .resource = _name##_id##_resource, \
8444 + .num_resources = ARRAY_SIZE(_name##_id##_resource), \
8447 +#define select_peripheral(pin, periph, flags) \
8448 + at32_select_periph(GPIO_PIN_##pin, GPIO_##periph, flags)
8450 +#define DEV_CLK(_name, devname, bus, _index) \
8451 +static struct clk devname##_##_name = { \
8453 + .dev = &devname##_device.dev, \
8454 + .parent = &bus##_clk, \
8455 + .mode = bus##_clk_mode, \
8456 + .get_rate = bus##_clk_get_rate, \
8457 + .index = _index, \
8460 +static DEFINE_SPINLOCK(pm_lock);
8462 +unsigned long at32ap7000_osc_rates[3] = {
8464 + /* FIXME: these are ATSTK1002-specific */
8469 +static unsigned long osc_get_rate(struct clk *clk)
8471 + return at32ap7000_osc_rates[clk->index];
8474 +static unsigned long pll_get_rate(struct clk *clk, unsigned long control)
8476 + unsigned long div, mul, rate;
8478 + if (!(control & PM_BIT(PLLEN)))
8481 + div = PM_BFEXT(PLLDIV, control) + 1;
8482 + mul = PM_BFEXT(PLLMUL, control) + 1;
8484 + rate = clk->parent->get_rate(clk->parent);
8485 + rate = (rate + div / 2) / div;
8491 +static unsigned long pll0_get_rate(struct clk *clk)
8495 + control = pm_readl(PLL0);
8497 + return pll_get_rate(clk, control);
8500 +static unsigned long pll1_get_rate(struct clk *clk)
8504 + control = pm_readl(PLL1);
8506 + return pll_get_rate(clk, control);
8510 + * The AT32AP7000 has five primary clock sources: One 32kHz
8511 + * oscillator, two crystal oscillators and two PLLs.
8513 +static struct clk osc32k = {
8515 + .get_rate = osc_get_rate,
8519 +static struct clk osc0 = {
8521 + .get_rate = osc_get_rate,
8525 +static struct clk osc1 = {
8527 + .get_rate = osc_get_rate,
8530 +static struct clk pll0 = {
8532 + .get_rate = pll0_get_rate,
8535 +static struct clk pll1 = {
8537 + .get_rate = pll1_get_rate,
8542 + * The main clock can be either osc0 or pll0. The boot loader may
8543 + * have chosen one for us, so we don't really know which one until we
8544 + * have a look at the SM.
8546 +static struct clk *main_clock;
8549 + * Synchronous clocks are generated from the main clock. The clocks
8550 + * must satisfy the constraint
8551 + * fCPU >= fHSB >= fPB
8552 + * i.e. each clock must not be faster than its parent.
8554 +static unsigned long bus_clk_get_rate(struct clk *clk, unsigned int shift)
8556 + return main_clock->get_rate(main_clock) >> shift;
8559 +static void cpu_clk_mode(struct clk *clk, int enabled)
8561 + unsigned long flags;
8564 + spin_lock_irqsave(&pm_lock, flags);
8565 + mask = pm_readl(CPU_MASK);
8567 + mask |= 1 << clk->index;
8569 + mask &= ~(1 << clk->index);
8570 + pm_writel(CPU_MASK, mask);
8571 + spin_unlock_irqrestore(&pm_lock, flags);
8574 +static unsigned long cpu_clk_get_rate(struct clk *clk)
8576 + unsigned long cksel, shift = 0;
8578 + cksel = pm_readl(CKSEL);
8579 + if (cksel & PM_BIT(CPUDIV))
8580 + shift = PM_BFEXT(CPUSEL, cksel) + 1;
8582 + return bus_clk_get_rate(clk, shift);
8585 +static long cpu_clk_set_rate(struct clk *clk, unsigned long rate, int apply)
8588 + unsigned long parent_rate, child_div, actual_rate, div;
8590 + parent_rate = clk->parent->get_rate(clk->parent);
8591 + control = pm_readl(CKSEL);
8593 + if (control & PM_BIT(HSBDIV))
8594 + child_div = 1 << (PM_BFEXT(HSBSEL, control) + 1);
8598 + if (rate > 3 * (parent_rate / 4) || child_div == 1) {
8599 + actual_rate = parent_rate;
8600 + control &= ~PM_BIT(CPUDIV);
8602 + unsigned int cpusel;
8603 + div = (parent_rate + rate / 2) / rate;
8604 + if (div > child_div)
8606 + cpusel = (div > 1) ? (fls(div) - 2) : 0;
8607 + control = PM_BIT(CPUDIV) | PM_BFINS(CPUSEL, cpusel, control);
8608 + actual_rate = parent_rate / (1 << (cpusel + 1));
8611 + pr_debug("clk %s: new rate %lu (actual rate %lu)\n",
8612 + clk->name, rate, actual_rate);
8615 + pm_writel(CKSEL, control);
8617 + return actual_rate;
8620 +static void hsb_clk_mode(struct clk *clk, int enabled)
8622 + unsigned long flags;
8625 + spin_lock_irqsave(&pm_lock, flags);
8626 + mask = pm_readl(HSB_MASK);
8628 + mask |= 1 << clk->index;
8630 + mask &= ~(1 << clk->index);
8631 + pm_writel(HSB_MASK, mask);
8632 + spin_unlock_irqrestore(&pm_lock, flags);
8635 +static unsigned long hsb_clk_get_rate(struct clk *clk)
8637 + unsigned long cksel, shift = 0;
8639 + cksel = pm_readl(CKSEL);
8640 + if (cksel & PM_BIT(HSBDIV))
8641 + shift = PM_BFEXT(HSBSEL, cksel) + 1;
8643 + return bus_clk_get_rate(clk, shift);
8646 +static void pba_clk_mode(struct clk *clk, int enabled)
8648 + unsigned long flags;
8651 + spin_lock_irqsave(&pm_lock, flags);
8652 + mask = pm_readl(PBA_MASK);
8654 + mask |= 1 << clk->index;
8656 + mask &= ~(1 << clk->index);
8657 + pm_writel(PBA_MASK, mask);
8658 + spin_unlock_irqrestore(&pm_lock, flags);
8661 +static unsigned long pba_clk_get_rate(struct clk *clk)
8663 + unsigned long cksel, shift = 0;
8665 + cksel = pm_readl(CKSEL);
8666 + if (cksel & PM_BIT(PBADIV))
8667 + shift = PM_BFEXT(PBASEL, cksel) + 1;
8669 + return bus_clk_get_rate(clk, shift);
8672 +static void pbb_clk_mode(struct clk *clk, int enabled)
8674 + unsigned long flags;
8677 + spin_lock_irqsave(&pm_lock, flags);
8678 + mask = pm_readl(PBB_MASK);
8680 + mask |= 1 << clk->index;
8682 + mask &= ~(1 << clk->index);
8683 + pm_writel(PBB_MASK, mask);
8684 + spin_unlock_irqrestore(&pm_lock, flags);
8687 +static unsigned long pbb_clk_get_rate(struct clk *clk)
8689 + unsigned long cksel, shift = 0;
8691 + cksel = pm_readl(CKSEL);
8692 + if (cksel & PM_BIT(PBBDIV))
8693 + shift = PM_BFEXT(PBBSEL, cksel) + 1;
8695 + return bus_clk_get_rate(clk, shift);
8698 +static struct clk cpu_clk = {
8700 + .get_rate = cpu_clk_get_rate,
8701 + .set_rate = cpu_clk_set_rate,
8704 +static struct clk hsb_clk = {
8706 + .parent = &cpu_clk,
8707 + .get_rate = hsb_clk_get_rate,
8709 +static struct clk pba_clk = {
8711 + .parent = &hsb_clk,
8712 + .mode = hsb_clk_mode,
8713 + .get_rate = pba_clk_get_rate,
8716 +static struct clk pbb_clk = {
8718 + .parent = &hsb_clk,
8719 + .mode = hsb_clk_mode,
8720 + .get_rate = pbb_clk_get_rate,
8725 +/* --------------------------------------------------------------------
8726 + * Generic Clock operations
8727 + * -------------------------------------------------------------------- */
8729 +static void genclk_mode(struct clk *clk, int enabled)
8733 + control = pm_readl(GCCTRL(clk->index));
8735 + control |= PM_BIT(CEN);
8737 + control &= ~PM_BIT(CEN);
8738 + pm_writel(GCCTRL(clk->index), control);
8741 +static unsigned long genclk_get_rate(struct clk *clk)
8744 + unsigned long div = 1;
8746 + control = pm_readl(GCCTRL(clk->index));
8747 + if (control & PM_BIT(DIVEN))
8748 + div = 2 * (PM_BFEXT(DIV, control) + 1);
8750 + return clk->parent->get_rate(clk->parent) / div;
8753 +static long genclk_set_rate(struct clk *clk, unsigned long rate, int apply)
8756 + unsigned long parent_rate, actual_rate, div;
8758 + parent_rate = clk->parent->get_rate(clk->parent);
8759 + control = pm_readl(GCCTRL(clk->index));
8761 + if (rate > 3 * parent_rate / 4) {
8762 + actual_rate = parent_rate;
8763 + control &= ~PM_BIT(DIVEN);
8765 + div = (parent_rate + rate) / (2 * rate) - 1;
8766 + control = PM_BFINS(DIV, div, control) | PM_BIT(DIVEN);
8767 + actual_rate = parent_rate / (2 * (div + 1));
8770 + dev_dbg(clk->dev, "clk %s: new rate %lu (actual rate %lu)\n",
8771 + clk->name, rate, actual_rate);
8774 + pm_writel(GCCTRL(clk->index), control);
8776 + return actual_rate;
8779 +int genclk_set_parent(struct clk *clk, struct clk *parent)
8783 + dev_dbg(clk->dev, "clk %s: new parent %s (was %s)\n",
8784 + clk->name, parent->name, clk->parent->name);
8786 + control = pm_readl(GCCTRL(clk->index));
8788 + if (parent == &osc1 || parent == &pll1)
8789 + control |= PM_BIT(OSCSEL);
8790 + else if (parent == &osc0 || parent == &pll0)
8791 + control &= ~PM_BIT(OSCSEL);
8795 + if (parent == &pll0 || parent == &pll1)
8796 + control |= PM_BIT(PLLSEL);
8798 + control &= ~PM_BIT(PLLSEL);
8800 + pm_writel(GCCTRL(clk->index), control);
8801 + clk->parent = parent;
8806 +static void __init genclk_init_parent(struct clk *clk)
8809 + struct clk *parent;
8811 + BUG_ON(clk->index > 7);
8813 + control = pm_readl(GCCTRL(clk->index));
8814 + if (control & PM_BIT(OSCSEL))
8815 + parent = (control & PM_BIT(PLLSEL)) ? &pll1 : &osc1;
8817 + parent = (control & PM_BIT(PLLSEL)) ? &pll0 : &osc0;
8819 + clk->parent = parent;
8822 +/* --------------------------------------------------------------------
8823 + * System peripherals
8824 + * -------------------------------------------------------------------- */
8825 +static struct resource at32_pm0_resource[] = {
8827 + .start = 0xfff00000,
8828 + .end = 0xfff0007f,
8829 + .flags = IORESOURCE_MEM,
8834 +static struct resource at32ap700x_rtc0_resource[] = {
8836 + .start = 0xfff00080,
8837 + .end = 0xfff000af,
8838 + .flags = IORESOURCE_MEM,
8843 +static struct resource at32_wdt0_resource[] = {
8845 + .start = 0xfff000b0,
8846 + .end = 0xfff000cf,
8847 + .flags = IORESOURCE_MEM,
8851 +static struct resource at32_eic0_resource[] = {
8853 + .start = 0xfff00100,
8854 + .end = 0xfff0013f,
8855 + .flags = IORESOURCE_MEM,
8860 +DEFINE_DEV(at32_pm, 0);
8861 +DEFINE_DEV(at32ap700x_rtc, 0);
8862 +DEFINE_DEV(at32_wdt, 0);
8863 +DEFINE_DEV(at32_eic, 0);
8866 + * Peripheral clock for PM, RTC, WDT and EIC. PM will ensure that this
8867 + * is always running.
8869 +static struct clk at32_pm_pclk = {
8871 + .dev = &at32_pm0_device.dev,
8872 + .parent = &pbb_clk,
8873 + .mode = pbb_clk_mode,
8874 + .get_rate = pbb_clk_get_rate,
8879 +static struct resource intc0_resource[] = {
8880 + PBMEM(0xfff00400),
8882 +struct platform_device at32_intc0_device = {
8885 + .resource = intc0_resource,
8886 + .num_resources = ARRAY_SIZE(intc0_resource),
8888 +DEV_CLK(pclk, at32_intc0, pbb, 1);
8890 +static struct clk ebi_clk = {
8892 + .parent = &hsb_clk,
8893 + .mode = hsb_clk_mode,
8894 + .get_rate = hsb_clk_get_rate,
8897 +static struct clk hramc_clk = {
8899 + .parent = &hsb_clk,
8900 + .mode = hsb_clk_mode,
8901 + .get_rate = hsb_clk_get_rate,
8906 +static struct resource smc0_resource[] = {
8907 + PBMEM(0xfff03400),
8909 +DEFINE_DEV(smc, 0);
8910 +DEV_CLK(pclk, smc0, pbb, 13);
8911 +DEV_CLK(mck, smc0, hsb, 0);
8913 +static struct platform_device pdc_device = {
8917 +DEV_CLK(hclk, pdc, hsb, 4);
8918 +DEV_CLK(pclk, pdc, pba, 16);
8920 +static struct clk pico_clk = {
8922 + .parent = &cpu_clk,
8923 + .mode = cpu_clk_mode,
8924 + .get_rate = cpu_clk_get_rate,
8928 +static struct resource dmaca0_resource[] = {
8930 + .start = 0xff200000,
8931 + .end = 0xff20ffff,
8932 + .flags = IORESOURCE_MEM,
8936 +DEFINE_DEV(dmaca, 0);
8937 +DEV_CLK(hclk, dmaca0, hsb, 10);
8939 +/* --------------------------------------------------------------------
8941 + * -------------------------------------------------------------------- */
8943 +static struct clk hmatrix_clk = {
8944 + .name = "hmatrix_clk",
8945 + .parent = &pbb_clk,
8946 + .mode = pbb_clk_mode,
8947 + .get_rate = pbb_clk_get_rate,
8951 +#define HMATRIX_BASE ((void __iomem *)0xfff00800)
8953 +#define hmatrix_readl(reg) \
8954 + __raw_readl((HMATRIX_BASE) + HMATRIX_##reg)
8955 +#define hmatrix_writel(reg,value) \
8956 + __raw_writel((value), (HMATRIX_BASE) + HMATRIX_##reg)
8959 + * Set bits in the HMATRIX Special Function Register (SFR) used by the
8960 + * External Bus Interface (EBI). This can be used to enable special
8961 + * features like CompactFlash support, NAND Flash support, etc. on
8962 + * certain chipselects.
8964 +static inline void set_ebi_sfr_bits(u32 mask)
8968 + clk_enable(&hmatrix_clk);
8969 + sfr = hmatrix_readl(SFR4);
8971 + hmatrix_writel(SFR4, sfr);
8972 + clk_disable(&hmatrix_clk);
8975 +/* --------------------------------------------------------------------
8976 + * Timer/Counter (TC)
8977 + * -------------------------------------------------------------------- */
8979 +static struct resource at32_tcb0_resource[] = {
8980 + PBMEM(0xfff00c00),
8983 +static struct platform_device at32_tcb0_device = {
8984 + .name = "atmel_tcb",
8986 + .resource = at32_tcb0_resource,
8987 + .num_resources = ARRAY_SIZE(at32_tcb0_resource),
8989 +DEV_CLK(t0_clk, at32_tcb0, pbb, 3);
8991 +static struct resource at32_tcb1_resource[] = {
8992 + PBMEM(0xfff01000),
8995 +static struct platform_device at32_tcb1_device = {
8996 + .name = "atmel_tcb",
8998 + .resource = at32_tcb1_resource,
8999 + .num_resources = ARRAY_SIZE(at32_tcb1_resource),
9001 +DEV_CLK(t0_clk, at32_tcb1, pbb, 4);
9003 +/* --------------------------------------------------------------------
9005 + * -------------------------------------------------------------------- */
9007 +static struct resource pio0_resource[] = {
9008 + PBMEM(0xffe02800),
9011 +DEFINE_DEV(pio, 0);
9012 +DEV_CLK(mck, pio0, pba, 10);
9014 +static struct resource pio1_resource[] = {
9015 + PBMEM(0xffe02c00),
9018 +DEFINE_DEV(pio, 1);
9019 +DEV_CLK(mck, pio1, pba, 11);
9021 +static struct resource pio2_resource[] = {
9022 + PBMEM(0xffe03000),
9025 +DEFINE_DEV(pio, 2);
9026 +DEV_CLK(mck, pio2, pba, 12);
9028 +static struct resource pio3_resource[] = {
9029 + PBMEM(0xffe03400),
9032 +DEFINE_DEV(pio, 3);
9033 +DEV_CLK(mck, pio3, pba, 13);
9035 +static struct resource pio4_resource[] = {
9036 + PBMEM(0xffe03800),
9039 +DEFINE_DEV(pio, 4);
9040 +DEV_CLK(mck, pio4, pba, 14);
9042 +void __init at32_add_system_devices(void)
9044 + platform_device_register(&at32_pm0_device);
9045 + platform_device_register(&at32_intc0_device);
9046 + platform_device_register(&at32ap700x_rtc0_device);
9047 + platform_device_register(&at32_wdt0_device);
9048 + platform_device_register(&at32_eic0_device);
9049 + platform_device_register(&smc0_device);
9050 + platform_device_register(&pdc_device);
9051 + platform_device_register(&dmaca0_device);
9053 + platform_device_register(&at32_tcb0_device);
9054 + platform_device_register(&at32_tcb1_device);
9056 + platform_device_register(&pio0_device);
9057 + platform_device_register(&pio1_device);
9058 + platform_device_register(&pio2_device);
9059 + platform_device_register(&pio3_device);
9060 + platform_device_register(&pio4_device);
9063 +/* --------------------------------------------------------------------
9065 + * -------------------------------------------------------------------- */
9066 +static struct resource atmel_psif0_resource[] __initdata = {
9068 + .start = 0xffe03c00,
9069 + .end = 0xffe03cff,
9070 + .flags = IORESOURCE_MEM,
9074 +static struct clk atmel_psif0_pclk = {
9076 + .parent = &pba_clk,
9077 + .mode = pba_clk_mode,
9078 + .get_rate = pba_clk_get_rate,
9082 +static struct resource atmel_psif1_resource[] __initdata = {
9084 + .start = 0xffe03d00,
9085 + .end = 0xffe03dff,
9086 + .flags = IORESOURCE_MEM,
9090 +static struct clk atmel_psif1_pclk = {
9092 + .parent = &pba_clk,
9093 + .mode = pba_clk_mode,
9094 + .get_rate = pba_clk_get_rate,
9098 +struct platform_device *__init at32_add_device_psif(unsigned int id)
9100 + struct platform_device *pdev;
9102 + if (!(id == 0 || id == 1))
9105 + pdev = platform_device_alloc("atmel_psif", id);
9111 + if (platform_device_add_resources(pdev, atmel_psif0_resource,
9112 + ARRAY_SIZE(atmel_psif0_resource)))
9113 + goto err_add_resources;
9114 + atmel_psif0_pclk.dev = &pdev->dev;
9115 + select_peripheral(PA(8), PERIPH_A, 0); /* CLOCK */
9116 + select_peripheral(PA(9), PERIPH_A, 0); /* DATA */
9119 + if (platform_device_add_resources(pdev, atmel_psif1_resource,
9120 + ARRAY_SIZE(atmel_psif1_resource)))
9121 + goto err_add_resources;
9122 + atmel_psif1_pclk.dev = &pdev->dev;
9123 + select_peripheral(PB(11), PERIPH_A, 0); /* CLOCK */
9124 + select_peripheral(PB(12), PERIPH_A, 0); /* DATA */
9130 + platform_device_add(pdev);
9134 + platform_device_put(pdev);
9138 +/* --------------------------------------------------------------------
9140 + * -------------------------------------------------------------------- */
9142 +static struct atmel_uart_data atmel_usart0_data = {
9146 +static struct resource atmel_usart0_resource[] = {
9147 + PBMEM(0xffe00c00),
9150 +DEFINE_DEV_DATA(atmel_usart, 0);
9151 +DEV_CLK(usart, atmel_usart0, pba, 3);
9153 +static struct atmel_uart_data atmel_usart1_data = {
9157 +static struct resource atmel_usart1_resource[] = {
9158 + PBMEM(0xffe01000),
9161 +DEFINE_DEV_DATA(atmel_usart, 1);
9162 +DEV_CLK(usart, atmel_usart1, pba, 4);
9164 +static struct atmel_uart_data atmel_usart2_data = {
9168 +static struct resource atmel_usart2_resource[] = {
9169 + PBMEM(0xffe01400),
9172 +DEFINE_DEV_DATA(atmel_usart, 2);
9173 +DEV_CLK(usart, atmel_usart2, pba, 5);
9175 +static struct atmel_uart_data atmel_usart3_data = {
9179 +static struct resource atmel_usart3_resource[] = {
9180 + PBMEM(0xffe01800),
9183 +DEFINE_DEV_DATA(atmel_usart, 3);
9184 +DEV_CLK(usart, atmel_usart3, pba, 6);
9186 +static inline void configure_usart0_pins(void)
9188 + select_peripheral(PA(8), PERIPH_B, 0); /* RXD */
9189 + select_peripheral(PA(9), PERIPH_B, 0); /* TXD */
9192 +static inline void configure_usart1_pins(void)
9194 + select_peripheral(PA(17), PERIPH_A, 0); /* RXD */
9195 + select_peripheral(PA(18), PERIPH_A, 0); /* TXD */
9198 +static inline void configure_usart2_pins(void)
9200 + select_peripheral(PB(26), PERIPH_B, 0); /* RXD */
9201 + select_peripheral(PB(27), PERIPH_B, 0); /* TXD */
9204 +static inline void configure_usart3_pins(void)
9206 + select_peripheral(PB(18), PERIPH_B, 0); /* RXD */
9207 + select_peripheral(PB(17), PERIPH_B, 0); /* TXD */
9210 +static struct platform_device *__initdata at32_usarts[4];
9212 +void __init at32_map_usart(unsigned int hw_id, unsigned int line)
9214 + struct platform_device *pdev;
9218 + pdev = &atmel_usart0_device;
9219 + configure_usart0_pins();
9222 + pdev = &atmel_usart1_device;
9223 + configure_usart1_pins();
9226 + pdev = &atmel_usart2_device;
9227 + configure_usart2_pins();
9230 + pdev = &atmel_usart3_device;
9231 + configure_usart3_pins();
9237 + if (PXSEG(pdev->resource[0].start) == P4SEG) {
9238 + /* Addresses in the P4 segment are permanently mapped 1:1 */
9239 + struct atmel_uart_data *data = pdev->dev.platform_data;
9240 + data->regs = (void __iomem *)pdev->resource[0].start;
9244 + at32_usarts[line] = pdev;
9247 +struct platform_device *__init at32_add_device_usart(unsigned int id)
9249 + platform_device_register(at32_usarts[id]);
9250 + return at32_usarts[id];
9253 +struct platform_device *atmel_default_console_device;
9255 +void __init at32_setup_serial_console(unsigned int usart_id)
9257 + atmel_default_console_device = at32_usarts[usart_id];
9260 +/* --------------------------------------------------------------------
9262 + * -------------------------------------------------------------------- */
9264 +#ifdef CONFIG_CPU_AT32AP7000
9265 +static struct eth_platform_data macb0_data;
9266 +static struct resource macb0_resource[] = {
9267 + PBMEM(0xfff01800),
9270 +DEFINE_DEV_DATA(macb, 0);
9271 +DEV_CLK(hclk, macb0, hsb, 8);
9272 +DEV_CLK(pclk, macb0, pbb, 6);
9274 +static struct eth_platform_data macb1_data;
9275 +static struct resource macb1_resource[] = {
9276 + PBMEM(0xfff01c00),
9279 +DEFINE_DEV_DATA(macb, 1);
9280 +DEV_CLK(hclk, macb1, hsb, 9);
9281 +DEV_CLK(pclk, macb1, pbb, 7);
9283 +struct platform_device *__init
9284 +at32_add_device_eth(unsigned int id, struct eth_platform_data *data)
9286 + struct platform_device *pdev;
9290 + pdev = &macb0_device;
9292 + select_peripheral(PC(3), PERIPH_A, 0); /* TXD0 */
9293 + select_peripheral(PC(4), PERIPH_A, 0); /* TXD1 */
9294 + select_peripheral(PC(7), PERIPH_A, 0); /* TXEN */
9295 + select_peripheral(PC(8), PERIPH_A, 0); /* TXCK */
9296 + select_peripheral(PC(9), PERIPH_A, 0); /* RXD0 */
9297 + select_peripheral(PC(10), PERIPH_A, 0); /* RXD1 */
9298 + select_peripheral(PC(13), PERIPH_A, 0); /* RXER */
9299 + select_peripheral(PC(15), PERIPH_A, 0); /* RXDV */
9300 + select_peripheral(PC(16), PERIPH_A, 0); /* MDC */
9301 + select_peripheral(PC(17), PERIPH_A, 0); /* MDIO */
9303 + if (!data->is_rmii) {
9304 + select_peripheral(PC(0), PERIPH_A, 0); /* COL */
9305 + select_peripheral(PC(1), PERIPH_A, 0); /* CRS */
9306 + select_peripheral(PC(2), PERIPH_A, 0); /* TXER */
9307 + select_peripheral(PC(5), PERIPH_A, 0); /* TXD2 */
9308 + select_peripheral(PC(6), PERIPH_A, 0); /* TXD3 */
9309 + select_peripheral(PC(11), PERIPH_A, 0); /* RXD2 */
9310 + select_peripheral(PC(12), PERIPH_A, 0); /* RXD3 */
9311 + select_peripheral(PC(14), PERIPH_A, 0); /* RXCK */
9312 + select_peripheral(PC(18), PERIPH_A, 0); /* SPD */
9317 + pdev = &macb1_device;
9319 + select_peripheral(PD(13), PERIPH_B, 0); /* TXD0 */
9320 + select_peripheral(PD(14), PERIPH_B, 0); /* TXD1 */
9321 + select_peripheral(PD(11), PERIPH_B, 0); /* TXEN */
9322 + select_peripheral(PD(12), PERIPH_B, 0); /* TXCK */
9323 + select_peripheral(PD(10), PERIPH_B, 0); /* RXD0 */
9324 + select_peripheral(PD(6), PERIPH_B, 0); /* RXD1 */
9325 + select_peripheral(PD(5), PERIPH_B, 0); /* RXER */
9326 + select_peripheral(PD(4), PERIPH_B, 0); /* RXDV */
9327 + select_peripheral(PD(3), PERIPH_B, 0); /* MDC */
9328 + select_peripheral(PD(2), PERIPH_B, 0); /* MDIO */
9330 + if (!data->is_rmii) {
9331 + select_peripheral(PC(19), PERIPH_B, 0); /* COL */
9332 + select_peripheral(PC(23), PERIPH_B, 0); /* CRS */
9333 + select_peripheral(PC(26), PERIPH_B, 0); /* TXER */
9334 + select_peripheral(PC(27), PERIPH_B, 0); /* TXD2 */
9335 + select_peripheral(PC(28), PERIPH_B, 0); /* TXD3 */
9336 + select_peripheral(PC(29), PERIPH_B, 0); /* RXD2 */
9337 + select_peripheral(PC(30), PERIPH_B, 0); /* RXD3 */
9338 + select_peripheral(PC(24), PERIPH_B, 0); /* RXCK */
9339 + select_peripheral(PD(15), PERIPH_B, 0); /* SPD */
9347 + memcpy(pdev->dev.platform_data, data, sizeof(struct eth_platform_data));
9348 + platform_device_register(pdev);
9354 +/* --------------------------------------------------------------------
9356 + * -------------------------------------------------------------------- */
9357 +static struct resource atmel_spi0_resource[] = {
9358 + PBMEM(0xffe00000),
9361 +DEFINE_DEV(atmel_spi, 0);
9362 +DEV_CLK(spi_clk, atmel_spi0, pba, 0);
9364 +static struct resource atmel_spi1_resource[] = {
9365 + PBMEM(0xffe00400),
9368 +DEFINE_DEV(atmel_spi, 1);
9369 +DEV_CLK(spi_clk, atmel_spi1, pba, 1);
9372 +at32_spi_setup_slaves(unsigned int bus_num, struct spi_board_info *b,
9373 + unsigned int n, const u8 *pins)
9375 + unsigned int pin, mode;
9377 + for (; n; n--, b++) {
9378 + b->bus_num = bus_num;
9379 + if (b->chip_select >= 4)
9381 + pin = (unsigned)b->controller_data;
9383 + pin = pins[b->chip_select];
9384 + b->controller_data = (void *)pin;
9386 + mode = AT32_GPIOF_OUTPUT;
9387 + if (!(b->mode & SPI_CS_HIGH))
9388 + mode |= AT32_GPIOF_HIGH;
9389 + at32_select_gpio(pin, mode);
9393 +struct platform_device *__init
9394 +at32_add_device_spi(unsigned int id, struct spi_board_info *b, unsigned int n)
9397 + * Manage the chipselects as GPIOs, normally using the same pins
9398 + * the SPI controller expects; but boards can use other pins.
9400 + static u8 __initdata spi0_pins[] =
9401 + { GPIO_PIN_PA(3), GPIO_PIN_PA(4),
9402 + GPIO_PIN_PA(5), GPIO_PIN_PA(20), };
9403 + static u8 __initdata spi1_pins[] =
9404 + { GPIO_PIN_PB(2), GPIO_PIN_PB(3),
9405 + GPIO_PIN_PB(4), GPIO_PIN_PA(27), };
9406 + struct platform_device *pdev;
9410 + pdev = &atmel_spi0_device;
9411 + select_peripheral(PA(0), PERIPH_A, 0); /* MISO */
9412 + select_peripheral(PA(1), PERIPH_A, 0); /* MOSI */
9413 + select_peripheral(PA(2), PERIPH_A, 0); /* SCK */
9414 + at32_spi_setup_slaves(0, b, n, spi0_pins);
9418 + pdev = &atmel_spi1_device;
9419 + select_peripheral(PB(0), PERIPH_B, 0); /* MISO */
9420 + select_peripheral(PB(1), PERIPH_B, 0); /* MOSI */
9421 + select_peripheral(PB(5), PERIPH_B, 0); /* SCK */
9422 + at32_spi_setup_slaves(1, b, n, spi1_pins);
9429 + spi_register_board_info(b, n);
9430 + platform_device_register(pdev);
9434 +/* --------------------------------------------------------------------
9436 + * -------------------------------------------------------------------- */
9437 +static struct resource atmel_twi0_resource[] __initdata = {
9438 + PBMEM(0xffe00800),
9441 +static struct clk atmel_twi0_pclk = {
9442 + .name = "twi_pclk",
9443 + .parent = &pba_clk,
9444 + .mode = pba_clk_mode,
9445 + .get_rate = pba_clk_get_rate,
9449 +struct platform_device *__init at32_add_device_twi(unsigned int id,
9450 + struct i2c_board_info *b,
9453 + struct platform_device *pdev;
9458 + pdev = platform_device_alloc("atmel_twi", id);
9462 + if (platform_device_add_resources(pdev, atmel_twi0_resource,
9463 + ARRAY_SIZE(atmel_twi0_resource)))
9464 + goto err_add_resources;
9466 + select_peripheral(PA(6), PERIPH_A, 0); /* SDA */
9467 + select_peripheral(PA(7), PERIPH_A, 0); /* SDL */
9469 + atmel_twi0_pclk.dev = &pdev->dev;
9472 + i2c_register_board_info(id, b, n);
9474 + platform_device_add(pdev);
9478 + platform_device_put(pdev);
9482 +/* --------------------------------------------------------------------
9484 + * -------------------------------------------------------------------- */
9485 +static struct resource atmel_mci0_resource[] __initdata = {
9486 + PBMEM(0xfff02400),
9489 +static struct clk atmel_mci0_pclk = {
9490 + .name = "mci_clk",
9491 + .parent = &pbb_clk,
9492 + .mode = pbb_clk_mode,
9493 + .get_rate = pbb_clk_get_rate,
9497 +struct platform_device *__init
9498 +at32_add_device_mci(unsigned int id, struct mci_platform_data *data)
9500 + struct platform_device *pdev;
9505 + pdev = platform_device_alloc("atmel_mci", id);
9509 + if (platform_device_add_resources(pdev, atmel_mci0_resource,
9510 + ARRAY_SIZE(atmel_mci0_resource)))
9513 + if (data && platform_device_add_data(pdev, data,
9514 + sizeof(struct mci_platform_data)))
9517 + select_peripheral(PA(10), PERIPH_A, 0); /* CLK */
9518 + select_peripheral(PA(11), PERIPH_A, 0); /* CMD */
9519 + select_peripheral(PA(12), PERIPH_A, 0); /* DATA0 */
9520 + select_peripheral(PA(13), PERIPH_A, 0); /* DATA1 */
9521 + select_peripheral(PA(14), PERIPH_A, 0); /* DATA2 */
9522 + select_peripheral(PA(15), PERIPH_A, 0); /* DATA3 */
9525 + if (data->detect_pin != GPIO_PIN_NONE)
9526 + at32_select_gpio(data->detect_pin, 0);
9527 + if (data->wp_pin != GPIO_PIN_NONE)
9528 + at32_select_gpio(data->wp_pin, 0);
9531 + atmel_mci0_pclk.dev = &pdev->dev;
9533 + platform_device_add(pdev);
9537 + platform_device_put(pdev);
9541 +/* --------------------------------------------------------------------
9543 + * -------------------------------------------------------------------- */
9544 +#if defined(CONFIG_CPU_AT32AP7000) || defined(CONFIG_CPU_AT32AP7002)
9545 +static struct atmel_lcdfb_info atmel_lcdfb0_data;
9546 +static struct resource atmel_lcdfb0_resource[] = {
9548 + .start = 0xff000000,
9549 + .end = 0xff000fff,
9550 + .flags = IORESOURCE_MEM,
9554 + /* Placeholder for pre-allocated fb memory */
9555 + .start = 0x00000000,
9556 + .end = 0x00000000,
9560 +DEFINE_DEV_DATA(atmel_lcdfb, 0);
9561 +DEV_CLK(hck1, atmel_lcdfb0, hsb, 7);
9562 +static struct clk atmel_lcdfb0_pixclk = {
9563 + .name = "lcdc_clk",
9564 + .dev = &atmel_lcdfb0_device.dev,
9565 + .mode = genclk_mode,
9566 + .get_rate = genclk_get_rate,
9567 + .set_rate = genclk_set_rate,
9568 + .set_parent = genclk_set_parent,
9572 +struct platform_device *__init
9573 +at32_add_device_lcdc(unsigned int id, struct atmel_lcdfb_info *data,
9574 + unsigned long fbmem_start, unsigned long fbmem_len)
9576 + struct platform_device *pdev;
9577 + struct atmel_lcdfb_info *info;
9578 + struct fb_monspecs *monspecs;
9579 + struct fb_videomode *modedb;
9580 + unsigned int modedb_size;
9583 + * Do a deep copy of the fb data, monspecs and modedb. Make
9584 + * sure all allocations are done before setting up the
9587 + monspecs = kmemdup(data->default_monspecs,
9588 + sizeof(struct fb_monspecs), GFP_KERNEL);
9592 + modedb_size = sizeof(struct fb_videomode) * monspecs->modedb_len;
9593 + modedb = kmemdup(monspecs->modedb, modedb_size, GFP_KERNEL);
9595 + goto err_dup_modedb;
9596 + monspecs->modedb = modedb;
9600 + pdev = &atmel_lcdfb0_device;
9601 + select_peripheral(PC(19), PERIPH_A, 0); /* CC */
9602 + select_peripheral(PC(20), PERIPH_A, 0); /* HSYNC */
9603 + select_peripheral(PC(21), PERIPH_A, 0); /* PCLK */
9604 + select_peripheral(PC(22), PERIPH_A, 0); /* VSYNC */
9605 + select_peripheral(PC(23), PERIPH_A, 0); /* DVAL */
9606 + select_peripheral(PC(24), PERIPH_A, 0); /* MODE */
9607 + select_peripheral(PC(25), PERIPH_A, 0); /* PWR */
9608 + select_peripheral(PC(26), PERIPH_A, 0); /* DATA0 */
9609 + select_peripheral(PC(27), PERIPH_A, 0); /* DATA1 */
9610 + select_peripheral(PC(28), PERIPH_A, 0); /* DATA2 */
9611 + select_peripheral(PC(29), PERIPH_A, 0); /* DATA3 */
9612 + select_peripheral(PC(30), PERIPH_A, 0); /* DATA4 */
9613 + select_peripheral(PC(31), PERIPH_A, 0); /* DATA5 */
9614 + select_peripheral(PD(0), PERIPH_A, 0); /* DATA6 */
9615 + select_peripheral(PD(1), PERIPH_A, 0); /* DATA7 */
9616 + select_peripheral(PD(2), PERIPH_A, 0); /* DATA8 */
9617 + select_peripheral(PD(3), PERIPH_A, 0); /* DATA9 */
9618 + select_peripheral(PD(4), PERIPH_A, 0); /* DATA10 */
9619 + select_peripheral(PD(5), PERIPH_A, 0); /* DATA11 */
9620 + select_peripheral(PD(6), PERIPH_A, 0); /* DATA12 */
9621 + select_peripheral(PD(7), PERIPH_A, 0); /* DATA13 */
9622 + select_peripheral(PD(8), PERIPH_A, 0); /* DATA14 */
9623 + select_peripheral(PD(9), PERIPH_A, 0); /* DATA15 */
9624 + select_peripheral(PD(10), PERIPH_A, 0); /* DATA16 */
9625 + select_peripheral(PD(11), PERIPH_A, 0); /* DATA17 */
9626 + select_peripheral(PD(12), PERIPH_A, 0); /* DATA18 */
9627 + select_peripheral(PD(13), PERIPH_A, 0); /* DATA19 */
9628 + select_peripheral(PD(14), PERIPH_A, 0); /* DATA20 */
9629 + select_peripheral(PD(15), PERIPH_A, 0); /* DATA21 */
9630 + select_peripheral(PD(16), PERIPH_A, 0); /* DATA22 */
9631 + select_peripheral(PD(17), PERIPH_A, 0); /* DATA23 */
9633 + clk_set_parent(&atmel_lcdfb0_pixclk, &pll0);
9634 + clk_set_rate(&atmel_lcdfb0_pixclk, clk_get_rate(&pll0));
9638 + goto err_invalid_id;
9642 + pdev->resource[2].start = fbmem_start;
9643 + pdev->resource[2].end = fbmem_start + fbmem_len - 1;
9644 + pdev->resource[2].flags = IORESOURCE_MEM;
9647 + info = pdev->dev.platform_data;
9648 + memcpy(info, data, sizeof(struct atmel_lcdfb_info));
9649 + info->default_monspecs = monspecs;
9651 + platform_device_register(pdev);
9662 +/* --------------------------------------------------------------------
9664 + * -------------------------------------------------------------------- */
9665 +static struct resource atmel_pwm0_resource[] __initdata = {
9666 + PBMEM(0xfff01400),
9669 +static struct clk atmel_pwm0_mck = {
9671 + .parent = &pbb_clk,
9672 + .mode = pbb_clk_mode,
9673 + .get_rate = pbb_clk_get_rate,
9677 +struct platform_device *__init at32_add_device_pwm(u32 mask)
9679 + struct platform_device *pdev;
9684 + pdev = platform_device_alloc("atmel_pwm", 0);
9688 + if (platform_device_add_resources(pdev, atmel_pwm0_resource,
9689 + ARRAY_SIZE(atmel_pwm0_resource)))
9690 + goto out_free_pdev;
9692 + if (platform_device_add_data(pdev, &mask, sizeof(mask)))
9693 + goto out_free_pdev;
9695 + if (mask & (1 << 0))
9696 + select_peripheral(PA(28), PERIPH_A, 0);
9697 + if (mask & (1 << 1))
9698 + select_peripheral(PA(29), PERIPH_A, 0);
9699 + if (mask & (1 << 2))
9700 + select_peripheral(PA(21), PERIPH_B, 0);
9701 + if (mask & (1 << 3))
9702 + select_peripheral(PA(22), PERIPH_B, 0);
9704 + atmel_pwm0_mck.dev = &pdev->dev;
9706 + platform_device_add(pdev);
9711 + platform_device_put(pdev);
9715 +/* --------------------------------------------------------------------
9717 + * -------------------------------------------------------------------- */
9718 +static struct resource ssc0_resource[] = {
9719 + PBMEM(0xffe01c00),
9722 +DEFINE_DEV(ssc, 0);
9723 +DEV_CLK(pclk, ssc0, pba, 7);
9725 +static struct resource ssc1_resource[] = {
9726 + PBMEM(0xffe02000),
9729 +DEFINE_DEV(ssc, 1);
9730 +DEV_CLK(pclk, ssc1, pba, 8);
9732 +static struct resource ssc2_resource[] = {
9733 + PBMEM(0xffe02400),
9736 +DEFINE_DEV(ssc, 2);
9737 +DEV_CLK(pclk, ssc2, pba, 9);
9739 +struct platform_device *__init
9740 +at32_add_device_ssc(unsigned int id, unsigned int flags)
9742 + struct platform_device *pdev;
9746 + pdev = &ssc0_device;
9747 + if (flags & ATMEL_SSC_RF)
9748 + select_peripheral(PA(21), PERIPH_A, 0); /* RF */
9749 + if (flags & ATMEL_SSC_RK)
9750 + select_peripheral(PA(22), PERIPH_A, 0); /* RK */
9751 + if (flags & ATMEL_SSC_TK)
9752 + select_peripheral(PA(23), PERIPH_A, 0); /* TK */
9753 + if (flags & ATMEL_SSC_TF)
9754 + select_peripheral(PA(24), PERIPH_A, 0); /* TF */
9755 + if (flags & ATMEL_SSC_TD)
9756 + select_peripheral(PA(25), PERIPH_A, 0); /* TD */
9757 + if (flags & ATMEL_SSC_RD)
9758 + select_peripheral(PA(26), PERIPH_A, 0); /* RD */
9761 + pdev = &ssc1_device;
9762 + if (flags & ATMEL_SSC_RF)
9763 + select_peripheral(PA(0), PERIPH_B, 0); /* RF */
9764 + if (flags & ATMEL_SSC_RK)
9765 + select_peripheral(PA(1), PERIPH_B, 0); /* RK */
9766 + if (flags & ATMEL_SSC_TK)
9767 + select_peripheral(PA(2), PERIPH_B, 0); /* TK */
9768 + if (flags & ATMEL_SSC_TF)
9769 + select_peripheral(PA(3), PERIPH_B, 0); /* TF */
9770 + if (flags & ATMEL_SSC_TD)
9771 + select_peripheral(PA(4), PERIPH_B, 0); /* TD */
9772 + if (flags & ATMEL_SSC_RD)
9773 + select_peripheral(PA(5), PERIPH_B, 0); /* RD */
9776 + pdev = &ssc2_device;
9777 + if (flags & ATMEL_SSC_TD)
9778 + select_peripheral(PB(13), PERIPH_A, 0); /* TD */
9779 + if (flags & ATMEL_SSC_RD)
9780 + select_peripheral(PB(14), PERIPH_A, 0); /* RD */
9781 + if (flags & ATMEL_SSC_TK)
9782 + select_peripheral(PB(15), PERIPH_A, 0); /* TK */
9783 + if (flags & ATMEL_SSC_TF)
9784 + select_peripheral(PB(16), PERIPH_A, 0); /* TF */
9785 + if (flags & ATMEL_SSC_RF)
9786 + select_peripheral(PB(17), PERIPH_A, 0); /* RF */
9787 + if (flags & ATMEL_SSC_RK)
9788 + select_peripheral(PB(18), PERIPH_A, 0); /* RK */
9794 + platform_device_register(pdev);
9798 +/* --------------------------------------------------------------------
9799 + * USB Device Controller
9800 + * -------------------------------------------------------------------- */
9801 +static struct resource usba0_resource[] __initdata = {
9803 + .start = 0xff300000,
9804 + .end = 0xff3fffff,
9805 + .flags = IORESOURCE_MEM,
9807 + .start = 0xfff03000,
9808 + .end = 0xfff033ff,
9809 + .flags = IORESOURCE_MEM,
9813 +static struct clk usba0_pclk = {
9815 + .parent = &pbb_clk,
9816 + .mode = pbb_clk_mode,
9817 + .get_rate = pbb_clk_get_rate,
9820 +static struct clk usba0_hclk = {
9822 + .parent = &hsb_clk,
9823 + .mode = hsb_clk_mode,
9824 + .get_rate = hsb_clk_get_rate,
9828 +#define EP(nam, idx, maxpkt, maxbk, dma, isoc) \
9832 + .fifo_size = maxpkt, \
9833 + .nr_banks = maxbk, \
9835 + .can_isoc = isoc, \
9838 +static struct usba_ep_data at32_usba_ep[] __initdata = {
9839 + EP("ep0", 0, 64, 1, 0, 0),
9840 + EP("ep1", 1, 512, 2, 1, 1),
9841 + EP("ep2", 2, 512, 2, 1, 1),
9842 + EP("ep3-int", 3, 64, 3, 1, 0),
9843 + EP("ep4-int", 4, 64, 3, 1, 0),
9844 + EP("ep5", 5, 1024, 3, 1, 1),
9845 + EP("ep6", 6, 1024, 3, 1, 1),
9850 +struct platform_device *__init
9851 +at32_add_device_usba(unsigned int id, struct usba_platform_data *data)
9854 + * pdata doesn't have room for any endpoints, so we need to
9855 + * append room for the ones we need right after it.
9858 + struct usba_platform_data pdata;
9859 + struct usba_ep_data ep[7];
9861 + struct platform_device *pdev;
9866 + pdev = platform_device_alloc("atmel_usba_udc", 0);
9870 + if (platform_device_add_resources(pdev, usba0_resource,
9871 + ARRAY_SIZE(usba0_resource)))
9872 + goto out_free_pdev;
9875 + usba_data.pdata.vbus_pin = data->vbus_pin;
9877 + usba_data.pdata.vbus_pin = -EINVAL;
9879 + data = &usba_data.pdata;
9880 + data->num_ep = ARRAY_SIZE(at32_usba_ep);
9881 + memcpy(data->ep, at32_usba_ep, sizeof(at32_usba_ep));
9883 + if (platform_device_add_data(pdev, data, sizeof(usba_data)))
9884 + goto out_free_pdev;
9886 + if (data->vbus_pin >= 0)
9887 + at32_select_gpio(data->vbus_pin, 0);
9889 + usba0_pclk.dev = &pdev->dev;
9890 + usba0_hclk.dev = &pdev->dev;
9892 + platform_device_add(pdev);
9897 + platform_device_put(pdev);
9901 +/* --------------------------------------------------------------------
9902 + * IDE / CompactFlash
9903 + * -------------------------------------------------------------------- */
9904 +#if defined(CONFIG_CPU_AT32AP7000) || defined(CONFIG_CPU_AT32AP7001)
9905 +static struct resource at32_smc_cs4_resource[] __initdata = {
9907 + .start = 0x04000000,
9908 + .end = 0x07ffffff,
9909 + .flags = IORESOURCE_MEM,
9911 + IRQ(~0UL), /* Magic IRQ will be overridden */
9913 +static struct resource at32_smc_cs5_resource[] __initdata = {
9915 + .start = 0x20000000,
9916 + .end = 0x23ffffff,
9917 + .flags = IORESOURCE_MEM,
9919 + IRQ(~0UL), /* Magic IRQ will be overridden */
9922 +static int __init at32_init_ide_or_cf(struct platform_device *pdev,
9923 + unsigned int cs, unsigned int extint)
9925 + static unsigned int extint_pin_map[4] __initdata = {
9931 + static bool common_pins_initialized __initdata = false;
9932 + unsigned int extint_pin;
9935 + if (extint >= ARRAY_SIZE(extint_pin_map))
9937 + extint_pin = extint_pin_map[extint];
9941 + ret = platform_device_add_resources(pdev,
9942 + at32_smc_cs4_resource,
9943 + ARRAY_SIZE(at32_smc_cs4_resource));
9947 + select_peripheral(PE(21), PERIPH_A, 0); /* NCS4 -> OE_N */
9948 + set_ebi_sfr_bits(HMATRIX_BIT(CS4A));
9951 + ret = platform_device_add_resources(pdev,
9952 + at32_smc_cs5_resource,
9953 + ARRAY_SIZE(at32_smc_cs5_resource));
9957 + select_peripheral(PE(22), PERIPH_A, 0); /* NCS5 -> OE_N */
9958 + set_ebi_sfr_bits(HMATRIX_BIT(CS5A));
9964 + if (!common_pins_initialized) {
9965 + select_peripheral(PE(19), PERIPH_A, 0); /* CFCE1 -> CS0_N */
9966 + select_peripheral(PE(20), PERIPH_A, 0); /* CFCE2 -> CS1_N */
9967 + select_peripheral(PE(23), PERIPH_A, 0); /* CFRNW -> DIR */
9968 + select_peripheral(PE(24), PERIPH_A, 0); /* NWAIT <- IORDY */
9969 + common_pins_initialized = true;
9972 + at32_select_periph(extint_pin, GPIO_PERIPH_A, AT32_GPIOF_DEGLITCH);
9974 + pdev->resource[1].start = EIM_IRQ_BASE + extint;
9975 + pdev->resource[1].end = pdev->resource[1].start;
9980 +struct platform_device *__init
9981 +at32_add_device_ide(unsigned int id, unsigned int extint,
9982 + struct ide_platform_data *data)
9984 + struct platform_device *pdev;
9986 + pdev = platform_device_alloc("at32_ide", id);
9990 + if (platform_device_add_data(pdev, data,
9991 + sizeof(struct ide_platform_data)))
9994 + if (at32_init_ide_or_cf(pdev, data->cs, extint))
9997 + platform_device_add(pdev);
10001 + platform_device_put(pdev);
10005 +struct platform_device *__init
10006 +at32_add_device_cf(unsigned int id, unsigned int extint,
10007 + struct cf_platform_data *data)
10009 + struct platform_device *pdev;
10011 + pdev = platform_device_alloc("at32_cf", id);
10015 + if (platform_device_add_data(pdev, data,
10016 + sizeof(struct cf_platform_data)))
10019 + if (at32_init_ide_or_cf(pdev, data->cs, extint))
10022 + if (data->detect_pin != GPIO_PIN_NONE)
10023 + at32_select_gpio(data->detect_pin, AT32_GPIOF_DEGLITCH);
10024 + if (data->reset_pin != GPIO_PIN_NONE)
10025 + at32_select_gpio(data->reset_pin, 0);
10026 + if (data->vcc_pin != GPIO_PIN_NONE)
10027 + at32_select_gpio(data->vcc_pin, 0);
10028 + /* READY is used as extint, so we can't select it as gpio */
10030 + platform_device_add(pdev);
10034 + platform_device_put(pdev);
10039 +/* --------------------------------------------------------------------
10041 + * -------------------------------------------------------------------- */
10042 +static struct resource atmel_ac97c0_resource[] __initdata = {
10043 + PBMEM(0xfff02800),
10046 +static struct clk atmel_ac97c0_pclk = {
10048 + .parent = &pbb_clk,
10049 + .mode = pbb_clk_mode,
10050 + .get_rate = pbb_clk_get_rate,
10054 +struct platform_device *__init at32_add_device_ac97c(unsigned int id)
10056 + struct platform_device *pdev;
10061 + pdev = platform_device_alloc("atmel_ac97c", id);
10065 + if (platform_device_add_resources(pdev, atmel_ac97c0_resource,
10066 + ARRAY_SIZE(atmel_ac97c0_resource)))
10067 + goto err_add_resources;
10069 + select_peripheral(PB(20), PERIPH_B, 0); /* SYNC */
10070 + select_peripheral(PB(21), PERIPH_B, 0); /* SDO */
10071 + select_peripheral(PB(22), PERIPH_B, 0); /* SDI */
10072 + select_peripheral(PB(23), PERIPH_B, 0); /* SCLK */
10074 + atmel_ac97c0_pclk.dev = &pdev->dev;
10076 + platform_device_add(pdev);
10079 +err_add_resources:
10080 + platform_device_put(pdev);
10084 +/* --------------------------------------------------------------------
10086 + * -------------------------------------------------------------------- */
10087 +static struct resource abdac0_resource[] __initdata = {
10088 + PBMEM(0xfff02000),
10091 +static struct clk abdac0_pclk = {
10093 + .parent = &pbb_clk,
10094 + .mode = pbb_clk_mode,
10095 + .get_rate = pbb_clk_get_rate,
10098 +static struct clk abdac0_sample_clk = {
10099 + .name = "sample_clk",
10100 + .mode = genclk_mode,
10101 + .get_rate = genclk_get_rate,
10102 + .set_rate = genclk_set_rate,
10103 + .set_parent = genclk_set_parent,
10107 +struct platform_device *__init at32_add_device_abdac(unsigned int id)
10109 + struct platform_device *pdev;
10114 + pdev = platform_device_alloc("abdac", id);
10118 + if (platform_device_add_resources(pdev, abdac0_resource,
10119 + ARRAY_SIZE(abdac0_resource)))
10120 + goto err_add_resources;
10122 + select_peripheral(PB(20), PERIPH_A, 0); /* DATA1 */
10123 + select_peripheral(PB(21), PERIPH_A, 0); /* DATA0 */
10124 + select_peripheral(PB(22), PERIPH_A, 0); /* DATAN1 */
10125 + select_peripheral(PB(23), PERIPH_A, 0); /* DATAN0 */
10127 + abdac0_pclk.dev = &pdev->dev;
10128 + abdac0_sample_clk.dev = &pdev->dev;
10130 + platform_device_add(pdev);
10133 +err_add_resources:
10134 + platform_device_put(pdev);
10138 +/* --------------------------------------------------------------------
10140 + * -------------------------------------------------------------------- */
10141 +static struct clk gclk0 = {
10143 + .mode = genclk_mode,
10144 + .get_rate = genclk_get_rate,
10145 + .set_rate = genclk_set_rate,
10146 + .set_parent = genclk_set_parent,
10149 +static struct clk gclk1 = {
10151 + .mode = genclk_mode,
10152 + .get_rate = genclk_get_rate,
10153 + .set_rate = genclk_set_rate,
10154 + .set_parent = genclk_set_parent,
10157 +static struct clk gclk2 = {
10159 + .mode = genclk_mode,
10160 + .get_rate = genclk_get_rate,
10161 + .set_rate = genclk_set_rate,
10162 + .set_parent = genclk_set_parent,
10165 +static struct clk gclk3 = {
10167 + .mode = genclk_mode,
10168 + .get_rate = genclk_get_rate,
10169 + .set_rate = genclk_set_rate,
10170 + .set_parent = genclk_set_parent,
10173 +static struct clk gclk4 = {
10175 + .mode = genclk_mode,
10176 + .get_rate = genclk_get_rate,
10177 + .set_rate = genclk_set_rate,
10178 + .set_parent = genclk_set_parent,
10182 +struct clk *at32_clock_list[] = {
10193 + &at32_intc0_pclk,
10208 + &at32_tcb0_t0_clk,
10209 + &at32_tcb1_t0_clk,
10210 + &atmel_psif0_pclk,
10211 + &atmel_psif1_pclk,
10212 + &atmel_usart0_usart,
10213 + &atmel_usart1_usart,
10214 + &atmel_usart2_usart,
10215 + &atmel_usart3_usart,
10217 +#if defined(CONFIG_CPU_AT32AP7000)
10223 + &atmel_spi0_spi_clk,
10224 + &atmel_spi1_spi_clk,
10225 + &atmel_twi0_pclk,
10226 + &atmel_mci0_pclk,
10227 +#if defined(CONFIG_CPU_AT32AP7000) || defined(CONFIG_CPU_AT32AP7002)
10228 + &atmel_lcdfb0_hck1,
10229 + &atmel_lcdfb0_pixclk,
10236 + &atmel_ac97c0_pclk,
10238 + &abdac0_sample_clk,
10245 +unsigned int at32_nr_clocks = ARRAY_SIZE(at32_clock_list);
10247 +void __init at32_portmux_init(void)
10249 + at32_init_pio(&pio0_device);
10250 + at32_init_pio(&pio1_device);
10251 + at32_init_pio(&pio2_device);
10252 + at32_init_pio(&pio3_device);
10253 + at32_init_pio(&pio4_device);
10256 +void __init at32_clock_init(void)
10258 + u32 cpu_mask = 0, hsb_mask = 0, pba_mask = 0, pbb_mask = 0;
10261 + if (pm_readl(MCCTRL) & PM_BIT(PLLSEL)) {
10262 + main_clock = &pll0;
10263 + cpu_clk.parent = &pll0;
10265 + main_clock = &osc0;
10266 + cpu_clk.parent = &osc0;
10269 + if (pm_readl(PLL0) & PM_BIT(PLLOSC))
10270 + pll0.parent = &osc1;
10271 + if (pm_readl(PLL1) & PM_BIT(PLLOSC))
10272 + pll1.parent = &osc1;
10274 + genclk_init_parent(&gclk0);
10275 + genclk_init_parent(&gclk1);
10276 + genclk_init_parent(&gclk2);
10277 + genclk_init_parent(&gclk3);
10278 + genclk_init_parent(&gclk4);
10279 +#if defined(CONFIG_CPU_AT32AP7000) || defined(CONFIG_CPU_AT32AP7002)
10280 + genclk_init_parent(&atmel_lcdfb0_pixclk);
10282 + genclk_init_parent(&abdac0_sample_clk);
10285 + * Turn on all clocks that have at least one user already, and
10286 + * turn off everything else. We only do this for module
10287 + * clocks, and even though it isn't particularly pretty to
10288 + * check the address of the mode function, it should do the
10291 + for (i = 0; i < ARRAY_SIZE(at32_clock_list); i++) {
10292 + struct clk *clk = at32_clock_list[i];
10294 + if (clk->users == 0)
10297 + if (clk->mode == &cpu_clk_mode)
10298 + cpu_mask |= 1 << clk->index;
10299 + else if (clk->mode == &hsb_clk_mode)
10300 + hsb_mask |= 1 << clk->index;
10301 + else if (clk->mode == &pba_clk_mode)
10302 + pba_mask |= 1 << clk->index;
10303 + else if (clk->mode == &pbb_clk_mode)
10304 + pbb_mask |= 1 << clk->index;
10307 + pm_writel(CPU_MASK, cpu_mask);
10308 + pm_writel(HSB_MASK, hsb_mask);
10309 + pm_writel(PBA_MASK, pba_mask);
10310 + pm_writel(PBB_MASK, pbb_mask);
10312 --- a/arch/avr32/mach-at32ap/extint.c
10313 +++ b/arch/avr32/mach-at32ap/extint.c
10314 @@ -26,16 +26,10 @@
10315 #define EIC_MODE 0x0014
10316 #define EIC_EDGE 0x0018
10317 #define EIC_LEVEL 0x001c
10318 -#define EIC_TEST 0x0020
10319 #define EIC_NMIC 0x0024
10321 -/* Bitfields in TEST */
10322 -#define EIC_TESTEN_OFFSET 31
10323 -#define EIC_TESTEN_SIZE 1
10325 /* Bitfields in NMIC */
10326 -#define EIC_EN_OFFSET 0
10327 -#define EIC_EN_SIZE 1
10328 +#define EIC_NMIC_ENABLE (1 << 0)
10330 /* Bit manipulation macros */
10331 #define EIC_BIT(name) \
10333 unsigned int first_irq;
10336 +static struct eic *nmi_eic;
10337 +static bool nmi_enabled;
10339 static void eic_ack_irq(unsigned int irq)
10341 struct eic *eic = get_irq_chip_data(irq);
10342 @@ -133,8 +130,11 @@
10343 eic_writel(eic, EDGE, edge);
10344 eic_writel(eic, LEVEL, level);
10346 - if (flow_type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH))
10347 + if (flow_type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH)) {
10348 flow_type |= IRQ_LEVEL;
10349 + __set_irq_handler_unlocked(irq, handle_level_irq);
10351 + __set_irq_handler_unlocked(irq, handle_edge_irq);
10352 desc->status &= ~(IRQ_TYPE_SENSE_MASK | IRQ_LEVEL);
10353 desc->status |= flow_type;
10355 @@ -154,9 +154,8 @@
10356 static void demux_eic_irq(unsigned int irq, struct irq_desc *desc)
10358 struct eic *eic = desc->handler_data;
10359 - struct irq_desc *ext_desc;
10360 unsigned long status, pending;
10361 - unsigned int i, ext_irq;
10364 status = eic_readl(eic, ISR);
10365 pending = status & eic_readl(eic, IMR);
10366 @@ -165,15 +164,28 @@
10367 i = fls(pending) - 1;
10368 pending &= ~(1 << i);
10370 - ext_irq = i + eic->first_irq;
10371 - ext_desc = irq_desc + ext_irq;
10372 - if (ext_desc->status & IRQ_LEVEL)
10373 - handle_level_irq(ext_irq, ext_desc);
10375 - handle_edge_irq(ext_irq, ext_desc);
10376 + generic_handle_irq(i + eic->first_irq);
10380 +int nmi_enable(void)
10382 + nmi_enabled = true;
10385 + eic_writel(nmi_eic, NMIC, EIC_NMIC_ENABLE);
10390 +void nmi_disable(void)
10393 + eic_writel(nmi_eic, NMIC, 0);
10395 + nmi_enabled = false;
10398 static int __init eic_probe(struct platform_device *pdev)
10401 @@ -214,14 +226,13 @@
10402 pattern = eic_readl(eic, MODE);
10403 nr_irqs = fls(pattern);
10405 - /* Trigger on falling edge unless overridden by driver */
10406 - eic_writel(eic, MODE, 0UL);
10407 + /* Trigger on low level unless overridden by driver */
10408 eic_writel(eic, EDGE, 0UL);
10409 + eic_writel(eic, LEVEL, 0UL);
10411 eic->chip = &eic_chip;
10413 for (i = 0; i < nr_irqs; i++) {
10414 - /* NOTE the handler we set here is ignored by the demux */
10415 set_irq_chip_and_handler(eic->first_irq + i, &eic_chip,
10417 set_irq_chip_data(eic->first_irq + i, eic);
10418 @@ -230,6 +241,16 @@
10419 set_irq_chained_handler(int_irq, demux_eic_irq);
10420 set_irq_data(int_irq, eic);
10422 + if (pdev->id == 0) {
10426 + * Someone tried to enable NMI before we were
10427 + * ready. Do it now.
10432 dev_info(&pdev->dev,
10433 "External Interrupt Controller at 0x%p, IRQ %u\n",
10434 eic->regs, int_irq);
10436 +++ b/arch/avr32/mach-at32ap/gpio-dev.c
10439 + * GPIO /dev and configfs interface
10441 + * Copyright (C) 2006-2007 Atmel Corporation
10443 + * This program is free software; you can redistribute it and/or modify
10444 + * it under the terms of the GNU General Public License version 2 as
10445 + * published by the Free Software Foundation.
10447 +#include <linux/kernel.h>
10448 +#include <linux/configfs.h>
10449 +#include <linux/cdev.h>
10450 +#include <linux/device.h>
10451 +#include <linux/fs.h>
10452 +#include <linux/interrupt.h>
10453 +#include <linux/module.h>
10454 +#include <linux/poll.h>
10455 +#include <linux/uaccess.h>
10456 +#include <linux/wait.h>
10458 +#include <asm/gpio.h>
10459 +#include <asm/arch/portmux.h>
10461 +#define GPIO_DEV_MAX 8
10463 +static struct class *gpio_dev_class;
10464 +static dev_t gpio_devt;
10466 +struct gpio_item {
10475 + /* Pin state last time we read it (for blocking reads) */
10479 + wait_queue_head_t change_wq;
10480 + struct fasync_struct *async_queue;
10483 + struct class_device *gpio_dev;
10484 + struct cdev char_dev;
10485 + struct config_item item;
10488 +struct gpio_attribute {
10489 + struct configfs_attribute attr;
10490 + ssize_t (*show)(struct gpio_item *, char *);
10491 + ssize_t (*store)(struct gpio_item *, const char *, size_t);
10494 +static irqreturn_t gpio_dev_interrupt(int irq, void *dev_id)
10496 + struct gpio_item *gpio = dev_id;
10497 + u32 old_state, new_state;
10499 + old_state = gpio->pin_state;
10500 + new_state = at32_gpio_get_value_multiple(gpio->port, gpio->pin_mask);
10501 + gpio->pin_state = new_state;
10503 + if (new_state != old_state) {
10504 + gpio->changed = 1;
10505 + wake_up_interruptible(&gpio->change_wq);
10507 + if (gpio->async_queue)
10508 + kill_fasync(&gpio->async_queue, SIGIO, POLL_IN);
10511 + return IRQ_HANDLED;
10514 +static int gpio_dev_open(struct inode *inode, struct file *file)
10516 + struct gpio_item *gpio = container_of(inode->i_cdev,
10517 + struct gpio_item,
10519 + unsigned int irq;
10523 + nonseekable_open(inode, file);
10524 + config_item_get(&gpio->item);
10525 + file->private_data = gpio;
10527 + gpio->pin_state = at32_gpio_get_value_multiple(gpio->port,
10529 + gpio->changed = 1;
10531 + for (i = 0; i < 32; i++) {
10532 + if (gpio->pin_mask & (1 << i)) {
10533 + irq = gpio_to_irq(32 * gpio->port + i);
10534 + ret = request_irq(irq, gpio_dev_interrupt, 0,
10535 + "gpio-dev", gpio);
10545 + if (gpio->pin_mask & (1 << i)) {
10546 + irq = gpio_to_irq(32 * gpio->port + i);
10547 + free_irq(irq, gpio);
10551 + config_item_put(&gpio->item);
10556 +static int gpio_dev_fasync(int fd, struct file *file, int mode)
10558 + struct gpio_item *gpio = file->private_data;
10560 + return fasync_helper(fd, file, mode, &gpio->async_queue);
10563 +static int gpio_dev_release(struct inode *inode, struct file *file)
10565 + struct gpio_item *gpio = file->private_data;
10566 + unsigned int irq;
10569 + gpio_dev_fasync(-1, file, 0);
10571 + for (i = 0; i < 32; i++) {
10572 + if (gpio->pin_mask & (1 << i)) {
10573 + irq = gpio_to_irq(32 * gpio->port + i);
10574 + free_irq(irq, gpio);
10578 + config_item_put(&gpio->item);
10583 +static unsigned int gpio_dev_poll(struct file *file, poll_table *wait)
10585 + struct gpio_item *gpio = file->private_data;
10586 + unsigned int mask = 0;
10588 + poll_wait(file, &gpio->change_wq, wait);
10589 + if (gpio->changed)
10590 + mask |= POLLIN | POLLRDNORM;
10595 +static ssize_t gpio_dev_read(struct file *file, char __user *buf,
10596 + size_t count, loff_t *offset)
10598 + struct gpio_item *gpio = file->private_data;
10601 + spin_lock_irq(&gpio->lock);
10602 + while (!gpio->changed) {
10603 + spin_unlock_irq(&gpio->lock);
10605 + if (file->f_flags & O_NONBLOCK)
10608 + if (wait_event_interruptible(gpio->change_wq, gpio->changed))
10609 + return -ERESTARTSYS;
10611 + spin_lock_irq(&gpio->lock);
10614 + gpio->changed = 0;
10615 + value = at32_gpio_get_value_multiple(gpio->port, gpio->pin_mask);
10617 + spin_unlock_irq(&gpio->lock);
10619 + count = min(count, (size_t)4);
10620 + if (copy_to_user(buf, &value, count))
10626 +static ssize_t gpio_dev_write(struct file *file, const char __user *buf,
10627 + size_t count, loff_t *offset)
10629 + struct gpio_item *gpio = file->private_data;
10633 + count = min(count, (size_t)4);
10634 + if (copy_from_user(&value, buf, count))
10637 + /* Assuming big endian */
10638 + mask <<= (4 - count) * 8;
10639 + mask &= gpio->pin_mask;
10641 + at32_gpio_set_value_multiple(gpio->port, value, mask);
10646 +static struct file_operations gpio_dev_fops = {
10647 + .owner = THIS_MODULE,
10648 + .llseek = no_llseek,
10649 + .open = gpio_dev_open,
10650 + .release = gpio_dev_release,
10651 + .fasync = gpio_dev_fasync,
10652 + .poll = gpio_dev_poll,
10653 + .read = gpio_dev_read,
10654 + .write = gpio_dev_write,
10657 +static struct gpio_item *to_gpio_item(struct config_item *item)
10659 + return item ? container_of(item, struct gpio_item, item) : NULL;
10662 +static ssize_t gpio_show_gpio_id(struct gpio_item *gpio, char *page)
10664 + return sprintf(page, "%d\n", gpio->port);
10667 +static ssize_t gpio_store_gpio_id(struct gpio_item *gpio,
10668 + const char *page, size_t count)
10670 + unsigned long id;
10671 + char *p = (char *)page;
10672 + ssize_t ret = -EINVAL;
10674 + id = simple_strtoul(p, &p, 0);
10675 + if (!p || (*p && (*p != '\n')))
10678 + /* Switching PIO is not allowed when live... */
10679 + spin_lock(&gpio->lock);
10680 + if (!gpio->enabled) {
10682 + if (at32_gpio_port_is_valid(id)) {
10687 + spin_unlock(&gpio->lock);
10692 +static ssize_t gpio_show_pin_mask(struct gpio_item *gpio, char *page)
10694 + return sprintf(page, "0x%08x\n", gpio->pin_mask);
10697 +static ssize_t gpio_store_pin_mask(struct gpio_item *gpio,
10698 + const char *page, size_t count)
10701 + char *p = (char *)page;
10702 + ssize_t ret = -EINVAL;
10704 + new_mask = simple_strtoul(p, &p, 0);
10705 + if (!p || (*p && (*p != '\n')))
10708 + /* Can't update the pin mask while live. */
10709 + spin_lock(&gpio->lock);
10710 + if (!gpio->enabled) {
10711 + gpio->oe_mask &= new_mask;
10712 + gpio->pin_mask = new_mask;
10715 + spin_unlock(&gpio->lock);
10720 +static ssize_t gpio_show_oe_mask(struct gpio_item *gpio, char *page)
10722 + return sprintf(page, "0x%08x\n", gpio->oe_mask);
10725 +static ssize_t gpio_store_oe_mask(struct gpio_item *gpio,
10726 + const char *page, size_t count)
10729 + char *p = (char *)page;
10730 + ssize_t ret = -EINVAL;
10732 + mask = simple_strtoul(p, &p, 0);
10733 + if (!p || (*p && (*p != '\n')))
10736 + spin_lock(&gpio->lock);
10737 + if (!gpio->enabled) {
10738 + gpio->oe_mask = mask & gpio->pin_mask;
10741 + spin_unlock(&gpio->lock);
10746 +static ssize_t gpio_show_enabled(struct gpio_item *gpio, char *page)
10748 + return sprintf(page, "%d\n", gpio->enabled);
10751 +static ssize_t gpio_store_enabled(struct gpio_item *gpio,
10752 + const char *page, size_t count)
10754 + char *p = (char *)page;
10758 + enabled = simple_strtoul(p, &p, 0);
10759 + if (!p || (*p && (*p != '\n')))
10762 + /* make it a boolean value */
10763 + enabled = !!enabled;
10765 + if (gpio->enabled == enabled)
10766 + /* No change; do nothing. */
10769 + BUG_ON(gpio->id >= GPIO_DEV_MAX);
10772 + class_device_unregister(gpio->gpio_dev);
10773 + cdev_del(&gpio->char_dev);
10774 + at32_deselect_pins(gpio->port, gpio->pin_mask);
10775 + gpio->initialized = 0;
10777 + if (gpio->port < 0 || !gpio->pin_mask)
10781 + /* Disallow any updates to gpio_id or pin_mask */
10782 + spin_lock(&gpio->lock);
10783 + gpio->enabled = enabled;
10784 + spin_unlock(&gpio->lock);
10789 + /* Now, try to allocate the pins */
10790 + ret = at32_select_gpio_pins(gpio->port, gpio->pin_mask, gpio->oe_mask);
10792 + goto err_alloc_pins;
10794 + gpio->initialized = 1;
10796 + cdev_init(&gpio->char_dev, &gpio_dev_fops);
10797 + gpio->char_dev.owner = THIS_MODULE;
10798 + ret = cdev_add(&gpio->char_dev, MKDEV(MAJOR(gpio_devt), gpio->id), 1);
10800 + goto err_cdev_add;
10801 + gpio->gpio_dev = class_device_create(gpio_dev_class, NULL,
10802 + MKDEV(MAJOR(gpio_devt), gpio->id),
10804 + "gpio%d", gpio->id);
10805 + if (IS_ERR(gpio->gpio_dev)) {
10806 + printk(KERN_ERR "failed to create gpio%d\n", gpio->id);
10807 + ret = PTR_ERR(gpio->gpio_dev);
10808 + goto err_class_dev;
10811 + printk(KERN_INFO "created gpio%d (port%d/0x%08x) as (%d:%d)\n",
10812 + gpio->id, gpio->port, gpio->pin_mask,
10813 + MAJOR(gpio->gpio_dev->devt), MINOR(gpio->gpio_dev->devt));
10818 + cdev_del(&gpio->char_dev);
10820 + at32_deselect_pins(gpio->port, gpio->pin_mask);
10821 + gpio->initialized = 0;
10823 + spin_lock(&gpio->lock);
10824 + gpio->enabled = 0;
10825 + spin_unlock(&gpio->lock);
10830 +static struct gpio_attribute gpio_item_attr_gpio_id = {
10832 + .ca_owner = THIS_MODULE,
10833 + .ca_name = "gpio_id",
10834 + .ca_mode = S_IRUGO | S_IWUSR,
10836 + .show = gpio_show_gpio_id,
10837 + .store = gpio_store_gpio_id,
10839 +static struct gpio_attribute gpio_item_attr_pin_mask = {
10841 + .ca_owner = THIS_MODULE,
10842 + .ca_name = "pin_mask",
10843 + .ca_mode = S_IRUGO | S_IWUSR,
10845 + .show = gpio_show_pin_mask,
10846 + .store = gpio_store_pin_mask,
10848 +static struct gpio_attribute gpio_item_attr_oe_mask = {
10850 + .ca_owner = THIS_MODULE,
10851 + .ca_name = "oe_mask",
10852 + .ca_mode = S_IRUGO | S_IWUSR,
10854 + .show = gpio_show_oe_mask,
10855 + .store = gpio_store_oe_mask,
10857 +static struct gpio_attribute gpio_item_attr_enabled = {
10859 + .ca_owner = THIS_MODULE,
10860 + .ca_name = "enabled",
10861 + .ca_mode = S_IRUGO | S_IWUSR,
10863 + .show = gpio_show_enabled,
10864 + .store = gpio_store_enabled,
10867 +static struct configfs_attribute *gpio_item_attrs[] = {
10868 + &gpio_item_attr_gpio_id.attr,
10869 + &gpio_item_attr_pin_mask.attr,
10870 + &gpio_item_attr_oe_mask.attr,
10871 + &gpio_item_attr_enabled.attr,
10875 +static ssize_t gpio_show_attr(struct config_item *item,
10876 + struct configfs_attribute *attr,
10879 + struct gpio_item *gpio_item = to_gpio_item(item);
10880 + struct gpio_attribute *gpio_attr
10881 + = container_of(attr, struct gpio_attribute, attr);
10884 + if (gpio_attr->show)
10885 + ret = gpio_attr->show(gpio_item, page);
10889 +static ssize_t gpio_store_attr(struct config_item *item,
10890 + struct configfs_attribute *attr,
10891 + const char *page, size_t count)
10893 + struct gpio_item *gpio_item = to_gpio_item(item);
10894 + struct gpio_attribute *gpio_attr
10895 + = container_of(attr, struct gpio_attribute, attr);
10896 + ssize_t ret = -EINVAL;
10898 + if (gpio_attr->store)
10899 + ret = gpio_attr->store(gpio_item, page, count);
10903 +static void gpio_release(struct config_item *item)
10905 + kfree(to_gpio_item(item));
10908 +static struct configfs_item_operations gpio_item_ops = {
10909 + .release = gpio_release,
10910 + .show_attribute = gpio_show_attr,
10911 + .store_attribute = gpio_store_attr,
10914 +static struct config_item_type gpio_item_type = {
10915 + .ct_item_ops = &gpio_item_ops,
10916 + .ct_attrs = gpio_item_attrs,
10917 + .ct_owner = THIS_MODULE,
10920 +static struct config_item *gpio_make_item(struct config_group *group,
10921 + const char *name)
10923 + static int next_id;
10924 + struct gpio_item *gpio;
10926 + if (next_id >= GPIO_DEV_MAX)
10929 + gpio = kzalloc(sizeof(struct gpio_item), GFP_KERNEL);
10933 + gpio->id = next_id++;
10934 + config_item_init_type_name(&gpio->item, name, &gpio_item_type);
10935 + spin_lock_init(&gpio->lock);
10936 + init_waitqueue_head(&gpio->change_wq);
10938 + return &gpio->item;
10941 +static void gpio_drop_item(struct config_group *group,
10942 + struct config_item *item)
10944 + struct gpio_item *gpio = to_gpio_item(item);
10946 + spin_lock(&gpio->lock);
10947 + if (gpio->enabled) {
10948 + class_device_unregister(gpio->gpio_dev);
10949 + cdev_del(&gpio->char_dev);
10952 + if (gpio->initialized) {
10953 + at32_deselect_pins(gpio->port, gpio->pin_mask);
10954 + gpio->initialized = 0;
10955 + gpio->enabled = 0;
10957 + spin_unlock(&gpio->lock);
10960 +static struct configfs_group_operations gpio_group_ops = {
10961 + .make_item = gpio_make_item,
10962 + .drop_item = gpio_drop_item,
10965 +static struct config_item_type gpio_group_type = {
10966 + .ct_group_ops = &gpio_group_ops,
10967 + .ct_owner = THIS_MODULE,
10970 +static struct configfs_subsystem gpio_subsys = {
10973 + .ci_namebuf = "gpio",
10974 + .ci_type = &gpio_group_type,
10979 +static int __init gpio_dev_init(void)
10983 + gpio_dev_class = class_create(THIS_MODULE, "gpio-dev");
10984 + if (IS_ERR(gpio_dev_class)) {
10985 + err = PTR_ERR(gpio_dev_class);
10986 + goto err_class_create;
10989 + err = alloc_chrdev_region(&gpio_devt, 0, GPIO_DEV_MAX, "gpio");
10991 + goto err_alloc_chrdev;
10993 + /* Configfs initialization */
10994 + config_group_init(&gpio_subsys.su_group);
10995 + mutex_init(&gpio_subsys.su_mutex);
10996 + err = configfs_register_subsystem(&gpio_subsys);
10998 + goto err_register_subsys;
11002 +err_register_subsys:
11003 + unregister_chrdev_region(gpio_devt, GPIO_DEV_MAX);
11005 + class_destroy(gpio_dev_class);
11007 + printk(KERN_WARNING "Failed to initialize gpio /dev interface\n");
11010 +late_initcall(gpio_dev_init);
11011 --- a/arch/avr32/mach-at32ap/intc.c
11012 +++ b/arch/avr32/mach-at32ap/intc.c
11014 #include <linux/irq.h>
11015 #include <linux/platform_device.h>
11017 -#include <asm/intc.h>
11018 #include <asm/io.h>
11021 --- a/arch/avr32/mach-at32ap/Kconfig
11022 +++ b/arch/avr32/mach-at32ap/Kconfig
11024 menu "Atmel AVR32 AP options"
11027 - prompt "AT32AP7000 static memory bus width"
11028 - depends on CPU_AT32AP7000
11029 - default AP7000_16_BIT_SMC
11030 + prompt "AT32AP700x static memory bus width"
11031 + depends on CPU_AT32AP700X
11032 + default AP700X_16_BIT_SMC
11034 Define the width of the AP7000 external static memory interface.
11035 This is used to determine how to mangle the address and/or data
11036 @@ -15,17 +15,24 @@
11037 width for all chip selects, excluding the flash (which is using
11038 raw access and is thus not affected by any of this.)
11040 -config AP7000_32_BIT_SMC
11041 +config AP700X_32_BIT_SMC
11044 -config AP7000_16_BIT_SMC
11045 +config AP700X_16_BIT_SMC
11048 -config AP7000_8_BIT_SMC
11049 +config AP700X_8_BIT_SMC
11055 + bool "GPIO /dev interface"
11056 + select CONFIGFS_FS
11059 + Say `Y' to enable a /dev interface to the GPIO pins.
11063 endif # PLATFORM_AT32AP
11064 --- a/arch/avr32/mach-at32ap/Makefile
11065 +++ b/arch/avr32/mach-at32ap/Makefile
11067 obj-y += at32ap.o clock.o intc.o extint.o pio.o hsmc.o
11068 -obj-$(CONFIG_CPU_AT32AP7000) += at32ap7000.o
11069 -obj-$(CONFIG_CPU_AT32AP7000) += time-tc.o
11070 +obj-$(CONFIG_CPU_AT32AP700X) += at32ap700x.o pm-at32ap700x.o
11071 obj-$(CONFIG_CPU_FREQ_AT32AP) += cpufreq.o
11072 +obj-$(CONFIG_GPIO_DEV) += gpio-dev.o
11073 --- a/arch/avr32/mach-at32ap/pio.c
11074 +++ b/arch/avr32/mach-at32ap/pio.c
11075 @@ -162,6 +162,82 @@
11079 +#ifdef CONFIG_GPIO_DEV
11081 +/* Gang allocators and accessors; used by the GPIO /dev driver */
11082 +int at32_gpio_port_is_valid(unsigned int port)
11084 + return port < MAX_NR_PIO_DEVICES && pio_dev[port].regs != NULL;
11087 +int at32_select_gpio_pins(unsigned int port, u32 pins, u32 oe_mask)
11089 + struct pio_device *pio;
11092 + pio = &pio_dev[port];
11093 + BUG_ON(port > ARRAY_SIZE(pio_dev) || !pio->regs || (oe_mask & ~pins));
11095 + /* Try to allocate the pins */
11097 + old = pio->pinmux_mask;
11101 + new = old | pins;
11102 + } while (cmpxchg(&pio->pinmux_mask, old, new) != old);
11104 + /* That went well, now configure the port */
11105 + pio_writel(pio, OER, oe_mask);
11106 + pio_writel(pio, PER, pins);
11111 +void at32_deselect_pins(unsigned int port, u32 pins)
11113 + struct pio_device *pio;
11116 + pio = &pio_dev[port];
11117 + BUG_ON(port > ARRAY_SIZE(pio_dev) || !pio->regs);
11119 + /* Return to a "safe" mux configuration */
11120 + pio_writel(pio, PUER, pins);
11121 + pio_writel(pio, ODR, pins);
11123 + /* Deallocate the pins */
11125 + old = pio->pinmux_mask;
11126 + new = old & ~pins;
11127 + } while (cmpxchg(&pio->pinmux_mask, old, new) != old);
11130 +u32 at32_gpio_get_value_multiple(unsigned int port, u32 pins)
11132 + struct pio_device *pio;
11134 + pio = &pio_dev[port];
11135 + BUG_ON(port > ARRAY_SIZE(pio_dev) || !pio->regs);
11137 + return pio_readl(pio, PDSR) & pins;
11140 +void at32_gpio_set_value_multiple(unsigned int port, u32 value, u32 mask)
11142 + struct pio_device *pio;
11144 + pio = &pio_dev[port];
11145 + BUG_ON(port > ARRAY_SIZE(pio_dev) || !pio->regs);
11147 + /* No atomic updates for now... */
11148 + pio_writel(pio, CODR, ~value & mask);
11149 + pio_writel(pio, SODR, value & mask);
11152 +#endif /* CONFIG_GPIO_DEV */
11155 /*--------------------------------------------------------------------------*/
11159 +++ b/arch/avr32/mach-at32ap/pm-at32ap700x.S
11162 + * Low-level Power Management code.
11164 + * Copyright (C) 2008 Atmel Corporation
11166 + * This program is free software; you can redistribute it and/or modify
11167 + * it under the terms of the GNU General Public License version 2 as
11168 + * published by the Free Software Foundation.
11170 +#include <asm/asm.h>
11171 +#include <asm/asm-offsets.h>
11172 +#include <asm/thread_info.h>
11173 +#include <asm/arch/pm.h>
11175 + .section .bss, "wa", @nobits
11176 + .global disable_idle_sleep
11177 + .type disable_idle_sleep, @object
11178 +disable_idle_sleep:
11180 + .size disable_idle_sleep, . - disable_idle_sleep
11182 + /* Keep this close to the irq handlers */
11183 + .section .irq.text, "ax", @progbits
11186 + * void cpu_enter_idle(void)
11188 + * Put the CPU into "idle" mode, in which it will consume
11189 + * significantly less power.
11191 + * If an interrupt comes along in the window between
11192 + * unmask_interrupts and the sleep instruction below, the
11193 + * interrupt code will adjust the return address so that we
11194 + * never execute the sleep instruction. This is required
11195 + * because the AP7000 doesn't unmask interrupts when entering
11196 + * sleep modes; later CPUs may not need this workaround.
11198 + .global cpu_enter_idle
11199 + .type cpu_enter_idle, @function
11202 + get_thread_info r8
11203 + ld.w r9, r8[TI_flags]
11204 + bld r9, TIF_NEED_RESCHED
11205 + brcs .Lret_from_sleep
11206 + sbr r9, TIF_CPU_GOING_TO_SLEEP
11207 + st.w r8[TI_flags], r9
11208 + unmask_interrupts
11209 + sleep CPU_SLEEP_IDLE
11210 + .size cpu_idle_sleep, . - cpu_idle_sleep
11213 + * Common return path for PM functions that don't run from
11216 + .global cpu_idle_skip_sleep
11217 + .type cpu_idle_skip_sleep, @function
11218 +cpu_idle_skip_sleep:
11220 + ld.w r9, r8[TI_flags]
11221 + cbr r9, TIF_CPU_GOING_TO_SLEEP
11222 + st.w r8[TI_flags], r9
11224 + unmask_interrupts
11226 + .size cpu_idle_skip_sleep, . - cpu_idle_skip_sleep
11227 --- a/arch/avr32/mach-at32ap/time-tc.c
11231 - * Copyright (C) 2004-2007 Atmel Corporation
11233 - * Based on MIPS implementation arch/mips/kernel/time.c
11234 - * Copyright 2001 MontaVista Software Inc.
11236 - * This program is free software; you can redistribute it and/or modify
11237 - * it under the terms of the GNU General Public License version 2 as
11238 - * published by the Free Software Foundation.
11241 -#include <linux/clk.h>
11242 -#include <linux/clocksource.h>
11243 -#include <linux/time.h>
11244 -#include <linux/module.h>
11245 -#include <linux/interrupt.h>
11246 -#include <linux/irq.h>
11247 -#include <linux/kernel_stat.h>
11248 -#include <linux/errno.h>
11249 -#include <linux/init.h>
11250 -#include <linux/profile.h>
11251 -#include <linux/sysdev.h>
11252 -#include <linux/err.h>
11254 -#include <asm/div64.h>
11255 -#include <asm/sysreg.h>
11256 -#include <asm/io.h>
11257 -#include <asm/sections.h>
11259 -#include <asm/arch/time.h>
11261 -/* how many counter cycles in a jiffy? */
11262 -static u32 cycles_per_jiffy;
11264 -/* the count value for the next timer interrupt */
11265 -static u32 expirelo;
11267 -/* the I/O registers of the TC module */
11268 -static void __iomem *ioregs;
11270 -cycle_t read_cycle_count(void)
11272 - return (cycle_t)timer_read(ioregs, 0, CV);
11275 -struct clocksource clocksource_avr32 = {
11278 - .read = read_cycle_count,
11279 - .mask = CLOCKSOURCE_MASK(16),
11281 - .flags = CLOCK_SOURCE_IS_CONTINUOUS,
11284 -static void avr32_timer_ack(void)
11286 - u16 count = expirelo;
11288 - /* Ack this timer interrupt and set the next one, use a u16
11289 - * variable so it will wrap around correctly */
11290 - count += cycles_per_jiffy;
11291 - expirelo = count;
11292 - timer_write(ioregs, 0, RC, expirelo);
11294 - /* Check to see if we have missed any timer interrupts */
11295 - count = timer_read(ioregs, 0, CV);
11296 - if ((count - expirelo) < 0x7fff) {
11297 - expirelo = count + cycles_per_jiffy;
11298 - timer_write(ioregs, 0, RC, expirelo);
11302 -u32 avr32_hpt_read(void)
11304 - return timer_read(ioregs, 0, CV);
11307 -static int avr32_timer_calc_div_and_set_jiffies(struct clk *pclk)
11309 - unsigned int cycles_max = (clocksource_avr32.mask + 1) / 2;
11310 - unsigned int divs[] = { 4, 8, 16, 32 };
11311 - int divs_size = ARRAY_SIZE(divs);
11313 - unsigned long count_hz;
11314 - unsigned long shift;
11315 - unsigned long mult;
11316 - int clock_div = -1;
11319 - shift = clocksource_avr32.shift;
11322 - count_hz = clk_get_rate(pclk) / divs[i];
11323 - mult = clocksource_hz2mult(count_hz, shift);
11324 - clocksource_avr32.mult = mult;
11329 - do_div(tmp, mult);
11331 - cycles_per_jiffy = tmp;
11332 - } while (cycles_per_jiffy > cycles_max && ++i < divs_size);
11334 - clock_div = i + 1;
11336 - if (clock_div > divs_size) {
11337 - pr_debug("timer: could not calculate clock divider\n");
11341 - /* Set the clock divider */
11342 - timer_write(ioregs, 0, CMR, TIMER_BF(CMR_TCCLKS, clock_div));
11347 -int avr32_hpt_init(unsigned int count)
11349 - struct resource *regs;
11350 - struct clk *pclk;
11356 - irq = platform_get_irq(&at32_systc0_device, 0);
11358 - pr_debug("timer: could not get irq\n");
11362 - pclk = clk_get(&at32_systc0_device.dev, "pclk");
11363 - if (IS_ERR(pclk)) {
11364 - pr_debug("timer: could not get clk: %ld\n", PTR_ERR(pclk));
11367 - clk_enable(pclk);
11369 - regs = platform_get_resource(&at32_systc0_device, IORESOURCE_MEM, 0);
11371 - pr_debug("timer: could not get resource\n");
11372 - goto out_error_clk;
11375 - ioregs = ioremap(regs->start, regs->end - regs->start + 1);
11377 - pr_debug("timer: could not get ioregs\n");
11378 - goto out_error_clk;
11381 - ret = avr32_timer_calc_div_and_set_jiffies(pclk);
11383 - goto out_error_io;
11385 - ret = setup_irq(irq, &timer_irqaction);
11387 - pr_debug("timer: could not request irq %d: %d\n",
11389 - goto out_error_io;
11392 - expirelo = (timer_read(ioregs, 0, CV) / cycles_per_jiffy + 1)
11393 - * cycles_per_jiffy;
11395 - /* Enable clock and interrupts on RC compare */
11396 - timer_write(ioregs, 0, CCR, TIMER_BIT(CCR_CLKEN));
11397 - timer_write(ioregs, 0, IER, TIMER_BIT(IER_CPCS));
11398 - /* Set cycles to first interrupt */
11399 - timer_write(ioregs, 0, RC, expirelo);
11401 - printk(KERN_INFO "timer: AT32AP system timer/counter at 0x%p irq %d\n",
11414 -int avr32_hpt_start(void)
11416 - timer_write(ioregs, 0, CCR, TIMER_BIT(CCR_SWTRG));
11420 -irqreturn_t timer_interrupt(int irq, void *dev_id)
11422 - unsigned int sr = timer_read(ioregs, 0, SR);
11424 - if (sr & TIMER_BIT(SR_CPCS)) {
11425 - /* ack timer interrupt and try to set next interrupt */
11426 - avr32_timer_ack();
11429 - * Call the generic timer interrupt handler
11431 - write_seqlock(&xtime_lock);
11433 - write_sequnlock(&xtime_lock);
11436 - * In UP mode, we call local_timer_interrupt() to do profiling
11437 - * and process accounting.
11439 - * SMP is not supported yet.
11441 - local_timer_interrupt(irq, dev_id);
11443 - return IRQ_HANDLED;
11448 --- a/arch/avr32/Makefile
11449 +++ b/arch/avr32/Makefile
11451 CFLAGS_MODULE += -mno-relax
11452 LDFLAGS_vmlinux += --relax
11454 -cpuflags-$(CONFIG_CPU_AT32AP7000) += -mcpu=ap7000
11455 +cpuflags-$(CONFIG_PLATFORM_AT32AP) += -march=ap
11457 KBUILD_CFLAGS += $(cpuflags-y)
11458 KBUILD_AFLAGS += $(cpuflags-y)
11460 core-$(CONFIG_LOADER_U_BOOT) += arch/avr32/boot/u-boot/
11461 core-y += arch/avr32/kernel/
11462 core-y += arch/avr32/mm/
11463 +drivers-$(CONFIG_OPROFILE) += arch/avr32/oprofile/
11464 +drivers-y += arch/avr32/drivers/
11465 libs-y += arch/avr32/lib/
11467 archincdir-$(CONFIG_PLATFORM_AT32AP) := arch-at32ap
11468 --- a/arch/avr32/mm/dma-coherent.c
11469 +++ b/arch/avr32/mm/dma-coherent.c
11471 struct page *page, *free, *end;
11474 + /* Following is a work-around (a.k.a. hack) to prevent pages
11475 + * with __GFP_COMP being passed to split_page() which cannot
11476 + * handle them. The real problem is that this flag probably
11477 + * should be 0 on AVR32 as it is not supported on this
11478 + * platform--see CONFIG_HUGETLB_PAGE. */
11479 + gfp &= ~(__GFP_COMP);
11481 size = PAGE_ALIGN(size);
11482 order = get_order(size);
11484 --- a/arch/avr32/mm/fault.c
11485 +++ b/arch/avr32/mm/fault.c
11486 @@ -189,6 +189,8 @@
11488 page = sysreg_read(PTBR);
11489 printk(KERN_ALERT "ptbr = %08lx", page);
11490 + if (address >= TASK_SIZE)
11491 + page = (unsigned long)swapper_pg_dir;
11493 page = ((unsigned long *)page)[address >> 22];
11494 printk(" pgd = %08lx", page);
11495 --- a/arch/avr32/mm/tlb.c
11496 +++ b/arch/avr32/mm/tlb.c
11497 @@ -348,7 +348,7 @@
11501 -static struct seq_operations tlb_ops = {
11502 +static const struct seq_operations tlb_ops = {
11503 .start = tlb_start,
11507 +++ b/arch/avr32/oprofile/Makefile
11509 +obj-$(CONFIG_OPROFILE) += oprofile.o
11511 +oprofile-y := $(addprefix ../../../drivers/oprofile/, \
11512 + oprof.o cpu_buffer.o buffer_sync.o \
11513 + event_buffer.o oprofile_files.o \
11514 + oprofilefs.o oprofile_stats.o \
11516 +oprofile-y += op_model_avr32.o
11518 +++ b/arch/avr32/oprofile/op_model_avr32.c
11521 + * AVR32 Performance Counter Driver
11523 + * Copyright (C) 2005-2007 Atmel Corporation
11525 + * This program is free software; you can redistribute it and/or modify
11526 + * it under the terms of the GNU General Public License version 2 as
11527 + * published by the Free Software Foundation.
11529 + * Author: Ronny Pedersen
11531 +#include <linux/errno.h>
11532 +#include <linux/interrupt.h>
11533 +#include <linux/irq.h>
11534 +#include <linux/oprofile.h>
11535 +#include <linux/sched.h>
11536 +#include <linux/types.h>
11538 +#include <asm/sysreg.h>
11539 +#include <asm/system.h>
11541 +#define AVR32_PERFCTR_IRQ_GROUP 0
11542 +#define AVR32_PERFCTR_IRQ_LINE 1
11544 +enum { PCCNT, PCNT0, PCNT1, NR_counter };
11546 +struct avr32_perf_counter {
11547 + unsigned long enabled;
11548 + unsigned long event;
11549 + unsigned long count;
11550 + unsigned long unit_mask;
11551 + unsigned long kernel;
11552 + unsigned long user;
11558 +static struct avr32_perf_counter counter[NR_counter] = {
11560 + .ie_mask = SYSREG_BIT(IEC),
11561 + .flag_mask = SYSREG_BIT(FC),
11563 + .ie_mask = SYSREG_BIT(IE0),
11564 + .flag_mask = SYSREG_BIT(F0),
11566 + .ie_mask = SYSREG_BIT(IE1),
11567 + .flag_mask = SYSREG_BIT(F1),
11571 +static void avr32_perf_counter_reset(void)
11573 + /* Reset all counter and disable/clear all interrupts */
11574 + sysreg_write(PCCR, (SYSREG_BIT(PCCR_R)
11575 + | SYSREG_BIT(PCCR_C)
11578 + | SYSREG_BIT(F1)));
11581 +static irqreturn_t avr32_perf_counter_interrupt(int irq, void *dev_id)
11583 + struct avr32_perf_counter *ctr = dev_id;
11584 + struct pt_regs *regs;
11587 + if (likely(!(intc_get_pending(AVR32_PERFCTR_IRQ_GROUP)
11588 + & (1 << AVR32_PERFCTR_IRQ_LINE))))
11591 + regs = get_irq_regs();
11592 + pccr = sysreg_read(PCCR);
11594 + /* Clear the interrupt flags we're about to handle */
11595 + sysreg_write(PCCR, pccr);
11598 + if (ctr->enabled && (pccr & ctr->flag_mask)) {
11599 + sysreg_write(PCCNT, -ctr->count);
11600 + oprofile_add_sample(regs, PCCNT);
11604 + if (ctr->enabled && (pccr & ctr->flag_mask)) {
11605 + sysreg_write(PCNT0, -ctr->count);
11606 + oprofile_add_sample(regs, PCNT0);
11610 + if (ctr->enabled && (pccr & ctr->flag_mask)) {
11611 + sysreg_write(PCNT1, -ctr->count);
11612 + oprofile_add_sample(regs, PCNT1);
11615 + return IRQ_HANDLED;
11618 +static int avr32_perf_counter_create_files(struct super_block *sb,
11619 + struct dentry *root)
11621 + struct dentry *dir;
11623 + char filename[4];
11625 + for (i = 0; i < NR_counter; i++) {
11626 + snprintf(filename, sizeof(filename), "%u", i);
11627 + dir = oprofilefs_mkdir(sb, root, filename);
11629 + oprofilefs_create_ulong(sb, dir, "enabled",
11630 + &counter[i].enabled);
11631 + oprofilefs_create_ulong(sb, dir, "event",
11632 + &counter[i].event);
11633 + oprofilefs_create_ulong(sb, dir, "count",
11634 + &counter[i].count);
11636 + /* Dummy entries */
11637 + oprofilefs_create_ulong(sb, dir, "kernel",
11638 + &counter[i].kernel);
11639 + oprofilefs_create_ulong(sb, dir, "user",
11640 + &counter[i].user);
11641 + oprofilefs_create_ulong(sb, dir, "unit_mask",
11642 + &counter[i].unit_mask);
11648 +static int avr32_perf_counter_setup(void)
11650 + struct avr32_perf_counter *ctr;
11655 + pr_debug("avr32_perf_counter_setup\n");
11657 + if (sysreg_read(PCCR) & SYSREG_BIT(PCCR_E)) {
11659 + "oprofile: setup: perf counter already enabled\n");
11663 + ret = request_irq(AVR32_PERFCTR_IRQ_GROUP,
11664 + avr32_perf_counter_interrupt, IRQF_SHARED,
11665 + "oprofile", counter);
11669 + avr32_perf_counter_reset();
11672 + for (i = PCCNT; i < NR_counter; i++) {
11673 + ctr = &counter[i];
11674 + if (!ctr->enabled)
11677 + pr_debug("enabling counter %d...\n", i);
11679 + pccr |= ctr->ie_mask;
11683 + /* PCCNT always counts cycles, so no events */
11684 + sysreg_write(PCCNT, -ctr->count);
11687 + pccr |= SYSREG_BF(CONF0, ctr->event);
11688 + sysreg_write(PCNT0, -ctr->count);
11691 + pccr |= SYSREG_BF(CONF1, ctr->event);
11692 + sysreg_write(PCNT1, -ctr->count);
11697 + pr_debug("oprofile: writing 0x%x to PCCR...\n", pccr);
11699 + sysreg_write(PCCR, pccr);
11704 +static void avr32_perf_counter_shutdown(void)
11706 + pr_debug("avr32_perf_counter_shutdown\n");
11708 + avr32_perf_counter_reset();
11709 + free_irq(AVR32_PERFCTR_IRQ_GROUP, counter);
11712 +static int avr32_perf_counter_start(void)
11714 + pr_debug("avr32_perf_counter_start\n");
11716 + sysreg_write(PCCR, sysreg_read(PCCR) | SYSREG_BIT(PCCR_E));
11721 +static void avr32_perf_counter_stop(void)
11723 + pr_debug("avr32_perf_counter_stop\n");
11725 + sysreg_write(PCCR, sysreg_read(PCCR) & ~SYSREG_BIT(PCCR_E));
11728 +static struct oprofile_operations avr32_perf_counter_ops __initdata = {
11729 + .create_files = avr32_perf_counter_create_files,
11730 + .setup = avr32_perf_counter_setup,
11731 + .shutdown = avr32_perf_counter_shutdown,
11732 + .start = avr32_perf_counter_start,
11733 + .stop = avr32_perf_counter_stop,
11734 + .cpu_type = "avr32",
11737 +int __init oprofile_arch_init(struct oprofile_operations *ops)
11739 + if (!(current_cpu_data.features & AVR32_FEATURE_PCTR))
11742 + memcpy(ops, &avr32_perf_counter_ops,
11743 + sizeof(struct oprofile_operations));
11745 + printk(KERN_INFO "oprofile: using AVR32 performance monitoring.\n");
11750 +void oprofile_arch_exit(void)
11754 --- a/Documentation/kernel-parameters.txt
11755 +++ b/Documentation/kernel-parameters.txt
11757 ALSA ALSA sound support is enabled.
11758 APIC APIC support is enabled.
11759 APM Advanced Power Management support is enabled.
11760 + AVR32 AVR32 architecture is enabled.
11761 AX25 Appropriate AX.25 support is enabled.
11762 BLACKFIN Blackfin architecture is enabled.
11763 DRM Direct Rendering Management support is enabled.
11764 @@ -1124,6 +1125,10 @@
11765 of returning the full 64-bit number.
11766 The default is to return 64-bit inode numbers.
11768 + nmi_debug= [KNL,AVR32] Specify one or more actions to take
11769 + when a NMI is triggered.
11770 + Format: [state][,regs][,debounce][,die]
11772 nmi_watchdog= [KNL,BUGS=X86-32] Debugging features for SMP kernels
11774 no387 [BUGS=X86-32] Tells the kernel to use the 387 maths
11775 --- a/drivers/clocksource/Makefile
11776 +++ b/drivers/clocksource/Makefile
11778 +obj-$(CONFIG_ATMEL_TCB_CLKSRC) += tcb_clksrc.o
11779 obj-$(CONFIG_X86_CYCLONE_TIMER) += cyclone.o
11780 obj-$(CONFIG_X86_PM_TIMER) += acpi_pm.o
11781 obj-$(CONFIG_SCx200HR_TIMER) += scx200_hrt.o
11783 +++ b/drivers/clocksource/tcb_clksrc.c
11785 +#include <linux/init.h>
11786 +#include <linux/clocksource.h>
11787 +#include <linux/clockchips.h>
11788 +#include <linux/interrupt.h>
11789 +#include <linux/irq.h>
11791 +#include <linux/clk.h>
11792 +#include <linux/err.h>
11793 +#include <linux/ioport.h>
11794 +#include <linux/io.h>
11795 +#include <linux/platform_device.h>
11796 +#include <linux/atmel_tc.h>
11800 + * We're configured to use a specific TC block, one that's not hooked
11801 + * up to external hardware, to provide a time solution:
11803 + * - Two channels combine to create a free-running 32 bit counter
11804 + * with a base rate of 5+ MHz, packaged as a clocksource (with
11805 + * resolution better than 200 nsec).
11807 + * - The third channel may be used to provide a 16-bit clockevent
11808 + * source, used in either periodic or oneshot mode. This runs
11809 + * at 32 KiHZ, and can handle delays of up to two seconds.
11811 + * A boot clocksource and clockevent source are also currently needed,
11812 + * unless the relevant platforms (ARM/AT91, AVR32/AT32) are changed so
11813 + * this code can be used when init_timers() is called, well before most
11814 + * devices are set up. (Some low end AT91 parts, which can run uClinux,
11815 + * have only the timers in one TC block... they currently don't support
11816 + * the tclib code, because of that initialization issue.)
11818 + * REVISIT behavior during system suspend states... we should disable
11819 + * all clocks and save the power. Easily done for clockevent devices,
11820 + * but clocksources won't necessarily get the needed notifications.
11821 + * For deeper system sleep states, this will be mandatory...
11824 +static void __iomem *tcaddr;
11826 +static cycle_t tc_get_cycles(void)
11828 + unsigned long flags;
11829 + u32 lower, upper;
11831 + raw_local_irq_save(flags);
11833 + upper = __raw_readl(tcaddr + ATMEL_TC_REG(1, CV));
11834 + lower = __raw_readl(tcaddr + ATMEL_TC_REG(0, CV));
11835 + } while (upper != __raw_readl(tcaddr + ATMEL_TC_REG(1, CV)));
11837 + raw_local_irq_restore(flags);
11838 + return (upper << 16) | lower;
11841 +static struct clocksource clksrc = {
11842 + .name = "tcb_clksrc",
11844 + .read = tc_get_cycles,
11845 + .mask = CLOCKSOURCE_MASK(32),
11847 + .flags = CLOCK_SOURCE_IS_CONTINUOUS,
11850 +#ifdef CONFIG_GENERIC_CLOCKEVENTS
11852 +struct tc_clkevt_device {
11853 + struct clock_event_device clkevt;
11855 + void __iomem *regs;
11858 +static struct tc_clkevt_device *to_tc_clkevt(struct clock_event_device *clkevt)
11860 + return container_of(clkevt, struct tc_clkevt_device, clkevt);
11863 +/* For now, we always use the 32K clock ... this optimizes for NO_HZ,
11864 + * because using one of the divided clocks would usually mean the
11865 + * tick rate can never be less than several dozen Hz (vs 0.5 Hz).
11867 + * A divided clock could be good for high resolution timers, since
11868 + * 30.5 usec resolution can seem "low".
11870 +static u32 timer_clock;
11872 +static void tc_mode(enum clock_event_mode m, struct clock_event_device *d)
11874 + struct tc_clkevt_device *tcd = to_tc_clkevt(d);
11875 + void __iomem *regs = tcd->regs;
11877 + if (tcd->clkevt.mode == CLOCK_EVT_MODE_PERIODIC
11878 + || tcd->clkevt.mode == CLOCK_EVT_MODE_ONESHOT) {
11879 + __raw_writel(0xff, regs + ATMEL_TC_REG(2, IDR));
11880 + __raw_writel(ATMEL_TC_CLKDIS, regs + ATMEL_TC_REG(2, CCR));
11881 + clk_disable(tcd->clk);
11886 + /* By not making the gentime core emulate periodic mode on top
11887 + * of oneshot, we get lower overhead and improved accuracy.
11889 + case CLOCK_EVT_MODE_PERIODIC:
11890 + clk_enable(tcd->clk);
11892 + /* slow clock, count up to RC, then irq and restart */
11893 + __raw_writel(timer_clock
11894 + | ATMEL_TC_WAVE | ATMEL_TC_WAVESEL_UP_AUTO,
11895 + regs + ATMEL_TC_REG(2, CMR));
11896 + __raw_writel((32768 + HZ/2) / HZ, tcaddr + ATMEL_TC_REG(2, RC));
11898 + /* Enable clock and interrupts on RC compare */
11899 + __raw_writel(ATMEL_TC_CPCS, regs + ATMEL_TC_REG(2, IER));
11901 + /* go go gadget! */
11902 + __raw_writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG,
11903 + regs + ATMEL_TC_REG(2, CCR));
11906 + case CLOCK_EVT_MODE_ONESHOT:
11907 + clk_enable(tcd->clk);
11909 + /* slow clock, count up to RC, then irq and stop */
11910 + __raw_writel(timer_clock | ATMEL_TC_CPCSTOP
11911 + | ATMEL_TC_WAVE | ATMEL_TC_WAVESEL_UP_AUTO,
11912 + regs + ATMEL_TC_REG(2, CMR));
11913 + __raw_writel(ATMEL_TC_CPCS, regs + ATMEL_TC_REG(2, IER));
11915 + /* set_next_event() configures and starts the timer */
11923 +static int tc_next_event(unsigned long delta, struct clock_event_device *d)
11925 + __raw_writel(delta, tcaddr + ATMEL_TC_REG(2, RC));
11927 + /* go go gadget! */
11928 + __raw_writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG,
11929 + tcaddr + ATMEL_TC_REG(2, CCR));
11933 +static struct tc_clkevt_device clkevt = {
11935 + .name = "tc_clkevt",
11936 + .features = CLOCK_EVT_FEAT_PERIODIC
11937 + | CLOCK_EVT_FEAT_ONESHOT,
11939 + /* Should be lower than at91rm9200's system timer */
11941 + .cpumask = CPU_MASK_CPU0,
11942 + .set_next_event = tc_next_event,
11943 + .set_mode = tc_mode,
11947 +static irqreturn_t ch2_irq(int irq, void *handle)
11949 + struct tc_clkevt_device *dev = handle;
11952 + sr = __raw_readl(dev->regs + ATMEL_TC_REG(2, SR));
11953 + if (sr & ATMEL_TC_CPCS) {
11954 + dev->clkevt.event_handler(&dev->clkevt);
11955 + return IRQ_HANDLED;
11961 +static struct irqaction tc_irqaction = {
11962 + .name = "tc_clkevt",
11963 + .flags = IRQF_TIMER | IRQF_DISABLED,
11964 + .handler = ch2_irq,
11967 +static void __init setup_clkevents(struct atmel_tc *tc,
11968 + struct clk *t0_clk, int clk32k_divisor_idx)
11970 + struct platform_device *pdev = tc->pdev;
11971 + struct clk *t2_clk = tc->clk[2];
11972 + int irq = tc->irq[2];
11974 + clkevt.regs = tc->regs;
11975 + clkevt.clk = t2_clk;
11976 + tc_irqaction.dev_id = &clkevt;
11978 + timer_clock = clk32k_divisor_idx;
11980 + clkevt.clkevt.mult = div_sc(32768, NSEC_PER_SEC, clkevt.clkevt.shift);
11981 + clkevt.clkevt.max_delta_ns
11982 + = clockevent_delta2ns(0xffff, &clkevt.clkevt);
11983 + clkevt.clkevt.min_delta_ns = clockevent_delta2ns(1, &clkevt.clkevt) + 1;
11985 + setup_irq(irq, &tc_irqaction);
11987 + clockevents_register_device(&clkevt.clkevt);
11990 +#else /* !CONFIG_GENERIC_CLOCKEVENTS */
11992 +static void __init setup_clkevents(struct atmel_tc *tc,
11993 + struct clk *t0_clk, int clk32k_divisor_idx)
12000 +static int __init tcb_clksrc_init(void)
12002 + static char bootinfo[] __initdata
12003 + = KERN_DEBUG "%s: tc%d at %d.%03d MHz\n";
12005 + struct platform_device *pdev;
12006 + struct atmel_tc *tc;
12007 + struct clk *t0_clk, *t1_clk;
12008 + u32 rate, divided_rate = 0;
12009 + int best_divisor_idx = -1;
12010 + int clk32k_divisor_idx = -1;
12013 + tc = atmel_tc_alloc(CONFIG_ATMEL_TCB_CLKSRC_BLOCK, clksrc.name);
12015 + pr_debug("can't alloc TC for clocksource\n");
12018 + tcaddr = tc->regs;
12021 + t0_clk = tc->clk[0];
12022 + clk_enable(t0_clk);
12024 + /* How fast will we be counting? Pick something over 5 MHz. */
12025 + rate = (u32) clk_get_rate(t0_clk);
12026 + for (i = 0; i < 5; i++) {
12027 + unsigned divisor = atmel_tc_divisors[i];
12030 + /* remember 32 KiHz clock for later */
12032 + clk32k_divisor_idx = i;
12036 + tmp = rate / divisor;
12037 + pr_debug("TC: %u / %-3u [%d] --> %u\n", rate, divisor, i, tmp);
12038 + if (best_divisor_idx > 0) {
12039 + if (tmp < 5 * 1000 * 1000)
12042 + divided_rate = tmp;
12043 + best_divisor_idx = i;
12046 + clksrc.mult = clocksource_hz2mult(divided_rate, clksrc.shift);
12048 + printk(bootinfo, clksrc.name, CONFIG_ATMEL_TCB_CLKSRC_BLOCK,
12049 + divided_rate / 1000000,
12050 + ((divided_rate + 500000) % 1000000) / 1000);
12052 + /* tclib will give us three clocks no matter what the
12053 + * underlying platform supports.
12055 + clk_enable(tc->clk[1]);
12057 + /* channel 0: waveform mode, input mclk/8, clock TIOA0 on overflow */
12058 + __raw_writel(best_divisor_idx /* likely divide-by-8 */
12060 + | ATMEL_TC_WAVESEL_UP /* free-run */
12061 + | ATMEL_TC_ACPA_SET /* TIOA0 rises at 0 */
12062 + | ATMEL_TC_ACPC_CLEAR, /* (duty cycle 50%) */
12063 + tcaddr + ATMEL_TC_REG(0, CMR));
12064 + __raw_writel(0x0000, tcaddr + ATMEL_TC_REG(0, RA));
12065 + __raw_writel(0x8000, tcaddr + ATMEL_TC_REG(0, RC));
12066 + __raw_writel(0xff, tcaddr + ATMEL_TC_REG(0, IDR)); /* no irqs */
12067 + __raw_writel(ATMEL_TC_CLKEN, tcaddr + ATMEL_TC_REG(0, CCR));
12069 + /* channel 1: waveform mode, input TIOA0 */
12070 + __raw_writel(ATMEL_TC_XC1 /* input: TIOA0 */
12072 + | ATMEL_TC_WAVESEL_UP, /* free-run */
12073 + tcaddr + ATMEL_TC_REG(1, CMR));
12074 + __raw_writel(0xff, tcaddr + ATMEL_TC_REG(1, IDR)); /* no irqs */
12075 + __raw_writel(ATMEL_TC_CLKEN, tcaddr + ATMEL_TC_REG(1, CCR));
12077 + /* chain channel 0 to channel 1, then reset all the timers */
12078 + __raw_writel(ATMEL_TC_TC1XC1S_TIOA0, tcaddr + ATMEL_TC_BMR);
12079 + __raw_writel(ATMEL_TC_SYNC, tcaddr + ATMEL_TC_BCR);
12081 + /* and away we go! */
12082 + clocksource_register(&clksrc);
12084 + /* channel 2: periodic and oneshot timer support */
12085 + setup_clkevents(tc, t0_clk, clk32k_divisor_idx);
12089 +arch_initcall(tcb_clksrc_init);
12091 +++ b/drivers/i2c/busses/i2c-atmeltwi.c
12094 + * i2c Support for Atmel's Two-Wire Interface (TWI)
12096 + * Based on the work of Copyright (C) 2004 Rick Bronson
12097 + * Converted to 2.6 by Andrew Victor <andrew at sanpeople.com>
12098 + * Ported to AVR32 and heavily modified by Espen Krangnes
12099 + * <ekrangnes at atmel.com>
12101 + * Copyright (C) 2006 Atmel Corporation
12103 + * Borrowed heavily from the original work by:
12104 + * Copyright (C) 2000 Philip Edelbrock <phil at stimpy.netroedge.com>
12106 + * Partialy rewriten by Karel Hojdar <cmkaho at seznam.cz>
12107 + * bugs removed, interrupt routine markedly rewritten
12109 + * This program is free software; you can redistribute it and/or modify
12110 + * it under the terms of the GNU General Public License as published by
12111 + * the Free Software Foundation; either version 2 of the License, or
12112 + * (at your option) any later version.
12114 +#undef VERBOSE_DEBUG
12116 +#include <linux/module.h>
12117 +#include <linux/slab.h>
12118 +#include <linux/i2c.h>
12119 +#include <linux/init.h>
12120 +#include <linux/clk.h>
12121 +#include <linux/err.h>
12122 +#include <linux/interrupt.h>
12123 +#include <linux/platform_device.h>
12124 +#include <linux/completion.h>
12125 +#include <linux/io.h>
12127 +#include "i2c-atmeltwi.h"
12129 +static unsigned int baudrate = 100 * 1000;
12130 +module_param(baudrate, uint, S_IRUGO);
12131 +MODULE_PARM_DESC(baudrate, "The TWI baudrate");
12134 +struct atmel_twi {
12135 + void __iomem *regs;
12136 + struct i2c_adapter adapter;
12137 + struct clk *pclk;
12138 + struct completion comp;
12144 + unsigned int irq;
12147 +#define to_atmel_twi(adap) container_of(adap, struct atmel_twi, adapter)
12150 + * (Re)Initialize the TWI hardware registers.
12152 +static int twi_hwinit(struct atmel_twi *twi)
12154 + unsigned long cdiv, ckdiv = 0;
12156 + /* REVISIT: wait till SCL is high before resetting; otherwise,
12157 + * some versions will wedge forever.
12160 + twi_writel(twi, IDR, ~0UL);
12161 + twi_writel(twi, CR, TWI_BIT(SWRST)); /*Reset peripheral*/
12162 + twi_readl(twi, SR);
12164 + cdiv = (clk_get_rate(twi->pclk) / (2 * baudrate)) - 4;
12166 + while (cdiv > 255) {
12168 + cdiv = cdiv >> 1;
12171 + /* REVISIT: there are various errata to consider re CDIV and CHDIV
12172 + * here, at least on at91 parts.
12178 + twi_writel(twi, CWGR, TWI_BF(CKDIV, ckdiv)
12179 + | TWI_BF(CHDIV, cdiv)
12180 + | TWI_BF(CLDIV, cdiv));
12185 + * Waits for the i2c status register to set the specified bitmask
12186 + * Returns 0 if timed out ... ~100ms is much longer than the SMBus
12187 + * limit, but I2C has no limit at all.
12189 +static int twi_complete(struct atmel_twi *twi, u32 mask)
12191 + int timeout = msecs_to_jiffies(100);
12193 + mask |= TWI_BIT(TXCOMP);
12194 + twi->mask = mask | TWI_BIT(NACK) | TWI_BIT(OVRE);
12195 + init_completion(&twi->comp);
12197 + twi_writel(twi, IER, mask);
12199 + if (!wait_for_completion_timeout(&twi->comp, timeout)) {
12200 + /* RESET TWI interface */
12201 + twi_writel(twi, CR, TWI_BIT(SWRST));
12203 + /* Reinitialize TWI */
12206 + return -ETIMEDOUT;
12212 + * Generic i2c master transfer entrypoint.
12214 +static int twi_xfer(struct i2c_adapter *adap, struct i2c_msg *pmsg, int num)
12216 + struct atmel_twi *twi = to_atmel_twi(adap);
12219 + dev_dbg(&adap->dev, "twi_xfer: processing %d messages:\n", num);
12222 + for (i = 0; i < num; i++, pmsg++) {
12223 + twi->len = pmsg->len;
12224 + twi->buf = pmsg->buf;
12225 + twi->acks_left = pmsg->len;
12226 + twi_writel(twi, MMR, TWI_BF(DADR, pmsg->addr) |
12227 + (pmsg->flags & I2C_M_RD ? TWI_BIT(MREAD) : 0));
12228 + twi_writel(twi, IADR, TWI_BF(IADR, pmsg->addr));
12230 + dev_dbg(&adap->dev,
12231 + "#%d: %s %d byte%s %s dev 0x%02x\n",
12233 + pmsg->flags & I2C_M_RD ? "reading" : "writing",
12235 + pmsg->len > 1 ? "s" : "",
12236 + pmsg->flags & I2C_M_RD ? "from" : "to", pmsg->addr);
12239 + twi_writel(twi, CR, TWI_BIT(MSEN));
12241 + if (pmsg->flags & I2C_M_RD) {
12242 + /* cleanup after previous RX overruns */
12243 + while (twi_readl(twi, SR) & TWI_BIT(RXRDY))
12244 + twi_readl(twi, RHR);
12246 + if (twi->len == 1)
12247 + twi_writel(twi, CR,
12248 + TWI_BIT(START) | TWI_BIT(STOP));
12250 + twi_writel(twi, CR, TWI_BIT(START));
12252 + if (twi_complete(twi, TWI_BIT(RXRDY)) == -ETIMEDOUT) {
12253 + dev_dbg(&adap->dev, "RX[%d] timeout. "
12254 + "Stopped with %d bytes left\n",
12255 + i, twi->acks_left);
12256 + return -ETIMEDOUT;
12259 + twi_writel(twi, THR, twi->buf[0]);
12260 + twi->acks_left--;
12261 + /* REVISIT: some chips don't start automagically:
12262 + * twi_writel(twi, CR, TWI_BIT(START));
12264 + if (twi_complete(twi, TWI_BIT(TXRDY)) == -ETIMEDOUT) {
12265 + dev_dbg(&adap->dev, "TX[%d] timeout. "
12266 + "Stopped with %d bytes left\n",
12267 + i, twi->acks_left);
12268 + return -ETIMEDOUT;
12270 + /* REVISIT: an erratum workaround may be needed here;
12271 + * see sam9261 "STOP not generated" (START either).
12275 + /* Disable TWI interface */
12276 + twi_writel(twi, CR, TWI_BIT(MSDIS));
12279 + return twi->status;
12281 + /* WARNING: This driver lies about properly supporting
12282 + * repeated start, or it would *ALWAYS* return here. It
12283 + * has issued a STOP. Continuing is a false claim -- that
12284 + * a second (or third, etc.) message is part of the same
12285 + * "combined" (no STOPs between parts) message.
12288 + } /* end cur msg */
12294 +static irqreturn_t twi_interrupt(int irq, void *dev_id)
12296 + struct atmel_twi *twi = dev_id;
12297 + int status = twi_readl(twi, SR);
12299 + /* Save state for later debug prints */
12300 + int old_status = status;
12302 + if (twi->mask & status) {
12304 + status &= twi->mask;
12306 + if (status & TWI_BIT(RXRDY)) {
12307 + if ((status & TWI_BIT(OVRE)) && twi->acks_left) {
12308 + /* Note weakness in fault reporting model:
12309 + * we can't say "the first N of these data
12310 + * bytes are valid".
12312 + dev_err(&twi->adapter.dev,
12313 + "OVERRUN RX! %04x, lost %d\n",
12314 + old_status, twi->acks_left);
12315 + twi->acks_left = 0;
12316 + twi_writel(twi, CR, TWI_BIT(STOP));
12317 + twi->status = -EOVERFLOW;
12318 + } else if (twi->acks_left > 0) {
12319 + twi->buf[twi->len - twi->acks_left] =
12320 + twi_readl(twi, RHR);
12321 + twi->acks_left--;
12323 + if (status & TWI_BIT(TXCOMP))
12325 + if (twi->acks_left == 1)
12326 + twi_writel(twi, CR, TWI_BIT(STOP));
12328 + } else if (status & (TWI_BIT(NACK) | TWI_BIT(TXCOMP))) {
12331 + } else if (status & TWI_BIT(TXRDY)) {
12332 + if (twi->acks_left > 0) {
12333 + twi_writel(twi, THR,
12334 + twi->buf[twi->len - twi->acks_left]);
12335 + twi->acks_left--;
12337 + twi_writel(twi, CR, TWI_BIT(STOP));
12340 + if (twi->acks_left == 0)
12341 + twi_writel(twi, IDR, ~TWI_BIT(TXCOMP));
12344 + /* enabling this message helps trigger overruns/underruns ... */
12345 + dev_vdbg(&twi->adapter.dev,
12346 + "ISR: SR 0x%04X, mask 0x%04X, acks %i\n",
12348 + twi->acks_left ? twi->mask : TWI_BIT(TXCOMP),
12351 + return IRQ_HANDLED;
12354 + /* Note weak fault reporting model: we can't report how many
12355 + * bytes we sent before the NAK, or let upper layers choose
12356 + * whether to continue. The I2C stack doesn't allow that...
12358 + if (status & TWI_BIT(NACK)) {
12359 + dev_dbg(&twi->adapter.dev, "NACK received! %d to go\n",
12361 + twi->status = -EPIPE;
12363 + /* TX underrun morphs automagically into a premature STOP;
12364 + * we'll probably observe UVRE even when it's not documented.
12366 + } else if (twi->acks_left && (twi->mask & TWI_BIT(TXRDY))) {
12367 + dev_err(&twi->adapter.dev, "UNDERRUN TX! %04x, %d to go\n",
12368 + old_status, twi->acks_left);
12369 + twi->status = -ENOSR;
12372 + twi_writel(twi, IDR, ~0UL);
12373 + complete(&twi->comp);
12375 + dev_dbg(&twi->adapter.dev, "ISR: SR 0x%04X, acks %i --> %d\n",
12376 + old_status, twi->acks_left, twi->status);
12378 + return IRQ_HANDLED;
12383 + * Return list of supported functionality.
12385 + * NOTE: see warning above about repeated starts; this driver is falsely
12386 + * claiming to support "combined" transfers. The mid-message STOPs mean
12387 + * some slaves will never work with this driver. (Use i2c-gpio...)
12389 +static u32 twi_func(struct i2c_adapter *adapter)
12391 + return (I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL)
12392 + & ~I2C_FUNC_SMBUS_QUICK;
12395 +static struct i2c_algorithm twi_algorithm = {
12396 + .master_xfer = twi_xfer,
12397 + .functionality = twi_func,
12401 + * Main initialization routine.
12403 +static int __init twi_probe(struct platform_device *pdev)
12405 + struct atmel_twi *twi;
12406 + struct resource *regs;
12407 + struct clk *pclk;
12408 + struct i2c_adapter *adapter;
12411 + regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
12415 + pclk = clk_get(&pdev->dev, "twi_pclk");
12416 + if (IS_ERR(pclk))
12417 + return PTR_ERR(pclk);
12418 + clk_enable(pclk);
12421 + twi = kzalloc(sizeof(struct atmel_twi), GFP_KERNEL);
12423 + dev_dbg(&pdev->dev, "can't allocate interface!\n");
12424 + goto err_alloc_twi;
12427 + twi->pclk = pclk;
12428 + twi->regs = ioremap(regs->start, regs->end - regs->start + 1);
12430 + goto err_ioremap;
12432 + irq = platform_get_irq(pdev, 0);
12433 + rc = request_irq(irq, twi_interrupt, 0, "twi", twi);
12435 + dev_dbg(&pdev->dev, "can't bind irq!\n");
12440 + rc = twi_hwinit(twi);
12442 + dev_err(&pdev->dev, "Unable to set baudrate\n");
12443 + goto err_hw_init;
12446 + adapter = &twi->adapter;
12447 + sprintf(adapter->name, "TWI");
12448 + adapter->algo = &twi_algorithm;
12449 + adapter->class = I2C_CLASS_ALL;
12450 + adapter->nr = pdev->id;
12451 + adapter->dev.parent = &pdev->dev;
12453 + platform_set_drvdata(pdev, twi);
12455 + rc = i2c_add_numbered_adapter(adapter);
12457 + dev_dbg(&pdev->dev, "Adapter %s registration failed\n",
12459 + goto err_register;
12462 + dev_info(&pdev->dev,
12463 + "Atmel TWI/I2C adapter (baudrate %dk) at 0x%08lx.\n",
12464 + baudrate/1000, (unsigned long)regs->start);
12470 + platform_set_drvdata(pdev, NULL);
12473 + free_irq(irq, twi);
12476 + iounmap(twi->regs);
12482 + clk_disable(pclk);
12488 +static int __exit twi_remove(struct platform_device *pdev)
12490 + struct atmel_twi *twi = platform_get_drvdata(pdev);
12493 + platform_set_drvdata(pdev, NULL);
12494 + res = i2c_del_adapter(&twi->adapter);
12495 + twi_writel(twi, CR, TWI_BIT(MSDIS));
12496 + iounmap(twi->regs);
12497 + clk_disable(twi->pclk);
12498 + clk_put(twi->pclk);
12499 + free_irq(twi->irq, twi);
12505 +static struct platform_driver twi_driver = {
12506 + .remove = __exit_p(twi_remove),
12508 + .name = "atmel_twi",
12509 + .owner = THIS_MODULE,
12513 +static int __init atmel_twi_init(void)
12515 + return platform_driver_probe(&twi_driver, twi_probe);
12518 +static void __exit atmel_twi_exit(void)
12520 + platform_driver_unregister(&twi_driver);
12523 +module_init(atmel_twi_init);
12524 +module_exit(atmel_twi_exit);
12526 +MODULE_AUTHOR("Espen Krangnes");
12527 +MODULE_DESCRIPTION("I2C driver for Atmel TWI");
12528 +MODULE_LICENSE("GPL");
12530 +++ b/drivers/i2c/busses/i2c-atmeltwi.h
12533 + * Register definitions for the Atmel Two-Wire Interface
12536 +#ifndef __ATMELTWI_H__
12537 +#define __ATMELTWI_H__
12539 +/* TWI register offsets */
12540 +#define TWI_CR 0x0000
12541 +#define TWI_MMR 0x0004
12542 +#define TWI_SMR 0x0008
12543 +#define TWI_IADR 0x000c
12544 +#define TWI_CWGR 0x0010
12545 +#define TWI_SR 0x0020
12546 +#define TWI_IER 0x0024
12547 +#define TWI_IDR 0x0028
12548 +#define TWI_IMR 0x002c
12549 +#define TWI_RHR 0x0030
12550 +#define TWI_THR 0x0034
12552 +/* Bitfields in CR */
12553 +#define TWI_START_OFFSET 0
12554 +#define TWI_START_SIZE 1
12555 +#define TWI_STOP_OFFSET 1
12556 +#define TWI_STOP_SIZE 1
12557 +#define TWI_MSEN_OFFSET 2
12558 +#define TWI_MSEN_SIZE 1
12559 +#define TWI_MSDIS_OFFSET 3
12560 +#define TWI_MSDIS_SIZE 1
12561 +#define TWI_SVEN_OFFSET 4
12562 +#define TWI_SVEN_SIZE 1
12563 +#define TWI_SVDIS_OFFSET 5
12564 +#define TWI_SVDIS_SIZE 1
12565 +#define TWI_SWRST_OFFSET 7
12566 +#define TWI_SWRST_SIZE 1
12568 +/* Bitfields in MMR */
12569 +#define TWI_IADRSZ_OFFSET 8
12570 +#define TWI_IADRSZ_SIZE 2
12571 +#define TWI_MREAD_OFFSET 12
12572 +#define TWI_MREAD_SIZE 1
12573 +#define TWI_DADR_OFFSET 16
12574 +#define TWI_DADR_SIZE 7
12576 +/* Bitfields in SMR */
12577 +#define TWI_SADR_OFFSET 16
12578 +#define TWI_SADR_SIZE 7
12580 +/* Bitfields in IADR */
12581 +#define TWI_IADR_OFFSET 0
12582 +#define TWI_IADR_SIZE 24
12584 +/* Bitfields in CWGR */
12585 +#define TWI_CLDIV_OFFSET 0
12586 +#define TWI_CLDIV_SIZE 8
12587 +#define TWI_CHDIV_OFFSET 8
12588 +#define TWI_CHDIV_SIZE 8
12589 +#define TWI_CKDIV_OFFSET 16
12590 +#define TWI_CKDIV_SIZE 3
12592 +/* Bitfields in SR */
12593 +#define TWI_TXCOMP_OFFSET 0
12594 +#define TWI_TXCOMP_SIZE 1
12595 +#define TWI_RXRDY_OFFSET 1
12596 +#define TWI_RXRDY_SIZE 1
12597 +#define TWI_TXRDY_OFFSET 2
12598 +#define TWI_TXRDY_SIZE 1
12599 +#define TWI_SVDIR_OFFSET 3
12600 +#define TWI_SVDIR_SIZE 1
12601 +#define TWI_SVACC_OFFSET 4
12602 +#define TWI_SVACC_SIZE 1
12603 +#define TWI_GCACC_OFFSET 5
12604 +#define TWI_GCACC_SIZE 1
12605 +#define TWI_OVRE_OFFSET 6
12606 +#define TWI_OVRE_SIZE 1
12607 +#define TWI_UNRE_OFFSET 7
12608 +#define TWI_UNRE_SIZE 1
12609 +#define TWI_NACK_OFFSET 8
12610 +#define TWI_NACK_SIZE 1
12611 +#define TWI_ARBLST_OFFSET 9
12612 +#define TWI_ARBLST_SIZE 1
12614 +/* Bitfields in RHR */
12615 +#define TWI_RXDATA_OFFSET 0
12616 +#define TWI_RXDATA_SIZE 8
12618 +/* Bitfields in THR */
12619 +#define TWI_TXDATA_OFFSET 0
12620 +#define TWI_TXDATA_SIZE 8
12622 +/* Constants for IADRSZ */
12623 +#define TWI_IADRSZ_NO_ADDR 0
12624 +#define TWI_IADRSZ_ONE_BYTE 1
12625 +#define TWI_IADRSZ_TWO_BYTES 2
12626 +#define TWI_IADRSZ_THREE_BYTES 3
12628 +/* Bit manipulation macros */
12629 +#define TWI_BIT(name) \
12630 + (1 << TWI_##name##_OFFSET)
12631 +#define TWI_BF(name, value) \
12632 + (((value) & ((1 << TWI_##name##_SIZE) - 1)) \
12633 + << TWI_##name##_OFFSET)
12634 +#define TWI_BFEXT(name, value) \
12635 + (((value) >> TWI_##name##_OFFSET) \
12636 + & ((1 << TWI_##name##_SIZE) - 1))
12637 +#define TWI_BFINS(name, value, old) \
12638 + (((old) & ~(((1 << TWI_##name##_SIZE) - 1) \
12639 + << TWI_##name##_OFFSET)) \
12640 + | TWI_BF(name, (value)))
12642 +/* Register access macros */
12643 +#define twi_readl(port, reg) \
12644 + __raw_readl((port)->regs + TWI_##reg)
12645 +#define twi_writel(port, reg, value) \
12646 + __raw_writel((value), (port)->regs + TWI_##reg)
12648 +#endif /* __ATMELTWI_H__ */
12649 --- a/drivers/i2c/busses/Kconfig
12650 +++ b/drivers/i2c/busses/Kconfig
12652 to support combined I2C messages. Use the i2c-gpio driver
12653 unless your system can cope with those limitations.
12655 +config I2C_ATMELTWI
12656 + tristate "Atmel Two-Wire Interface (TWI)"
12657 + depends on I2C && (ARCH_AT91 || PLATFORM_AT32AP)
12659 + Atmel on-chip TWI controller. Say Y if you have an AT32 or
12660 + AT91-based device and want to use its built-in TWI
12664 tristate "Au1550/Au1200 SMBus interface"
12665 depends on SOC_AU1550 || SOC_AU1200
12666 --- a/drivers/i2c/busses/Makefile
12667 +++ b/drivers/i2c/busses/Makefile
12669 obj-$(CONFIG_I2C_VOODOO3) += i2c-voodoo3.o
12670 obj-$(CONFIG_SCx200_ACB) += scx200_acb.o
12671 obj-$(CONFIG_SCx200_I2C) += scx200_i2c.o
12672 +obj-$(CONFIG_I2C_ATMELTWI) += i2c-atmeltwi.o
12674 ifeq ($(CONFIG_I2C_DEBUG_BUS),y)
12675 EXTRA_CFLAGS += -DDEBUG
12677 +++ b/drivers/input/serio/at32psif.c
12680 + * Copyright (C) 2007 Atmel Corporation
12682 + * Driver for the AT32AP700X PS/2 controller (PSIF).
12684 + * This program is free software; you can redistribute it and/or modify it
12685 + * under the terms of the GNU General Public License version 2 as published
12686 + * by the Free Software Foundation.
12688 +#include <linux/kernel.h>
12689 +#include <linux/module.h>
12690 +#include <linux/device.h>
12691 +#include <linux/init.h>
12692 +#include <linux/serio.h>
12693 +#include <linux/timer.h>
12694 +#include <linux/interrupt.h>
12695 +#include <linux/err.h>
12696 +#include <linux/io.h>
12697 +#include <linux/clk.h>
12698 +#include <linux/platform_device.h>
12700 +#include "at32psif.h"
12702 +#define PSIF_BUF_SIZE 16
12704 +#define ring_is_empty(_psif) (_psif->head == _psif->tail)
12705 +#define ring_next_head(_psif) ((_psif->head + 1) & (PSIF_BUF_SIZE - 1))
12706 +#define ring_next_tail(_psif) ((_psif->tail + 1) & (PSIF_BUF_SIZE - 1))
12709 + struct platform_device *pdev;
12710 + struct clk *pclk;
12711 + struct serio *io;
12712 + struct timer_list tx_timer;
12713 + void __iomem *regs;
12714 + unsigned int irq;
12715 + unsigned int open;
12716 + /* Prevent concurrent writes to circular buffer. */
12718 + unsigned int head;
12719 + unsigned int tail;
12720 + unsigned char buffer[PSIF_BUF_SIZE];
12723 +static irqreturn_t psif_interrupt(int irq, void *_ptr)
12725 + struct psif *psif = _ptr;
12726 + int retval = IRQ_NONE;
12727 + unsigned int io_flags = 0;
12728 + unsigned long status;
12730 + status = psif_readl(psif, SR);
12732 + if (status & PSIF_BIT(RXRDY)) {
12733 + unsigned char val = (unsigned char) psif_readl(psif, RHR);
12735 + if (status & PSIF_BIT(PARITY))
12736 + io_flags |= SERIO_PARITY;
12737 + if (status & PSIF_BIT(OVRUN))
12738 + dev_err(&psif->pdev->dev, "overrun read error\n");
12740 + serio_interrupt(psif->io, val, io_flags);
12742 + retval = IRQ_HANDLED;
12745 + spin_lock(&psif->lock);
12747 + if (status & PSIF_BIT(TXEMPTY)) {
12748 + if (status & PSIF_BIT(NACK))
12749 + dev_err(&psif->pdev->dev, "NACK error\n");
12751 + psif_writel(psif, IDR, PSIF_BIT(TXEMPTY));
12753 + if (!ring_is_empty(psif))
12754 + mod_timer(&psif->tx_timer,
12755 + jiffies + msecs_to_jiffies(1));
12757 + retval = IRQ_HANDLED;
12760 + spin_unlock(&psif->lock);
12765 +static void psif_transmit_data(unsigned long data)
12767 + struct psif *psif = (struct psif *)data;
12768 + unsigned long flags;
12770 + spin_lock_irqsave(&psif->lock, flags);
12772 + psif_writel(psif, THR, psif->buffer[psif->tail]);
12773 + psif->tail = ring_next_tail(psif);
12775 + if (!ring_is_empty(psif))
12776 + psif_writel(psif, IER, PSIF_BIT(TXEMPTY));
12778 + spin_unlock_irqrestore(&psif->lock, flags);
12781 +static int psif_write(struct serio *io, unsigned char val)
12783 + struct psif *psif = io->port_data;
12784 + unsigned long flags;
12785 + unsigned int head;
12787 + spin_lock_irqsave(&psif->lock, flags);
12789 + head = ring_next_head(psif);
12791 + if (head != psif->tail) {
12792 + psif->buffer[psif->head] = val;
12793 + psif->head = head;
12795 + dev_err(&psif->pdev->dev, "underrun write error\n");
12798 + spin_unlock_irqrestore(&psif->lock, flags);
12800 + /* Make sure TXEMPTY interrupt is enabled. */
12801 + psif_writel(psif, IER, PSIF_BIT(TXEMPTY));
12806 +static int psif_open(struct serio *io)
12808 + struct psif *psif = io->port_data;
12811 + retval = clk_enable(psif->pclk);
12815 + psif_writel(psif, CR, PSIF_BIT(CR_TXEN) | PSIF_BIT(CR_RXEN));
12816 + psif_writel(psif, IER, PSIF_BIT(RXRDY));
12823 +static void psif_close(struct serio *io)
12825 + struct psif *psif = io->port_data;
12829 + psif_writel(psif, IDR, ~0UL);
12830 + psif_writel(psif, CR, PSIF_BIT(CR_TXDIS) | PSIF_BIT(CR_RXDIS));
12832 + clk_disable(psif->pclk);
12835 +static void psif_set_prescaler(struct psif *psif)
12837 + unsigned long prscv;
12838 + unsigned long rate = clk_get_rate(psif->pclk);
12840 + /* PRSCV = Pulse length (100 us) * PSIF module frequency. */
12841 + prscv = 100 * (rate / 1000000UL);
12843 + if (prscv > ((1<<PSIF_PSR_PRSCV_SIZE) - 1)) {
12844 + prscv = (1<<PSIF_PSR_PRSCV_SIZE) - 1;
12845 + dev_dbg(&psif->pdev->dev, "pclk too fast, "
12846 + "prescaler set to max\n");
12849 + clk_enable(psif->pclk);
12850 + psif_writel(psif, PSR, prscv);
12851 + clk_disable(psif->pclk);
12854 +static int __init psif_probe(struct platform_device *pdev)
12856 + struct resource *regs;
12857 + struct psif *psif;
12858 + struct serio *io;
12859 + struct clk *pclk;
12863 + psif = kzalloc(sizeof(struct psif), GFP_KERNEL);
12865 + dev_dbg(&pdev->dev, "out of memory\n");
12869 + psif->pdev = pdev;
12871 + io = kzalloc(sizeof(struct serio), GFP_KERNEL);
12873 + dev_dbg(&pdev->dev, "out of memory\n");
12875 + goto out_free_psif;
12879 + regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
12881 + dev_dbg(&pdev->dev, "no mmio resources defined\n");
12883 + goto out_free_io;
12886 + psif->regs = ioremap(regs->start, regs->end - regs->start + 1);
12887 + if (!psif->regs) {
12889 + dev_dbg(&pdev->dev, "could not map I/O memory\n");
12890 + goto out_free_io;
12893 + pclk = clk_get(&pdev->dev, "pclk");
12894 + if (IS_ERR(pclk)) {
12895 + dev_dbg(&pdev->dev, "could not get peripheral clock\n");
12896 + ret = PTR_ERR(pclk);
12897 + goto out_iounmap;
12899 + psif->pclk = pclk;
12901 + /* Reset the PSIF to enter at a known state. */
12902 + ret = clk_enable(pclk);
12904 + dev_dbg(&pdev->dev, "could not enable pclk\n");
12905 + goto out_put_clk;
12907 + psif_writel(psif, CR, PSIF_BIT(CR_SWRST));
12908 + clk_disable(pclk);
12910 + setup_timer(&psif->tx_timer, psif_transmit_data, (unsigned long)psif);
12912 + irq = platform_get_irq(pdev, 0);
12914 + dev_dbg(&pdev->dev, "could not get irq\n");
12916 + goto out_put_clk;
12918 + ret = request_irq(irq, psif_interrupt, IRQF_SHARED, "at32psif", psif);
12920 + dev_dbg(&pdev->dev, "could not request irq %d\n", irq);
12921 + goto out_put_clk;
12925 + io->id.type = SERIO_8042;
12926 + io->write = psif_write;
12927 + io->open = psif_open;
12928 + io->close = psif_close;
12929 + strlcpy(io->name, pdev->dev.bus_id, sizeof(io->name));
12930 + strlcpy(io->phys, pdev->dev.bus_id, sizeof(io->phys));
12931 + io->port_data = psif;
12932 + io->dev.parent = &pdev->dev;
12934 + psif_set_prescaler(psif);
12936 + spin_lock_init(&psif->lock);
12937 + serio_register_port(psif->io);
12938 + platform_set_drvdata(pdev, psif);
12940 + dev_info(&pdev->dev, "Atmel AVR32 PSIF PS/2 driver on 0x%08x irq %d\n",
12941 + (int)psif->regs, psif->irq);
12946 + clk_put(psif->pclk);
12948 + iounmap(psif->regs);
12957 +static int __exit psif_remove(struct platform_device *pdev)
12959 + struct psif *psif = platform_get_drvdata(pdev);
12961 + psif_writel(psif, IDR, ~0UL);
12962 + psif_writel(psif, CR, PSIF_BIT(CR_TXDIS) | PSIF_BIT(CR_RXDIS));
12964 + serio_unregister_port(psif->io);
12965 + iounmap(psif->regs);
12966 + free_irq(psif->irq, psif);
12967 + clk_put(psif->pclk);
12970 + platform_set_drvdata(pdev, NULL);
12976 +static int psif_suspend(struct platform_device *pdev, pm_message_t state)
12978 + struct psif *psif = platform_get_drvdata(pdev);
12980 + if (psif->open) {
12981 + psif_writel(psif, CR, PSIF_BIT(CR_RXDIS) | PSIF_BIT(CR_TXDIS));
12982 + clk_disable(psif->pclk);
12988 +static int psif_resume(struct platform_device *pdev)
12990 + struct psif *psif = platform_get_drvdata(pdev);
12992 + if (psif->open) {
12993 + clk_enable(psif->pclk);
12994 + psif_set_prescaler(psif);
12995 + psif_writel(psif, CR, PSIF_BIT(CR_RXEN) | PSIF_BIT(CR_TXEN));
13001 +#define psif_suspend NULL
13002 +#define psif_resume NULL
13005 +static struct platform_driver psif_driver = {
13006 + .remove = __exit_p(psif_remove),
13008 + .name = "atmel_psif",
13010 + .suspend = psif_suspend,
13011 + .resume = psif_resume,
13014 +static int __init psif_init(void)
13016 + return platform_driver_probe(&psif_driver, psif_probe);
13019 +static void __exit psif_exit(void)
13021 + platform_driver_unregister(&psif_driver);
13024 +module_init(psif_init);
13025 +module_exit(psif_exit);
13027 +MODULE_AUTHOR("Hans-Christian Egtvedt <hcegtvedt@atmel.com>");
13028 +MODULE_DESCRIPTION("Atmel AVR32 PSIF PS/2 driver");
13029 +MODULE_LICENSE("GPL");
13031 +++ b/drivers/input/serio/at32psif.h
13034 + * Copyright (C) 2007 Atmel Corporation
13036 + * Driver for the AT32AP700X PS/2 controller (PSIF).
13038 + * This program is free software; you can redistribute it and/or modify it
13039 + * under the terms of the GNU General Public License version 2 as published
13040 + * by the Free Software Foundation.
13043 +#ifndef _AT32PSIF_H
13044 +#define _AT32PSIF_H
13046 +/* PSIF register offsets */
13047 +#define PSIF_CR 0x00
13048 +#define PSIF_RHR 0x04
13049 +#define PSIF_THR 0x08
13050 +#define PSIF_SR 0x10
13051 +#define PSIF_IER 0x14
13052 +#define PSIF_IDR 0x18
13053 +#define PSIF_IMR 0x1c
13054 +#define PSIF_PSR 0x24
13056 +/* Bitfields in control register. */
13057 +#define PSIF_CR_RXDIS_OFFSET 1
13058 +#define PSIF_CR_RXDIS_SIZE 1
13059 +#define PSIF_CR_RXEN_OFFSET 0
13060 +#define PSIF_CR_RXEN_SIZE 1
13061 +#define PSIF_CR_SWRST_OFFSET 15
13062 +#define PSIF_CR_SWRST_SIZE 1
13063 +#define PSIF_CR_TXDIS_OFFSET 9
13064 +#define PSIF_CR_TXDIS_SIZE 1
13065 +#define PSIF_CR_TXEN_OFFSET 8
13066 +#define PSIF_CR_TXEN_SIZE 1
13068 +/* Bitfields in interrupt disable, enable, mask and status register. */
13069 +#define PSIF_NACK_OFFSET 8
13070 +#define PSIF_NACK_SIZE 1
13071 +#define PSIF_OVRUN_OFFSET 5
13072 +#define PSIF_OVRUN_SIZE 1
13073 +#define PSIF_PARITY_OFFSET 9
13074 +#define PSIF_PARITY_SIZE 1
13075 +#define PSIF_RXRDY_OFFSET 4
13076 +#define PSIF_RXRDY_SIZE 1
13077 +#define PSIF_TXEMPTY_OFFSET 1
13078 +#define PSIF_TXEMPTY_SIZE 1
13079 +#define PSIF_TXRDY_OFFSET 0
13080 +#define PSIF_TXRDY_SIZE 1
13082 +/* Bitfields in prescale register. */
13083 +#define PSIF_PSR_PRSCV_OFFSET 0
13084 +#define PSIF_PSR_PRSCV_SIZE 12
13086 +/* Bitfields in receive hold register. */
13087 +#define PSIF_RHR_RXDATA_OFFSET 0
13088 +#define PSIF_RHR_RXDATA_SIZE 8
13090 +/* Bitfields in transmit hold register. */
13091 +#define PSIF_THR_TXDATA_OFFSET 0
13092 +#define PSIF_THR_TXDATA_SIZE 8
13094 +/* Bit manipulation macros */
13095 +#define PSIF_BIT(name) \
13096 + (1 << PSIF_##name##_OFFSET)
13097 +#define PSIF_BF(name, value) \
13098 + (((value) & ((1 << PSIF_##name##_SIZE) - 1)) \
13099 + << PSIF_##name##_OFFSET)
13100 +#define PSIF_BFEXT(name, value)\
13101 + (((value) >> PSIF_##name##_OFFSET) \
13102 + & ((1 << PSIF_##name##_SIZE) - 1))
13103 +#define PSIF_BFINS(name, value, old) \
13104 + (((old) & ~(((1 << PSIF_##name##_SIZE) - 1) \
13105 + << PSIF_##name##_OFFSET)) \
13106 + | PSIF_BF(name, value))
13108 +/* Register access macros */
13109 +#define psif_readl(port, reg) \
13110 + __raw_readl((port)->regs + PSIF_##reg)
13111 +#define psif_writel(port, reg, value) \
13112 + __raw_writel((value), (port)->regs + PSIF_##reg)
13114 +#endif /* _AT32PSIF_H */
13115 --- a/drivers/input/serio/Kconfig
13116 +++ b/drivers/input/serio/Kconfig
13118 To compile this driver as a module, choose M here: the
13119 module will be called rpckbd.
13121 +config SERIO_AT32PSIF
13122 + tristate "AVR32 PSIF PS/2 keyboard and mouse controller"
13126 + Say Y here if you want to use the PSIF peripheral on AVR32 devices
13127 + and connect a PS/2 keyboard and/or mouse to it.
13129 + To compile this driver as a module, choose M here: the module will
13130 + be called at32psif.
13132 config SERIO_AMBAKMI
13133 tristate "AMBA KMI keyboard controller"
13134 depends on ARM_AMBA
13135 --- a/drivers/input/serio/Makefile
13136 +++ b/drivers/input/serio/Makefile
13138 obj-$(CONFIG_SERIO_RPCKBD) += rpckbd.o
13139 obj-$(CONFIG_SERIO_SA1111) += sa1111ps2.o
13140 obj-$(CONFIG_SERIO_AMBAKMI) += ambakmi.o
13141 +obj-$(CONFIG_SERIO_AT32PSIF) += at32psif.o
13142 obj-$(CONFIG_SERIO_Q40KBD) += q40kbd.o
13143 obj-$(CONFIG_SERIO_GSCPS2) += gscps2.o
13144 obj-$(CONFIG_HP_SDC) += hp_sdc.o
13145 --- a/drivers/leds/Kconfig
13146 +++ b/drivers/leds/Kconfig
13149 comment "LED drivers"
13151 +config LEDS_ATMEL_PWM
13152 + tristate "LED Support using Atmel PWM outputs"
13153 + depends on LEDS_CLASS && ATMEL_PWM
13155 + This option enables support for LEDs driven using outputs
13156 + of the dedicated PWM controller found on newer Atmel SOCs.
13159 tristate "LED Support for the Sharp SL-C7x0 series"
13160 depends on LEDS_CLASS && PXA_SHARP_C7xx
13162 +++ b/drivers/leds/leds-atmel-pwm.c
13164 +#include <linux/kernel.h>
13165 +#include <linux/platform_device.h>
13166 +#include <linux/leds.h>
13167 +#include <linux/io.h>
13168 +#include <linux/atmel_pwm.h>
13172 + struct led_classdev cdev;
13173 + struct pwm_channel pwmc;
13174 + struct gpio_led *desc;
13181 + * For simplicity, we use "brightness" as if it were a linear function
13182 + * of PWM duty cycle. However, a logarithmic function of duty cycle is
13183 + * probably a better match for perceived brightness: two is half as bright
13184 + * as four, four is half as bright as eight, etc
13186 +static void pwmled_brightness(struct led_classdev *cdev, enum led_brightness b)
13188 + struct pwmled *led;
13190 + /* update the duty cycle for the *next* period */
13191 + led = container_of(cdev, struct pwmled, cdev);
13192 + pwm_channel_writel(&led->pwmc, PWM_CUPD, led->mult * (unsigned) b);
13196 + * NOTE: we reuse the platform_data structure of GPIO leds,
13197 + * but repurpose its "gpio" number as a PWM channel number.
13199 +static int __init pwmled_probe(struct platform_device *pdev)
13201 + const struct gpio_led_platform_data *pdata;
13202 + struct pwmled *leds;
13206 + pdata = pdev->dev.platform_data;
13207 + if (!pdata || pdata->num_leds < 1)
13210 + leds = kcalloc(pdata->num_leds, sizeof(*leds), GFP_KERNEL);
13214 + for (i = 0; i < pdata->num_leds; i++) {
13215 + struct pwmled *led = leds + i;
13216 + const struct gpio_led *dat = pdata->leds + i;
13219 + led->cdev.name = dat->name;
13220 + led->cdev.brightness = LED_OFF;
13221 + led->cdev.brightness_set = pwmled_brightness;
13222 + led->cdev.default_trigger = dat->default_trigger;
13224 + led->active_low = dat->active_low;
13226 + status = pwm_channel_alloc(dat->gpio, &led->pwmc);
13231 + * Prescale clock by 2^x, so PWM counts in low MHz.
13232 + * Start each cycle with the LED active, so increasing
13233 + * the duty cycle gives us more time on (== brighter).
13236 + if (!led->active_low)
13237 + tmp |= PWM_CPR_CPOL;
13238 + pwm_channel_writel(&led->pwmc, PWM_CMR, tmp);
13241 + * Pick a period so PWM cycles at 100+ Hz; and a multiplier
13242 + * for scaling duty cycle: brightness * mult.
13244 + tmp = (led->pwmc.mck / (1 << 5)) / 100;
13247 + pwm_channel_writel(&led->pwmc, PWM_CDTY,
13248 + led->cdev.brightness * 255);
13249 + pwm_channel_writel(&led->pwmc, PWM_CPRD,
13252 + pwm_channel_enable(&led->pwmc);
13254 + /* Hand it over to the LED framework */
13255 + status = led_classdev_register(&pdev->dev, &led->cdev);
13256 + if (status < 0) {
13257 + pwm_channel_free(&led->pwmc);
13262 + platform_set_drvdata(pdev, leds);
13266 + while (i-- > 0) {
13267 + led_classdev_unregister(&leds[i].cdev);
13268 + pwm_channel_free(&leds[i].pwmc);
13275 +static int __exit pwmled_remove(struct platform_device *pdev)
13277 + const struct gpio_led_platform_data *pdata;
13278 + struct pwmled *leds;
13281 + pdata = pdev->dev.platform_data;
13282 + leds = platform_get_drvdata(pdev);
13284 + for (i = 0; i < pdata->num_leds; i++) {
13285 + struct pwmled *led = leds + i;
13287 + led_classdev_unregister(&led->cdev);
13288 + pwm_channel_free(&led->pwmc);
13292 + platform_set_drvdata(pdev, NULL);
13296 +static struct platform_driver pwmled_driver = {
13298 + .name = "leds-atmel-pwm",
13299 + .owner = THIS_MODULE,
13301 + /* REVISIT add suspend() and resume() methods */
13302 + .remove = __exit_p(pwmled_remove),
13305 +static int __init modinit(void)
13307 + return platform_driver_probe(&pwmled_driver, pwmled_probe);
13309 +module_init(modinit);
13311 +static void __exit modexit(void)
13313 + platform_driver_unregister(&pwmled_driver);
13315 +module_exit(modexit);
13317 +MODULE_DESCRIPTION("Driver for LEDs with PWM-controlled brightness");
13318 +MODULE_LICENSE("GPL");
13319 --- a/drivers/leds/Makefile
13320 +++ b/drivers/leds/Makefile
13322 obj-$(CONFIG_LEDS_TRIGGERS) += led-triggers.o
13324 # LED Platform Drivers
13325 +obj-$(CONFIG_LEDS_ATMEL_PWM) += leds-atmel-pwm.o
13326 obj-$(CONFIG_LEDS_CORGI) += leds-corgi.o
13327 obj-$(CONFIG_LEDS_LOCOMO) += leds-locomo.o
13328 obj-$(CONFIG_LEDS_SPITZ) += leds-spitz.o
13330 +++ b/drivers/misc/atmel_pwm.c
13332 +#include <linux/module.h>
13333 +#include <linux/clk.h>
13334 +#include <linux/err.h>
13335 +#include <linux/io.h>
13336 +#include <linux/interrupt.h>
13337 +#include <linux/platform_device.h>
13338 +#include <linux/atmel_pwm.h>
13342 + * This is a simple driver for the PWM controller found in various newer
13343 + * Atmel SOCs, including the AVR32 series and the AT91sam9263.
13345 + * Chips with current Linux ports have only 4 PWM channels, out of max 32.
13346 + * AT32UC3A and AT32UC3B chips have 7 channels (but currently no Linux).
13347 + * Docs are inconsistent about the width of the channel counter registers;
13348 + * it's at least 16 bits, but several places say 20 bits.
13350 +#define PWM_NCHAN 4 /* max 32 */
13354 + struct platform_device *pdev;
13357 + void __iomem *base;
13359 + struct pwm_channel *channel[PWM_NCHAN];
13360 + void (*handler[PWM_NCHAN])(struct pwm_channel *);
13364 +/* global PWM controller registers */
13365 +#define PWM_MR 0x00
13366 +#define PWM_ENA 0x04
13367 +#define PWM_DIS 0x08
13368 +#define PWM_SR 0x0c
13369 +#define PWM_IER 0x10
13370 +#define PWM_IDR 0x14
13371 +#define PWM_IMR 0x18
13372 +#define PWM_ISR 0x1c
13374 +static inline void pwm_writel(const struct pwm *p, unsigned offset, u32 val)
13376 + __raw_writel(val, p->base + offset);
13379 +static inline u32 pwm_readl(const struct pwm *p, unsigned offset)
13381 + return __raw_readl(p->base + offset);
13384 +static inline void __iomem *pwmc_regs(const struct pwm *p, int index)
13386 + return p->base + 0x200 + index * 0x20;
13389 +static struct pwm *pwm;
13391 +static void pwm_dumpregs(struct pwm_channel *ch, char *tag)
13393 + struct device *dev = &pwm->pdev->dev;
13395 + dev_dbg(dev, "%s: mr %08x, sr %08x, imr %08x\n",
13397 + pwm_readl(pwm, PWM_MR),
13398 + pwm_readl(pwm, PWM_SR),
13399 + pwm_readl(pwm, PWM_IMR));
13401 + "pwm ch%d - mr %08x, dty %u, prd %u, cnt %u\n",
13403 + pwm_channel_readl(ch, PWM_CMR),
13404 + pwm_channel_readl(ch, PWM_CDTY),
13405 + pwm_channel_readl(ch, PWM_CPRD),
13406 + pwm_channel_readl(ch, PWM_CCNT));
13411 + * pwm_channel_alloc - allocate an unused PWM channel
13412 + * @index: identifies the channel
13413 + * @ch: structure to be initialized
13415 + * Drivers allocate PWM channels according to the board's wiring, and
13416 + * matching board-specific setup code. Returns zero or negative errno.
13418 +int pwm_channel_alloc(int index, struct pwm_channel *ch)
13420 + unsigned long flags;
13423 + /* insist on PWM init, with this signal pinned out */
13424 + if (!pwm || !(pwm->mask & 1 << index))
13427 + if (index < 0 || index >= PWM_NCHAN || !ch)
13429 + memset(ch, 0, sizeof *ch);
13431 + spin_lock_irqsave(&pwm->lock, flags);
13432 + if (pwm->channel[index])
13435 + clk_enable(pwm->clk);
13437 + ch->regs = pwmc_regs(pwm, index);
13438 + ch->index = index;
13440 + /* REVISIT: ap7000 seems to go 2x as fast as we expect!! */
13441 + ch->mck = clk_get_rate(pwm->clk);
13443 + pwm->channel[index] = ch;
13444 + pwm->handler[index] = NULL;
13446 + /* channel and irq are always disabled when we return */
13447 + pwm_writel(pwm, PWM_DIS, 1 << index);
13448 + pwm_writel(pwm, PWM_IDR, 1 << index);
13450 + spin_unlock_irqrestore(&pwm->lock, flags);
13453 +EXPORT_SYMBOL(pwm_channel_alloc);
13455 +static int pwmcheck(struct pwm_channel *ch)
13463 + index = ch->index;
13464 + if (index < 0 || index >= PWM_NCHAN || pwm->channel[index] != ch)
13471 + * pwm_channel_free - release a previously allocated channel
13472 + * @ch: the channel being released
13474 + * The channel is completely shut down (counter and IRQ disabled),
13475 + * and made available for re-use. Returns zero, or negative errno.
13477 +int pwm_channel_free(struct pwm_channel *ch)
13479 + unsigned long flags;
13482 + spin_lock_irqsave(&pwm->lock, flags);
13483 + t = pwmcheck(ch);
13485 + pwm->channel[t] = NULL;
13486 + pwm->handler[t] = NULL;
13488 + /* channel and irq are always disabled when we return */
13489 + pwm_writel(pwm, PWM_DIS, 1 << t);
13490 + pwm_writel(pwm, PWM_IDR, 1 << t);
13492 + clk_disable(pwm->clk);
13495 + spin_unlock_irqrestore(&pwm->lock, flags);
13498 +EXPORT_SYMBOL(pwm_channel_free);
13500 +int __pwm_channel_onoff(struct pwm_channel *ch, int enabled)
13502 + unsigned long flags;
13505 + /* OMITTED FUNCTIONALITY: starting several channels in synch */
13507 + spin_lock_irqsave(&pwm->lock, flags);
13508 + t = pwmcheck(ch);
13510 + pwm_writel(pwm, enabled ? PWM_ENA : PWM_DIS, 1 << t);
13512 + pwm_dumpregs(ch, enabled ? "enable" : "disable");
13514 + spin_unlock_irqrestore(&pwm->lock, flags);
13518 +EXPORT_SYMBOL(__pwm_channel_onoff);
13521 + * pwm_clk_alloc - allocate and configure CLKA or CLKB
13522 + * @prescale: from 0..10, the power of two used to divide MCK
13523 + * @div: from 1..255, the linear divisor to use
13525 + * Returns PWM_CPR_CLKA, PWM_CPR_CLKB, or negative errno. The allocated
13526 + * clock will run with a period of (2^prescale * div) / MCK, or twice as
13527 + * long if center aligned PWM output is used. The clock must later be
13528 + * deconfigured using pwm_clk_free().
13530 +int pwm_clk_alloc(unsigned prescale, unsigned div)
13532 + unsigned long flags;
13534 + u32 val = (prescale << 8) | div;
13535 + int ret = -EBUSY;
13537 + if (prescale >= 10 || div == 0 || div > 255)
13540 + spin_lock_irqsave(&pwm->lock, flags);
13541 + mr = pwm_readl(pwm, PWM_MR);
13542 + if ((mr & 0xffff) == 0) {
13544 + ret = PWM_CPR_CLKA;
13546 + if ((mr & (0xffff << 16)) == 0) {
13548 + ret = PWM_CPR_CLKB;
13551 + pwm_writel(pwm, PWM_MR, mr);
13552 + spin_unlock_irqrestore(&pwm->lock, flags);
13555 +EXPORT_SYMBOL(pwm_clk_alloc);
13558 + * pwm_clk_free - deconfigure and release CLKA or CLKB
13560 + * Reverses the effect of pwm_clk_alloc().
13562 +void pwm_clk_free(unsigned clk)
13564 + unsigned long flags;
13567 + spin_lock_irqsave(&pwm->lock, flags);
13568 + mr = pwm_readl(pwm, PWM_MR);
13569 + if (clk == PWM_CPR_CLKA)
13570 + pwm_writel(pwm, PWM_MR, mr & ~(0xffff << 0));
13571 + if (clk == PWM_CPR_CLKB)
13572 + pwm_writel(pwm, PWM_MR, mr & ~(0xffff << 16));
13573 + spin_unlock_irqrestore(&pwm->lock, flags);
13575 +EXPORT_SYMBOL(pwm_clk_free);
13578 + * pwm_channel_handler - manage channel's IRQ handler
13579 + * @ch: the channel
13580 + * @handler: the handler to use, possibly NULL
13582 + * If the handler is non-null, the handler will be called after every
13583 + * period of this PWM channel. If the handler is null, this channel
13584 + * won't generate an IRQ.
13586 +int pwm_channel_handler(struct pwm_channel *ch,
13587 + void (*handler)(struct pwm_channel *ch))
13589 + unsigned long flags;
13592 + spin_lock_irqsave(&pwm->lock, flags);
13593 + t = pwmcheck(ch);
13595 + pwm->handler[t] = handler;
13596 + pwm_writel(pwm, handler ? PWM_IER : PWM_IDR, 1 << t);
13599 + spin_unlock_irqrestore(&pwm->lock, flags);
13603 +EXPORT_SYMBOL(pwm_channel_handler);
13605 +static irqreturn_t pwm_irq(int id, void *_pwm)
13607 + struct pwm *p = _pwm;
13608 + irqreturn_t handled = IRQ_NONE;
13612 + spin_lock(&p->lock);
13614 + /* ack irqs, then handle them */
13615 + irqstat = pwm_readl(pwm, PWM_ISR);
13617 + while (irqstat) {
13618 + struct pwm_channel *ch;
13619 + void (*handler)(struct pwm_channel *ch);
13621 + index = ffs(irqstat) - 1;
13622 + irqstat &= ~(1 << index);
13623 + ch = pwm->channel[index];
13624 + handler = pwm->handler[index];
13625 + if (handler && ch) {
13626 + spin_unlock(&p->lock);
13628 + spin_lock(&p->lock);
13629 + handled = IRQ_HANDLED;
13633 + spin_unlock(&p->lock);
13637 +static int __init pwm_probe(struct platform_device *pdev)
13639 + struct resource *r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
13640 + int irq = platform_get_irq(pdev, 0);
13641 + u32 *mp = pdev->dev.platform_data;
13643 + int status = -EIO;
13647 + if (!r || irq < 0 || !mp || !*mp)
13649 + if (*mp & ~((1<<PWM_NCHAN)-1)) {
13650 + dev_warn(&pdev->dev, "mask 0x%x ... more than %d channels\n",
13655 + p = kzalloc(sizeof(*p), GFP_KERNEL);
13659 + spin_lock_init(&p->lock);
13663 + p->base = ioremap(r->start, r->end - r->start + 1);
13666 + p->clk = clk_get(&pdev->dev, "mck");
13667 + if (IS_ERR(p->clk)) {
13668 + status = PTR_ERR(p->clk);
13673 + status = request_irq(irq, pwm_irq, 0, pdev->name, p);
13678 + platform_set_drvdata(pdev, p);
13686 + iounmap(p->base);
13692 +static int __exit pwm_remove(struct platform_device *pdev)
13694 + struct pwm *p = platform_get_drvdata(pdev);
13699 + clk_enable(pwm->clk);
13700 + pwm_writel(pwm, PWM_DIS, (1 << PWM_NCHAN) - 1);
13701 + pwm_writel(pwm, PWM_IDR, (1 << PWM_NCHAN) - 1);
13702 + clk_disable(pwm->clk);
13706 + free_irq(p->irq, p);
13708 + iounmap(p->base);
13714 +static struct platform_driver atmel_pwm_driver = {
13716 + .name = "atmel_pwm",
13717 + .owner = THIS_MODULE,
13719 + .remove = __exit_p(pwm_remove),
13721 + /* NOTE: PWM can keep running in AVR32 "idle" and "frozen" states;
13722 + * and all AT91sam9263 states, albeit at reduced clock rate if
13723 + * MCK becomes the slow clock (i.e. what Linux labels STR).
13727 +static int __init pwm_init(void)
13729 + return platform_driver_probe(&atmel_pwm_driver, pwm_probe);
13731 +module_init(pwm_init);
13733 +static void __exit pwm_exit(void)
13735 + platform_driver_unregister(&atmel_pwm_driver);
13737 +module_exit(pwm_exit);
13739 +MODULE_DESCRIPTION("Driver for AT32/AT91 PWM module");
13740 +MODULE_LICENSE("GPL");
13742 +++ b/drivers/misc/atmel_tclib.c
13744 +#include <linux/atmel_tc.h>
13745 +#include <linux/clk.h>
13746 +#include <linux/err.h>
13747 +#include <linux/init.h>
13748 +#include <linux/io.h>
13749 +#include <linux/ioport.h>
13750 +#include <linux/kernel.h>
13751 +#include <linux/platform_device.h>
13753 +/* Number of bytes to reserve for the iomem resource */
13754 +#define ATMEL_TC_IOMEM_SIZE 256
13758 + * This is a thin library to solve the problem of how to portably allocate
13759 + * one of the TC blocks. For simplicity, it doesn't currently expect to
13760 + * share individual timers between different drivers.
13763 +#if defined(CONFIG_AVR32)
13764 +/* AVR32 has these divide PBB */
13765 +const u8 atmel_tc_divisors[5] = { 0, 4, 8, 16, 32, };
13766 +EXPORT_SYMBOL(atmel_tc_divisors);
13768 +#elif defined(CONFIG_ARCH_AT91)
13769 +/* AT91 has these divide MCK */
13770 +const u8 atmel_tc_divisors[5] = { 2, 8, 32, 128, 0, };
13771 +EXPORT_SYMBOL(atmel_tc_divisors);
13775 +static DEFINE_SPINLOCK(tc_list_lock);
13776 +static LIST_HEAD(tc_list);
13779 + * atmel_tc_alloc - allocate a specified TC block
13780 + * @block: which block to allocate
13781 + * @name: name to be associated with the iomem resource
13783 + * Caller allocates a block. If it is available, a pointer to a
13784 + * pre-initialized struct atmel_tc is returned. The caller can access
13785 + * the registers directly through the "regs" field.
13787 +struct atmel_tc *atmel_tc_alloc(unsigned block, const char *name)
13789 + struct atmel_tc *tc;
13790 + struct platform_device *pdev = NULL;
13791 + struct resource *r;
13793 + spin_lock(&tc_list_lock);
13794 + list_for_each_entry(tc, &tc_list, node) {
13795 + if (tc->pdev->id == block) {
13801 + if (!pdev || tc->iomem)
13804 + r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
13805 + r = request_mem_region(r->start, ATMEL_TC_IOMEM_SIZE, name);
13809 + tc->regs = ioremap(r->start, ATMEL_TC_IOMEM_SIZE);
13811 + goto fail_ioremap;
13816 + spin_unlock(&tc_list_lock);
13820 + release_resource(r);
13825 +EXPORT_SYMBOL_GPL(atmel_tc_alloc);
13828 + * atmel_tc_free - release a specified TC block
13829 + * @tc: Timer/counter block that was returned by atmel_tc_alloc()
13831 + * This reverses the effect of atmel_tc_alloc(), unmapping the I/O
13832 + * registers, invalidating the resource returned by that routine and
13833 + * making the TC available to other drivers.
13835 +void atmel_tc_free(struct atmel_tc *tc)
13837 + spin_lock(&tc_list_lock);
13839 + iounmap(tc->regs);
13840 + release_resource(tc->iomem);
13842 + tc->iomem = NULL;
13844 + spin_unlock(&tc_list_lock);
13846 +EXPORT_SYMBOL_GPL(atmel_tc_free);
13848 +static int __init tc_probe(struct platform_device *pdev)
13850 + struct atmel_tc *tc;
13854 + if (!platform_get_resource(pdev, IORESOURCE_MEM, 0))
13857 + irq = platform_get_irq(pdev, 0);
13861 + tc = kzalloc(sizeof(struct atmel_tc), GFP_KERNEL);
13867 + clk = clk_get(&pdev->dev, "t0_clk");
13868 + if (IS_ERR(clk)) {
13873 + tc->clk[0] = clk;
13874 + tc->clk[1] = clk_get(&pdev->dev, "t1_clk");
13875 + if (IS_ERR(tc->clk[1]))
13876 + tc->clk[1] = clk;
13877 + tc->clk[2] = clk_get(&pdev->dev, "t2_clk");
13878 + if (IS_ERR(tc->clk[2]))
13879 + tc->clk[2] = clk;
13881 + tc->irq[0] = irq;
13882 + tc->irq[1] = platform_get_irq(pdev, 1);
13883 + if (tc->irq[1] < 0)
13884 + tc->irq[1] = irq;
13885 + tc->irq[2] = platform_get_irq(pdev, 2);
13886 + if (tc->irq[2] < 0)
13887 + tc->irq[2] = irq;
13889 + spin_lock(&tc_list_lock);
13890 + list_add_tail(&tc->node, &tc_list);
13891 + spin_unlock(&tc_list_lock);
13896 +static struct platform_driver tc_driver = {
13897 + .driver.name = "atmel_tcb",
13900 +static int __init tc_init(void)
13902 + return platform_driver_probe(&tc_driver, tc_probe);
13904 +arch_initcall(tc_init);
13905 --- a/drivers/misc/Kconfig
13906 +++ b/drivers/misc/Kconfig
13912 + tristate "Atmel AT32/AT91 PWM support"
13913 + depends on AVR32 || ARCH_AT91
13915 + This option enables device driver support for the PWM channels
13916 + on certain Atmel prcoessors. Pulse Width Modulation is used for
13917 + purposes including software controlled power-efficent backlights
13918 + on LCD displays, motor control, and waveform generation.
13920 +config ATMEL_TCLIB
13921 + bool "Atmel AT32/AT91 Timer/Counter Library"
13922 + depends on (AVR32 || ARCH_AT91)
13924 + Select this if you want a library to allocate the Timer/Counter
13925 + blocks found on many Atmel processors. This facilitates using
13926 + these blocks by different drivers despite processor differences.
13928 +config ATMEL_TCB_CLKSRC
13929 + bool "TC Block Clocksource"
13930 + depends on ATMEL_TCLIB && GENERIC_TIME
13933 + Select this to get a high precision clocksource based on a
13934 + TC block with a 5+ MHz base clock rate. Two timer channels
13935 + are combined to make a single 32-bit timer.
13937 + When GENERIC_CLOCKEVENTS is defined, the third timer channel
13938 + may be used as a clock event device supporting oneshot mode
13939 + (delays of up to two seconds) based on the 32 KiHz clock.
13941 +config ATMEL_TCB_CLKSRC_BLOCK
13943 + depends on ATMEL_TCB_CLKSRC
13944 + prompt "TC Block" if ARCH_AT91RM9200 || ARCH_AT91SAM9260 || CPU_AT32AP700X
13948 + Some chips provide more than one TC block, so you have the
13949 + choice of which one to use for the clock framework. The other
13950 + TC can be used for other purposes, such as PWM generation and
13954 tristate "Device driver for IBM RSA service processor"
13955 depends on X86 && PCI && INPUT && EXPERIMENTAL
13956 --- a/drivers/misc/Makefile
13957 +++ b/drivers/misc/Makefile
13959 obj-$(CONFIG_HDPU_FEATURES) += hdpuftrs/
13960 obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o
13961 obj-$(CONFIG_ASUS_LAPTOP) += asus-laptop.o
13962 +obj-$(CONFIG_ATMEL_PWM) += atmel_pwm.o
13963 obj-$(CONFIG_ATMEL_SSC) += atmel-ssc.o
13964 +obj-$(CONFIG_ATMEL_TCLIB) += atmel_tclib.o
13965 obj-$(CONFIG_LKDTM) += lkdtm.o
13966 obj-$(CONFIG_TIFM_CORE) += tifm_core.o
13967 obj-$(CONFIG_TIFM_7XX1) += tifm_7xx1.o
13969 +++ b/drivers/mmc/host/atmel-mci.c
13972 + * Atmel MultiMedia Card Interface driver
13974 + * Copyright (C) 2004-2006 Atmel Corporation
13976 + * This program is free software; you can redistribute it and/or modify
13977 + * it under the terms of the GNU General Public License version 2 as
13978 + * published by the Free Software Foundation.
13980 +#include <linux/blkdev.h>
13981 +#include <linux/clk.h>
13982 +#include <linux/device.h>
13983 +#include <linux/dma-mapping.h>
13984 +#include <linux/init.h>
13985 +#include <linux/interrupt.h>
13986 +#include <linux/ioport.h>
13987 +#include <linux/module.h>
13988 +#include <linux/platform_device.h>
13990 +#include <linux/mmc/host.h>
13992 +#include <asm/dma-controller.h>
13993 +#include <asm/io.h>
13994 +#include <asm/arch/board.h>
13995 +#include <asm/arch/gpio.h>
13997 +#include "atmel-mci.h"
13999 +#define DRIVER_NAME "atmel_mci"
14001 +#define MCI_DATA_ERROR_FLAGS (MCI_BIT(DCRCE) | MCI_BIT(DTOE) | \
14002 + MCI_BIT(OVRE) | MCI_BIT(UNRE))
14005 + EVENT_CMD_COMPLETE = 0,
14006 + EVENT_DATA_COMPLETE,
14007 + EVENT_DATA_ERROR,
14009 + EVENT_STOP_COMPLETE,
14010 + EVENT_DMA_COMPLETE,
14014 +struct atmel_mci_dma {
14015 + struct dma_request_sg req;
14016 + unsigned short rx_periph_id;
14017 + unsigned short tx_periph_id;
14020 +struct atmel_mci {
14021 + struct mmc_host *mmc;
14022 + void __iomem *regs;
14023 + struct atmel_mci_dma dma;
14025 + struct mmc_request *mrq;
14026 + struct mmc_command *cmd;
14027 + struct mmc_data *data;
14034 + struct tasklet_struct tasklet;
14035 + unsigned long pending_events;
14036 + unsigned long completed_events;
14042 + /* For detect pin debouncing */
14043 + struct timer_list detect_timer;
14045 + unsigned long bus_hz;
14046 + unsigned long mapbase;
14048 + struct platform_device *pdev;
14050 +#ifdef CONFIG_DEBUG_FS
14051 + struct dentry *debugfs_root;
14052 + struct dentry *debugfs_regs;
14053 + struct dentry *debugfs_req;
14054 + struct dentry *debugfs_pending_events;
14055 + struct dentry *debugfs_completed_events;
14059 +/* Those printks take an awful lot of time... */
14061 +static unsigned int fmax = 15000000U;
14063 +static unsigned int fmax = 1000000U;
14065 +module_param(fmax, uint, 0444);
14066 +MODULE_PARM_DESC(fmax, "Max frequency in Hz of the MMC bus clock");
14068 +/* Test bit macros for completed events */
14069 +#define mci_cmd_is_complete(host) \
14070 + test_bit(EVENT_CMD_COMPLETE, &host->completed_events)
14071 +#define mci_data_is_complete(host) \
14072 + test_bit(EVENT_DATA_COMPLETE, &host->completed_events)
14073 +#define mci_data_error_is_complete(host) \
14074 + test_bit(EVENT_DATA_ERROR, &host->completed_events)
14075 +#define mci_stop_sent_is_complete(host) \
14076 + test_bit(EVENT_STOP_SENT, &host->completed_events)
14077 +#define mci_stop_is_complete(host) \
14078 + test_bit(EVENT_STOP_COMPLETE, &host->completed_events)
14079 +#define mci_dma_is_complete(host) \
14080 + test_bit(EVENT_DMA_COMPLETE, &host->completed_events)
14081 +#define mci_dma_error_is_complete(host) \
14082 + test_bit(EVENT_DMA_ERROR, &host->completed_events)
14084 +/* Test and clear bit macros for pending events */
14085 +#define mci_clear_cmd_is_pending(host) \
14086 + test_and_clear_bit(EVENT_CMD_COMPLETE, &host->pending_events)
14087 +#define mci_clear_data_is_pending(host) \
14088 + test_and_clear_bit(EVENT_DATA_COMPLETE, &host->pending_events)
14089 +#define mci_clear_data_error_is_pending(host) \
14090 + test_and_clear_bit(EVENT_DATA_ERROR, &host->pending_events)
14091 +#define mci_clear_stop_sent_is_pending(host) \
14092 + test_and_clear_bit(EVENT_STOP_SENT, &host->pending_events)
14093 +#define mci_clear_stop_is_pending(host) \
14094 + test_and_clear_bit(EVENT_STOP_COMPLETE, &host->pending_events)
14095 +#define mci_clear_dma_error_is_pending(host) \
14096 + test_and_clear_bit(EVENT_DMA_ERROR, &host->pending_events)
14098 +/* Test and set bit macros for completed events */
14099 +#define mci_set_cmd_is_completed(host) \
14100 + test_and_set_bit(EVENT_CMD_COMPLETE, &host->completed_events)
14101 +#define mci_set_data_is_completed(host) \
14102 + test_and_set_bit(EVENT_DATA_COMPLETE, &host->completed_events)
14103 +#define mci_set_data_error_is_completed(host) \
14104 + test_and_set_bit(EVENT_DATA_ERROR, &host->completed_events)
14105 +#define mci_set_stop_sent_is_completed(host) \
14106 + test_and_set_bit(EVENT_STOP_SENT, &host->completed_events)
14107 +#define mci_set_stop_is_completed(host) \
14108 + test_and_set_bit(EVENT_STOP_COMPLETE, &host->completed_events)
14109 +#define mci_set_dma_error_is_completed(host) \
14110 + test_and_set_bit(EVENT_DMA_ERROR, &host->completed_events)
14112 +/* Set bit macros for completed events */
14113 +#define mci_set_cmd_complete(host) \
14114 + set_bit(EVENT_CMD_COMPLETE, &host->completed_events)
14115 +#define mci_set_data_complete(host) \
14116 + set_bit(EVENT_DATA_COMPLETE, &host->completed_events)
14117 +#define mci_set_data_error_complete(host) \
14118 + set_bit(EVENT_DATA_ERROR, &host->completed_events)
14119 +#define mci_set_stop_sent_complete(host) \
14120 + set_bit(EVENT_STOP_SENT, &host->completed_events)
14121 +#define mci_set_stop_complete(host) \
14122 + set_bit(EVENT_STOP_COMPLETE, &host->completed_events)
14123 +#define mci_set_dma_complete(host) \
14124 + set_bit(EVENT_DMA_COMPLETE, &host->completed_events)
14125 +#define mci_set_dma_error_complete(host) \
14126 + set_bit(EVENT_DMA_ERROR, &host->completed_events)
14128 +/* Set bit macros for pending events */
14129 +#define mci_set_cmd_pending(host) \
14130 + set_bit(EVENT_CMD_COMPLETE, &host->pending_events)
14131 +#define mci_set_data_pending(host) \
14132 + set_bit(EVENT_DATA_COMPLETE, &host->pending_events)
14133 +#define mci_set_data_error_pending(host) \
14134 + set_bit(EVENT_DATA_ERROR, &host->pending_events)
14135 +#define mci_set_stop_sent_pending(host) \
14136 + set_bit(EVENT_STOP_SENT, &host->pending_events)
14137 +#define mci_set_stop_pending(host) \
14138 + set_bit(EVENT_STOP_COMPLETE, &host->pending_events)
14139 +#define mci_set_dma_error_pending(host) \
14140 + set_bit(EVENT_DMA_ERROR, &host->pending_events)
14142 +/* Clear bit macros for pending events */
14143 +#define mci_clear_cmd_pending(host) \
14144 + clear_bit(EVENT_CMD_COMPLETE, &host->pending_events)
14145 +#define mci_clear_data_pending(host) \
14146 + clear_bit(EVENT_DATA_COMPLETE, &host->pending_events)
14147 +#define mci_clear_data_error_pending(host) \
14148 + clear_bit(EVENT_DATA_ERROR, &host->pending_events)
14149 +#define mci_clear_stop_sent_pending(host) \
14150 + clear_bit(EVENT_STOP_SENT, &host->pending_events)
14151 +#define mci_clear_stop_pending(host) \
14152 + clear_bit(EVENT_STOP_COMPLETE, &host->pending_events)
14153 +#define mci_clear_dma_error_pending(host) \
14154 + clear_bit(EVENT_DMA_ERROR, &host->pending_events)
14157 +#ifdef CONFIG_DEBUG_FS
14158 +#include <linux/debugfs.h>
14160 +#define DBG_REQ_BUF_SIZE (4096 - sizeof(unsigned int))
14162 +struct req_dbg_data {
14163 + unsigned int nbytes;
14164 + char str[DBG_REQ_BUF_SIZE];
14167 +static int req_dbg_open(struct inode *inode, struct file *file)
14169 + struct atmel_mci *host;
14170 + struct mmc_request *mrq;
14171 + struct mmc_command *cmd, *stop;
14172 + struct mmc_data *data;
14173 + struct req_dbg_data *priv;
14175 + unsigned long n = 0;
14177 + priv = kzalloc(DBG_REQ_BUF_SIZE, GFP_KERNEL);
14182 + mutex_lock(&inode->i_mutex);
14183 + host = inode->i_private;
14185 + spin_lock_irq(&host->mmc->lock);
14189 + data = mrq->data;
14190 + stop = mrq->stop;
14191 + n = snprintf(str, DBG_REQ_BUF_SIZE,
14192 + "CMD%u(0x%x) %x %x %x %x %x (err %u)\n",
14193 + cmd->opcode, cmd->arg, cmd->flags,
14194 + cmd->resp[0], cmd->resp[1], cmd->resp[2],
14195 + cmd->resp[3], cmd->error);
14196 + if (n < DBG_REQ_BUF_SIZE && data)
14197 + n += snprintf(str + n, DBG_REQ_BUF_SIZE - n,
14198 + "DATA %u * %u (%u) %x (err %u)\n",
14199 + data->blocks, data->blksz,
14200 + data->bytes_xfered, data->flags,
14202 + if (n < DBG_REQ_BUF_SIZE && stop)
14203 + n += snprintf(str + n, DBG_REQ_BUF_SIZE - n,
14204 + "CMD%u(0x%x) %x %x %x %x %x (err %u)\n",
14205 + stop->opcode, stop->arg, stop->flags,
14206 + stop->resp[0], stop->resp[1],
14207 + stop->resp[2], stop->resp[3],
14210 + spin_unlock_irq(&host->mmc->lock);
14211 + mutex_unlock(&inode->i_mutex);
14213 + priv->nbytes = min(n, DBG_REQ_BUF_SIZE);
14214 + file->private_data = priv;
14219 +static ssize_t req_dbg_read(struct file *file, char __user *buf,
14220 + size_t nbytes, loff_t *ppos)
14222 + struct req_dbg_data *priv = file->private_data;
14224 + return simple_read_from_buffer(buf, nbytes, ppos,
14225 + priv->str, priv->nbytes);
14228 +static int req_dbg_release(struct inode *inode, struct file *file)
14230 + kfree(file->private_data);
14234 +static const struct file_operations req_dbg_fops = {
14235 + .owner = THIS_MODULE,
14236 + .open = req_dbg_open,
14237 + .llseek = no_llseek,
14238 + .read = req_dbg_read,
14239 + .release = req_dbg_release,
14242 +static int regs_dbg_open(struct inode *inode, struct file *file)
14244 + struct atmel_mci *host;
14247 + int ret = -ENOMEM;
14249 + mutex_lock(&inode->i_mutex);
14250 + host = inode->i_private;
14251 + data = kmalloc(inode->i_size, GFP_KERNEL);
14255 + spin_lock_irq(&host->mmc->lock);
14256 + for (i = 0; i < inode->i_size / 4; i++)
14257 + data[i] = __raw_readl(host->regs + i * 4);
14258 + spin_unlock_irq(&host->mmc->lock);
14260 + file->private_data = data;
14264 + mutex_unlock(&inode->i_mutex);
14269 +static ssize_t regs_dbg_read(struct file *file, char __user *buf,
14270 + size_t nbytes, loff_t *ppos)
14272 + struct inode *inode = file->f_dentry->d_inode;
14275 + mutex_lock(&inode->i_mutex);
14276 + ret = simple_read_from_buffer(buf, nbytes, ppos,
14277 + file->private_data,
14278 + file->f_dentry->d_inode->i_size);
14279 + mutex_unlock(&inode->i_mutex);
14284 +static int regs_dbg_release(struct inode *inode, struct file *file)
14286 + kfree(file->private_data);
14290 +static const struct file_operations regs_dbg_fops = {
14291 + .owner = THIS_MODULE,
14292 + .open = regs_dbg_open,
14293 + .llseek = generic_file_llseek,
14294 + .read = regs_dbg_read,
14295 + .release = regs_dbg_release,
14298 +static void atmci_init_debugfs(struct atmel_mci *host)
14300 + struct mmc_host *mmc;
14301 + struct dentry *root, *regs;
14302 + struct resource *res;
14305 + root = debugfs_create_dir(mmc_hostname(mmc), NULL);
14306 + if (IS_ERR(root) || !root)
14308 + host->debugfs_root = root;
14310 + regs = debugfs_create_file("regs", 0400, root, host, ®s_dbg_fops);
14314 + res = platform_get_resource(host->pdev, IORESOURCE_MEM, 0);
14315 + regs->d_inode->i_size = res->end - res->start + 1;
14316 + host->debugfs_regs = regs;
14318 + host->debugfs_req = debugfs_create_file("req", 0400, root,
14319 + host, &req_dbg_fops);
14320 + if (!host->debugfs_req)
14323 + host->debugfs_pending_events
14324 + = debugfs_create_u32("pending_events", 0400, root,
14325 + (u32 *)&host->pending_events);
14326 + if (!host->debugfs_pending_events)
14327 + goto err_pending_events;
14329 + host->debugfs_completed_events
14330 + = debugfs_create_u32("completed_events", 0400, root,
14331 + (u32 *)&host->completed_events);
14332 + if (!host->debugfs_completed_events)
14333 + goto err_completed_events;
14337 +err_completed_events:
14338 + debugfs_remove(host->debugfs_pending_events);
14339 +err_pending_events:
14340 + debugfs_remove(host->debugfs_req);
14342 + debugfs_remove(host->debugfs_regs);
14344 + debugfs_remove(host->debugfs_root);
14346 + host->debugfs_root = NULL;
14347 + dev_err(&host->pdev->dev,
14348 + "failed to initialize debugfs for %s\n",
14349 + mmc_hostname(mmc));
14352 +static void atmci_cleanup_debugfs(struct atmel_mci *host)
14354 + if (host->debugfs_root) {
14355 + debugfs_remove(host->debugfs_completed_events);
14356 + debugfs_remove(host->debugfs_pending_events);
14357 + debugfs_remove(host->debugfs_req);
14358 + debugfs_remove(host->debugfs_regs);
14359 + debugfs_remove(host->debugfs_root);
14360 + host->debugfs_root = NULL;
14364 +static inline void atmci_init_debugfs(struct atmel_mci *host)
14369 +static inline void atmci_cleanup_debugfs(struct atmel_mci *host)
14373 +#endif /* CONFIG_DEBUG_FS */
14375 +static inline unsigned int ns_to_clocks(struct atmel_mci *host,
14378 + return (ns * (host->bus_hz / 1000000) + 999) / 1000;
14381 +static void atmci_set_timeout(struct atmel_mci *host,
14382 + struct mmc_data *data)
14384 + static unsigned dtomul_to_shift[] = {
14385 + 0, 4, 7, 8, 10, 12, 16, 20
14387 + unsigned timeout;
14388 + unsigned dtocyc, dtomul;
14390 + timeout = ns_to_clocks(host, data->timeout_ns) + data->timeout_clks;
14392 + for (dtomul = 0; dtomul < 8; dtomul++) {
14393 + unsigned shift = dtomul_to_shift[dtomul];
14394 + dtocyc = (timeout + (1 << shift) - 1) >> shift;
14399 + if (dtomul >= 8) {
14404 + dev_dbg(&host->mmc->class_dev, "setting timeout to %u cycles\n",
14405 + dtocyc << dtomul_to_shift[dtomul]);
14406 + mci_writel(host, DTOR, (MCI_BF(DTOMUL, dtomul)
14407 + | MCI_BF(DTOCYC, dtocyc)));
14411 + * Return mask with command flags to be enabled for this command.
14413 +static u32 atmci_prepare_command(struct mmc_host *mmc,
14414 + struct mmc_command *cmd)
14420 + cmdr = MCI_BF(CMDNB, cmd->opcode);
14422 + if (cmd->flags & MMC_RSP_PRESENT) {
14423 + if (cmd->flags & MMC_RSP_136)
14424 + cmdr |= MCI_BF(RSPTYP, MCI_RSPTYP_136_BIT);
14426 + cmdr |= MCI_BF(RSPTYP, MCI_RSPTYP_48_BIT);
14430 + * This should really be MAXLAT_5 for CMD2 and ACMD41, but
14431 + * it's too difficult to determine whether this is an ACMD or
14432 + * not. Better make it 64.
14434 + cmdr |= MCI_BIT(MAXLAT);
14436 + if (mmc->ios.bus_mode == MMC_BUSMODE_OPENDRAIN)
14437 + cmdr |= MCI_BIT(OPDCMD);
14439 + dev_dbg(&mmc->class_dev,
14440 + "cmd: op %02x arg %08x flags %08x, cmdflags %08lx\n",
14441 + cmd->opcode, cmd->arg, cmd->flags, (unsigned long)cmdr);
14446 +static void atmci_start_command(struct atmel_mci *host,
14447 + struct mmc_command *cmd,
14450 + WARN_ON(host->cmd);
14453 + mci_writel(host, ARGR, cmd->arg);
14454 + mci_writel(host, CMDR, cmd_flags);
14457 + dma_start_request(host->dma.req.req.dmac,
14458 + host->dma.req.req.channel);
14462 + * Returns a mask of flags to be set in the command register when the
14463 + * command to start the transfer is to be sent.
14465 +static u32 atmci_prepare_data(struct mmc_host *mmc, struct mmc_data *data)
14467 + struct atmel_mci *host = mmc_priv(mmc);
14470 + WARN_ON(host->data);
14471 + host->data = data;
14473 + atmci_set_timeout(host, data);
14474 + mci_writel(host, BLKR, (MCI_BF(BCNT, data->blocks)
14475 + | MCI_BF(BLKLEN, data->blksz)));
14476 + host->dma.req.block_size = data->blksz;
14477 + host->dma.req.nr_blocks = data->blocks;
14479 + cmd_flags = MCI_BF(TRCMD, MCI_TRCMD_START_TRANS);
14480 + if (data->flags & MMC_DATA_STREAM)
14481 + cmd_flags |= MCI_BF(TRTYP, MCI_TRTYP_STREAM);
14482 + else if (data->blocks > 1)
14483 + cmd_flags |= MCI_BF(TRTYP, MCI_TRTYP_MULTI_BLOCK);
14485 + cmd_flags |= MCI_BF(TRTYP, MCI_TRTYP_BLOCK);
14487 + if (data->flags & MMC_DATA_READ) {
14488 + cmd_flags |= MCI_BIT(TRDIR);
14489 + host->dma.req.nr_sg
14490 + = dma_map_sg(&host->pdev->dev, data->sg,
14491 + data->sg_len, DMA_FROM_DEVICE);
14492 + host->dma.req.periph_id = host->dma.rx_periph_id;
14493 + host->dma.req.direction = DMA_DIR_PERIPH_TO_MEM;
14494 + host->dma.req.data_reg = host->mapbase + MCI_RDR;
14496 + host->dma.req.nr_sg
14497 + = dma_map_sg(&host->pdev->dev, data->sg,
14498 + data->sg_len, DMA_TO_DEVICE);
14499 + host->dma.req.periph_id = host->dma.tx_periph_id;
14500 + host->dma.req.direction = DMA_DIR_MEM_TO_PERIPH;
14501 + host->dma.req.data_reg = host->mapbase + MCI_TDR;
14503 + host->dma.req.sg = data->sg;
14505 + dma_prepare_request_sg(host->dma.req.req.dmac, &host->dma.req);
14507 + return cmd_flags;
14510 +static void atmci_request(struct mmc_host *mmc, struct mmc_request *mrq)
14512 + struct atmel_mci *host = mmc_priv(mmc);
14513 + struct mmc_data *data = mrq->data;
14515 + u32 cmdflags = 0;
14517 + iflags = mci_readl(host, IMR);
14519 + dev_warn(&mmc->class_dev, "WARNING: IMR=0x%08x\n",
14520 + mci_readl(host, IMR));
14522 + WARN_ON(host->mrq != NULL);
14525 + * We may "know" the card is gone even though there's still an
14526 + * electrical connection. If so, we really need to communicate
14527 + * this to the MMC core since there won't be any more
14528 + * interrupts as the card is completely removed. Otherwise,
14529 + * the MMC core might believe the card is still there even
14530 + * though the card was just removed very slowly.
14532 + if (!host->present) {
14533 + mrq->cmd->error = -ENOMEDIUM;
14534 + mmc_request_done(mmc, mrq);
14539 + host->pending_events = 0;
14540 + host->completed_events = 0;
14542 + iflags = MCI_BIT(CMDRDY);
14543 + cmdflags = atmci_prepare_command(mmc, mrq->cmd);
14548 + host->stop_cmdr = atmci_prepare_command(mmc, mrq->stop);
14549 + host->stop_cmdr |= MCI_BF(TRCMD, MCI_TRCMD_STOP_TRANS);
14550 + if (!(data->flags & MMC_DATA_WRITE))
14551 + host->stop_cmdr |= MCI_BIT(TRDIR);
14552 + if (data->flags & MMC_DATA_STREAM)
14553 + host->stop_cmdr |= MCI_BF(TRTYP, MCI_TRTYP_STREAM);
14555 + host->stop_cmdr |= MCI_BF(TRTYP, MCI_TRTYP_MULTI_BLOCK);
14558 + cmdflags |= atmci_prepare_data(mmc, data);
14559 + iflags |= MCI_DATA_ERROR_FLAGS;
14562 + atmci_start_command(host, mrq->cmd, cmdflags);
14563 + mci_writel(host, IER, iflags);
14566 +static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
14568 + struct atmel_mci *host = mmc_priv(mmc);
14571 + if (ios->clock) {
14574 + /* Set clock rate */
14575 + clkdiv = DIV_ROUND_UP(host->bus_hz, 2 * ios->clock) - 1;
14576 + if (clkdiv > 255) {
14577 + dev_warn(&mmc->class_dev,
14578 + "clock %u too slow; using %lu\n",
14579 + ios->clock, host->bus_hz / (2 * 256));
14583 + mr = mci_readl(host, MR);
14584 + mr = MCI_BFINS(CLKDIV, clkdiv, mr)
14585 + | MCI_BIT(WRPROOF) | MCI_BIT(RDPROOF);
14586 + mci_writel(host, MR, mr);
14588 + /* Enable the MCI controller */
14589 + mci_writel(host, CR, MCI_BIT(MCIEN));
14591 + /* Disable the MCI controller */
14592 + mci_writel(host, CR, MCI_BIT(MCIDIS));
14595 + switch (ios->bus_width) {
14596 + case MMC_BUS_WIDTH_1:
14597 + mci_writel(host, SDCR, 0);
14599 + case MMC_BUS_WIDTH_4:
14600 + mci_writel(host, SDCR, MCI_BIT(SDCBUS));
14604 + switch (ios->power_mode) {
14605 + case MMC_POWER_ON:
14606 + /* Send init sequence (74 clock cycles) */
14607 + mci_writel(host, IDR, ~0UL);
14608 + mci_writel(host, CMDR, MCI_BF(SPCMD, MCI_SPCMD_INIT_CMD));
14609 + while (!(mci_readl(host, SR) & MCI_BIT(CMDRDY)))
14614 + * TODO: None of the currently available AVR32-based
14615 + * boards allow MMC power to be turned off. Implement
14616 + * power control when this can be tested properly.
14622 +static int atmci_get_ro(struct mmc_host *mmc)
14624 + int read_only = 0;
14625 + struct atmel_mci *host = mmc_priv(mmc);
14627 + if (host->wp_pin >= 0) {
14628 + read_only = gpio_get_value(host->wp_pin);
14629 + dev_dbg(&mmc->class_dev, "card is %s\n",
14630 + read_only ? "read-only" : "read-write");
14632 + dev_dbg(&mmc->class_dev,
14633 + "no pin for checking read-only switch."
14634 + " Assuming write-enable.\n");
14637 + return read_only;
14640 +static struct mmc_host_ops atmci_ops = {
14641 + .request = atmci_request,
14642 + .set_ios = atmci_set_ios,
14643 + .get_ro = atmci_get_ro,
14646 +static void atmci_request_end(struct mmc_host *mmc, struct mmc_request *mrq)
14648 + struct atmel_mci *host = mmc_priv(mmc);
14650 + WARN_ON(host->cmd || host->data);
14651 + host->mrq = NULL;
14653 + mmc_request_done(mmc, mrq);
14656 +static void send_stop_cmd(struct mmc_host *mmc, struct mmc_data *data,
14659 + struct atmel_mci *host = mmc_priv(mmc);
14661 + atmci_start_command(host, data->stop, host->stop_cmdr | flags);
14662 + mci_writel(host, IER, MCI_BIT(CMDRDY));
14665 +static void atmci_data_complete(struct atmel_mci *host, struct mmc_data *data)
14667 + host->data = NULL;
14668 + dma_unmap_sg(&host->pdev->dev, data->sg, host->dma.req.nr_sg,
14669 + ((data->flags & MMC_DATA_WRITE)
14670 + ? DMA_TO_DEVICE : DMA_FROM_DEVICE));
14673 + * Data might complete before command for very short transfers
14674 + * (like READ_SCR)
14676 + if (mci_cmd_is_complete(host)
14677 + && (!data->stop || mci_stop_is_complete(host)))
14678 + atmci_request_end(host->mmc, data->mrq);
14681 +static void atmci_command_complete(struct atmel_mci *host,
14682 + struct mmc_command *cmd, u32 status)
14684 + if (status & MCI_BIT(RTOE))
14685 + cmd->error = -ETIMEDOUT;
14686 + else if ((cmd->flags & MMC_RSP_CRC)
14687 + && (status & MCI_BIT(RCRCE)))
14688 + cmd->error = -EILSEQ;
14689 + else if (status & (MCI_BIT(RINDE) | MCI_BIT(RDIRE) | MCI_BIT(RENDE)))
14690 + cmd->error = -EIO;
14692 + if (cmd->error) {
14693 + dev_dbg(&host->mmc->class_dev,
14694 + "command error: op=0x%x status=0x%08x\n",
14695 + cmd->opcode, status);
14698 + dma_stop_request(host->dma.req.req.dmac,
14699 + host->dma.req.req.channel);
14700 + mci_writel(host, IDR, MCI_BIT(NOTBUSY)
14701 + | MCI_DATA_ERROR_FLAGS);
14702 + host->data = NULL;
14707 +static void atmci_detect_change(unsigned long data)
14709 + struct atmel_mci *host = (struct atmel_mci *)data;
14710 + struct mmc_request *mrq = host->mrq;
14714 + * atmci_remove() sets detect_pin to -1 before freeing the
14715 + * interrupt. We must not re-enable the interrupt if it has
14719 + if (host->detect_pin < 0)
14722 + enable_irq(gpio_to_irq(host->detect_pin));
14723 + present = !gpio_get_value(host->detect_pin);
14725 + dev_vdbg(&host->pdev->dev, "detect change: %d (was %d)\n",
14726 + present, host->present);
14728 + if (present != host->present) {
14729 + dev_dbg(&host->mmc->class_dev, "card %s\n",
14730 + present ? "inserted" : "removed");
14731 + host->present = present;
14733 + /* Reset controller if card is gone */
14735 + mci_writel(host, CR, MCI_BIT(SWRST));
14736 + mci_writel(host, IDR, ~0UL);
14737 + mci_writel(host, CR, MCI_BIT(MCIEN));
14740 + /* Clean up queue if present */
14742 + if (!mci_cmd_is_complete(host))
14743 + mrq->cmd->error = -ENOMEDIUM;
14744 + if (mrq->data && !mci_data_is_complete(host)
14745 + && !mci_data_error_is_complete(host)) {
14746 + dma_stop_request(host->dma.req.req.dmac,
14747 + host->dma.req.req.channel);
14748 + host->data->error = -ENOMEDIUM;
14749 + atmci_data_complete(host, host->data);
14751 + if (mrq->stop && !mci_stop_is_complete(host))
14752 + mrq->stop->error = -ENOMEDIUM;
14754 + host->cmd = NULL;
14755 + atmci_request_end(host->mmc, mrq);
14758 + mmc_detect_change(host->mmc, 0);
14762 +static void atmci_tasklet_func(unsigned long priv)
14764 + struct mmc_host *mmc = (struct mmc_host *)priv;
14765 + struct atmel_mci *host = mmc_priv(mmc);
14766 + struct mmc_request *mrq = host->mrq;
14767 + struct mmc_data *data = host->data;
14769 + dev_vdbg(&mmc->class_dev,
14770 + "tasklet: pending/completed/mask %lx/%lx/%x\n",
14771 + host->pending_events, host->completed_events,
14772 + mci_readl(host, IMR));
14774 + if (mci_clear_cmd_is_pending(host)) {
14775 + mci_set_cmd_complete(host);
14776 + atmci_command_complete(host, mrq->cmd, host->cmd_status);
14777 + if (!host->data || mci_data_is_complete(host)
14778 + || mci_data_error_is_complete(host))
14779 + atmci_request_end(mmc, mrq);
14781 + if (mci_clear_stop_is_pending(host)) {
14782 + mci_set_stop_complete(host);
14783 + atmci_command_complete(host, mrq->stop, host->stop_status);
14784 + if (mci_data_is_complete(host)
14785 + || mci_data_error_is_complete(host))
14786 + atmci_request_end(mmc, mrq);
14788 + if (mci_clear_dma_error_is_pending(host)) {
14789 + mci_set_dma_error_complete(host);
14790 + mci_clear_data_pending(host);
14792 + /* DMA controller got bus error => invalid address */
14793 + data->error = -EIO;
14795 + dev_dbg(&mmc->class_dev, "dma error after %u bytes xfered\n",
14796 + host->data->bytes_xfered);
14799 + && !mci_set_stop_sent_is_completed(host))
14800 + /* TODO: Check if card is still present */
14801 + send_stop_cmd(host->mmc, data, 0);
14803 + atmci_data_complete(host, data);
14805 + if (mci_clear_data_error_is_pending(host)) {
14806 + u32 status = host->data_status;
14808 + mci_set_data_error_complete(host);
14809 + mci_clear_data_pending(host);
14811 + dma_stop_request(host->dma.req.req.dmac,
14812 + host->dma.req.req.channel);
14814 + if (status & MCI_BIT(DCRCE)) {
14815 + dev_dbg(&mmc->class_dev, "data CRC error\n");
14816 + data->error = -EILSEQ;
14817 + } else if (status & MCI_BIT(DTOE)) {
14818 + dev_dbg(&mmc->class_dev, "data timeout error\n");
14819 + data->error = -ETIMEDOUT;
14821 + dev_dbg(&mmc->class_dev, "data FIFO error\n");
14822 + data->error = -EIO;
14824 + dev_dbg(&mmc->class_dev, "bytes xfered: %u\n",
14825 + data->bytes_xfered);
14828 + && !mci_set_stop_sent_is_completed(host))
14829 + /* TODO: Check if card is still present */
14830 + send_stop_cmd(host->mmc, data, 0);
14832 + atmci_data_complete(host, data);
14834 + if (mci_clear_data_is_pending(host)) {
14835 + mci_set_data_complete(host);
14836 + data->bytes_xfered = data->blocks * data->blksz;
14837 + atmci_data_complete(host, data);
14841 +static void atmci_cmd_interrupt(struct mmc_host *mmc, u32 status)
14843 + struct atmel_mci *host = mmc_priv(mmc);
14844 + struct mmc_command *cmd = host->cmd;
14847 + * Read the response now so that we're free to send a new
14848 + * command immediately.
14850 + cmd->resp[0] = mci_readl(host, RSPR);
14851 + cmd->resp[1] = mci_readl(host, RSPR);
14852 + cmd->resp[2] = mci_readl(host, RSPR);
14853 + cmd->resp[3] = mci_readl(host, RSPR);
14855 + mci_writel(host, IDR, MCI_BIT(CMDRDY));
14856 + host->cmd = NULL;
14858 + if (mci_stop_sent_is_complete(host)) {
14859 + host->stop_status = status;
14860 + mci_set_stop_pending(host);
14862 + struct mmc_request *mrq = host->mrq;
14864 + if (mrq->stop && mci_dma_is_complete(host)
14865 + && !mci_set_stop_sent_is_completed(host))
14866 + send_stop_cmd(host->mmc, mrq->data, 0);
14867 + host->cmd_status = status;
14868 + mci_set_cmd_pending(host);
14871 + tasklet_schedule(&host->tasklet);
14874 +static void atmci_xfer_complete(struct dma_request *_req)
14876 + struct dma_request_sg *req = to_dma_request_sg(_req);
14877 + struct atmel_mci_dma *dma;
14878 + struct atmel_mci *host;
14879 + struct mmc_data *data;
14881 + dma = container_of(req, struct atmel_mci_dma, req);
14882 + host = container_of(dma, struct atmel_mci, dma);
14883 + data = host->data;
14886 + * This callback may be called before we see the CMDRDY
14887 + * interrupt under heavy irq load (possibly caused by other
14888 + * drivers) or when interrupts are disabled for a long time.
14890 + mci_set_dma_complete(host);
14891 + if (data->stop && mci_cmd_is_complete(host)
14892 + && !mci_set_stop_sent_is_completed(host))
14893 + send_stop_cmd(host->mmc, data, 0);
14896 + * Regardless of what the documentation says, we have to wait
14897 + * for NOTBUSY even after block read operations.
14899 + * When the DMA transfer is complete, the controller may still
14900 + * be reading the CRC from the card, i.e. the data transfer is
14901 + * still in progress and we haven't seen all the potential
14902 + * error bits yet.
14904 + mci_writel(host, IER, MCI_BIT(NOTBUSY));
14907 +static void atmci_dma_error(struct dma_request *_req)
14909 + struct dma_request_sg *req = to_dma_request_sg(_req);
14910 + struct atmel_mci_dma *dma;
14911 + struct atmel_mci *host;
14913 + dma = container_of(req, struct atmel_mci_dma, req);
14914 + host = container_of(dma, struct atmel_mci, dma);
14916 + mci_writel(host, IDR, (MCI_BIT(NOTBUSY)
14917 + | MCI_DATA_ERROR_FLAGS));
14919 + mci_set_dma_error_pending(host);
14920 + tasklet_schedule(&host->tasklet);
14923 +static irqreturn_t atmci_interrupt(int irq, void *dev_id)
14925 + struct mmc_host *mmc = dev_id;
14926 + struct atmel_mci *host = mmc_priv(mmc);
14927 + u32 status, mask, pending;
14929 + spin_lock(&mmc->lock);
14931 + status = mci_readl(host, SR);
14932 + mask = mci_readl(host, IMR);
14933 + pending = status & mask;
14936 + if (pending & MCI_DATA_ERROR_FLAGS) {
14937 + mci_writel(host, IDR, (MCI_BIT(NOTBUSY)
14938 + | MCI_DATA_ERROR_FLAGS));
14939 + host->data_status = status;
14940 + mci_set_data_error_pending(host);
14941 + tasklet_schedule(&host->tasklet);
14944 + if (pending & MCI_BIT(CMDRDY))
14945 + atmci_cmd_interrupt(mmc, status);
14946 + if (pending & MCI_BIT(NOTBUSY)) {
14947 + mci_writel(host, IDR, (MCI_BIT(NOTBUSY)
14948 + | MCI_DATA_ERROR_FLAGS));
14949 + mci_set_data_pending(host);
14950 + tasklet_schedule(&host->tasklet);
14953 + status = mci_readl(host, SR);
14954 + mask = mci_readl(host, IMR);
14955 + pending = status & mask;
14956 + } while (pending);
14958 + spin_unlock(&mmc->lock);
14960 + return IRQ_HANDLED;
14963 +static irqreturn_t atmci_detect_interrupt(int irq, void *dev_id)
14965 + struct mmc_host *mmc = dev_id;
14966 + struct atmel_mci *host = mmc_priv(mmc);
14969 + * Disable interrupts until the pin has stabilized and check
14970 + * the state then. Use mod_timer() since we may be in the
14971 + * middle of the timer routine when this interrupt triggers.
14973 + disable_irq_nosync(irq);
14974 + mod_timer(&host->detect_timer, jiffies + msecs_to_jiffies(20));
14976 + return IRQ_HANDLED;
14979 +static int __devinit atmci_probe(struct platform_device *pdev)
14981 + struct mci_platform_data *board;
14982 + struct atmel_mci *host;
14983 + struct mmc_host *mmc;
14984 + struct resource *regs;
14988 + regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
14991 + irq = platform_get_irq(pdev, 0);
14995 + board = pdev->dev.platform_data;
14997 + mmc = mmc_alloc_host(sizeof(struct atmel_mci), &pdev->dev);
15001 + host = mmc_priv(mmc);
15002 + host->pdev = pdev;
15005 + host->detect_pin = board->detect_pin;
15006 + host->wp_pin = board->wp_pin;
15008 + host->detect_pin = -1;
15009 + host->wp_pin = -1;
15012 + host->mck = clk_get(&pdev->dev, "mci_clk");
15013 + if (IS_ERR(host->mck)) {
15014 + ret = PTR_ERR(host->mck);
15015 + goto out_free_host;
15017 + clk_enable(host->mck);
15020 + host->regs = ioremap(regs->start, regs->end - regs->start + 1);
15022 + goto out_disable_clk;
15024 + host->bus_hz = clk_get_rate(host->mck);
15025 + host->mapbase = regs->start;
15027 + mmc->ops = &atmci_ops;
15028 + mmc->f_min = (host->bus_hz + 511) / 512;
15029 + mmc->f_max = min((unsigned int)(host->bus_hz / 2), fmax);
15030 + mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
15031 + mmc->caps |= MMC_CAP_4_BIT_DATA;
15033 + tasklet_init(&host->tasklet, atmci_tasklet_func, (unsigned long)mmc);
15035 + ret = request_irq(irq, atmci_interrupt, 0, "mmci", mmc);
15039 + /* Assume card is present if we don't have a detect pin */
15040 + host->present = 1;
15041 + if (host->detect_pin >= 0) {
15042 + if (gpio_request(host->detect_pin, "mmc_detect")) {
15043 + dev_dbg(&mmc->class_dev, "no detect pin available\n");
15044 + host->detect_pin = -1;
15046 + host->present = !gpio_get_value(host->detect_pin);
15049 + if (host->wp_pin >= 0) {
15050 + if (gpio_request(host->wp_pin, "mmc_wp")) {
15051 + dev_dbg(&mmc->class_dev, "no WP pin available\n");
15052 + host->wp_pin = -1;
15056 + /* TODO: Get this information from platform data */
15058 + host->dma.req.req.dmac = find_dma_controller(0);
15059 + if (!host->dma.req.req.dmac) {
15060 + dev_dbg(&mmc->class_dev, "no DMA controller available\n");
15061 + goto out_free_irq;
15063 + ret = dma_alloc_channel(host->dma.req.req.dmac);
15065 + dev_dbg(&mmc->class_dev, "unable to allocate DMA channel\n");
15066 + goto out_free_irq;
15068 + host->dma.req.req.channel = ret;
15069 + host->dma.req.width = DMA_WIDTH_32BIT;
15070 + host->dma.req.req.xfer_complete = atmci_xfer_complete;
15071 + host->dma.req.req.block_complete = NULL; // atmci_block_complete;
15072 + host->dma.req.req.error = atmci_dma_error;
15073 + host->dma.rx_periph_id = 0;
15074 + host->dma.tx_periph_id = 1;
15076 + mci_writel(host, CR, MCI_BIT(SWRST));
15077 + mci_writel(host, IDR, ~0UL);
15079 + platform_set_drvdata(pdev, host);
15081 + mmc_add_host(mmc);
15083 + if (host->detect_pin >= 0) {
15084 + setup_timer(&host->detect_timer, atmci_detect_change,
15085 + (unsigned long)host);
15087 + ret = request_irq(gpio_to_irq(host->detect_pin),
15088 + atmci_detect_interrupt,
15089 + IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
15090 + DRIVER_NAME, mmc);
15092 + dev_dbg(&mmc->class_dev,
15093 + "could not request IRQ %d for detect pin\n",
15094 + gpio_to_irq(host->detect_pin));
15095 + gpio_free(host->detect_pin);
15096 + host->detect_pin = -1;
15100 + dev_info(&mmc->class_dev, "Atmel MCI controller at 0x%08lx irq %d\n",
15101 + host->mapbase, irq);
15103 + atmci_init_debugfs(host);
15108 + if (host->detect_pin >= 0)
15109 + gpio_free(host->detect_pin);
15110 + if (host->wp_pin >= 0)
15111 + gpio_free(host->wp_pin);
15112 + free_irq(irq, mmc);
15114 + iounmap(host->regs);
15116 + clk_disable(host->mck);
15117 + clk_put(host->mck);
15119 + mmc_free_host(mmc);
15123 +static int __devexit atmci_remove(struct platform_device *pdev)
15125 + struct atmel_mci *host = platform_get_drvdata(pdev);
15127 + platform_set_drvdata(pdev, NULL);
15130 + atmci_cleanup_debugfs(host);
15132 + if (host->detect_pin >= 0) {
15133 + int pin = host->detect_pin;
15135 + /* Make sure our timer doesn't enable the interrupt */
15136 + host->detect_pin = -1;
15139 + free_irq(gpio_to_irq(pin), host->mmc);
15140 + del_timer_sync(&host->detect_timer);
15141 + cancel_delayed_work(&host->mmc->detect);
15145 + mmc_remove_host(host->mmc);
15147 + mci_writel(host, IDR, ~0UL);
15148 + mci_writel(host, CR, MCI_BIT(MCIDIS));
15149 + mci_readl(host, SR);
15151 + dma_release_channel(host->dma.req.req.dmac,
15152 + host->dma.req.req.channel);
15154 + if (host->wp_pin >= 0)
15155 + gpio_free(host->wp_pin);
15157 + free_irq(platform_get_irq(pdev, 0), host->mmc);
15158 + iounmap(host->regs);
15160 + clk_disable(host->mck);
15161 + clk_put(host->mck);
15163 + mmc_free_host(host->mmc);
15168 +static struct platform_driver atmci_driver = {
15169 + .probe = atmci_probe,
15170 + .remove = __devexit_p(atmci_remove),
15172 + .name = DRIVER_NAME,
15176 +static int __init atmci_init(void)
15178 + return platform_driver_register(&atmci_driver);
15181 +static void __exit atmci_exit(void)
15183 + platform_driver_unregister(&atmci_driver);
15186 +module_init(atmci_init);
15187 +module_exit(atmci_exit);
15189 +MODULE_DESCRIPTION("Atmel Multimedia Card Interface driver");
15190 +MODULE_LICENSE("GPL");
15192 +++ b/drivers/mmc/host/atmel-mci.h
15195 + * Atmel MultiMedia Card Interface driver
15197 + * Copyright (C) 2004-2006 Atmel Corporation
15199 + * This program is free software; you can redistribute it and/or modify
15200 + * it under the terms of the GNU General Public License version 2 as
15201 + * published by the Free Software Foundation.
15203 +#ifndef __DRIVERS_MMC_ATMEL_MCI_H__
15204 +#define __DRIVERS_MMC_ATMEL_MCI_H__
15206 +/* MCI register offsets */
15207 +#define MCI_CR 0x0000
15208 +#define MCI_MR 0x0004
15209 +#define MCI_DTOR 0x0008
15210 +#define MCI_SDCR 0x000c
15211 +#define MCI_ARGR 0x0010
15212 +#define MCI_CMDR 0x0014
15213 +#define MCI_BLKR 0x0018
15214 +#define MCI_RSPR 0x0020
15215 +#define MCI_RSPR1 0x0024
15216 +#define MCI_RSPR2 0x0028
15217 +#define MCI_RSPR3 0x002c
15218 +#define MCI_RDR 0x0030
15219 +#define MCI_TDR 0x0034
15220 +#define MCI_SR 0x0040
15221 +#define MCI_IER 0x0044
15222 +#define MCI_IDR 0x0048
15223 +#define MCI_IMR 0x004c
15225 +/* Bitfields in CR */
15226 +#define MCI_MCIEN_OFFSET 0
15227 +#define MCI_MCIEN_SIZE 1
15228 +#define MCI_MCIDIS_OFFSET 1
15229 +#define MCI_MCIDIS_SIZE 1
15230 +#define MCI_PWSEN_OFFSET 2
15231 +#define MCI_PWSEN_SIZE 1
15232 +#define MCI_PWSDIS_OFFSET 3
15233 +#define MCI_PWSDIS_SIZE 1
15234 +#define MCI_SWRST_OFFSET 7
15235 +#define MCI_SWRST_SIZE 1
15237 +/* Bitfields in MR */
15238 +#define MCI_CLKDIV_OFFSET 0
15239 +#define MCI_CLKDIV_SIZE 8
15240 +#define MCI_PWSDIV_OFFSET 8
15241 +#define MCI_PWSDIV_SIZE 3
15242 +#define MCI_RDPROOF_OFFSET 11
15243 +#define MCI_RDPROOF_SIZE 1
15244 +#define MCI_WRPROOF_OFFSET 12
15245 +#define MCI_WRPROOF_SIZE 1
15246 +#define MCI_DMAPADV_OFFSET 14
15247 +#define MCI_DMAPADV_SIZE 1
15248 +#define MCI_BLKLEN_OFFSET 16
15249 +#define MCI_BLKLEN_SIZE 16
15251 +/* Bitfields in DTOR */
15252 +#define MCI_DTOCYC_OFFSET 0
15253 +#define MCI_DTOCYC_SIZE 4
15254 +#define MCI_DTOMUL_OFFSET 4
15255 +#define MCI_DTOMUL_SIZE 3
15257 +/* Bitfields in SDCR */
15258 +#define MCI_SDCSEL_OFFSET 0
15259 +#define MCI_SDCSEL_SIZE 4
15260 +#define MCI_SDCBUS_OFFSET 7
15261 +#define MCI_SDCBUS_SIZE 1
15263 +/* Bitfields in ARGR */
15264 +#define MCI_ARG_OFFSET 0
15265 +#define MCI_ARG_SIZE 32
15267 +/* Bitfields in CMDR */
15268 +#define MCI_CMDNB_OFFSET 0
15269 +#define MCI_CMDNB_SIZE 6
15270 +#define MCI_RSPTYP_OFFSET 6
15271 +#define MCI_RSPTYP_SIZE 2
15272 +#define MCI_SPCMD_OFFSET 8
15273 +#define MCI_SPCMD_SIZE 3
15274 +#define MCI_OPDCMD_OFFSET 11
15275 +#define MCI_OPDCMD_SIZE 1
15276 +#define MCI_MAXLAT_OFFSET 12
15277 +#define MCI_MAXLAT_SIZE 1
15278 +#define MCI_TRCMD_OFFSET 16
15279 +#define MCI_TRCMD_SIZE 2
15280 +#define MCI_TRDIR_OFFSET 18
15281 +#define MCI_TRDIR_SIZE 1
15282 +#define MCI_TRTYP_OFFSET 19
15283 +#define MCI_TRTYP_SIZE 2
15285 +/* Bitfields in BLKR */
15286 +#define MCI_BCNT_OFFSET 0
15287 +#define MCI_BCNT_SIZE 16
15289 +/* Bitfields in RSPRn */
15290 +#define MCI_RSP_OFFSET 0
15291 +#define MCI_RSP_SIZE 32
15293 +/* Bitfields in SR/IER/IDR/IMR */
15294 +#define MCI_CMDRDY_OFFSET 0
15295 +#define MCI_CMDRDY_SIZE 1
15296 +#define MCI_RXRDY_OFFSET 1
15297 +#define MCI_RXRDY_SIZE 1
15298 +#define MCI_TXRDY_OFFSET 2
15299 +#define MCI_TXRDY_SIZE 1
15300 +#define MCI_BLKE_OFFSET 3
15301 +#define MCI_BLKE_SIZE 1
15302 +#define MCI_DTIP_OFFSET 4
15303 +#define MCI_DTIP_SIZE 1
15304 +#define MCI_NOTBUSY_OFFSET 5
15305 +#define MCI_NOTBUSY_SIZE 1
15306 +#define MCI_ENDRX_OFFSET 6
15307 +#define MCI_ENDRX_SIZE 1
15308 +#define MCI_ENDTX_OFFSET 7
15309 +#define MCI_ENDTX_SIZE 1
15310 +#define MCI_RXBUFF_OFFSET 14
15311 +#define MCI_RXBUFF_SIZE 1
15312 +#define MCI_TXBUFE_OFFSET 15
15313 +#define MCI_TXBUFE_SIZE 1
15314 +#define MCI_RINDE_OFFSET 16
15315 +#define MCI_RINDE_SIZE 1
15316 +#define MCI_RDIRE_OFFSET 17
15317 +#define MCI_RDIRE_SIZE 1
15318 +#define MCI_RCRCE_OFFSET 18
15319 +#define MCI_RCRCE_SIZE 1
15320 +#define MCI_RENDE_OFFSET 19
15321 +#define MCI_RENDE_SIZE 1
15322 +#define MCI_RTOE_OFFSET 20
15323 +#define MCI_RTOE_SIZE 1
15324 +#define MCI_DCRCE_OFFSET 21
15325 +#define MCI_DCRCE_SIZE 1
15326 +#define MCI_DTOE_OFFSET 22
15327 +#define MCI_DTOE_SIZE 1
15328 +#define MCI_OVRE_OFFSET 30
15329 +#define MCI_OVRE_SIZE 1
15330 +#define MCI_UNRE_OFFSET 31
15331 +#define MCI_UNRE_SIZE 1
15333 +/* Constants for DTOMUL */
15334 +#define MCI_DTOMUL_1_CYCLE 0
15335 +#define MCI_DTOMUL_16_CYCLES 1
15336 +#define MCI_DTOMUL_128_CYCLES 2
15337 +#define MCI_DTOMUL_256_CYCLES 3
15338 +#define MCI_DTOMUL_1024_CYCLES 4
15339 +#define MCI_DTOMUL_4096_CYCLES 5
15340 +#define MCI_DTOMUL_65536_CYCLES 6
15341 +#define MCI_DTOMUL_1048576_CYCLES 7
15343 +/* Constants for RSPTYP */
15344 +#define MCI_RSPTYP_NO_RESP 0
15345 +#define MCI_RSPTYP_48_BIT 1
15346 +#define MCI_RSPTYP_136_BIT 2
15348 +/* Constants for SPCMD */
15349 +#define MCI_SPCMD_NO_SPEC_CMD 0
15350 +#define MCI_SPCMD_INIT_CMD 1
15351 +#define MCI_SPCMD_SYNC_CMD 2
15352 +#define MCI_SPCMD_INT_CMD 4
15353 +#define MCI_SPCMD_INT_RESP 5
15355 +/* Constants for TRCMD */
15356 +#define MCI_TRCMD_NO_TRANS 0
15357 +#define MCI_TRCMD_START_TRANS 1
15358 +#define MCI_TRCMD_STOP_TRANS 2
15360 +/* Constants for TRTYP */
15361 +#define MCI_TRTYP_BLOCK 0
15362 +#define MCI_TRTYP_MULTI_BLOCK 1
15363 +#define MCI_TRTYP_STREAM 2
15365 +/* Bit manipulation macros */
15366 +#define MCI_BIT(name) \
15367 + (1 << MCI_##name##_OFFSET)
15368 +#define MCI_BF(name,value) \
15369 + (((value) & ((1 << MCI_##name##_SIZE) - 1)) \
15370 + << MCI_##name##_OFFSET)
15371 +#define MCI_BFEXT(name,value) \
15372 + (((value) >> MCI_##name##_OFFSET) \
15373 + & ((1 << MCI_##name##_SIZE) - 1))
15374 +#define MCI_BFINS(name,value,old) \
15375 + (((old) & ~(((1 << MCI_##name##_SIZE) - 1) \
15376 + << MCI_##name##_OFFSET)) \
15377 + | MCI_BF(name,value))
15379 +/* Register access macros */
15380 +#define mci_readl(port,reg) \
15381 + __raw_readl((port)->regs + MCI_##reg)
15382 +#define mci_writel(port,reg,value) \
15383 + __raw_writel((value), (port)->regs + MCI_##reg)
15385 +#endif /* __DRIVERS_MMC_ATMEL_MCI_H__ */
15386 --- a/drivers/mmc/host/Kconfig
15387 +++ b/drivers/mmc/host/Kconfig
15392 +config MMC_ATMELMCI
15393 + tristate "Atmel Multimedia Card Interface support"
15394 + depends on AVR32 && MMC
15396 + This selects the Atmel Multimedia Card Interface. If you have
15397 + a AT91 (ARM) or AT32 (AVR32) platform with a Multimedia Card
15398 + slot, say Y or M here.
15400 + If unsure, say N.
15403 tristate "Motorola i.MX Multimedia Card Interface support"
15404 depends on ARCH_IMX
15405 --- a/drivers/mmc/host/Makefile
15406 +++ b/drivers/mmc/host/Makefile
15408 obj-$(CONFIG_MMC_AU1X) += au1xmmc.o
15409 obj-$(CONFIG_MMC_OMAP) += omap.o
15410 obj-$(CONFIG_MMC_AT91) += at91_mci.o
15411 +obj-$(CONFIG_MMC_ATMELMCI) += atmel-mci.o
15412 obj-$(CONFIG_MMC_TIFM_SD) += tifm_sd.o
15413 obj-$(CONFIG_MMC_SPI) += mmc_spi.o
15415 --- a/drivers/mtd/chips/cfi_cmdset_0001.c
15416 +++ b/drivers/mtd/chips/cfi_cmdset_0001.c
15418 #define I82802AC 0x00ac
15419 #define MANUFACTURER_ST 0x0020
15420 #define M50LPW080 0x002F
15421 +#define AT49BV640D 0x02de
15423 static int cfi_intelext_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
15424 static int cfi_intelext_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
15425 @@ -157,6 +158,47 @@
15429 +/* Atmel chips don't use the same PRI format as Intel chips */
15430 +static void fixup_convert_atmel_pri(struct mtd_info *mtd, void *param)
15432 + struct map_info *map = mtd->priv;
15433 + struct cfi_private *cfi = map->fldrv_priv;
15434 + struct cfi_pri_intelext *extp = cfi->cmdset_priv;
15435 + struct cfi_pri_atmel atmel_pri;
15436 + uint32_t features = 0;
15438 + /* Reverse byteswapping */
15439 + extp->FeatureSupport = cpu_to_le32(extp->FeatureSupport);
15440 + extp->BlkStatusRegMask = cpu_to_le16(extp->BlkStatusRegMask);
15441 + extp->ProtRegAddr = cpu_to_le16(extp->ProtRegAddr);
15443 + memcpy(&atmel_pri, extp, sizeof(atmel_pri));
15444 + memset((char *)extp + 5, 0, sizeof(*extp) - 5);
15446 + printk(KERN_ERR "atmel Features: %02x\n", atmel_pri.Features);
15448 + if (atmel_pri.Features & 0x01) /* chip erase supported */
15449 + features |= (1<<0);
15450 + if (atmel_pri.Features & 0x02) /* erase suspend supported */
15451 + features |= (1<<1);
15452 + if (atmel_pri.Features & 0x04) /* program suspend supported */
15453 + features |= (1<<2);
15454 + if (atmel_pri.Features & 0x08) /* simultaneous operations supported */
15455 + features |= (1<<9);
15456 + if (atmel_pri.Features & 0x20) /* page mode read supported */
15457 + features |= (1<<7);
15458 + if (atmel_pri.Features & 0x40) /* queued erase supported */
15459 + features |= (1<<4);
15460 + if (atmel_pri.Features & 0x80) /* Protection bits supported */
15461 + features |= (1<<6);
15463 + extp->FeatureSupport = features;
15465 + /* burst write mode not supported */
15466 + cfi->cfiq->BufWriteTimeoutTyp = 0;
15467 + cfi->cfiq->BufWriteTimeoutMax = 0;
15470 #ifdef CMDSET0001_DISABLE_ERASE_SUSPEND_ON_WRITE
15471 /* Some Intel Strata Flash prior to FPO revision C has bugs in this area */
15472 static void fixup_intel_strataflash(struct mtd_info *mtd, void* param)
15473 @@ -234,6 +276,7 @@
15476 static struct cfi_fixup cfi_fixup_table[] = {
15477 + { CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri, NULL },
15478 #ifdef CMDSET0001_DISABLE_ERASE_SUSPEND_ON_WRITE
15479 { CFI_MFR_ANY, CFI_ID_ANY, fixup_intel_strataflash, NULL },
15481 --- a/drivers/mtd/chips/cfi_cmdset_0002.c
15482 +++ b/drivers/mtd/chips/cfi_cmdset_0002.c
15483 @@ -186,6 +186,10 @@
15484 extp->TopBottom = 2;
15486 extp->TopBottom = 3;
15488 + /* burst write mode not supported */
15489 + cfi->cfiq->BufWriteTimeoutTyp = 0;
15490 + cfi->cfiq->BufWriteTimeoutMax = 0;
15493 static void fixup_use_secsi(struct mtd_info *mtd, void *param)
15494 @@ -218,6 +222,7 @@
15497 static struct cfi_fixup cfi_fixup_table[] = {
15498 + { CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri, NULL },
15499 #ifdef AMD_BOOTLOC_BUG
15500 { CFI_MFR_AMD, CFI_ID_ANY, fixup_amd_bootblock, NULL },
15502 @@ -230,7 +235,6 @@
15503 #if !FORCE_WORD_WRITE
15504 { CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers, NULL, },
15506 - { CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri, NULL },
15507 { 0, 0, NULL, NULL }
15509 static struct cfi_fixup jedec_fixup_table[] = {
15511 +++ b/drivers/pcmcia/at32_cf.c
15514 + * Driver for AVR32 Static Memory Controller: CompactFlash support
15516 + * Copyright (C) 2006 Atmel Norway
15518 + * This program is free software; you can redistribute it and/or
15519 + * modify it under the terms of the GNU General Public License as
15520 + * published by the Free Software Foundation; either version 2 of the
15521 + * License, or (at your option) any later version.
15523 + * This program is distributed in the hope that it will be useful, but
15524 + * WITHOUT ANY WARRANTY; without even the implied warranty of
15525 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15526 + * General Public License for more details.
15528 + * You should have received a copy of the GNU General Public License
15529 + * along with this program; if not, write to the Free Software
15530 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
15531 + * 02111-1307, USA.
15533 + * The full GNU General Public License is included in this
15534 + * distribution in the file called COPYING.
15536 +#include <linux/module.h>
15537 +#include <linux/kernel.h>
15538 +#include <linux/platform_device.h>
15539 +#include <linux/init.h>
15540 +#include <linux/device.h>
15541 +#include <linux/delay.h>
15542 +#include <linux/interrupt.h>
15543 +#include <linux/err.h>
15544 +#include <linux/clk.h>
15545 +#include <linux/dma-mapping.h>
15547 +#include <pcmcia/ss.h>
15549 +#include <asm/gpio.h>
15550 +#include <asm/io.h>
15551 +#include <asm/arch/board.h>
15553 +#include <asm/arch/smc.h>
15555 +struct at32_cf_socket {
15556 + struct pcmcia_socket socket;
15561 + struct resource res_attr;
15562 + struct resource res_mem;
15563 + struct resource res_io;
15564 + struct smc_config smc;
15565 + unsigned int irq;
15566 + unsigned int cf_cs;
15567 + socket_state_t state;
15568 + unsigned present:1;
15570 +#define to_at32_cf(sock) container_of(sock, struct at32_cf_socket, socket)
15573 + * We have the following memory layout relative to the base address:
15575 + * Alt IDE Mode: 00e0 0000 -> 00ff ffff
15576 + * True IDE Mode: 00c0 0000 -> 00df ffff
15577 + * I/O memory: 0080 0000 -> 00bf ffff
15578 + * Common memory: 0040 0000 -> 007f ffff
15579 + * Attribute memory: 0000 0000 -> 003f ffff
15581 +#define CF_ATTR_OFFSET 0x00000000
15582 +#define CF_MEM_OFFSET 0x00400000
15583 +#define CF_IO_OFFSET 0x00800000
15584 +#define CF_RES_SIZE 4096
15588 +static int pc_debug;
15589 +module_param(pc_debug, int, 0644);
15591 +static void at32_cf_debug(struct at32_cf_socket *cf, const char *func,
15592 + int level, const char *fmt, ...)
15596 + if (pc_debug > level) {
15597 + printk(KERN_DEBUG "at32_cf/%u: %s: ", cf->cf_cs, func);
15598 + va_start(args, fmt);
15599 + vprintk(fmt, args);
15604 +#define debug(cf, lvl, fmt, arg...) \
15605 + at32_cf_debug(cf, __func__, lvl, fmt, ##arg)
15608 +#define debug(cf, lvl, fmt, arg...) do { } while (0)
15611 +static inline int at32_cf_present(struct at32_cf_socket *cf)
15615 + /* If we don't have a detect pin, assume the card is present */
15616 + if (cf->detect_pin >= 0)
15617 + present = !gpio_get_value(cf->detect_pin);
15622 +static irqreturn_t at32_cf_irq(int irq, void *dev_id)
15624 + struct at32_cf_socket *cf = dev_id;
15625 + unsigned int present;
15627 + present = at32_cf_present(cf);
15628 + if (present != cf->present) {
15629 + cf->present = present;
15630 + debug(cf, 3, "card %s\n", present ? "present" : "gone");
15631 + pcmcia_parse_events(&cf->socket, SS_DETECT);
15634 + return IRQ_HANDLED;
15637 +static int at32_cf_get_status(struct pcmcia_socket *sock, u_int *value)
15639 + struct at32_cf_socket *cf;
15640 + u_int status = 0;
15642 + cf = container_of(sock, struct at32_cf_socket, socket);
15644 + if (at32_cf_present(cf)) {
15645 + /* NOTE: gpio on AP7xxx is 3.3V */
15646 + status = SS_DETECT | SS_3VCARD;
15647 + if (cf->ready_pin < 0 || gpio_get_value(cf->ready_pin))
15648 + status |= SS_READY;
15649 + if (cf->vcc_pin < 0 || gpio_get_value(cf->vcc_pin))
15650 + status |= SS_POWERON;
15657 +static int at32_cf_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
15659 + struct at32_cf_socket *cf = container_of(sock, struct at32_cf_socket, socket);
15661 + debug(cf, 2, "mask: %s%s%s%s%s%sflags: %s%s%s%s%s%sVcc %d Vpp %d irq %d\n",
15662 + (state->csc_mask==0)?"<NONE> ":"",
15663 + (state->csc_mask&SS_DETECT)?"DETECT ":"",
15664 + (state->csc_mask&SS_READY)?"READY ":"",
15665 + (state->csc_mask&SS_BATDEAD)?"BATDEAD ":"",
15666 + (state->csc_mask&SS_BATWARN)?"BATWARN ":"",
15667 + (state->csc_mask&SS_STSCHG)?"STSCHG ":"",
15668 + (state->flags==0)?"<NONE> ":"",
15669 + (state->flags&SS_PWR_AUTO)?"PWR_AUTO ":"",
15670 + (state->flags&SS_IOCARD)?"IOCARD ":"",
15671 + (state->flags&SS_RESET)?"RESET ":"",
15672 + (state->flags&SS_SPKR_ENA)?"SPKR_ENA ":"",
15673 + (state->flags&SS_OUTPUT_ENA)?"OUTPUT_ENA ":"",
15674 + state->Vcc, state->Vpp, state->io_irq);
15677 + * TODO: Allow boards to override this in case they have level
15680 + switch (state->Vcc) {
15682 + if (cf->vcc_pin >= 0)
15683 + gpio_set_value(cf->vcc_pin, 0);
15686 + if (cf->vcc_pin >= 0)
15687 + gpio_set_value(cf->vcc_pin, 1);
15693 + if (cf->reset_pin >= 0)
15694 + gpio_set_value(cf->reset_pin, state->flags & SS_RESET);
15696 + cf->state = *state;
15701 +static int at32_cf_socket_init(struct pcmcia_socket *sock)
15703 + debug(to_at32_cf(sock), 2, "called\n");
15708 +static int at32_cf_suspend(struct pcmcia_socket *sock)
15710 + debug(to_at32_cf(sock), 2, "called\n");
15712 + at32_cf_set_socket(sock, &dead_socket);
15717 +static int at32_cf_set_io_map(struct pcmcia_socket *sock,
15718 + struct pccard_io_map *map)
15720 + struct at32_cf_socket *cf = container_of(sock, struct at32_cf_socket, socket);
15723 + debug(cf, 2, "map %u speed %u start 0x%08x stop 0x%08x\n",
15724 + map->map, map->speed, map->start, map->stop);
15725 + debug(cf, 2, "flags: %s%s%s%s%s%s%s%s\n",
15726 + (map->flags == 0) ? "<NONE>":"",
15727 + (map->flags & MAP_ACTIVE) ? "ACTIVE " : "",
15728 + (map->flags & MAP_16BIT) ? "16BIT " : "",
15729 + (map->flags & MAP_AUTOSZ) ? "AUTOSZ " : "",
15730 + (map->flags & MAP_0WS) ? "0WS " : "",
15731 + (map->flags & MAP_WRPROT) ? "WRPROT " : "",
15732 + (map->flags & MAP_USE_WAIT) ? "USE_WAIT " : "",
15733 + (map->flags & MAP_PREFETCH) ? "PREFETCH " : "");
15735 + map->flags &= MAP_ACTIVE | MAP_16BIT | MAP_USE_WAIT;
15737 + if (map->flags & MAP_16BIT)
15738 + cf->smc.bus_width = 2;
15740 + cf->smc.bus_width = 1;
15742 + if (map->flags & MAP_USE_WAIT)
15743 + cf->smc.nwait_mode = 3;
15745 + cf->smc.nwait_mode = 0;
15747 + retval = smc_set_configuration(cf->cf_cs, &cf->smc);
15749 + printk(KERN_ERR "at32_cf: could not set up SMC for I/O\n");
15753 + map->start = cf->socket.io_offset;
15754 + map->stop = map->start + CF_RES_SIZE - 1;
15760 +at32_cf_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *map)
15762 + struct at32_cf_socket *cf;
15763 + struct resource *res;
15766 + cf = container_of(sock, struct at32_cf_socket, socket);
15768 + debug(cf, 2, "map %u speed %u card_start %08x\n",
15769 + map->map, map->speed, map->card_start);
15770 + debug(cf, 2, "flags: %s%s%s%s%s%s%s%s\n",
15771 + (map->flags==0)?"<NONE>":"",
15772 + (map->flags&MAP_ACTIVE)?"ACTIVE ":"",
15773 + (map->flags&MAP_16BIT)?"16BIT ":"",
15774 + (map->flags&MAP_AUTOSZ)?"AUTOSZ ":"",
15775 + (map->flags&MAP_0WS)?"0WS ":"",
15776 + (map->flags&MAP_WRPROT)?"WRPROT ":"",
15777 + (map->flags&MAP_ATTRIB)?"ATTRIB ":"",
15778 + (map->flags&MAP_USE_WAIT)?"USE_WAIT ":"");
15780 + if (map->card_start)
15783 + map->flags &= MAP_ACTIVE | MAP_ATTRIB | MAP_16BIT | MAP_USE_WAIT;
15785 + if (map->flags & MAP_ATTRIB) {
15786 + res = &cf->res_attr;
15788 + /* Linksys WCF12 seems to use WAIT when reading CIS */
15789 + map->flags |= MAP_USE_WAIT;
15791 + res = &cf->res_mem;
15794 + if (map->flags & MAP_USE_WAIT)
15795 + cf->smc.nwait_mode = 3;
15797 + cf->smc.nwait_mode = 0;
15799 + retval = smc_set_configuration(cf->cf_cs, &cf->smc);
15801 + printk(KERN_ERR "at32_cf: could not set up SMC for mem\n");
15805 + map->static_start = res->start;
15810 +static struct pccard_operations at32_cf_ops = {
15811 + .init = at32_cf_socket_init,
15812 + .suspend = at32_cf_suspend,
15813 + .get_status = at32_cf_get_status,
15814 + .set_socket = at32_cf_set_socket,
15815 + .set_io_map = at32_cf_set_io_map,
15816 + .set_mem_map = at32_cf_set_mem_map,
15819 +static int __init request_pin(struct platform_device *pdev,
15820 + unsigned int pin, const char *name)
15822 + if (gpio_request(pin, name)) {
15823 + dev_warn(&pdev->dev, "failed to request %s pin\n", name);
15830 +static struct smc_timing at32_cf_timing __initdata = {
15831 + .ncs_read_setup = 30,
15832 + .nrd_setup = 100,
15833 + .ncs_write_setup = 30,
15834 + .nwe_setup = 100,
15836 + .ncs_read_pulse = 360,
15837 + .nrd_pulse = 290,
15838 + .ncs_write_pulse = 360,
15839 + .nwe_pulse = 290,
15841 + .read_cycle = 420,
15842 + .write_cycle = 420,
15845 +static int __init at32_cf_probe(struct platform_device *pdev)
15847 + struct at32_cf_socket *cf;
15848 + struct cf_platform_data *board = pdev->dev.platform_data;
15849 + struct resource *res_skt;
15853 + dev_dbg(&pdev->dev, "probe");
15858 + res_skt = platform_get_resource(pdev, IORESOURCE_MEM, 0);
15862 + irq = platform_get_irq(pdev, 0);
15866 + cf = kzalloc(sizeof(struct at32_cf_socket), GFP_KERNEL);
15870 + cf->detect_pin = -1;
15871 + cf->reset_pin = -1;
15872 + cf->vcc_pin = -1;
15873 + cf->ready_pin = -1;
15874 + cf->cf_cs = board->cs;
15876 + if (board->detect_pin != GPIO_PIN_NONE)
15877 + cf->detect_pin = request_pin(pdev, board->detect_pin,
15879 + if (board->reset_pin != GPIO_PIN_NONE)
15880 + cf->reset_pin = request_pin(pdev, board->reset_pin,
15882 + if (board->vcc_pin != GPIO_PIN_NONE)
15883 + cf->vcc_pin = request_pin(pdev, board->vcc_pin,
15885 + if (board->ready_pin != GPIO_PIN_NONE)
15886 + /* READY is also used for irq through EIM */
15887 + cf->ready_pin = board->ready_pin;
15889 + debug(cf, 2, "pins: detect=%d reset=%d vcc=%d\n",
15890 + cf->detect_pin, cf->reset_pin, cf->vcc_pin);
15892 + cf->socket.pci_irq = irq;
15893 + cf->socket.ops = &at32_cf_ops;
15894 + cf->socket.resource_ops = &pccard_static_ops;
15895 + cf->socket.dev.parent = &pdev->dev;
15896 + cf->socket.owner = THIS_MODULE;
15897 + cf->socket.features =
15898 + SS_CAP_MEM_ALIGN | SS_CAP_STATIC_MAP | SS_CAP_PCCARD;
15899 + cf->socket.map_size = CF_RES_SIZE;
15901 + cf->res_attr.start = res_skt->start + CF_ATTR_OFFSET;
15902 + cf->res_attr.end = cf->res_attr.start + CF_RES_SIZE - 1;
15903 + cf->res_attr.name = "attribute";
15904 + cf->res_attr.flags = IORESOURCE_MEM;
15905 + ret = request_resource(res_skt, &cf->res_attr);
15907 + goto err_request_res_attr;
15909 + cf->res_mem.start = res_skt->start + CF_MEM_OFFSET;
15910 + cf->res_mem.end = cf->res_mem.start + CF_RES_SIZE - 1;
15911 + cf->res_mem.name = "memory";
15912 + cf->res_mem.flags = IORESOURCE_MEM;
15913 + ret = request_resource(res_skt, &cf->res_mem);
15915 + goto err_request_res_mem;
15917 + cf->res_io.start = res_skt->start + CF_IO_OFFSET;
15918 + cf->res_io.end = cf->res_io.start + CF_RES_SIZE - 1;
15919 + cf->res_io.name = "io";
15920 + cf->res_io.flags = IORESOURCE_MEM;
15921 + ret = request_resource(res_skt, &cf->res_io);
15923 + goto err_request_res_io;
15925 + cf->socket.io_offset = cf->res_io.start;
15927 + if (cf->detect_pin >= 0) {
15928 + ret = request_irq(gpio_to_irq(cf->detect_pin), at32_cf_irq,
15929 + IRQF_SHARED, "cf_detect", cf);
15932 + "failed to request cf_detect interrupt\n");
15933 + goto err_detect_irq;
15937 + cf->present = at32_cf_present(cf);
15939 + /* Setup SMC timings */
15940 + smc_set_timing(&cf->smc, &at32_cf_timing);
15942 + cf->smc.bus_width = 2;
15943 + cf->smc.nrd_controlled = 1;
15944 + cf->smc.nwe_controlled = 1;
15945 + cf->smc.nwait_mode = 0;
15946 + cf->smc.byte_write = 0;
15947 + cf->smc.tdf_cycles = 8;
15948 + cf->smc.tdf_mode = 0;
15950 + ret = smc_set_configuration(cf->cf_cs, &cf->smc);
15952 + debug(cf, 1, "failed to configure SMC\n", ret);
15956 + ret = pcmcia_register_socket(&cf->socket);
15958 + debug(cf, 1, "failed to register socket: %d\n", ret);
15959 + goto err_register_socket;
15962 + if (cf->reset_pin >= 0)
15963 + gpio_direction_output(cf->reset_pin, 0);
15965 + platform_set_drvdata(pdev, cf);
15967 + dev_info(&pdev->dev, "Atmel SMC CF interface at 0x%08lx\n",
15968 + (unsigned long)res_skt->start);
15972 +err_register_socket:
15974 + if (cf->detect_pin >= 0)
15975 + free_irq(gpio_to_irq(cf->detect_pin), cf);
15977 + release_resource(&cf->res_io);
15978 +err_request_res_io:
15979 + release_resource(&cf->res_mem);
15980 +err_request_res_mem:
15981 + release_resource(&cf->res_attr);
15982 +err_request_res_attr:
15983 + if (cf->vcc_pin >= 0)
15984 + gpio_free(cf->vcc_pin);
15985 + if (cf->reset_pin >= 0)
15986 + gpio_free(cf->reset_pin);
15987 + if (cf->detect_pin >= 0)
15988 + gpio_free(cf->detect_pin);
15994 +static int __exit at32_cf_remove(struct platform_device *pdev)
15996 + struct at32_cf_socket *cf = platform_get_drvdata(pdev);
15998 + pcmcia_unregister_socket(&cf->socket);
15999 + if (cf->detect_pin >= 0) {
16000 + free_irq(gpio_to_irq(cf->detect_pin), cf);
16001 + gpio_free(cf->detect_pin);
16003 + if (cf->vcc_pin >= 0)
16004 + gpio_free(cf->vcc_pin);
16005 + if (cf->reset_pin >= 0)
16006 + gpio_free(cf->reset_pin);
16008 + release_resource(&cf->res_io);
16009 + release_resource(&cf->res_mem);
16010 + release_resource(&cf->res_attr);
16012 + platform_set_drvdata(pdev, NULL);
16017 +static struct platform_driver at32_cf_driver = {
16018 + .remove = __exit_p(at32_cf_remove),
16020 + .name = "at32_cf",
16021 + .owner = THIS_MODULE,
16025 +static int __init at32_cf_init(void)
16029 + ret = platform_driver_probe(&at32_cf_driver, at32_cf_probe);
16031 + printk(KERN_ERR "at32_cf: probe failed: %d\n", ret);
16035 +static void __exit at32_cf_exit(void)
16037 + platform_driver_unregister(&at32_cf_driver);
16040 +module_init(at32_cf_init);
16041 +module_exit(at32_cf_exit);
16043 +MODULE_LICENSE("GPL");
16044 +MODULE_DESCRIPTION("Driver for SMC PCMCIA interface");
16045 +MODULE_AUTHOR("Hans-Christian Egtvedt <hcegtvedt@atmel.com>");
16046 --- a/drivers/pcmcia/Kconfig
16047 +++ b/drivers/pcmcia/Kconfig
16048 @@ -276,6 +276,13 @@
16049 Say Y here to support the CompactFlash controller on the
16050 PA Semi Electra eval board.
16053 + tristate "AT32AP CompactFlash Controller"
16054 + depends on PCMCIA && AVR32 && PLATFORM_AT32AP
16056 + Say Y here to support the CompactFlash controller on AT32 chips.
16057 + Or choose M to compile the driver as a module named "at32_cf".
16059 config PCCARD_NONSTATIC
16062 --- a/drivers/pcmcia/Makefile
16063 +++ b/drivers/pcmcia/Makefile
16065 obj-$(CONFIG_OMAP_CF) += omap_cf.o
16066 obj-$(CONFIG_AT91_CF) += at91_cf.o
16067 obj-$(CONFIG_ELECTRA_CF) += electra_cf.o
16068 +obj-$(CONFIG_AT32_CF) += at32_cf.o
16070 sa11xx_core-y += soc_common.o sa11xx_base.o
16071 pxa2xx_core-y += soc_common.o pxa2xx_base.o
16072 --- a/drivers/serial/atmel_serial.c
16073 +++ b/drivers/serial/atmel_serial.c
16075 * Based on drivers/char/serial_sa1100.c, by Deep Blue Solutions Ltd.
16076 * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
16078 + * DMA support added by Chip Coldwell.
16080 * This program is free software; you can redistribute it and/or modify
16081 * it under the terms of the GNU General Public License as published by
16082 * the Free Software Foundation; either version 2 of the License, or
16084 #include <linux/sysrq.h>
16085 #include <linux/tty_flip.h>
16086 #include <linux/platform_device.h>
16087 +#include <linux/dma-mapping.h>
16088 #include <linux/atmel_pdc.h>
16089 +#include <linux/atmel_serial.h>
16091 #include <asm/io.h>
16094 #include <asm/arch/gpio.h>
16097 -#include "atmel_serial.h"
16098 +#define PDC_BUFFER_SIZE 512
16099 +/* Revisit: We should calculate this based on the actual port settings */
16100 +#define PDC_RX_TIMEOUT (3 * 10) /* 3 bytes */
16102 #if defined(CONFIG_SERIAL_ATMEL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
16103 #define SUPPORT_SYSRQ
16106 #define ATMEL_ISR_PASS_LIMIT 256
16108 +/* UART registers. CR is write-only, hence no GET macro */
16109 #define UART_PUT_CR(port,v) __raw_writel(v, (port)->membase + ATMEL_US_CR)
16110 #define UART_GET_MR(port) __raw_readl((port)->membase + ATMEL_US_MR)
16111 #define UART_PUT_MR(port,v) __raw_writel(v, (port)->membase + ATMEL_US_MR)
16113 #define UART_PUT_BRGR(port,v) __raw_writel(v, (port)->membase + ATMEL_US_BRGR)
16114 #define UART_PUT_RTOR(port,v) __raw_writel(v, (port)->membase + ATMEL_US_RTOR)
16116 -// #define UART_GET_CR(port) __raw_readl((port)->membase + ATMEL_US_CR) // is write-only
16118 /* PDC registers */
16119 #define UART_PUT_PTCR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_PTCR)
16120 #define UART_GET_PTSR(port) __raw_readl((port)->membase + ATMEL_PDC_PTSR)
16121 @@ -101,12 +106,24 @@
16123 #define UART_PUT_TPR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_TPR)
16124 #define UART_PUT_TCR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_TCR)
16125 -//#define UART_PUT_TNPR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_TNPR)
16126 -//#define UART_PUT_TNCR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_TNCR)
16128 static int (*atmel_open_hook)(struct uart_port *);
16129 static void (*atmel_close_hook)(struct uart_port *);
16131 +struct atmel_dma_buffer {
16132 + unsigned char *buf;
16133 + dma_addr_t dma_addr;
16134 + unsigned int dma_size;
16135 + unsigned int ofs;
16138 +struct atmel_uart_char {
16143 +#define ATMEL_SERIAL_RINGSIZE 1024
16146 * We wrap our port structure around the generic uart_port.
16148 @@ -115,6 +132,19 @@
16149 struct clk *clk; /* uart clock */
16150 unsigned short suspended; /* is port suspended? */
16151 int break_active; /* break being received */
16153 + short use_dma_rx; /* enable PDC receiver */
16154 + short pdc_rx_idx; /* current PDC RX buffer */
16155 + struct atmel_dma_buffer pdc_rx[2]; /* PDC receier */
16157 + short use_dma_tx; /* enable PDC transmitter */
16158 + struct atmel_dma_buffer pdc_tx; /* PDC transmitter */
16160 + struct tasklet_struct tasklet;
16161 + unsigned int irq_status;
16162 + unsigned int irq_status_prev;
16164 + struct circ_buf rx_ring;
16167 static struct atmel_uart_port atmel_ports[ATMEL_MAX_UART];
16168 @@ -123,6 +153,38 @@
16169 static struct console atmel_console;
16172 +static inline struct atmel_uart_port *
16173 +to_atmel_uart_port(struct uart_port *uart)
16175 + return container_of(uart, struct atmel_uart_port, uart);
16178 +#ifdef CONFIG_SERIAL_ATMEL_PDC
16179 +static bool atmel_use_dma_rx(struct uart_port *port)
16181 + struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
16183 + return atmel_port->use_dma_rx;
16186 +static bool atmel_use_dma_tx(struct uart_port *port)
16188 + struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
16190 + return atmel_port->use_dma_tx;
16193 +static bool atmel_use_dma_rx(struct uart_port *port)
16198 +static bool atmel_use_dma_tx(struct uart_port *port)
16205 * Return TIOCSER_TEMT when transmitter FIFO and Shift register is empty.
16207 @@ -142,8 +204,8 @@
16208 #ifdef CONFIG_ARCH_AT91RM9200
16209 if (cpu_is_at91rm9200()) {
16211 - * AT91RM9200 Errata #39: RTS0 is not internally connected to PA21.
16212 - * We need to drive the pin manually.
16213 + * AT91RM9200 Errata #39: RTS0 is not internally connected
16214 + * to PA21. We need to drive the pin manually.
16216 if (port->mapbase == AT91RM9200_BASE_US0) {
16217 if (mctrl & TIOCM_RTS)
16218 @@ -204,7 +266,12 @@
16220 static void atmel_stop_tx(struct uart_port *port)
16222 - UART_PUT_IDR(port, ATMEL_US_TXRDY);
16223 + if (atmel_use_dma_tx(port)) {
16224 + /* disable PDC transmit */
16225 + UART_PUT_PTCR(port, ATMEL_PDC_TXTDIS);
16226 + UART_PUT_IDR(port, ATMEL_US_ENDTX | ATMEL_US_TXBUFE);
16228 + UART_PUT_IDR(port, ATMEL_US_TXRDY);
16232 @@ -212,7 +279,17 @@
16234 static void atmel_start_tx(struct uart_port *port)
16236 - UART_PUT_IER(port, ATMEL_US_TXRDY);
16237 + if (atmel_use_dma_tx(port)) {
16238 + if (UART_GET_PTSR(port) & ATMEL_PDC_TXTEN)
16239 + /* The transmitter is already running. Yes, we
16240 + really need this.*/
16243 + UART_PUT_IER(port, ATMEL_US_ENDTX | ATMEL_US_TXBUFE);
16244 + /* re-enable PDC transmit */
16245 + UART_PUT_PTCR(port, ATMEL_PDC_TXTEN);
16247 + UART_PUT_IER(port, ATMEL_US_TXRDY);
16251 @@ -220,7 +297,12 @@
16253 static void atmel_stop_rx(struct uart_port *port)
16255 - UART_PUT_IDR(port, ATMEL_US_RXRDY);
16256 + if (atmel_use_dma_rx(port)) {
16257 + /* disable PDC receive */
16258 + UART_PUT_PTCR(port, ATMEL_PDC_RXTDIS);
16259 + UART_PUT_IDR(port, ATMEL_US_ENDRX | ATMEL_US_TIMEOUT);
16261 + UART_PUT_IDR(port, ATMEL_US_RXRDY);
16265 @@ -228,7 +310,8 @@
16267 static void atmel_enable_ms(struct uart_port *port)
16269 - UART_PUT_IER(port, ATMEL_US_RIIC | ATMEL_US_DSRIC | ATMEL_US_DCDIC | ATMEL_US_CTSIC);
16270 + UART_PUT_IER(port, ATMEL_US_RIIC | ATMEL_US_DSRIC
16271 + | ATMEL_US_DCDIC | ATMEL_US_CTSIC);
16275 @@ -243,22 +326,63 @@
16279 + * Stores the incoming character in the ring buffer
16282 +atmel_buffer_rx_char(struct uart_port *port, unsigned int status,
16285 + struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
16286 + struct circ_buf *ring = &atmel_port->rx_ring;
16287 + struct atmel_uart_char *c;
16289 + if (!CIRC_SPACE(ring->head, ring->tail, ATMEL_SERIAL_RINGSIZE))
16290 + /* Buffer overflow, ignore char */
16293 + c = &((struct atmel_uart_char *)ring->buf)[ring->head];
16294 + c->status = status;
16297 + /* Make sure the character is stored before we update head. */
16300 + ring->head = (ring->head + 1) & (ATMEL_SERIAL_RINGSIZE - 1);
16304 + * Deal with parity, framing and overrun errors.
16306 +static void atmel_pdc_rxerr(struct uart_port *port, unsigned int status)
16308 + /* clear error */
16309 + UART_PUT_CR(port, ATMEL_US_RSTSTA);
16311 + if (status & ATMEL_US_RXBRK) {
16312 + /* ignore side-effect */
16313 + status &= ~(ATMEL_US_PARE | ATMEL_US_FRAME);
16314 + port->icount.brk++;
16316 + if (status & ATMEL_US_PARE)
16317 + port->icount.parity++;
16318 + if (status & ATMEL_US_FRAME)
16319 + port->icount.frame++;
16320 + if (status & ATMEL_US_OVRE)
16321 + port->icount.overrun++;
16325 * Characters received (called from interrupt handler)
16327 static void atmel_rx_chars(struct uart_port *port)
16329 - struct atmel_uart_port *atmel_port = (struct atmel_uart_port *) port;
16330 - struct tty_struct *tty = port->info->tty;
16331 - unsigned int status, ch, flg;
16332 + struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
16333 + unsigned int status, ch;
16335 status = UART_GET_CSR(port);
16336 while (status & ATMEL_US_RXRDY) {
16337 ch = UART_GET_CHAR(port);
16339 - port->icount.rx++;
16341 - flg = TTY_NORMAL;
16344 * note that the error handling code is
16345 * out of the main execution path
16346 @@ -266,15 +390,14 @@
16347 if (unlikely(status & (ATMEL_US_PARE | ATMEL_US_FRAME
16348 | ATMEL_US_OVRE | ATMEL_US_RXBRK)
16349 || atmel_port->break_active)) {
16350 - UART_PUT_CR(port, ATMEL_US_RSTSTA); /* clear error */
16352 + /* clear error */
16353 + UART_PUT_CR(port, ATMEL_US_RSTSTA);
16355 if (status & ATMEL_US_RXBRK
16356 && !atmel_port->break_active) {
16357 - status &= ~(ATMEL_US_PARE | ATMEL_US_FRAME); /* ignore side-effect */
16358 - port->icount.brk++;
16359 atmel_port->break_active = 1;
16360 UART_PUT_IER(port, ATMEL_US_RXBRK);
16361 - if (uart_handle_break(port))
16362 - goto ignore_char;
16365 * This is either the end-of-break
16366 @@ -287,52 +410,30 @@
16367 status &= ~ATMEL_US_RXBRK;
16368 atmel_port->break_active = 0;
16370 - if (status & ATMEL_US_PARE)
16371 - port->icount.parity++;
16372 - if (status & ATMEL_US_FRAME)
16373 - port->icount.frame++;
16374 - if (status & ATMEL_US_OVRE)
16375 - port->icount.overrun++;
16377 - status &= port->read_status_mask;
16379 - if (status & ATMEL_US_RXBRK)
16381 - else if (status & ATMEL_US_PARE)
16382 - flg = TTY_PARITY;
16383 - else if (status & ATMEL_US_FRAME)
16387 - if (uart_handle_sysrq_char(port, ch))
16388 - goto ignore_char;
16390 - uart_insert_char(port, status, ATMEL_US_OVRE, ch, flg);
16393 + atmel_buffer_rx_char(port, status, ch);
16394 status = UART_GET_CSR(port);
16397 - tty_flip_buffer_push(tty);
16398 + tasklet_schedule(&atmel_port->tasklet);
16402 - * Transmit characters (called from interrupt handler)
16403 + * Transmit characters (called from tasklet with TXRDY interrupt
16406 static void atmel_tx_chars(struct uart_port *port)
16408 struct circ_buf *xmit = &port->info->xmit;
16410 - if (port->x_char) {
16411 + if (port->x_char && UART_GET_CSR(port) & ATMEL_US_TXRDY) {
16412 UART_PUT_CHAR(port, port->x_char);
16417 - if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
16418 - atmel_stop_tx(port);
16419 + if (uart_circ_empty(xmit) || uart_tx_stopped(port))
16423 while (UART_GET_CSR(port) & ATMEL_US_TXRDY) {
16424 UART_PUT_CHAR(port, xmit->buf[xmit->tail]);
16425 @@ -345,8 +446,88 @@
16426 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
16427 uart_write_wakeup(port);
16429 - if (uart_circ_empty(xmit))
16430 - atmel_stop_tx(port);
16431 + if (!uart_circ_empty(xmit))
16432 + UART_PUT_IER(port, ATMEL_US_TXRDY);
16436 + * receive interrupt handler.
16439 +atmel_handle_receive(struct uart_port *port, unsigned int pending)
16441 + struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
16443 + if (atmel_use_dma_rx(port)) {
16445 + * PDC receive. Just schedule the tasklet and let it
16446 + * figure out the details.
16448 + * TODO: We're not handling error flags correctly at
16451 + if (pending & (ATMEL_US_ENDRX | ATMEL_US_TIMEOUT)) {
16452 + UART_PUT_IDR(port, (ATMEL_US_ENDRX
16453 + | ATMEL_US_TIMEOUT));
16454 + tasklet_schedule(&atmel_port->tasklet);
16457 + if (pending & (ATMEL_US_RXBRK | ATMEL_US_OVRE |
16458 + ATMEL_US_FRAME | ATMEL_US_PARE))
16459 + atmel_pdc_rxerr(port, pending);
16462 + /* Interrupt receive */
16463 + if (pending & ATMEL_US_RXRDY)
16464 + atmel_rx_chars(port);
16465 + else if (pending & ATMEL_US_RXBRK) {
16467 + * End of break detected. If it came along with a
16468 + * character, atmel_rx_chars will handle it.
16470 + UART_PUT_CR(port, ATMEL_US_RSTSTA);
16471 + UART_PUT_IDR(port, ATMEL_US_RXBRK);
16472 + atmel_port->break_active = 0;
16477 + * transmit interrupt handler. (Transmit is IRQF_NODELAY safe)
16480 +atmel_handle_transmit(struct uart_port *port, unsigned int pending)
16482 + struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
16484 + if (atmel_use_dma_tx(port)) {
16485 + /* PDC transmit */
16486 + if (pending & (ATMEL_US_ENDTX | ATMEL_US_TXBUFE)) {
16487 + UART_PUT_IDR(port, ATMEL_US_ENDTX | ATMEL_US_TXBUFE);
16488 + tasklet_schedule(&atmel_port->tasklet);
16491 + /* Interrupt transmit */
16492 + if (pending & ATMEL_US_TXRDY) {
16493 + UART_PUT_IDR(port, ATMEL_US_TXRDY);
16494 + tasklet_schedule(&atmel_port->tasklet);
16500 + * status flags interrupt handler.
16503 +atmel_handle_status(struct uart_port *port, unsigned int pending,
16504 + unsigned int status)
16506 + struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
16508 + if (pending & (ATMEL_US_RIIC | ATMEL_US_DSRIC | ATMEL_US_DCDIC
16509 + | ATMEL_US_CTSIC)) {
16510 + atmel_port->irq_status = status;
16511 + tasklet_schedule(&atmel_port->tasklet);
16516 @@ -355,47 +536,255 @@
16517 static irqreturn_t atmel_interrupt(int irq, void *dev_id)
16519 struct uart_port *port = dev_id;
16520 - struct atmel_uart_port *atmel_port = (struct atmel_uart_port *) port;
16521 unsigned int status, pending, pass_counter = 0;
16523 - status = UART_GET_CSR(port);
16524 - pending = status & UART_GET_IMR(port);
16525 - while (pending) {
16526 - /* Interrupt receive */
16527 - if (pending & ATMEL_US_RXRDY)
16528 - atmel_rx_chars(port);
16529 - else if (pending & ATMEL_US_RXBRK) {
16531 + status = UART_GET_CSR(port);
16532 + pending = status & UART_GET_IMR(port);
16536 + atmel_handle_receive(port, pending);
16537 + atmel_handle_status(port, pending, status);
16538 + atmel_handle_transmit(port, pending);
16539 + } while (pass_counter++ < ATMEL_ISR_PASS_LIMIT);
16541 + return IRQ_HANDLED;
16545 + * Called from tasklet with ENDTX and TXBUFE interrupts disabled.
16547 +static void atmel_tx_dma(struct uart_port *port)
16549 + struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
16550 + struct circ_buf *xmit = &port->info->xmit;
16551 + struct atmel_dma_buffer *pdc = &atmel_port->pdc_tx;
16554 + xmit->tail += pdc->ofs;
16555 + xmit->tail &= UART_XMIT_SIZE - 1;
16557 + port->icount.tx += pdc->ofs;
16560 + if (!uart_circ_empty(xmit)) {
16561 + /* more to transmit - setup next transfer */
16563 + /* disable PDC transmit */
16564 + UART_PUT_PTCR(port, ATMEL_PDC_TXTDIS);
16565 + dma_sync_single_for_device(port->dev,
16570 + count = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE);
16571 + pdc->ofs = count;
16573 + UART_PUT_TPR(port, pdc->dma_addr + xmit->tail);
16574 + UART_PUT_TCR(port, count);
16575 + /* re-enable PDC transmit and interrupts */
16576 + UART_PUT_PTCR(port, ATMEL_PDC_TXTEN);
16577 + UART_PUT_IER(port, ATMEL_US_ENDTX | ATMEL_US_TXBUFE);
16579 + /* nothing left to transmit - disable the transmitter */
16581 + /* disable PDC transmit */
16582 + UART_PUT_PTCR(port, ATMEL_PDC_TXTDIS);
16585 + if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
16586 + uart_write_wakeup(port);
16589 +static void atmel_rx_from_ring(struct uart_port *port)
16591 + struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
16592 + struct circ_buf *ring = &atmel_port->rx_ring;
16593 + unsigned int flg;
16594 + unsigned int status;
16596 + while (ring->head != ring->tail) {
16597 + struct atmel_uart_char c;
16599 + /* Make sure c is loaded after head. */
16602 + c = ((struct atmel_uart_char *)ring->buf)[ring->tail];
16604 + ring->tail = (ring->tail + 1) & (ATMEL_SERIAL_RINGSIZE - 1);
16606 + port->icount.rx++;
16607 + status = c.status;
16608 + flg = TTY_NORMAL;
16611 + * note that the error handling code is
16612 + * out of the main execution path
16614 + if (unlikely(status & (ATMEL_US_PARE | ATMEL_US_FRAME
16615 + | ATMEL_US_OVRE | ATMEL_US_RXBRK))) {
16616 + if (status & ATMEL_US_RXBRK) {
16617 + /* ignore side-effect */
16618 + status &= ~(ATMEL_US_PARE | ATMEL_US_FRAME);
16620 + port->icount.brk++;
16621 + if (uart_handle_break(port))
16624 + if (status & ATMEL_US_PARE)
16625 + port->icount.parity++;
16626 + if (status & ATMEL_US_FRAME)
16627 + port->icount.frame++;
16628 + if (status & ATMEL_US_OVRE)
16629 + port->icount.overrun++;
16631 + status &= port->read_status_mask;
16633 + if (status & ATMEL_US_RXBRK)
16635 + else if (status & ATMEL_US_PARE)
16636 + flg = TTY_PARITY;
16637 + else if (status & ATMEL_US_FRAME)
16642 + if (uart_handle_sysrq_char(port, c.ch))
16645 + uart_insert_char(port, status, ATMEL_US_OVRE, c.ch, flg);
16649 + * Drop the lock here since it might end up calling
16650 + * uart_start(), which takes the lock.
16652 + spin_unlock(&port->lock);
16653 + tty_flip_buffer_push(port->info->tty);
16654 + spin_lock(&port->lock);
16657 +static void atmel_rx_from_dma(struct uart_port *port)
16659 + struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
16660 + struct tty_struct *tty = port->info->tty;
16661 + struct atmel_dma_buffer *pdc;
16662 + int rx_idx = atmel_port->pdc_rx_idx;
16663 + unsigned int head;
16664 + unsigned int tail;
16665 + unsigned int count;
16668 + /* Reset the UART timeout early so that we don't miss one */
16669 + UART_PUT_CR(port, ATMEL_US_STTTO);
16671 + pdc = &atmel_port->pdc_rx[rx_idx];
16672 + head = UART_GET_RPR(port) - pdc->dma_addr;
16675 + /* If the PDC has switched buffers, RPR won't contain
16676 + * any address within the current buffer. Since head
16677 + * is unsigned, we just need a one-way comparison to
16680 + * In this case, we just need to consume the entire
16681 + * buffer and resubmit it for DMA. This will clear the
16682 + * ENDRX bit as well, so that we can safely re-enable
16683 + * all interrupts below.
16685 + head = min(head, pdc->dma_size);
16687 + if (likely(head != tail)) {
16688 + dma_sync_single_for_cpu(port->dev, pdc->dma_addr,
16689 + pdc->dma_size, DMA_FROM_DEVICE);
16692 - * End of break detected. If it came along
16693 - * with a character, atmel_rx_chars will
16695 + * head will only wrap around when we recycle
16696 + * the DMA buffer, and when that happens, we
16697 + * explicitly set tail to 0. So head will
16698 + * always be greater than tail.
16700 - UART_PUT_CR(port, ATMEL_US_RSTSTA);
16701 - UART_PUT_IDR(port, ATMEL_US_RXBRK);
16702 - atmel_port->break_active = 0;
16703 + count = head - tail;
16705 + tty_insert_flip_string(tty, pdc->buf + pdc->ofs, count);
16707 + dma_sync_single_for_device(port->dev, pdc->dma_addr,
16708 + pdc->dma_size, DMA_FROM_DEVICE);
16710 + port->icount.rx += count;
16715 + * If the current buffer is full, we need to check if
16716 + * the next one contains any additional data.
16718 + if (head >= pdc->dma_size) {
16720 + UART_PUT_RNPR(port, pdc->dma_addr);
16721 + UART_PUT_RNCR(port, pdc->dma_size);
16723 + rx_idx = !rx_idx;
16724 + atmel_port->pdc_rx_idx = rx_idx;
16726 + } while (head >= pdc->dma_size);
16729 + * Drop the lock here since it might end up calling
16730 + * uart_start(), which takes the lock.
16732 + spin_unlock(&port->lock);
16733 + tty_flip_buffer_push(tty);
16734 + spin_lock(&port->lock);
16736 + UART_PUT_IER(port, ATMEL_US_ENDRX | ATMEL_US_TIMEOUT);
16739 - // TODO: All reads to CSR will clear these interrupts!
16740 - if (pending & ATMEL_US_RIIC) port->icount.rng++;
16741 - if (pending & ATMEL_US_DSRIC) port->icount.dsr++;
16742 - if (pending & ATMEL_US_DCDIC)
16744 + * tasklet handling tty stuff outside the interrupt handler.
16746 +static void atmel_tasklet_func(unsigned long data)
16748 + struct uart_port *port = (struct uart_port *)data;
16749 + struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
16750 + unsigned int status;
16751 + unsigned int status_change;
16753 + /* The interrupt handler does not take the lock */
16754 + spin_lock(&port->lock);
16756 + if (atmel_use_dma_tx(port))
16757 + atmel_tx_dma(port);
16759 + atmel_tx_chars(port);
16761 + status = atmel_port->irq_status;
16762 + status_change = status ^ atmel_port->irq_status_prev;
16764 + if (status_change & (ATMEL_US_RI | ATMEL_US_DSR
16765 + | ATMEL_US_DCD | ATMEL_US_CTS)) {
16766 + /* TODO: All reads to CSR will clear these interrupts! */
16767 + if (status_change & ATMEL_US_RI)
16768 + port->icount.rng++;
16769 + if (status_change & ATMEL_US_DSR)
16770 + port->icount.dsr++;
16771 + if (status_change & ATMEL_US_DCD)
16772 uart_handle_dcd_change(port, !(status & ATMEL_US_DCD));
16773 - if (pending & ATMEL_US_CTSIC)
16774 + if (status_change & ATMEL_US_CTS)
16775 uart_handle_cts_change(port, !(status & ATMEL_US_CTS));
16776 - if (pending & (ATMEL_US_RIIC | ATMEL_US_DSRIC | ATMEL_US_DCDIC | ATMEL_US_CTSIC))
16777 - wake_up_interruptible(&port->info->delta_msr_wait);
16779 - /* Interrupt transmit */
16780 - if (pending & ATMEL_US_TXRDY)
16781 - atmel_tx_chars(port);
16783 - if (pass_counter++ > ATMEL_ISR_PASS_LIMIT)
16785 + wake_up_interruptible(&port->info->delta_msr_wait);
16787 - status = UART_GET_CSR(port);
16788 - pending = status & UART_GET_IMR(port);
16789 + atmel_port->irq_status_prev = status;
16791 - return IRQ_HANDLED;
16793 + if (atmel_use_dma_rx(port))
16794 + atmel_rx_from_dma(port);
16796 + atmel_rx_from_ring(port);
16798 + spin_unlock(&port->lock);
16802 @@ -403,6 +792,8 @@
16804 static int atmel_startup(struct uart_port *port)
16806 + struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
16807 + struct tty_struct *tty = port->info->tty;
16811 @@ -415,13 +806,64 @@
16815 - retval = request_irq(port->irq, atmel_interrupt, IRQF_SHARED, "atmel_serial", port);
16816 + retval = request_irq(port->irq, atmel_interrupt, IRQF_SHARED,
16817 + tty ? tty->name : "atmel_serial", port);
16819 printk("atmel_serial: atmel_startup - Can't get irq\n");
16824 + * Initialize DMA (if necessary)
16826 + if (atmel_use_dma_rx(port)) {
16829 + for (i = 0; i < 2; i++) {
16830 + struct atmel_dma_buffer *pdc = &atmel_port->pdc_rx[i];
16832 + pdc->buf = kmalloc(PDC_BUFFER_SIZE, GFP_KERNEL);
16833 + if (pdc->buf == NULL) {
16835 + dma_unmap_single(port->dev,
16836 + atmel_port->pdc_rx[0].dma_addr,
16838 + DMA_FROM_DEVICE);
16839 + kfree(atmel_port->pdc_rx[0].buf);
16841 + free_irq(port->irq, port);
16844 + pdc->dma_addr = dma_map_single(port->dev,
16847 + DMA_FROM_DEVICE);
16848 + pdc->dma_size = PDC_BUFFER_SIZE;
16852 + atmel_port->pdc_rx_idx = 0;
16854 + UART_PUT_RPR(port, atmel_port->pdc_rx[0].dma_addr);
16855 + UART_PUT_RCR(port, PDC_BUFFER_SIZE);
16857 + UART_PUT_RNPR(port, atmel_port->pdc_rx[1].dma_addr);
16858 + UART_PUT_RNCR(port, PDC_BUFFER_SIZE);
16860 + if (atmel_use_dma_tx(port)) {
16861 + struct atmel_dma_buffer *pdc = &atmel_port->pdc_tx;
16862 + struct circ_buf *xmit = &port->info->xmit;
16864 + pdc->buf = xmit->buf;
16865 + pdc->dma_addr = dma_map_single(port->dev,
16869 + pdc->dma_size = UART_XMIT_SIZE;
16874 * If there is a specific "open" function (to register
16875 * control line interrupts)
16877 @@ -437,9 +879,21 @@
16878 * Finally, enable the serial port
16880 UART_PUT_CR(port, ATMEL_US_RSTSTA | ATMEL_US_RSTRX);
16881 - UART_PUT_CR(port, ATMEL_US_TXEN | ATMEL_US_RXEN); /* enable xmit & rcvr */
16882 + /* enable xmit & rcvr */
16883 + UART_PUT_CR(port, ATMEL_US_TXEN | ATMEL_US_RXEN);
16885 - UART_PUT_IER(port, ATMEL_US_RXRDY); /* enable receive only */
16886 + if (atmel_use_dma_rx(port)) {
16887 + /* set UART timeout */
16888 + UART_PUT_RTOR(port, PDC_RX_TIMEOUT);
16889 + UART_PUT_CR(port, ATMEL_US_STTTO);
16891 + UART_PUT_IER(port, ATMEL_US_ENDRX | ATMEL_US_TIMEOUT);
16892 + /* enable PDC controller */
16893 + UART_PUT_PTCR(port, ATMEL_PDC_RXTEN);
16895 + /* enable receive only */
16896 + UART_PUT_IER(port, ATMEL_US_RXRDY);
16901 @@ -449,6 +903,38 @@
16903 static void atmel_shutdown(struct uart_port *port)
16905 + struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
16907 + * Ensure everything is stopped.
16909 + atmel_stop_rx(port);
16910 + atmel_stop_tx(port);
16913 + * Shut-down the DMA.
16915 + if (atmel_use_dma_rx(port)) {
16918 + for (i = 0; i < 2; i++) {
16919 + struct atmel_dma_buffer *pdc = &atmel_port->pdc_rx[i];
16921 + dma_unmap_single(port->dev,
16924 + DMA_FROM_DEVICE);
16928 + if (atmel_use_dma_tx(port)) {
16929 + struct atmel_dma_buffer *pdc = &atmel_port->pdc_tx;
16931 + dma_unmap_single(port->dev,
16938 * Disable all interrupts, port and break condition.
16940 @@ -471,45 +957,48 @@
16942 * Power / Clock management.
16944 -static void atmel_serial_pm(struct uart_port *port, unsigned int state, unsigned int oldstate)
16945 +static void atmel_serial_pm(struct uart_port *port, unsigned int state,
16946 + unsigned int oldstate)
16948 - struct atmel_uart_port *atmel_port = (struct atmel_uart_port *) port;
16949 + struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
16954 - * Enable the peripheral clock for this serial port.
16955 - * This is called on uart_open() or a resume event.
16957 - clk_enable(atmel_port->clk);
16961 - * Disable the peripheral clock for this serial port.
16962 - * This is called on uart_close() or a suspend event.
16964 - clk_disable(atmel_port->clk);
16967 - printk(KERN_ERR "atmel_serial: unknown pm %d\n", state);
16970 + * Enable the peripheral clock for this serial port.
16971 + * This is called on uart_open() or a resume event.
16973 + clk_enable(atmel_port->clk);
16977 + * Disable the peripheral clock for this serial port.
16978 + * This is called on uart_close() or a suspend event.
16980 + clk_disable(atmel_port->clk);
16983 + printk(KERN_ERR "atmel_serial: unknown pm %d\n", state);
16988 * Change the port parameters
16990 -static void atmel_set_termios(struct uart_port *port, struct ktermios * termios, struct ktermios * old)
16991 +static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
16992 + struct ktermios *old)
16994 unsigned long flags;
16995 unsigned int mode, imr, quot, baud;
16997 /* Get current mode register */
16998 - mode = UART_GET_MR(port) & ~(ATMEL_US_USCLKS | ATMEL_US_CHRL | ATMEL_US_NBSTOP | ATMEL_US_PAR);
16999 + mode = UART_GET_MR(port) & ~(ATMEL_US_USCLKS | ATMEL_US_CHRL
17000 + | ATMEL_US_NBSTOP | ATMEL_US_PAR);
17002 - baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
17003 + baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk / 16);
17004 quot = uart_get_divisor(port, baud);
17006 - if (quot > 65535) { /* BRGR is 16-bit, so switch to slower clock */
17007 + if (quot > 65535) { /* BRGR is 16-bit, so switch to slower clock */
17009 mode |= ATMEL_US_USCLKS_MCK_DIV8;
17011 @@ -536,18 +1025,17 @@
17014 if (termios->c_cflag & PARENB) {
17015 - if (termios->c_cflag & CMSPAR) { /* Mark or Space parity */
17016 + /* Mark or Space parity */
17017 + if (termios->c_cflag & CMSPAR) {
17018 if (termios->c_cflag & PARODD)
17019 mode |= ATMEL_US_PAR_MARK;
17021 mode |= ATMEL_US_PAR_SPACE;
17023 - else if (termios->c_cflag & PARODD)
17024 + } else if (termios->c_cflag & PARODD)
17025 mode |= ATMEL_US_PAR_ODD;
17027 mode |= ATMEL_US_PAR_EVEN;
17031 mode |= ATMEL_US_PAR_NONE;
17033 spin_lock_irqsave(&port->lock, flags);
17034 @@ -558,6 +1046,10 @@
17035 if (termios->c_iflag & (BRKINT | PARMRK))
17036 port->read_status_mask |= ATMEL_US_RXBRK;
17038 + if (atmel_use_dma_rx(port))
17039 + /* need to enable error interrupts */
17040 + UART_PUT_IER(port, port->read_status_mask);
17043 * Characters to ignore
17045 @@ -573,16 +1065,16 @@
17046 if (termios->c_iflag & IGNPAR)
17047 port->ignore_status_mask |= ATMEL_US_OVRE;
17050 - // TODO: Ignore all characters if CREAD is set.
17051 + /* TODO: Ignore all characters if CREAD is set.*/
17053 /* update the per-port timeout */
17054 uart_update_timeout(port, termios->c_cflag, baud);
17056 - /* disable interrupts and drain transmitter */
17057 - imr = UART_GET_IMR(port); /* get interrupt mask */
17058 - UART_PUT_IDR(port, -1); /* disable all interrupts */
17059 - while (!(UART_GET_CSR(port) & ATMEL_US_TXEMPTY)) { barrier(); }
17060 + /* save/disable interrupts and drain transmitter */
17061 + imr = UART_GET_IMR(port);
17062 + UART_PUT_IDR(port, -1);
17063 + while (!(UART_GET_CSR(port) & ATMEL_US_TXEMPTY))
17066 /* disable receiver and transmitter */
17067 UART_PUT_CR(port, ATMEL_US_TXDIS | ATMEL_US_RXDIS);
17068 @@ -708,7 +1200,8 @@
17070 * Configure the port from the platform device resource info.
17072 -static void __devinit atmel_init_port(struct atmel_uart_port *atmel_port, struct platform_device *pdev)
17073 +static void __devinit atmel_init_port(struct atmel_uart_port *atmel_port,
17074 + struct platform_device *pdev)
17076 struct uart_port *port = &atmel_port->uart;
17077 struct atmel_uart_data *data = pdev->dev.platform_data;
17078 @@ -723,6 +1216,11 @@
17079 port->mapbase = pdev->resource[0].start;
17080 port->irq = pdev->resource[1].start;
17082 + tasklet_init(&atmel_port->tasklet, atmel_tasklet_func,
17083 + (unsigned long)port);
17085 + memset(&atmel_port->rx_ring, 0, sizeof(atmel_port->rx_ring));
17088 /* Already mapped by setup code */
17089 port->membase = data->regs;
17090 @@ -731,11 +1229,17 @@
17091 port->membase = NULL;
17094 - if (!atmel_port->clk) { /* for console, the clock could already be configured */
17095 + /* for console, the clock could already be configured */
17096 + if (!atmel_port->clk) {
17097 atmel_port->clk = clk_get(&pdev->dev, "usart");
17098 clk_enable(atmel_port->clk);
17099 port->uartclk = clk_get_rate(atmel_port->clk);
17102 + atmel_port->use_dma_rx = data->use_dma_rx;
17103 + atmel_port->use_dma_tx = data->use_dma_tx;
17104 + if (atmel_use_dma_tx(port))
17105 + port->fifosize = PDC_BUFFER_SIZE;
17109 @@ -755,12 +1259,11 @@
17110 atmel_pops.set_wake = fns->set_wake;
17114 #ifdef CONFIG_SERIAL_ATMEL_CONSOLE
17115 static void atmel_console_putchar(struct uart_port *port, int ch)
17117 while (!(UART_GET_CSR(port) & ATMEL_US_TXRDY))
17120 UART_PUT_CHAR(port, ch);
17123 @@ -773,38 +1276,40 @@
17124 unsigned int status, imr;
17127 - * First, save IMR and then disable interrupts
17128 + * First, save IMR and then disable interrupts
17130 - imr = UART_GET_IMR(port); /* get interrupt mask */
17131 + imr = UART_GET_IMR(port);
17132 UART_PUT_IDR(port, ATMEL_US_RXRDY | ATMEL_US_TXRDY);
17134 uart_console_write(port, s, count, atmel_console_putchar);
17137 - * Finally, wait for transmitter to become empty
17138 - * and restore IMR
17139 + * Finally, wait for transmitter to become empty
17140 + * and restore IMR
17143 status = UART_GET_CSR(port);
17144 } while (!(status & ATMEL_US_TXRDY));
17145 - UART_PUT_IER(port, imr); /* set interrupts back the way they were */
17146 + /* set interrupts back the way they were */
17147 + UART_PUT_IER(port, imr);
17151 - * If the port was already initialised (eg, by a boot loader), try to determine
17152 - * the current setup.
17153 + * If the port was already initialised (eg, by a boot loader),
17154 + * try to determine the current setup.
17156 -static void __init atmel_console_get_options(struct uart_port *port, int *baud, int *parity, int *bits)
17157 +static void __init atmel_console_get_options(struct uart_port *port, int *baud,
17158 + int *parity, int *bits)
17160 unsigned int mr, quot;
17162 -// TODO: CR is a write-only register
17163 -// unsigned int cr;
17165 -// cr = UART_GET_CR(port) & (ATMEL_US_RXEN | ATMEL_US_TXEN);
17166 -// if (cr == (ATMEL_US_RXEN | ATMEL_US_TXEN)) {
17167 -// /* ok, the port was enabled */
17170 + * If the baud rate generator isn't running, the port wasn't
17171 + * initialized by the boot loader.
17173 + quot = UART_GET_BRGR(port);
17177 mr = UART_GET_MR(port) & ATMEL_US_CHRL;
17178 if (mr == ATMEL_US_CHRL_8)
17179 @@ -824,7 +1329,6 @@
17180 * lower than one of those, as it would make us fall through
17181 * to a much lower baud rate than we really want.
17183 - quot = UART_GET_BRGR(port);
17184 *baud = port->uartclk / (16 * (quot - 1));
17187 @@ -836,10 +1340,12 @@
17191 - if (port->membase == 0) /* Port not initialized yet - delay setup */
17192 + if (port->membase == NULL) {
17193 + /* Port not initialized yet - delay setup */
17197 - UART_PUT_IDR(port, -1); /* disable interrupts */
17198 + UART_PUT_IDR(port, -1);
17199 UART_PUT_CR(port, ATMEL_US_RSTSTA | ATMEL_US_RSTRX);
17200 UART_PUT_CR(port, ATMEL_US_TXEN | ATMEL_US_RXEN);
17202 @@ -871,13 +1377,16 @@
17203 static int __init atmel_console_init(void)
17205 if (atmel_default_console_device) {
17206 - add_preferred_console(ATMEL_DEVICENAME, atmel_default_console_device->id, NULL);
17207 - atmel_init_port(&(atmel_ports[atmel_default_console_device->id]), atmel_default_console_device);
17208 + add_preferred_console(ATMEL_DEVICENAME,
17209 + atmel_default_console_device->id, NULL);
17210 + atmel_init_port(&atmel_ports[atmel_default_console_device->id],
17211 + atmel_default_console_device);
17212 register_console(&atmel_console);
17218 console_initcall(atmel_console_init);
17221 @@ -885,34 +1394,48 @@
17223 static int __init atmel_late_console_init(void)
17225 - if (atmel_default_console_device && !(atmel_console.flags & CON_ENABLED))
17226 + if (atmel_default_console_device
17227 + && !(atmel_console.flags & CON_ENABLED))
17228 register_console(&atmel_console);
17233 core_initcall(atmel_late_console_init);
17235 +static inline bool atmel_is_console_port(struct uart_port *port)
17237 + return port->cons && port->cons->index == port->line;
17241 #define ATMEL_CONSOLE_DEVICE NULL
17243 +static inline bool atmel_is_console_port(struct uart_port *port)
17249 static struct uart_driver atmel_uart = {
17250 - .owner = THIS_MODULE,
17251 - .driver_name = "atmel_serial",
17252 - .dev_name = ATMEL_DEVICENAME,
17253 - .major = SERIAL_ATMEL_MAJOR,
17254 - .minor = MINOR_START,
17255 - .nr = ATMEL_MAX_UART,
17256 - .cons = ATMEL_CONSOLE_DEVICE,
17257 + .owner = THIS_MODULE,
17258 + .driver_name = "atmel_serial",
17259 + .dev_name = ATMEL_DEVICENAME,
17260 + .major = SERIAL_ATMEL_MAJOR,
17261 + .minor = MINOR_START,
17262 + .nr = ATMEL_MAX_UART,
17263 + .cons = ATMEL_CONSOLE_DEVICE,
17267 -static int atmel_serial_suspend(struct platform_device *pdev, pm_message_t state)
17268 +static int atmel_serial_suspend(struct platform_device *pdev,
17269 + pm_message_t state)
17271 struct uart_port *port = platform_get_drvdata(pdev);
17272 - struct atmel_uart_port *atmel_port = (struct atmel_uart_port *) port;
17273 + struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
17275 - if (device_may_wakeup(&pdev->dev) && !at91_suspend_entering_slow_clock())
17276 + if (device_may_wakeup(&pdev->dev)
17277 + && !at91_suspend_entering_slow_clock())
17278 enable_irq_wake(port->irq);
17280 uart_suspend_port(&atmel_uart, port);
17281 @@ -925,13 +1448,12 @@
17282 static int atmel_serial_resume(struct platform_device *pdev)
17284 struct uart_port *port = platform_get_drvdata(pdev);
17285 - struct atmel_uart_port *atmel_port = (struct atmel_uart_port *) port;
17286 + struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
17288 if (atmel_port->suspended) {
17289 uart_resume_port(&atmel_uart, port);
17290 atmel_port->suspended = 0;
17294 disable_irq_wake(port->irq);
17297 @@ -944,15 +1466,40 @@
17298 static int __devinit atmel_serial_probe(struct platform_device *pdev)
17300 struct atmel_uart_port *port;
17304 + BUILD_BUG_ON(!is_power_of_2(ATMEL_SERIAL_RINGSIZE));
17306 port = &atmel_ports[pdev->id];
17307 atmel_init_port(port, pdev);
17309 + if (!atmel_use_dma_rx(&port->uart)) {
17311 + data = kmalloc(sizeof(struct atmel_uart_char)
17312 + * ATMEL_SERIAL_RINGSIZE, GFP_KERNEL);
17314 + goto err_alloc_ring;
17315 + port->rx_ring.buf = data;
17318 ret = uart_add_one_port(&atmel_uart, &port->uart);
17320 - device_init_wakeup(&pdev->dev, 1);
17321 - platform_set_drvdata(pdev, port);
17323 + goto err_add_port;
17325 + device_init_wakeup(&pdev->dev, 1);
17326 + platform_set_drvdata(pdev, port);
17331 + kfree(port->rx_ring.buf);
17332 + port->rx_ring.buf = NULL;
17334 + if (!atmel_is_console_port(&port->uart)) {
17335 + clk_disable(port->clk);
17336 + clk_put(port->clk);
17337 + port->clk = NULL;
17341 @@ -961,19 +1508,21 @@
17342 static int __devexit atmel_serial_remove(struct platform_device *pdev)
17344 struct uart_port *port = platform_get_drvdata(pdev);
17345 - struct atmel_uart_port *atmel_port = (struct atmel_uart_port *) port;
17346 + struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
17349 - clk_disable(atmel_port->clk);
17350 - clk_put(atmel_port->clk);
17352 device_init_wakeup(&pdev->dev, 0);
17353 platform_set_drvdata(pdev, NULL);
17356 - ret = uart_remove_one_port(&atmel_uart, port);
17359 + ret = uart_remove_one_port(&atmel_uart, port);
17361 + tasklet_kill(&atmel_port->tasklet);
17362 + kfree(atmel_port->rx_ring.buf);
17364 + /* "port" is allocated statically, so we shouldn't free it */
17366 + clk_disable(atmel_port->clk);
17367 + clk_put(atmel_port->clk);
17371 --- a/drivers/serial/atmel_serial.h
17375 - * drivers/serial/atmel_serial.h
17377 - * Copyright (C) 2005 Ivan Kokshaysky
17378 - * Copyright (C) SAN People
17380 - * USART registers.
17381 - * Based on AT91RM9200 datasheet revision E.
17383 - * This program is free software; you can redistribute it and/or modify
17384 - * it under the terms of the GNU General Public License as published by
17385 - * the Free Software Foundation; either version 2 of the License, or
17386 - * (at your option) any later version.
17389 -#ifndef ATMEL_SERIAL_H
17390 -#define ATMEL_SERIAL_H
17392 -#define ATMEL_US_CR 0x00 /* Control Register */
17393 -#define ATMEL_US_RSTRX (1 << 2) /* Reset Receiver */
17394 -#define ATMEL_US_RSTTX (1 << 3) /* Reset Transmitter */
17395 -#define ATMEL_US_RXEN (1 << 4) /* Receiver Enable */
17396 -#define ATMEL_US_RXDIS (1 << 5) /* Receiver Disable */
17397 -#define ATMEL_US_TXEN (1 << 6) /* Transmitter Enable */
17398 -#define ATMEL_US_TXDIS (1 << 7) /* Transmitter Disable */
17399 -#define ATMEL_US_RSTSTA (1 << 8) /* Reset Status Bits */
17400 -#define ATMEL_US_STTBRK (1 << 9) /* Start Break */
17401 -#define ATMEL_US_STPBRK (1 << 10) /* Stop Break */
17402 -#define ATMEL_US_STTTO (1 << 11) /* Start Time-out */
17403 -#define ATMEL_US_SENDA (1 << 12) /* Send Address */
17404 -#define ATMEL_US_RSTIT (1 << 13) /* Reset Iterations */
17405 -#define ATMEL_US_RSTNACK (1 << 14) /* Reset Non Acknowledge */
17406 -#define ATMEL_US_RETTO (1 << 15) /* Rearm Time-out */
17407 -#define ATMEL_US_DTREN (1 << 16) /* Data Terminal Ready Enable [AT91RM9200 only] */
17408 -#define ATMEL_US_DTRDIS (1 << 17) /* Data Terminal Ready Disable [AT91RM9200 only] */
17409 -#define ATMEL_US_RTSEN (1 << 18) /* Request To Send Enable */
17410 -#define ATMEL_US_RTSDIS (1 << 19) /* Request To Send Disable */
17412 -#define ATMEL_US_MR 0x04 /* Mode Register */
17413 -#define ATMEL_US_USMODE (0xf << 0) /* Mode of the USART */
17414 -#define ATMEL_US_USMODE_NORMAL 0
17415 -#define ATMEL_US_USMODE_RS485 1
17416 -#define ATMEL_US_USMODE_HWHS 2
17417 -#define ATMEL_US_USMODE_MODEM 3
17418 -#define ATMEL_US_USMODE_ISO7816_T0 4
17419 -#define ATMEL_US_USMODE_ISO7816_T1 6
17420 -#define ATMEL_US_USMODE_IRDA 8
17421 -#define ATMEL_US_USCLKS (3 << 4) /* Clock Selection */
17422 -#define ATMEL_US_USCLKS_MCK (0 << 4)
17423 -#define ATMEL_US_USCLKS_MCK_DIV8 (1 << 4)
17424 -#define ATMEL_US_USCLKS_SCK (3 << 4)
17425 -#define ATMEL_US_CHRL (3 << 6) /* Character Length */
17426 -#define ATMEL_US_CHRL_5 (0 << 6)
17427 -#define ATMEL_US_CHRL_6 (1 << 6)
17428 -#define ATMEL_US_CHRL_7 (2 << 6)
17429 -#define ATMEL_US_CHRL_8 (3 << 6)
17430 -#define ATMEL_US_SYNC (1 << 8) /* Synchronous Mode Select */
17431 -#define ATMEL_US_PAR (7 << 9) /* Parity Type */
17432 -#define ATMEL_US_PAR_EVEN (0 << 9)
17433 -#define ATMEL_US_PAR_ODD (1 << 9)
17434 -#define ATMEL_US_PAR_SPACE (2 << 9)
17435 -#define ATMEL_US_PAR_MARK (3 << 9)
17436 -#define ATMEL_US_PAR_NONE (4 << 9)
17437 -#define ATMEL_US_PAR_MULTI_DROP (6 << 9)
17438 -#define ATMEL_US_NBSTOP (3 << 12) /* Number of Stop Bits */
17439 -#define ATMEL_US_NBSTOP_1 (0 << 12)
17440 -#define ATMEL_US_NBSTOP_1_5 (1 << 12)
17441 -#define ATMEL_US_NBSTOP_2 (2 << 12)
17442 -#define ATMEL_US_CHMODE (3 << 14) /* Channel Mode */
17443 -#define ATMEL_US_CHMODE_NORMAL (0 << 14)
17444 -#define ATMEL_US_CHMODE_ECHO (1 << 14)
17445 -#define ATMEL_US_CHMODE_LOC_LOOP (2 << 14)
17446 -#define ATMEL_US_CHMODE_REM_LOOP (3 << 14)
17447 -#define ATMEL_US_MSBF (1 << 16) /* Bit Order */
17448 -#define ATMEL_US_MODE9 (1 << 17) /* 9-bit Character Length */
17449 -#define ATMEL_US_CLKO (1 << 18) /* Clock Output Select */
17450 -#define ATMEL_US_OVER (1 << 19) /* Oversampling Mode */
17451 -#define ATMEL_US_INACK (1 << 20) /* Inhibit Non Acknowledge */
17452 -#define ATMEL_US_DSNACK (1 << 21) /* Disable Successive NACK */
17453 -#define ATMEL_US_MAX_ITER (7 << 24) /* Max Iterations */
17454 -#define ATMEL_US_FILTER (1 << 28) /* Infrared Receive Line Filter */
17456 -#define ATMEL_US_IER 0x08 /* Interrupt Enable Register */
17457 -#define ATMEL_US_RXRDY (1 << 0) /* Receiver Ready */
17458 -#define ATMEL_US_TXRDY (1 << 1) /* Transmitter Ready */
17459 -#define ATMEL_US_RXBRK (1 << 2) /* Break Received / End of Break */
17460 -#define ATMEL_US_ENDRX (1 << 3) /* End of Receiver Transfer */
17461 -#define ATMEL_US_ENDTX (1 << 4) /* End of Transmitter Transfer */
17462 -#define ATMEL_US_OVRE (1 << 5) /* Overrun Error */
17463 -#define ATMEL_US_FRAME (1 << 6) /* Framing Error */
17464 -#define ATMEL_US_PARE (1 << 7) /* Parity Error */
17465 -#define ATMEL_US_TIMEOUT (1 << 8) /* Receiver Time-out */
17466 -#define ATMEL_US_TXEMPTY (1 << 9) /* Transmitter Empty */
17467 -#define ATMEL_US_ITERATION (1 << 10) /* Max number of Repetitions Reached */
17468 -#define ATMEL_US_TXBUFE (1 << 11) /* Transmission Buffer Empty */
17469 -#define ATMEL_US_RXBUFF (1 << 12) /* Reception Buffer Full */
17470 -#define ATMEL_US_NACK (1 << 13) /* Non Acknowledge */
17471 -#define ATMEL_US_RIIC (1 << 16) /* Ring Indicator Input Change [AT91RM9200 only] */
17472 -#define ATMEL_US_DSRIC (1 << 17) /* Data Set Ready Input Change [AT91RM9200 only] */
17473 -#define ATMEL_US_DCDIC (1 << 18) /* Data Carrier Detect Input Change [AT91RM9200 only] */
17474 -#define ATMEL_US_CTSIC (1 << 19) /* Clear to Send Input Change */
17475 -#define ATMEL_US_RI (1 << 20) /* RI */
17476 -#define ATMEL_US_DSR (1 << 21) /* DSR */
17477 -#define ATMEL_US_DCD (1 << 22) /* DCD */
17478 -#define ATMEL_US_CTS (1 << 23) /* CTS */
17480 -#define ATMEL_US_IDR 0x0c /* Interrupt Disable Register */
17481 -#define ATMEL_US_IMR 0x10 /* Interrupt Mask Register */
17482 -#define ATMEL_US_CSR 0x14 /* Channel Status Register */
17483 -#define ATMEL_US_RHR 0x18 /* Receiver Holding Register */
17484 -#define ATMEL_US_THR 0x1c /* Transmitter Holding Register */
17485 -#define ATMEL_US_SYNH (1 << 15) /* Transmit/Receive Sync [AT91SAM9261 only] */
17487 -#define ATMEL_US_BRGR 0x20 /* Baud Rate Generator Register */
17488 -#define ATMEL_US_CD (0xffff << 0) /* Clock Divider */
17490 -#define ATMEL_US_RTOR 0x24 /* Receiver Time-out Register */
17491 -#define ATMEL_US_TO (0xffff << 0) /* Time-out Value */
17493 -#define ATMEL_US_TTGR 0x28 /* Transmitter Timeguard Register */
17494 -#define ATMEL_US_TG (0xff << 0) /* Timeguard Value */
17496 -#define ATMEL_US_FIDI 0x40 /* FI DI Ratio Register */
17497 -#define ATMEL_US_NER 0x44 /* Number of Errors Register */
17498 -#define ATMEL_US_IF 0x4c /* IrDA Filter Register */
17501 --- a/drivers/serial/Kconfig
17502 +++ b/drivers/serial/Kconfig
17503 @@ -380,6 +380,21 @@
17504 console is the device which receives all kernel messages and
17505 warnings and which allows logins in single user mode).
17507 +config SERIAL_ATMEL_PDC
17508 + bool "Support DMA transfers on AT91 / AT32 serial port"
17509 + depends on SERIAL_ATMEL
17512 + Say Y here if you wish to use the PDC to do DMA transfers to
17513 + and from the Atmel AT91 / AT32 serial port. In order to
17514 + actually use DMA transfers, make sure that the use_dma_tx
17515 + and use_dma_rx members in the atmel_uart_data struct is set
17516 + appropriately for each port.
17518 + Note that break and error handling currently doesn't work
17519 + properly when DMA is enabled. Make sure that ports where
17520 + this matters don't use DMA.
17522 config SERIAL_ATMEL_TTYAT
17523 bool "Install as device ttyATn instead of ttySn"
17524 depends on SERIAL_ATMEL=y
17525 --- a/drivers/spi/atmel_spi.c
17526 +++ b/drivers/spi/atmel_spi.c
17529 struct list_head queue;
17530 struct spi_transfer *current_transfer;
17531 - unsigned long remaining_bytes;
17532 + unsigned long current_remaining_bytes;
17533 + struct spi_transfer *next_transfer;
17534 + unsigned long next_remaining_bytes;
17537 dma_addr_t buffer_dma;
17538 @@ -113,6 +115,16 @@
17539 unsigned gpio = (unsigned) spi->controller_data;
17540 unsigned active = spi->mode & SPI_CS_HIGH;
17544 + u32 cpol = (spi->mode & SPI_CPOL) ? SPI_BIT(CPOL) : 0;
17546 + /* Make sure clock polarity is correct */
17547 + for (i = 0; i < spi->master->num_chipselect; i++) {
17548 + csr = spi_readl(as, CSR0 + 4 * i);
17549 + if ((csr ^ cpol) & SPI_BIT(CPOL))
17550 + spi_writel(as, CSR0 + 4 * i, csr ^ SPI_BIT(CPOL));
17553 /* only deactivate *this* device; sometimes transfers to
17554 * another device may be active when this routine is called.
17555 @@ -131,6 +143,48 @@
17556 gpio_set_value(gpio, !active);
17559 +static inline int atmel_spi_xfer_is_last(struct spi_message *msg,
17560 + struct spi_transfer *xfer)
17562 + return msg->transfers.prev == &xfer->transfer_list;
17565 +static inline int atmel_spi_xfer_can_be_chained(struct spi_transfer *xfer)
17567 + return xfer->delay_usecs == 0 && !xfer->cs_change;
17570 +static void atmel_spi_next_xfer_data(struct spi_master *master,
17571 + struct spi_transfer *xfer,
17572 + dma_addr_t *tx_dma,
17573 + dma_addr_t *rx_dma,
17576 + struct atmel_spi *as = spi_master_get_devdata(master);
17579 + /* use scratch buffer only when rx or tx data is unspecified */
17580 + if (xfer->rx_buf)
17581 + *rx_dma = xfer->rx_dma + xfer->len - len;
17583 + *rx_dma = as->buffer_dma;
17584 + if (len > BUFFER_SIZE)
17585 + len = BUFFER_SIZE;
17587 + if (xfer->tx_buf)
17588 + *tx_dma = xfer->tx_dma + xfer->len - len;
17590 + *tx_dma = as->buffer_dma;
17591 + if (len > BUFFER_SIZE)
17592 + len = BUFFER_SIZE;
17593 + memset(as->buffer, 0, len);
17594 + dma_sync_single_for_device(&as->pdev->dev,
17595 + as->buffer_dma, len, DMA_TO_DEVICE);
17602 * Submit next transfer for DMA.
17603 * lock is held, spi irq is blocked
17604 @@ -140,53 +194,78 @@
17606 struct atmel_spi *as = spi_master_get_devdata(master);
17607 struct spi_transfer *xfer;
17609 + u32 len, remaining, total;
17610 dma_addr_t tx_dma, rx_dma;
17612 - xfer = as->current_transfer;
17613 - if (!xfer || as->remaining_bytes == 0) {
17615 - xfer = list_entry(xfer->transfer_list.next,
17616 - struct spi_transfer, transfer_list);
17618 - xfer = list_entry(msg->transfers.next,
17619 - struct spi_transfer, transfer_list);
17620 - as->remaining_bytes = xfer->len;
17621 - as->current_transfer = xfer;
17622 + if (!as->current_transfer)
17623 + xfer = list_entry(msg->transfers.next,
17624 + struct spi_transfer, transfer_list);
17625 + else if (!as->next_transfer)
17626 + xfer = list_entry(as->current_transfer->transfer_list.next,
17627 + struct spi_transfer, transfer_list);
17633 + atmel_spi_next_xfer_data(master, xfer, &tx_dma, &rx_dma, &len);
17634 + remaining = xfer->len - len;
17636 + spi_writel(as, RPR, rx_dma);
17637 + spi_writel(as, TPR, tx_dma);
17639 + if (msg->spi->bits_per_word > 8)
17641 + spi_writel(as, RCR, len);
17642 + spi_writel(as, TCR, len);
17644 + dev_dbg(&msg->spi->dev,
17645 + " start xfer %p: len %u tx %p/%08x rx %p/%08x\n",
17646 + xfer, xfer->len, xfer->tx_buf, xfer->tx_dma,
17647 + xfer->rx_buf, xfer->rx_dma);
17649 + xfer = as->next_transfer;
17650 + remaining = as->next_remaining_bytes;
17653 - len = as->remaining_bytes;
17654 + as->current_transfer = xfer;
17655 + as->current_remaining_bytes = remaining;
17657 - tx_dma = xfer->tx_dma + xfer->len - len;
17658 - rx_dma = xfer->rx_dma + xfer->len - len;
17659 + if (remaining > 0)
17661 + else if (!atmel_spi_xfer_is_last(msg, xfer)
17662 + && atmel_spi_xfer_can_be_chained(xfer)) {
17663 + xfer = list_entry(xfer->transfer_list.next,
17664 + struct spi_transfer, transfer_list);
17669 - /* use scratch buffer only when rx or tx data is unspecified */
17670 - if (!xfer->rx_buf) {
17671 - rx_dma = as->buffer_dma;
17672 - if (len > BUFFER_SIZE)
17673 - len = BUFFER_SIZE;
17675 - if (!xfer->tx_buf) {
17676 - tx_dma = as->buffer_dma;
17677 - if (len > BUFFER_SIZE)
17678 - len = BUFFER_SIZE;
17679 - memset(as->buffer, 0, len);
17680 - dma_sync_single_for_device(&as->pdev->dev,
17681 - as->buffer_dma, len, DMA_TO_DEVICE);
17683 + as->next_transfer = xfer;
17685 - spi_writel(as, RPR, rx_dma);
17686 - spi_writel(as, TPR, tx_dma);
17689 + atmel_spi_next_xfer_data(master, xfer, &tx_dma, &rx_dma, &len);
17690 + as->next_remaining_bytes = total - len;
17692 + spi_writel(as, RNPR, rx_dma);
17693 + spi_writel(as, TNPR, tx_dma);
17695 + if (msg->spi->bits_per_word > 8)
17697 + spi_writel(as, RNCR, len);
17698 + spi_writel(as, TNCR, len);
17700 + dev_dbg(&msg->spi->dev,
17701 + " next xfer %p: len %u tx %p/%08x rx %p/%08x\n",
17702 + xfer, xfer->len, xfer->tx_buf, xfer->tx_dma,
17703 + xfer->rx_buf, xfer->rx_dma);
17705 + spi_writel(as, RNCR, 0);
17706 + spi_writel(as, TNCR, 0);
17709 - as->remaining_bytes -= len;
17710 - if (msg->spi->bits_per_word > 8)
17713 - /* REVISIT: when xfer->delay_usecs == 0, the PDC "next transfer"
17714 - * mechanism might help avoid the IRQ latency between transfers
17715 - * (and improve the nCS0 errata handling on at91rm9200 chips)
17717 - * We're also waiting for ENDRX before we start the next
17718 + /* REVISIT: We're waiting for ENDRX before we start the next
17719 * transfer because we need to handle some difficult timing
17720 * issues otherwise. If we wait for ENDTX in one transfer and
17721 * then starts waiting for ENDRX in the next, it's difficult
17722 @@ -196,17 +275,7 @@
17724 * It should be doable, though. Just not now...
17726 - spi_writel(as, TNCR, 0);
17727 - spi_writel(as, RNCR, 0);
17728 spi_writel(as, IER, SPI_BIT(ENDRX) | SPI_BIT(OVRES));
17730 - dev_dbg(&msg->spi->dev,
17731 - " start xfer %p: len %u tx %p/%08x rx %p/%08x imr %03x\n",
17732 - xfer, xfer->len, xfer->tx_buf, xfer->tx_dma,
17733 - xfer->rx_buf, xfer->rx_dma, spi_readl(as, IMR));
17735 - spi_writel(as, RCR, len);
17736 - spi_writel(as, TCR, len);
17737 spi_writel(as, PTCR, SPI_BIT(TXTEN) | SPI_BIT(RXTEN));
17740 @@ -304,6 +373,7 @@
17741 spin_lock(&as->lock);
17743 as->current_transfer = NULL;
17744 + as->next_transfer = NULL;
17746 /* continue if needed */
17747 if (list_empty(&as->queue) || as->stopping)
17748 @@ -387,7 +457,7 @@
17750 spi_writel(as, IDR, pending);
17752 - if (as->remaining_bytes == 0) {
17753 + if (as->current_remaining_bytes == 0) {
17754 msg->actual_length += xfer->len;
17756 if (!msg->is_dma_mapped)
17757 @@ -397,7 +467,7 @@
17758 if (xfer->delay_usecs)
17759 udelay(xfer->delay_usecs);
17761 - if (msg->transfers.prev == &xfer->transfer_list) {
17762 + if (atmel_spi_xfer_is_last(msg, xfer)) {
17763 /* report completed message */
17764 atmel_spi_msg_done(master, as, msg, 0,
17766 @@ -500,9 +570,14 @@
17767 if (!(spi->mode & SPI_CPHA))
17768 csr |= SPI_BIT(NCPHA);
17770 - /* TODO: DLYBS and DLYBCT */
17771 - csr |= SPI_BF(DLYBS, 10);
17772 - csr |= SPI_BF(DLYBCT, 10);
17773 + /* DLYBS is mostly irrelevant since we manage chipselect using GPIOs.
17775 + * DLYBCT would add delays between words, slowing down transfers.
17776 + * It could potentially be useful to cope with DMA bottlenecks, but
17777 + * in those cases it's probably best to just use a lower bitrate.
17779 + csr |= SPI_BF(DLYBS, 0);
17780 + csr |= SPI_BF(DLYBCT, 0);
17782 /* chipselect must have been muxed as GPIO (e.g. in board setup) */
17783 npcs_pin = (unsigned int)spi->controller_data;
17784 --- a/drivers/usb/gadget/atmel_usba_udc.c
17785 +++ b/drivers/usb/gadget/atmel_usba_udc.c
17787 #include <linux/platform_device.h>
17788 #include <linux/usb/ch9.h>
17789 #include <linux/usb/gadget.h>
17790 +#include <linux/usb/atmel_usba_udc.h>
17791 #include <linux/delay.h>
17793 #include <asm/gpio.h>
17797 static struct usba_udc the_udc;
17798 +static struct usba_ep *usba_ep;
17800 #ifdef CONFIG_USB_GADGET_DEBUG_FS
17801 #include <linux/debugfs.h>
17802 @@ -324,53 +326,6 @@
17806 -static void copy_to_fifo(void __iomem *fifo, const void *buf, int len)
17808 - unsigned long tmp;
17810 - DBG(DBG_FIFO, "copy to FIFO (len %d):\n", len);
17811 - for (; len > 0; len -= 4, buf += 4, fifo += 4) {
17812 - tmp = *(unsigned long *)buf;
17814 - DBG(DBG_FIFO, " -> %08lx\n", tmp);
17815 - __raw_writel(tmp, fifo);
17818 - DBG(DBG_FIFO, " -> %02lx\n", tmp >> 24);
17819 - __raw_writeb(tmp >> 24, fifo);
17828 -static void copy_from_fifo(void *buf, void __iomem *fifo, int len)
17831 - unsigned long *w;
17832 - unsigned char *b;
17834 - unsigned long tmp;
17836 - DBG(DBG_FIFO, "copy from FIFO (len %d):\n", len);
17837 - for (p.w = buf; len > 0; len -= 4, p.w++, fifo += 4) {
17839 - tmp = __raw_readl(fifo);
17841 - DBG(DBG_FIFO, " -> %08lx\n", tmp);
17844 - tmp = __raw_readb(fifo);
17846 - DBG(DBG_FIFO, " -> %02lx\n", tmp);
17853 static void next_fifo_transaction(struct usba_ep *ep, struct usba_request *req)
17855 unsigned int transaction_len;
17856 @@ -387,7 +342,7 @@
17857 ep->ep.name, req, transaction_len,
17858 req->last_transaction ? ", done" : "");
17860 - copy_to_fifo(ep->fifo, req->req.buf + req->req.actual, transaction_len);
17861 + memcpy_toio(ep->fifo, req->req.buf + req->req.actual, transaction_len);
17862 usba_ep_writel(ep, SET_STA, USBA_TX_PK_RDY);
17863 req->req.actual += transaction_len;
17865 @@ -476,7 +431,7 @@
17866 bytecount = req->req.length - req->req.actual;
17869 - copy_from_fifo(req->req.buf + req->req.actual,
17870 + memcpy_fromio(req->req.buf + req->req.actual,
17871 ep->fifo, bytecount);
17872 req->req.actual += bytecount;
17874 @@ -1029,33 +984,6 @@
17875 .set_selfpowered = usba_udc_set_selfpowered,
17878 -#define EP(nam, idx, maxpkt, maxbk, dma, isoc) \
17881 - .ops = &usba_ep_ops, \
17883 - .maxpacket = maxpkt, \
17885 - .udc = &the_udc, \
17886 - .queue = LIST_HEAD_INIT(usba_ep[idx].queue), \
17887 - .fifo_size = maxpkt, \
17888 - .nr_banks = maxbk, \
17890 - .can_dma = dma, \
17891 - .can_isoc = isoc, \
17894 -static struct usba_ep usba_ep[] = {
17895 - EP("ep0", 0, 64, 1, 0, 0),
17896 - EP("ep1in-bulk", 1, 512, 2, 1, 1),
17897 - EP("ep2out-bulk", 2, 512, 2, 1, 1),
17898 - EP("ep3in-int", 3, 64, 3, 1, 0),
17899 - EP("ep4out-int", 4, 64, 3, 1, 0),
17900 - EP("ep5in-iso", 5, 1024, 3, 1, 1),
17901 - EP("ep6out-iso", 6, 1024, 3, 1, 1),
17905 static struct usb_endpoint_descriptor usba_ep0_desc = {
17906 .bLength = USB_DT_ENDPOINT_SIZE,
17907 .bDescriptorType = USB_DT_ENDPOINT,
17908 @@ -1074,7 +1002,6 @@
17909 static struct usba_udc the_udc = {
17911 .ops = &usba_udc_ops,
17912 - .ep0 = &usba_ep[0].ep,
17913 .ep_list = LIST_HEAD_INIT(the_udc.gadget.ep_list),
17915 .name = "atmel_usba_udc",
17916 @@ -1231,7 +1158,7 @@
17918 usba_ep_writel(ep, CTL_ENB, USBA_EPT_ENABLE);
17919 usba_writel(udc, TST, USBA_TST_PKT_MODE);
17920 - copy_to_fifo(ep->fifo, test_packet_buffer,
17921 + memcpy_toio(ep->fifo, test_packet_buffer,
17922 sizeof(test_packet_buffer));
17923 usba_ep_writel(ep, SET_STA, USBA_TX_PK_RDY);
17924 dev_info(dev, "Entering Test_Packet mode...\n");
17925 @@ -1539,7 +1466,7 @@
17928 DBG(DBG_FIFO, "Copying ctrl request from 0x%p:\n", ep->fifo);
17929 - copy_from_fifo(crq.data, ep->fifo, sizeof(crq));
17930 + memcpy_fromio(crq.data, ep->fifo, sizeof(crq));
17932 /* Free up one bank in the FIFO so that we can
17933 * generate or receive a reply right away. */
17934 @@ -1911,7 +1838,7 @@
17936 regs = platform_get_resource(pdev, IORESOURCE_MEM, CTRL_IOMEM_ID);
17937 fifo = platform_get_resource(pdev, IORESOURCE_MEM, FIFO_IOMEM_ID);
17938 - if (!regs || !fifo)
17939 + if (!regs || !fifo || !pdata)
17942 irq = platform_get_irq(pdev, 0);
17943 @@ -1959,16 +1886,44 @@
17944 usba_writel(udc, CTRL, 0);
17947 + usba_ep = kmalloc(sizeof(struct usba_ep) * pdata->num_ep,
17950 + goto err_alloc_ep;
17952 + the_udc.gadget.ep0 = &usba_ep[0].ep;
17954 INIT_LIST_HEAD(&usba_ep[0].ep.ep_list);
17955 usba_ep[0].ep_regs = udc->regs + USBA_EPT_BASE(0);
17956 usba_ep[0].dma_regs = udc->regs + USBA_DMA_BASE(0);
17957 usba_ep[0].fifo = udc->fifo + USBA_FIFO_BASE(0);
17958 - for (i = 1; i < ARRAY_SIZE(usba_ep); i++) {
17959 + usba_ep[0].ep.ops = &usba_ep_ops;
17960 + usba_ep[0].ep.name = pdata->ep[0].name;
17961 + usba_ep[0].ep.maxpacket = pdata->ep[0].fifo_size;
17962 + usba_ep[0].udc = &the_udc;
17963 + INIT_LIST_HEAD(&usba_ep[0].queue);
17964 + usba_ep[0].fifo_size = pdata->ep[0].fifo_size;
17965 + usba_ep[0].nr_banks = pdata->ep[0].nr_banks;
17966 + usba_ep[0].index = pdata->ep[0].index;
17967 + usba_ep[0].can_dma = pdata->ep[0].can_dma;
17968 + usba_ep[0].can_isoc = pdata->ep[0].can_isoc;
17970 + for (i = 1; i < pdata->num_ep; i++) {
17971 struct usba_ep *ep = &usba_ep[i];
17973 ep->ep_regs = udc->regs + USBA_EPT_BASE(i);
17974 ep->dma_regs = udc->regs + USBA_DMA_BASE(i);
17975 ep->fifo = udc->fifo + USBA_FIFO_BASE(i);
17976 + ep->ep.ops = &usba_ep_ops;
17977 + ep->ep.name = pdata->ep[i].name;
17978 + ep->ep.maxpacket = pdata->ep[i].fifo_size;
17979 + ep->udc = &the_udc;
17980 + INIT_LIST_HEAD(&ep->queue);
17981 + ep->fifo_size = pdata->ep[i].fifo_size;
17982 + ep->nr_banks = pdata->ep[i].nr_banks;
17983 + ep->index = pdata->ep[i].index;
17984 + ep->can_dma = pdata->ep[i].can_dma;
17985 + ep->can_isoc = pdata->ep[i].can_isoc;
17987 list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list);
17989 @@ -1987,7 +1942,7 @@
17990 goto err_device_add;
17993 - if (pdata && pdata->vbus_pin != GPIO_PIN_NONE) {
17994 + if (pdata->vbus_pin >= 0) {
17995 if (!gpio_request(pdata->vbus_pin, "atmel_usba_udc")) {
17996 udc->vbus_pin = pdata->vbus_pin;
17998 @@ -2007,7 +1962,7 @@
18001 usba_init_debugfs(udc);
18002 - for (i = 1; i < ARRAY_SIZE(usba_ep); i++)
18003 + for (i = 1; i < pdata->num_ep; i++)
18004 usba_ep_init_debugfs(udc, &usba_ep[i]);
18007 @@ -2015,6 +1970,8 @@
18009 free_irq(irq, udc);
18013 iounmap(udc->fifo);
18015 iounmap(udc->regs);
18016 @@ -2032,10 +1989,11 @@
18018 struct usba_udc *udc;
18020 + struct usba_platform_data *pdata = pdev->dev.platform_data;
18022 udc = platform_get_drvdata(pdev);
18024 - for (i = 1; i < ARRAY_SIZE(usba_ep); i++)
18025 + for (i = 1; i < pdata->num_ep; i++)
18026 usba_ep_cleanup_debugfs(&usba_ep[i]);
18027 usba_cleanup_debugfs(udc);
18029 --- a/drivers/video/atmel_lcdfb.c
18030 +++ b/drivers/video/atmel_lcdfb.c
18032 #include <linux/fb.h>
18033 #include <linux/init.h>
18034 #include <linux/delay.h>
18035 +#include <linux/backlight.h>
18037 #include <asm/arch/board.h>
18038 #include <asm/arch/cpu.h>
18042 #if defined(CONFIG_ARCH_AT91)
18043 -#define ATMEL_LCDFB_FBINFO_DEFAULT FBINFO_DEFAULT
18044 +#define ATMEL_LCDFB_FBINFO_DEFAULT (FBINFO_DEFAULT \
18045 + | FBINFO_PARTIAL_PAN_OK \
18046 + | FBINFO_HWACCEL_YPAN)
18048 static inline void atmel_lcdfb_update_dma2d(struct atmel_lcdfb_info *sinfo,
18049 struct fb_var_screeninfo *var)
18050 @@ -69,12 +72,113 @@
18054 +static const u32 contrast_ctr = ATMEL_LCDC_PS_DIV8
18055 + | ATMEL_LCDC_POL_POSITIVE
18056 + | ATMEL_LCDC_ENA_PWMENABLE;
18058 +#ifdef CONFIG_BACKLIGHT_ATMEL_LCDC
18060 +/* some bl->props field just changed */
18061 +static int atmel_bl_update_status(struct backlight_device *bl)
18063 + struct atmel_lcdfb_info *sinfo = bl_get_data(bl);
18064 + int power = sinfo->bl_power;
18065 + int brightness = bl->props.brightness;
18067 + /* REVISIT there may be a meaningful difference between
18068 + * fb_blank and power ... there seem to be some cases
18069 + * this doesn't handle correctly.
18071 + if (bl->props.fb_blank != sinfo->bl_power)
18072 + power = bl->props.fb_blank;
18073 + else if (bl->props.power != sinfo->bl_power)
18074 + power = bl->props.power;
18076 + if (brightness < 0 && power == FB_BLANK_UNBLANK)
18077 + brightness = lcdc_readl(sinfo, ATMEL_LCDC_CONTRAST_VAL);
18078 + else if (power != FB_BLANK_UNBLANK)
18081 + lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_VAL, brightness);
18082 + lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR,
18083 + brightness ? contrast_ctr : 0);
18085 + bl->props.fb_blank = bl->props.power = sinfo->bl_power = power;
18090 +static int atmel_bl_get_brightness(struct backlight_device *bl)
18092 + struct atmel_lcdfb_info *sinfo = bl_get_data(bl);
18094 + return lcdc_readl(sinfo, ATMEL_LCDC_CONTRAST_VAL);
18097 +static struct backlight_ops atmel_lcdc_bl_ops = {
18098 + .update_status = atmel_bl_update_status,
18099 + .get_brightness = atmel_bl_get_brightness,
18102 +static void init_backlight(struct atmel_lcdfb_info *sinfo)
18104 + struct backlight_device *bl;
18106 + sinfo->bl_power = FB_BLANK_UNBLANK;
18108 + if (sinfo->backlight)
18111 + bl = backlight_device_register("backlight", &sinfo->pdev->dev,
18112 + sinfo, &atmel_lcdc_bl_ops);
18113 + if (IS_ERR(sinfo->backlight)) {
18114 + dev_err(&sinfo->pdev->dev, "error %ld on backlight register\n",
18118 + sinfo->backlight = bl;
18120 + bl->props.power = FB_BLANK_UNBLANK;
18121 + bl->props.fb_blank = FB_BLANK_UNBLANK;
18122 + bl->props.max_brightness = 0xff;
18123 + bl->props.brightness = atmel_bl_get_brightness(bl);
18126 +static void exit_backlight(struct atmel_lcdfb_info *sinfo)
18128 + if (sinfo->backlight)
18129 + backlight_device_unregister(sinfo->backlight);
18134 +static void init_backlight(struct atmel_lcdfb_info *sinfo)
18136 + dev_warn(&sinfo->pdev->dev, "backlight control is not available\n");
18139 +static void exit_backlight(struct atmel_lcdfb_info *sinfo)
18145 +static void init_contrast(struct atmel_lcdfb_info *sinfo)
18147 + /* have some default contrast/backlight settings */
18148 + lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, contrast_ctr);
18149 + lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_VAL, ATMEL_LCDC_CVAL_DEFAULT);
18151 + if (sinfo->lcdcon_is_backlight)
18152 + init_backlight(sinfo);
18156 static struct fb_fix_screeninfo atmel_lcdfb_fix __initdata = {
18157 .type = FB_TYPE_PACKED_PIXELS,
18158 .visual = FB_VISUAL_TRUECOLOR,
18163 .accel = FB_ACCEL_NONE,
18165 @@ -148,6 +252,8 @@
18169 + memset(info->screen_base, 0, info->fix.smem_len);
18174 @@ -203,6 +309,26 @@
18175 var->transp.offset = var->transp.length = 0;
18176 var->xoffset = var->yoffset = 0;
18178 + /* Saturate vertical and horizontal timings at maximum values */
18179 + var->vsync_len = min_t(u32, var->vsync_len,
18180 + (ATMEL_LCDC_VPW >> ATMEL_LCDC_VPW_OFFSET) + 1);
18181 + var->upper_margin = min_t(u32, var->upper_margin,
18182 + ATMEL_LCDC_VBP >> ATMEL_LCDC_VBP_OFFSET);
18183 + var->lower_margin = min_t(u32, var->lower_margin,
18185 + var->right_margin = min_t(u32, var->right_margin,
18186 + (ATMEL_LCDC_HFP >> ATMEL_LCDC_HFP_OFFSET) + 1);
18187 + var->hsync_len = min_t(u32, var->hsync_len,
18188 + (ATMEL_LCDC_HPW >> ATMEL_LCDC_HPW_OFFSET) + 1);
18189 + var->left_margin = min_t(u32, var->left_margin,
18190 + ATMEL_LCDC_HBP + 1);
18192 + /* Some parameters can't be zero */
18193 + var->vsync_len = max_t(u32, var->vsync_len, 1);
18194 + var->right_margin = max_t(u32, var->right_margin, 1);
18195 + var->hsync_len = max_t(u32, var->hsync_len, 1);
18196 + var->left_margin = max_t(u32, var->left_margin, 1);
18198 switch (var->bits_per_pixel) {
18201 @@ -370,10 +496,6 @@
18202 /* Disable all interrupts */
18203 lcdc_writel(sinfo, ATMEL_LCDC_IDR, ~0UL);
18205 - /* Set contrast */
18206 - value = ATMEL_LCDC_PS_DIV8 | ATMEL_LCDC_POL_POSITIVE | ATMEL_LCDC_ENA_PWMENABLE;
18207 - lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, value);
18208 - lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_VAL, ATMEL_LCDC_CVAL_DEFAULT);
18209 /* ...wait for DMA engine to become idle... */
18210 while (lcdc_readl(sinfo, ATMEL_LCDC_DMACON) & ATMEL_LCDC_DMABUSY)
18212 @@ -516,7 +638,6 @@
18213 struct fb_info *info = sinfo->info;
18216 - memset_io(info->screen_base, 0, info->fix.smem_len);
18217 info->var.activate |= FB_ACTIVATE_FORCE | FB_ACTIVATE_NOW;
18219 dev_info(info->device,
18220 @@ -577,6 +698,7 @@
18221 sinfo->default_monspecs = pdata_sinfo->default_monspecs;
18222 sinfo->atmel_lcdfb_power_control = pdata_sinfo->atmel_lcdfb_power_control;
18223 sinfo->guard_time = pdata_sinfo->guard_time;
18224 + sinfo->lcdcon_is_backlight = pdata_sinfo->lcdcon_is_backlight;
18226 dev_err(dev, "cannot get default configuration\n");
18228 @@ -645,6 +767,11 @@
18229 info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len);
18230 if (!info->screen_base)
18231 goto release_intmem;
18234 + * Don't clear the framebuffer -- someone may have set
18235 + * up a splash image.
18238 /* alocate memory buffer */
18239 ret = atmel_lcdfb_alloc_video_memory(sinfo);
18240 @@ -670,6 +797,9 @@
18244 + /* Initialize PWM for contrast or backlight ("off") */
18245 + init_contrast(sinfo);
18248 ret = request_irq(sinfo->irq_base, atmel_lcdfb_interrupt, 0, pdev->name, info);
18250 @@ -721,6 +851,7 @@
18252 free_irq(sinfo->irq_base, info);
18254 + exit_backlight(sinfo);
18255 iounmap(sinfo->mmio);
18257 release_mem_region(info->fix.mmio_start, info->fix.mmio_len);
18258 @@ -755,6 +886,7 @@
18262 + exit_backlight(sinfo);
18263 if (sinfo->atmel_lcdfb_power_control)
18264 sinfo->atmel_lcdfb_power_control(0);
18265 unregister_framebuffer(info);
18266 @@ -781,6 +913,9 @@
18268 static struct platform_driver atmel_lcdfb_driver = {
18269 .remove = __exit_p(atmel_lcdfb_remove),
18271 +// FIXME need suspend, resume
18274 .name = "atmel_lcdfb",
18275 .owner = THIS_MODULE,
18276 --- a/drivers/video/backlight/Kconfig
18277 +++ b/drivers/video/backlight/Kconfig
18279 To have support for your specific LCD panel you will have to
18280 select the proper drivers which depend on this option.
18282 +config BACKLIGHT_ATMEL_LCDC
18283 + bool "Atmel LCDC Contrast-as-Backlight control"
18284 + depends on BACKLIGHT_CLASS_DEVICE && FB_ATMEL
18285 + default y if MACH_SAM9261EK || MACH_SAM9263EK
18287 + This provides a backlight control internal to the Atmel LCDC
18288 + driver. If the LCD "contrast control" on your board is wired
18289 + so it controls the backlight brightness, select this option to
18290 + export this as a PWM-based backlight control.
18292 + If in doubt, it's safe to enable this option; it doesn't kick
18293 + in unless the board's description says it's wired that way.
18295 config BACKLIGHT_CORGI
18296 tristate "Generic (aka Sharp Corgi) Backlight Driver"
18297 depends on BACKLIGHT_CLASS_DEVICE
18298 --- a/drivers/video/console/Kconfig
18299 +++ b/drivers/video/console/Kconfig
18303 bool "VGA text console" if EMBEDDED || !X86
18304 - depends on !ARCH_ACORN && !ARCH_EBSA110 && !4xx && !8xx && !SPARC && !M68K && !PARISC && !FRV && !ARCH_VERSATILE && !SUPERH && !BLACKFIN
18305 + depends on !ARCH_ACORN && !ARCH_EBSA110 && !4xx && !8xx && !SPARC && !M68K && !PARISC && !FRV && !ARCH_VERSATILE && !SUPERH && !BLACKFIN && !AVR32
18308 Saying Y here will allow you to use Linux in text mode through a
18309 --- a/drivers/watchdog/Kconfig
18310 +++ b/drivers/watchdog/Kconfig
18311 @@ -223,7 +223,7 @@
18313 config AT32AP700X_WDT
18314 tristate "AT32AP700x watchdog"
18315 - depends on CPU_AT32AP7000
18316 + depends on CPU_AT32AP700X
18318 Watchdog timer embedded into AT32AP700x devices. This will reboot
18319 your system when the timeout is reached.
18320 --- a/include/asm-avr32/arch-at32ap/at32ap7000.h
18324 - * Pin definitions for AT32AP7000.
18326 - * Copyright (C) 2006 Atmel Corporation
18328 - * This program is free software; you can redistribute it and/or modify
18329 - * it under the terms of the GNU General Public License version 2 as
18330 - * published by the Free Software Foundation.
18332 -#ifndef __ASM_ARCH_AT32AP7000_H__
18333 -#define __ASM_ARCH_AT32AP7000_H__
18335 -#define GPIO_PERIPH_A 0
18336 -#define GPIO_PERIPH_B 1
18338 -#define NR_GPIO_CONTROLLERS 4
18341 - * Pin numbers identifying specific GPIO pins on the chip. They can
18342 - * also be converted to IRQ numbers by passing them through
18345 -#define GPIO_PIOA_BASE (0)
18346 -#define GPIO_PIOB_BASE (GPIO_PIOA_BASE + 32)
18347 -#define GPIO_PIOC_BASE (GPIO_PIOB_BASE + 32)
18348 -#define GPIO_PIOD_BASE (GPIO_PIOC_BASE + 32)
18349 -#define GPIO_PIOE_BASE (GPIO_PIOD_BASE + 32)
18351 -#define GPIO_PIN_PA(N) (GPIO_PIOA_BASE + (N))
18352 -#define GPIO_PIN_PB(N) (GPIO_PIOB_BASE + (N))
18353 -#define GPIO_PIN_PC(N) (GPIO_PIOC_BASE + (N))
18354 -#define GPIO_PIN_PD(N) (GPIO_PIOD_BASE + (N))
18355 -#define GPIO_PIN_PE(N) (GPIO_PIOE_BASE + (N))
18357 -#endif /* __ASM_ARCH_AT32AP7000_H__ */
18359 +++ b/include/asm-avr32/arch-at32ap/at32ap700x.h
18362 + * Pin definitions for AT32AP7000.
18364 + * Copyright (C) 2006 Atmel Corporation
18366 + * This program is free software; you can redistribute it and/or modify
18367 + * it under the terms of the GNU General Public License version 2 as
18368 + * published by the Free Software Foundation.
18370 +#ifndef __ASM_ARCH_AT32AP700X_H__
18371 +#define __ASM_ARCH_AT32AP700X_H__
18373 +#define GPIO_PERIPH_A 0
18374 +#define GPIO_PERIPH_B 1
18376 +#define NR_GPIO_CONTROLLERS 4
18379 + * Pin numbers identifying specific GPIO pins on the chip. They can
18380 + * also be converted to IRQ numbers by passing them through
18383 +#define GPIO_PIOA_BASE (0)
18384 +#define GPIO_PIOB_BASE (GPIO_PIOA_BASE + 32)
18385 +#define GPIO_PIOC_BASE (GPIO_PIOB_BASE + 32)
18386 +#define GPIO_PIOD_BASE (GPIO_PIOC_BASE + 32)
18387 +#define GPIO_PIOE_BASE (GPIO_PIOD_BASE + 32)
18389 +#define GPIO_PIN_PA(N) (GPIO_PIOA_BASE + (N))
18390 +#define GPIO_PIN_PB(N) (GPIO_PIOB_BASE + (N))
18391 +#define GPIO_PIN_PC(N) (GPIO_PIOC_BASE + (N))
18392 +#define GPIO_PIN_PD(N) (GPIO_PIOD_BASE + (N))
18393 +#define GPIO_PIN_PE(N) (GPIO_PIOE_BASE + (N))
18395 +#endif /* __ASM_ARCH_AT32AP700X_H__ */
18396 --- a/include/asm-avr32/arch-at32ap/board.h
18397 +++ b/include/asm-avr32/arch-at32ap/board.h
18399 at32_add_device_lcdc(unsigned int id, struct atmel_lcdfb_info *data,
18400 unsigned long fbmem_start, unsigned long fbmem_len);
18402 -struct usba_platform_data {
18405 +struct usba_platform_data;
18406 struct platform_device *
18407 at32_add_device_usba(unsigned int id, struct usba_platform_data *data);
18410 at32_add_device_ide(unsigned int id, unsigned int extint,
18411 struct ide_platform_data *data);
18413 +/* mask says which PWM channels to mux */
18414 +struct platform_device *at32_add_device_pwm(u32 mask);
18416 /* depending on what's hooked up, not all SSC pins will be used */
18417 #define ATMEL_SSC_TK 0x01
18418 #define ATMEL_SSC_TF 0x02
18420 struct platform_device *
18421 at32_add_device_ssc(unsigned int id, unsigned int flags);
18423 -struct platform_device *at32_add_device_twi(unsigned int id);
18424 -struct platform_device *at32_add_device_mci(unsigned int id);
18425 +struct i2c_board_info;
18426 +struct platform_device *at32_add_device_twi(unsigned int id,
18427 + struct i2c_board_info *b,
18430 +struct mci_platform_data {
18434 +struct platform_device *
18435 +at32_add_device_mci(unsigned int id, struct mci_platform_data *data);
18436 struct platform_device *at32_add_device_ac97c(unsigned int id);
18437 struct platform_device *at32_add_device_abdac(unsigned int id);
18440 at32_add_device_cf(unsigned int id, unsigned int extint,
18441 struct cf_platform_data *data);
18443 +struct platform_device *
18444 +at32_add_device_psif(unsigned int id);
18446 #endif /* __ASM_ARCH_BOARD_H */
18447 --- a/include/asm-avr32/arch-at32ap/cpu.h
18448 +++ b/include/asm-avr32/arch-at32ap/cpu.h
18450 * Only AT32AP7000 is defined for now. We can identify the specific
18451 * chip at runtime, but I'm not sure if it's really worth it.
18453 -#ifdef CONFIG_CPU_AT32AP7000
18454 +#ifdef CONFIG_CPU_AT32AP700X
18455 # define cpu_is_at32ap7000() (1)
18457 # define cpu_is_at32ap7000() (0)
18458 --- a/include/asm-avr32/arch-at32ap/io.h
18459 +++ b/include/asm-avr32/arch-at32ap/io.h
18461 /* For "bizarre" halfword swapping */
18462 #include <linux/byteorder/swabb.h>
18464 -#if defined(CONFIG_AP7000_32_BIT_SMC)
18465 +#if defined(CONFIG_AP700X_32_BIT_SMC)
18466 # define __swizzle_addr_b(addr) (addr ^ 3UL)
18467 # define __swizzle_addr_w(addr) (addr ^ 2UL)
18468 # define __swizzle_addr_l(addr) (addr)
18470 # define __mem_ioswabb(a, x) (x)
18471 # define __mem_ioswabw(a, x) swab16(x)
18472 # define __mem_ioswabl(a, x) swab32(x)
18473 -#elif defined(CONFIG_AP7000_16_BIT_SMC)
18474 +#elif defined(CONFIG_AP700X_16_BIT_SMC)
18475 # define __swizzle_addr_b(addr) (addr ^ 1UL)
18476 # define __swizzle_addr_w(addr) (addr)
18477 # define __swizzle_addr_l(addr) (addr)
18479 +++ b/include/asm-avr32/arch-at32ap/pm.h
18482 + * AVR32 AP Power Management.
18484 + * Copyright (C) 2008 Atmel Corporation
18486 + * This program is free software; you can redistribute it and/or modify
18487 + * it under the terms of the GNU General Public License version 2 as
18488 + * published by the Free Software Foundation.
18490 +#ifndef __ASM_AVR32_ARCH_PM_H
18491 +#define __ASM_AVR32_ARCH_PM_H
18493 +/* Possible arguments to the "sleep" instruction */
18494 +#define CPU_SLEEP_IDLE 0
18495 +#define CPU_SLEEP_FROZEN 1
18496 +#define CPU_SLEEP_STANDBY 2
18497 +#define CPU_SLEEP_STOP 3
18498 +#define CPU_SLEEP_STATIC 5
18500 +#ifndef __ASSEMBLY__
18501 +extern void cpu_enter_idle(void);
18503 +extern bool disable_idle_sleep;
18505 +static inline void cpu_disable_idle_sleep(void)
18507 + disable_idle_sleep = true;
18510 +static inline void cpu_enable_idle_sleep(void)
18512 + disable_idle_sleep = false;
18515 +static inline void cpu_idle_sleep(void)
18518 + * If we're using the COUNT and COMPARE registers for
18519 + * timekeeping, we can't use the IDLE state.
18521 + if (disable_idle_sleep)
18524 + cpu_enter_idle();
18528 +#endif /* __ASM_AVR32_ARCH_PM_H */
18529 --- a/include/asm-avr32/arch-at32ap/portmux.h
18530 +++ b/include/asm-avr32/arch-at32ap/portmux.h
18532 void at32_select_gpio(unsigned int pin, unsigned long flags);
18533 void at32_reserve_pin(unsigned int pin);
18535 +#ifdef CONFIG_GPIO_DEV
18537 +/* Gang allocators and accessors; used by the GPIO /dev driver */
18538 +int at32_gpio_port_is_valid(unsigned int port);
18539 +int at32_select_gpio_pins(unsigned int port, u32 pins, u32 oe_mask);
18540 +void at32_deselect_pins(unsigned int port, u32 pins);
18542 +u32 at32_gpio_get_value_multiple(unsigned int port, u32 pins);
18543 +void at32_gpio_set_value_multiple(unsigned int port, u32 value, u32 mask);
18545 +#endif /* CONFIG_GPIO_DEV */
18547 #endif /* __ASM_ARCH_PORTMUX_H__ */
18548 --- a/include/asm-avr32/arch-at32ap/time.h
18552 - * Copyright (C) 2007 Atmel Corporation
18554 - * This program is free software; you can redistribute it and/or modify
18555 - * it under the terms of the GNU General Public License version 2 as
18556 - * published by the Free Software Foundation.
18559 -#ifndef _ASM_AVR32_ARCH_AT32AP_TIME_H
18560 -#define _ASM_AVR32_ARCH_AT32AP_TIME_H
18562 -#include <linux/platform_device.h>
18564 -extern struct irqaction timer_irqaction;
18565 -extern struct platform_device at32_systc0_device;
18566 -extern void local_timer_interrupt(int irq, void *dev_id);
18568 -#define TIMER_BCR 0x000000c0
18569 -#define TIMER_BCR_SYNC 0
18570 -#define TIMER_BMR 0x000000c4
18571 -#define TIMER_BMR_TC0XC0S 0
18572 -#define TIMER_BMR_TC1XC1S 2
18573 -#define TIMER_BMR_TC2XC2S 4
18574 -#define TIMER_CCR 0x00000000
18575 -#define TIMER_CCR_CLKDIS 1
18576 -#define TIMER_CCR_CLKEN 0
18577 -#define TIMER_CCR_SWTRG 2
18578 -#define TIMER_CMR 0x00000004
18579 -#define TIMER_CMR_ABETRG 10
18580 -#define TIMER_CMR_ACPA 16
18581 -#define TIMER_CMR_ACPC 18
18582 -#define TIMER_CMR_AEEVT 20
18583 -#define TIMER_CMR_ASWTRG 22
18584 -#define TIMER_CMR_BCPB 24
18585 -#define TIMER_CMR_BCPC 26
18586 -#define TIMER_CMR_BEEVT 28
18587 -#define TIMER_CMR_BSWTRG 30
18588 -#define TIMER_CMR_BURST 4
18589 -#define TIMER_CMR_CLKI 3
18590 -#define TIMER_CMR_CPCDIS 7
18591 -#define TIMER_CMR_CPCSTOP 6
18592 -#define TIMER_CMR_CPCTRG 14
18593 -#define TIMER_CMR_EEVT 10
18594 -#define TIMER_CMR_EEVTEDG 8
18595 -#define TIMER_CMR_ENETRG 12
18596 -#define TIMER_CMR_ETRGEDG 8
18597 -#define TIMER_CMR_LDBDIS 7
18598 -#define TIMER_CMR_LDBSTOP 6
18599 -#define TIMER_CMR_LDRA 16
18600 -#define TIMER_CMR_LDRB 18
18601 -#define TIMER_CMR_TCCLKS 0
18602 -#define TIMER_CMR_WAVE 15
18603 -#define TIMER_CMR_WAVSEL 13
18604 -#define TIMER_CV 0x00000010
18605 -#define TIMER_CV_CV 0
18606 -#define TIMER_IDR 0x00000028
18607 -#define TIMER_IDR_COVFS 0
18608 -#define TIMER_IDR_CPAS 2
18609 -#define TIMER_IDR_CPBS 3
18610 -#define TIMER_IDR_CPCS 4
18611 -#define TIMER_IDR_ETRGS 7
18612 -#define TIMER_IDR_LDRAS 5
18613 -#define TIMER_IDR_LDRBS 6
18614 -#define TIMER_IDR_LOVRS 1
18615 -#define TIMER_IER 0x00000024
18616 -#define TIMER_IER_COVFS 0
18617 -#define TIMER_IER_CPAS 2
18618 -#define TIMER_IER_CPBS 3
18619 -#define TIMER_IER_CPCS 4
18620 -#define TIMER_IER_ETRGS 7
18621 -#define TIMER_IER_LDRAS 5
18622 -#define TIMER_IER_LDRBS 6
18623 -#define TIMER_IER_LOVRS 1
18624 -#define TIMER_IMR 0x0000002c
18625 -#define TIMER_IMR_COVFS 0
18626 -#define TIMER_IMR_CPAS 2
18627 -#define TIMER_IMR_CPBS 3
18628 -#define TIMER_IMR_CPCS 4
18629 -#define TIMER_IMR_ETRGS 7
18630 -#define TIMER_IMR_LDRAS 5
18631 -#define TIMER_IMR_LDRBS 6
18632 -#define TIMER_IMR_LOVRS 1
18633 -#define TIMER_RA 0x00000014
18634 -#define TIMER_RA_RA 0
18635 -#define TIMER_RB 0x00000018
18636 -#define TIMER_RB_RB 0
18637 -#define TIMER_RC 0x0000001c
18638 -#define TIMER_RC_RC 0
18639 -#define TIMER_SR 0x00000020
18640 -#define TIMER_SR_CLKSTA 16
18641 -#define TIMER_SR_COVFS 0
18642 -#define TIMER_SR_CPAS 2
18643 -#define TIMER_SR_CPBS 3
18644 -#define TIMER_SR_CPCS 4
18645 -#define TIMER_SR_ETRGS 7
18646 -#define TIMER_SR_LDRAS 5
18647 -#define TIMER_SR_LDRBS 6
18648 -#define TIMER_SR_LOVRS 1
18649 -#define TIMER_SR_MTIOA 17
18650 -#define TIMER_SR_MTIOB 18
18652 -/* Bit manipulation macros */
18653 -#define TIMER_BIT(name) (1 << TIMER_##name)
18654 -#define TIMER_BF(name,value) ((value) << TIMER_##name)
18656 -/* Register access macros */
18657 -#define timer_read(port,instance,reg) \
18658 - __raw_readl(port + (0x40 * instance) + TIMER_##reg)
18659 -#define timer_write(port,instance,reg,value) \
18660 - __raw_writel((value), port + (0x40 * instance) + TIMER_##reg)
18662 -#endif /* _ASM_AVR32_ARCH_AT32AP_TIME_H */
18663 --- a/include/asm-avr32/asm.h
18664 +++ b/include/asm-avr32/asm.h
18665 @@ -12,10 +12,10 @@
18666 #include <asm/asm-offsets.h>
18667 #include <asm/thread_info.h>
18669 -#define mask_interrupts ssrf SR_GM_BIT
18670 -#define mask_exceptions ssrf SR_EM_BIT
18671 -#define unmask_interrupts csrf SR_GM_BIT
18672 -#define unmask_exceptions csrf SR_EM_BIT
18673 +#define mask_interrupts ssrf SYSREG_GM_OFFSET
18674 +#define mask_exceptions ssrf SYSREG_EM_OFFSET
18675 +#define unmask_interrupts csrf SYSREG_GM_OFFSET
18676 +#define unmask_exceptions csrf SYSREG_EM_OFFSET
18678 #ifdef CONFIG_FRAME_POINTER
18680 --- a/include/asm-avr32/byteorder.h
18681 +++ b/include/asm-avr32/byteorder.h
18683 extern unsigned short __builtin_bswap_16(unsigned short x);
18687 #define __arch__swab32(x) __builtin_bswap_32(x)
18688 #define __arch__swab16(x) __builtin_bswap_16(x)
18691 #if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
18692 # define __BYTEORDER_HAS_U64__
18694 +++ b/include/asm-avr32/dma-controller.h
18697 + * Copyright (C) 2005-2006 Atmel Corporation
18699 + * This program is free software; you can redistribute it and/or modify
18700 + * it under the terms of the GNU General Public License version 2 as
18701 + * published by the Free Software Foundation.
18703 +#ifndef __ASM_AVR32_DMA_CONTROLLER_H
18704 +#define __ASM_AVR32_DMA_CONTROLLER_H
18706 +#include <linux/device.h>
18708 +#define DMA_DIR_MEM_TO_MEM 0x0000
18709 +#define DMA_DIR_MEM_TO_PERIPH 0x0001
18710 +#define DMA_DIR_PERIPH_TO_MEM 0x0002
18711 +#define DMA_DIR_PERIPH_TO_PERIPH 0x0003
18713 +#define DMA_WIDTH_8BIT 0
18714 +#define DMA_WIDTH_16BIT 1
18715 +#define DMA_WIDTH_32BIT 2
18717 +struct dma_request {
18718 + struct dma_controller *dmac;
18719 + struct list_head list;
18721 + unsigned short channel;
18723 + void (*xfer_complete)(struct dma_request *req);
18724 + void (*block_complete)(struct dma_request *req);
18725 + void (*error)(struct dma_request *req);
18728 +struct dma_request_sg {
18729 + struct dma_request req;
18732 + struct scatterlist *sg;
18733 + unsigned long block_size;
18734 + unsigned int nr_blocks;
18736 + dma_addr_t data_reg;
18737 + unsigned short periph_id;
18739 + unsigned char direction;
18740 + unsigned char width;
18742 +#define to_dma_request_sg(_req) \
18743 + container_of(_req, struct dma_request_sg, req)
18745 +struct dma_request_cyclic {
18746 + struct dma_request req;
18749 + unsigned long buffer_size;
18751 + dma_addr_t buffer_start;
18752 + dma_addr_t data_reg;
18754 + unsigned short periph_id;
18755 + unsigned char direction;
18756 + unsigned char width;
18760 +#define to_dma_request_cyclic(_req) \
18761 + container_of(_req, struct dma_request_cyclic, req)
18763 +struct dma_request_memcpy {
18764 + struct dma_request req;
18766 + dma_addr_t src_addr;
18767 + unsigned int src_width;
18768 + unsigned int src_stride;
18770 + dma_addr_t dst_addr;
18771 + unsigned int dst_width;
18772 + unsigned int dst_stride;
18776 + unsigned short src_reverse:1;
18777 + unsigned short dst_reverse:1;
18779 +#define to_dma_request_memcpy(_req) \
18780 + container_of(_req, struct dma_request_memcpy, req)
18782 +struct dma_controller {
18783 + struct list_head list;
18785 + struct device *dev;
18787 + int (*alloc_channel)(struct dma_controller *dmac);
18788 + void (*release_channel)(struct dma_controller *dmac,
18790 + int (*prepare_request_sg)(struct dma_controller *dmac,
18791 + struct dma_request_sg *req);
18792 + int (*prepare_request_cyclic)(struct dma_controller *dmac,
18793 + struct dma_request_cyclic *req);
18794 + int (*prepare_request_memcpy)(struct dma_controller *dmac,
18795 + struct dma_request_memcpy *req);
18796 + int (*start_request)(struct dma_controller *dmac,
18797 + unsigned int channel);
18798 + int (*stop_request)(struct dma_controller *dmac,
18799 + unsigned int channel);
18800 + dma_addr_t (*get_current_pos)(struct dma_controller *dmac,
18801 + unsigned int channel);
18805 +dma_alloc_channel(struct dma_controller *dmac)
18807 + return dmac->alloc_channel(dmac);
18810 +static inline void
18811 +dma_release_channel(struct dma_controller *dmac, int chan)
18813 + dmac->release_channel(dmac, chan);
18817 +dma_prepare_request_sg(struct dma_controller *dmac,
18818 + struct dma_request_sg *req)
18820 + return dmac->prepare_request_sg(dmac, req);
18824 +dma_prepare_request_cyclic(struct dma_controller *dmac,
18825 + struct dma_request_cyclic *req)
18827 + return dmac->prepare_request_cyclic(dmac, req);
18831 +dma_prepare_request_memcpy(struct dma_controller *dmac,
18832 + struct dma_request_memcpy *req)
18834 + return dmac->prepare_request_memcpy(dmac, req);
18838 +dma_start_request(struct dma_controller *dmac,
18839 + unsigned int channel)
18841 + return dmac->start_request(dmac, channel);
18845 +dma_stop_request(struct dma_controller *dmac,
18846 + unsigned int channel)
18848 + return dmac->stop_request(dmac, channel);
18851 +static inline dma_addr_t
18852 +dma_get_current_pos(struct dma_controller *dmac,
18853 + unsigned int channel)
18855 + return dmac->get_current_pos(dmac, channel);
18858 +extern int register_dma_controller(struct dma_controller *dmac);
18859 +extern struct dma_controller *find_dma_controller(int id);
18861 +#endif /* __ASM_AVR32_DMA_CONTROLLER_H */
18862 --- a/include/asm-avr32/intc.h
18865 -#ifndef __ASM_AVR32_INTC_H
18866 -#define __ASM_AVR32_INTC_H
18868 -#include <linux/sysdev.h>
18869 -#include <linux/interrupt.h>
18871 -struct irq_controller;
18875 -struct platform_device;
18877 -/* Information about the internal interrupt controller */
18878 -struct intc_device {
18879 - /* ioremapped address of configuration block */
18880 - void __iomem *regs;
18882 - /* the physical device */
18883 - struct platform_device *pdev;
18885 - /* Number of interrupt lines per group. */
18886 - unsigned int irqs_per_group;
18888 - /* The highest group ID + 1 */
18889 - unsigned int nr_groups;
18892 - * Bitfield indicating which groups are actually in use. The
18893 - * size of the array is
18894 - * ceil(group_max / (8 * sizeof(unsigned int))).
18896 - unsigned int group_mask[];
18899 -struct irq_controller_class {
18901 - * A short name identifying this kind of controller.
18903 - const char *typename;
18905 - * Handle the IRQ. Must do any necessary acking and masking.
18907 - irqreturn_t (*handle)(int irq, void *dev_id, struct pt_regs *regs);
18909 - * Register a new IRQ handler.
18911 - int (*setup)(struct irq_controller *ctrl, unsigned int irq,
18912 - struct irqaction *action);
18914 - * Unregister a IRQ handler.
18916 - void (*free)(struct irq_controller *ctrl, unsigned int irq,
18919 - * Mask the IRQ in the interrupt controller.
18921 - void (*mask)(struct irq_controller *ctrl, unsigned int irq);
18923 - * Unmask the IRQ in the interrupt controller.
18925 - void (*unmask)(struct irq_controller *ctrl, unsigned int irq);
18927 - * Set the type of the IRQ. See below for possible types.
18928 - * Return -EINVAL if a given type is not supported
18930 - int (*set_type)(struct irq_controller *ctrl, unsigned int irq,
18931 - unsigned int type);
18933 - * Return the IRQ type currently set
18935 - unsigned int (*get_type)(struct irq_controller *ctrl, unsigned int irq);
18938 -struct irq_controller {
18939 - struct irq_controller_class *class;
18940 - unsigned int irq_group;
18941 - unsigned int first_irq;
18942 - unsigned int nr_irqs;
18943 - struct list_head list;
18946 -struct intc_group_desc {
18947 - struct irq_controller *ctrl;
18948 - irqreturn_t (*handle)(int, void *, struct pt_regs *);
18949 - unsigned long flags;
18951 - const char *devname;
18955 - * The internal interrupt controller. Defined in board/part-specific
18957 - * TODO: Should probably be defined per-cpu.
18959 -extern struct intc_device intc;
18961 -extern int request_internal_irq(unsigned int irq,
18962 - irqreturn_t (*handler)(int, void *, struct pt_regs *),
18963 - unsigned long irqflags,
18964 - const char *devname, void *dev_id);
18965 -extern void free_internal_irq(unsigned int irq);
18967 -/* Only used by time_init() */
18968 -extern int setup_internal_irq(unsigned int irq, struct intc_group_desc *desc);
18971 - * Set interrupt priority for a given group. `group' can be found by
18972 - * using irq_to_group(irq). Priority can be from 0 (lowest) to 3
18973 - * (highest). Higher-priority interrupts will preempt lower-priority
18974 - * interrupts (unless interrupts are masked globally).
18976 - * This function does not check for conflicts within a group.
18978 -extern int intc_set_priority(unsigned int group,
18979 - unsigned int priority);
18982 - * Returns a bitmask of pending interrupts in a group.
18984 -extern unsigned long intc_get_pending(unsigned int group);
18987 - * Register a new external interrupt controller. Returns the first
18988 - * external IRQ number that is assigned to the new controller.
18990 -extern int intc_register_controller(struct irq_controller *ctrl);
18992 -#endif /* __ASM_AVR32_INTC_H */
18993 --- a/include/asm-avr32/irq.h
18994 +++ b/include/asm-avr32/irq.h
18997 #define irq_canonicalize(i) (i)
18999 +#ifndef __ASSEMBLER__
19000 +int nmi_enable(void);
19001 +void nmi_disable(void);
19004 + * Returns a bitmask of pending interrupts in a group.
19006 +extern unsigned long intc_get_pending(unsigned int group);
19009 #endif /* __ASM_AVR32_IOCTLS_H */
19010 --- a/include/asm-avr32/kdebug.h
19011 +++ b/include/asm-avr32/kdebug.h
19019 #endif /* __ASM_AVR32_KDEBUG_H */
19020 --- a/include/asm-avr32/ocd.h
19021 +++ b/include/asm-avr32/ocd.h
19022 @@ -533,6 +533,11 @@
19023 #define ocd_read(reg) __ocd_read(OCD_##reg)
19024 #define ocd_write(reg, value) __ocd_write(OCD_##reg, value)
19026 +struct task_struct;
19028 +void ocd_enable(struct task_struct *child);
19029 +void ocd_disable(struct task_struct *child);
19031 #endif /* !__ASSEMBLER__ */
19033 #endif /* __ASM_AVR32_OCD_H */
19034 --- a/include/asm-avr32/pgtable.h
19035 +++ b/include/asm-avr32/pgtable.h
19036 @@ -157,6 +157,7 @@
19037 #define _PAGE_S(x) _PAGE_NORMAL(x)
19039 #define PAGE_COPY _PAGE_P(PAGE_WRITE | PAGE_READ)
19040 +#define PAGE_SHARED _PAGE_S(PAGE_WRITE | PAGE_READ)
19042 #ifndef __ASSEMBLY__
19044 --- a/include/asm-avr32/processor.h
19045 +++ b/include/asm-avr32/processor.h
19046 @@ -57,11 +57,25 @@
19047 unsigned short cpu_revision;
19048 enum tlb_config tlb_config;
19049 unsigned long features;
19052 struct cache_info icache;
19053 struct cache_info dcache;
19056 +static inline unsigned int avr32_get_manufacturer_id(struct avr32_cpuinfo *cpu)
19058 + return (cpu->device_id >> 1) & 0x7f;
19060 +static inline unsigned int avr32_get_product_number(struct avr32_cpuinfo *cpu)
19062 + return (cpu->device_id >> 12) & 0xffff;
19064 +static inline unsigned int avr32_get_chip_revision(struct avr32_cpuinfo *cpu)
19066 + return (cpu->device_id >> 28) & 0x0f;
19069 extern struct avr32_cpuinfo boot_cpu_data;
19072 --- a/include/asm-avr32/ptrace.h
19073 +++ b/include/asm-avr32/ptrace.h
19074 @@ -121,7 +121,15 @@
19078 -# define user_mode(regs) (((regs)->sr & MODE_MASK) == MODE_USER)
19080 +#include <asm/ocd.h>
19082 +#define arch_ptrace_attach(child) ocd_enable(child)
19084 +#define user_mode(regs) (((regs)->sr & MODE_MASK) == MODE_USER)
19085 +#define instruction_pointer(regs) ((regs)->pc)
19086 +#define profile_pc(regs) instruction_pointer(regs)
19088 extern void show_regs (struct pt_regs *);
19090 static __inline__ int valid_user_regs(struct pt_regs *regs)
19091 @@ -141,9 +149,6 @@
19095 -#define instruction_pointer(regs) ((regs)->pc)
19097 -#define profile_pc(regs) instruction_pointer(regs)
19099 #endif /* __KERNEL__ */
19101 --- a/include/asm-avr32/thread_info.h
19102 +++ b/include/asm-avr32/thread_info.h
19104 #define TIF_MEMDIE 6
19105 #define TIF_RESTORE_SIGMASK 7 /* restore signal mask in do_signal */
19106 #define TIF_CPU_GOING_TO_SLEEP 8 /* CPU is entering sleep 0 mode */
19107 +#define TIF_DEBUG 30 /* debugging enabled */
19108 #define TIF_USERSPACE 31 /* true if FS sets userspace */
19110 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
19112 +++ b/include/linux/atmel_pwm.h
19114 +#ifndef __LINUX_ATMEL_PWM_H
19115 +#define __LINUX_ATMEL_PWM_H
19118 + * struct pwm_channel - driver handle to a PWM channel
19119 + * @regs: base of this channel's registers
19120 + * @index: number of this channel (0..31)
19121 + * @mck: base clock rate, which can be prescaled and maybe subdivided
19123 + * Drivers initialize a pwm_channel structure using pwm_channel_alloc().
19124 + * Then they configure its clock rate (derived from MCK), alignment,
19125 + * polarity, and duty cycle by writing directly to the channel registers,
19126 + * before enabling the channel by calling pwm_channel_enable().
19128 + * After emitting a PWM signal for the desired length of time, drivers
19129 + * may then pwm_channel_disable() or pwm_channel_free(). Both of these
19130 + * disable the channel, but when it's freed the IRQ is deconfigured and
19131 + * the channel must later be re-allocated and reconfigured.
19133 + * Note that if the period or duty cycle need to be changed while the
19134 + * PWM channel is operating, drivers must use the PWM_CUPD double buffer
19135 + * mechanism, either polling until they change or getting implicitly
19136 + * notified through a once-per-period interrupt handler.
19138 +struct pwm_channel {
19139 + void __iomem *regs;
19141 + unsigned long mck;
19144 +extern int pwm_channel_alloc(int index, struct pwm_channel *ch);
19145 +extern int pwm_channel_free(struct pwm_channel *ch);
19147 +extern int pwm_clk_alloc(unsigned prescale, unsigned div);
19148 +extern void pwm_clk_free(unsigned clk);
19150 +extern int __pwm_channel_onoff(struct pwm_channel *ch, int enabled);
19152 +#define pwm_channel_enable(ch) __pwm_channel_onoff((ch), 1)
19153 +#define pwm_channel_disable(ch) __pwm_channel_onoff((ch), 0)
19155 +/* periodic interrupts, mostly for CUPD changes to period or cycle */
19156 +extern int pwm_channel_handler(struct pwm_channel *ch,
19157 + void (*handler)(struct pwm_channel *ch));
19159 +/* per-channel registers (banked at pwm_channel->regs) */
19160 +#define PWM_CMR 0x00 /* mode register */
19161 +#define PWM_CPR_CPD (1 << 10) /* set: CUPD modifies period */
19162 +#define PWM_CPR_CPOL (1 << 9) /* set: idle high */
19163 +#define PWM_CPR_CALG (1 << 8) /* set: center align */
19164 +#define PWM_CPR_CPRE (0xf << 0) /* mask: rate is mck/(2^pre) */
19165 +#define PWM_CPR_CLKA (0xb << 0) /* rate CLKA */
19166 +#define PWM_CPR_CLKB (0xc << 0) /* rate CLKB */
19167 +#define PWM_CDTY 0x04 /* duty cycle (max of CPRD) */
19168 +#define PWM_CPRD 0x08 /* period (count up from zero) */
19169 +#define PWM_CCNT 0x0c /* counter (20 bits?) */
19170 +#define PWM_CUPD 0x10 /* update CPRD (or CDTY) next period */
19172 +static inline void
19173 +pwm_channel_writel(struct pwm_channel *pwmc, unsigned offset, u32 val)
19175 + __raw_writel(val, pwmc->regs + offset);
19178 +static inline u32 pwm_channel_readl(struct pwm_channel *pwmc, unsigned offset)
19180 + return __raw_readl(pwmc->regs + offset);
19183 +#endif /* __LINUX_ATMEL_PWM_H */
19185 +++ b/include/linux/atmel_serial.h
19188 + * include/linux/atmel_serial.h
19190 + * Copyright (C) 2005 Ivan Kokshaysky
19191 + * Copyright (C) SAN People
19193 + * USART registers.
19194 + * Based on AT91RM9200 datasheet revision E.
19196 + * This program is free software; you can redistribute it and/or modify
19197 + * it under the terms of the GNU General Public License as published by
19198 + * the Free Software Foundation; either version 2 of the License, or
19199 + * (at your option) any later version.
19202 +#ifndef ATMEL_SERIAL_H
19203 +#define ATMEL_SERIAL_H
19205 +#define ATMEL_US_CR 0x00 /* Control Register */
19206 +#define ATMEL_US_RSTRX (1 << 2) /* Reset Receiver */
19207 +#define ATMEL_US_RSTTX (1 << 3) /* Reset Transmitter */
19208 +#define ATMEL_US_RXEN (1 << 4) /* Receiver Enable */
19209 +#define ATMEL_US_RXDIS (1 << 5) /* Receiver Disable */
19210 +#define ATMEL_US_TXEN (1 << 6) /* Transmitter Enable */
19211 +#define ATMEL_US_TXDIS (1 << 7) /* Transmitter Disable */
19212 +#define ATMEL_US_RSTSTA (1 << 8) /* Reset Status Bits */
19213 +#define ATMEL_US_STTBRK (1 << 9) /* Start Break */
19214 +#define ATMEL_US_STPBRK (1 << 10) /* Stop Break */
19215 +#define ATMEL_US_STTTO (1 << 11) /* Start Time-out */
19216 +#define ATMEL_US_SENDA (1 << 12) /* Send Address */
19217 +#define ATMEL_US_RSTIT (1 << 13) /* Reset Iterations */
19218 +#define ATMEL_US_RSTNACK (1 << 14) /* Reset Non Acknowledge */
19219 +#define ATMEL_US_RETTO (1 << 15) /* Rearm Time-out */
19220 +#define ATMEL_US_DTREN (1 << 16) /* Data Terminal Ready Enable [AT91RM9200 only] */
19221 +#define ATMEL_US_DTRDIS (1 << 17) /* Data Terminal Ready Disable [AT91RM9200 only] */
19222 +#define ATMEL_US_RTSEN (1 << 18) /* Request To Send Enable */
19223 +#define ATMEL_US_RTSDIS (1 << 19) /* Request To Send Disable */
19225 +#define ATMEL_US_MR 0x04 /* Mode Register */
19226 +#define ATMEL_US_USMODE (0xf << 0) /* Mode of the USART */
19227 +#define ATMEL_US_USMODE_NORMAL 0
19228 +#define ATMEL_US_USMODE_RS485 1
19229 +#define ATMEL_US_USMODE_HWHS 2
19230 +#define ATMEL_US_USMODE_MODEM 3
19231 +#define ATMEL_US_USMODE_ISO7816_T0 4
19232 +#define ATMEL_US_USMODE_ISO7816_T1 6
19233 +#define ATMEL_US_USMODE_IRDA 8
19234 +#define ATMEL_US_USCLKS (3 << 4) /* Clock Selection */
19235 +#define ATMEL_US_USCLKS_MCK (0 << 4)
19236 +#define ATMEL_US_USCLKS_MCK_DIV8 (1 << 4)
19237 +#define ATMEL_US_USCLKS_SCK (3 << 4)
19238 +#define ATMEL_US_CHRL (3 << 6) /* Character Length */
19239 +#define ATMEL_US_CHRL_5 (0 << 6)
19240 +#define ATMEL_US_CHRL_6 (1 << 6)
19241 +#define ATMEL_US_CHRL_7 (2 << 6)
19242 +#define ATMEL_US_CHRL_8 (3 << 6)
19243 +#define ATMEL_US_SYNC (1 << 8) /* Synchronous Mode Select */
19244 +#define ATMEL_US_PAR (7 << 9) /* Parity Type */
19245 +#define ATMEL_US_PAR_EVEN (0 << 9)
19246 +#define ATMEL_US_PAR_ODD (1 << 9)
19247 +#define ATMEL_US_PAR_SPACE (2 << 9)
19248 +#define ATMEL_US_PAR_MARK (3 << 9)
19249 +#define ATMEL_US_PAR_NONE (4 << 9)
19250 +#define ATMEL_US_PAR_MULTI_DROP (6 << 9)
19251 +#define ATMEL_US_NBSTOP (3 << 12) /* Number of Stop Bits */
19252 +#define ATMEL_US_NBSTOP_1 (0 << 12)
19253 +#define ATMEL_US_NBSTOP_1_5 (1 << 12)
19254 +#define ATMEL_US_NBSTOP_2 (2 << 12)
19255 +#define ATMEL_US_CHMODE (3 << 14) /* Channel Mode */
19256 +#define ATMEL_US_CHMODE_NORMAL (0 << 14)
19257 +#define ATMEL_US_CHMODE_ECHO (1 << 14)
19258 +#define ATMEL_US_CHMODE_LOC_LOOP (2 << 14)
19259 +#define ATMEL_US_CHMODE_REM_LOOP (3 << 14)
19260 +#define ATMEL_US_MSBF (1 << 16) /* Bit Order */
19261 +#define ATMEL_US_MODE9 (1 << 17) /* 9-bit Character Length */
19262 +#define ATMEL_US_CLKO (1 << 18) /* Clock Output Select */
19263 +#define ATMEL_US_OVER (1 << 19) /* Oversampling Mode */
19264 +#define ATMEL_US_INACK (1 << 20) /* Inhibit Non Acknowledge */
19265 +#define ATMEL_US_DSNACK (1 << 21) /* Disable Successive NACK */
19266 +#define ATMEL_US_MAX_ITER (7 << 24) /* Max Iterations */
19267 +#define ATMEL_US_FILTER (1 << 28) /* Infrared Receive Line Filter */
19269 +#define ATMEL_US_IER 0x08 /* Interrupt Enable Register */
19270 +#define ATMEL_US_RXRDY (1 << 0) /* Receiver Ready */
19271 +#define ATMEL_US_TXRDY (1 << 1) /* Transmitter Ready */
19272 +#define ATMEL_US_RXBRK (1 << 2) /* Break Received / End of Break */
19273 +#define ATMEL_US_ENDRX (1 << 3) /* End of Receiver Transfer */
19274 +#define ATMEL_US_ENDTX (1 << 4) /* End of Transmitter Transfer */
19275 +#define ATMEL_US_OVRE (1 << 5) /* Overrun Error */
19276 +#define ATMEL_US_FRAME (1 << 6) /* Framing Error */
19277 +#define ATMEL_US_PARE (1 << 7) /* Parity Error */
19278 +#define ATMEL_US_TIMEOUT (1 << 8) /* Receiver Time-out */
19279 +#define ATMEL_US_TXEMPTY (1 << 9) /* Transmitter Empty */
19280 +#define ATMEL_US_ITERATION (1 << 10) /* Max number of Repetitions Reached */
19281 +#define ATMEL_US_TXBUFE (1 << 11) /* Transmission Buffer Empty */
19282 +#define ATMEL_US_RXBUFF (1 << 12) /* Reception Buffer Full */
19283 +#define ATMEL_US_NACK (1 << 13) /* Non Acknowledge */
19284 +#define ATMEL_US_RIIC (1 << 16) /* Ring Indicator Input Change [AT91RM9200 only] */
19285 +#define ATMEL_US_DSRIC (1 << 17) /* Data Set Ready Input Change [AT91RM9200 only] */
19286 +#define ATMEL_US_DCDIC (1 << 18) /* Data Carrier Detect Input Change [AT91RM9200 only] */
19287 +#define ATMEL_US_CTSIC (1 << 19) /* Clear to Send Input Change */
19288 +#define ATMEL_US_RI (1 << 20) /* RI */
19289 +#define ATMEL_US_DSR (1 << 21) /* DSR */
19290 +#define ATMEL_US_DCD (1 << 22) /* DCD */
19291 +#define ATMEL_US_CTS (1 << 23) /* CTS */
19293 +#define ATMEL_US_IDR 0x0c /* Interrupt Disable Register */
19294 +#define ATMEL_US_IMR 0x10 /* Interrupt Mask Register */
19295 +#define ATMEL_US_CSR 0x14 /* Channel Status Register */
19296 +#define ATMEL_US_RHR 0x18 /* Receiver Holding Register */
19297 +#define ATMEL_US_THR 0x1c /* Transmitter Holding Register */
19298 +#define ATMEL_US_SYNH (1 << 15) /* Transmit/Receive Sync [AT91SAM9261 only] */
19300 +#define ATMEL_US_BRGR 0x20 /* Baud Rate Generator Register */
19301 +#define ATMEL_US_CD (0xffff << 0) /* Clock Divider */
19303 +#define ATMEL_US_RTOR 0x24 /* Receiver Time-out Register */
19304 +#define ATMEL_US_TO (0xffff << 0) /* Time-out Value */
19306 +#define ATMEL_US_TTGR 0x28 /* Transmitter Timeguard Register */
19307 +#define ATMEL_US_TG (0xff << 0) /* Timeguard Value */
19309 +#define ATMEL_US_FIDI 0x40 /* FI DI Ratio Register */
19310 +#define ATMEL_US_NER 0x44 /* Number of Errors Register */
19311 +#define ATMEL_US_IF 0x4c /* IrDA Filter Register */
19315 +++ b/include/linux/atmel_tc.h
19318 + * Timer/Counter Unit (TC) registers.
19320 + * This program is free software; you can redistribute it and/or modify
19321 + * it under the terms of the GNU General Public License as published by
19322 + * the Free Software Foundation; either version 2 of the License, or
19323 + * (at your option) any later version.
19326 +#ifndef ATMEL_TC_H
19327 +#define ATMEL_TC_H
19329 +#include <linux/compiler.h>
19330 +#include <linux/list.h>
19333 + * Many 32-bit Atmel SOCs include one or more TC blocks, each of which holds
19334 + * three general-purpose 16-bit timers. These timers share one register bank.
19335 + * Depending on the SOC, each timer may have its own clock and IRQ, or those
19336 + * may be shared by the whole TC block.
19338 + * These TC blocks may have up to nine external pins: TCLK0..2 signals for
19339 + * clocks or clock gates, and per-timer TIOA and TIOB signals used for PWM
19340 + * or triggering. Those pins need to be set up for use with the TC block,
19341 + * else they will be used as GPIOs or for a different controller.
19343 + * Although we expect each TC block to have a platform_device node, those
19344 + * nodes are not what drivers bind to. Instead, they ask for a specific
19345 + * TC block, by number ... which is a common approach on systems with many
19346 + * timers. Then they use clk_get() and platform_get_irq() to get clock and
19353 + * struct atmel_tc - information about a Timer/Counter Block
19354 + * @pdev: physical device
19355 + * @iomem: resource associated with the I/O register
19356 + * @regs: mapping through which the I/O registers can be accessed
19357 + * @irq: irq for each of the three channels
19358 + * @clk: internal clock source for each of the three channels
19359 + * @node: list node, for tclib internal use
19361 + * On some platforms, each TC channel has its own clocks and IRQs,
19362 + * while on others, all TC channels share the same clock and IRQ.
19363 + * Drivers should clk_enable() all the clocks they need even though
19364 + * all the entries in @clk may point to the same physical clock.
19365 + * Likewise, drivers should request irqs independently for each
19366 + * channel, but they must use IRQF_SHARED in case some of the entries
19367 + * in @irq are actually the same IRQ.
19370 + struct platform_device *pdev;
19371 + struct resource *iomem;
19372 + void __iomem *regs;
19374 + struct clk *clk[3];
19375 + struct list_head node;
19378 +extern struct atmel_tc *atmel_tc_alloc(unsigned block, const char *name);
19379 +extern void atmel_tc_free(struct atmel_tc *tc);
19381 +/* platform-specific ATMEL_TC_TIMER_CLOCKx divisors (0 means 32KiHz) */
19382 +extern const u8 atmel_tc_divisors[5];
19386 + * Two registers have block-wide controls. These are: configuring the three
19387 + * "external" clocks (or event sources) used by the timer channels; and
19388 + * synchronizing the timers by resetting them all at once.
19390 + * "External" can mean "external to chip" using the TCLK0, TCLK1, or TCLK2
19391 + * signals. Or, it can mean "external to timer", using the TIOA output from
19392 + * one of the other two timers that's being run in waveform mode.
19395 +#define ATMEL_TC_BCR 0xc0 /* TC Block Control Register */
19396 +#define ATMEL_TC_SYNC (1 << 0) /* synchronize timers */
19398 +#define ATMEL_TC_BMR 0xc4 /* TC Block Mode Register */
19399 +#define ATMEL_TC_TC0XC0S (3 << 0) /* external clock 0 source */
19400 +#define ATMEL_TC_TC0XC0S_TCLK0 (0 << 0)
19401 +#define ATMEL_TC_TC0XC0S_NONE (1 << 0)
19402 +#define ATMEL_TC_TC0XC0S_TIOA1 (2 << 0)
19403 +#define ATMEL_TC_TC0XC0S_TIOA2 (3 << 0)
19404 +#define ATMEL_TC_TC1XC1S (3 << 2) /* external clock 1 source */
19405 +#define ATMEL_TC_TC1XC1S_TCLK1 (0 << 2)
19406 +#define ATMEL_TC_TC1XC1S_NONE (1 << 2)
19407 +#define ATMEL_TC_TC1XC1S_TIOA0 (2 << 2)
19408 +#define ATMEL_TC_TC1XC1S_TIOA2 (3 << 2)
19409 +#define ATMEL_TC_TC2XC2S (3 << 4) /* external clock 2 source */
19410 +#define ATMEL_TC_TC2XC2S_TCLK2 (0 << 4)
19411 +#define ATMEL_TC_TC2XC2S_NONE (1 << 4)
19412 +#define ATMEL_TC_TC2XC2S_TIOA0 (2 << 4)
19413 +#define ATMEL_TC_TC2XC2S_TIOA1 (3 << 4)
19417 + * Each TC block has three "channels", each with one counter and controls.
19419 + * Note that the semantics of ATMEL_TC_TIMER_CLOCKx (input clock selection
19420 + * when it's not "external") is silicon-specific. AT91 platforms use one
19421 + * set of definitions; AVR32 platforms use a different set. Don't hard-wire
19422 + * such knowledge into your code, use the global "atmel_tc_divisors" ...
19423 + * where index N is the divisor for clock N+1, else zero to indicate it uses
19424 + * the 32 KiHz clock.
19426 + * The timers can be chained in various ways, and operated in "waveform"
19427 + * generation mode (including PWM) or "capture" mode (to time events). In
19428 + * both modes, behavior can be configured in many ways.
19430 + * Each timer has two I/O pins, TIOA and TIOB. Waveform mode uses TIOA as a
19431 + * PWM output, and TIOB as either another PWM or as a trigger. Capture mode
19432 + * uses them only as inputs.
19434 +#define ATMEL_TC_CHAN(idx) ((idx)*0x40)
19435 +#define ATMEL_TC_REG(idx, reg) (ATMEL_TC_CHAN(idx) + ATMEL_TC_ ## reg)
19437 +#define ATMEL_TC_CCR 0x00 /* Channel Control Register */
19438 +#define ATMEL_TC_CLKEN (1 << 0) /* clock enable */
19439 +#define ATMEL_TC_CLKDIS (1 << 1) /* clock disable */
19440 +#define ATMEL_TC_SWTRG (1 << 2) /* software trigger */
19442 +#define ATMEL_TC_CMR 0x04 /* Channel Mode Register */
19444 +/* Both modes share some CMR bits */
19445 +#define ATMEL_TC_TCCLKS (7 << 0) /* clock source */
19446 +#define ATMEL_TC_TIMER_CLOCK1 (0 << 0)
19447 +#define ATMEL_TC_TIMER_CLOCK2 (1 << 0)
19448 +#define ATMEL_TC_TIMER_CLOCK3 (2 << 0)
19449 +#define ATMEL_TC_TIMER_CLOCK4 (3 << 0)
19450 +#define ATMEL_TC_TIMER_CLOCK5 (4 << 0)
19451 +#define ATMEL_TC_XC0 (5 << 0)
19452 +#define ATMEL_TC_XC1 (6 << 0)
19453 +#define ATMEL_TC_XC2 (7 << 0)
19454 +#define ATMEL_TC_CLKI (1 << 3) /* clock invert */
19455 +#define ATMEL_TC_BURST (3 << 4) /* clock gating */
19456 +#define ATMEL_TC_GATE_NONE (0 << 4)
19457 +#define ATMEL_TC_GATE_XC0 (1 << 4)
19458 +#define ATMEL_TC_GATE_XC1 (2 << 4)
19459 +#define ATMEL_TC_GATE_XC2 (3 << 4)
19460 +#define ATMEL_TC_WAVE (1 << 15) /* true = Waveform mode */
19462 +/* CAPTURE mode CMR bits */
19463 +#define ATMEL_TC_LDBSTOP (1 << 6) /* counter stops on RB load */
19464 +#define ATMEL_TC_LDBDIS (1 << 7) /* counter disable on RB load */
19465 +#define ATMEL_TC_ETRGEDG (3 << 8) /* external trigger edge */
19466 +#define ATMEL_TC_ETRGEDG_NONE (0 << 8)
19467 +#define ATMEL_TC_ETRGEDG_RISING (1 << 8)
19468 +#define ATMEL_TC_ETRGEDG_FALLING (2 << 8)
19469 +#define ATMEL_TC_ETRGEDG_BOTH (3 << 8)
19470 +#define ATMEL_TC_ABETRG (1 << 10) /* external trigger is TIOA? */
19471 +#define ATMEL_TC_CPCTRG (1 << 14) /* RC compare trigger enable */
19472 +#define ATMEL_TC_LDRA (3 << 16) /* RA loading edge (of TIOA) */
19473 +#define ATMEL_TC_LDRA_NONE (0 << 16)
19474 +#define ATMEL_TC_LDRA_RISING (1 << 16)
19475 +#define ATMEL_TC_LDRA_FALLING (2 << 16)
19476 +#define ATMEL_TC_LDRA_BOTH (3 << 16)
19477 +#define ATMEL_TC_LDRB (3 << 18) /* RB loading edge (of TIOA) */
19478 +#define ATMEL_TC_LDRB_NONE (0 << 18)
19479 +#define ATMEL_TC_LDRB_RISING (1 << 18)
19480 +#define ATMEL_TC_LDRB_FALLING (2 << 18)
19481 +#define ATMEL_TC_LDRB_BOTH (3 << 18)
19483 +/* WAVEFORM mode CMR bits */
19484 +#define ATMEL_TC_CPCSTOP (1 << 6) /* RC compare stops counter */
19485 +#define ATMEL_TC_CPCDIS (1 << 7) /* RC compare disables counter */
19486 +#define ATMEL_TC_EEVTEDG (3 << 8) /* external event edge */
19487 +#define ATMEL_TC_EEVTEDG_NONE (0 << 8)
19488 +#define ATMEL_TC_EEVTEDG_RISING (1 << 8)
19489 +#define ATMEL_TC_EEVTEDG_FALLING (2 << 8)
19490 +#define ATMEL_TC_EEVTEDG_BOTH (3 << 8)
19491 +#define ATMEL_TC_EEVT (3 << 10) /* external event source */
19492 +#define ATMEL_TC_EEVT_TIOB (0 << 10)
19493 +#define ATMEL_TC_EEVT_XC0 (1 << 10)
19494 +#define ATMEL_TC_EEVT_XC1 (2 << 10)
19495 +#define ATMEL_TC_EEVT_XC2 (3 << 10)
19496 +#define ATMEL_TC_ENETRG (1 << 12) /* external event is trigger */
19497 +#define ATMEL_TC_WAVESEL (3 << 13) /* waveform type */
19498 +#define ATMEL_TC_WAVESEL_UP (0 << 13)
19499 +#define ATMEL_TC_WAVESEL_UPDOWN (1 << 13)
19500 +#define ATMEL_TC_WAVESEL_UP_AUTO (2 << 13)
19501 +#define ATMEL_TC_WAVESEL_UPDOWN_AUTO (3 << 13)
19502 +#define ATMEL_TC_ACPA (3 << 16) /* RA compare changes TIOA */
19503 +#define ATMEL_TC_ACPA_NONE (0 << 16)
19504 +#define ATMEL_TC_ACPA_SET (1 << 16)
19505 +#define ATMEL_TC_ACPA_CLEAR (2 << 16)
19506 +#define ATMEL_TC_ACPA_TOGGLE (3 << 16)
19507 +#define ATMEL_TC_ACPC (3 << 18) /* RC compare changes TIOA */
19508 +#define ATMEL_TC_ACPC_NONE (0 << 18)
19509 +#define ATMEL_TC_ACPC_SET (1 << 18)
19510 +#define ATMEL_TC_ACPC_CLEAR (2 << 18)
19511 +#define ATMEL_TC_ACPC_TOGGLE (3 << 18)
19512 +#define ATMEL_TC_AEEVT (3 << 20) /* external event changes TIOA */
19513 +#define ATMEL_TC_AEEVT_NONE (0 << 20)
19514 +#define ATMEL_TC_AEEVT_SET (1 << 20)
19515 +#define ATMEL_TC_AEEVT_CLEAR (2 << 20)
19516 +#define ATMEL_TC_AEEVT_TOGGLE (3 << 20)
19517 +#define ATMEL_TC_ASWTRG (3 << 22) /* software trigger changes TIOA */
19518 +#define ATMEL_TC_ASWTRG_NONE (0 << 22)
19519 +#define ATMEL_TC_ASWTRG_SET (1 << 22)
19520 +#define ATMEL_TC_ASWTRG_CLEAR (2 << 22)
19521 +#define ATMEL_TC_ASWTRG_TOGGLE (3 << 22)
19522 +#define ATMEL_TC_BCPB (3 << 24) /* RB compare changes TIOB */
19523 +#define ATMEL_TC_BCPB_NONE (0 << 24)
19524 +#define ATMEL_TC_BCPB_SET (1 << 24)
19525 +#define ATMEL_TC_BCPB_CLEAR (2 << 24)
19526 +#define ATMEL_TC_BCPB_TOGGLE (3 << 24)
19527 +#define ATMEL_TC_BCPC (3 << 26) /* RC compare changes TIOB */
19528 +#define ATMEL_TC_BCPC_NONE (0 << 26)
19529 +#define ATMEL_TC_BCPC_SET (1 << 26)
19530 +#define ATMEL_TC_BCPC_CLEAR (2 << 26)
19531 +#define ATMEL_TC_BCPC_TOGGLE (3 << 26)
19532 +#define ATMEL_TC_BEEVT (3 << 28) /* external event changes TIOB */
19533 +#define ATMEL_TC_BEEVT_NONE (0 << 28)
19534 +#define ATMEL_TC_BEEVT_SET (1 << 28)
19535 +#define ATMEL_TC_BEEVT_CLEAR (2 << 28)
19536 +#define ATMEL_TC_BEEVT_TOGGLE (3 << 28)
19537 +#define ATMEL_TC_BSWTRG (3 << 30) /* software trigger changes TIOB */
19538 +#define ATMEL_TC_BSWTRG_NONE (0 << 30)
19539 +#define ATMEL_TC_BSWTRG_SET (1 << 30)
19540 +#define ATMEL_TC_BSWTRG_CLEAR (2 << 30)
19541 +#define ATMEL_TC_BSWTRG_TOGGLE (3 << 30)
19543 +#define ATMEL_TC_CV 0x10 /* counter Value */
19544 +#define ATMEL_TC_RA 0x14 /* register A */
19545 +#define ATMEL_TC_RB 0x18 /* register B */
19546 +#define ATMEL_TC_RC 0x1c /* register C */
19548 +#define ATMEL_TC_SR 0x20 /* status (read-only) */
19549 +/* Status-only flags */
19550 +#define ATMEL_TC_CLKSTA (1 << 16) /* clock enabled */
19551 +#define ATMEL_TC_MTIOA (1 << 17) /* TIOA mirror */
19552 +#define ATMEL_TC_MTIOB (1 << 18) /* TIOB mirror */
19554 +#define ATMEL_TC_IER 0x24 /* interrupt enable (write-only) */
19555 +#define ATMEL_TC_IDR 0x28 /* interrupt disable (write-only) */
19556 +#define ATMEL_TC_IMR 0x2c /* interrupt mask (read-only) */
19558 +/* Status and IRQ flags */
19559 +#define ATMEL_TC_COVFS (1 << 0) /* counter overflow */
19560 +#define ATMEL_TC_LOVRS (1 << 1) /* load overrun */
19561 +#define ATMEL_TC_CPAS (1 << 2) /* RA compare */
19562 +#define ATMEL_TC_CPBS (1 << 3) /* RB compare */
19563 +#define ATMEL_TC_CPCS (1 << 4) /* RC compare */
19564 +#define ATMEL_TC_LDRAS (1 << 5) /* RA loading */
19565 +#define ATMEL_TC_LDRBS (1 << 6) /* RB loading */
19566 +#define ATMEL_TC_ETRGS (1 << 7) /* external trigger */
19570 +++ b/include/linux/usb/atmel_usba_udc.h
19573 + * Platform data definitions for Atmel USBA gadget driver.
19575 +#ifndef __LINUX_USB_USBA_H
19576 +#define __LINUX_USB_USBA_H
19578 +struct usba_ep_data {
19587 +struct usba_platform_data {
19590 + struct usba_ep_data ep[0];
19593 +#endif /* __LINUX_USB_USBA_H */
19594 --- a/include/video/atmel_lcdc.h
19595 +++ b/include/video/atmel_lcdc.h
19597 #ifndef __ATMEL_LCDC_H__
19598 #define __ATMEL_LCDC_H__
19600 - /* LCD Controller info data structure */
19601 + /* LCD Controller info data structure, stored in device platform_data */
19602 struct atmel_lcdfb_info {
19604 struct fb_info *info;
19606 struct platform_device *pdev;
19607 struct clk *bus_clk;
19608 struct clk *lcdc_clk;
19609 - unsigned int default_bpp;
19611 +#ifdef CONFIG_BACKLIGHT_ATMEL_LCDC
19612 + struct backlight_device *backlight;
19615 + bool lcdcon_is_backlight;
19618 unsigned int default_lcdcon2;
19619 unsigned int default_dmacon;
19620 void (*atmel_lcdfb_power_control)(int on);
19621 @@ -115,20 +122,20 @@
19622 #define ATMEL_LCDC_MEMOR_LITTLE (1 << 31)
19624 #define ATMEL_LCDC_TIM1 0x0808
19625 -#define ATMEL_LCDC_VFP (0xff << 0)
19626 +#define ATMEL_LCDC_VFP (0xffU << 0)
19627 #define ATMEL_LCDC_VBP_OFFSET 8
19628 -#define ATMEL_LCDC_VBP (0xff << ATMEL_LCDC_VBP_OFFSET)
19629 +#define ATMEL_LCDC_VBP (0xffU << ATMEL_LCDC_VBP_OFFSET)
19630 #define ATMEL_LCDC_VPW_OFFSET 16
19631 -#define ATMEL_LCDC_VPW (0x3f << ATMEL_LCDC_VPW_OFFSET)
19632 +#define ATMEL_LCDC_VPW (0x3fU << ATMEL_LCDC_VPW_OFFSET)
19633 #define ATMEL_LCDC_VHDLY_OFFSET 24
19634 -#define ATMEL_LCDC_VHDLY (0xf << ATMEL_LCDC_VHDLY_OFFSET)
19635 +#define ATMEL_LCDC_VHDLY (0xfU << ATMEL_LCDC_VHDLY_OFFSET)
19637 #define ATMEL_LCDC_TIM2 0x080c
19638 -#define ATMEL_LCDC_HBP (0xff << 0)
19639 +#define ATMEL_LCDC_HBP (0xffU << 0)
19640 #define ATMEL_LCDC_HPW_OFFSET 8
19641 -#define ATMEL_LCDC_HPW (0x3f << ATMEL_LCDC_HPW_OFFSET)
19642 +#define ATMEL_LCDC_HPW (0x3fU << ATMEL_LCDC_HPW_OFFSET)
19643 #define ATMEL_LCDC_HFP_OFFSET 21
19644 -#define ATMEL_LCDC_HFP (0x7ff << ATMEL_LCDC_HFP_OFFSET)
19645 +#define ATMEL_LCDC_HFP (0x7ffU << ATMEL_LCDC_HFP_OFFSET)
19647 #define ATMEL_LCDC_LCDFRMCFG 0x0810
19648 #define ATMEL_LCDC_LINEVAL (0x7ff << 0)
19649 --- a/init/do_mounts.c
19650 +++ b/init/do_mounts.c
19651 @@ -219,8 +219,14 @@
19653 static int __init rootwait_setup(char *str)
19656 + if (*str && *str != '=')
19660 + printk(KERN_WARNING
19661 + "WARNING: \"rootwait=1\" is deprecated, "
19662 + "use \"rootwait\" instead.\n");
19667 --- a/kernel/ptrace.c
19668 +++ b/kernel/ptrace.c
19669 @@ -470,6 +470,8 @@
19671 if (request == PTRACE_TRACEME) {
19672 ret = ptrace_traceme();
19674 + arch_ptrace_attach(current);
19680 @@ -671,6 +671,12 @@
19681 W: http://www.at91.com/
19684 +ATMEL AT91 / AT32 SERIAL DRIVER
19685 +P: Haavard Skinnemoen
19686 +M: hskinnemoen@atmel.com
19687 +L: linux-kernel@vger.kernel.org
19692 M: nicolas.ferre@atmel.com
19694 +++ b/sound/avr32/ac97c.c
19697 + * Driver for the Atmel AC97 controller
19699 + * Copyright (C) 2005-2007 Atmel Corporation
19701 + * This program is free software; you can redistribute it and/or modify it
19702 + * under the terms of the GNU General Public License version 2 as published by
19703 + * the Free Software Foundation.
19705 +#include <linux/clk.h>
19706 +#include <linux/delay.h>
19707 +#include <linux/dma-mapping.h>
19708 +#include <linux/init.h>
19709 +#include <linux/interrupt.h>
19710 +#include <linux/module.h>
19711 +#include <linux/platform_device.h>
19712 +#include <linux/mutex.h>
19713 +#include <linux/io.h>
19715 +#include <sound/driver.h>
19716 +#include <sound/core.h>
19717 +#include <sound/initval.h>
19718 +#include <sound/pcm.h>
19719 +#include <sound/pcm_params.h>
19720 +#include <sound/ac97_codec.h>
19721 +#include <sound/memalloc.h>
19723 +#include <asm/dma-controller.h>
19725 +#include "ac97c.h"
19727 +/* Serialize access to opened */
19728 +static DEFINE_MUTEX(opened_mutex);
19730 +struct atmel_ac97_dma_info {
19731 + struct dma_request_cyclic req_tx;
19732 + struct dma_request_cyclic req_rx;
19733 + unsigned short rx_periph_id;
19734 + unsigned short tx_periph_id;
19737 +struct atmel_ac97 {
19738 + /* Serialize access to opened */
19740 + void __iomem *regs;
19741 + struct snd_pcm_substream *playback_substream;
19742 + struct snd_pcm_substream *capture_substream;
19743 + struct snd_card *card;
19744 + struct snd_pcm *pcm;
19745 + struct snd_ac97 *ac97;
19746 + struct snd_ac97_bus *ac97_bus;
19750 + unsigned int cur_rate;
19752 + struct platform_device *pdev;
19753 + struct atmel_ac97_dma_info dma;
19756 +#define get_chip(card) ((struct atmel_ac97 *)(card)->private_data)
19758 +#define ac97c_writel(chip, reg, val) \
19759 + __raw_writel((val), (chip)->regs + AC97C_##reg)
19760 +#define ac97c_readl(chip, reg) \
19761 + __raw_readl((chip)->regs + AC97C_##reg)
19766 +static struct snd_pcm_hardware snd_atmel_ac97_playback_hw = {
19767 + .info = (SNDRV_PCM_INFO_INTERLEAVED
19768 + | SNDRV_PCM_INFO_MMAP
19769 + | SNDRV_PCM_INFO_MMAP_VALID
19770 + | SNDRV_PCM_INFO_BLOCK_TRANSFER
19771 + | SNDRV_PCM_INFO_JOINT_DUPLEX),
19772 + .formats = (SNDRV_PCM_FMTBIT_S16_BE
19773 + | SNDRV_PCM_FMTBIT_S16_LE),
19774 + .rates = (SNDRV_PCM_RATE_CONTINUOUS),
19775 + .rate_min = 4000,
19776 + .rate_max = 48000,
19777 + .channels_min = 1,
19778 + .channels_max = 6,
19779 + .buffer_bytes_max = 64*1024,
19780 + .period_bytes_min = 512,
19781 + .period_bytes_max = 4095,
19782 + .periods_min = 8,
19783 + .periods_max = 1024,
19786 +static struct snd_pcm_hardware snd_atmel_ac97_capture_hw = {
19787 + .info = (SNDRV_PCM_INFO_INTERLEAVED
19788 + | SNDRV_PCM_INFO_MMAP
19789 + | SNDRV_PCM_INFO_MMAP_VALID
19790 + | SNDRV_PCM_INFO_BLOCK_TRANSFER
19791 + | SNDRV_PCM_INFO_JOINT_DUPLEX),
19792 + .formats = (SNDRV_PCM_FMTBIT_S16_BE
19793 + | SNDRV_PCM_FMTBIT_S16_LE),
19794 + .rates = (SNDRV_PCM_RATE_CONTINUOUS),
19795 + .rate_min = 4000,
19796 + .rate_max = 48000,
19797 + .channels_min = 1,
19798 + .channels_max = 2,
19799 + .buffer_bytes_max = 64*1024,
19800 + .period_bytes_min = 512,
19801 + .period_bytes_max = 4095,
19802 + .periods_min = 8,
19803 + .periods_max = 1024,
19810 +snd_atmel_ac97_playback_open(struct snd_pcm_substream *substream)
19812 + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
19813 + struct snd_pcm_runtime *runtime = substream->runtime;
19815 + mutex_lock(&opened_mutex);
19817 + runtime->hw = snd_atmel_ac97_playback_hw;
19818 + if (chip->cur_rate) {
19819 + runtime->hw.rate_min = chip->cur_rate;
19820 + runtime->hw.rate_max = chip->cur_rate;
19822 + if (chip->cur_format)
19823 + runtime->hw.formats = (1ULL << chip->cur_format);
19824 + mutex_unlock(&opened_mutex);
19825 + chip->playback_substream = substream;
19826 + chip->period = 0;
19831 +snd_atmel_ac97_capture_open(struct snd_pcm_substream *substream)
19833 + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
19834 + struct snd_pcm_runtime *runtime = substream->runtime;
19836 + mutex_lock(&opened_mutex);
19838 + runtime->hw = snd_atmel_ac97_capture_hw;
19839 + if (chip->cur_rate) {
19840 + runtime->hw.rate_min = chip->cur_rate;
19841 + runtime->hw.rate_max = chip->cur_rate;
19843 + if (chip->cur_format)
19844 + runtime->hw.formats = (1ULL << chip->cur_format);
19845 + mutex_unlock(&opened_mutex);
19846 + chip->capture_substream = substream;
19847 + chip->period = 0;
19851 +static int snd_atmel_ac97_playback_close(struct snd_pcm_substream *substream)
19853 + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
19854 + mutex_lock(&opened_mutex);
19856 + if (!chip->opened) {
19857 + chip->cur_rate = 0;
19858 + chip->cur_format = 0;
19860 + mutex_unlock(&opened_mutex);
19864 +static int snd_atmel_ac97_capture_close(struct snd_pcm_substream *substream)
19866 + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
19867 + mutex_lock(&opened_mutex);
19869 + if (!chip->opened) {
19870 + chip->cur_rate = 0;
19871 + chip->cur_format = 0;
19873 + mutex_unlock(&opened_mutex);
19878 +snd_atmel_ac97_playback_hw_params(struct snd_pcm_substream *substream,
19879 + struct snd_pcm_hw_params *hw_params)
19881 + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
19884 + err = snd_pcm_lib_malloc_pages(substream,
19885 + params_buffer_bytes(hw_params));
19889 + /* Set restrictions to params */
19890 + mutex_lock(&opened_mutex);
19891 + chip->cur_rate = params_rate(hw_params);
19892 + chip->cur_format = params_format(hw_params);
19893 + mutex_unlock(&opened_mutex);
19899 +snd_atmel_ac97_capture_hw_params(struct snd_pcm_substream *substream,
19900 + struct snd_pcm_hw_params *hw_params)
19902 + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
19905 + err = snd_pcm_lib_malloc_pages(substream,
19906 + params_buffer_bytes(hw_params));
19910 + /* Set restrictions to params */
19911 + mutex_lock(&opened_mutex);
19912 + chip->cur_rate = params_rate(hw_params);
19913 + chip->cur_format = params_format(hw_params);
19914 + mutex_unlock(&opened_mutex);
19919 +static int snd_atmel_ac97_playback_hw_free(struct snd_pcm_substream *substream)
19921 + return snd_pcm_lib_free_pages(substream);
19924 +static int snd_atmel_ac97_capture_hw_free(struct snd_pcm_substream *substream)
19927 + return snd_pcm_lib_free_pages(substream);
19930 +static int snd_atmel_ac97_playback_prepare(struct snd_pcm_substream *substream)
19932 + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
19933 + struct platform_device *pdev = chip->pdev;
19934 + struct snd_pcm_runtime *runtime = substream->runtime;
19935 + int block_size = frames_to_bytes(runtime, runtime->period_size);
19936 + unsigned long word = 0;
19937 + unsigned long buffer_size = 0;
19939 + dma_sync_single_for_device(&pdev->dev, runtime->dma_addr,
19940 + block_size * 2, DMA_TO_DEVICE);
19942 + /* Assign slots to channels */
19943 + switch (substream->runtime->channels) {
19945 + word |= AC97C_CH_ASSIGN(PCM_LEFT, A);
19948 + /* Assign Left and Right slot to Channel A */
19949 + word |= AC97C_CH_ASSIGN(PCM_LEFT, A)
19950 + | AC97C_CH_ASSIGN(PCM_RIGHT, A);
19953 + /* TODO: support more than two channels */
19957 + ac97c_writel(chip, OCA, word);
19959 + /* Configure sample format and size */
19960 + word = AC97C_CMR_PDCEN | AC97C_CMR_SIZE_16;
19962 + switch (runtime->format) {
19963 + case SNDRV_PCM_FORMAT_S16_LE:
19964 + word |= AC97C_CMR_CEM_LITTLE;
19966 + case SNDRV_PCM_FORMAT_S16_BE: /* fall through */
19968 + word &= ~AC97C_CMR_CEM_LITTLE;
19972 + ac97c_writel(chip, CAMR, word);
19974 + /* Set variable rate if needed */
19975 + if (runtime->rate != 48000) {
19976 + word = ac97c_readl(chip, MR);
19977 + word |= AC97C_MR_VRA;
19978 + ac97c_writel(chip, MR, word);
19980 + /* Clear Variable Rate Bit */
19981 + word = ac97c_readl(chip, MR);
19982 + word &= ~AC97C_MR_VRA;
19983 + ac97c_writel(chip, MR, word);
19987 + snd_ac97_set_rate(chip->ac97, AC97_PCM_FRONT_DAC_RATE, runtime->rate);
19989 + buffer_size = frames_to_bytes(runtime, runtime->period_size) *
19990 + runtime->periods;
19992 + chip->dma.req_tx.buffer_size = buffer_size;
19993 + chip->dma.req_tx.periods = runtime->periods;
19995 + BUG_ON(chip->dma.req_tx.buffer_size !=
19996 + (chip->dma.req_tx.periods *
19997 + frames_to_bytes(runtime, runtime->period_size)));
19999 + chip->dma.req_tx.buffer_start = runtime->dma_addr;
20000 + chip->dma.req_tx.data_reg = (dma_addr_t)(chip->regs + AC97C_CATHR + 2);
20001 + chip->dma.req_tx.periph_id = chip->dma.tx_periph_id;
20002 + chip->dma.req_tx.direction = DMA_DIR_MEM_TO_PERIPH;
20003 + chip->dma.req_tx.width = DMA_WIDTH_16BIT;
20004 + chip->dma.req_tx.dev_id = chip;
20009 +static int snd_atmel_ac97_capture_prepare(struct snd_pcm_substream *substream)
20011 + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
20012 + struct platform_device *pdev = chip->pdev;
20013 + struct snd_pcm_runtime *runtime = substream->runtime;
20014 + int block_size = frames_to_bytes(runtime, runtime->period_size);
20015 + unsigned long word = 0;
20016 + unsigned long buffer_size = 0;
20018 + dma_sync_single_for_device(&pdev->dev, runtime->dma_addr,
20019 + block_size * 2, DMA_FROM_DEVICE);
20021 + /* Assign slots to channels */
20022 + switch (substream->runtime->channels) {
20024 + word |= AC97C_CH_ASSIGN(PCM_LEFT, A);
20027 + /* Assign Left and Right slot to Channel A */
20028 + word |= AC97C_CH_ASSIGN(PCM_LEFT, A)
20029 + | AC97C_CH_ASSIGN(PCM_RIGHT, A);
20032 + /* TODO: support more than two channels */
20036 + ac97c_writel(chip, ICA, word);
20038 + /* Configure sample format and size */
20039 + word = AC97C_CMR_PDCEN | AC97C_CMR_SIZE_16;
20041 + switch (runtime->format) {
20042 + case SNDRV_PCM_FORMAT_S16_LE:
20043 + word |= AC97C_CMR_CEM_LITTLE;
20045 + case SNDRV_PCM_FORMAT_S16_BE:
20047 + word &= ~(AC97C_CMR_CEM_LITTLE);
20051 + ac97c_writel(chip, CAMR, word);
20053 + /* Set variable rate if needed */
20054 + if (runtime->rate != 48000) {
20055 + word = ac97c_readl(chip, MR);
20056 + word |= AC97C_MR_VRA;
20057 + ac97c_writel(chip, MR, word);
20059 + /* Clear Variable Rate Bit */
20060 + word = ac97c_readl(chip, MR);
20061 + word &= ~(AC97C_MR_VRA);
20062 + ac97c_writel(chip, MR, word);
20066 + snd_ac97_set_rate(chip->ac97, AC97_PCM_LR_ADC_RATE, runtime->rate);
20068 + buffer_size = frames_to_bytes(runtime, runtime->period_size) *
20069 + runtime->periods;
20071 + chip->dma.req_rx.buffer_size = buffer_size;
20072 + chip->dma.req_rx.periods = runtime->periods;
20074 + BUG_ON(chip->dma.req_rx.buffer_size !=
20075 + (chip->dma.req_rx.periods *
20076 + frames_to_bytes(runtime, runtime->period_size)));
20078 + chip->dma.req_rx.buffer_start = runtime->dma_addr;
20079 + chip->dma.req_rx.data_reg = (dma_addr_t)(chip->regs + AC97C_CARHR + 2);
20080 + chip->dma.req_rx.periph_id = chip->dma.rx_periph_id;
20081 + chip->dma.req_rx.direction = DMA_DIR_PERIPH_TO_MEM;
20082 + chip->dma.req_rx.width = DMA_WIDTH_16BIT;
20083 + chip->dma.req_rx.dev_id = chip;
20089 +snd_atmel_ac97_playback_trigger(struct snd_pcm_substream *substream, int cmd)
20091 + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
20092 + unsigned long camr;
20093 + int flags, err = 0;
20095 + spin_lock_irqsave(&chip->lock, flags);
20096 + camr = ac97c_readl(chip, CAMR);
20099 + case SNDRV_PCM_TRIGGER_START:
20100 + err = dma_prepare_request_cyclic(chip->dma.req_tx.req.dmac,
20101 + &chip->dma.req_tx);
20102 + dma_start_request(chip->dma.req_tx.req.dmac,
20103 + chip->dma.req_tx.req.channel);
20104 + camr |= AC97C_CMR_CENA;
20106 + case SNDRV_PCM_TRIGGER_STOP:
20107 + err = dma_stop_request(chip->dma.req_tx.req.dmac,
20108 + chip->dma.req_tx.req.channel);
20109 + if (chip->opened <= 1)
20110 + camr &= ~AC97C_CMR_CENA;
20117 + ac97c_writel(chip, CAMR, camr);
20119 + spin_unlock_irqrestore(&chip->lock, flags);
20124 +snd_atmel_ac97_capture_trigger(struct snd_pcm_substream *substream, int cmd)
20126 + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
20127 + unsigned long camr;
20128 + int flags, err = 0;
20130 + spin_lock_irqsave(&chip->lock, flags);
20131 + camr = ac97c_readl(chip, CAMR);
20134 + case SNDRV_PCM_TRIGGER_START:
20135 + err = dma_prepare_request_cyclic(chip->dma.req_rx.req.dmac,
20136 + &chip->dma.req_rx);
20137 + dma_start_request(chip->dma.req_rx.req.dmac,
20138 + chip->dma.req_rx.req.channel);
20139 + camr |= AC97C_CMR_CENA;
20141 + case SNDRV_PCM_TRIGGER_STOP:
20142 + err = dma_stop_request(chip->dma.req_rx.req.dmac,
20143 + chip->dma.req_rx.req.channel);
20144 + mutex_lock(&opened_mutex);
20145 + if (chip->opened <= 1)
20146 + camr &= ~AC97C_CMR_CENA;
20147 + mutex_unlock(&opened_mutex);
20154 + ac97c_writel(chip, CAMR, camr);
20156 + spin_unlock_irqrestore(&chip->lock, flags);
20160 + static snd_pcm_uframes_t
20161 +snd_atmel_ac97_playback_pointer(struct snd_pcm_substream *substream)
20163 + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
20164 + struct snd_pcm_runtime *runtime = substream->runtime;
20165 + snd_pcm_uframes_t pos;
20166 + unsigned long bytes;
20168 + bytes = (dma_get_current_pos
20169 + (chip->dma.req_tx.req.dmac,
20170 + chip->dma.req_tx.req.channel) - runtime->dma_addr);
20171 + pos = bytes_to_frames(runtime, bytes);
20172 + if (pos >= runtime->buffer_size)
20173 + pos -= runtime->buffer_size;
20178 + static snd_pcm_uframes_t
20179 +snd_atmel_ac97_capture_pointer(struct snd_pcm_substream *substream)
20181 + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
20182 + struct snd_pcm_runtime *runtime = substream->runtime;
20183 + snd_pcm_uframes_t pos;
20184 + unsigned long bytes;
20186 + bytes = (dma_get_current_pos
20187 + (chip->dma.req_rx.req.dmac,
20188 + chip->dma.req_rx.req.channel)
20189 + - runtime->dma_addr);
20190 + pos = bytes_to_frames(runtime, bytes);
20191 + if (pos >= runtime->buffer_size)
20192 + pos -= runtime->buffer_size;
20198 +static struct snd_pcm_ops atmel_ac97_playback_ops = {
20199 + .open = snd_atmel_ac97_playback_open,
20200 + .close = snd_atmel_ac97_playback_close,
20201 + .ioctl = snd_pcm_lib_ioctl,
20202 + .hw_params = snd_atmel_ac97_playback_hw_params,
20203 + .hw_free = snd_atmel_ac97_playback_hw_free,
20204 + .prepare = snd_atmel_ac97_playback_prepare,
20205 + .trigger = snd_atmel_ac97_playback_trigger,
20206 + .pointer = snd_atmel_ac97_playback_pointer,
20209 +static struct snd_pcm_ops atmel_ac97_capture_ops = {
20210 + .open = snd_atmel_ac97_capture_open,
20211 + .close = snd_atmel_ac97_capture_close,
20212 + .ioctl = snd_pcm_lib_ioctl,
20213 + .hw_params = snd_atmel_ac97_capture_hw_params,
20214 + .hw_free = snd_atmel_ac97_capture_hw_free,
20215 + .prepare = snd_atmel_ac97_capture_prepare,
20216 + .trigger = snd_atmel_ac97_capture_trigger,
20217 + .pointer = snd_atmel_ac97_capture_pointer,
20220 +static struct ac97_pcm atmel_ac97_pcm_defs[] __devinitdata = {
20225 + .slots = ((1 << AC97_SLOT_PCM_LEFT)
20226 + | (1 << AC97_SLOT_PCM_RIGHT)
20227 + | (1 << AC97_SLOT_PCM_CENTER)
20228 + | (1 << AC97_SLOT_PCM_SLEFT)
20229 + | (1 << AC97_SLOT_PCM_SRIGHT)
20230 + | (1 << AC97_SLOT_LFE)),
20238 + .slots = ((1 << AC97_SLOT_PCM_LEFT)
20239 + | (1 << AC97_SLOT_PCM_RIGHT)),
20247 + .slots = (1<<AC97_SLOT_MIC),
20252 +static int __devinit snd_atmel_ac97_pcm_new(struct atmel_ac97 *chip)
20254 + struct snd_pcm *pcm;
20257 + err = snd_ac97_pcm_assign(chip->ac97_bus,
20258 + ARRAY_SIZE(atmel_ac97_pcm_defs),
20259 + atmel_ac97_pcm_defs);
20263 + err = snd_pcm_new(chip->card, "Atmel-AC97", 0, 1, 1, &pcm);
20267 + snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
20268 + &atmel_ac97_playback_ops);
20270 + snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
20271 + &atmel_ac97_capture_ops);
20273 + snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
20274 + &chip->pdev->dev,
20275 + 128 * 1024, 128 * 1024);
20277 + pcm->private_data = chip;
20278 + pcm->info_flags = 0;
20279 + strcpy(pcm->name, "Atmel-AC97");
20288 +static int snd_atmel_ac97_mixer_new(struct atmel_ac97 *chip)
20291 + struct snd_ac97_template template;
20293 + memset(&template, 0, sizeof(template));
20294 + template.private_data = chip;
20295 + err = snd_ac97_mixer(chip->ac97_bus, &template, &chip->ac97);
20300 +static void atmel_ac97_error(struct dma_request *_req)
20302 + struct dma_request_cyclic *req = to_dma_request_cyclic(_req);
20303 + struct atmel_ac97 *chip = req->dev_id;
20305 + dev_dbg(&chip->pdev->dev, "DMA Controller error, channel %d\n",
20306 + req->req.channel);
20309 +static void atmel_ac97_block_complete(struct dma_request *_req)
20311 + struct dma_request_cyclic *req = to_dma_request_cyclic(_req);
20312 + struct atmel_ac97 *chip = req->dev_id;
20313 + if (req->periph_id == chip->dma.tx_periph_id)
20314 + snd_pcm_period_elapsed(chip->playback_substream);
20316 + snd_pcm_period_elapsed(chip->capture_substream);
20322 +static void snd_atmel_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
20323 + unsigned short val)
20325 + struct atmel_ac97 *chip = get_chip(ac97);
20326 + unsigned long word;
20327 + int timeout = 40;
20329 + word = (reg & 0x7f) << 16 | val;
20332 + if (ac97c_readl(chip, COSR) & AC97C_CSR_TXRDY) {
20333 + ac97c_writel(chip, COTHR, word);
20337 + } while (--timeout);
20339 + dev_dbg(&chip->pdev->dev, "codec write timeout\n");
20342 +static unsigned short snd_atmel_ac97_read(struct snd_ac97 *ac97,
20343 + unsigned short reg)
20345 + struct atmel_ac97 *chip = get_chip(ac97);
20346 + unsigned long word;
20347 + int timeout = 40;
20350 + word = (0x80 | (reg & 0x7f)) << 16;
20352 + if ((ac97c_readl(chip, COSR) & AC97C_CSR_RXRDY) != 0)
20353 + ac97c_readl(chip, CORHR);
20359 + if ((ac97c_readl(chip, COSR) & AC97C_CSR_TXRDY) != 0) {
20360 + ac97c_writel(chip, COTHR, word);
20364 + } while (--timeout);
20368 + goto retry_write;
20372 + if ((ac97c_readl(chip, COSR) & AC97C_CSR_RXRDY) != 0) {
20373 + unsigned short val = ac97c_readl(chip, CORHR);
20377 + } while (--timeout);
20381 + goto retry_write;
20384 + dev_dbg(&chip->pdev->dev, "codec read timeout\n");
20388 +static void snd_atmel_ac97_reset(struct atmel_ac97 *chip)
20390 + ac97c_writel(chip, MR, AC97C_MR_WRST);
20392 + ac97c_writel(chip, MR, AC97C_MR_ENA);
20395 +static void snd_atmel_ac97_destroy(struct snd_card *card)
20397 + struct atmel_ac97 *chip = get_chip(card);
20400 + iounmap(chip->regs);
20403 + clk_disable(chip->mck);
20404 + clk_put(chip->mck);
20407 + if (chip->dma.req_tx.req.dmac) {
20408 + dma_release_channel(chip->dma.req_tx.req.dmac,
20409 + chip->dma.req_tx.req.channel);
20411 + if (chip->dma.req_rx.req.dmac) {
20412 + dma_release_channel(chip->dma.req_rx.req.dmac,
20413 + chip->dma.req_rx.req.channel);
20417 +static int __devinit snd_atmel_ac97_create(struct snd_card *card,
20418 + struct platform_device *pdev)
20420 + static struct snd_ac97_bus_ops ops = {
20421 + .write = snd_atmel_ac97_write,
20422 + .read = snd_atmel_ac97_read,
20424 + struct atmel_ac97 *chip = get_chip(card);
20425 + struct resource *regs;
20429 + regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
20433 + mck = clk_get(&pdev->dev, "pclk");
20435 + return PTR_ERR(mck);
20439 + card->private_free = snd_atmel_ac97_destroy;
20441 + spin_lock_init(&chip->lock);
20442 + chip->card = card;
20443 + chip->pdev = pdev;
20445 + chip->regs = ioremap(regs->start, regs->end - regs->start + 1);
20449 + snd_card_set_dev(card, &pdev->dev);
20451 + err = snd_ac97_bus(card, 0, &ops, chip, &chip->ac97_bus);
20456 +static int __devinit snd_atmel_ac97_probe(struct platform_device *pdev)
20459 + struct snd_card *card;
20460 + struct atmel_ac97 *chip;
20464 + mutex_init(&opened_mutex);
20467 + card = snd_card_new(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
20468 + THIS_MODULE, sizeof(struct atmel_ac97));
20471 + chip = get_chip(card);
20473 + err = snd_atmel_ac97_create(card, pdev);
20475 + goto out_free_card;
20477 + snd_atmel_ac97_reset(chip);
20479 + err = snd_atmel_ac97_mixer_new(chip);
20481 + goto out_free_card;
20483 + err = snd_atmel_ac97_pcm_new(chip);
20485 + goto out_free_card;
20487 + /* TODO: Get this information from the platform device */
20488 + chip->dma.req_tx.req.dmac = find_dma_controller(0);
20489 + if (!chip->dma.req_tx.req.dmac) {
20490 + dev_dbg(&chip->pdev->dev, "DMA controller for TX missing\n");
20492 + goto out_free_card;
20494 + chip->dma.req_rx.req.dmac = find_dma_controller(0);
20495 + if (!chip->dma.req_rx.req.dmac) {
20496 + dev_dbg(&chip->pdev->dev, "DMA controller for RX missing\n");
20498 + goto out_free_card;
20501 + chip->dma.rx_periph_id = 3;
20502 + chip->dma.tx_periph_id = 4;
20504 + ch = dma_alloc_channel(chip->dma.req_tx.req.dmac);
20506 + dev_dbg(&chip->pdev->dev,
20507 + "could not allocate TX DMA channel\n");
20509 + goto out_free_card;
20511 + chip->dma.req_tx.req.channel = ch;
20512 + chip->dma.req_tx.width = DMA_WIDTH_16BIT;
20513 + chip->dma.req_tx.req.block_complete = atmel_ac97_block_complete;
20514 + chip->dma.req_tx.req.error = atmel_ac97_error;
20516 + ch = dma_alloc_channel(chip->dma.req_rx.req.dmac);
20518 + dev_dbg(&chip->pdev->dev,
20519 + "could not allocate RX DMA channel\n");
20521 + goto out_free_card;
20523 + chip->dma.req_rx.req.channel = ch;
20524 + chip->dma.req_rx.width = DMA_WIDTH_16BIT;
20525 + chip->dma.req_rx.req.block_complete = atmel_ac97_block_complete;
20526 + chip->dma.req_rx.req.error = atmel_ac97_error;
20528 + strcpy(card->driver, "atmel_ac97c");
20529 + strcpy(card->shortname, "atmel_ac97c");
20530 + sprintf(card->longname, "Atmel AVR32 AC97 controller");
20532 + err = snd_card_register(card);
20534 + goto out_free_card;
20536 + platform_set_drvdata(pdev, card);
20539 + dev_info(&pdev->dev, "Atmel AVR32 AC97 controller at 0x%p\n",
20545 + snd_card_free(card);
20552 +snd_atmel_ac97_suspend(struct platform_device *pdev, pm_message_t msg)
20554 + struct snd_card *card = platform_get_drvdata(pdev);
20555 + struct atmel_ac97 *chip = card->private_data;
20557 + clk_disable(chip->mck);
20562 +static int snd_atmel_ac97_resume(struct platform_device *pdev)
20564 + struct snd_card *card = dev_get_drvdata(pdev);
20565 + struct atmel_ac97 *chip = card->private_data;
20567 + clk_enable(chip->mck);
20572 +#define snd_atmel_ac97_suspend NULL
20573 +#define snd_atmel_ac97_resume NULL
20576 +static int __devexit snd_atmel_ac97_remove(struct platform_device *pdev)
20578 + struct snd_card *card = platform_get_drvdata(pdev);
20580 + snd_card_free(card);
20581 + platform_set_drvdata(pdev, NULL);
20585 +static struct platform_driver atmel_ac97_driver = {
20586 + .remove = __devexit_p(snd_atmel_ac97_remove),
20588 + .name = "atmel_ac97c",
20590 + .suspend = snd_atmel_ac97_suspend,
20591 + .resume = snd_atmel_ac97_resume,
20594 +static int __init atmel_ac97_init(void)
20596 + return platform_driver_probe(&atmel_ac97_driver,
20597 + snd_atmel_ac97_probe);
20599 +module_init(atmel_ac97_init);
20601 +static void __exit atmel_ac97_exit(void)
20603 + platform_driver_unregister(&atmel_ac97_driver);
20605 +module_exit(atmel_ac97_exit);
20607 +MODULE_LICENSE("GPL");
20608 +MODULE_DESCRIPTION("Driver for Atmel AC97 Controller");
20609 +MODULE_AUTHOR("Haavard Skinnemoen <hskinnemoen@atmel.com>");
20611 +++ b/sound/avr32/ac97c.h
20614 + * Register definitions for the Atmel AC97 Controller.
20616 + * Copyright (C) 2005-2006 Atmel Corporation
20618 + * This program is free software; you can redistribute it and/or modify
20619 + * it under the terms of the GNU General Public License version 2 as
20620 + * published by the Free Software Foundation.
20622 +#ifndef __SOUND_AVR32_AC97C_H
20623 +#define __SOUND_AVR32_AC97C_H
20625 +#define AC97C_MR 0x08
20626 +#define AC97C_ICA 0x10
20627 +#define AC97C_OCA 0x14
20628 +#define AC97C_CARHR 0x20
20629 +#define AC97C_CATHR 0x24
20630 +#define AC97C_CASR 0x28
20631 +#define AC97C_CAMR 0x2c
20632 +#define AC97C_CBRHR 0x30
20633 +#define AC97C_CBTHR 0x34
20634 +#define AC97C_CBSR 0x38
20635 +#define AC97C_CBMR 0x3c
20636 +#define AC97C_CORHR 0x40
20637 +#define AC97C_COTHR 0x44
20638 +#define AC97C_COSR 0x48
20639 +#define AC97C_COMR 0x4c
20640 +#define AC97C_SR 0x50
20641 +#define AC97C_IER 0x54
20642 +#define AC97C_IDR 0x58
20643 +#define AC97C_IMR 0x5c
20644 +#define AC97C_VERSION 0xfc
20646 +#define AC97C_CATPR PDC_TPR
20647 +#define AC97C_CATCR PDC_TCR
20648 +#define AC97C_CATNPR PDC_TNPR
20649 +#define AC97C_CATNCR PDC_TNCR
20650 +#define AC97C_CARPR PDC_RPR
20651 +#define AC97C_CARCR PDC_RCR
20652 +#define AC97C_CARNPR PDC_RNPR
20653 +#define AC97C_CARNCR PDC_RNCR
20654 +#define AC97C_PTCR PDC_PTCR
20656 +#define AC97C_MR_ENA (1 << 0)
20657 +#define AC97C_MR_WRST (1 << 1)
20658 +#define AC97C_MR_VRA (1 << 2)
20660 +#define AC97C_CSR_TXRDY (1 << 0)
20661 +#define AC97C_CSR_UNRUN (1 << 2)
20662 +#define AC97C_CSR_RXRDY (1 << 4)
20663 +#define AC97C_CSR_ENDTX (1 << 10)
20664 +#define AC97C_CSR_ENDRX (1 << 14)
20666 +#define AC97C_CMR_SIZE_20 (0 << 16)
20667 +#define AC97C_CMR_SIZE_18 (1 << 16)
20668 +#define AC97C_CMR_SIZE_16 (2 << 16)
20669 +#define AC97C_CMR_SIZE_10 (3 << 16)
20670 +#define AC97C_CMR_CEM_LITTLE (1 << 18)
20671 +#define AC97C_CMR_CEM_BIG (0 << 18)
20672 +#define AC97C_CMR_CENA (1 << 21)
20673 +#define AC97C_CMR_PDCEN (1 << 22)
20675 +#define AC97C_SR_CAEVT (1 << 3)
20677 +#define AC97C_CH_ASSIGN(slot, channel) \
20678 + (AC97C_CHANNEL_##channel << (3 * (AC97_SLOT_##slot - 3)))
20679 +#define AC97C_CHANNEL_NONE 0x0
20680 +#define AC97C_CHANNEL_A 0x1
20681 +#define AC97C_CHANNEL_B 0x2
20683 +#endif /* __SOUND_AVR32_AC97C_H */
20685 +++ b/sound/avr32/Kconfig
20687 +menu "AVR32 devices"
20688 + depends on SND != n && AVR32
20690 +config SND_ATMEL_AC97
20691 + tristate "Atmel AC97 Controller Driver"
20693 + select SND_AC97_CODEC
20695 + ALSA sound driver for the Atmel AC97 controller.
20699 +++ b/sound/avr32/Makefile
20701 +snd-atmel-ac97-objs := ac97c.o
20703 +obj-$(CONFIG_SND_ATMEL_AC97) += snd-atmel-ac97.o
20704 --- a/sound/Kconfig
20705 +++ b/sound/Kconfig
20708 source "sound/arm/Kconfig"
20710 +source "sound/avr32/Kconfig"
20713 source "sound/spi/Kconfig"
20715 --- a/sound/Makefile
20716 +++ b/sound/Makefile
20718 obj-$(CONFIG_SOUND_PRIME) += oss/
20719 obj-$(CONFIG_DMASOUND) += oss/
20720 obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ sh/ synth/ usb/ \
20721 - sparc/ spi/ parisc/ pcmcia/ mips/ soc/
20722 + sparc/ spi/ parisc/ pcmcia/ mips/ soc/ avr32/
20723 obj-$(CONFIG_SND_AOA) += aoa/
20725 # This one must be compilable even if sound is configured out
20727 +++ b/sound/oss/at32_abdac.c
20730 + * OSS Sound Driver for the Atmel AT32 on-chip DAC.
20732 + * Copyright (C) 2006 Atmel Corporation
20734 + * This program is free software; you can redistribute it and/or modify
20735 + * it under the terms of the GNU General Public License version 2 as
20736 + * published by the Free Software Foundation.
20738 +#include <linux/clk.h>
20739 +#include <linux/dma-mapping.h>
20740 +#include <linux/fs.h>
20741 +#include <linux/init.h>
20742 +#include <linux/interrupt.h>
20743 +#include <linux/kernel.h>
20744 +#include <linux/module.h>
20745 +#include <linux/platform_device.h>
20746 +#include <linux/sound.h>
20747 +#include <linux/soundcard.h>
20749 +#include <asm/byteorder.h>
20750 +#include <asm/dma-controller.h>
20751 +#include <asm/io.h>
20752 +#include <asm/uaccess.h>
20754 +/* We want to use the "bizarre" swap-bytes-in-each-halfword macro */
20755 +#include <linux/byteorder/swabb.h>
20757 +#include "at32_abdac.h"
20759 +#define DMA_BUFFER_SIZE 32768
20760 +#define DMA_PERIOD_SHIFT 10
20761 +#define DMA_PERIOD_SIZE (1 << DMA_PERIOD_SHIFT)
20762 +#define DMA_WRITE_THRESHOLD DMA_PERIOD_SIZE
20764 +struct sound_settings {
20765 + unsigned int format;
20766 + unsigned int channels;
20767 + unsigned int sample_rate;
20768 + /* log2(bytes per sample) */
20769 + unsigned int input_order;
20774 + void __iomem *regs;
20776 + /* head and tail refer to number of words */
20783 + struct semaphore sem;
20784 + wait_queue_head_t write_wait;
20787 + * Read at most ucount bytes from ubuf, translate to 2-channel
20788 + * signed 16-bit big endian format and write to the DMA buffer
20789 + * as long as there is room left. Return the number of bytes
20790 + * successfully copied from ubuf, or -EFAULT if the first
20791 + * sample from ubuf couldn't be read. This function is not
20792 + * called unless there is room for at least one sample (4
20793 + * bytes) in the DMA buffer.
20795 + ssize_t (*trans)(struct at32_dac *dac, const char __user *ubuf,
20798 + struct sound_settings dsp_settings;
20799 + struct dma_request_cyclic req;
20802 + struct clk *sample_clk;
20803 + struct platform_device *pdev;
20808 +static struct at32_dac *the_dac;
20810 +static inline unsigned int abdac_get_head(struct at32_dac *dac)
20812 + return dac->dma.head & ((DMA_BUFFER_SIZE / 4) - 1);
20815 +static inline unsigned int abdac_get_tail(struct at32_dac *dac)
20817 + return dac->dma.tail & ((DMA_BUFFER_SIZE / 4) - 1);
20820 +static inline unsigned int abdac_dma_space(struct at32_dac *dac)
20822 + unsigned int space;
20824 + space = ((dac->dma.tail - dac->dma.head - 1)
20825 + & ((DMA_BUFFER_SIZE / 4) - 1));
20829 +static void abdac_update_dma_tail(struct at32_dac *dac)
20831 + dma_addr_t dma_addr;
20832 + unsigned int new_tail;
20834 + if (dac->playing) {
20835 + dma_addr = dma_get_current_pos(dac->req.req.dmac,
20836 + dac->req.req.channel);
20837 + new_tail = (dma_addr - dac->req.buffer_start) / 4;
20838 + if (new_tail >= dac->dma.head
20839 + && (dac->dma.tail < dac->dma.head
20840 + || dac->dma.tail > new_tail))
20841 + dev_notice(&dac->pdev->dev, "DMA underrun detected!\n");
20842 + dac->dma.tail = new_tail;
20843 + dev_dbg(&dac->pdev->dev, "update tail: 0x%x - 0x%x = %u\n",
20844 + dma_addr, dac->req.buffer_start, dac->dma.tail);
20848 +static int abdac_start(struct at32_dac *dac)
20852 + if (dac->playing)
20855 + memset(dac->dma.buf, 0, DMA_BUFFER_SIZE);
20857 + clk_enable(dac->sample_clk);
20859 + ret = dma_prepare_request_cyclic(dac->req.req.dmac, &dac->req);
20861 + goto out_stop_clock;
20863 + dev_dbg(&dac->pdev->dev, "starting DMA...\n");
20864 + ret = dma_start_request(dac->req.req.dmac, dac->req.req.channel);
20866 + goto out_stop_request;
20868 + dac_writel(dac, CTRL, DAC_BIT(EN));
20869 + dac->playing = 1;
20874 + dma_stop_request(dac->req.req.dmac,
20875 + dac->req.req.channel);
20877 + clk_disable(dac->sample_clk);
20881 +static int abdac_stop(struct at32_dac *dac)
20883 + if (dac->playing) {
20884 + dma_stop_request(dac->req.req.dmac, dac->req.req.channel);
20885 + dac_writel(dac, DATA, 0);
20886 + dac_writel(dac, CTRL, 0);
20887 + dac->playing = 0;
20888 + clk_disable(dac->sample_clk);
20894 +static int abdac_dma_prepare(struct at32_dac *dac)
20896 + dac->dma.buf = dma_alloc_coherent(&dac->pdev->dev, DMA_BUFFER_SIZE,
20897 + &dac->req.buffer_start, GFP_KERNEL);
20898 + if (!dac->dma.buf)
20901 + dac->dma.head = dac->dma.tail = 0;
20902 + dac->req.periods = DMA_BUFFER_SIZE / DMA_PERIOD_SIZE;
20903 + dac->req.buffer_size = DMA_BUFFER_SIZE;
20908 +static void abdac_dma_cleanup(struct at32_dac *dac)
20910 + if (dac->dma.buf)
20911 + dma_free_coherent(&dac->pdev->dev, DMA_BUFFER_SIZE,
20912 + dac->dma.buf, dac->req.buffer_start);
20913 + dac->dma.buf = NULL;
20916 +static void abdac_dma_block_complete(struct dma_request *req)
20918 + struct dma_request_cyclic *creq = to_dma_request_cyclic(req);
20919 + struct at32_dac *dac = container_of(creq, struct at32_dac, req);
20921 + wake_up(&dac->write_wait);
20924 +static void abdac_dma_error(struct dma_request *req)
20926 + struct dma_request_cyclic *creq = to_dma_request_cyclic(req);
20927 + struct at32_dac *dac = container_of(creq, struct at32_dac, req);
20929 + dev_err(&dac->pdev->dev, "DMA error\n");
20932 +static irqreturn_t abdac_interrupt(int irq, void *dev_id)
20934 + struct at32_dac *dac = dev_id;
20937 + status = dac_readl(dac, INT_STATUS);
20938 + if (status & DAC_BIT(UNDERRUN)) {
20939 + dev_err(&dac->pdev->dev, "Underrun detected!\n");
20940 + dac_writel(dac, INT_CLR, DAC_BIT(UNDERRUN));
20942 + dev_err(&dac->pdev->dev, "Spurious interrupt (status=0x%x)\n",
20944 + dac_writel(dac, INT_CLR, status);
20947 + return IRQ_HANDLED;
20950 +static ssize_t trans_s16be(struct at32_dac *dac, const char __user *ubuf,
20955 + if (dac->dsp_settings.channels == 2) {
20956 + const u32 __user *up = (const u32 __user *)ubuf;
20959 + for (ret = 0; ret < (ssize_t)(ucount - 3); ret += 4) {
20960 + if (!abdac_dma_space(dac))
20963 + if (unlikely(__get_user(sample, up++))) {
20968 + dac->dma.buf[abdac_get_head(dac)] = sample;
20972 + const u16 __user *up = (const u16 __user *)ubuf;
20975 + for (ret = 0; ret < (ssize_t)(ucount - 1); ret += 2) {
20976 + if (!abdac_dma_space(dac))
20979 + if (unlikely(__get_user(sample, up++))) {
20984 + dac->dma.buf[abdac_get_head(dac)]
20985 + = (sample << 16) | sample;
20993 +static ssize_t trans_s16le(struct at32_dac *dac, const char __user *ubuf,
20998 + if (dac->dsp_settings.channels == 2) {
20999 + const u32 __user *up = (const u32 __user *)ubuf;
21002 + for (ret = 0; ret < (ssize_t)(ucount - 3); ret += 4) {
21003 + if (!abdac_dma_space(dac))
21006 + if (unlikely(__get_user(sample, up++))) {
21011 + /* Swap bytes in each halfword */
21012 + dac->dma.buf[abdac_get_head(dac)] = swahb32(sample);
21016 + const u16 __user *up = (const u16 __user *)ubuf;
21019 + for (ret = 0; ret < (ssize_t)(ucount - 1); ret += 2) {
21020 + if (!abdac_dma_space(dac))
21023 + if (unlikely(__get_user(sample, up++))) {
21028 + sample = swab16(sample);
21029 + dac->dma.buf[abdac_get_head(dac)]
21030 + = (sample << 16) | sample;
21038 +static ssize_t abdac_dma_translate_from_user(struct at32_dac *dac,
21039 + const char __user *buffer,
21042 + /* At least one buffer must be available at this point */
21043 + dev_dbg(&dac->pdev->dev, "copying %zu bytes from user...\n", count);
21045 + return dac->trans(dac, buffer, count);
21048 +static int abdac_set_format(struct at32_dac *dac, int format)
21050 + unsigned int order;
21052 + switch (format) {
21053 + case AFMT_S16_BE:
21055 + dac->trans = trans_s16be;
21057 + case AFMT_S16_LE:
21059 + dac->trans = trans_s16le;
21062 + dev_dbg(&dac->pdev->dev, "unsupported format: %d\n", format);
21066 + if (dac->dsp_settings.channels == 2)
21069 + dac->dsp_settings.input_order = order;
21070 + dac->dsp_settings.format = format;
21074 +static int abdac_set_sample_rate(struct at32_dac *dac, unsigned long rate)
21076 + unsigned long new_rate;
21079 + ret = clk_set_rate(dac->sample_clk, 256 * rate);
21083 + /* TODO: mplayer seems to have a problem with this */
21085 + new_rate = clk_get_rate(dac->sample_clk);
21086 + dac->dsp_settings.sample_rate = new_rate / 256;
21088 + dac->dsp_settings.sample_rate = rate;
21094 +static ssize_t abdac_dsp_write(struct file *file,
21095 + const char __user *buffer,
21096 + size_t count, loff_t *ppos)
21098 + struct at32_dac *dac = file->private_data;
21099 + DECLARE_WAITQUEUE(wait, current);
21100 + unsigned int avail;
21104 + /* Avoid address space checking in the translation functions */
21105 + if (!access_ok(buffer, count, VERIFY_READ))
21110 + if (!dac->dma.buf) {
21111 + ret = abdac_dma_prepare(dac);
21116 + add_wait_queue(&dac->write_wait, &wait);
21118 + while (count > 0) {
21120 + abdac_update_dma_tail(dac);
21121 + avail = abdac_dma_space(dac);
21122 + set_current_state(TASK_INTERRUPTIBLE);
21123 + if (avail >= DMA_WRITE_THRESHOLD)
21126 + if (file->f_flags & O_NONBLOCK) {
21132 + pr_debug("Going to wait (avail = %u, count = %zu)\n",
21137 + if (signal_pending(current)) {
21139 + ret = -ERESTARTSYS;
21145 + copied = abdac_dma_translate_from_user(dac, buffer, count);
21146 + if (copied < 0) {
21152 + abdac_start(dac);
21161 + remove_wait_queue(&dac->write_wait, &wait);
21162 + set_current_state(TASK_RUNNING);
21166 +static int abdac_dsp_ioctl(struct inode *inode, struct file *file,
21167 + unsigned int cmd, unsigned long arg)
21169 + struct at32_dac *dac = file->private_data;
21170 + int __user *up = (int __user *)arg;
21171 + struct audio_buf_info abinfo;
21175 + case OSS_GETVERSION:
21176 + return put_user(SOUND_VERSION, up);
21178 + case SNDCTL_DSP_SPEED:
21179 + if (get_user(val, up))
21183 + ret = abdac_set_sample_rate(dac, val);
21187 + return put_user(dac->dsp_settings.sample_rate, up);
21189 + case SNDCTL_DSP_STEREO:
21190 + if (get_user(val, up))
21193 + if (val && dac->dsp_settings.channels == 1)
21194 + dac->dsp_settings.input_order++;
21195 + else if (!val && dac->dsp_settings.channels != 1)
21196 + dac->dsp_settings.input_order--;
21197 + dac->dsp_settings.channels = val ? 2 : 1;
21200 + case SNDCTL_DSP_CHANNELS:
21201 + if (get_user(val, up))
21205 + if (val < 0 || val > 2)
21209 + dac->dsp_settings.input_order
21210 + += val - dac->dsp_settings.channels;
21211 + dac->dsp_settings.channels = val;
21213 + return put_user(val, (int *)arg);
21215 + case SNDCTL_DSP_GETFMTS:
21216 + return put_user(AFMT_S16_BE | AFMT_S16_BE, up);
21218 + case SNDCTL_DSP_SETFMT:
21219 + if (get_user(val, up))
21222 + if (val == AFMT_QUERY) {
21223 + val = dac->dsp_settings.format;
21225 + ret = abdac_set_format(dac, val);
21229 + return put_user(val, up);
21231 + case SNDCTL_DSP_GETOSPACE:
21232 + abdac_update_dma_tail(dac);
21233 + abinfo.fragsize = ((1 << dac->dsp_settings.input_order)
21234 + * (DMA_PERIOD_SIZE / 4));
21235 + abinfo.bytes = (abdac_dma_space(dac)
21236 + << dac->dsp_settings.input_order);
21237 + abinfo.fragstotal = ((DMA_BUFFER_SIZE * 4)
21238 + >> (DMA_PERIOD_SHIFT
21239 + + dac->dsp_settings.input_order));
21240 + abinfo.fragments = ((abinfo.bytes
21241 + >> dac->dsp_settings.input_order)
21242 + / (DMA_PERIOD_SIZE / 4));
21243 + pr_debug("fragments=%d fragstotal=%d fragsize=%d bytes=%d\n",
21244 + abinfo.fragments, abinfo.fragstotal, abinfo.fragsize,
21246 + return copy_to_user(up, &abinfo, sizeof(abinfo)) ? -EFAULT : 0;
21249 + dev_dbg(&dac->pdev->dev, "Unimplemented ioctl cmd: 0x%x\n", cmd);
21254 +static int abdac_dsp_open(struct inode *inode, struct file *file)
21256 + struct at32_dac *dac = the_dac;
21259 + if (file->f_mode & FMODE_READ)
21267 + dac->dma.head = dac->dma.tail = 0;
21269 + /* FIXME: What are the correct defaults? */
21270 + dac->dsp_settings.channels = 2;
21271 + abdac_set_format(dac, AFMT_S16_BE);
21272 + ret = abdac_set_sample_rate(dac, 8000);
21276 + file->private_data = dac;
21286 +static int abdac_dsp_release(struct inode *inode, struct file *file)
21288 + struct at32_dac *dac = file->private_data;
21293 + abdac_dma_cleanup(dac);
21301 +static struct file_operations abdac_dsp_fops = {
21302 + .owner = THIS_MODULE,
21303 + .llseek = no_llseek,
21304 + .write = abdac_dsp_write,
21305 + .ioctl = abdac_dsp_ioctl,
21306 + .open = abdac_dsp_open,
21307 + .release = abdac_dsp_release,
21310 +static int __init abdac_probe(struct platform_device *pdev)
21312 + struct at32_dac *dac;
21313 + struct resource *regs;
21315 + struct clk *sample_clk;
21322 + regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
21325 + irq = platform_get_irq(pdev, 0);
21329 + mck = clk_get(&pdev->dev, "pclk");
21331 + return PTR_ERR(mck);
21332 + sample_clk = clk_get(&pdev->dev, "sample_clk");
21333 + if (IS_ERR(sample_clk)) {
21334 + ret = PTR_ERR(sample_clk);
21335 + goto out_put_mck;
21340 + dac = kzalloc(sizeof(struct at32_dac), GFP_KERNEL);
21342 + goto out_disable_clk;
21344 + spin_lock_init(&dac->lock);
21345 + init_MUTEX(&dac->sem);
21346 + init_waitqueue_head(&dac->write_wait);
21347 + dac->pdev = pdev;
21349 + dac->sample_clk = sample_clk;
21351 + dac->regs = ioremap(regs->start, regs->end - regs->start + 1);
21353 + goto out_free_dac;
21355 + ret = request_irq(irq, abdac_interrupt, 0, "dac", dac);
21357 + goto out_unmap_regs;
21360 + dac->req.req.dmac = find_dma_controller(0);
21361 + if (!dac->req.req.dmac)
21362 + goto out_free_irq;
21364 + ret = dma_alloc_channel(dac->req.req.dmac);
21366 + goto out_free_irq;
21368 + dac->req.req.channel = ret;
21369 + dac->req.req.block_complete = abdac_dma_block_complete;
21370 + dac->req.req.error = abdac_dma_error;
21371 + dac->req.data_reg = regs->start + DAC_DATA;
21372 + dac->req.periph_id = 2; /* FIXME */
21373 + dac->req.direction = DMA_DIR_MEM_TO_PERIPH;
21374 + dac->req.width = DMA_WIDTH_32BIT;
21376 + /* Make sure the DAC is silent and disabled */
21377 + dac_writel(dac, DATA, 0);
21378 + dac_writel(dac, CTRL, 0);
21380 + ret = register_sound_dsp(&abdac_dsp_fops, -1);
21382 + goto out_free_dma;
21383 + dac->dev_dsp = ret;
21385 + /* TODO: Register mixer */
21388 + platform_set_drvdata(pdev, dac);
21393 + dma_release_channel(dac->req.req.dmac, dac->req.req.channel);
21395 + free_irq(irq, dac);
21397 + iounmap(dac->regs);
21401 + clk_disable(mck);
21402 + clk_put(sample_clk);
21408 +static int __exit abdac_remove(struct platform_device *pdev)
21410 + struct at32_dac *dac;
21412 + dac = platform_get_drvdata(pdev);
21414 + unregister_sound_dsp(dac->dev_dsp);
21415 + dma_release_channel(dac->req.req.dmac, dac->req.req.channel);
21416 + free_irq(platform_get_irq(pdev, 0), dac);
21417 + iounmap(dac->regs);
21418 + clk_disable(dac->mck);
21419 + clk_put(dac->sample_clk);
21420 + clk_put(dac->mck);
21422 + platform_set_drvdata(pdev, NULL);
21429 +static struct platform_driver abdac_driver = {
21430 + .remove = __exit_p(abdac_remove),
21436 +static int __init abdac_init(void)
21438 + return platform_driver_probe(&abdac_driver, abdac_probe);
21440 +module_init(abdac_init);
21442 +static void __exit abdac_exit(void)
21444 + platform_driver_unregister(&abdac_driver);
21446 +module_exit(abdac_exit);
21448 +MODULE_AUTHOR("Haavard Skinnemoen <hskinnemoen@atmel.com>");
21449 +MODULE_DESCRIPTION("Sound Driver for the Atmel AT32 ABDAC");
21450 +MODULE_LICENSE("GPL");
21452 +++ b/sound/oss/at32_abdac.h
21455 + * Register definitions for the Atmel AT32 on-chip DAC.
21457 + * Copyright (C) 2006 Atmel Corporation
21459 + * This program is free software; you can redistribute it and/or modify
21460 + * it under the terms of the GNU General Public License version 2 as
21461 + * published by the Free Software Foundation.
21463 +#ifndef __SOUND_OSS_AT32_ABDAC_H__
21464 +#define __SOUND_OSS_AT32_ABDAC_H__
21466 +/* DAC register offsets */
21467 +#define DAC_DATA 0x0000
21468 +#define DAC_CTRL 0x0008
21469 +#define DAC_INT_MASK 0x000c
21470 +#define DAC_INT_EN 0x0010
21471 +#define DAC_INT_DIS 0x0014
21472 +#define DAC_INT_CLR 0x0018
21473 +#define DAC_INT_STATUS 0x001c
21474 +#define DAC_PDC_DATA 0x0020
21476 +/* Bitfields in CTRL */
21477 +#define DAC_SWAP_OFFSET 30
21478 +#define DAC_SWAP_SIZE 1
21479 +#define DAC_EN_OFFSET 31
21480 +#define DAC_EN_SIZE 1
21482 +/* Bitfields in INT_MASK/INT_EN/INT_DIS/INT_STATUS/INT_CLR */
21483 +#define DAC_UNDERRUN_OFFSET 28
21484 +#define DAC_UNDERRUN_SIZE 1
21485 +#define DAC_TX_READY_OFFSET 29
21486 +#define DAC_TX_READY_SIZE 1
21487 +#define DAC_TX_BUFFER_EMPTY_OFFSET 30
21488 +#define DAC_TX_BUFFER_EMPTY_SIZE 1
21489 +#define DAC_CHANNEL_TX_END_OFFSET 31
21490 +#define DAC_CHANNEL_TX_END_SIZE 1
21492 +/* Bit manipulation macros */
21493 +#define DAC_BIT(name) \
21494 + (1 << DAC_##name##_OFFSET)
21495 +#define DAC_BF(name, value) \
21496 + (((value) & ((1 << DAC_##name##_SIZE) - 1)) \
21497 + << DAC_##name##_OFFSET)
21498 +#define DAC_BFEXT(name, value) \
21499 + (((value) >> DAC_##name##_OFFSET) \
21500 + & ((1 << DAC_##name##_SIZE) - 1))
21501 +#define DAC_BFINS(name, value, old) \
21502 + (((old) & ~(((1 << DAC_##name##_SIZE) - 1) \
21503 + << DAC_##name##_OFFSET)) \
21504 + | DAC_BF(name,value))
21506 +/* Register access macros */
21507 +#define dac_readl(port, reg) \
21508 + __raw_readl((port)->regs + DAC_##reg)
21509 +#define dac_writel(port, reg, value) \
21510 + __raw_writel((value), (port)->regs + DAC_##reg)
21512 +#endif /* __SOUND_OSS_AT32_ABDAC_H__ */
21513 --- a/sound/oss/Kconfig
21514 +++ b/sound/oss/Kconfig
21515 @@ -654,3 +654,7 @@
21518 depends on SOUND_SH_DAC_AUDIO
21520 +config SOUND_AT32_ABDAC
21521 + tristate "Atmel AT32 Audio Bitstream DAC (ABDAC) support"
21522 + depends on SOUND_PRIME && AVR32
21523 --- a/sound/oss/Makefile
21524 +++ b/sound/oss/Makefile
21527 # Please leave it as is, cause the link order is significant !
21529 +obj-$(CONFIG_SOUND_AT32_ABDAC) += at32_abdac.o
21530 obj-$(CONFIG_SOUND_SH_DAC_AUDIO) += sh_dac_audio.o
21531 obj-$(CONFIG_SOUND_HAL2) += hal2.o
21532 obj-$(CONFIG_SOUND_AEDSP16) += aedsp16.o
21533 --- a/sound/spi/at73c213.c
21534 +++ b/sound/spi/at73c213.c
21535 @@ -744,7 +744,7 @@
21539 -static int snd_at73c213_ssc_init(struct snd_at73c213 *chip)
21540 +static int __devinit snd_at73c213_ssc_init(struct snd_at73c213 *chip)
21543 * Continuous clock output.
21544 @@ -774,7 +774,7 @@
21548 -static int snd_at73c213_chip_init(struct snd_at73c213 *chip)
21549 +static int __devinit snd_at73c213_chip_init(struct snd_at73c213 *chip)
21552 unsigned char dac_ctrl = 0;
21553 @@ -939,7 +939,7 @@
21557 -static int snd_at73c213_probe(struct spi_device *spi)
21558 +static int __devinit snd_at73c213_probe(struct spi_device *spi)
21560 struct snd_card *card;
21561 struct snd_at73c213 *chip;