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
19 #include <asm/arch/init.h>
20 #include <asm/arch/portmux.h>
22 +/* Oscillator frequencies. These are board-specific */
23 +unsigned long at32_board_osc_rates[3] = {
24 + [0] = 32768, /* 32.768 kHz on RTC osc */
25 + [1] = 20000000, /* 20 MHz on osc0 */
26 + [2] = 12000000, /* 12 MHz on osc1 */
29 /* Initialized by bootloader-specific startup code. */
30 struct tag *bootloader_tags __initdata;
33 static struct spi_board_info spi0_board_info[] __initdata = {
35 .modalias = "mtd_dataflash",
36 - .max_speed_hz = 10000000,
37 + .max_speed_hz = 8000000,
42 +static struct mci_platform_data __initdata mci0_data = {
43 + .detect_pin = GPIO_PIN_PC(25),
44 + .wp_pin = GPIO_PIN_PE(0),
48 * The next two functions should go away as the boot loader is
49 * supposed to initialize the macb address registers with a valid
54 +#ifdef CONFIG_BOARD_ATNGW100_I2C_GPIO
55 static struct i2c_gpio_platform_data i2c_gpio_data = {
56 .sda_pin = GPIO_PIN_PA(6),
57 .scl_pin = GPIO_PIN_PA(7),
59 .platform_data = &i2c_gpio_data,
64 static int __init atngw100_init(void)
67 set_hw_addr(at32_add_device_eth(1, ð_data[1]));
69 at32_add_device_spi(0, spi0_board_info, ARRAY_SIZE(spi0_board_info));
70 + at32_add_device_mci(0, &mci0_data);
71 at32_add_device_usba(0, NULL);
73 for (i = 0; i < ARRAY_SIZE(ngw_leds); i++) {
76 platform_device_register(&ngw_gpio_leds);
78 +#ifdef CONFIG_BOARD_ATNGW100_I2C_GPIO
79 at32_select_gpio(i2c_gpio_data.sda_pin,
80 AT32_GPIOF_MULTIDRV | AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
81 at32_select_gpio(i2c_gpio_data.scl_pin,
82 AT32_GPIOF_MULTIDRV | AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
83 platform_device_register(&i2c_gpio_device);
85 + at32_add_device_twi(0, NULL, 0);
90 --- a/arch/avr32/boards/atstk1000/atstk1002.c
91 +++ b/arch/avr32/boards/atstk1000/atstk1002.c
94 - * ATSTK1002 daughterboard-specific init code
95 + * ATSTK1002/ATSTK1006 daughterboard-specific init code
97 - * Copyright (C) 2005-2006 Atmel Corporation
98 + * Copyright (C) 2005-2007 Atmel Corporation
100 * This program is free software; you can redistribute it and/or modify
101 * it under the terms of the GNU General Public License version 2 as
104 #include "atstk1000.h"
106 +/* Oscillator frequencies. These are board specific */
107 +unsigned long at32_board_osc_rates[3] = {
108 + [0] = 32768, /* 32.768 kHz on RTC osc */
109 + [1] = 20000000, /* 20 MHz on osc0 */
110 + [2] = 12000000, /* 12 MHz on osc1 */
114 + * The ATSTK1006 daughterboard is very similar to the ATSTK1002. Both
115 + * have the AT32AP7000 chip on board; the difference is that the
116 + * STK1006 has 128 MB SDRAM (the STK1002 uses the 8 MB SDRAM chip on
117 + * the STK1000 motherboard) and 256 MB NAND flash (the STK1002 has
120 + * The RAM difference is handled by the boot loader, so the only
121 + * difference we end up handling here is the NAND flash.
123 +#ifdef CONFIG_BOARD_ATSTK1006
124 +#include <linux/mtd/partitions.h>
125 +#include <asm/arch/smc.h>
127 +static struct smc_timing nand_timing __initdata = {
128 + .ncs_read_setup = 0,
130 + .ncs_write_setup = 0,
133 + .ncs_read_pulse = 30,
135 + .ncs_write_pulse = 30,
141 + .ncs_read_recover = 0,
143 + .ncs_write_recover = 0,
144 + /* WE# high -> RE# low min 60 ns */
148 +static struct smc_config nand_config __initdata = {
150 + .nrd_controlled = 1,
151 + .nwe_controlled = 1,
158 +static struct mtd_partition nand_partitions[] = {
161 + .offset = 0x00000000,
162 + .size = MTDPART_SIZ_FULL,
166 +static struct mtd_partition *nand_part_info(int size, int *num_partitions)
168 + *num_partitions = ARRAY_SIZE(nand_partitions);
169 + return nand_partitions;
172 +static struct atmel_nand_data atstk1006_nand_data __initdata = {
175 + .rdy_pin = GPIO_PIN_PB(30),
176 + .enable_pin = GPIO_PIN_PB(29),
177 + .partition_info = nand_part_info,
187 +static struct cf_platform_data __initdata cf0_data = {
188 +#ifdef CONFIG_BOARD_ATSTK1000_CF_HACKS
189 + .detect_pin = CONFIG_BOARD_ATSTK1000_CF_DETECT_PIN,
190 + .reset_pin = CONFIG_BOARD_ATSTK1000_CF_RESET_PIN,
192 + .detect_pin = GPIO_PIN_NONE,
193 + .reset_pin = GPIO_PIN_NONE,
195 + .vcc_pin = GPIO_PIN_NONE,
196 + .ready_pin = GPIO_PIN_PB(27),
201 * The next two functions should go away as the boot loader is
202 * supposed to initialize the macb address registers with a valid
205 at32_add_system_devices();
207 +#ifdef CONFIG_BOARD_ATSTK1006
208 + smc_set_timing(&nand_config, &nand_timing);
209 + smc_set_configuration(3, &nand_config);
210 + at32_add_device_nand(0, &atstk1006_nand_data);
213 #ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
214 at32_add_device_usart(1);
216 @@ -228,16 +321,30 @@
217 #ifdef CONFIG_BOARD_ATSTK100X_SPI1
218 at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info));
220 + at32_add_device_twi(0, NULL, 0);
221 +#ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
222 + at32_add_device_mci(0, NULL);
224 #ifdef CONFIG_BOARD_ATSTK1002_SW5_CUSTOM
225 set_hw_addr(at32_add_device_eth(1, ð_data[1]));
227 at32_add_device_lcdc(0, &atstk1000_lcdc_data,
228 - fbmem_start, fbmem_size);
229 + fbmem_start, fbmem_size, 0);
231 at32_add_device_usba(0, NULL);
232 +#ifdef CONFIG_BOARD_ATSTK100X_ENABLE_AC97
233 + at32_add_device_ac97c(0);
235 + at32_add_device_abdac(0);
237 #ifndef CONFIG_BOARD_ATSTK100X_SW3_CUSTOM
238 at32_add_device_ssc(0, ATMEL_SSC_TX);
240 + at32_add_device_cf(0, 2, &cf0_data);
241 +#ifdef CONFIG_BOARD_ATSTK100X_ENABLE_PSIF
242 + at32_add_device_psif(0);
243 + at32_add_device_psif(1);
246 atstk1000_setup_j2_leds();
247 atstk1002_setup_extdac();
248 --- a/arch/avr32/boards/atstk1000/atstk1003.c
249 +++ b/arch/avr32/boards/atstk1000/atstk1003.c
252 #include "atstk1000.h"
254 +/* Oscillator frequencies. These are board specific */
255 +unsigned long at32_board_osc_rates[3] = {
256 + [0] = 32768, /* 32.768 kHz on RTC osc */
257 + [1] = 20000000, /* 20 MHz on osc0 */
258 + [2] = 12000000, /* 12 MHz on osc1 */
261 #ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
262 static struct at73c213_board_info at73c213_data = {
268 +static struct cf_platform_data __initdata cf0_data = {
269 +#ifdef CONFIG_BOARD_ATSTK1000_CF_HACKS
270 + .detect_pin = CONFIG_BOARD_ATSTK1000_CF_DETECT_PIN,
271 + .reset_pin = CONFIG_BOARD_ATSTK1000_CF_RESET_PIN,
273 + .detect_pin = GPIO_PIN_NONE,
274 + .reset_pin = GPIO_PIN_NONE,
276 + .vcc_pin = GPIO_PIN_NONE,
277 + .ready_pin = GPIO_PIN_PB(27),
281 #ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
282 static void __init atstk1003_setup_extdac(void)
284 @@ -147,12 +167,22 @@
285 at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info));
287 #ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
288 - at32_add_device_mci(0);
289 + at32_add_device_mci(0, NULL);
291 at32_add_device_usba(0, NULL);
292 +#ifdef CONFIG_BOARD_ATSTK100X_ENABLE_AC97
293 + at32_add_device_ac97c(0);
295 + at32_add_device_abdac(0);
297 #ifndef CONFIG_BOARD_ATSTK100X_SW3_CUSTOM
298 at32_add_device_ssc(0, ATMEL_SSC_TX);
300 + at32_add_device_cf(0, 2, &cf0_data);
301 +#ifdef CONFIG_BOARD_ATSTK100X_ENABLE_PSIF
302 + at32_add_device_psif(0);
303 + at32_add_device_psif(1);
306 atstk1000_setup_j2_leds();
307 atstk1003_setup_extdac();
308 --- a/arch/avr32/boards/atstk1000/atstk1004.c
309 +++ b/arch/avr32/boards/atstk1000/atstk1004.c
312 #include "atstk1000.h"
314 +/* Oscillator frequencies. These are board specific */
315 +unsigned long at32_board_osc_rates[3] = {
316 + [0] = 32768, /* 32.768 kHz on RTC osc */
317 + [1] = 20000000, /* 20 MHz on osc0 */
318 + [2] = 12000000, /* 12 MHz on osc1 */
321 #ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
322 static struct at73c213_board_info at73c213_data = {
324 @@ -130,14 +137,23 @@
325 at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info));
327 #ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
328 - at32_add_device_mci(0);
329 + at32_add_device_mci(0, NULL);
331 at32_add_device_lcdc(0, &atstk1000_lcdc_data,
332 - fbmem_start, fbmem_size);
333 + fbmem_start, fbmem_size, 0);
334 at32_add_device_usba(0, NULL);
335 +#ifdef CONFIG_BOARD_ATSTK100X_ENABLE_AC97
336 + at32_add_device_ac97c(0);
338 + at32_add_device_abdac(0);
340 #ifndef CONFIG_BOARD_ATSTK100X_SW3_CUSTOM
341 at32_add_device_ssc(0, ATMEL_SSC_TX);
343 +#ifdef CONFIG_BOARD_ATSTK100X_ENABLE_PSIF
344 + at32_add_device_psif(0);
345 + at32_add_device_psif(1);
348 atstk1000_setup_j2_leds();
349 atstk1004_setup_extdac();
350 --- a/arch/avr32/boards/atstk1000/Kconfig
351 +++ b/arch/avr32/boards/atstk1000/Kconfig
354 select CPU_AT32AP7002
356 +config BOARD_ATSTK1006
358 + select CPU_AT32AP7000
364 depends on !BOARD_ATSTK100X_SW1_CUSTOM && !BOARD_ATSTK100X_SW3_CUSTOM
367 +config BOARD_ATSTK100X_ENABLE_AC97
368 + bool "Use AC97C instead of ABDAC"
370 + Select this if you want to use the built-in AC97 controller
371 + instead of the built-in Audio Bitstream DAC. These share
372 + the same I/O pins on the AP7000, so both can't be enabled
375 + Note that the STK1000 kit doesn't ship with an AC97 codec on
376 + board, so say N unless you've got an expansion board with an
377 + AC97 codec on it that you want to use.
379 +config BOARD_ATSTK1000_CF_HACKS
380 + bool "ATSTK1000 CompactFlash hacks"
381 + depends on !BOARD_ATSTK100X_SW4_CUSTOM
383 + Select this if you have re-routed the CompactFlash RESET and
384 + CD signals to GPIOs on your STK1000. This is necessary for
385 + reset and card detection to work properly, although some CF
386 + cards may be able to cope without reset.
388 +config BOARD_ATSTK1000_CF_RESET_PIN
389 + hex "CompactFlash RESET pin"
391 + depends on BOARD_ATSTK1000_CF_HACKS
393 + Select which GPIO pin to use for the CompactFlash RESET
394 + signal. This is specified as a hexadecimal number and should
395 + be defined as 0x20 * gpio_port + pin.
397 + The default is 0x30, which is pin 16 on PIOB, aka GPIO14.
399 +config BOARD_ATSTK1000_CF_DETECT_PIN
400 + hex "CompactFlash DETECT pin"
402 + depends on BOARD_ATSTK1000_CF_HACKS
404 + Select which GPIO pin to use for the CompactFlash CD
405 + signal. This is specified as a hexadecimal number and should
406 + be defined as 0x20 * gpio_port + pin.
408 + The default is 0x3e, which is pin 30 on PIOB, aka GPIO15.
410 +config BOARD_ATSTK100X_ENABLE_PSIF
411 + bool "Enable PSIF peripheral (PS/2 support)"
414 + Select this if you want to use the PSIF peripheral to hook up PS/2
415 + devices to your STK1000. This will require a hardware modification to
416 + work correctly, since PS/2 devices require 5 volt power and signals,
417 + while the STK1000 only provides 3.3 volt.
419 + Say N if you have not modified the hardware to boost the voltage, say
420 + Y if you have level convertion hardware or a PS/2 device capable of
421 + operating on 3.3 volt.
424 --- a/arch/avr32/boards/atstk1000/Makefile
425 +++ b/arch/avr32/boards/atstk1000/Makefile
427 obj-$(CONFIG_BOARD_ATSTK1002) += atstk1002.o
428 obj-$(CONFIG_BOARD_ATSTK1003) += atstk1003.o
429 obj-$(CONFIG_BOARD_ATSTK1004) += atstk1004.o
430 +obj-$(CONFIG_BOARD_ATSTK1006) += atstk1002.o
431 --- a/arch/avr32/configs/atngw100_defconfig
432 +++ b/arch/avr32/configs/atngw100_defconfig
435 # Automatically generated make config: don't edit
436 -# Linux kernel version: 2.6.24-rc7
437 -# Wed Jan 9 23:20:41 2008
438 +# Linux kernel version: 2.6.25.4
439 +# Wed Jun 11 15:23:36 2008
442 CONFIG_GENERIC_GPIO=y
444 CONFIG_GENERIC_IRQ_PROBE=y
445 CONFIG_RWSEM_GENERIC_SPINLOCK=y
446 CONFIG_GENERIC_TIME=y
447 +CONFIG_GENERIC_CLOCKEVENTS=y
448 # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
449 # CONFIG_ARCH_HAS_ILOG2_U32 is not set
450 # CONFIG_ARCH_HAS_ILOG2_U64 is not set
451 -CONFIG_ARCH_SUPPORTS_OPROFILE=y
452 CONFIG_GENERIC_HWEIGHT=y
453 CONFIG_GENERIC_CALIBRATE_DELAY=y
456 CONFIG_BSD_PROCESS_ACCT=y
457 CONFIG_BSD_PROCESS_ACCT_V3=y
458 # CONFIG_TASKSTATS is not set
459 -# CONFIG_USER_NS is not set
460 -# CONFIG_PID_NS is not set
461 # CONFIG_AUDIT is not set
462 # CONFIG_IKCONFIG is not set
463 CONFIG_LOG_BUF_SHIFT=14
464 # CONFIG_CGROUPS is not set
465 -CONFIG_FAIR_GROUP_SCHED=y
466 -CONFIG_FAIR_USER_SCHED=y
467 -# CONFIG_FAIR_CGROUP_SCHED is not set
468 +# CONFIG_GROUP_SCHED is not set
469 CONFIG_SYSFS_DEPRECATED=y
470 +CONFIG_SYSFS_DEPRECATED_V2=y
471 # CONFIG_RELAY is not set
472 +# CONFIG_NAMESPACES is not set
473 CONFIG_BLK_DEV_INITRD=y
474 CONFIG_INITRAMFS_SOURCE=""
475 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
480 +# CONFIG_COMPAT_BRK is not set
481 # CONFIG_BASE_FULL is not set
489 CONFIG_VM_EVENT_COUNTERS=y
491 # CONFIG_SLAB is not set
493 # CONFIG_SLOB is not set
495 +# CONFIG_MARKERS is not set
497 +CONFIG_HAVE_OPROFILE=y
499 +CONFIG_HAVE_KPROBES=y
500 +# CONFIG_HAVE_KRETPROBES is not set
501 +CONFIG_PROC_PAGE_MONITOR=y
504 # CONFIG_TINY_SHMEM is not set
505 @@ -101,10 +109,15 @@
507 # CONFIG_DEFAULT_NOOP is not set
508 CONFIG_DEFAULT_IOSCHED="cfq"
509 +CONFIG_CLASSIC_RCU=y
512 # System Type and features
514 +CONFIG_TICK_ONESHOT=y
516 +CONFIG_HIGH_RES_TIMERS=y
517 +CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
518 CONFIG_SUBARCH_AVR32B=y
520 CONFIG_PERFORMANCE_COUNTERS=y
522 CONFIG_CPU_AT32AP7000=y
523 # CONFIG_BOARD_ATSTK1000 is not set
524 CONFIG_BOARD_ATNGW100=y
525 +CONFIG_BOARD_ATNGW100_I2C_GPIO=y
526 CONFIG_LOADER_U_BOOT=y
530 # CONFIG_AP700X_32_BIT_SMC is not set
531 CONFIG_AP700X_16_BIT_SMC=y
532 # CONFIG_AP700X_8_BIT_SMC is not set
534 CONFIG_LOAD_ADDRESS=0x10000000
535 CONFIG_ENTRY_ADDRESS=0x90000000
536 CONFIG_PHYS_OFFSET=0x10000000
537 @@ -146,16 +161,26 @@
538 CONFIG_ZONE_DMA_FLAG=0
540 # CONFIG_OWNERSHIP_TRACE is not set
541 +CONFIG_NMI_DEBUGGING=y
543 # CONFIG_HZ_100 is not set
545 # CONFIG_HZ_300 is not set
546 # CONFIG_HZ_1000 is not set
548 +# CONFIG_SCHED_HRTICK is not set
552 # Power management options
554 +CONFIG_ARCH_SUSPEND_POSSIBLE=y
556 +# CONFIG_PM_LEGACY is not set
557 +# CONFIG_PM_DEBUG is not set
560 +CONFIG_SUSPEND_FREEZER=y
563 # CPU Frequency scaling
565 CONFIG_CPU_FREQ_TABLE=y
566 # CONFIG_CPU_FREQ_DEBUG is not set
567 # CONFIG_CPU_FREQ_STAT is not set
568 -CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
569 +# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
570 # CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
571 -# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
572 +CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
573 # CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
574 CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
575 # CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
578 # CONFIG_XFRM_SUB_POLICY is not set
579 # CONFIG_XFRM_MIGRATE is not set
580 +# CONFIG_XFRM_STATISTICS is not set
582 # CONFIG_NET_KEY_MIGRATE is not set
584 @@ -260,82 +286,33 @@
585 # CONFIG_NETWORK_SECMARK is not set
587 # CONFIG_NETFILTER_DEBUG is not set
588 -CONFIG_BRIDGE_NETFILTER=y
589 +# CONFIG_NETFILTER_ADVANCED is not set
592 # Core Netfilter Configuration
594 -# CONFIG_NETFILTER_NETLINK is not set
595 -CONFIG_NF_CONNTRACK_ENABLED=m
596 +CONFIG_NETFILTER_NETLINK=m
597 +CONFIG_NETFILTER_NETLINK_LOG=m
598 CONFIG_NF_CONNTRACK=m
600 -CONFIG_NF_CONNTRACK_MARK=y
601 -# CONFIG_NF_CONNTRACK_EVENTS is not set
602 -CONFIG_NF_CT_PROTO_GRE=m
603 -# CONFIG_NF_CT_PROTO_SCTP is not set
604 -# CONFIG_NF_CT_PROTO_UDPLITE is not set
605 -CONFIG_NF_CONNTRACK_AMANDA=m
606 CONFIG_NF_CONNTRACK_FTP=m
607 -CONFIG_NF_CONNTRACK_H323=m
608 CONFIG_NF_CONNTRACK_IRC=m
609 -CONFIG_NF_CONNTRACK_NETBIOS_NS=m
610 -CONFIG_NF_CONNTRACK_PPTP=m
611 -CONFIG_NF_CONNTRACK_SANE=m
612 CONFIG_NF_CONNTRACK_SIP=m
613 -CONFIG_NF_CONNTRACK_TFTP=m
614 +CONFIG_NF_CT_NETLINK=m
615 CONFIG_NETFILTER_XTABLES=y
616 -CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
617 -# CONFIG_NETFILTER_XT_TARGET_CONNMARK is not set
618 -# CONFIG_NETFILTER_XT_TARGET_DSCP is not set
619 CONFIG_NETFILTER_XT_TARGET_MARK=m
620 -CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m
621 CONFIG_NETFILTER_XT_TARGET_NFLOG=m
622 -# CONFIG_NETFILTER_XT_TARGET_NOTRACK is not set
623 -# CONFIG_NETFILTER_XT_TARGET_TRACE is not set
624 CONFIG_NETFILTER_XT_TARGET_TCPMSS=m
625 -CONFIG_NETFILTER_XT_MATCH_COMMENT=m
626 -CONFIG_NETFILTER_XT_MATCH_CONNBYTES=m
627 -# CONFIG_NETFILTER_XT_MATCH_CONNLIMIT is not set
628 -CONFIG_NETFILTER_XT_MATCH_CONNMARK=m
629 CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
630 -# CONFIG_NETFILTER_XT_MATCH_DCCP is not set
631 -# CONFIG_NETFILTER_XT_MATCH_DSCP is not set
632 -CONFIG_NETFILTER_XT_MATCH_ESP=m
633 -CONFIG_NETFILTER_XT_MATCH_HELPER=m
634 -CONFIG_NETFILTER_XT_MATCH_LENGTH=m
635 -CONFIG_NETFILTER_XT_MATCH_LIMIT=m
636 -CONFIG_NETFILTER_XT_MATCH_MAC=m
637 CONFIG_NETFILTER_XT_MATCH_MARK=m
638 CONFIG_NETFILTER_XT_MATCH_POLICY=m
639 -CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
640 -# CONFIG_NETFILTER_XT_MATCH_PHYSDEV is not set
641 -CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m
642 -CONFIG_NETFILTER_XT_MATCH_QUOTA=m
643 -CONFIG_NETFILTER_XT_MATCH_REALM=m
644 -# CONFIG_NETFILTER_XT_MATCH_SCTP is not set
645 CONFIG_NETFILTER_XT_MATCH_STATE=m
646 -CONFIG_NETFILTER_XT_MATCH_STATISTIC=m
647 -CONFIG_NETFILTER_XT_MATCH_STRING=m
648 -CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
649 -# CONFIG_NETFILTER_XT_MATCH_TIME is not set
650 -# CONFIG_NETFILTER_XT_MATCH_U32 is not set
651 -CONFIG_NETFILTER_XT_MATCH_HASHLIMIT=m
654 # IP: Netfilter Configuration
656 CONFIG_NF_CONNTRACK_IPV4=m
657 CONFIG_NF_CONNTRACK_PROC_COMPAT=y
658 -# CONFIG_IP_NF_QUEUE is not set
659 CONFIG_IP_NF_IPTABLES=m
660 -CONFIG_IP_NF_MATCH_IPRANGE=m
661 -CONFIG_IP_NF_MATCH_TOS=m
662 -CONFIG_IP_NF_MATCH_RECENT=m
663 -CONFIG_IP_NF_MATCH_ECN=m
664 -CONFIG_IP_NF_MATCH_AH=m
665 -CONFIG_IP_NF_MATCH_TTL=m
666 -CONFIG_IP_NF_MATCH_OWNER=m
667 -CONFIG_IP_NF_MATCH_ADDRTYPE=m
668 CONFIG_IP_NF_FILTER=m
669 CONFIG_IP_NF_TARGET_REJECT=m
670 CONFIG_IP_NF_TARGET_LOG=m
671 @@ -343,54 +320,25 @@
673 CONFIG_NF_NAT_NEEDED=y
674 CONFIG_IP_NF_TARGET_MASQUERADE=m
675 -CONFIG_IP_NF_TARGET_REDIRECT=m
676 -CONFIG_IP_NF_TARGET_NETMAP=m
677 -CONFIG_IP_NF_TARGET_SAME=m
678 -CONFIG_NF_NAT_SNMP_BASIC=m
679 -CONFIG_NF_NAT_PROTO_GRE=m
682 -CONFIG_NF_NAT_TFTP=m
683 -CONFIG_NF_NAT_AMANDA=m
684 -CONFIG_NF_NAT_PPTP=m
685 -CONFIG_NF_NAT_H323=m
686 +# CONFIG_NF_NAT_TFTP is not set
687 +# CONFIG_NF_NAT_AMANDA is not set
688 +# CONFIG_NF_NAT_PPTP is not set
689 +# CONFIG_NF_NAT_H323 is not set
691 CONFIG_IP_NF_MANGLE=m
692 -CONFIG_IP_NF_TARGET_TOS=m
693 -CONFIG_IP_NF_TARGET_ECN=m
694 -CONFIG_IP_NF_TARGET_TTL=m
695 -CONFIG_IP_NF_TARGET_CLUSTERIP=m
697 -CONFIG_IP_NF_ARPTABLES=m
698 -CONFIG_IP_NF_ARPFILTER=m
699 -CONFIG_IP_NF_ARP_MANGLE=m
702 -# IPv6: Netfilter Configuration (EXPERIMENTAL)
703 +# IPv6: Netfilter Configuration
705 CONFIG_NF_CONNTRACK_IPV6=m
706 -CONFIG_IP6_NF_QUEUE=m
707 CONFIG_IP6_NF_IPTABLES=m
708 -CONFIG_IP6_NF_MATCH_RT=m
709 -CONFIG_IP6_NF_MATCH_OPTS=m
710 -CONFIG_IP6_NF_MATCH_FRAG=m
711 -CONFIG_IP6_NF_MATCH_HL=m
712 -CONFIG_IP6_NF_MATCH_OWNER=m
713 CONFIG_IP6_NF_MATCH_IPV6HEADER=m
714 -CONFIG_IP6_NF_MATCH_AH=m
715 -CONFIG_IP6_NF_MATCH_MH=m
716 -CONFIG_IP6_NF_MATCH_EUI64=m
717 CONFIG_IP6_NF_FILTER=m
718 CONFIG_IP6_NF_TARGET_LOG=m
719 CONFIG_IP6_NF_TARGET_REJECT=m
720 CONFIG_IP6_NF_MANGLE=m
721 -CONFIG_IP6_NF_TARGET_HL=m
725 -# Bridge: Netfilter Configuration
727 -# CONFIG_BRIDGE_NF_EBTABLES is not set
728 # CONFIG_IP_DCCP is not set
729 # CONFIG_IP_SCTP is not set
730 # CONFIG_TIPC is not set
732 # CONFIG_ECONET is not set
733 # CONFIG_WAN_ROUTER is not set
734 # CONFIG_NET_SCHED is not set
735 -CONFIG_NET_CLS_ROUTE=y
740 # CONFIG_NET_PKTGEN is not set
741 # CONFIG_NET_TCPPROBE is not set
742 # CONFIG_HAMRADIO is not set
743 +# CONFIG_CAN is not set
744 # CONFIG_IRDA is not set
745 # CONFIG_BT is not set
746 # CONFIG_AF_RXRPC is not set
747 @@ -531,11 +479,18 @@
749 CONFIG_BLK_DEV_RAM_COUNT=16
750 CONFIG_BLK_DEV_RAM_SIZE=4096
751 -CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
752 +# CONFIG_BLK_DEV_XIP is not set
753 # CONFIG_CDROM_PKTCDVD is not set
754 # CONFIG_ATA_OVER_ETH is not set
755 -# CONFIG_MISC_DEVICES is not set
756 -# CONFIG_IDE is not set
757 +CONFIG_MISC_DEVICES=y
758 +# CONFIG_ATMEL_PWM is not set
759 +CONFIG_ATMEL_TCLIB=y
760 +CONFIG_ATMEL_TCB_CLKSRC=y
761 +CONFIG_ATMEL_TCB_CLKSRC_BLOCK=0
762 +# CONFIG_EEPROM_93CX6 is not set
763 +# CONFIG_ATMEL_SSC is not set
764 +# CONFIG_ENCLOSURE_SERVICES is not set
765 +# CONFIG_HAVE_IDE is not set
768 # SCSI device support
769 @@ -568,11 +523,13 @@
770 # CONFIG_SMSC_PHY is not set
771 # CONFIG_BROADCOM_PHY is not set
772 # CONFIG_ICPLUS_PHY is not set
773 +# CONFIG_REALTEK_PHY is not set
774 # CONFIG_FIXED_PHY is not set
775 # CONFIG_MDIO_BITBANG is not set
776 CONFIG_NET_ETHERNET=y
777 # CONFIG_MII is not set
779 +# CONFIG_ENC28J60 is not set
780 # CONFIG_IBM_NEW_EMAC_ZMII is not set
781 # CONFIG_IBM_NEW_EMAC_RGMII is not set
782 # CONFIG_IBM_NEW_EMAC_TAH is not set
784 # CONFIG_PPPOL2TP is not set
785 # CONFIG_SLIP is not set
787 -# CONFIG_SHAPER is not set
788 # CONFIG_NETCONSOLE is not set
789 # CONFIG_NETPOLL is not set
790 # CONFIG_NET_POLL_CONTROLLER is not set
793 CONFIG_SERIAL_ATMEL=y
794 CONFIG_SERIAL_ATMEL_CONSOLE=y
795 +CONFIG_SERIAL_ATMEL_PDC=y
796 # CONFIG_SERIAL_ATMEL_TTYAT is not set
798 CONFIG_SERIAL_CORE_CONSOLE=y
800 # CONFIG_LEGACY_PTYS is not set
801 # CONFIG_IPMI_HANDLER is not set
802 # CONFIG_HW_RANDOM is not set
803 -# CONFIG_RTC is not set
804 -# CONFIG_GEN_RTC is not set
805 # CONFIG_R3964 is not set
806 # CONFIG_RAW_DRIVER is not set
807 # CONFIG_TCG_TPM is not set
810 # I2C Hardware Bus support
812 +CONFIG_I2C_ATMELTWI=m
814 # CONFIG_I2C_OCORES is not set
815 # CONFIG_I2C_PARPORT_LIGHT is not set
816 @@ -669,13 +625,12 @@
818 # Miscellaneous I2C Chip support
820 -# CONFIG_SENSORS_DS1337 is not set
821 -# CONFIG_SENSORS_DS1374 is not set
822 # CONFIG_DS1682 is not set
823 # CONFIG_SENSORS_EEPROM is not set
824 # CONFIG_SENSORS_PCF8574 is not set
825 -# CONFIG_SENSORS_PCA9539 is not set
826 +# CONFIG_PCF8575 is not set
827 # CONFIG_SENSORS_PCF8591 is not set
828 +# CONFIG_TPS65010 is not set
829 # CONFIG_SENSORS_MAX6875 is not set
830 # CONFIG_SENSORS_TSL2550 is not set
831 # CONFIG_I2C_DEBUG_CORE is not set
833 # CONFIG_SPI_AT25 is not set
835 # CONFIG_SPI_TLE62X0 is not set
836 +CONFIG_HAVE_GPIO_LIB=y
841 +# CONFIG_DEBUG_GPIO is not set
844 +# I2C GPIO expanders:
846 +# CONFIG_GPIO_PCA953X is not set
847 +# CONFIG_GPIO_PCF857X is not set
850 +# SPI GPIO expanders:
852 +# CONFIG_GPIO_MCP23S08 is not set
853 # CONFIG_W1 is not set
854 # CONFIG_POWER_SUPPLY is not set
855 # CONFIG_HWMON is not set
856 +# CONFIG_THERMAL is not set
858 # CONFIG_WATCHDOG_NOWAYOUT is not set
862 # NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
866 -# USB Gadget Support
869 # CONFIG_USB_GADGET_DEBUG is not set
870 # CONFIG_USB_GADGET_DEBUG_FILES is not set
871 @@ -787,21 +756,24 @@
872 # CONFIG_USB_FILE_STORAGE_TEST is not set
873 CONFIG_USB_G_SERIAL=m
874 # CONFIG_USB_MIDI_GADGET is not set
876 +# CONFIG_USB_G_PRINTER is not set
878 # CONFIG_MMC_DEBUG is not set
879 # CONFIG_MMC_UNSAFE_RESUME is not set
882 # MMC/SD Card Drivers
886 CONFIG_MMC_BLOCK_BOUNCE=y
887 # CONFIG_SDIO_UART is not set
890 # MMC/SD Host Controller Drivers
892 +CONFIG_MMC_ATMELMCI=y
894 +# CONFIG_MEMSTICK is not set
898 @@ -844,19 +816,22 @@
899 # CONFIG_RTC_DRV_PCF8563 is not set
900 # CONFIG_RTC_DRV_PCF8583 is not set
901 # CONFIG_RTC_DRV_M41T80 is not set
902 +# CONFIG_RTC_DRV_S35390A is not set
907 -# CONFIG_RTC_DRV_RS5C348 is not set
908 # CONFIG_RTC_DRV_MAX6902 is not set
909 +# CONFIG_RTC_DRV_R9701 is not set
910 +# CONFIG_RTC_DRV_RS5C348 is not set
913 # Platform RTC drivers
915 +# CONFIG_RTC_DRV_DS1511 is not set
916 # CONFIG_RTC_DRV_DS1553 is not set
917 -# CONFIG_RTC_DRV_STK17TA8 is not set
918 # CONFIG_RTC_DRV_DS1742 is not set
919 +# CONFIG_RTC_DRV_STK17TA8 is not set
920 # CONFIG_RTC_DRV_M48T86 is not set
921 # CONFIG_RTC_DRV_M48T59 is not set
922 # CONFIG_RTC_DRV_V3020 is not set
923 @@ -874,25 +849,23 @@
929 # CONFIG_EXT2_FS_XATTR is not set
930 # CONFIG_EXT2_FS_XIP is not set
933 # CONFIG_EXT3_FS_XATTR is not set
934 # CONFIG_EXT4DEV_FS is not set
937 # CONFIG_REISERFS_FS is not set
938 # CONFIG_JFS_FS is not set
939 # CONFIG_FS_POSIX_ACL is not set
940 # CONFIG_XFS_FS is not set
941 # CONFIG_GFS2_FS is not set
942 # CONFIG_OCFS2_FS is not set
943 -# CONFIG_MINIX_FS is not set
944 -# CONFIG_ROMFS_FS is not set
945 +# CONFIG_DNOTIFY is not set
947 CONFIG_INOTIFY_USER=y
948 # CONFIG_QUOTA is not set
949 -# CONFIG_DNOTIFY is not set
950 # CONFIG_AUTOFS_FS is not set
951 # CONFIG_AUTOFS4_FS is not set
955 # CONFIG_TMPFS_POSIX_ACL is not set
956 # CONFIG_HUGETLB_PAGE is not set
957 -CONFIG_CONFIGFS_FS=m
958 +CONFIG_CONFIGFS_FS=y
961 # Miscellaneous filesystems
963 # CONFIG_JFFS2_RUBIN is not set
964 # CONFIG_CRAMFS is not set
965 # CONFIG_VXFS_FS is not set
966 +# CONFIG_MINIX_FS is not set
967 # CONFIG_HPFS_FS is not set
968 # CONFIG_QNX4FS_FS is not set
969 +# CONFIG_ROMFS_FS is not set
970 # CONFIG_SYSV_FS is not set
971 # CONFIG_UFS_FS is not set
972 CONFIG_NETWORK_FILESYSTEMS=y
973 @@ -1030,11 +1005,6 @@
974 # CONFIG_NLS_KOI8_U is not set
976 # CONFIG_DLM is not set
977 -CONFIG_INSTRUMENTATION=y
981 -# CONFIG_MARKERS is not set
985 @@ -1053,6 +1023,7 @@
986 # CONFIG_SCHEDSTATS is not set
987 # CONFIG_TIMER_STATS is not set
988 # CONFIG_SLUB_DEBUG_ON is not set
989 +# CONFIG_SLUB_STATS is not set
990 # CONFIG_DEBUG_RT_MUTEXES is not set
991 # CONFIG_RT_MUTEX_TESTER is not set
992 # CONFIG_DEBUG_SPINLOCK is not set
993 @@ -1069,9 +1040,10 @@
994 # CONFIG_DEBUG_LIST is not set
995 # CONFIG_DEBUG_SG is not set
996 CONFIG_FRAME_POINTER=y
997 -# CONFIG_FORCED_INLINING is not set
998 # CONFIG_BOOT_PRINTK_DELAY is not set
999 # CONFIG_RCU_TORTURE_TEST is not set
1000 +# CONFIG_KPROBES_SANITY_TEST is not set
1001 +# CONFIG_BACKTRACE_SELF_TEST is not set
1002 # CONFIG_LKDTM is not set
1003 # CONFIG_FAULT_INJECTION is not set
1004 # CONFIG_SAMPLES is not set
1005 @@ -1084,7 +1056,9 @@
1006 # CONFIG_SECURITY_FILE_CAPABILITIES is not set
1008 CONFIG_CRYPTO_ALGAPI=y
1009 +CONFIG_CRYPTO_AEAD=y
1010 CONFIG_CRYPTO_BLKCIPHER=y
1011 +# CONFIG_CRYPTO_SEQIV is not set
1012 CONFIG_CRYPTO_HASH=y
1013 CONFIG_CRYPTO_MANAGER=y
1014 CONFIG_CRYPTO_HMAC=y
1015 @@ -1103,6 +1077,9 @@
1016 CONFIG_CRYPTO_PCBC=m
1017 # CONFIG_CRYPTO_LRW is not set
1018 # CONFIG_CRYPTO_XTS is not set
1019 +# CONFIG_CRYPTO_CTR is not set
1020 +# CONFIG_CRYPTO_GCM is not set
1021 +# CONFIG_CRYPTO_CCM is not set
1022 # CONFIG_CRYPTO_CRYPTD is not set
1024 # CONFIG_CRYPTO_FCRYPT is not set
1025 @@ -1117,12 +1094,14 @@
1026 # CONFIG_CRYPTO_KHAZAD is not set
1027 # CONFIG_CRYPTO_ANUBIS is not set
1028 # CONFIG_CRYPTO_SEED is not set
1029 +# CONFIG_CRYPTO_SALSA20 is not set
1030 CONFIG_CRYPTO_DEFLATE=y
1031 # CONFIG_CRYPTO_MICHAEL_MIC is not set
1032 # CONFIG_CRYPTO_CRC32C is not set
1033 # CONFIG_CRYPTO_CAMELLIA is not set
1034 # CONFIG_CRYPTO_TEST is not set
1035 -# CONFIG_CRYPTO_AUTHENC is not set
1036 +CONFIG_CRYPTO_AUTHENC=y
1037 +# CONFIG_CRYPTO_LZO is not set
1041 @@ -1137,10 +1116,7 @@
1042 # CONFIG_LIBCRC32C is not set
1043 CONFIG_ZLIB_INFLATE=y
1044 CONFIG_ZLIB_DEFLATE=y
1045 -CONFIG_TEXTSEARCH=y
1046 -CONFIG_TEXTSEARCH_KMP=m
1047 -CONFIG_TEXTSEARCH_BM=m
1048 -CONFIG_TEXTSEARCH_FSM=m
1049 +CONFIG_GENERIC_ALLOCATOR=y
1053 --- a/arch/avr32/configs/atstk1002_defconfig
1054 +++ b/arch/avr32/configs/atstk1002_defconfig
1057 # Automatically generated make config: don't edit
1058 -# Linux kernel version: 2.6.24-rc7
1059 -# Wed Jan 9 23:07:43 2008
1060 +# Linux kernel version: 2.6.25.4
1061 +# Wed Jun 11 15:29:18 2008
1064 CONFIG_GENERIC_GPIO=y
1066 CONFIG_GENERIC_IRQ_PROBE=y
1067 CONFIG_RWSEM_GENERIC_SPINLOCK=y
1068 CONFIG_GENERIC_TIME=y
1069 +CONFIG_GENERIC_CLOCKEVENTS=y
1070 # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
1071 # CONFIG_ARCH_HAS_ILOG2_U32 is not set
1072 # CONFIG_ARCH_HAS_ILOG2_U64 is not set
1073 -CONFIG_ARCH_SUPPORTS_OPROFILE=y
1074 CONFIG_GENERIC_HWEIGHT=y
1075 CONFIG_GENERIC_CALIBRATE_DELAY=y
1076 CONFIG_GENERIC_BUG=y
1078 CONFIG_POSIX_MQUEUE=y
1079 # CONFIG_BSD_PROCESS_ACCT is not set
1080 # CONFIG_TASKSTATS is not set
1081 -# CONFIG_USER_NS is not set
1082 -# CONFIG_PID_NS is not set
1083 # CONFIG_AUDIT is not set
1084 # CONFIG_IKCONFIG is not set
1085 CONFIG_LOG_BUF_SHIFT=14
1086 # CONFIG_CGROUPS is not set
1087 -# CONFIG_FAIR_GROUP_SCHED is not set
1088 +# CONFIG_GROUP_SCHED is not set
1089 CONFIG_SYSFS_DEPRECATED=y
1090 +CONFIG_SYSFS_DEPRECATED_V2=y
1092 +# CONFIG_NAMESPACES is not set
1093 CONFIG_BLK_DEV_INITRD=y
1094 CONFIG_INITRAMFS_SOURCE=""
1095 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
1100 +# CONFIG_COMPAT_BRK is not set
1101 # CONFIG_BASE_FULL is not set
1103 CONFIG_ANON_INODES=y
1109 CONFIG_VM_EVENT_COUNTERS=y
1111 # CONFIG_SLAB is not set
1113 # CONFIG_SLOB is not set
1115 +# CONFIG_MARKERS is not set
1117 +CONFIG_HAVE_OPROFILE=y
1119 +CONFIG_HAVE_KPROBES=y
1120 +# CONFIG_HAVE_KRETPROBES is not set
1121 +CONFIG_PROC_PAGE_MONITOR=y
1124 # CONFIG_TINY_SHMEM is not set
1125 @@ -98,10 +108,15 @@
1126 CONFIG_DEFAULT_CFQ=y
1127 # CONFIG_DEFAULT_NOOP is not set
1128 CONFIG_DEFAULT_IOSCHED="cfq"
1129 +CONFIG_CLASSIC_RCU=y
1132 # System Type and features
1134 +CONFIG_TICK_ONESHOT=y
1136 +CONFIG_HIGH_RES_TIMERS=y
1137 +CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
1138 CONFIG_SUBARCH_AVR32B=y
1140 CONFIG_PERFORMANCE_COUNTERS=y
1141 @@ -113,12 +128,16 @@
1142 CONFIG_BOARD_ATSTK1002=y
1143 # CONFIG_BOARD_ATSTK1003 is not set
1144 # CONFIG_BOARD_ATSTK1004 is not set
1145 +# CONFIG_BOARD_ATSTK1006 is not set
1146 # CONFIG_BOARD_ATSTK100X_CUSTOM is not set
1147 # CONFIG_BOARD_ATSTK100X_SPI1 is not set
1148 # CONFIG_BOARD_ATSTK1000_J2_LED is not set
1149 # CONFIG_BOARD_ATSTK1000_J2_LED8 is not set
1150 # CONFIG_BOARD_ATSTK1000_J2_RGB is not set
1151 CONFIG_BOARD_ATSTK1000_EXTDAC=y
1152 +# CONFIG_BOARD_ATSTK100X_ENABLE_AC97 is not set
1153 +# CONFIG_BOARD_ATSTK1000_CF_HACKS is not set
1154 +# CONFIG_BOARD_ATSTK100X_ENABLE_PSIF is not set
1155 CONFIG_LOADER_U_BOOT=y
1159 # CONFIG_AP700X_32_BIT_SMC is not set
1160 CONFIG_AP700X_16_BIT_SMC=y
1161 # CONFIG_AP700X_8_BIT_SMC is not set
1163 CONFIG_LOAD_ADDRESS=0x10000000
1164 CONFIG_ENTRY_ADDRESS=0x90000000
1165 CONFIG_PHYS_OFFSET=0x10000000
1166 @@ -152,16 +172,26 @@
1167 CONFIG_ZONE_DMA_FLAG=0
1168 CONFIG_VIRT_TO_BUS=y
1169 # CONFIG_OWNERSHIP_TRACE is not set
1170 +CONFIG_NMI_DEBUGGING=y
1172 # CONFIG_HZ_100 is not set
1174 # CONFIG_HZ_300 is not set
1175 # CONFIG_HZ_1000 is not set
1177 +# CONFIG_SCHED_HRTICK is not set
1181 # Power management options
1183 +CONFIG_ARCH_SUSPEND_POSSIBLE=y
1185 +# CONFIG_PM_LEGACY is not set
1186 +# CONFIG_PM_DEBUG is not set
1189 +CONFIG_SUSPEND_FREEZER=y
1192 # CPU Frequency scaling
1194 CONFIG_CPU_FREQ_TABLE=y
1195 # CONFIG_CPU_FREQ_DEBUG is not set
1196 # CONFIG_CPU_FREQ_STAT is not set
1197 -CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
1198 +# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
1199 # CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
1200 -# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
1201 +CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
1202 # CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
1203 CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
1204 # CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
1207 # CONFIG_XFRM_SUB_POLICY is not set
1208 # CONFIG_XFRM_MIGRATE is not set
1209 +# CONFIG_XFRM_STATISTICS is not set
1211 # CONFIG_NET_KEY_MIGRATE is not set
1214 # CONFIG_NET_PKTGEN is not set
1215 # CONFIG_NET_TCPPROBE is not set
1216 # CONFIG_HAMRADIO is not set
1217 +# CONFIG_CAN is not set
1218 # CONFIG_IRDA is not set
1219 # CONFIG_BT is not set
1220 # CONFIG_AF_RXRPC is not set
1221 @@ -395,13 +427,18 @@
1222 CONFIG_BLK_DEV_RAM=m
1223 CONFIG_BLK_DEV_RAM_COUNT=16
1224 CONFIG_BLK_DEV_RAM_SIZE=4096
1225 -CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
1226 +# CONFIG_BLK_DEV_XIP is not set
1227 # CONFIG_CDROM_PKTCDVD is not set
1228 # CONFIG_ATA_OVER_ETH is not set
1229 CONFIG_MISC_DEVICES=y
1231 +CONFIG_ATMEL_TCLIB=y
1232 +CONFIG_ATMEL_TCB_CLKSRC=y
1233 +CONFIG_ATMEL_TCB_CLKSRC_BLOCK=0
1234 # CONFIG_EEPROM_93CX6 is not set
1236 -# CONFIG_IDE is not set
1237 +# CONFIG_ENCLOSURE_SERVICES is not set
1238 +# CONFIG_HAVE_IDE is not set
1241 # SCSI device support
1243 # CONFIG_SCSI_LOWLEVEL is not set
1245 # CONFIG_ATA_NONSTANDARD is not set
1246 +# CONFIG_SATA_MV is not set
1248 # CONFIG_PATA_PLATFORM is not set
1249 # CONFIG_MD is not set
1250 @@ -469,11 +507,13 @@
1251 # CONFIG_SMSC_PHY is not set
1252 # CONFIG_BROADCOM_PHY is not set
1253 # CONFIG_ICPLUS_PHY is not set
1254 +# CONFIG_REALTEK_PHY is not set
1255 # CONFIG_FIXED_PHY is not set
1256 # CONFIG_MDIO_BITBANG is not set
1257 CONFIG_NET_ETHERNET=y
1258 # CONFIG_MII is not set
1260 +# CONFIG_ENC28J60 is not set
1261 # CONFIG_IBM_NEW_EMAC_ZMII is not set
1262 # CONFIG_IBM_NEW_EMAC_RGMII is not set
1263 # CONFIG_IBM_NEW_EMAC_TAH is not set
1265 # CONFIG_PPPOL2TP is not set
1266 # CONFIG_SLIP is not set
1268 -# CONFIG_SHAPER is not set
1269 # CONFIG_NETCONSOLE is not set
1270 # CONFIG_NETPOLL is not set
1271 # CONFIG_NET_POLL_CONTROLLER is not set
1274 CONFIG_SERIAL_ATMEL=y
1275 CONFIG_SERIAL_ATMEL_CONSOLE=y
1276 +CONFIG_SERIAL_ATMEL_PDC=y
1277 # CONFIG_SERIAL_ATMEL_TTYAT is not set
1278 CONFIG_SERIAL_CORE=y
1279 CONFIG_SERIAL_CORE_CONSOLE=y
1281 # CONFIG_LEGACY_PTYS is not set
1282 # CONFIG_IPMI_HANDLER is not set
1283 # CONFIG_HW_RANDOM is not set
1284 -# CONFIG_RTC is not set
1285 -# CONFIG_GEN_RTC is not set
1286 # CONFIG_R3964 is not set
1287 # CONFIG_RAW_DRIVER is not set
1288 # CONFIG_TCG_TPM is not set
1291 # I2C Hardware Bus support
1293 +CONFIG_I2C_ATMELTWI=m
1295 # CONFIG_I2C_OCORES is not set
1296 # CONFIG_I2C_PARPORT_LIGHT is not set
1297 @@ -604,13 +643,12 @@
1299 # Miscellaneous I2C Chip support
1301 -# CONFIG_SENSORS_DS1337 is not set
1302 -# CONFIG_SENSORS_DS1374 is not set
1303 # CONFIG_DS1682 is not set
1304 # CONFIG_SENSORS_EEPROM is not set
1305 # CONFIG_SENSORS_PCF8574 is not set
1306 -# CONFIG_SENSORS_PCA9539 is not set
1307 +# CONFIG_PCF8575 is not set
1308 # CONFIG_SENSORS_PCF8591 is not set
1309 +# CONFIG_TPS65010 is not set
1310 # CONFIG_SENSORS_MAX6875 is not set
1311 # CONFIG_SENSORS_TSL2550 is not set
1312 # CONFIG_I2C_DEBUG_CORE is not set
1313 @@ -637,9 +675,27 @@
1314 # CONFIG_SPI_AT25 is not set
1316 # CONFIG_SPI_TLE62X0 is not set
1317 +CONFIG_HAVE_GPIO_LIB=y
1322 +# CONFIG_DEBUG_GPIO is not set
1325 +# I2C GPIO expanders:
1327 +# CONFIG_GPIO_PCA953X is not set
1328 +# CONFIG_GPIO_PCF857X is not set
1331 +# SPI GPIO expanders:
1333 +# CONFIG_GPIO_MCP23S08 is not set
1334 # CONFIG_W1 is not set
1335 # CONFIG_POWER_SUPPLY is not set
1336 # CONFIG_HWMON is not set
1337 +# CONFIG_THERMAL is not set
1339 # CONFIG_WATCHDOG_NOWAYOUT is not set
1341 @@ -732,12 +788,18 @@
1345 +CONFIG_SND_AC97_CODEC=m
1346 # CONFIG_SND_DUMMY is not set
1347 # CONFIG_SND_MTPAV is not set
1348 # CONFIG_SND_SERIAL_U16550 is not set
1349 # CONFIG_SND_MPU401 is not set
1354 +CONFIG_SND_ATMEL_AC97=m
1359 CONFIG_SND_AT73C213=m
1360 @@ -753,9 +815,14 @@
1364 +# ALSA SoC audio for Freescale SOCs
1370 # CONFIG_SOUND_PRIME is not set
1372 # CONFIG_HID_SUPPORT is not set
1373 CONFIG_USB_SUPPORT=y
1374 # CONFIG_USB_ARCH_HAS_HCD is not set
1375 @@ -765,10 +832,6 @@
1377 # NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
1381 -# USB Gadget Support
1384 # CONFIG_USB_GADGET_DEBUG is not set
1385 # CONFIG_USB_GADGET_DEBUG_FILES is not set
1386 @@ -796,27 +859,31 @@
1387 # CONFIG_USB_FILE_STORAGE_TEST is not set
1388 CONFIG_USB_G_SERIAL=m
1389 # CONFIG_USB_MIDI_GADGET is not set
1391 +# CONFIG_USB_G_PRINTER is not set
1393 # CONFIG_MMC_DEBUG is not set
1394 # CONFIG_MMC_UNSAFE_RESUME is not set
1397 # MMC/SD Card Drivers
1401 CONFIG_MMC_BLOCK_BOUNCE=y
1402 # CONFIG_SDIO_UART is not set
1405 # MMC/SD Host Controller Drivers
1407 +CONFIG_MMC_ATMELMCI=y
1409 +# CONFIG_MEMSTICK is not set
1416 +CONFIG_LEDS_ATMEL_PWM=m
1420 @@ -853,19 +920,22 @@
1421 # CONFIG_RTC_DRV_PCF8563 is not set
1422 # CONFIG_RTC_DRV_PCF8583 is not set
1423 # CONFIG_RTC_DRV_M41T80 is not set
1424 +# CONFIG_RTC_DRV_S35390A is not set
1429 -# CONFIG_RTC_DRV_RS5C348 is not set
1430 # CONFIG_RTC_DRV_MAX6902 is not set
1431 +# CONFIG_RTC_DRV_R9701 is not set
1432 +# CONFIG_RTC_DRV_RS5C348 is not set
1435 # Platform RTC drivers
1437 +# CONFIG_RTC_DRV_DS1511 is not set
1438 # CONFIG_RTC_DRV_DS1553 is not set
1439 -# CONFIG_RTC_DRV_STK17TA8 is not set
1440 # CONFIG_RTC_DRV_DS1742 is not set
1441 +# CONFIG_RTC_DRV_STK17TA8 is not set
1442 # CONFIG_RTC_DRV_M48T86 is not set
1443 # CONFIG_RTC_DRV_M48T59 is not set
1444 # CONFIG_RTC_DRV_V3020 is not set
1445 @@ -883,13 +953,13 @@
1451 # CONFIG_EXT2_FS_XATTR is not set
1452 # CONFIG_EXT2_FS_XIP is not set
1455 # CONFIG_EXT3_FS_XATTR is not set
1456 # CONFIG_EXT4DEV_FS is not set
1459 # CONFIG_JBD_DEBUG is not set
1460 # CONFIG_REISERFS_FS is not set
1461 # CONFIG_JFS_FS is not set
1462 @@ -897,12 +967,10 @@
1463 # CONFIG_XFS_FS is not set
1464 # CONFIG_GFS2_FS is not set
1465 # CONFIG_OCFS2_FS is not set
1467 -# CONFIG_ROMFS_FS is not set
1468 +# CONFIG_DNOTIFY is not set
1470 CONFIG_INOTIFY_USER=y
1471 # CONFIG_QUOTA is not set
1472 -# CONFIG_DNOTIFY is not set
1473 # CONFIG_AUTOFS_FS is not set
1474 # CONFIG_AUTOFS4_FS is not set
1476 @@ -933,7 +1001,7 @@
1478 # CONFIG_TMPFS_POSIX_ACL is not set
1479 # CONFIG_HUGETLB_PAGE is not set
1480 -# CONFIG_CONFIGFS_FS is not set
1481 +CONFIG_CONFIGFS_FS=y
1484 # Miscellaneous filesystems
1485 @@ -957,8 +1025,10 @@
1486 # CONFIG_JFFS2_RUBIN is not set
1487 # CONFIG_CRAMFS is not set
1488 # CONFIG_VXFS_FS is not set
1490 # CONFIG_HPFS_FS is not set
1491 # CONFIG_QNX4FS_FS is not set
1492 +# CONFIG_ROMFS_FS is not set
1493 # CONFIG_SYSV_FS is not set
1494 # CONFIG_UFS_FS is not set
1495 CONFIG_NETWORK_FILESYSTEMS=y
1496 @@ -1028,11 +1098,6 @@
1497 # CONFIG_NLS_KOI8_U is not set
1499 # CONFIG_DLM is not set
1500 -CONFIG_INSTRUMENTATION=y
1504 -# CONFIG_MARKERS is not set
1508 @@ -1051,6 +1116,7 @@
1509 # CONFIG_SCHEDSTATS is not set
1510 # CONFIG_TIMER_STATS is not set
1511 # CONFIG_SLUB_DEBUG_ON is not set
1512 +# CONFIG_SLUB_STATS is not set
1513 # CONFIG_DEBUG_RT_MUTEXES is not set
1514 # CONFIG_RT_MUTEX_TESTER is not set
1515 # CONFIG_DEBUG_SPINLOCK is not set
1516 @@ -1067,9 +1133,10 @@
1517 # CONFIG_DEBUG_LIST is not set
1518 # CONFIG_DEBUG_SG is not set
1519 CONFIG_FRAME_POINTER=y
1520 -CONFIG_FORCED_INLINING=y
1521 # CONFIG_BOOT_PRINTK_DELAY is not set
1522 # CONFIG_RCU_TORTURE_TEST is not set
1523 +# CONFIG_KPROBES_SANITY_TEST is not set
1524 +# CONFIG_BACKTRACE_SELF_TEST is not set
1525 # CONFIG_LKDTM is not set
1526 # CONFIG_FAULT_INJECTION is not set
1527 # CONFIG_SAMPLES is not set
1528 @@ -1082,7 +1149,9 @@
1529 # CONFIG_SECURITY_FILE_CAPABILITIES is not set
1531 CONFIG_CRYPTO_ALGAPI=m
1532 +CONFIG_CRYPTO_AEAD=m
1533 CONFIG_CRYPTO_BLKCIPHER=m
1534 +# CONFIG_CRYPTO_SEQIV is not set
1535 CONFIG_CRYPTO_HASH=m
1536 CONFIG_CRYPTO_MANAGER=m
1537 CONFIG_CRYPTO_HMAC=m
1538 @@ -1101,6 +1170,9 @@
1539 # CONFIG_CRYPTO_PCBC is not set
1540 # CONFIG_CRYPTO_LRW is not set
1541 # CONFIG_CRYPTO_XTS is not set
1542 +# CONFIG_CRYPTO_CTR is not set
1543 +# CONFIG_CRYPTO_GCM is not set
1544 +# CONFIG_CRYPTO_CCM is not set
1545 # CONFIG_CRYPTO_CRYPTD is not set
1547 # CONFIG_CRYPTO_FCRYPT is not set
1548 @@ -1115,12 +1187,14 @@
1549 # CONFIG_CRYPTO_KHAZAD is not set
1550 # CONFIG_CRYPTO_ANUBIS is not set
1551 # CONFIG_CRYPTO_SEED is not set
1552 +# CONFIG_CRYPTO_SALSA20 is not set
1553 CONFIG_CRYPTO_DEFLATE=m
1554 # CONFIG_CRYPTO_MICHAEL_MIC is not set
1555 # CONFIG_CRYPTO_CRC32C is not set
1556 # CONFIG_CRYPTO_CAMELLIA is not set
1557 # CONFIG_CRYPTO_TEST is not set
1558 -# CONFIG_CRYPTO_AUTHENC is not set
1559 +CONFIG_CRYPTO_AUTHENC=m
1560 +# CONFIG_CRYPTO_LZO is not set
1561 # CONFIG_CRYPTO_HW is not set
1564 @@ -1135,6 +1209,7 @@
1565 # CONFIG_LIBCRC32C is not set
1566 CONFIG_ZLIB_INFLATE=y
1567 CONFIG_ZLIB_DEFLATE=y
1568 +CONFIG_GENERIC_ALLOCATOR=y
1572 --- a/arch/avr32/configs/atstk1003_defconfig
1573 +++ b/arch/avr32/configs/atstk1003_defconfig
1576 # Automatically generated make config: don't edit
1577 -# Linux kernel version: 2.6.24-rc7
1578 -# Wed Jan 9 22:54:34 2008
1579 +# Linux kernel version: 2.6.25.4
1580 +# Wed Jun 11 15:33:36 2008
1583 CONFIG_GENERIC_GPIO=y
1585 CONFIG_GENERIC_IRQ_PROBE=y
1586 CONFIG_RWSEM_GENERIC_SPINLOCK=y
1587 CONFIG_GENERIC_TIME=y
1588 +CONFIG_GENERIC_CLOCKEVENTS=y
1589 # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
1590 # CONFIG_ARCH_HAS_ILOG2_U32 is not set
1591 # CONFIG_ARCH_HAS_ILOG2_U64 is not set
1592 -CONFIG_ARCH_SUPPORTS_OPROFILE=y
1593 CONFIG_GENERIC_HWEIGHT=y
1594 CONFIG_GENERIC_CALIBRATE_DELAY=y
1595 CONFIG_GENERIC_BUG=y
1598 CONFIG_TASK_DELAY_ACCT=y
1599 # CONFIG_TASK_XACCT is not set
1600 -# CONFIG_USER_NS is not set
1601 -# CONFIG_PID_NS is not set
1603 # CONFIG_IKCONFIG is not set
1604 CONFIG_LOG_BUF_SHIFT=14
1605 # CONFIG_CGROUPS is not set
1606 -CONFIG_FAIR_GROUP_SCHED=y
1607 -CONFIG_FAIR_USER_SCHED=y
1608 -# CONFIG_FAIR_CGROUP_SCHED is not set
1609 +# CONFIG_GROUP_SCHED is not set
1610 CONFIG_SYSFS_DEPRECATED=y
1611 +CONFIG_SYSFS_DEPRECATED_V2=y
1613 +# CONFIG_NAMESPACES is not set
1614 CONFIG_BLK_DEV_INITRD=y
1615 CONFIG_INITRAMFS_SOURCE=""
1616 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
1621 +# CONFIG_COMPAT_BRK is not set
1622 # CONFIG_BASE_FULL is not set
1624 CONFIG_ANON_INODES=y
1630 CONFIG_VM_EVENT_COUNTERS=y
1632 # CONFIG_SLAB is not set
1634 # CONFIG_SLOB is not set
1636 +# CONFIG_MARKERS is not set
1638 +CONFIG_HAVE_OPROFILE=y
1640 +CONFIG_HAVE_KPROBES=y
1641 +# CONFIG_HAVE_KRETPROBES is not set
1642 +CONFIG_PROC_PAGE_MONITOR=y
1645 # CONFIG_TINY_SHMEM is not set
1646 @@ -103,10 +111,15 @@
1647 CONFIG_DEFAULT_CFQ=y
1648 # CONFIG_DEFAULT_NOOP is not set
1649 CONFIG_DEFAULT_IOSCHED="cfq"
1650 +CONFIG_CLASSIC_RCU=y
1653 # System Type and features
1655 +CONFIG_TICK_ONESHOT=y
1657 +CONFIG_HIGH_RES_TIMERS=y
1658 +CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
1659 CONFIG_SUBARCH_AVR32B=y
1661 CONFIG_PERFORMANCE_COUNTERS=y
1662 @@ -118,12 +131,16 @@
1663 # CONFIG_BOARD_ATSTK1002 is not set
1664 CONFIG_BOARD_ATSTK1003=y
1665 # CONFIG_BOARD_ATSTK1004 is not set
1666 +# CONFIG_BOARD_ATSTK1006 is not set
1667 # CONFIG_BOARD_ATSTK100X_CUSTOM is not set
1668 # CONFIG_BOARD_ATSTK100X_SPI1 is not set
1669 # CONFIG_BOARD_ATSTK1000_J2_LED is not set
1670 # CONFIG_BOARD_ATSTK1000_J2_LED8 is not set
1671 # CONFIG_BOARD_ATSTK1000_J2_RGB is not set
1672 CONFIG_BOARD_ATSTK1000_EXTDAC=y
1673 +# CONFIG_BOARD_ATSTK100X_ENABLE_AC97 is not set
1674 +# CONFIG_BOARD_ATSTK1000_CF_HACKS is not set
1675 +# CONFIG_BOARD_ATSTK100X_ENABLE_PSIF is not set
1676 CONFIG_LOADER_U_BOOT=y
1680 # CONFIG_AP700X_32_BIT_SMC is not set
1681 CONFIG_AP700X_16_BIT_SMC=y
1682 # CONFIG_AP700X_8_BIT_SMC is not set
1684 CONFIG_LOAD_ADDRESS=0x10000000
1685 CONFIG_ENTRY_ADDRESS=0x90000000
1686 CONFIG_PHYS_OFFSET=0x10000000
1687 @@ -157,16 +175,26 @@
1688 CONFIG_ZONE_DMA_FLAG=0
1689 CONFIG_VIRT_TO_BUS=y
1690 # CONFIG_OWNERSHIP_TRACE is not set
1691 +CONFIG_NMI_DEBUGGING=y
1693 # CONFIG_HZ_100 is not set
1695 # CONFIG_HZ_300 is not set
1696 # CONFIG_HZ_1000 is not set
1698 +# CONFIG_SCHED_HRTICK is not set
1702 # Power management options
1704 +CONFIG_ARCH_SUSPEND_POSSIBLE=y
1706 +# CONFIG_PM_LEGACY is not set
1707 +# CONFIG_PM_DEBUG is not set
1710 +CONFIG_SUSPEND_FREEZER=y
1713 # CPU Frequency scaling
1715 CONFIG_CPU_FREQ_TABLE=y
1716 # CONFIG_CPU_FREQ_DEBUG is not set
1717 # CONFIG_CPU_FREQ_STAT is not set
1718 -CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
1719 +# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
1720 # CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
1721 -# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
1722 +CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
1723 # CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
1724 CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
1725 # CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
1727 # CONFIG_NET_PKTGEN is not set
1728 # CONFIG_NET_TCPPROBE is not set
1729 # CONFIG_HAMRADIO is not set
1730 +# CONFIG_CAN is not set
1731 # CONFIG_IRDA is not set
1732 # CONFIG_BT is not set
1733 # CONFIG_AF_RXRPC is not set
1734 @@ -376,13 +405,18 @@
1735 CONFIG_BLK_DEV_RAM=m
1736 CONFIG_BLK_DEV_RAM_COUNT=16
1737 CONFIG_BLK_DEV_RAM_SIZE=4096
1738 -CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
1739 +# CONFIG_BLK_DEV_XIP is not set
1740 # CONFIG_CDROM_PKTCDVD is not set
1741 # CONFIG_ATA_OVER_ETH is not set
1742 CONFIG_MISC_DEVICES=y
1744 +CONFIG_ATMEL_TCLIB=y
1745 +CONFIG_ATMEL_TCB_CLKSRC=y
1746 +CONFIG_ATMEL_TCB_CLKSRC_BLOCK=0
1747 # CONFIG_EEPROM_93CX6 is not set
1749 -# CONFIG_IDE is not set
1750 +# CONFIG_ENCLOSURE_SERVICES is not set
1751 +# CONFIG_HAVE_IDE is not set
1754 # SCSI device support
1756 # CONFIG_SCSI_DEBUG is not set
1758 # CONFIG_ATA_NONSTANDARD is not set
1759 +# CONFIG_SATA_MV is not set
1761 # CONFIG_PATA_PLATFORM is not set
1762 # CONFIG_MD is not set
1764 # CONFIG_PPPOL2TP is not set
1765 # CONFIG_SLIP is not set
1767 -# CONFIG_SHAPER is not set
1768 # CONFIG_NETCONSOLE is not set
1769 # CONFIG_NETPOLL is not set
1770 # CONFIG_NET_POLL_CONTROLLER is not set
1773 CONFIG_SERIAL_ATMEL=y
1774 CONFIG_SERIAL_ATMEL_CONSOLE=y
1775 +CONFIG_SERIAL_ATMEL_PDC=y
1776 # CONFIG_SERIAL_ATMEL_TTYAT is not set
1777 CONFIG_SERIAL_CORE=y
1778 CONFIG_SERIAL_CORE_CONSOLE=y
1780 # CONFIG_LEGACY_PTYS is not set
1781 # CONFIG_IPMI_HANDLER is not set
1782 # CONFIG_HW_RANDOM is not set
1783 -# CONFIG_RTC is not set
1784 -# CONFIG_GEN_RTC is not set
1785 # CONFIG_R3964 is not set
1786 # CONFIG_RAW_DRIVER is not set
1787 # CONFIG_TCG_TPM is not set
1790 # I2C Hardware Bus support
1792 +CONFIG_I2C_ATMELTWI=m
1794 # CONFIG_I2C_OCORES is not set
1795 # CONFIG_I2C_PARPORT_LIGHT is not set
1796 @@ -564,13 +598,12 @@
1798 # Miscellaneous I2C Chip support
1800 -# CONFIG_SENSORS_DS1337 is not set
1801 -# CONFIG_SENSORS_DS1374 is not set
1802 # CONFIG_DS1682 is not set
1803 # CONFIG_SENSORS_EEPROM is not set
1804 # CONFIG_SENSORS_PCF8574 is not set
1805 -# CONFIG_SENSORS_PCA9539 is not set
1806 +# CONFIG_PCF8575 is not set
1807 # CONFIG_SENSORS_PCF8591 is not set
1808 +# CONFIG_TPS65010 is not set
1809 # CONFIG_SENSORS_MAX6875 is not set
1810 # CONFIG_SENSORS_TSL2550 is not set
1811 # CONFIG_I2C_DEBUG_CORE is not set
1812 @@ -597,9 +630,27 @@
1813 # CONFIG_SPI_AT25 is not set
1815 # CONFIG_SPI_TLE62X0 is not set
1816 +CONFIG_HAVE_GPIO_LIB=y
1821 +# CONFIG_DEBUG_GPIO is not set
1824 +# I2C GPIO expanders:
1826 +# CONFIG_GPIO_PCA953X is not set
1827 +# CONFIG_GPIO_PCF857X is not set
1830 +# SPI GPIO expanders:
1832 +# CONFIG_GPIO_MCP23S08 is not set
1833 # CONFIG_W1 is not set
1834 # CONFIG_POWER_SUPPLY is not set
1835 # CONFIG_HWMON is not set
1836 +# CONFIG_THERMAL is not set
1838 # CONFIG_WATCHDOG_NOWAYOUT is not set
1840 @@ -665,12 +716,18 @@
1844 +CONFIG_SND_AC97_CODEC=m
1845 # CONFIG_SND_DUMMY is not set
1846 # CONFIG_SND_MTPAV is not set
1847 # CONFIG_SND_SERIAL_U16550 is not set
1848 # CONFIG_SND_MPU401 is not set
1853 +CONFIG_SND_ATMEL_AC97=m
1858 CONFIG_SND_AT73C213=m
1859 @@ -686,9 +743,14 @@
1863 +# ALSA SoC audio for Freescale SOCs
1869 # CONFIG_SOUND_PRIME is not set
1871 # CONFIG_HID_SUPPORT is not set
1872 CONFIG_USB_SUPPORT=y
1873 # CONFIG_USB_ARCH_HAS_HCD is not set
1874 @@ -698,10 +760,6 @@
1876 # NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
1880 -# USB Gadget Support
1883 # CONFIG_USB_GADGET_DEBUG is not set
1884 # CONFIG_USB_GADGET_DEBUG_FILES is not set
1885 @@ -729,27 +787,31 @@
1886 # CONFIG_USB_FILE_STORAGE_TEST is not set
1887 CONFIG_USB_G_SERIAL=m
1888 # CONFIG_USB_MIDI_GADGET is not set
1890 +# CONFIG_USB_G_PRINTER is not set
1892 # CONFIG_MMC_DEBUG is not set
1893 # CONFIG_MMC_UNSAFE_RESUME is not set
1896 # MMC/SD Card Drivers
1900 # CONFIG_MMC_BLOCK_BOUNCE is not set
1901 # CONFIG_SDIO_UART is not set
1904 # MMC/SD Host Controller Drivers
1906 +CONFIG_MMC_ATMELMCI=y
1908 +# CONFIG_MEMSTICK is not set
1915 +CONFIG_LEDS_ATMEL_PWM=m
1919 @@ -786,19 +848,22 @@
1920 # CONFIG_RTC_DRV_PCF8563 is not set
1921 # CONFIG_RTC_DRV_PCF8583 is not set
1922 # CONFIG_RTC_DRV_M41T80 is not set
1923 +# CONFIG_RTC_DRV_S35390A is not set
1928 -# CONFIG_RTC_DRV_RS5C348 is not set
1929 # CONFIG_RTC_DRV_MAX6902 is not set
1930 +# CONFIG_RTC_DRV_R9701 is not set
1931 +# CONFIG_RTC_DRV_RS5C348 is not set
1934 # Platform RTC drivers
1936 +# CONFIG_RTC_DRV_DS1511 is not set
1937 # CONFIG_RTC_DRV_DS1553 is not set
1938 -# CONFIG_RTC_DRV_STK17TA8 is not set
1939 # CONFIG_RTC_DRV_DS1742 is not set
1940 +# CONFIG_RTC_DRV_STK17TA8 is not set
1941 # CONFIG_RTC_DRV_M48T86 is not set
1942 # CONFIG_RTC_DRV_M48T59 is not set
1943 # CONFIG_RTC_DRV_V3020 is not set
1944 @@ -816,13 +881,13 @@
1950 # CONFIG_EXT2_FS_XATTR is not set
1951 # CONFIG_EXT2_FS_XIP is not set
1954 # CONFIG_EXT3_FS_XATTR is not set
1955 # CONFIG_EXT4DEV_FS is not set
1958 # CONFIG_JBD_DEBUG is not set
1959 # CONFIG_REISERFS_FS is not set
1960 # CONFIG_JFS_FS is not set
1961 @@ -830,12 +895,10 @@
1962 # CONFIG_XFS_FS is not set
1963 # CONFIG_GFS2_FS is not set
1964 # CONFIG_OCFS2_FS is not set
1965 -# CONFIG_MINIX_FS is not set
1966 -# CONFIG_ROMFS_FS is not set
1967 +# CONFIG_DNOTIFY is not set
1969 CONFIG_INOTIFY_USER=y
1970 # CONFIG_QUOTA is not set
1971 -# CONFIG_DNOTIFY is not set
1972 # CONFIG_AUTOFS_FS is not set
1973 # CONFIG_AUTOFS4_FS is not set
1977 # CONFIG_TMPFS_POSIX_ACL is not set
1978 # CONFIG_HUGETLB_PAGE is not set
1979 -CONFIG_CONFIGFS_FS=m
1980 +CONFIG_CONFIGFS_FS=y
1983 # Miscellaneous filesystems
1984 @@ -891,8 +954,10 @@
1985 # CONFIG_JFFS2_RUBIN is not set
1986 # CONFIG_CRAMFS is not set
1987 # CONFIG_VXFS_FS is not set
1988 +# CONFIG_MINIX_FS is not set
1989 # CONFIG_HPFS_FS is not set
1990 # CONFIG_QNX4FS_FS is not set
1991 +# CONFIG_ROMFS_FS is not set
1992 # CONFIG_SYSV_FS is not set
1993 # CONFIG_UFS_FS is not set
1994 # CONFIG_NETWORK_FILESYSTEMS is not set
1995 @@ -943,11 +1008,6 @@
1996 # CONFIG_NLS_KOI8_U is not set
1998 # CONFIG_DLM is not set
1999 -CONFIG_INSTRUMENTATION=y
2003 -# CONFIG_MARKERS is not set
2007 @@ -965,6 +1025,7 @@
2008 CONFIG_SCHED_DEBUG=y
2009 # CONFIG_SCHEDSTATS is not set
2010 # CONFIG_TIMER_STATS is not set
2011 +# CONFIG_SLUB_STATS is not set
2012 # CONFIG_DEBUG_RT_MUTEXES is not set
2013 # CONFIG_RT_MUTEX_TESTER is not set
2014 # CONFIG_DEBUG_SPINLOCK is not set
2015 @@ -981,9 +1042,10 @@
2016 # CONFIG_DEBUG_LIST is not set
2017 # CONFIG_DEBUG_SG is not set
2018 CONFIG_FRAME_POINTER=y
2019 -CONFIG_FORCED_INLINING=y
2020 # CONFIG_BOOT_PRINTK_DELAY is not set
2021 # CONFIG_RCU_TORTURE_TEST is not set
2022 +# CONFIG_KPROBES_SANITY_TEST is not set
2023 +# CONFIG_BACKTRACE_SELF_TEST is not set
2024 # CONFIG_LKDTM is not set
2025 # CONFIG_FAULT_INJECTION is not set
2026 # CONFIG_SAMPLES is not set
2027 @@ -1009,6 +1071,7 @@
2028 CONFIG_AUDIT_GENERIC=y
2029 CONFIG_ZLIB_INFLATE=y
2030 CONFIG_ZLIB_DEFLATE=y
2031 +CONFIG_GENERIC_ALLOCATOR=y
2035 --- a/arch/avr32/configs/atstk1004_defconfig
2036 +++ b/arch/avr32/configs/atstk1004_defconfig
2039 # Automatically generated make config: don't edit
2040 -# Linux kernel version: 2.6.24-rc7
2041 -# Wed Jan 9 23:04:20 2008
2042 +# Linux kernel version: 2.6.25.4
2043 +# Wed Jun 11 15:37:49 2008
2046 CONFIG_GENERIC_GPIO=y
2048 CONFIG_GENERIC_IRQ_PROBE=y
2049 CONFIG_RWSEM_GENERIC_SPINLOCK=y
2050 CONFIG_GENERIC_TIME=y
2051 +CONFIG_GENERIC_CLOCKEVENTS=y
2052 # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
2053 # CONFIG_ARCH_HAS_ILOG2_U32 is not set
2054 # CONFIG_ARCH_HAS_ILOG2_U64 is not set
2055 -CONFIG_ARCH_SUPPORTS_OPROFILE=y
2056 CONFIG_GENERIC_HWEIGHT=y
2057 CONFIG_GENERIC_CALIBRATE_DELAY=y
2058 CONFIG_GENERIC_BUG=y
2060 # CONFIG_POSIX_MQUEUE is not set
2061 # CONFIG_BSD_PROCESS_ACCT is not set
2062 # CONFIG_TASKSTATS is not set
2063 -# CONFIG_USER_NS is not set
2064 -# CONFIG_PID_NS is not set
2065 # CONFIG_AUDIT is not set
2066 # CONFIG_IKCONFIG is not set
2067 CONFIG_LOG_BUF_SHIFT=14
2068 # CONFIG_CGROUPS is not set
2069 -# CONFIG_FAIR_GROUP_SCHED is not set
2070 +# CONFIG_GROUP_SCHED is not set
2071 CONFIG_SYSFS_DEPRECATED=y
2072 +CONFIG_SYSFS_DEPRECATED_V2=y
2073 # CONFIG_RELAY is not set
2074 +# CONFIG_NAMESPACES is not set
2075 # CONFIG_BLK_DEV_INITRD is not set
2076 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
2082 +# CONFIG_COMPAT_BRK is not set
2083 # CONFIG_BASE_FULL is not set
2084 # CONFIG_FUTEX is not set
2085 # CONFIG_EPOLL is not set
2086 # CONFIG_SIGNALFD is not set
2087 +# CONFIG_TIMERFD is not set
2088 # CONFIG_EVENTFD is not set
2090 CONFIG_VM_EVENT_COUNTERS=y
2091 # CONFIG_SLAB is not set
2092 # CONFIG_SLUB is not set
2094 +# CONFIG_PROFILING is not set
2095 +# CONFIG_MARKERS is not set
2096 +CONFIG_HAVE_OPROFILE=y
2097 +CONFIG_HAVE_KPROBES=y
2098 +# CONFIG_HAVE_KRETPROBES is not set
2099 +# CONFIG_PROC_PAGE_MONITOR is not set
2100 # CONFIG_TINY_SHMEM is not set
2102 # CONFIG_MODULES is not set
2103 # CONFIG_BLOCK is not set
2104 +CONFIG_CLASSIC_RCU=y
2107 # System Type and features
2109 +# CONFIG_TICK_ONESHOT is not set
2110 +# CONFIG_NO_HZ is not set
2111 +# CONFIG_HIGH_RES_TIMERS is not set
2112 +CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
2113 CONFIG_SUBARCH_AVR32B=y
2115 CONFIG_PERFORMANCE_COUNTERS=y
2117 # CONFIG_BOARD_ATSTK1002 is not set
2118 # CONFIG_BOARD_ATSTK1003 is not set
2119 CONFIG_BOARD_ATSTK1004=y
2120 +# CONFIG_BOARD_ATSTK1006 is not set
2121 # CONFIG_BOARD_ATSTK100X_CUSTOM is not set
2122 # CONFIG_BOARD_ATSTK100X_SPI1 is not set
2123 # CONFIG_BOARD_ATSTK1000_J2_LED is not set
2124 CONFIG_BOARD_ATSTK1000_EXTDAC=y
2125 +# CONFIG_BOARD_ATSTK100X_ENABLE_AC97 is not set
2126 +# CONFIG_BOARD_ATSTK1000_CF_HACKS is not set
2127 +# CONFIG_BOARD_ATSTK100X_ENABLE_PSIF is not set
2128 CONFIG_LOADER_U_BOOT=y
2132 # CONFIG_AP700X_32_BIT_SMC is not set
2133 CONFIG_AP700X_16_BIT_SMC=y
2134 # CONFIG_AP700X_8_BIT_SMC is not set
2135 +# CONFIG_GPIO_DEV is not set
2136 CONFIG_LOAD_ADDRESS=0x10000000
2137 CONFIG_ENTRY_ADDRESS=0x90000000
2138 CONFIG_PHYS_OFFSET=0x10000000
2139 @@ -120,34 +138,26 @@
2140 CONFIG_ZONE_DMA_FLAG=0
2141 CONFIG_VIRT_TO_BUS=y
2142 # CONFIG_OWNERSHIP_TRACE is not set
2143 +# CONFIG_NMI_DEBUGGING is not set
2145 # CONFIG_HZ_100 is not set
2147 # CONFIG_HZ_300 is not set
2148 # CONFIG_HZ_1000 is not set
2150 +# CONFIG_SCHED_HRTICK is not set
2154 # Power management options
2156 +CONFIG_ARCH_SUSPEND_POSSIBLE=y
2157 +# CONFIG_PM is not set
2160 # CPU Frequency scaling
2163 -CONFIG_CPU_FREQ_TABLE=y
2164 -# CONFIG_CPU_FREQ_DEBUG is not set
2165 -# CONFIG_CPU_FREQ_STAT is not set
2166 -CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
2167 -# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
2168 -# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
2169 -# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
2170 -CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
2171 -# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
2172 -CONFIG_CPU_FREQ_GOV_USERSPACE=y
2173 -CONFIG_CPU_FREQ_GOV_ONDEMAND=y
2174 -# CONFIG_CPU_FREQ_GOV_CONSERVATIVE is not set
2175 -CONFIG_CPU_FREQ_AT32AP=y
2176 +# CONFIG_CPU_FREQ is not set
2182 # CONFIG_NET_PKTGEN is not set
2183 # CONFIG_HAMRADIO is not set
2184 +# CONFIG_CAN is not set
2185 # CONFIG_IRDA is not set
2186 # CONFIG_BT is not set
2187 # CONFIG_AF_RXRPC is not set
2189 # CONFIG_MTD_UBI is not set
2190 # CONFIG_PARPORT is not set
2191 # CONFIG_MISC_DEVICES is not set
2192 +# CONFIG_HAVE_IDE is not set
2195 # SCSI device support
2198 CONFIG_SERIAL_ATMEL=y
2199 CONFIG_SERIAL_ATMEL_CONSOLE=y
2200 +# CONFIG_SERIAL_ATMEL_PDC is not set
2201 # CONFIG_SERIAL_ATMEL_TTYAT is not set
2202 CONFIG_SERIAL_CORE=y
2203 CONFIG_SERIAL_CORE_CONSOLE=y
2205 # CONFIG_LEGACY_PTYS is not set
2206 # CONFIG_IPMI_HANDLER is not set
2207 # CONFIG_HW_RANDOM is not set
2208 -# CONFIG_RTC is not set
2209 -# CONFIG_GEN_RTC is not set
2210 # CONFIG_R3964 is not set
2211 # CONFIG_TCG_TPM is not set
2212 # CONFIG_I2C is not set
2213 @@ -389,9 +400,24 @@
2214 # CONFIG_SPI_AT25 is not set
2215 # CONFIG_SPI_SPIDEV is not set
2216 # CONFIG_SPI_TLE62X0 is not set
2217 +CONFIG_HAVE_GPIO_LIB=y
2224 +# I2C GPIO expanders:
2228 +# SPI GPIO expanders:
2230 +# CONFIG_GPIO_MCP23S08 is not set
2231 # CONFIG_W1 is not set
2232 # CONFIG_POWER_SUPPLY is not set
2233 # CONFIG_HWMON is not set
2234 +# CONFIG_THERMAL is not set
2236 # CONFIG_WATCHDOG_NOWAYOUT is not set
2238 @@ -471,10 +497,6 @@
2240 # NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
2244 -# USB Gadget Support
2247 # CONFIG_USB_GADGET_DEBUG_FILES is not set
2248 CONFIG_USB_GADGET_SELECTED=y
2250 # CONFIG_USB_FILE_STORAGE is not set
2251 # CONFIG_USB_G_SERIAL is not set
2252 # CONFIG_USB_MIDI_GADGET is not set
2253 +# CONFIG_USB_G_PRINTER is not set
2254 # CONFIG_MMC is not set
2255 +# CONFIG_MEMSTICK is not set
2256 # CONFIG_NEW_LEDS is not set
2259 @@ -519,15 +543,17 @@
2263 -# CONFIG_RTC_DRV_RS5C348 is not set
2264 # CONFIG_RTC_DRV_MAX6902 is not set
2265 +# CONFIG_RTC_DRV_R9701 is not set
2266 +# CONFIG_RTC_DRV_RS5C348 is not set
2269 # Platform RTC drivers
2271 +# CONFIG_RTC_DRV_DS1511 is not set
2272 # CONFIG_RTC_DRV_DS1553 is not set
2273 -# CONFIG_RTC_DRV_STK17TA8 is not set
2274 # CONFIG_RTC_DRV_DS1742 is not set
2275 +# CONFIG_RTC_DRV_STK17TA8 is not set
2276 # CONFIG_RTC_DRV_M48T86 is not set
2277 # CONFIG_RTC_DRV_M48T59 is not set
2278 # CONFIG_RTC_DRV_V3020 is not set
2283 +# CONFIG_DNOTIFY is not set
2284 # CONFIG_INOTIFY is not set
2285 # CONFIG_QUOTA is not set
2286 -# CONFIG_DNOTIFY is not set
2287 # CONFIG_AUTOFS_FS is not set
2288 # CONFIG_AUTOFS4_FS is not set
2289 # CONFIG_FUSE_FS is not set
2291 # CONFIG_NETWORK_FILESYSTEMS is not set
2292 # CONFIG_NLS is not set
2293 # CONFIG_DLM is not set
2294 -# CONFIG_INSTRUMENTATION is not set
2299 # CONFIG_LIBCRC32C is not set
2300 CONFIG_ZLIB_INFLATE=y
2301 CONFIG_ZLIB_DEFLATE=y
2302 +CONFIG_GENERIC_ALLOCATOR=y
2307 +++ b/arch/avr32/configs/atstk1006_defconfig
2310 +# Automatically generated make config: don't edit
2311 +# Linux kernel version: 2.6.25.4
2312 +# Wed Jun 11 15:40:45 2008
2315 +CONFIG_GENERIC_GPIO=y
2316 +CONFIG_GENERIC_HARDIRQS=y
2317 +CONFIG_STACKTRACE_SUPPORT=y
2318 +CONFIG_LOCKDEP_SUPPORT=y
2319 +CONFIG_TRACE_IRQFLAGS_SUPPORT=y
2320 +CONFIG_HARDIRQS_SW_RESEND=y
2321 +CONFIG_GENERIC_IRQ_PROBE=y
2322 +CONFIG_RWSEM_GENERIC_SPINLOCK=y
2323 +CONFIG_GENERIC_TIME=y
2324 +CONFIG_GENERIC_CLOCKEVENTS=y
2325 +# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
2326 +# CONFIG_ARCH_HAS_ILOG2_U32 is not set
2327 +# CONFIG_ARCH_HAS_ILOG2_U64 is not set
2328 +CONFIG_GENERIC_HWEIGHT=y
2329 +CONFIG_GENERIC_CALIBRATE_DELAY=y
2330 +CONFIG_GENERIC_BUG=y
2331 +CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
2336 +CONFIG_EXPERIMENTAL=y
2337 +CONFIG_BROKEN_ON_SMP=y
2338 +CONFIG_INIT_ENV_ARG_LIMIT=32
2339 +CONFIG_LOCALVERSION=""
2340 +# CONFIG_LOCALVERSION_AUTO is not set
2343 +CONFIG_SYSVIPC_SYSCTL=y
2344 +CONFIG_POSIX_MQUEUE=y
2345 +# CONFIG_BSD_PROCESS_ACCT is not set
2346 +# CONFIG_TASKSTATS is not set
2347 +# CONFIG_AUDIT is not set
2348 +# CONFIG_IKCONFIG is not set
2349 +CONFIG_LOG_BUF_SHIFT=14
2350 +# CONFIG_CGROUPS is not set
2351 +# CONFIG_GROUP_SCHED is not set
2352 +CONFIG_SYSFS_DEPRECATED=y
2353 +CONFIG_SYSFS_DEPRECATED_V2=y
2355 +# CONFIG_NAMESPACES is not set
2356 +CONFIG_BLK_DEV_INITRD=y
2357 +CONFIG_INITRAMFS_SOURCE=""
2358 +CONFIG_CC_OPTIMIZE_FOR_SIZE=y
2361 +# CONFIG_SYSCTL_SYSCALL is not set
2363 +# CONFIG_KALLSYMS_ALL is not set
2364 +# CONFIG_KALLSYMS_EXTRA_PASS is not set
2369 +# CONFIG_COMPAT_BRK is not set
2370 +# CONFIG_BASE_FULL is not set
2372 +CONFIG_ANON_INODES=y
2378 +CONFIG_VM_EVENT_COUNTERS=y
2379 +CONFIG_SLUB_DEBUG=y
2380 +# CONFIG_SLAB is not set
2382 +# CONFIG_SLOB is not set
2384 +# CONFIG_MARKERS is not set
2386 +CONFIG_HAVE_OPROFILE=y
2388 +CONFIG_HAVE_KPROBES=y
2389 +# CONFIG_HAVE_KRETPROBES is not set
2390 +CONFIG_PROC_PAGE_MONITOR=y
2392 +CONFIG_RT_MUTEXES=y
2393 +# CONFIG_TINY_SHMEM is not set
2394 +CONFIG_BASE_SMALL=1
2396 +CONFIG_MODULE_UNLOAD=y
2397 +# CONFIG_MODULE_FORCE_UNLOAD is not set
2398 +# CONFIG_MODVERSIONS is not set
2399 +# CONFIG_MODULE_SRCVERSION_ALL is not set
2400 +# CONFIG_KMOD is not set
2402 +# CONFIG_LBD is not set
2403 +# CONFIG_BLK_DEV_IO_TRACE is not set
2404 +# CONFIG_LSF is not set
2405 +# CONFIG_BLK_DEV_BSG is not set
2410 +CONFIG_IOSCHED_NOOP=y
2411 +# CONFIG_IOSCHED_AS is not set
2412 +# CONFIG_IOSCHED_DEADLINE is not set
2413 +CONFIG_IOSCHED_CFQ=y
2414 +# CONFIG_DEFAULT_AS is not set
2415 +# CONFIG_DEFAULT_DEADLINE is not set
2416 +CONFIG_DEFAULT_CFQ=y
2417 +# CONFIG_DEFAULT_NOOP is not set
2418 +CONFIG_DEFAULT_IOSCHED="cfq"
2419 +CONFIG_CLASSIC_RCU=y
2422 +# System Type and features
2424 +CONFIG_TICK_ONESHOT=y
2426 +CONFIG_HIGH_RES_TIMERS=y
2427 +CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
2428 +CONFIG_SUBARCH_AVR32B=y
2430 +CONFIG_PERFORMANCE_COUNTERS=y
2431 +CONFIG_PLATFORM_AT32AP=y
2432 +CONFIG_CPU_AT32AP700X=y
2433 +CONFIG_CPU_AT32AP7000=y
2434 +CONFIG_BOARD_ATSTK1000=y
2435 +# CONFIG_BOARD_ATNGW100 is not set
2436 +# CONFIG_BOARD_ATSTK1002 is not set
2437 +# CONFIG_BOARD_ATSTK1003 is not set
2438 +# CONFIG_BOARD_ATSTK1004 is not set
2439 +CONFIG_BOARD_ATSTK1006=y
2440 +# CONFIG_BOARD_ATSTK100X_CUSTOM is not set
2441 +# CONFIG_BOARD_ATSTK100X_SPI1 is not set
2442 +# CONFIG_BOARD_ATSTK1000_J2_LED is not set
2443 +# CONFIG_BOARD_ATSTK1000_J2_LED8 is not set
2444 +# CONFIG_BOARD_ATSTK1000_J2_RGB is not set
2445 +CONFIG_BOARD_ATSTK1000_EXTDAC=y
2446 +# CONFIG_BOARD_ATSTK100X_ENABLE_AC97 is not set
2447 +# CONFIG_BOARD_ATSTK1000_CF_HACKS is not set
2448 +# CONFIG_BOARD_ATSTK100X_ENABLE_PSIF is not set
2449 +CONFIG_LOADER_U_BOOT=y
2452 +# Atmel AVR32 AP options
2454 +# CONFIG_AP700X_32_BIT_SMC is not set
2455 +CONFIG_AP700X_16_BIT_SMC=y
2456 +# CONFIG_AP700X_8_BIT_SMC is not set
2458 +CONFIG_LOAD_ADDRESS=0x10000000
2459 +CONFIG_ENTRY_ADDRESS=0x90000000
2460 +CONFIG_PHYS_OFFSET=0x10000000
2461 +CONFIG_PREEMPT_NONE=y
2462 +# CONFIG_PREEMPT_VOLUNTARY is not set
2463 +# CONFIG_PREEMPT is not set
2464 +# CONFIG_HAVE_ARCH_BOOTMEM_NODE is not set
2465 +# CONFIG_ARCH_HAVE_MEMORY_PRESENT is not set
2466 +# CONFIG_NEED_NODE_MEMMAP_SIZE is not set
2467 +CONFIG_ARCH_FLATMEM_ENABLE=y
2468 +# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
2469 +# CONFIG_ARCH_SPARSEMEM_ENABLE is not set
2470 +CONFIG_SELECT_MEMORY_MODEL=y
2471 +CONFIG_FLATMEM_MANUAL=y
2472 +# CONFIG_DISCONTIGMEM_MANUAL is not set
2473 +# CONFIG_SPARSEMEM_MANUAL is not set
2475 +CONFIG_FLAT_NODE_MEM_MAP=y
2476 +# CONFIG_SPARSEMEM_STATIC is not set
2477 +# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
2478 +CONFIG_SPLIT_PTLOCK_CPUS=4
2479 +# CONFIG_RESOURCES_64BIT is not set
2480 +CONFIG_ZONE_DMA_FLAG=0
2481 +CONFIG_VIRT_TO_BUS=y
2482 +# CONFIG_OWNERSHIP_TRACE is not set
2483 +CONFIG_NMI_DEBUGGING=y
2485 +# CONFIG_HZ_100 is not set
2487 +# CONFIG_HZ_300 is not set
2488 +# CONFIG_HZ_1000 is not set
2490 +# CONFIG_SCHED_HRTICK is not set
2494 +# Power management options
2496 +CONFIG_ARCH_SUSPEND_POSSIBLE=y
2498 +# CONFIG_PM_LEGACY is not set
2499 +# CONFIG_PM_DEBUG is not set
2502 +CONFIG_SUSPEND_FREEZER=y
2505 +# CPU Frequency scaling
2508 +CONFIG_CPU_FREQ_TABLE=y
2509 +# CONFIG_CPU_FREQ_DEBUG is not set
2510 +# CONFIG_CPU_FREQ_STAT is not set
2511 +# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
2512 +# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
2513 +CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
2514 +# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
2515 +CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
2516 +# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
2517 +CONFIG_CPU_FREQ_GOV_USERSPACE=y
2518 +CONFIG_CPU_FREQ_GOV_ONDEMAND=y
2519 +# CONFIG_CPU_FREQ_GOV_CONSERVATIVE is not set
2520 +CONFIG_CPU_FREQ_AT32AP=y
2525 +# CONFIG_ARCH_SUPPORTS_MSI is not set
2526 +# CONFIG_PCCARD is not set
2529 +# Executable file formats
2531 +CONFIG_BINFMT_ELF=y
2532 +# CONFIG_BINFMT_MISC is not set
2540 +# Networking options
2543 +CONFIG_PACKET_MMAP=y
2547 +# CONFIG_XFRM_SUB_POLICY is not set
2548 +# CONFIG_XFRM_MIGRATE is not set
2549 +# CONFIG_XFRM_STATISTICS is not set
2551 +# CONFIG_NET_KEY_MIGRATE is not set
2553 +# CONFIG_IP_MULTICAST is not set
2554 +# CONFIG_IP_ADVANCED_ROUTER is not set
2555 +CONFIG_IP_FIB_HASH=y
2557 +CONFIG_IP_PNP_DHCP=y
2558 +# CONFIG_IP_PNP_BOOTP is not set
2559 +# CONFIG_IP_PNP_RARP is not set
2562 +# CONFIG_ARPD is not set
2563 +# CONFIG_SYN_COOKIES is not set
2566 +# CONFIG_INET_IPCOMP is not set
2567 +# CONFIG_INET_XFRM_TUNNEL is not set
2568 +CONFIG_INET_TUNNEL=m
2569 +CONFIG_INET_XFRM_MODE_TRANSPORT=m
2570 +CONFIG_INET_XFRM_MODE_TUNNEL=m
2571 +CONFIG_INET_XFRM_MODE_BEET=m
2572 +# CONFIG_INET_LRO is not set
2574 +CONFIG_INET_TCP_DIAG=y
2575 +# CONFIG_TCP_CONG_ADVANCED is not set
2576 +CONFIG_TCP_CONG_CUBIC=y
2577 +CONFIG_DEFAULT_TCP_CONG="cubic"
2578 +# CONFIG_TCP_MD5SIG is not set
2580 +# CONFIG_IPV6_PRIVACY is not set
2581 +# CONFIG_IPV6_ROUTER_PREF is not set
2582 +# CONFIG_IPV6_OPTIMISTIC_DAD is not set
2585 +CONFIG_INET6_IPCOMP=m
2586 +# CONFIG_IPV6_MIP6 is not set
2587 +CONFIG_INET6_XFRM_TUNNEL=m
2588 +CONFIG_INET6_TUNNEL=m
2589 +CONFIG_INET6_XFRM_MODE_TRANSPORT=m
2590 +CONFIG_INET6_XFRM_MODE_TUNNEL=m
2591 +CONFIG_INET6_XFRM_MODE_BEET=m
2592 +# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
2594 +CONFIG_IPV6_TUNNEL=m
2595 +# CONFIG_IPV6_MULTIPLE_TABLES is not set
2596 +# CONFIG_NETWORK_SECMARK is not set
2597 +# CONFIG_NETFILTER is not set
2598 +# CONFIG_IP_DCCP is not set
2599 +# CONFIG_IP_SCTP is not set
2600 +# CONFIG_TIPC is not set
2601 +# CONFIG_ATM is not set
2603 +# CONFIG_VLAN_8021Q is not set
2604 +# CONFIG_DECNET is not set
2606 +# CONFIG_LLC2 is not set
2607 +# CONFIG_IPX is not set
2608 +# CONFIG_ATALK is not set
2609 +# CONFIG_X25 is not set
2610 +# CONFIG_LAPB is not set
2611 +# CONFIG_ECONET is not set
2612 +# CONFIG_WAN_ROUTER is not set
2613 +# CONFIG_NET_SCHED is not set
2618 +# CONFIG_NET_PKTGEN is not set
2619 +# CONFIG_NET_TCPPROBE is not set
2620 +# CONFIG_HAMRADIO is not set
2621 +# CONFIG_CAN is not set
2622 +# CONFIG_IRDA is not set
2623 +# CONFIG_BT is not set
2624 +# CONFIG_AF_RXRPC is not set
2629 +# CONFIG_CFG80211 is not set
2630 +# CONFIG_WIRELESS_EXT is not set
2631 +# CONFIG_MAC80211 is not set
2632 +# CONFIG_IEEE80211 is not set
2633 +# CONFIG_RFKILL is not set
2634 +# CONFIG_NET_9P is not set
2641 +# Generic Driver Options
2643 +CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
2644 +CONFIG_STANDALONE=y
2645 +# CONFIG_PREVENT_FIRMWARE_BUILD is not set
2646 +# CONFIG_FW_LOADER is not set
2647 +# CONFIG_DEBUG_DRIVER is not set
2648 +# CONFIG_DEBUG_DEVRES is not set
2649 +# CONFIG_SYS_HYPERVISOR is not set
2650 +# CONFIG_CONNECTOR is not set
2652 +# CONFIG_MTD_DEBUG is not set
2653 +# CONFIG_MTD_CONCAT is not set
2654 +CONFIG_MTD_PARTITIONS=y
2655 +# CONFIG_MTD_REDBOOT_PARTS is not set
2656 +CONFIG_MTD_CMDLINE_PARTS=y
2659 +# User Modules And Translation Layers
2662 +CONFIG_MTD_BLKDEVS=y
2664 +# CONFIG_FTL is not set
2665 +# CONFIG_NFTL is not set
2666 +# CONFIG_INFTL is not set
2667 +# CONFIG_RFD_FTL is not set
2668 +# CONFIG_SSFDC is not set
2669 +# CONFIG_MTD_OOPS is not set
2672 +# RAM/ROM/Flash chip drivers
2675 +# CONFIG_MTD_JEDECPROBE is not set
2676 +CONFIG_MTD_GEN_PROBE=y
2677 +# CONFIG_MTD_CFI_ADV_OPTIONS is not set
2678 +CONFIG_MTD_MAP_BANK_WIDTH_1=y
2679 +CONFIG_MTD_MAP_BANK_WIDTH_2=y
2680 +CONFIG_MTD_MAP_BANK_WIDTH_4=y
2681 +# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
2682 +# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
2683 +# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
2684 +CONFIG_MTD_CFI_I1=y
2685 +CONFIG_MTD_CFI_I2=y
2686 +# CONFIG_MTD_CFI_I4 is not set
2687 +# CONFIG_MTD_CFI_I8 is not set
2688 +# CONFIG_MTD_CFI_INTELEXT is not set
2689 +CONFIG_MTD_CFI_AMDSTD=y
2690 +# CONFIG_MTD_CFI_STAA is not set
2691 +CONFIG_MTD_CFI_UTIL=y
2692 +# CONFIG_MTD_RAM is not set
2693 +# CONFIG_MTD_ROM is not set
2694 +# CONFIG_MTD_ABSENT is not set
2697 +# Mapping drivers for chip access
2699 +# CONFIG_MTD_COMPLEX_MAPPINGS is not set
2700 +CONFIG_MTD_PHYSMAP=y
2701 +CONFIG_MTD_PHYSMAP_START=0x8000000
2702 +CONFIG_MTD_PHYSMAP_LEN=0x0
2703 +CONFIG_MTD_PHYSMAP_BANKWIDTH=2
2704 +# CONFIG_MTD_PLATRAM is not set
2707 +# Self-contained MTD device drivers
2709 +CONFIG_MTD_DATAFLASH=m
2710 +CONFIG_MTD_M25P80=m
2711 +# CONFIG_MTD_SLRAM is not set
2712 +# CONFIG_MTD_PHRAM is not set
2713 +# CONFIG_MTD_MTDRAM is not set
2714 +# CONFIG_MTD_BLOCK2MTD is not set
2717 +# Disk-On-Chip Device Drivers
2719 +# CONFIG_MTD_DOC2000 is not set
2720 +# CONFIG_MTD_DOC2001 is not set
2721 +# CONFIG_MTD_DOC2001PLUS is not set
2723 +# CONFIG_MTD_NAND_VERIFY_WRITE is not set
2724 +# CONFIG_MTD_NAND_ECC_SMC is not set
2725 +# CONFIG_MTD_NAND_MUSEUM_IDS is not set
2726 +CONFIG_MTD_NAND_IDS=y
2727 +# CONFIG_MTD_NAND_DISKONCHIP is not set
2728 +CONFIG_MTD_NAND_ATMEL=y
2729 +CONFIG_MTD_NAND_ATMEL_ECC_HW=y
2730 +# CONFIG_MTD_NAND_ATMEL_ECC_SOFT is not set
2731 +# CONFIG_MTD_NAND_ATMEL_ECC_NONE is not set
2732 +# CONFIG_MTD_NAND_NANDSIM is not set
2733 +# CONFIG_MTD_NAND_PLATFORM is not set
2734 +# CONFIG_MTD_ONENAND is not set
2737 +# UBI - Unsorted block images
2740 +CONFIG_MTD_UBI_WL_THRESHOLD=4096
2741 +CONFIG_MTD_UBI_BEB_RESERVE=1
2742 +CONFIG_MTD_UBI_GLUEBI=y
2745 +# UBI debugging options
2747 +# CONFIG_MTD_UBI_DEBUG is not set
2748 +# CONFIG_PARPORT is not set
2750 +# CONFIG_BLK_DEV_COW_COMMON is not set
2751 +CONFIG_BLK_DEV_LOOP=m
2752 +# CONFIG_BLK_DEV_CRYPTOLOOP is not set
2753 +CONFIG_BLK_DEV_NBD=m
2754 +CONFIG_BLK_DEV_RAM=m
2755 +CONFIG_BLK_DEV_RAM_COUNT=16
2756 +CONFIG_BLK_DEV_RAM_SIZE=4096
2757 +# CONFIG_BLK_DEV_XIP is not set
2758 +# CONFIG_CDROM_PKTCDVD is not set
2759 +# CONFIG_ATA_OVER_ETH is not set
2760 +CONFIG_MISC_DEVICES=y
2762 +CONFIG_ATMEL_TCLIB=y
2763 +CONFIG_ATMEL_TCB_CLKSRC=y
2764 +CONFIG_ATMEL_TCB_CLKSRC_BLOCK=0
2765 +# CONFIG_EEPROM_93CX6 is not set
2767 +# CONFIG_ENCLOSURE_SERVICES is not set
2768 +# CONFIG_HAVE_IDE is not set
2771 +# SCSI device support
2773 +# CONFIG_RAID_ATTRS is not set
2776 +# CONFIG_SCSI_TGT is not set
2777 +# CONFIG_SCSI_NETLINK is not set
2778 +# CONFIG_SCSI_PROC_FS is not set
2781 +# SCSI support type (disk, tape, CD-ROM)
2783 +CONFIG_BLK_DEV_SD=m
2784 +# CONFIG_CHR_DEV_ST is not set
2785 +# CONFIG_CHR_DEV_OSST is not set
2786 +CONFIG_BLK_DEV_SR=m
2787 +# CONFIG_BLK_DEV_SR_VENDOR is not set
2788 +# CONFIG_CHR_DEV_SG is not set
2789 +# CONFIG_CHR_DEV_SCH is not set
2792 +# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
2794 +# CONFIG_SCSI_MULTI_LUN is not set
2795 +# CONFIG_SCSI_CONSTANTS is not set
2796 +# CONFIG_SCSI_LOGGING is not set
2797 +# CONFIG_SCSI_SCAN_ASYNC is not set
2798 +CONFIG_SCSI_WAIT_SCAN=m
2803 +# CONFIG_SCSI_SPI_ATTRS is not set
2804 +# CONFIG_SCSI_FC_ATTRS is not set
2805 +# CONFIG_SCSI_ISCSI_ATTRS is not set
2806 +# CONFIG_SCSI_SAS_LIBSAS is not set
2807 +# CONFIG_SCSI_SRP_ATTRS is not set
2808 +# CONFIG_SCSI_LOWLEVEL is not set
2810 +# CONFIG_ATA_NONSTANDARD is not set
2811 +# CONFIG_SATA_MV is not set
2813 +# CONFIG_PATA_PLATFORM is not set
2814 +# CONFIG_MD is not set
2815 +CONFIG_NETDEVICES=y
2816 +# CONFIG_NETDEVICES_MULTIQUEUE is not set
2817 +# CONFIG_DUMMY is not set
2818 +# CONFIG_BONDING is not set
2819 +# CONFIG_MACVLAN is not set
2820 +# CONFIG_EQUALIZER is not set
2822 +# CONFIG_VETH is not set
2826 +# MII PHY device drivers
2828 +# CONFIG_MARVELL_PHY is not set
2829 +# CONFIG_DAVICOM_PHY is not set
2830 +# CONFIG_QSEMI_PHY is not set
2831 +# CONFIG_LXT_PHY is not set
2832 +# CONFIG_CICADA_PHY is not set
2833 +# CONFIG_VITESSE_PHY is not set
2834 +# CONFIG_SMSC_PHY is not set
2835 +# CONFIG_BROADCOM_PHY is not set
2836 +# CONFIG_ICPLUS_PHY is not set
2837 +# CONFIG_REALTEK_PHY is not set
2838 +# CONFIG_FIXED_PHY is not set
2839 +# CONFIG_MDIO_BITBANG is not set
2840 +CONFIG_NET_ETHERNET=y
2841 +# CONFIG_MII is not set
2843 +# CONFIG_ENC28J60 is not set
2844 +# CONFIG_IBM_NEW_EMAC_ZMII is not set
2845 +# CONFIG_IBM_NEW_EMAC_RGMII is not set
2846 +# CONFIG_IBM_NEW_EMAC_TAH is not set
2847 +# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
2848 +# CONFIG_B44 is not set
2849 +# CONFIG_NETDEV_1000 is not set
2850 +# CONFIG_NETDEV_10000 is not set
2855 +# CONFIG_WLAN_PRE80211 is not set
2856 +# CONFIG_WLAN_80211 is not set
2857 +# CONFIG_WAN is not set
2859 +# CONFIG_PPP_MULTILINK is not set
2860 +# CONFIG_PPP_FILTER is not set
2862 +# CONFIG_PPP_SYNC_TTY is not set
2863 +CONFIG_PPP_DEFLATE=m
2864 +CONFIG_PPP_BSDCOMP=m
2865 +# CONFIG_PPP_MPPE is not set
2866 +# CONFIG_PPPOE is not set
2867 +# CONFIG_PPPOL2TP is not set
2868 +# CONFIG_SLIP is not set
2870 +# CONFIG_NETCONSOLE is not set
2871 +# CONFIG_NETPOLL is not set
2872 +# CONFIG_NET_POLL_CONTROLLER is not set
2873 +# CONFIG_ISDN is not set
2874 +# CONFIG_PHONE is not set
2877 +# Input device support
2880 +# CONFIG_INPUT_FF_MEMLESS is not set
2881 +CONFIG_INPUT_POLLDEV=m
2884 +# Userland interfaces
2886 +CONFIG_INPUT_MOUSEDEV=m
2887 +CONFIG_INPUT_MOUSEDEV_PSAUX=y
2888 +CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
2889 +CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
2890 +# CONFIG_INPUT_JOYDEV is not set
2891 +CONFIG_INPUT_EVDEV=m
2892 +# CONFIG_INPUT_EVBUG is not set
2895 +# Input Device Drivers
2897 +CONFIG_INPUT_KEYBOARD=y
2898 +# CONFIG_KEYBOARD_ATKBD is not set
2899 +# CONFIG_KEYBOARD_SUNKBD is not set
2900 +# CONFIG_KEYBOARD_LKKBD is not set
2901 +# CONFIG_KEYBOARD_XTKBD is not set
2902 +# CONFIG_KEYBOARD_NEWTON is not set
2903 +# CONFIG_KEYBOARD_STOWAWAY is not set
2904 +CONFIG_KEYBOARD_GPIO=m
2905 +CONFIG_INPUT_MOUSE=y
2906 +# CONFIG_MOUSE_PS2 is not set
2907 +# CONFIG_MOUSE_SERIAL is not set
2908 +# CONFIG_MOUSE_VSXXXAA is not set
2909 +CONFIG_MOUSE_GPIO=m
2910 +# CONFIG_INPUT_JOYSTICK is not set
2911 +# CONFIG_INPUT_TABLET is not set
2912 +# CONFIG_INPUT_TOUCHSCREEN is not set
2913 +# CONFIG_INPUT_MISC is not set
2916 +# Hardware I/O ports
2918 +# CONFIG_SERIO is not set
2919 +# CONFIG_GAMEPORT is not set
2922 +# Character devices
2924 +# CONFIG_VT is not set
2925 +# CONFIG_SERIAL_NONSTANDARD is not set
2930 +# CONFIG_SERIAL_8250 is not set
2933 +# Non-8250 serial port support
2935 +CONFIG_SERIAL_ATMEL=y
2936 +CONFIG_SERIAL_ATMEL_CONSOLE=y
2937 +CONFIG_SERIAL_ATMEL_PDC=y
2938 +# CONFIG_SERIAL_ATMEL_TTYAT is not set
2939 +CONFIG_SERIAL_CORE=y
2940 +CONFIG_SERIAL_CORE_CONSOLE=y
2941 +CONFIG_UNIX98_PTYS=y
2942 +# CONFIG_LEGACY_PTYS is not set
2943 +# CONFIG_IPMI_HANDLER is not set
2944 +# CONFIG_HW_RANDOM is not set
2945 +# CONFIG_R3964 is not set
2946 +# CONFIG_RAW_DRIVER is not set
2947 +# CONFIG_TCG_TPM is not set
2949 +CONFIG_I2C_BOARDINFO=y
2950 +CONFIG_I2C_CHARDEV=m
2955 +CONFIG_I2C_ALGOBIT=m
2956 +# CONFIG_I2C_ALGOPCF is not set
2957 +# CONFIG_I2C_ALGOPCA is not set
2960 +# I2C Hardware Bus support
2962 +CONFIG_I2C_ATMELTWI=m
2964 +# CONFIG_I2C_OCORES is not set
2965 +# CONFIG_I2C_PARPORT_LIGHT is not set
2966 +# CONFIG_I2C_SIMTEC is not set
2967 +# CONFIG_I2C_TAOS_EVM is not set
2968 +# CONFIG_I2C_STUB is not set
2971 +# Miscellaneous I2C Chip support
2973 +# CONFIG_DS1682 is not set
2974 +# CONFIG_SENSORS_EEPROM is not set
2975 +# CONFIG_SENSORS_PCF8574 is not set
2976 +# CONFIG_PCF8575 is not set
2977 +# CONFIG_SENSORS_PCF8591 is not set
2978 +# CONFIG_TPS65010 is not set
2979 +# CONFIG_SENSORS_MAX6875 is not set
2980 +# CONFIG_SENSORS_TSL2550 is not set
2981 +# CONFIG_I2C_DEBUG_CORE is not set
2982 +# CONFIG_I2C_DEBUG_ALGO is not set
2983 +# CONFIG_I2C_DEBUG_BUS is not set
2984 +# CONFIG_I2C_DEBUG_CHIP is not set
2990 +# CONFIG_SPI_DEBUG is not set
2991 +CONFIG_SPI_MASTER=y
2994 +# SPI Master Controller Drivers
2997 +# CONFIG_SPI_BITBANG is not set
3000 +# SPI Protocol Masters
3002 +# CONFIG_SPI_AT25 is not set
3003 +CONFIG_SPI_SPIDEV=m
3004 +# CONFIG_SPI_TLE62X0 is not set
3005 +CONFIG_HAVE_GPIO_LIB=y
3010 +# CONFIG_DEBUG_GPIO is not set
3013 +# I2C GPIO expanders:
3015 +# CONFIG_GPIO_PCA953X is not set
3016 +# CONFIG_GPIO_PCF857X is not set
3019 +# SPI GPIO expanders:
3021 +# CONFIG_GPIO_MCP23S08 is not set
3022 +# CONFIG_W1 is not set
3023 +# CONFIG_POWER_SUPPLY is not set
3024 +# CONFIG_HWMON is not set
3025 +# CONFIG_THERMAL is not set
3027 +# CONFIG_WATCHDOG_NOWAYOUT is not set
3030 +# Watchdog Device Drivers
3032 +# CONFIG_SOFT_WATCHDOG is not set
3033 +CONFIG_AT32AP700X_WDT=y
3036 +# Sonics Silicon Backplane
3038 +CONFIG_SSB_POSSIBLE=y
3039 +# CONFIG_SSB is not set
3042 +# Multifunction device drivers
3044 +# CONFIG_MFD_SM501 is not set
3047 +# Multimedia devices
3049 +# CONFIG_VIDEO_DEV is not set
3050 +# CONFIG_DVB_CORE is not set
3051 +# CONFIG_DAB is not set
3056 +# CONFIG_VGASTATE is not set
3057 +# CONFIG_VIDEO_OUTPUT_CONTROL is not set
3059 +# CONFIG_FIRMWARE_EDID is not set
3060 +# CONFIG_FB_DDC is not set
3061 +CONFIG_FB_CFB_FILLRECT=y
3062 +CONFIG_FB_CFB_COPYAREA=y
3063 +CONFIG_FB_CFB_IMAGEBLIT=y
3064 +# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
3065 +# CONFIG_FB_SYS_FILLRECT is not set
3066 +# CONFIG_FB_SYS_COPYAREA is not set
3067 +# CONFIG_FB_SYS_IMAGEBLIT is not set
3068 +# CONFIG_FB_SYS_FOPS is not set
3069 +CONFIG_FB_DEFERRED_IO=y
3070 +# CONFIG_FB_SVGALIB is not set
3071 +# CONFIG_FB_MACMODES is not set
3072 +# CONFIG_FB_BACKLIGHT is not set
3073 +# CONFIG_FB_MODE_HELPERS is not set
3074 +# CONFIG_FB_TILEBLITTING is not set
3077 +# Frame buffer hardware drivers
3079 +# CONFIG_FB_S1D13XXX is not set
3081 +# CONFIG_FB_VIRTUAL is not set
3082 +CONFIG_BACKLIGHT_LCD_SUPPORT=y
3083 +CONFIG_LCD_CLASS_DEVICE=y
3084 +CONFIG_LCD_LTV350QV=y
3085 +# CONFIG_BACKLIGHT_CLASS_DEVICE is not set
3088 +# Display device support
3090 +# CONFIG_DISPLAY_SUPPORT is not set
3091 +# CONFIG_LOGO is not set
3099 +# Advanced Linux Sound Architecture
3104 +# CONFIG_SND_SEQUENCER is not set
3105 +CONFIG_SND_OSSEMUL=y
3106 +CONFIG_SND_MIXER_OSS=m
3107 +CONFIG_SND_PCM_OSS=m
3108 +CONFIG_SND_PCM_OSS_PLUGINS=y
3109 +# CONFIG_SND_DYNAMIC_MINORS is not set
3110 +# CONFIG_SND_SUPPORT_OLD_API is not set
3111 +# CONFIG_SND_VERBOSE_PROCFS is not set
3112 +# CONFIG_SND_VERBOSE_PRINTK is not set
3113 +# CONFIG_SND_DEBUG is not set
3118 +CONFIG_SND_AC97_CODEC=m
3119 +# CONFIG_SND_DUMMY is not set
3120 +# CONFIG_SND_MTPAV is not set
3121 +# CONFIG_SND_SERIAL_U16550 is not set
3122 +# CONFIG_SND_MPU401 is not set
3127 +CONFIG_SND_ATMEL_AC97=m
3132 +CONFIG_SND_AT73C213=m
3133 +CONFIG_SND_AT73C213_TARGET_BITRATE=48000
3136 +# System on Chip audio support
3138 +# CONFIG_SND_SOC is not set
3141 +# SoC Audio support for SuperH
3145 +# ALSA SoC audio for Freescale SOCs
3149 +# Open Sound System
3151 +# CONFIG_SOUND_PRIME is not set
3153 +# CONFIG_HID_SUPPORT is not set
3154 +CONFIG_USB_SUPPORT=y
3155 +# CONFIG_USB_ARCH_HAS_HCD is not set
3156 +# CONFIG_USB_ARCH_HAS_OHCI is not set
3157 +# CONFIG_USB_ARCH_HAS_EHCI is not set
3160 +# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
3162 +CONFIG_USB_GADGET=y
3163 +# CONFIG_USB_GADGET_DEBUG is not set
3164 +# CONFIG_USB_GADGET_DEBUG_FILES is not set
3165 +# CONFIG_USB_GADGET_DEBUG_FS is not set
3166 +CONFIG_USB_GADGET_SELECTED=y
3167 +# CONFIG_USB_GADGET_AMD5536UDC is not set
3168 +CONFIG_USB_GADGET_ATMEL_USBA=y
3169 +CONFIG_USB_ATMEL_USBA=y
3170 +# CONFIG_USB_GADGET_FSL_USB2 is not set
3171 +# CONFIG_USB_GADGET_NET2280 is not set
3172 +# CONFIG_USB_GADGET_PXA2XX is not set
3173 +# CONFIG_USB_GADGET_M66592 is not set
3174 +# CONFIG_USB_GADGET_GOKU is not set
3175 +# CONFIG_USB_GADGET_LH7A40X is not set
3176 +# CONFIG_USB_GADGET_OMAP is not set
3177 +# CONFIG_USB_GADGET_S3C2410 is not set
3178 +# CONFIG_USB_GADGET_AT91 is not set
3179 +# CONFIG_USB_GADGET_DUMMY_HCD is not set
3180 +CONFIG_USB_GADGET_DUALSPEED=y
3183 +CONFIG_USB_ETH_RNDIS=y
3184 +CONFIG_USB_GADGETFS=m
3185 +CONFIG_USB_FILE_STORAGE=m
3186 +# CONFIG_USB_FILE_STORAGE_TEST is not set
3187 +CONFIG_USB_G_SERIAL=m
3188 +# CONFIG_USB_MIDI_GADGET is not set
3189 +# CONFIG_USB_G_PRINTER is not set
3191 +# CONFIG_MMC_DEBUG is not set
3192 +# CONFIG_MMC_UNSAFE_RESUME is not set
3195 +# MMC/SD Card Drivers
3198 +CONFIG_MMC_BLOCK_BOUNCE=y
3199 +# CONFIG_SDIO_UART is not set
3202 +# MMC/SD Host Controller Drivers
3204 +CONFIG_MMC_ATMELMCI=y
3206 +# CONFIG_MEMSTICK is not set
3208 +CONFIG_LEDS_CLASS=m
3213 +CONFIG_LEDS_ATMEL_PWM=m
3219 +CONFIG_LEDS_TRIGGERS=y
3220 +CONFIG_LEDS_TRIGGER_TIMER=m
3221 +CONFIG_LEDS_TRIGGER_HEARTBEAT=m
3224 +CONFIG_RTC_HCTOSYS=y
3225 +CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
3226 +# CONFIG_RTC_DEBUG is not set
3231 +CONFIG_RTC_INTF_SYSFS=y
3232 +CONFIG_RTC_INTF_PROC=y
3233 +CONFIG_RTC_INTF_DEV=y
3234 +# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
3235 +# CONFIG_RTC_DRV_TEST is not set
3240 +# CONFIG_RTC_DRV_DS1307 is not set
3241 +# CONFIG_RTC_DRV_DS1374 is not set
3242 +# CONFIG_RTC_DRV_DS1672 is not set
3243 +# CONFIG_RTC_DRV_MAX6900 is not set
3244 +# CONFIG_RTC_DRV_RS5C372 is not set
3245 +# CONFIG_RTC_DRV_ISL1208 is not set
3246 +# CONFIG_RTC_DRV_X1205 is not set
3247 +# CONFIG_RTC_DRV_PCF8563 is not set
3248 +# CONFIG_RTC_DRV_PCF8583 is not set
3249 +# CONFIG_RTC_DRV_M41T80 is not set
3250 +# CONFIG_RTC_DRV_S35390A is not set
3255 +# CONFIG_RTC_DRV_MAX6902 is not set
3256 +# CONFIG_RTC_DRV_R9701 is not set
3257 +# CONFIG_RTC_DRV_RS5C348 is not set
3260 +# Platform RTC drivers
3262 +# CONFIG_RTC_DRV_DS1511 is not set
3263 +# CONFIG_RTC_DRV_DS1553 is not set
3264 +# CONFIG_RTC_DRV_DS1742 is not set
3265 +# CONFIG_RTC_DRV_STK17TA8 is not set
3266 +# CONFIG_RTC_DRV_M48T86 is not set
3267 +# CONFIG_RTC_DRV_M48T59 is not set
3268 +# CONFIG_RTC_DRV_V3020 is not set
3271 +# on-CPU RTC drivers
3273 +CONFIG_RTC_DRV_AT32AP700X=y
3278 +# CONFIG_UIO is not set
3284 +# CONFIG_EXT2_FS_XATTR is not set
3285 +# CONFIG_EXT2_FS_XIP is not set
3287 +# CONFIG_EXT3_FS_XATTR is not set
3288 +# CONFIG_EXT4DEV_FS is not set
3290 +# CONFIG_JBD_DEBUG is not set
3291 +# CONFIG_REISERFS_FS is not set
3292 +# CONFIG_JFS_FS is not set
3293 +# CONFIG_FS_POSIX_ACL is not set
3294 +# CONFIG_XFS_FS is not set
3295 +# CONFIG_GFS2_FS is not set
3296 +# CONFIG_OCFS2_FS is not set
3297 +# CONFIG_DNOTIFY is not set
3299 +CONFIG_INOTIFY_USER=y
3300 +# CONFIG_QUOTA is not set
3301 +# CONFIG_AUTOFS_FS is not set
3302 +# CONFIG_AUTOFS4_FS is not set
3306 +# CD-ROM/DVD Filesystems
3308 +# CONFIG_ISO9660_FS is not set
3309 +# CONFIG_UDF_FS is not set
3312 +# DOS/FAT/NT Filesystems
3317 +CONFIG_FAT_DEFAULT_CODEPAGE=437
3318 +CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
3319 +# CONFIG_NTFS_FS is not set
3322 +# Pseudo filesystems
3325 +CONFIG_PROC_KCORE=y
3326 +CONFIG_PROC_SYSCTL=y
3329 +# CONFIG_TMPFS_POSIX_ACL is not set
3330 +# CONFIG_HUGETLB_PAGE is not set
3331 +CONFIG_CONFIGFS_FS=y
3334 +# Miscellaneous filesystems
3336 +# CONFIG_ADFS_FS is not set
3337 +# CONFIG_AFFS_FS is not set
3338 +# CONFIG_HFS_FS is not set
3339 +# CONFIG_HFSPLUS_FS is not set
3340 +# CONFIG_BEFS_FS is not set
3341 +# CONFIG_BFS_FS is not set
3342 +# CONFIG_EFS_FS is not set
3344 +CONFIG_JFFS2_FS_DEBUG=0
3345 +# CONFIG_JFFS2_FS_WRITEBUFFER is not set
3346 +# CONFIG_JFFS2_SUMMARY is not set
3347 +# CONFIG_JFFS2_FS_XATTR is not set
3348 +# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
3349 +CONFIG_JFFS2_ZLIB=y
3350 +# CONFIG_JFFS2_LZO is not set
3351 +CONFIG_JFFS2_RTIME=y
3352 +# CONFIG_JFFS2_RUBIN is not set
3353 +# CONFIG_CRAMFS is not set
3354 +# CONFIG_VXFS_FS is not set
3356 +# CONFIG_HPFS_FS is not set
3357 +# CONFIG_QNX4FS_FS is not set
3358 +# CONFIG_ROMFS_FS is not set
3359 +# CONFIG_SYSV_FS is not set
3360 +# CONFIG_UFS_FS is not set
3361 +CONFIG_NETWORK_FILESYSTEMS=y
3364 +# CONFIG_NFS_V3_ACL is not set
3365 +# CONFIG_NFS_V4 is not set
3366 +# CONFIG_NFS_DIRECTIO is not set
3367 +# CONFIG_NFSD is not set
3371 +CONFIG_NFS_COMMON=y
3373 +# CONFIG_SUNRPC_BIND34 is not set
3374 +# CONFIG_RPCSEC_GSS_KRB5 is not set
3375 +# CONFIG_RPCSEC_GSS_SPKM3 is not set
3376 +# CONFIG_SMB_FS is not set
3377 +# CONFIG_CIFS is not set
3378 +# CONFIG_NCP_FS is not set
3379 +# CONFIG_CODA_FS is not set
3380 +# CONFIG_AFS_FS is not set
3385 +# CONFIG_PARTITION_ADVANCED is not set
3386 +CONFIG_MSDOS_PARTITION=y
3388 +CONFIG_NLS_DEFAULT="iso8859-1"
3389 +CONFIG_NLS_CODEPAGE_437=m
3390 +# CONFIG_NLS_CODEPAGE_737 is not set
3391 +# CONFIG_NLS_CODEPAGE_775 is not set
3392 +# CONFIG_NLS_CODEPAGE_850 is not set
3393 +# CONFIG_NLS_CODEPAGE_852 is not set
3394 +# CONFIG_NLS_CODEPAGE_855 is not set
3395 +# CONFIG_NLS_CODEPAGE_857 is not set
3396 +# CONFIG_NLS_CODEPAGE_860 is not set
3397 +# CONFIG_NLS_CODEPAGE_861 is not set
3398 +# CONFIG_NLS_CODEPAGE_862 is not set
3399 +# CONFIG_NLS_CODEPAGE_863 is not set
3400 +# CONFIG_NLS_CODEPAGE_864 is not set
3401 +# CONFIG_NLS_CODEPAGE_865 is not set
3402 +# CONFIG_NLS_CODEPAGE_866 is not set
3403 +# CONFIG_NLS_CODEPAGE_869 is not set
3404 +# CONFIG_NLS_CODEPAGE_936 is not set
3405 +# CONFIG_NLS_CODEPAGE_950 is not set
3406 +# CONFIG_NLS_CODEPAGE_932 is not set
3407 +# CONFIG_NLS_CODEPAGE_949 is not set
3408 +# CONFIG_NLS_CODEPAGE_874 is not set
3409 +# CONFIG_NLS_ISO8859_8 is not set
3410 +# CONFIG_NLS_CODEPAGE_1250 is not set
3411 +# CONFIG_NLS_CODEPAGE_1251 is not set
3412 +# CONFIG_NLS_ASCII is not set
3413 +CONFIG_NLS_ISO8859_1=m
3414 +# CONFIG_NLS_ISO8859_2 is not set
3415 +# CONFIG_NLS_ISO8859_3 is not set
3416 +# CONFIG_NLS_ISO8859_4 is not set
3417 +# CONFIG_NLS_ISO8859_5 is not set
3418 +# CONFIG_NLS_ISO8859_6 is not set
3419 +# CONFIG_NLS_ISO8859_7 is not set
3420 +# CONFIG_NLS_ISO8859_9 is not set
3421 +# CONFIG_NLS_ISO8859_13 is not set
3422 +# CONFIG_NLS_ISO8859_14 is not set
3423 +# CONFIG_NLS_ISO8859_15 is not set
3424 +# CONFIG_NLS_KOI8_R is not set
3425 +# CONFIG_NLS_KOI8_U is not set
3427 +# CONFIG_DLM is not set
3432 +# CONFIG_PRINTK_TIME is not set
3433 +CONFIG_ENABLE_WARN_DEPRECATED=y
3434 +CONFIG_ENABLE_MUST_CHECK=y
3435 +CONFIG_MAGIC_SYSRQ=y
3436 +# CONFIG_UNUSED_SYMBOLS is not set
3438 +# CONFIG_HEADERS_CHECK is not set
3439 +CONFIG_DEBUG_KERNEL=y
3440 +# CONFIG_DEBUG_SHIRQ is not set
3441 +CONFIG_DETECT_SOFTLOCKUP=y
3442 +CONFIG_SCHED_DEBUG=y
3443 +# CONFIG_SCHEDSTATS is not set
3444 +# CONFIG_TIMER_STATS is not set
3445 +# CONFIG_SLUB_DEBUG_ON is not set
3446 +# CONFIG_SLUB_STATS is not set
3447 +# CONFIG_DEBUG_RT_MUTEXES is not set
3448 +# CONFIG_RT_MUTEX_TESTER is not set
3449 +# CONFIG_DEBUG_SPINLOCK is not set
3450 +# CONFIG_DEBUG_MUTEXES is not set
3451 +# CONFIG_DEBUG_LOCK_ALLOC is not set
3452 +# CONFIG_PROVE_LOCKING is not set
3453 +# CONFIG_LOCK_STAT is not set
3454 +# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
3455 +# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
3456 +# CONFIG_DEBUG_KOBJECT is not set
3457 +CONFIG_DEBUG_BUGVERBOSE=y
3458 +# CONFIG_DEBUG_INFO is not set
3459 +# CONFIG_DEBUG_VM is not set
3460 +# CONFIG_DEBUG_LIST is not set
3461 +# CONFIG_DEBUG_SG is not set
3462 +CONFIG_FRAME_POINTER=y
3463 +# CONFIG_BOOT_PRINTK_DELAY is not set
3464 +# CONFIG_RCU_TORTURE_TEST is not set
3465 +# CONFIG_KPROBES_SANITY_TEST is not set
3466 +# CONFIG_BACKTRACE_SELF_TEST is not set
3467 +# CONFIG_LKDTM is not set
3468 +# CONFIG_FAULT_INJECTION is not set
3469 +# CONFIG_SAMPLES is not set
3474 +# CONFIG_KEYS is not set
3475 +# CONFIG_SECURITY is not set
3476 +# CONFIG_SECURITY_FILE_CAPABILITIES is not set
3478 +CONFIG_CRYPTO_ALGAPI=m
3479 +CONFIG_CRYPTO_AEAD=m
3480 +CONFIG_CRYPTO_BLKCIPHER=m
3481 +# CONFIG_CRYPTO_SEQIV is not set
3482 +CONFIG_CRYPTO_HASH=m
3483 +CONFIG_CRYPTO_MANAGER=m
3484 +CONFIG_CRYPTO_HMAC=m
3485 +# CONFIG_CRYPTO_XCBC is not set
3486 +# CONFIG_CRYPTO_NULL is not set
3487 +# CONFIG_CRYPTO_MD4 is not set
3488 +CONFIG_CRYPTO_MD5=m
3489 +CONFIG_CRYPTO_SHA1=m
3490 +# CONFIG_CRYPTO_SHA256 is not set
3491 +# CONFIG_CRYPTO_SHA512 is not set
3492 +# CONFIG_CRYPTO_WP512 is not set
3493 +# CONFIG_CRYPTO_TGR192 is not set
3494 +# CONFIG_CRYPTO_GF128MUL is not set
3495 +# CONFIG_CRYPTO_ECB is not set
3496 +CONFIG_CRYPTO_CBC=m
3497 +# CONFIG_CRYPTO_PCBC is not set
3498 +# CONFIG_CRYPTO_LRW is not set
3499 +# CONFIG_CRYPTO_XTS is not set
3500 +# CONFIG_CRYPTO_CTR is not set
3501 +# CONFIG_CRYPTO_GCM is not set
3502 +# CONFIG_CRYPTO_CCM is not set
3503 +# CONFIG_CRYPTO_CRYPTD is not set
3504 +CONFIG_CRYPTO_DES=m
3505 +# CONFIG_CRYPTO_FCRYPT is not set
3506 +# CONFIG_CRYPTO_BLOWFISH is not set
3507 +# CONFIG_CRYPTO_TWOFISH is not set
3508 +# CONFIG_CRYPTO_SERPENT is not set
3509 +# CONFIG_CRYPTO_AES is not set
3510 +# CONFIG_CRYPTO_CAST5 is not set
3511 +# CONFIG_CRYPTO_CAST6 is not set
3512 +# CONFIG_CRYPTO_TEA is not set
3513 +# CONFIG_CRYPTO_ARC4 is not set
3514 +# CONFIG_CRYPTO_KHAZAD is not set
3515 +# CONFIG_CRYPTO_ANUBIS is not set
3516 +# CONFIG_CRYPTO_SEED is not set
3517 +# CONFIG_CRYPTO_SALSA20 is not set
3518 +CONFIG_CRYPTO_DEFLATE=m
3519 +# CONFIG_CRYPTO_MICHAEL_MIC is not set
3520 +# CONFIG_CRYPTO_CRC32C is not set
3521 +# CONFIG_CRYPTO_CAMELLIA is not set
3522 +# CONFIG_CRYPTO_TEST is not set
3523 +CONFIG_CRYPTO_AUTHENC=m
3524 +# CONFIG_CRYPTO_LZO is not set
3525 +# CONFIG_CRYPTO_HW is not set
3530 +CONFIG_BITREVERSE=y
3532 +# CONFIG_CRC16 is not set
3536 +# CONFIG_LIBCRC32C is not set
3537 +CONFIG_ZLIB_INFLATE=y
3538 +CONFIG_ZLIB_DEFLATE=y
3539 +CONFIG_GENERIC_ALLOCATOR=y
3542 +CONFIG_HAS_IOPORT=y
3545 +++ b/arch/avr32/drivers/dw-dmac.c
3548 + * Driver for the Synopsys DesignWare DMA Controller
3550 + * Copyright (C) 2005-2006 Atmel Corporation
3552 + * This program is free software; you can redistribute it and/or modify
3553 + * it under the terms of the GNU General Public License version 2 as
3554 + * published by the Free Software Foundation.
3556 +#include <linux/clk.h>
3557 +#include <linux/device.h>
3558 +#include <linux/dma-mapping.h>
3559 +#include <linux/dmapool.h>
3560 +#include <linux/init.h>
3561 +#include <linux/interrupt.h>
3562 +#include <linux/module.h>
3563 +#include <linux/platform_device.h>
3565 +#include <asm/dma-controller.h>
3566 +#include <asm/io.h>
3568 +#include "dw-dmac.h"
3570 +#define DMAC_NR_CHANNELS 3
3571 +#define DMAC_MAX_BLOCKSIZE 4095
3574 + CH_STATE_FREE = 0,
3575 + CH_STATE_ALLOCATED,
3579 +struct dw_dma_lli {
3589 +struct dw_dma_block {
3590 + struct dw_dma_lli *lli_vaddr;
3591 + dma_addr_t lli_dma_addr;
3594 +struct dw_dma_channel {
3595 + unsigned int state;
3597 + struct dma_request_sg *req_sg;
3598 + struct dma_request_cyclic *req_cyclic;
3599 + unsigned int nr_blocks;
3601 + struct dw_dma_block *block;
3604 +struct dw_dma_controller {
3606 + void * __iomem regs;
3607 + struct dma_pool *lli_pool;
3609 + struct dma_controller dma;
3610 + struct dw_dma_channel channel[DMAC_NR_CHANNELS];
3612 +#define to_dw_dmac(dmac) container_of(dmac, struct dw_dma_controller, dma)
3614 +#define dmac_writel_hi(dmac, reg, value) \
3615 + __raw_writel((value), (dmac)->regs + DW_DMAC_##reg + 4)
3616 +#define dmac_readl_hi(dmac, reg) \
3617 + __raw_readl((dmac)->regs + DW_DMAC_##reg + 4)
3618 +#define dmac_writel_lo(dmac, reg, value) \
3619 + __raw_writel((value), (dmac)->regs + DW_DMAC_##reg)
3620 +#define dmac_readl_lo(dmac, reg) \
3621 + __raw_readl((dmac)->regs + DW_DMAC_##reg)
3622 +#define dmac_chan_writel_hi(dmac, chan, reg, value) \
3623 + __raw_writel((value), ((dmac)->regs + 0x58 * (chan) \
3624 + + DW_DMAC_CHAN_##reg + 4))
3625 +#define dmac_chan_readl_hi(dmac, chan, reg) \
3626 + __raw_readl((dmac)->regs + 0x58 * (chan) + DW_DMAC_CHAN_##reg + 4)
3627 +#define dmac_chan_writel_lo(dmac, chan, reg, value) \
3628 + __raw_writel((value), (dmac)->regs + 0x58 * (chan) + DW_DMAC_CHAN_##reg)
3629 +#define dmac_chan_readl_lo(dmac, chan, reg) \
3630 + __raw_readl((dmac)->regs + 0x58 * (chan) + DW_DMAC_CHAN_##reg)
3631 +#define set_channel_bit(dmac, reg, chan) \
3632 + dmac_writel_lo(dmac, reg, (1 << (chan)) | (1 << ((chan) + 8)))
3633 +#define clear_channel_bit(dmac, reg, chan) \
3634 + dmac_writel_lo(dmac, reg, (0 << (chan)) | (1 << ((chan) + 8)))
3636 +static int dmac_alloc_channel(struct dma_controller *_dmac)
3638 + struct dw_dma_controller *dmac = to_dw_dmac(_dmac);
3639 + struct dw_dma_channel *chan;
3640 + unsigned long flags;
3643 + spin_lock_irqsave(&dmac->lock, flags);
3644 + for (i = 0; i < DMAC_NR_CHANNELS; i++)
3645 + if (dmac->channel[i].state == CH_STATE_FREE)
3648 + if (i < DMAC_NR_CHANNELS) {
3649 + chan = &dmac->channel[i];
3650 + chan->state = CH_STATE_ALLOCATED;
3655 + spin_unlock_irqrestore(&dmac->lock, flags);
3660 +static void dmac_release_channel(struct dma_controller *_dmac, int channel)
3662 + struct dw_dma_controller *dmac = to_dw_dmac(_dmac);
3664 + BUG_ON(channel >= DMAC_NR_CHANNELS
3665 + || dmac->channel[channel].state != CH_STATE_ALLOCATED);
3667 + dmac->channel[channel].state = CH_STATE_FREE;
3670 +static struct dw_dma_block *allocate_blocks(struct dw_dma_controller *dmac,
3671 + unsigned int nr_blocks)
3673 + struct dw_dma_block *block;
3677 + block = kmalloc(nr_blocks * sizeof(*block),
3679 + if (unlikely(!block))
3682 + for (i = 0; i < nr_blocks; i++) {
3683 + p = dma_pool_alloc(dmac->lli_pool, GFP_KERNEL,
3684 + &block[i].lli_dma_addr);
3685 + block[i].lli_vaddr = p;
3693 + for (i = 0; i < nr_blocks; i++) {
3694 + if (!block[i].lli_vaddr)
3696 + dma_pool_free(dmac->lli_pool, block[i].lli_vaddr,
3697 + block[i].lli_dma_addr);
3703 +static void cleanup_channel(struct dw_dma_controller *dmac,
3704 + struct dw_dma_channel *chan)
3708 + if (chan->nr_blocks > 1) {
3709 + for (i = 0; i < chan->nr_blocks; i++)
3710 + dma_pool_free(dmac->lli_pool, chan->block[i].lli_vaddr,
3711 + chan->block[i].lli_dma_addr);
3712 + kfree(chan->block);
3715 + chan->state = CH_STATE_ALLOCATED;
3718 +static int dmac_prepare_request_sg(struct dma_controller *_dmac,
3719 + struct dma_request_sg *req)
3721 + struct dw_dma_controller *dmac = to_dw_dmac(_dmac);
3722 + struct dw_dma_channel *chan;
3723 + unsigned long ctlhi, ctllo, cfghi, cfglo;
3724 + unsigned long block_size;
3725 + unsigned int nr_blocks;
3726 + int ret, i, direction;
3727 + unsigned long flags;
3729 + spin_lock_irqsave(&dmac->lock, flags);
3732 + if (req->req.channel >= DMAC_NR_CHANNELS
3733 + || dmac->channel[req->req.channel].state != CH_STATE_ALLOCATED
3734 + || req->block_size > DMAC_MAX_BLOCKSIZE) {
3735 + spin_unlock_irqrestore(&dmac->lock, flags);
3739 + chan = &dmac->channel[req->req.channel];
3740 + chan->state = CH_STATE_BUSY;
3741 + chan->req_sg = req;
3742 + chan->is_cyclic = 0;
3745 + * We have marked the channel as busy, so no need to keep the
3746 + * lock as long as we only touch the channel-specific
3749 + spin_unlock_irqrestore(&dmac->lock, flags);
3752 + * There may be limitations in the driver and/or the DMA
3753 + * controller that prevents us from sending a whole
3754 + * scatterlist item in one go. Taking this into account,
3755 + * calculate the number of block transfers we need to set up.
3757 + * FIXME: Let the peripheral driver know about the maximum
3758 + * block size we support. We really don't want to use a
3759 + * different block size than what was suggested by the
3762 + * Each block will get its own Linked List Item (LLI) below.
3764 + block_size = req->block_size;
3765 + nr_blocks = req->nr_blocks;
3766 + pr_debug("block_size %lu, nr_blocks %u nr_sg = %u\n",
3767 + block_size, nr_blocks, req->nr_sg);
3769 + BUG_ON(nr_blocks == 0);
3770 + chan->nr_blocks = nr_blocks;
3773 + cfglo = cfghi = 0;
3774 + switch (req->direction) {
3775 + case DMA_DIR_MEM_TO_PERIPH:
3776 + direction = DMA_TO_DEVICE;
3777 + cfghi = req->periph_id << (43 - 32);
3780 + case DMA_DIR_PERIPH_TO_MEM:
3781 + direction = DMA_FROM_DEVICE;
3782 + cfghi = req->periph_id << (39 - 32);
3785 + goto out_unclaim_channel;
3788 + chan->direction = direction;
3790 + dmac_chan_writel_hi(dmac, req->req.channel, CFG, cfghi);
3791 + dmac_chan_writel_lo(dmac, req->req.channel, CFG, cfglo);
3793 + ctlhi = block_size >> req->width;
3794 + ctllo = ((req->direction << 20)
3795 + // | (1 << 14) | (1 << 11) // source/dest burst trans len
3796 + | (req->width << 4) | (req->width << 1)
3797 + | (1 << 0)); // interrupt enable
3799 + if (nr_blocks == 1) {
3800 + /* Only one block: No need to use block chaining */
3801 + if (direction == DMA_TO_DEVICE) {
3802 + dmac_chan_writel_lo(dmac, req->req.channel, SAR,
3803 + req->sg->dma_address);
3804 + dmac_chan_writel_lo(dmac, req->req.channel, DAR,
3806 + ctllo |= 2 << 7; // no dst increment
3808 + dmac_chan_writel_lo(dmac, req->req.channel, SAR,
3810 + dmac_chan_writel_lo(dmac, req->req.channel, DAR,
3811 + req->sg->dma_address);
3812 + ctllo |= 2 << 9; // no src increment
3814 + dmac_chan_writel_lo(dmac, req->req.channel, CTL, ctllo);
3815 + dmac_chan_writel_hi(dmac, req->req.channel, CTL, ctlhi);
3816 + pr_debug("ctl hi:lo 0x%lx:%lx\n", ctlhi, ctllo);
3818 + struct dw_dma_lli *lli, *lli_prev = NULL;
3819 + int j = 0, offset = 0;
3822 + chan->block = allocate_blocks(dmac, nr_blocks);
3824 + goto out_unclaim_channel;
3826 + if (direction == DMA_TO_DEVICE)
3827 + ctllo |= 1 << 28 | 1 << 27 | 2 << 7;
3829 + ctllo |= 1 << 28 | 1 << 27 | 2 << 9;
3832 + * Map scatterlist items to blocks. One scatterlist
3833 + * item may need more than one block for the reasons
3834 + * mentioned above.
3836 + for (i = 0; i < nr_blocks; i++) {
3837 + lli = chan->block[i].lli_vaddr;
3839 + lli_prev->llp = chan->block[i].lli_dma_addr;
3840 + pr_debug("lli[%d] (0x%p/0x%x): 0x%x 0x%x 0x%x 0x%x 0x%x\n",
3841 + i - 1, chan->block[i - 1].lli_vaddr,
3842 + chan->block[i - 1].lli_dma_addr,
3843 + lli_prev->sar, lli_prev->dar, lli_prev->llp,
3844 + lli_prev->ctllo, lli_prev->ctlhi);
3847 + lli->ctllo = ctllo;
3848 + lli->ctlhi = ctlhi;
3849 + if (direction == DMA_TO_DEVICE) {
3850 + lli->sar = req->sg[j].dma_address + offset;
3851 + lli->dar = req->data_reg;
3853 + lli->sar = req->data_reg;
3854 + lli->dar = req->sg[j].dma_address + offset;
3858 + offset += block_size;
3859 + if (offset > req->sg[j].length) {
3865 + pr_debug("lli[%d] (0x%p/0x%x): 0x%x 0x%x 0x%x 0x%x 0x%x\n",
3866 + i - 1, chan->block[i - 1].lli_vaddr,
3867 + chan->block[i - 1].lli_dma_addr, lli_prev->sar,
3868 + lli_prev->dar, lli_prev->llp,
3869 + lli_prev->ctllo, lli_prev->ctlhi);
3872 + * SAR, DAR and CTL are initialized from the LLI. We
3873 + * only have to enable the LLI bits in CTL.
3875 + dmac_chan_writel_hi(dmac, req->req.channel, CTL, 0);
3876 + dmac_chan_writel_lo(dmac, req->req.channel, LLP,
3877 + chan->block[0].lli_dma_addr);
3878 + dmac_chan_writel_lo(dmac, req->req.channel, CTL, 1 << 28 | 1 << 27);
3881 + set_channel_bit(dmac, MASK_XFER, req->req.channel);
3882 + set_channel_bit(dmac, MASK_ERROR, req->req.channel);
3883 + if (req->req.block_complete)
3884 + set_channel_bit(dmac, MASK_BLOCK, req->req.channel);
3886 + clear_channel_bit(dmac, MASK_BLOCK, req->req.channel);
3890 +out_unclaim_channel:
3891 + chan->state = CH_STATE_ALLOCATED;
3895 +static int dmac_prepare_request_cyclic(struct dma_controller *_dmac,
3896 + struct dma_request_cyclic *req)
3898 + struct dw_dma_controller *dmac = to_dw_dmac(_dmac);
3899 + struct dw_dma_channel *chan;
3900 + unsigned long ctlhi, ctllo, cfghi, cfglo;
3901 + unsigned long block_size;
3902 + int ret, i, direction;
3903 + unsigned long flags;
3905 + spin_lock_irqsave(&dmac->lock, flags);
3907 + block_size = (req->buffer_size/req->periods) >> req->width;
3910 + if (req->req.channel >= DMAC_NR_CHANNELS
3911 + || dmac->channel[req->req.channel].state != CH_STATE_ALLOCATED
3912 + || (req->periods == 0)
3913 + || block_size > DMAC_MAX_BLOCKSIZE) {
3914 + spin_unlock_irqrestore(&dmac->lock, flags);
3918 + chan = &dmac->channel[req->req.channel];
3919 + chan->state = CH_STATE_BUSY;
3920 + chan->is_cyclic = 1;
3921 + chan->req_cyclic = req;
3924 + * We have marked the channel as busy, so no need to keep the
3925 + * lock as long as we only touch the channel-specific
3928 + spin_unlock_irqrestore(&dmac->lock, flags);
3933 + BUG_ON(req->buffer_size % req->periods);
3934 + /* printk(KERN_INFO "block_size = %lu, periods = %u\n", block_size, req->periods); */
3936 + chan->nr_blocks = req->periods;
3939 + cfglo = cfghi = 0;
3940 + switch (req->direction) {
3941 + case DMA_DIR_MEM_TO_PERIPH:
3942 + direction = DMA_TO_DEVICE;
3943 + cfghi = req->periph_id << (43 - 32);
3946 + case DMA_DIR_PERIPH_TO_MEM:
3947 + direction = DMA_FROM_DEVICE;
3948 + cfghi = req->periph_id << (39 - 32);
3951 + goto out_unclaim_channel;
3954 + chan->direction = direction;
3956 + dmac_chan_writel_hi(dmac, req->req.channel, CFG, cfghi);
3957 + dmac_chan_writel_lo(dmac, req->req.channel, CFG, cfglo);
3959 + ctlhi = block_size;
3960 + ctllo = ((req->direction << 20)
3961 + | (req->width << 4) | (req->width << 1)
3962 + | (1 << 0)); // interrupt enable
3965 + struct dw_dma_lli *lli = NULL, *lli_prev = NULL;
3968 + chan->block = allocate_blocks(dmac, req->periods);
3970 + goto out_unclaim_channel;
3972 + if (direction == DMA_TO_DEVICE)
3973 + ctllo |= 1 << 28 | 1 << 27 | 2 << 7;
3975 + ctllo |= 1 << 28 | 1 << 27 | 2 << 9;
3978 + * Set up a linked list items where each period gets
3979 + * an item. The linked list item for the last period
3980 + * points back to the star of the buffer making a
3983 + for (i = 0; i < req->periods; i++) {
3984 + lli = chan->block[i].lli_vaddr;
3986 + lli_prev->llp = chan->block[i].lli_dma_addr;
3987 + /* printk(KERN_INFO "lli[%d] (0x%p/0x%x): 0x%x 0x%x 0x%x 0x%x 0x%x\n",
3988 + i - 1, chan->block[i - 1].lli_vaddr,
3989 + chan->block[i - 1].lli_dma_addr,
3990 + lli_prev->sar, lli_prev->dar, lli_prev->llp,
3991 + lli_prev->ctllo, lli_prev->ctlhi);*/
3994 + lli->ctllo = ctllo;
3995 + lli->ctlhi = ctlhi;
3996 + if (direction == DMA_TO_DEVICE) {
3997 + lli->sar = req->buffer_start + i*(block_size << req->width);
3998 + lli->dar = req->data_reg;
4000 + lli->sar = req->data_reg;
4001 + lli->dar = req->buffer_start + i*(block_size << req->width);
4005 + lli->llp = chan->block[0].lli_dma_addr;
4007 + /*printk(KERN_INFO "lli[%d] (0x%p/0x%x): 0x%x 0x%x 0x%x 0x%x 0x%x\n",
4008 + i - 1, chan->block[i - 1].lli_vaddr,
4009 + chan->block[i - 1].lli_dma_addr, lli_prev->sar,
4010 + lli_prev->dar, lli_prev->llp,
4011 + lli_prev->ctllo, lli_prev->ctlhi); */
4014 + * SAR, DAR and CTL are initialized from the LLI. We
4015 + * only have to enable the LLI bits in CTL.
4017 + dmac_chan_writel_lo(dmac, req->req.channel, LLP,
4018 + chan->block[0].lli_dma_addr);
4019 + dmac_chan_writel_lo(dmac, req->req.channel, CTL, 1 << 28 | 1 << 27);
4022 + clear_channel_bit(dmac, MASK_XFER, req->req.channel);
4023 + set_channel_bit(dmac, MASK_ERROR, req->req.channel);
4024 + if (req->req.block_complete)
4025 + set_channel_bit(dmac, MASK_BLOCK, req->req.channel);
4027 + clear_channel_bit(dmac, MASK_BLOCK, req->req.channel);
4031 +out_unclaim_channel:
4032 + chan->state = CH_STATE_ALLOCATED;
4036 +static int dmac_start_request(struct dma_controller *_dmac,
4037 + unsigned int channel)
4039 + struct dw_dma_controller *dmac = to_dw_dmac(_dmac);
4041 + BUG_ON(channel >= DMAC_NR_CHANNELS);
4043 + set_channel_bit(dmac, CH_EN, channel);
4048 +static dma_addr_t dmac_get_current_pos(struct dma_controller *_dmac,
4049 + unsigned int channel)
4051 + struct dw_dma_controller *dmac = to_dw_dmac(_dmac);
4052 + struct dw_dma_channel *chan;
4053 + dma_addr_t current_pos;
4055 + BUG_ON(channel >= DMAC_NR_CHANNELS);
4057 + chan = &dmac->channel[channel];
4059 + switch (chan->direction) {
4060 + case DMA_TO_DEVICE:
4061 + current_pos = dmac_chan_readl_lo(dmac, channel, SAR);
4063 + case DMA_FROM_DEVICE:
4064 + current_pos = dmac_chan_readl_lo(dmac, channel, DAR);
4071 + if (!current_pos) {
4072 + if (chan->is_cyclic) {
4073 + current_pos = chan->req_cyclic->buffer_start;
4075 + current_pos = chan->req_sg->sg->dma_address;
4079 + return current_pos;
4083 +static int dmac_stop_request(struct dma_controller *_dmac,
4084 + unsigned int channel)
4086 + struct dw_dma_controller *dmac = to_dw_dmac(_dmac);
4087 + struct dw_dma_channel *chan;
4089 + BUG_ON(channel >= DMAC_NR_CHANNELS);
4091 + chan = &dmac->channel[channel];
4092 + pr_debug("stop: st%u s%08x d%08x l%08x ctl0x%08x:0x%08x\n",
4093 + chan->state, dmac_chan_readl_lo(dmac, channel, SAR),
4094 + dmac_chan_readl_lo(dmac, channel, DAR),
4095 + dmac_chan_readl_lo(dmac, channel, LLP),
4096 + dmac_chan_readl_hi(dmac, channel, CTL),
4097 + dmac_chan_readl_lo(dmac, channel, CTL));
4099 + if (chan->state == CH_STATE_BUSY) {
4100 + clear_channel_bit(dmac, CH_EN, channel);
4101 + cleanup_channel(dmac, &dmac->channel[channel]);
4108 +static void dmac_block_complete(struct dw_dma_controller *dmac)
4110 + struct dw_dma_channel *chan;
4111 + unsigned long status, chanid;
4113 + status = dmac_readl_lo(dmac, STATUS_BLOCK);
4116 + struct dma_request *req;
4117 + chanid = __ffs(status);
4118 + chan = &dmac->channel[chanid];
4120 + if (chan->is_cyclic) {
4121 + BUG_ON(!chan->req_cyclic
4122 + || !chan->req_cyclic->req.block_complete);
4123 + req = &chan->req_cyclic->req;
4125 + BUG_ON(!chan->req_sg || !chan->req_sg->req.block_complete);
4126 + req = &chan->req_sg->req;
4128 + dmac_writel_lo(dmac, CLEAR_BLOCK, 1 << chanid);
4129 + req->block_complete(req);
4130 + status = dmac_readl_lo(dmac, STATUS_BLOCK);
4134 +static void dmac_xfer_complete(struct dw_dma_controller *dmac)
4136 + struct dw_dma_channel *chan;
4137 + struct dma_request *req;
4138 + unsigned long status, chanid;
4140 + status = dmac_readl_lo(dmac, STATUS_XFER);
4143 + chanid = __ffs(status);
4144 + chan = &dmac->channel[chanid];
4146 + dmac_writel_lo(dmac, CLEAR_XFER, 1 << chanid);
4148 + req = &chan->req_sg->req;
4150 + cleanup_channel(dmac, chan);
4151 + if (req->xfer_complete)
4152 + req->xfer_complete(req);
4154 + status = dmac_readl_lo(dmac, STATUS_XFER);
4158 +static void dmac_error(struct dw_dma_controller *dmac)
4160 + struct dw_dma_channel *chan;
4161 + unsigned long status, chanid;
4163 + status = dmac_readl_lo(dmac, STATUS_ERROR);
4166 + struct dma_request *req;
4168 + chanid = __ffs(status);
4169 + chan = &dmac->channel[chanid];
4171 + dmac_writel_lo(dmac, CLEAR_ERROR, 1 << chanid);
4172 + clear_channel_bit(dmac, CH_EN, chanid);
4174 + if (chan->is_cyclic) {
4175 + BUG_ON(!chan->req_cyclic);
4176 + req = &chan->req_cyclic->req;
4178 + BUG_ON(!chan->req_sg);
4179 + req = &chan->req_sg->req;
4182 + cleanup_channel(dmac, chan);
4186 + status = dmac_readl_lo(dmac, STATUS_XFER);
4190 +static irqreturn_t dmac_interrupt(int irq, void *dev_id)
4192 + struct dw_dma_controller *dmac = dev_id;
4193 + unsigned long status;
4194 + int ret = IRQ_NONE;
4196 + spin_lock(&dmac->lock);
4198 + status = dmac_readl_lo(dmac, STATUS_INT);
4201 + ret = IRQ_HANDLED;
4202 + if (status & 0x10)
4204 + if (status & 0x02)
4205 + dmac_block_complete(dmac);
4206 + if (status & 0x01)
4207 + dmac_xfer_complete(dmac);
4209 + status = dmac_readl_lo(dmac, STATUS_INT);
4212 + spin_unlock(&dmac->lock);
4216 +static int __devinit dmac_probe(struct platform_device *pdev)
4218 + struct dw_dma_controller *dmac;
4219 + struct resource *regs;
4222 + regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
4226 + dmac = kmalloc(sizeof(*dmac), GFP_KERNEL);
4229 + memset(dmac, 0, sizeof(*dmac));
4231 + dmac->hclk = clk_get(&pdev->dev, "hclk");
4232 + if (IS_ERR(dmac->hclk)) {
4233 + ret = PTR_ERR(dmac->hclk);
4234 + goto out_free_dmac;
4236 + clk_enable(dmac->hclk);
4239 + dmac->lli_pool = dma_pool_create("dmac", &pdev->dev,
4240 + sizeof(struct dw_dma_lli), 4, 0);
4241 + if (!dmac->lli_pool)
4242 + goto out_disable_clk;
4244 + spin_lock_init(&dmac->lock);
4245 + dmac->dma.dev = &pdev->dev;
4246 + dmac->dma.alloc_channel = dmac_alloc_channel;
4247 + dmac->dma.release_channel = dmac_release_channel;
4248 + dmac->dma.prepare_request_sg = dmac_prepare_request_sg;
4249 + dmac->dma.prepare_request_cyclic = dmac_prepare_request_cyclic;
4250 + dmac->dma.start_request = dmac_start_request;
4251 + dmac->dma.stop_request = dmac_stop_request;
4252 + dmac->dma.get_current_pos = dmac_get_current_pos;
4254 + dmac->regs = ioremap(regs->start, regs->end - regs->start + 1);
4256 + goto out_free_pool;
4258 + ret = request_irq(platform_get_irq(pdev, 0), dmac_interrupt,
4259 + IRQF_SAMPLE_RANDOM, pdev->name, dmac);
4261 + goto out_unmap_regs;
4263 + /* Enable the DMA controller */
4264 + dmac_writel_lo(dmac, CFG, 1);
4266 + register_dma_controller(&dmac->dma);
4269 + "dmac%d: DesignWare DMA controller at 0x%p irq %d\n",
4270 + dmac->dma.id, dmac->regs, platform_get_irq(pdev, 0));
4275 + iounmap(dmac->regs);
4277 + dma_pool_destroy(dmac->lli_pool);
4279 + clk_disable(dmac->hclk);
4280 + clk_put(dmac->hclk);
4286 +static struct platform_driver dmac_driver = {
4287 + .probe = dmac_probe,
4293 +static int __init dmac_init(void)
4295 + return platform_driver_register(&dmac_driver);
4297 +subsys_initcall(dmac_init);
4299 +static void __exit dmac_exit(void)
4301 + platform_driver_unregister(&dmac_driver);
4303 +module_exit(dmac_exit);
4305 +MODULE_DESCRIPTION("Synopsys DesignWare DMA Controller driver");
4306 +MODULE_AUTHOR("Haavard Skinnemoen <hskinnemoen@atmel.com>");
4307 +MODULE_LICENSE("GPL");
4309 +++ b/arch/avr32/drivers/dw-dmac.h
4312 + * Driver for the Synopsys DesignWare DMA Controller
4314 + * Copyright (C) 2005-2006 Atmel Corporation
4316 + * This program is free software; you can redistribute it and/or modify
4317 + * it under the terms of the GNU General Public License version 2 as
4318 + * published by the Free Software Foundation.
4320 +#ifndef __AVR32_DW_DMAC_H__
4321 +#define __AVR32_DW_DMAC_H__
4323 +#define DW_DMAC_CFG 0x398
4324 +#define DW_DMAC_CH_EN 0x3a0
4326 +#define DW_DMAC_STATUS_XFER 0x2e8
4327 +#define DW_DMAC_STATUS_BLOCK 0x2f0
4328 +#define DW_DMAC_STATUS_ERROR 0x308
4330 +#define DW_DMAC_MASK_XFER 0x310
4331 +#define DW_DMAC_MASK_BLOCK 0x318
4332 +#define DW_DMAC_MASK_ERROR 0x330
4334 +#define DW_DMAC_CLEAR_XFER 0x338
4335 +#define DW_DMAC_CLEAR_BLOCK 0x340
4336 +#define DW_DMAC_CLEAR_ERROR 0x358
4338 +#define DW_DMAC_STATUS_INT 0x360
4340 +#define DW_DMAC_CHAN_SAR 0x000
4341 +#define DW_DMAC_CHAN_DAR 0x008
4342 +#define DW_DMAC_CHAN_LLP 0x010
4343 +#define DW_DMAC_CHAN_CTL 0x018
4344 +#define DW_DMAC_CHAN_SSTAT 0x020
4345 +#define DW_DMAC_CHAN_DSTAT 0x028
4346 +#define DW_DMAC_CHAN_SSTATAR 0x030
4347 +#define DW_DMAC_CHAN_DSTATAR 0x038
4348 +#define DW_DMAC_CHAN_CFG 0x040
4349 +#define DW_DMAC_CHAN_SGR 0x048
4350 +#define DW_DMAC_CHAN_DSR 0x050
4352 +#endif /* __AVR32_DW_DMAC_H__ */
4354 +++ b/arch/avr32/drivers/Makefile
4356 +obj-$(CONFIG_DW_DMAC) += dw-dmac.o
4357 --- a/arch/avr32/Kconfig
4358 +++ b/arch/avr32/Kconfig
4363 +config GENERIC_CLOCKEVENTS
4366 config RWSEM_XCHGADD_ALGORITHM
4371 menu "System Type and features"
4373 +source "kernel/time/Kconfig"
4375 config SUBARCH_AVR32B
4380 select PERFORMANCE_COUNTERS
4381 select HAVE_GPIO_LIB
4382 + select GENERIC_ALLOCATOR
4388 source "arch/avr32/boards/atstk1000/Kconfig"
4391 +source "arch/avr32/boards/atngw100/Kconfig"
4395 prompt "Boot loader type"
4396 @@ -180,6 +189,10 @@
4397 be dumped to the console when a Non-Maskable Interrupt
4401 + tristate "Synopsys DesignWare DMA Controller support"
4402 + default y if CPU_AT32AP7000
4404 # FPU emulation goes here
4406 source "kernel/Kconfig.hz"
4407 @@ -196,6 +209,11 @@
4409 menu "Power management options"
4411 +config ARCH_SUSPEND_POSSIBLE
4414 +source "kernel/power/Kconfig"
4416 menu "CPU Frequency scaling"
4418 source "drivers/cpufreq/Kconfig"
4419 --- a/arch/avr32/kernel/avr32_ksyms.c
4420 +++ b/arch/avr32/kernel/avr32_ksyms.c
4423 EXPORT_SYMBOL(memset);
4424 EXPORT_SYMBOL(memcpy);
4426 EXPORT_SYMBOL(clear_page);
4427 +EXPORT_SYMBOL(copy_page);
4430 * Userspace access stuff.
4432 EXPORT_SYMBOL(__strncpy_from_user);
4433 EXPORT_SYMBOL(clear_user);
4434 EXPORT_SYMBOL(__clear_user);
4435 +EXPORT_SYMBOL(strnlen_user);
4437 EXPORT_SYMBOL(csum_partial);
4438 EXPORT_SYMBOL(csum_partial_copy_generic);
4441 +++ b/arch/avr32/kernel/dma-controller.c
4444 + * Preliminary DMA controller framework for AVR32
4446 + * Copyright (C) 2005-2006 Atmel Corporation
4448 + * This program is free software; you can redistribute it and/or modify
4449 + * it under the terms of the GNU General Public License version 2 as
4450 + * published by the Free Software Foundation.
4452 +#include <asm/dma-controller.h>
4454 +static LIST_HEAD(controllers);
4456 +int register_dma_controller(struct dma_controller *dmac)
4458 + static int next_id;
4460 + dmac->id = next_id++;
4461 + list_add_tail(&dmac->list, &controllers);
4465 +EXPORT_SYMBOL(register_dma_controller);
4467 +struct dma_controller *find_dma_controller(int id)
4469 + struct dma_controller *dmac;
4471 + list_for_each_entry(dmac, &controllers, list)
4472 + if (dmac->id == id)
4476 +EXPORT_SYMBOL(find_dma_controller);
4477 --- a/arch/avr32/kernel/entry-avr32b.S
4478 +++ b/arch/avr32/kernel/entry-avr32b.S
4479 @@ -741,26 +741,6 @@
4481 .section .irq.text,"ax",@progbits
4483 -.global cpu_idle_sleep
4486 - get_thread_info r8
4487 - ld.w r9, r8[TI_flags]
4488 - bld r9, TIF_NEED_RESCHED
4489 - brcs cpu_idle_enable_int_and_exit
4490 - sbr r9, TIF_CPU_GOING_TO_SLEEP
4491 - st.w r8[TI_flags], r9
4494 -cpu_idle_skip_sleep:
4496 - ld.w r9, r8[TI_flags]
4497 - cbr r9, TIF_CPU_GOING_TO_SLEEP
4498 - st.w r8[TI_flags], r9
4499 -cpu_idle_enable_int_and_exit:
4506 --- a/arch/avr32/kernel/Makefile
4507 +++ b/arch/avr32/kernel/Makefile
4509 obj-y += setup.o traps.o semaphore.o ocd.o ptrace.o
4510 obj-y += signal.o sys_avr32.o process.o time.o
4511 obj-y += init_task.o switch_to.o cpu.o
4512 +obj-y += dma-controller.o
4513 obj-$(CONFIG_MODULES) += module.o avr32_ksyms.o
4514 obj-$(CONFIG_KPROBES) += kprobes.o
4515 obj-$(CONFIG_STACKTRACE) += stacktrace.o
4516 --- a/arch/avr32/kernel/process.c
4517 +++ b/arch/avr32/kernel/process.c
4519 #include <asm/sysreg.h>
4520 #include <asm/ocd.h>
4522 +#include <asm/arch/pm.h>
4524 void (*pm_power_off)(void) = NULL;
4525 EXPORT_SYMBOL(pm_power_off);
4527 -extern void cpu_idle_sleep(void);
4530 * This file handles the architecture-dependent parts of process handling..
4534 void machine_power_off(void)
4540 void machine_restart(char *cmd)
4541 --- a/arch/avr32/kernel/setup.c
4542 +++ b/arch/avr32/kernel/setup.c
4545 "Failed to allocate framebuffer memory\n");
4548 + memset(__va(fbmem_start), 0, fbmem_size);
4552 --- a/arch/avr32/kernel/signal.c
4553 +++ b/arch/avr32/kernel/signal.c
4555 if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
4558 + if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->sp) == -EFAULT)
4561 pr_debug("Context restored: pc = %08lx, lr = %08lx, sp = %08lx\n",
4562 regs->pc, regs->lr, regs->sp);
4564 --- a/arch/avr32/kernel/time.c
4565 +++ b/arch/avr32/kernel/time.c
4568 * Copyright (C) 2004-2007 Atmel Corporation
4570 - * Based on MIPS implementation arch/mips/kernel/time.c
4571 - * Copyright 2001 MontaVista Software Inc.
4573 * This program is free software; you can redistribute it and/or modify
4574 * it under the terms of the GNU General Public License version 2 as
4575 * published by the Free Software Foundation.
4578 #include <linux/clk.h>
4579 -#include <linux/clocksource.h>
4580 +#include <linux/clockchips.h>
4581 #include <linux/time.h>
4582 #include <linux/module.h>
4583 #include <linux/interrupt.h>
4584 @@ -27,207 +23,133 @@
4586 #include <asm/sections.h>
4588 -/* how many counter cycles in a jiffy? */
4589 -static u32 cycles_per_jiffy;
4590 +#include <asm/arch/pm.h>
4592 -/* the count value for the next timer interrupt */
4593 -static u32 expirelo;
4595 -cycle_t __weak read_cycle_count(void)
4596 +static cycle_t read_cycle_count(void)
4598 return (cycle_t)sysreg_read(COUNT);
4601 -struct clocksource __weak clocksource_avr32 = {
4605 + * The architectural cycle count registers are a fine clocksource unless
4606 + * the system idle loop use sleep states like "idle": the CPU cycles
4607 + * measured by COUNT (and COMPARE) don't happen during sleep states.
4608 + * Their duration also changes if cpufreq changes the CPU clock rate.
4609 + * So we rate the clocksource using COUNT as very low quality.
4611 +static struct clocksource counter = {
4612 + .name = "avr32_counter",
4614 .read = read_cycle_count,
4615 .mask = CLOCKSOURCE_MASK(32),
4617 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
4620 -irqreturn_t __weak timer_interrupt(int irq, void *dev_id);
4622 -struct irqaction timer_irqaction = {
4623 - .handler = timer_interrupt,
4624 - .flags = IRQF_DISABLED,
4629 - * By default we provide the null RTC ops
4631 -static unsigned long null_rtc_get_time(void)
4632 +static irqreturn_t timer_interrupt(int irq, void *dev_id)
4634 - return mktime(2007, 1, 1, 0, 0, 0);
4637 -static int null_rtc_set_time(unsigned long sec)
4641 + struct clock_event_device *evdev = dev_id;
4643 -static unsigned long (*rtc_get_time)(void) = null_rtc_get_time;
4644 -static int (*rtc_set_time)(unsigned long) = null_rtc_set_time;
4646 -static void avr32_timer_ack(void)
4650 - /* Ack this timer interrupt and set the next one */
4651 - expirelo += cycles_per_jiffy;
4652 - /* setting COMPARE to 0 stops the COUNT-COMPARE */
4653 - if (expirelo == 0) {
4654 - sysreg_write(COMPARE, expirelo + 1);
4656 - sysreg_write(COMPARE, expirelo);
4659 + * Disable the interrupt until the clockevent subsystem
4662 + sysreg_write(COMPARE, 0);
4664 - /* Check to see if we have missed any timer interrupts */
4665 - count = sysreg_read(COUNT);
4666 - if ((count - expirelo) < 0x7fffffff) {
4667 - expirelo = count + cycles_per_jiffy;
4668 - sysreg_write(COMPARE, expirelo);
4670 + evdev->event_handler(evdev);
4671 + return IRQ_HANDLED;
4674 -int __weak avr32_hpt_init(void)
4677 - unsigned long mult, shift, count_hz;
4679 - count_hz = clk_get_rate(boot_cpu_data.clk);
4680 - shift = clocksource_avr32.shift;
4681 - mult = clocksource_hz2mult(count_hz, shift);
4682 - clocksource_avr32.mult = mult;
4690 - do_div(tmp, mult);
4692 - cycles_per_jiffy = tmp;
4694 +static struct irqaction timer_irqaction = {
4695 + .handler = timer_interrupt,
4696 + .flags = IRQF_TIMER | IRQF_DISABLED,
4697 + .name = "avr32_comparator",
4700 - ret = setup_irq(0, &timer_irqaction);
4702 - pr_debug("timer: could not request IRQ 0: %d\n", ret);
4705 +static int comparator_next_event(unsigned long delta,
4706 + struct clock_event_device *evdev)
4708 + unsigned long flags;
4710 - printk(KERN_INFO "timer: AT32AP COUNT-COMPARE at irq 0, "
4711 - "%lu.%03lu MHz\n",
4712 - ((count_hz + 500) / 1000) / 1000,
4713 - ((count_hz + 500) / 1000) % 1000);
4714 + raw_local_irq_save(flags);
4718 + /* The time to read COUNT then update COMPARE must be less
4719 + * than the min_delta_ns value for this clockevent source.
4721 + sysreg_write(COMPARE, (sysreg_read(COUNT) + delta) ? : 1);
4724 - * Taken from MIPS c0_hpt_timer_init().
4726 - * The reason COUNT is written twice is probably to make sure we don't get any
4727 - * timer interrupts while we are messing with the counter.
4729 -int __weak avr32_hpt_start(void)
4731 - u32 count = sysreg_read(COUNT);
4732 - expirelo = (count / cycles_per_jiffy + 1) * cycles_per_jiffy;
4733 - sysreg_write(COUNT, expirelo - cycles_per_jiffy);
4734 - sysreg_write(COMPARE, expirelo);
4735 - sysreg_write(COUNT, count);
4736 + raw_local_irq_restore(flags);
4742 - * local_timer_interrupt() does profiling and process accounting on a
4745 - * In UP mode, it is invoked from the (global) timer_interrupt.
4747 -void local_timer_interrupt(int irq, void *dev_id)
4748 +static void comparator_mode(enum clock_event_mode mode,
4749 + struct clock_event_device *evdev)
4752 - profile_tick(CPU_PROFILING);
4753 - update_process_times(user_mode(get_irq_regs()));
4755 + case CLOCK_EVT_MODE_ONESHOT:
4756 + pr_debug("%s: start\n", evdev->name);
4758 + case CLOCK_EVT_MODE_RESUME:
4759 + cpu_disable_idle_sleep();
4761 + case CLOCK_EVT_MODE_UNUSED:
4762 + case CLOCK_EVT_MODE_SHUTDOWN:
4763 + sysreg_write(COMPARE, 0);
4764 + pr_debug("%s: stop\n", evdev->name);
4765 + cpu_enable_idle_sleep();
4772 -irqreturn_t __weak timer_interrupt(int irq, void *dev_id)
4774 - /* ack timer interrupt and try to set next interrupt */
4775 - avr32_timer_ack();
4778 - * Call the generic timer interrupt handler
4780 - write_seqlock(&xtime_lock);
4782 - write_sequnlock(&xtime_lock);
4785 - * In UP mode, we call local_timer_interrupt() to do profiling
4786 - * and process accounting.
4788 - * SMP is not supported yet.
4790 - local_timer_interrupt(irq, dev_id);
4792 - return IRQ_HANDLED;
4794 +static struct clock_event_device comparator = {
4795 + .name = "avr32_comparator",
4796 + .features = CLOCK_EVT_FEAT_ONESHOT,
4799 + .cpumask = CPU_MASK_CPU0,
4800 + .set_next_event = comparator_next_event,
4801 + .set_mode = comparator_mode,
4804 void __init time_init(void)
4806 + unsigned long counter_hz;
4810 - * Make sure we don't get any COMPARE interrupts before we can
4813 - sysreg_write(COMPARE, 0);
4815 - xtime.tv_sec = rtc_get_time();
4816 + xtime.tv_sec = mktime(2007, 1, 1, 0, 0, 0);
4819 set_normalized_timespec(&wall_to_monotonic,
4820 -xtime.tv_sec, -xtime.tv_nsec);
4822 - ret = avr32_hpt_init();
4824 - pr_debug("timer: failed setup: %d\n", ret);
4827 + /* figure rate for counter */
4828 + counter_hz = clk_get_rate(boot_cpu_data.clk);
4829 + counter.mult = clocksource_hz2mult(counter_hz, counter.shift);
4831 - ret = clocksource_register(&clocksource_avr32);
4832 + ret = clocksource_register(&counter);
4834 pr_debug("timer: could not register clocksource: %d\n", ret);
4836 - ret = avr32_hpt_start();
4838 - pr_debug("timer: failed starting: %d\n", ret);
4842 + /* setup COMPARE clockevent */
4843 + comparator.mult = div_sc(counter_hz, NSEC_PER_SEC, comparator.shift);
4844 + comparator.max_delta_ns = clockevent_delta2ns((u32)~0, &comparator);
4845 + comparator.min_delta_ns = clockevent_delta2ns(50, &comparator) + 1;
4847 -static struct sysdev_class timer_class = {
4850 + sysreg_write(COMPARE, 0);
4851 + timer_irqaction.dev_id = &comparator;
4853 -static struct sys_device timer_device = {
4855 - .cls = &timer_class,
4857 + ret = setup_irq(0, &timer_irqaction);
4859 + pr_debug("timer: could not request IRQ 0: %d\n", ret);
4861 + clockevents_register_device(&comparator);
4863 -static int __init init_timer_sysfs(void)
4865 - int err = sysdev_class_register(&timer_class);
4867 - err = sysdev_register(&timer_device);
4869 + pr_info("%s: irq 0, %lu.%03lu MHz\n", comparator.name,
4870 + ((counter_hz + 500) / 1000) / 1000,
4871 + ((counter_hz + 500) / 1000) % 1000);
4875 -device_initcall(init_timer_sysfs);
4876 --- a/arch/avr32/lib/io-readsb.S
4877 +++ b/arch/avr32/lib/io-readsb.S
4882 -3: ld.uh r8, r12[0]
4883 +3: ld.ub r8, r12[0]
4887 --- a/arch/avr32/mach-at32ap/at32ap700x.c
4888 +++ b/arch/avr32/mach-at32ap/at32ap700x.c
4890 * published by the Free Software Foundation.
4892 #include <linux/clk.h>
4893 +#include <linux/delay.h>
4894 #include <linux/fb.h>
4895 #include <linux/init.h>
4896 #include <linux/platform_device.h>
4897 #include <linux/dma-mapping.h>
4898 #include <linux/spi/spi.h>
4899 +#include <linux/usb/atmel_usba_udc.h>
4902 #include <asm/irq.h>
4904 #include <asm/arch/at32ap700x.h>
4905 #include <asm/arch/board.h>
4906 #include <asm/arch/portmux.h>
4907 +#include <asm/arch/sram.h>
4909 #include <video/atmel_lcdc.h>
4913 static DEFINE_SPINLOCK(pm_lock);
4915 -unsigned long at32ap7000_osc_rates[3] = {
4917 - /* FIXME: these are ATSTK1002-specific */
4921 +static struct clk osc0;
4922 +static struct clk osc1;
4924 static unsigned long osc_get_rate(struct clk *clk)
4926 - return at32ap7000_osc_rates[clk->index];
4927 + return at32_board_osc_rates[clk->index];
4930 static unsigned long pll_get_rate(struct clk *clk, unsigned long control)
4932 unsigned long div, mul, rate;
4934 - if (!(control & PM_BIT(PLLEN)))
4937 div = PM_BFEXT(PLLDIV, control) + 1;
4938 mul = PM_BFEXT(PLLMUL, control) + 1;
4940 @@ -120,6 +116,71 @@
4944 +static long pll_set_rate(struct clk *clk, unsigned long rate,
4947 + unsigned long mul;
4948 + unsigned long mul_best_fit = 0;
4949 + unsigned long div;
4950 + unsigned long div_min;
4951 + unsigned long div_max;
4952 + unsigned long div_best_fit = 0;
4953 + unsigned long base;
4954 + unsigned long pll_in;
4955 + unsigned long actual = 0;
4956 + unsigned long rate_error;
4957 + unsigned long rate_error_prev = ~0UL;
4960 + /* Rate must be between 80 MHz and 200 Mhz. */
4961 + if (rate < 80000000UL || rate > 200000000UL)
4964 + ctrl = PM_BF(PLLOPT, 4);
4965 + base = clk->parent->get_rate(clk->parent);
4967 + /* PLL input frequency must be between 6 MHz and 32 MHz. */
4968 + div_min = DIV_ROUND_UP(base, 32000000UL);
4969 + div_max = base / 6000000UL;
4971 + if (div_max < div_min)
4974 + for (div = div_min; div <= div_max; div++) {
4975 + pll_in = (base + div / 2) / div;
4976 + mul = (rate + pll_in / 2) / pll_in;
4981 + actual = pll_in * mul;
4982 + rate_error = abs(actual - rate);
4984 + if (rate_error < rate_error_prev) {
4985 + mul_best_fit = mul;
4986 + div_best_fit = div;
4987 + rate_error_prev = rate_error;
4990 + if (rate_error == 0)
4994 + if (div_best_fit == 0)
4997 + ctrl |= PM_BF(PLLMUL, mul_best_fit - 1);
4998 + ctrl |= PM_BF(PLLDIV, div_best_fit - 1);
4999 + ctrl |= PM_BF(PLLCOUNT, 16);
5001 + if (clk->parent == &osc1)
5002 + ctrl |= PM_BIT(PLLOSC);
5009 static unsigned long pll0_get_rate(struct clk *clk)
5012 @@ -129,6 +190,41 @@
5013 return pll_get_rate(clk, control);
5016 +static void pll1_mode(struct clk *clk, int enabled)
5018 + unsigned long timeout;
5022 + ctrl = pm_readl(PLL1);
5025 + if (!PM_BFEXT(PLLMUL, ctrl) && !PM_BFEXT(PLLDIV, ctrl)) {
5026 + pr_debug("clk %s: failed to enable, rate not set\n",
5031 + ctrl |= PM_BIT(PLLEN);
5032 + pm_writel(PLL1, ctrl);
5034 + /* Wait for PLL lock. */
5035 + for (timeout = 10000; timeout; timeout--) {
5036 + status = pm_readl(ISR);
5037 + if (status & PM_BIT(LOCK1))
5042 + if (!(status & PM_BIT(LOCK1)))
5043 + printk(KERN_ERR "clk %s: timeout waiting for lock\n",
5046 + ctrl &= ~PM_BIT(PLLEN);
5047 + pm_writel(PLL1, ctrl);
5051 static unsigned long pll1_get_rate(struct clk *clk)
5054 @@ -138,6 +234,49 @@
5055 return pll_get_rate(clk, control);
5058 +static long pll1_set_rate(struct clk *clk, unsigned long rate, int apply)
5061 + unsigned long actual_rate;
5063 + actual_rate = pll_set_rate(clk, rate, &ctrl);
5066 + if (actual_rate != rate)
5068 + if (clk->users > 0)
5070 + pr_debug(KERN_INFO "clk %s: new rate %lu (actual rate %lu)\n",
5071 + clk->name, rate, actual_rate);
5072 + pm_writel(PLL1, ctrl);
5075 + return actual_rate;
5078 +static int pll1_set_parent(struct clk *clk, struct clk *parent)
5082 + if (clk->users > 0)
5085 + ctrl = pm_readl(PLL1);
5086 + WARN_ON(ctrl & PM_BIT(PLLEN));
5088 + if (parent == &osc0)
5089 + ctrl &= ~PM_BIT(PLLOSC);
5090 + else if (parent == &osc1)
5091 + ctrl |= PM_BIT(PLLOSC);
5095 + pm_writel(PLL1, ctrl);
5096 + clk->parent = parent;
5102 * The AT32AP7000 has five primary clock sources: One 32kHz
5103 * oscillator, two crystal oscillators and two PLLs.
5104 @@ -166,7 +305,10 @@
5106 static struct clk pll1 = {
5108 + .mode = pll1_mode,
5109 .get_rate = pll1_get_rate,
5110 + .set_rate = pll1_set_rate,
5111 + .set_parent = pll1_set_parent,
5115 @@ -534,6 +676,14 @@
5119 +static struct clk sdramc_clk = {
5120 + .name = "sdramc_clk",
5121 + .parent = &pbb_clk,
5122 + .mode = pbb_clk_mode,
5123 + .get_rate = pbb_clk_get_rate,
5128 static struct resource smc0_resource[] = {
5130 @@ -605,19 +755,32 @@
5133 /* --------------------------------------------------------------------
5134 - * System Timer/Counter (TC)
5135 + * Timer/Counter (TC)
5136 * -------------------------------------------------------------------- */
5137 -static struct resource at32_systc0_resource[] = {
5139 +static struct resource at32_tcb0_resource[] = {
5143 -struct platform_device at32_systc0_device = {
5145 +static struct platform_device at32_tcb0_device = {
5146 + .name = "atmel_tcb",
5148 - .resource = at32_systc0_resource,
5149 - .num_resources = ARRAY_SIZE(at32_systc0_resource),
5150 + .resource = at32_tcb0_resource,
5151 + .num_resources = ARRAY_SIZE(at32_tcb0_resource),
5153 -DEV_CLK(pclk, at32_systc0, pbb, 3);
5154 +DEV_CLK(t0_clk, at32_tcb0, pbb, 3);
5156 +static struct resource at32_tcb1_resource[] = {
5157 + PBMEM(0xfff01000),
5160 +static struct platform_device at32_tcb1_device = {
5161 + .name = "atmel_tcb",
5163 + .resource = at32_tcb1_resource,
5164 + .num_resources = ARRAY_SIZE(at32_tcb1_resource),
5166 +DEV_CLK(t0_clk, at32_tcb1, pbb, 4);
5168 /* --------------------------------------------------------------------
5171 platform_device_register(&pdc_device);
5172 platform_device_register(&dmaca0_device);
5174 - platform_device_register(&at32_systc0_device);
5175 + platform_device_register(&at32_tcb0_device);
5176 + platform_device_register(&at32_tcb1_device);
5178 platform_device_register(&pio0_device);
5179 platform_device_register(&pio1_device);
5180 @@ -679,6 +843,81 @@
5183 /* --------------------------------------------------------------------
5185 + * -------------------------------------------------------------------- */
5186 +static struct resource atmel_psif0_resource[] __initdata = {
5188 + .start = 0xffe03c00,
5189 + .end = 0xffe03cff,
5190 + .flags = IORESOURCE_MEM,
5194 +static struct clk atmel_psif0_pclk = {
5196 + .parent = &pba_clk,
5197 + .mode = pba_clk_mode,
5198 + .get_rate = pba_clk_get_rate,
5202 +static struct resource atmel_psif1_resource[] __initdata = {
5204 + .start = 0xffe03d00,
5205 + .end = 0xffe03dff,
5206 + .flags = IORESOURCE_MEM,
5210 +static struct clk atmel_psif1_pclk = {
5212 + .parent = &pba_clk,
5213 + .mode = pba_clk_mode,
5214 + .get_rate = pba_clk_get_rate,
5218 +struct platform_device *__init at32_add_device_psif(unsigned int id)
5220 + struct platform_device *pdev;
5222 + if (!(id == 0 || id == 1))
5225 + pdev = platform_device_alloc("atmel_psif", id);
5231 + if (platform_device_add_resources(pdev, atmel_psif0_resource,
5232 + ARRAY_SIZE(atmel_psif0_resource)))
5233 + goto err_add_resources;
5234 + atmel_psif0_pclk.dev = &pdev->dev;
5235 + select_peripheral(PA(8), PERIPH_A, 0); /* CLOCK */
5236 + select_peripheral(PA(9), PERIPH_A, 0); /* DATA */
5239 + if (platform_device_add_resources(pdev, atmel_psif1_resource,
5240 + ARRAY_SIZE(atmel_psif1_resource)))
5241 + goto err_add_resources;
5242 + atmel_psif1_pclk.dev = &pdev->dev;
5243 + select_peripheral(PB(11), PERIPH_A, 0); /* CLOCK */
5244 + select_peripheral(PB(12), PERIPH_A, 0); /* DATA */
5250 + platform_device_add(pdev);
5254 + platform_device_put(pdev);
5258 +/* --------------------------------------------------------------------
5260 * -------------------------------------------------------------------- */
5262 @@ -989,7 +1228,9 @@
5266 -struct platform_device *__init at32_add_device_twi(unsigned int id)
5267 +struct platform_device *__init at32_add_device_twi(unsigned int id,
5268 + struct i2c_board_info *b,
5271 struct platform_device *pdev;
5273 @@ -1009,6 +1250,9 @@
5275 atmel_twi0_pclk.dev = &pdev->dev;
5278 + i2c_register_board_info(id, b, n);
5280 platform_device_add(pdev);
5283 @@ -1032,7 +1276,8 @@
5287 -struct platform_device *__init at32_add_device_mci(unsigned int id)
5288 +struct platform_device *__init
5289 +at32_add_device_mci(unsigned int id, struct mci_platform_data *data)
5291 struct platform_device *pdev;
5293 @@ -1041,11 +1286,15 @@
5295 pdev = platform_device_alloc("atmel_mci", id);
5300 if (platform_device_add_resources(pdev, atmel_mci0_resource,
5301 ARRAY_SIZE(atmel_mci0_resource)))
5302 - goto err_add_resources;
5305 + if (data && platform_device_add_data(pdev, data,
5306 + sizeof(struct mci_platform_data)))
5309 select_peripheral(PA(10), PERIPH_A, 0); /* CLK */
5310 select_peripheral(PA(11), PERIPH_A, 0); /* CMD */
5311 @@ -1054,12 +1303,19 @@
5312 select_peripheral(PA(14), PERIPH_A, 0); /* DATA2 */
5313 select_peripheral(PA(15), PERIPH_A, 0); /* DATA3 */
5316 + if (data->detect_pin != GPIO_PIN_NONE)
5317 + at32_select_gpio(data->detect_pin, 0);
5318 + if (data->wp_pin != GPIO_PIN_NONE)
5319 + at32_select_gpio(data->wp_pin, 0);
5322 atmel_mci0_pclk.dev = &pdev->dev;
5324 platform_device_add(pdev);
5329 platform_device_put(pdev);
5332 @@ -1097,7 +1353,8 @@
5334 struct platform_device *__init
5335 at32_add_device_lcdc(unsigned int id, struct atmel_lcdfb_info *data,
5336 - unsigned long fbmem_start, unsigned long fbmem_len)
5337 + unsigned long fbmem_start, unsigned long fbmem_len,
5338 + unsigned int pin_config)
5340 struct platform_device *pdev;
5341 struct atmel_lcdfb_info *info;
5342 @@ -1124,37 +1381,77 @@
5345 pdev = &atmel_lcdfb0_device;
5346 - select_peripheral(PC(19), PERIPH_A, 0); /* CC */
5347 - select_peripheral(PC(20), PERIPH_A, 0); /* HSYNC */
5348 - select_peripheral(PC(21), PERIPH_A, 0); /* PCLK */
5349 - select_peripheral(PC(22), PERIPH_A, 0); /* VSYNC */
5350 - select_peripheral(PC(23), PERIPH_A, 0); /* DVAL */
5351 - select_peripheral(PC(24), PERIPH_A, 0); /* MODE */
5352 - select_peripheral(PC(25), PERIPH_A, 0); /* PWR */
5353 - select_peripheral(PC(26), PERIPH_A, 0); /* DATA0 */
5354 - select_peripheral(PC(27), PERIPH_A, 0); /* DATA1 */
5355 - select_peripheral(PC(28), PERIPH_A, 0); /* DATA2 */
5356 - select_peripheral(PC(29), PERIPH_A, 0); /* DATA3 */
5357 - select_peripheral(PC(30), PERIPH_A, 0); /* DATA4 */
5358 - select_peripheral(PC(31), PERIPH_A, 0); /* DATA5 */
5359 - select_peripheral(PD(0), PERIPH_A, 0); /* DATA6 */
5360 - select_peripheral(PD(1), PERIPH_A, 0); /* DATA7 */
5361 - select_peripheral(PD(2), PERIPH_A, 0); /* DATA8 */
5362 - select_peripheral(PD(3), PERIPH_A, 0); /* DATA9 */
5363 - select_peripheral(PD(4), PERIPH_A, 0); /* DATA10 */
5364 - select_peripheral(PD(5), PERIPH_A, 0); /* DATA11 */
5365 - select_peripheral(PD(6), PERIPH_A, 0); /* DATA12 */
5366 - select_peripheral(PD(7), PERIPH_A, 0); /* DATA13 */
5367 - select_peripheral(PD(8), PERIPH_A, 0); /* DATA14 */
5368 - select_peripheral(PD(9), PERIPH_A, 0); /* DATA15 */
5369 - select_peripheral(PD(10), PERIPH_A, 0); /* DATA16 */
5370 - select_peripheral(PD(11), PERIPH_A, 0); /* DATA17 */
5371 - select_peripheral(PD(12), PERIPH_A, 0); /* DATA18 */
5372 - select_peripheral(PD(13), PERIPH_A, 0); /* DATA19 */
5373 - select_peripheral(PD(14), PERIPH_A, 0); /* DATA20 */
5374 - select_peripheral(PD(15), PERIPH_A, 0); /* DATA21 */
5375 - select_peripheral(PD(16), PERIPH_A, 0); /* DATA22 */
5376 - select_peripheral(PD(17), PERIPH_A, 0); /* DATA23 */
5378 + switch (pin_config) {
5380 + select_peripheral(PC(19), PERIPH_A, 0); /* CC */
5381 + select_peripheral(PC(20), PERIPH_A, 0); /* HSYNC */
5382 + select_peripheral(PC(21), PERIPH_A, 0); /* PCLK */
5383 + select_peripheral(PC(22), PERIPH_A, 0); /* VSYNC */
5384 + select_peripheral(PC(23), PERIPH_A, 0); /* DVAL */
5385 + select_peripheral(PC(24), PERIPH_A, 0); /* MODE */
5386 + select_peripheral(PC(25), PERIPH_A, 0); /* PWR */
5387 + select_peripheral(PC(26), PERIPH_A, 0); /* DATA0 */
5388 + select_peripheral(PC(27), PERIPH_A, 0); /* DATA1 */
5389 + select_peripheral(PC(28), PERIPH_A, 0); /* DATA2 */
5390 + select_peripheral(PC(29), PERIPH_A, 0); /* DATA3 */
5391 + select_peripheral(PC(30), PERIPH_A, 0); /* DATA4 */
5392 + select_peripheral(PC(31), PERIPH_A, 0); /* DATA5 */
5393 + select_peripheral(PD(0), PERIPH_A, 0); /* DATA6 */
5394 + select_peripheral(PD(1), PERIPH_A, 0); /* DATA7 */
5395 + select_peripheral(PD(2), PERIPH_A, 0); /* DATA8 */
5396 + select_peripheral(PD(3), PERIPH_A, 0); /* DATA9 */
5397 + select_peripheral(PD(4), PERIPH_A, 0); /* DATA10 */
5398 + select_peripheral(PD(5), PERIPH_A, 0); /* DATA11 */
5399 + select_peripheral(PD(6), PERIPH_A, 0); /* DATA12 */
5400 + select_peripheral(PD(7), PERIPH_A, 0); /* DATA13 */
5401 + select_peripheral(PD(8), PERIPH_A, 0); /* DATA14 */
5402 + select_peripheral(PD(9), PERIPH_A, 0); /* DATA15 */
5403 + select_peripheral(PD(10), PERIPH_A, 0); /* DATA16 */
5404 + select_peripheral(PD(11), PERIPH_A, 0); /* DATA17 */
5405 + select_peripheral(PD(12), PERIPH_A, 0); /* DATA18 */
5406 + select_peripheral(PD(13), PERIPH_A, 0); /* DATA19 */
5407 + select_peripheral(PD(14), PERIPH_A, 0); /* DATA20 */
5408 + select_peripheral(PD(15), PERIPH_A, 0); /* DATA21 */
5409 + select_peripheral(PD(16), PERIPH_A, 0); /* DATA22 */
5410 + select_peripheral(PD(17), PERIPH_A, 0); /* DATA23 */
5413 + select_peripheral(PE(0), PERIPH_B, 0); /* CC */
5414 + select_peripheral(PC(20), PERIPH_A, 0); /* HSYNC */
5415 + select_peripheral(PC(21), PERIPH_A, 0); /* PCLK */
5416 + select_peripheral(PC(22), PERIPH_A, 0); /* VSYNC */
5417 + select_peripheral(PE(1), PERIPH_B, 0); /* DVAL */
5418 + select_peripheral(PE(2), PERIPH_B, 0); /* MODE */
5419 + select_peripheral(PC(25), PERIPH_A, 0); /* PWR */
5420 + select_peripheral(PE(3), PERIPH_B, 0); /* DATA0 */
5421 + select_peripheral(PE(4), PERIPH_B, 0); /* DATA1 */
5422 + select_peripheral(PE(5), PERIPH_B, 0); /* DATA2 */
5423 + select_peripheral(PE(6), PERIPH_B, 0); /* DATA3 */
5424 + select_peripheral(PE(7), PERIPH_B, 0); /* DATA4 */
5425 + select_peripheral(PC(31), PERIPH_A, 0); /* DATA5 */
5426 + select_peripheral(PD(0), PERIPH_A, 0); /* DATA6 */
5427 + select_peripheral(PD(1), PERIPH_A, 0); /* DATA7 */
5428 + select_peripheral(PE(8), PERIPH_B, 0); /* DATA8 */
5429 + select_peripheral(PE(9), PERIPH_B, 0); /* DATA9 */
5430 + select_peripheral(PE(10), PERIPH_B, 0); /* DATA10 */
5431 + select_peripheral(PE(11), PERIPH_B, 0); /* DATA11 */
5432 + select_peripheral(PE(12), PERIPH_B, 0); /* DATA12 */
5433 + select_peripheral(PD(7), PERIPH_A, 0); /* DATA13 */
5434 + select_peripheral(PD(8), PERIPH_A, 0); /* DATA14 */
5435 + select_peripheral(PD(9), PERIPH_A, 0); /* DATA15 */
5436 + select_peripheral(PE(13), PERIPH_B, 0); /* DATA16 */
5437 + select_peripheral(PE(14), PERIPH_B, 0); /* DATA17 */
5438 + select_peripheral(PE(15), PERIPH_B, 0); /* DATA18 */
5439 + select_peripheral(PE(16), PERIPH_B, 0); /* DATA19 */
5440 + select_peripheral(PE(17), PERIPH_B, 0); /* DATA20 */
5441 + select_peripheral(PE(18), PERIPH_B, 0); /* DATA21 */
5442 + select_peripheral(PD(16), PERIPH_A, 0); /* DATA22 */
5443 + select_peripheral(PD(17), PERIPH_A, 0); /* DATA23 */
5446 + goto err_invalid_id;
5449 clk_set_parent(&atmel_lcdfb0_pixclk, &pll0);
5450 clk_set_rate(&atmel_lcdfb0_pixclk, clk_get_rate(&pll0));
5451 @@ -1351,9 +1648,39 @@
5455 +#define EP(nam, idx, maxpkt, maxbk, dma, isoc) \
5459 + .fifo_size = maxpkt, \
5460 + .nr_banks = maxbk, \
5462 + .can_isoc = isoc, \
5465 +static struct usba_ep_data at32_usba_ep[] __initdata = {
5466 + EP("ep0", 0, 64, 1, 0, 0),
5467 + EP("ep1", 1, 512, 2, 1, 1),
5468 + EP("ep2", 2, 512, 2, 1, 1),
5469 + EP("ep3-int", 3, 64, 3, 1, 0),
5470 + EP("ep4-int", 4, 64, 3, 1, 0),
5471 + EP("ep5", 5, 1024, 3, 1, 1),
5472 + EP("ep6", 6, 1024, 3, 1, 1),
5477 struct platform_device *__init
5478 at32_add_device_usba(unsigned int id, struct usba_platform_data *data)
5481 + * pdata doesn't have room for any endpoints, so we need to
5482 + * append room for the ones we need right after it.
5485 + struct usba_platform_data pdata;
5486 + struct usba_ep_data ep[7];
5488 struct platform_device *pdev;
5491 @@ -1367,13 +1694,20 @@
5492 ARRAY_SIZE(usba0_resource)))
5496 - if (platform_device_add_data(pdev, data, sizeof(*data)))
5497 - goto out_free_pdev;
5499 + usba_data.pdata.vbus_pin = data->vbus_pin;
5501 + usba_data.pdata.vbus_pin = -EINVAL;
5503 - if (data->vbus_pin != GPIO_PIN_NONE)
5504 - at32_select_gpio(data->vbus_pin, 0);
5506 + data = &usba_data.pdata;
5507 + data->num_ep = ARRAY_SIZE(at32_usba_ep);
5508 + memcpy(data->ep, at32_usba_ep, sizeof(at32_usba_ep));
5510 + if (platform_device_add_data(pdev, data, sizeof(usba_data)))
5511 + goto out_free_pdev;
5513 + if (data->vbus_pin >= 0)
5514 + at32_select_gpio(data->vbus_pin, 0);
5516 usba0_pclk.dev = &pdev->dev;
5517 usba0_hclk.dev = &pdev->dev;
5518 @@ -1526,6 +1860,58 @@
5521 /* --------------------------------------------------------------------
5522 + * NAND Flash / SmartMedia
5523 + * -------------------------------------------------------------------- */
5524 +static struct resource smc_cs3_resource[] __initdata = {
5526 + .start = 0x0c000000,
5527 + .end = 0x0fffffff,
5528 + .flags = IORESOURCE_MEM,
5530 + .start = 0xfff03c00,
5531 + .end = 0xfff03fff,
5532 + .flags = IORESOURCE_MEM,
5536 +struct platform_device *__init
5537 +at32_add_device_nand(unsigned int id, struct atmel_nand_data *data)
5539 + struct platform_device *pdev;
5541 + if (id != 0 || !data)
5544 + pdev = platform_device_alloc("atmel_nand", id);
5548 + if (platform_device_add_resources(pdev, smc_cs3_resource,
5549 + ARRAY_SIZE(smc_cs3_resource)))
5552 + if (platform_device_add_data(pdev, data,
5553 + sizeof(struct atmel_nand_data)))
5556 + set_ebi_sfr_bits(HMATRIX_BIT(CS3A));
5557 + if (data->enable_pin)
5558 + at32_select_gpio(data->enable_pin,
5559 + AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
5560 + if (data->rdy_pin)
5561 + at32_select_gpio(data->rdy_pin, 0);
5562 + if (data->det_pin)
5563 + at32_select_gpio(data->det_pin, 0);
5565 + platform_device_add(pdev);
5569 + platform_device_put(pdev);
5573 +/* --------------------------------------------------------------------
5575 * -------------------------------------------------------------------- */
5576 static struct resource atmel_ac97c0_resource[] __initdata = {
5577 @@ -1683,6 +2069,7 @@
5585 @@ -1694,7 +2081,10 @@
5589 - &at32_systc0_pclk,
5590 + &at32_tcb0_t0_clk,
5591 + &at32_tcb1_t0_clk,
5592 + &atmel_psif0_pclk,
5593 + &atmel_psif1_pclk,
5594 &atmel_usart0_usart,
5595 &atmel_usart1_usart,
5596 &atmel_usart2_usart,
5597 @@ -1730,16 +2120,7 @@
5599 unsigned int at32_nr_clocks = ARRAY_SIZE(at32_clock_list);
5601 -void __init at32_portmux_init(void)
5603 - at32_init_pio(&pio0_device);
5604 - at32_init_pio(&pio1_device);
5605 - at32_init_pio(&pio2_device);
5606 - at32_init_pio(&pio3_device);
5607 - at32_init_pio(&pio4_device);
5610 -void __init at32_clock_init(void)
5611 +void __init setup_platform(void)
5613 u32 cpu_mask = 0, hsb_mask = 0, pba_mask = 0, pbb_mask = 0;
5615 @@ -1794,4 +2175,36 @@
5616 pm_writel(HSB_MASK, hsb_mask);
5617 pm_writel(PBA_MASK, pba_mask);
5618 pm_writel(PBB_MASK, pbb_mask);
5620 + /* Initialize the port muxes */
5621 + at32_init_pio(&pio0_device);
5622 + at32_init_pio(&pio1_device);
5623 + at32_init_pio(&pio2_device);
5624 + at32_init_pio(&pio3_device);
5625 + at32_init_pio(&pio4_device);
5628 +struct gen_pool *sram_pool;
5630 +static int __init sram_init(void)
5632 + struct gen_pool *pool;
5634 + /* 1KiB granularity */
5635 + pool = gen_pool_create(10, -1);
5639 + if (gen_pool_add(pool, 0x24000000, 0x8000, -1))
5640 + goto err_pool_add;
5646 + gen_pool_destroy(pool);
5648 + pr_err("Failed to create SRAM pool\n");
5651 +core_initcall(sram_init);
5652 --- a/arch/avr32/mach-at32ap/at32ap.c
5656 - * Copyright (C) 2006 Atmel Corporation
5658 - * This program is free software; you can redistribute it and/or modify
5659 - * it under the terms of the GNU General Public License version 2 as
5660 - * published by the Free Software Foundation.
5663 -#include <linux/clk.h>
5664 -#include <linux/err.h>
5665 -#include <linux/init.h>
5666 -#include <linux/platform_device.h>
5668 -#include <asm/arch/init.h>
5670 -void __init setup_platform(void)
5672 - at32_clock_init();
5673 - at32_portmux_init();
5676 -static int __init pdc_probe(struct platform_device *pdev)
5678 - struct clk *pclk, *hclk;
5680 - pclk = clk_get(&pdev->dev, "pclk");
5681 - if (IS_ERR(pclk)) {
5682 - dev_err(&pdev->dev, "no pclk defined\n");
5683 - return PTR_ERR(pclk);
5685 - hclk = clk_get(&pdev->dev, "hclk");
5686 - if (IS_ERR(hclk)) {
5687 - dev_err(&pdev->dev, "no hclk defined\n");
5689 - return PTR_ERR(hclk);
5695 - dev_info(&pdev->dev, "Atmel Peripheral DMA Controller enabled\n");
5699 -static struct platform_driver pdc_driver = {
5700 - .probe = pdc_probe,
5706 -static int __init pdc_init(void)
5708 - return platform_driver_register(&pdc_driver);
5710 -arch_initcall(pdc_init);
5711 --- a/arch/avr32/mach-at32ap/cpufreq.c
5712 +++ b/arch/avr32/mach-at32ap/cpufreq.c
5715 return cpufreq_register_driver(&at32_driver);
5718 -arch_initcall(at32_cpufreq_init);
5719 +late_initcall(at32_cpufreq_init);
5721 +++ b/arch/avr32/mach-at32ap/gpio-dev.c
5724 + * GPIO /dev and configfs interface
5726 + * Copyright (C) 2006-2007 Atmel Corporation
5728 + * This program is free software; you can redistribute it and/or modify
5729 + * it under the terms of the GNU General Public License version 2 as
5730 + * published by the Free Software Foundation.
5732 +#include <linux/kernel.h>
5733 +#include <linux/configfs.h>
5734 +#include <linux/cdev.h>
5735 +#include <linux/device.h>
5736 +#include <linux/fs.h>
5737 +#include <linux/interrupt.h>
5738 +#include <linux/module.h>
5739 +#include <linux/poll.h>
5740 +#include <linux/uaccess.h>
5741 +#include <linux/wait.h>
5743 +#include <asm/gpio.h>
5744 +#include <asm/arch/portmux.h>
5746 +#define GPIO_DEV_MAX 8
5748 +static struct class *gpio_dev_class;
5749 +static dev_t gpio_devt;
5760 + /* Pin state last time we read it (for blocking reads) */
5764 + wait_queue_head_t change_wq;
5765 + struct fasync_struct *async_queue;
5768 + struct class_device *gpio_dev;
5769 + struct cdev char_dev;
5770 + struct config_item item;
5773 +struct gpio_attribute {
5774 + struct configfs_attribute attr;
5775 + ssize_t (*show)(struct gpio_item *, char *);
5776 + ssize_t (*store)(struct gpio_item *, const char *, size_t);
5779 +static irqreturn_t gpio_dev_interrupt(int irq, void *dev_id)
5781 + struct gpio_item *gpio = dev_id;
5782 + u32 old_state, new_state;
5784 + old_state = gpio->pin_state;
5785 + new_state = at32_gpio_get_value_multiple(gpio->port, gpio->pin_mask);
5786 + gpio->pin_state = new_state;
5788 + if (new_state != old_state) {
5789 + gpio->changed = 1;
5790 + wake_up_interruptible(&gpio->change_wq);
5792 + if (gpio->async_queue)
5793 + kill_fasync(&gpio->async_queue, SIGIO, POLL_IN);
5796 + return IRQ_HANDLED;
5799 +static int gpio_dev_open(struct inode *inode, struct file *file)
5801 + struct gpio_item *gpio = container_of(inode->i_cdev,
5808 + nonseekable_open(inode, file);
5809 + config_item_get(&gpio->item);
5810 + file->private_data = gpio;
5812 + gpio->pin_state = at32_gpio_get_value_multiple(gpio->port,
5814 + gpio->changed = 1;
5816 + for (i = 0; i < 32; i++) {
5817 + if (gpio->pin_mask & (1 << i)) {
5818 + irq = gpio_to_irq(32 * gpio->port + i);
5819 + ret = request_irq(irq, gpio_dev_interrupt, 0,
5820 + "gpio-dev", gpio);
5830 + if (gpio->pin_mask & (1 << i)) {
5831 + irq = gpio_to_irq(32 * gpio->port + i);
5832 + free_irq(irq, gpio);
5836 + config_item_put(&gpio->item);
5841 +static int gpio_dev_fasync(int fd, struct file *file, int mode)
5843 + struct gpio_item *gpio = file->private_data;
5845 + return fasync_helper(fd, file, mode, &gpio->async_queue);
5848 +static int gpio_dev_release(struct inode *inode, struct file *file)
5850 + struct gpio_item *gpio = file->private_data;
5854 + gpio_dev_fasync(-1, file, 0);
5856 + for (i = 0; i < 32; i++) {
5857 + if (gpio->pin_mask & (1 << i)) {
5858 + irq = gpio_to_irq(32 * gpio->port + i);
5859 + free_irq(irq, gpio);
5863 + config_item_put(&gpio->item);
5868 +static unsigned int gpio_dev_poll(struct file *file, poll_table *wait)
5870 + struct gpio_item *gpio = file->private_data;
5871 + unsigned int mask = 0;
5873 + poll_wait(file, &gpio->change_wq, wait);
5874 + if (gpio->changed)
5875 + mask |= POLLIN | POLLRDNORM;
5880 +static ssize_t gpio_dev_read(struct file *file, char __user *buf,
5881 + size_t count, loff_t *offset)
5883 + struct gpio_item *gpio = file->private_data;
5886 + spin_lock_irq(&gpio->lock);
5887 + while (!gpio->changed) {
5888 + spin_unlock_irq(&gpio->lock);
5890 + if (file->f_flags & O_NONBLOCK)
5893 + if (wait_event_interruptible(gpio->change_wq, gpio->changed))
5894 + return -ERESTARTSYS;
5896 + spin_lock_irq(&gpio->lock);
5899 + gpio->changed = 0;
5900 + value = at32_gpio_get_value_multiple(gpio->port, gpio->pin_mask);
5902 + spin_unlock_irq(&gpio->lock);
5904 + count = min(count, (size_t)4);
5905 + if (copy_to_user(buf, &value, count))
5911 +static ssize_t gpio_dev_write(struct file *file, const char __user *buf,
5912 + size_t count, loff_t *offset)
5914 + struct gpio_item *gpio = file->private_data;
5918 + count = min(count, (size_t)4);
5919 + if (copy_from_user(&value, buf, count))
5922 + /* Assuming big endian */
5923 + mask <<= (4 - count) * 8;
5924 + mask &= gpio->pin_mask;
5926 + at32_gpio_set_value_multiple(gpio->port, value, mask);
5931 +static struct file_operations gpio_dev_fops = {
5932 + .owner = THIS_MODULE,
5933 + .llseek = no_llseek,
5934 + .open = gpio_dev_open,
5935 + .release = gpio_dev_release,
5936 + .fasync = gpio_dev_fasync,
5937 + .poll = gpio_dev_poll,
5938 + .read = gpio_dev_read,
5939 + .write = gpio_dev_write,
5942 +static struct gpio_item *to_gpio_item(struct config_item *item)
5944 + return item ? container_of(item, struct gpio_item, item) : NULL;
5947 +static ssize_t gpio_show_gpio_id(struct gpio_item *gpio, char *page)
5949 + return sprintf(page, "%d\n", gpio->port);
5952 +static ssize_t gpio_store_gpio_id(struct gpio_item *gpio,
5953 + const char *page, size_t count)
5956 + char *p = (char *)page;
5957 + ssize_t ret = -EINVAL;
5959 + id = simple_strtoul(p, &p, 0);
5960 + if (!p || (*p && (*p != '\n')))
5963 + /* Switching PIO is not allowed when live... */
5964 + spin_lock(&gpio->lock);
5965 + if (!gpio->enabled) {
5967 + if (at32_gpio_port_is_valid(id)) {
5972 + spin_unlock(&gpio->lock);
5977 +static ssize_t gpio_show_pin_mask(struct gpio_item *gpio, char *page)
5979 + return sprintf(page, "0x%08x\n", gpio->pin_mask);
5982 +static ssize_t gpio_store_pin_mask(struct gpio_item *gpio,
5983 + const char *page, size_t count)
5986 + char *p = (char *)page;
5987 + ssize_t ret = -EINVAL;
5989 + new_mask = simple_strtoul(p, &p, 0);
5990 + if (!p || (*p && (*p != '\n')))
5993 + /* Can't update the pin mask while live. */
5994 + spin_lock(&gpio->lock);
5995 + if (!gpio->enabled) {
5996 + gpio->oe_mask &= new_mask;
5997 + gpio->pin_mask = new_mask;
6000 + spin_unlock(&gpio->lock);
6005 +static ssize_t gpio_show_oe_mask(struct gpio_item *gpio, char *page)
6007 + return sprintf(page, "0x%08x\n", gpio->oe_mask);
6010 +static ssize_t gpio_store_oe_mask(struct gpio_item *gpio,
6011 + const char *page, size_t count)
6014 + char *p = (char *)page;
6015 + ssize_t ret = -EINVAL;
6017 + mask = simple_strtoul(p, &p, 0);
6018 + if (!p || (*p && (*p != '\n')))
6021 + spin_lock(&gpio->lock);
6022 + if (!gpio->enabled) {
6023 + gpio->oe_mask = mask & gpio->pin_mask;
6026 + spin_unlock(&gpio->lock);
6031 +static ssize_t gpio_show_enabled(struct gpio_item *gpio, char *page)
6033 + return sprintf(page, "%d\n", gpio->enabled);
6036 +static ssize_t gpio_store_enabled(struct gpio_item *gpio,
6037 + const char *page, size_t count)
6039 + char *p = (char *)page;
6043 + enabled = simple_strtoul(p, &p, 0);
6044 + if (!p || (*p && (*p != '\n')))
6047 + /* make it a boolean value */
6048 + enabled = !!enabled;
6050 + if (gpio->enabled == enabled)
6051 + /* No change; do nothing. */
6054 + BUG_ON(gpio->id >= GPIO_DEV_MAX);
6057 + class_device_unregister(gpio->gpio_dev);
6058 + cdev_del(&gpio->char_dev);
6059 + at32_deselect_pins(gpio->port, gpio->pin_mask);
6060 + gpio->initialized = 0;
6062 + if (gpio->port < 0 || !gpio->pin_mask)
6066 + /* Disallow any updates to gpio_id or pin_mask */
6067 + spin_lock(&gpio->lock);
6068 + gpio->enabled = enabled;
6069 + spin_unlock(&gpio->lock);
6074 + /* Now, try to allocate the pins */
6075 + ret = at32_select_gpio_pins(gpio->port, gpio->pin_mask, gpio->oe_mask);
6077 + goto err_alloc_pins;
6079 + gpio->initialized = 1;
6081 + cdev_init(&gpio->char_dev, &gpio_dev_fops);
6082 + gpio->char_dev.owner = THIS_MODULE;
6083 + ret = cdev_add(&gpio->char_dev, MKDEV(MAJOR(gpio_devt), gpio->id), 1);
6085 + goto err_cdev_add;
6086 + gpio->gpio_dev = class_device_create(gpio_dev_class, NULL,
6087 + MKDEV(MAJOR(gpio_devt), gpio->id),
6089 + "gpio%d", gpio->id);
6090 + if (IS_ERR(gpio->gpio_dev)) {
6091 + printk(KERN_ERR "failed to create gpio%d\n", gpio->id);
6092 + ret = PTR_ERR(gpio->gpio_dev);
6093 + goto err_class_dev;
6096 + printk(KERN_INFO "created gpio%d (port%d/0x%08x) as (%d:%d)\n",
6097 + gpio->id, gpio->port, gpio->pin_mask,
6098 + MAJOR(gpio->gpio_dev->devt), MINOR(gpio->gpio_dev->devt));
6103 + cdev_del(&gpio->char_dev);
6105 + at32_deselect_pins(gpio->port, gpio->pin_mask);
6106 + gpio->initialized = 0;
6108 + spin_lock(&gpio->lock);
6109 + gpio->enabled = 0;
6110 + spin_unlock(&gpio->lock);
6115 +static struct gpio_attribute gpio_item_attr_gpio_id = {
6117 + .ca_owner = THIS_MODULE,
6118 + .ca_name = "gpio_id",
6119 + .ca_mode = S_IRUGO | S_IWUSR,
6121 + .show = gpio_show_gpio_id,
6122 + .store = gpio_store_gpio_id,
6124 +static struct gpio_attribute gpio_item_attr_pin_mask = {
6126 + .ca_owner = THIS_MODULE,
6127 + .ca_name = "pin_mask",
6128 + .ca_mode = S_IRUGO | S_IWUSR,
6130 + .show = gpio_show_pin_mask,
6131 + .store = gpio_store_pin_mask,
6133 +static struct gpio_attribute gpio_item_attr_oe_mask = {
6135 + .ca_owner = THIS_MODULE,
6136 + .ca_name = "oe_mask",
6137 + .ca_mode = S_IRUGO | S_IWUSR,
6139 + .show = gpio_show_oe_mask,
6140 + .store = gpio_store_oe_mask,
6142 +static struct gpio_attribute gpio_item_attr_enabled = {
6144 + .ca_owner = THIS_MODULE,
6145 + .ca_name = "enabled",
6146 + .ca_mode = S_IRUGO | S_IWUSR,
6148 + .show = gpio_show_enabled,
6149 + .store = gpio_store_enabled,
6152 +static struct configfs_attribute *gpio_item_attrs[] = {
6153 + &gpio_item_attr_gpio_id.attr,
6154 + &gpio_item_attr_pin_mask.attr,
6155 + &gpio_item_attr_oe_mask.attr,
6156 + &gpio_item_attr_enabled.attr,
6160 +static ssize_t gpio_show_attr(struct config_item *item,
6161 + struct configfs_attribute *attr,
6164 + struct gpio_item *gpio_item = to_gpio_item(item);
6165 + struct gpio_attribute *gpio_attr
6166 + = container_of(attr, struct gpio_attribute, attr);
6169 + if (gpio_attr->show)
6170 + ret = gpio_attr->show(gpio_item, page);
6174 +static ssize_t gpio_store_attr(struct config_item *item,
6175 + struct configfs_attribute *attr,
6176 + const char *page, size_t count)
6178 + struct gpio_item *gpio_item = to_gpio_item(item);
6179 + struct gpio_attribute *gpio_attr
6180 + = container_of(attr, struct gpio_attribute, attr);
6181 + ssize_t ret = -EINVAL;
6183 + if (gpio_attr->store)
6184 + ret = gpio_attr->store(gpio_item, page, count);
6188 +static void gpio_release(struct config_item *item)
6190 + kfree(to_gpio_item(item));
6193 +static struct configfs_item_operations gpio_item_ops = {
6194 + .release = gpio_release,
6195 + .show_attribute = gpio_show_attr,
6196 + .store_attribute = gpio_store_attr,
6199 +static struct config_item_type gpio_item_type = {
6200 + .ct_item_ops = &gpio_item_ops,
6201 + .ct_attrs = gpio_item_attrs,
6202 + .ct_owner = THIS_MODULE,
6205 +static struct config_item *gpio_make_item(struct config_group *group,
6208 + static int next_id;
6209 + struct gpio_item *gpio;
6211 + if (next_id >= GPIO_DEV_MAX)
6214 + gpio = kzalloc(sizeof(struct gpio_item), GFP_KERNEL);
6218 + gpio->id = next_id++;
6219 + config_item_init_type_name(&gpio->item, name, &gpio_item_type);
6220 + spin_lock_init(&gpio->lock);
6221 + init_waitqueue_head(&gpio->change_wq);
6223 + return &gpio->item;
6226 +static void gpio_drop_item(struct config_group *group,
6227 + struct config_item *item)
6229 + struct gpio_item *gpio = to_gpio_item(item);
6231 + spin_lock(&gpio->lock);
6232 + if (gpio->enabled) {
6233 + class_device_unregister(gpio->gpio_dev);
6234 + cdev_del(&gpio->char_dev);
6237 + if (gpio->initialized) {
6238 + at32_deselect_pins(gpio->port, gpio->pin_mask);
6239 + gpio->initialized = 0;
6240 + gpio->enabled = 0;
6242 + spin_unlock(&gpio->lock);
6245 +static struct configfs_group_operations gpio_group_ops = {
6246 + .make_item = gpio_make_item,
6247 + .drop_item = gpio_drop_item,
6250 +static struct config_item_type gpio_group_type = {
6251 + .ct_group_ops = &gpio_group_ops,
6252 + .ct_owner = THIS_MODULE,
6255 +static struct configfs_subsystem gpio_subsys = {
6258 + .ci_namebuf = "gpio",
6259 + .ci_type = &gpio_group_type,
6264 +static int __init gpio_dev_init(void)
6268 + gpio_dev_class = class_create(THIS_MODULE, "gpio-dev");
6269 + if (IS_ERR(gpio_dev_class)) {
6270 + err = PTR_ERR(gpio_dev_class);
6271 + goto err_class_create;
6274 + err = alloc_chrdev_region(&gpio_devt, 0, GPIO_DEV_MAX, "gpio");
6276 + goto err_alloc_chrdev;
6278 + /* Configfs initialization */
6279 + config_group_init(&gpio_subsys.su_group);
6280 + mutex_init(&gpio_subsys.su_mutex);
6281 + err = configfs_register_subsystem(&gpio_subsys);
6283 + goto err_register_subsys;
6287 +err_register_subsys:
6288 + unregister_chrdev_region(gpio_devt, GPIO_DEV_MAX);
6290 + class_destroy(gpio_dev_class);
6292 + printk(KERN_WARNING "Failed to initialize gpio /dev interface\n");
6295 +late_initcall(gpio_dev_init);
6296 --- a/arch/avr32/mach-at32ap/hsmc.c
6297 +++ b/arch/avr32/mach-at32ap/hsmc.c
6300 return platform_driver_register(&hsmc_driver);
6302 -arch_initcall(hsmc_init);
6303 +core_initcall(hsmc_init);
6304 --- a/arch/avr32/mach-at32ap/intc.c
6305 +++ b/arch/avr32/mach-at32ap/intc.c
6308 - * Copyright (C) 2006 Atmel Corporation
6309 + * Copyright (C) 2006, 2008 Atmel Corporation
6311 * This program is free software; you can redistribute it and/or modify
6312 * it under the terms of the GNU General Public License version 2 as
6314 #include <linux/interrupt.h>
6315 #include <linux/irq.h>
6316 #include <linux/platform_device.h>
6317 +#include <linux/sysdev.h>
6319 -#include <asm/intc.h>
6325 - void __iomem *regs;
6326 - struct irq_chip chip;
6327 + void __iomem *regs;
6328 + struct irq_chip chip;
6329 + struct sys_device sysdev;
6331 + unsigned long suspend_ipr;
6332 + unsigned long saved_ipr[64];
6336 extern struct platform_device at32_intc0_device;
6337 @@ -137,6 +142,74 @@
6338 panic("Interrupt controller initialization failed!\n");
6342 +void intc_set_suspend_handler(unsigned long offset)
6344 + intc0.suspend_ipr = offset;
6347 +static int intc_suspend(struct sys_device *sdev, pm_message_t state)
6349 + struct intc *intc = container_of(sdev, struct intc, sysdev);
6352 + if (unlikely(!irqs_disabled())) {
6353 + pr_err("intc_suspend: called with interrupts enabled\n");
6357 + if (unlikely(!intc->suspend_ipr)) {
6358 + pr_err("intc_suspend: suspend_ipr not initialized\n");
6362 + for (i = 0; i < 64; i++) {
6363 + intc->saved_ipr[i] = intc_readl(intc, INTPR0 + 4 * i);
6364 + intc_writel(intc, INTPR0 + 4 * i, intc->suspend_ipr);
6370 +static int intc_resume(struct sys_device *sdev)
6372 + struct intc *intc = container_of(sdev, struct intc, sysdev);
6375 + WARN_ON(!irqs_disabled());
6377 + for (i = 0; i < 64; i++)
6378 + intc_writel(intc, INTPR0 + 4 * i, intc->saved_ipr[i]);
6383 +#define intc_suspend NULL
6384 +#define intc_resume NULL
6387 +static struct sysdev_class intc_class = {
6389 + .suspend = intc_suspend,
6390 + .resume = intc_resume,
6393 +static int __init intc_init_sysdev(void)
6397 + ret = sysdev_class_register(&intc_class);
6401 + intc0.sysdev.id = 0;
6402 + intc0.sysdev.cls = &intc_class;
6403 + ret = sysdev_register(&intc0.sysdev);
6407 +device_initcall(intc_init_sysdev);
6409 unsigned long intc_get_pending(unsigned int group)
6411 return intc_readl(&intc0, INTREQ0 + 4 * group);
6412 --- a/arch/avr32/mach-at32ap/Kconfig
6413 +++ b/arch/avr32/mach-at32ap/Kconfig
6419 + bool "GPIO /dev interface"
6420 + select CONFIGFS_FS
6423 + Say `Y' to enable a /dev interface to the GPIO pins.
6427 endif # PLATFORM_AT32AP
6428 --- a/arch/avr32/mach-at32ap/Makefile
6429 +++ b/arch/avr32/mach-at32ap/Makefile
6431 -obj-y += at32ap.o clock.o intc.o extint.o pio.o hsmc.o
6432 -obj-$(CONFIG_CPU_AT32AP700X) += at32ap700x.o
6433 -obj-$(CONFIG_CPU_AT32AP700X) += time-tc.o
6434 +obj-y += pdc.o clock.o intc.o extint.o pio.o hsmc.o
6435 +obj-$(CONFIG_CPU_AT32AP700X) += at32ap700x.o pm-at32ap700x.o
6436 obj-$(CONFIG_CPU_FREQ_AT32AP) += cpufreq.o
6437 +obj-$(CONFIG_GPIO_DEV) += gpio-dev.o
6438 +obj-$(CONFIG_PM) += pm.o
6440 +ifeq ($(CONFIG_PM_DEBUG),y)
6441 +CFLAGS_pm.o += -DDEBUG
6444 +++ b/arch/avr32/mach-at32ap/pdc.c
6447 + * Copyright (C) 2006 Atmel Corporation
6449 + * This program is free software; you can redistribute it and/or modify
6450 + * it under the terms of the GNU General Public License version 2 as
6451 + * published by the Free Software Foundation.
6454 +#include <linux/clk.h>
6455 +#include <linux/err.h>
6456 +#include <linux/init.h>
6457 +#include <linux/platform_device.h>
6459 +static int __init pdc_probe(struct platform_device *pdev)
6461 + struct clk *pclk, *hclk;
6463 + pclk = clk_get(&pdev->dev, "pclk");
6464 + if (IS_ERR(pclk)) {
6465 + dev_err(&pdev->dev, "no pclk defined\n");
6466 + return PTR_ERR(pclk);
6468 + hclk = clk_get(&pdev->dev, "hclk");
6469 + if (IS_ERR(hclk)) {
6470 + dev_err(&pdev->dev, "no hclk defined\n");
6472 + return PTR_ERR(hclk);
6478 + dev_info(&pdev->dev, "Atmel Peripheral DMA Controller enabled\n");
6482 +static struct platform_driver pdc_driver = {
6483 + .probe = pdc_probe,
6489 +static int __init pdc_init(void)
6491 + return platform_driver_register(&pdc_driver);
6493 +arch_initcall(pdc_init);
6494 --- a/arch/avr32/mach-at32ap/pio.c
6495 +++ b/arch/avr32/mach-at32ap/pio.c
6496 @@ -157,6 +157,82 @@
6500 +#ifdef CONFIG_GPIO_DEV
6502 +/* Gang allocators and accessors; used by the GPIO /dev driver */
6503 +int at32_gpio_port_is_valid(unsigned int port)
6505 + return port < MAX_NR_PIO_DEVICES && pio_dev[port].regs != NULL;
6508 +int at32_select_gpio_pins(unsigned int port, u32 pins, u32 oe_mask)
6510 + struct pio_device *pio;
6513 + pio = &pio_dev[port];
6514 + BUG_ON(port > ARRAY_SIZE(pio_dev) || !pio->regs || (oe_mask & ~pins));
6516 + /* Try to allocate the pins */
6518 + old = pio->pinmux_mask;
6523 + } while (cmpxchg(&pio->pinmux_mask, old, new) != old);
6525 + /* That went well, now configure the port */
6526 + pio_writel(pio, OER, oe_mask);
6527 + pio_writel(pio, PER, pins);
6532 +void at32_deselect_pins(unsigned int port, u32 pins)
6534 + struct pio_device *pio;
6537 + pio = &pio_dev[port];
6538 + BUG_ON(port > ARRAY_SIZE(pio_dev) || !pio->regs);
6540 + /* Return to a "safe" mux configuration */
6541 + pio_writel(pio, PUER, pins);
6542 + pio_writel(pio, ODR, pins);
6544 + /* Deallocate the pins */
6546 + old = pio->pinmux_mask;
6547 + new = old & ~pins;
6548 + } while (cmpxchg(&pio->pinmux_mask, old, new) != old);
6551 +u32 at32_gpio_get_value_multiple(unsigned int port, u32 pins)
6553 + struct pio_device *pio;
6555 + pio = &pio_dev[port];
6556 + BUG_ON(port > ARRAY_SIZE(pio_dev) || !pio->regs);
6558 + return pio_readl(pio, PDSR) & pins;
6561 +void at32_gpio_set_value_multiple(unsigned int port, u32 value, u32 mask)
6563 + struct pio_device *pio;
6565 + pio = &pio_dev[port];
6566 + BUG_ON(port > ARRAY_SIZE(pio_dev) || !pio->regs);
6568 + /* No atomic updates for now... */
6569 + pio_writel(pio, CODR, ~value & mask);
6570 + pio_writel(pio, SODR, value & mask);
6573 +#endif /* CONFIG_GPIO_DEV */
6576 /*--------------------------------------------------------------------------*/
6582 label = gpiochip_is_requested(chip, i);
6583 + if (!label && (imr & mask))
6589 +++ b/arch/avr32/mach-at32ap/pm-at32ap700x.S
6592 + * Low-level Power Management code.
6594 + * Copyright (C) 2008 Atmel Corporation
6596 + * This program is free software; you can redistribute it and/or modify
6597 + * it under the terms of the GNU General Public License version 2 as
6598 + * published by the Free Software Foundation.
6600 +#include <asm/asm.h>
6601 +#include <asm/asm-offsets.h>
6602 +#include <asm/thread_info.h>
6603 +#include <asm/arch/pm.h>
6606 +#include "sdramc.h"
6608 +/* Same as 0xfff00000 but fits in a 21 bit signed immediate */
6609 +#define PM_BASE -0x100000
6611 + .section .bss, "wa", @nobits
6612 + .global disable_idle_sleep
6613 + .type disable_idle_sleep, @object
6614 +disable_idle_sleep:
6616 + .size disable_idle_sleep, . - disable_idle_sleep
6618 + /* Keep this close to the irq handlers */
6619 + .section .irq.text, "ax", @progbits
6622 + * void cpu_enter_idle(void)
6624 + * Put the CPU into "idle" mode, in which it will consume
6625 + * significantly less power.
6627 + * If an interrupt comes along in the window between
6628 + * unmask_interrupts and the sleep instruction below, the
6629 + * interrupt code will adjust the return address so that we
6630 + * never execute the sleep instruction. This is required
6631 + * because the AP7000 doesn't unmask interrupts when entering
6632 + * sleep modes; later CPUs may not need this workaround.
6634 + .global cpu_enter_idle
6635 + .type cpu_enter_idle, @function
6638 + get_thread_info r8
6639 + ld.w r9, r8[TI_flags]
6640 + bld r9, TIF_NEED_RESCHED
6641 + brcs .Lret_from_sleep
6642 + sbr r9, TIF_CPU_GOING_TO_SLEEP
6643 + st.w r8[TI_flags], r9
6645 + sleep CPU_SLEEP_IDLE
6646 + .size cpu_idle_sleep, . - cpu_idle_sleep
6649 + * Common return path for PM functions that don't run from
6652 + .global cpu_idle_skip_sleep
6653 + .type cpu_idle_skip_sleep, @function
6654 +cpu_idle_skip_sleep:
6656 + ld.w r9, r8[TI_flags]
6657 + cbr r9, TIF_CPU_GOING_TO_SLEEP
6658 + st.w r8[TI_flags], r9
6662 + .size cpu_idle_skip_sleep, . - cpu_idle_skip_sleep
6665 + .section .init.text, "ax", @progbits
6667 + .global pm_exception
6668 + .type pm_exception, @function
6671 + * Exceptions are masked when we switch to this handler, so
6672 + * we'll only get "unrecoverable" exceptions (offset 0.)
6674 + sub r12, pc, . - .Lpanic_msg
6675 + lddpc pc, .Lpanic_addr
6681 + .asciz "Unrecoverable exception during suspend\n"
6682 + .size pm_exception, . - pm_exception
6685 + .type pm_irq0, @function
6687 + /* Disable interrupts and return after the sleep instruction */
6688 + mfsr r9, SYSREG_RSR_INT0
6689 + mtsr SYSREG_RAR_INT0, r8
6690 + sbr r9, SYSREG_GM_OFFSET
6691 + mtsr SYSREG_RSR_INT0, r9
6695 + * void cpu_enter_standby(unsigned long sdramc_base)
6697 + * Enter PM_SUSPEND_STANDBY mode. At this point, all drivers
6698 + * are suspended and interrupts are disabled. Interrupts
6699 + * marked as 'wakeup' event sources may still come along and
6700 + * get us out of here.
6702 + * The SDRAM will be put into self-refresh mode (which does
6703 + * not require a clock from the CPU), and the CPU will be put
6704 + * into "frozen" mode (HSB bus stopped). The SDRAM controller
6705 + * will automatically bring the SDRAM into normal mode on the
6706 + * first access, and the power manager will automatically
6707 + * start the HSB and CPU clocks upon a wakeup event.
6709 + * This code uses the same "skip sleep" technique as above.
6710 + * It is very important that we jump directly to
6711 + * cpu_after_sleep after the sleep instruction since that's
6712 + * where we'll end up if the interrupt handler decides that we
6713 + * need to skip the sleep instruction.
6715 + .global pm_standby
6716 + .type pm_standby, @function
6719 + * interrupts are already masked at this point, and EVBA
6720 + * points to pm_exception above.
6722 + ld.w r10, r12[SDRAMC_LPR]
6723 + sub r8, pc, . - 1f /* return address for irq handler */
6724 + mov r11, SDRAMC_LPR_LPCB_SELF_RFR
6725 + bfins r10, r11, 0, 2 /* LPCB <- self Refresh */
6726 + sync 0 /* flush write buffer */
6727 + st.w r12[SDRAMC_LPR], r11 /* put SDRAM in self-refresh mode */
6728 + ld.w r11, r12[SDRAMC_LPR]
6730 + sleep CPU_SLEEP_FROZEN
6733 + .size pm_standby, . - pm_standby
6735 + .global pm_suspend_to_ram
6736 + .type pm_suspend_to_ram, @function
6739 + * interrupts are already masked at this point, and EVBA
6740 + * points to pm_exception above.
6743 + cache r11[2], 8 /* clean all dcache lines */
6744 + sync 0 /* flush write buffer */
6745 + ld.w r10, r12[SDRAMC_LPR]
6746 + sub r8, pc, . - 1f /* return address for irq handler */
6747 + mov r11, SDRAMC_LPR_LPCB_SELF_RFR
6748 + bfins r10, r11, 0, 2 /* LPCB <- self refresh */
6749 + st.w r12[SDRAMC_LPR], r10 /* put SDRAM in self-refresh mode */
6750 + ld.w r11, r12[SDRAMC_LPR]
6753 + sleep CPU_SLEEP_STOP
6757 + .size pm_suspend_to_ram, . - pm_suspend_to_ram
6759 + .global pm_sram_end
6760 + .type pm_sram_end, @function
6762 + .size pm_sram_end, 0
6764 +#endif /* CONFIG_PM */
6766 +++ b/arch/avr32/mach-at32ap/pm.c
6769 + * AVR32 AP Power Management
6771 + * Copyright (C) 2008 Atmel Corporation
6773 + * This program is free software; you can redistribute it and/or
6774 + * modify it under the terms of the GNU General Public License
6775 + * version 2 as published by the Free Software Foundation.
6777 +#include <linux/io.h>
6778 +#include <linux/suspend.h>
6779 +#include <linux/vmalloc.h>
6781 +#include <asm/cacheflush.h>
6782 +#include <asm/sysreg.h>
6784 +#include <asm/arch/pm.h>
6785 +#include <asm/arch/sram.h>
6787 +/* FIXME: This is only valid for AP7000 */
6788 +#define SDRAMC_BASE 0xfff03800
6790 +#include "sdramc.h"
6792 +#define SRAM_PAGE_FLAGS (SYSREG_BIT(TLBELO_D) | SYSREG_BF(SZ, 1) \
6793 + | SYSREG_BF(AP, 3) | SYSREG_BIT(G))
6796 +static unsigned long pm_sram_start;
6797 +static size_t pm_sram_size;
6798 +static struct vm_struct *pm_sram_area;
6800 +static void (*avr32_pm_enter_standby)(unsigned long sdramc_base);
6801 +static void (*avr32_pm_enter_str)(unsigned long sdramc_base);
6804 + * Must be called with interrupts disabled. Exceptions will be masked
6805 + * on return (i.e. all exceptions will be "unrecoverable".)
6807 +static void *avr32_pm_map_sram(void)
6809 + unsigned long vaddr;
6810 + unsigned long page_addr;
6814 + vaddr = (unsigned long)pm_sram_area->addr;
6815 + page_addr = pm_sram_start & PAGE_MASK;
6818 + * Mask exceptions and grab the first TLB entry. We won't be
6819 + * needing it while sleeping.
6821 + asm volatile("ssrf %0" : : "i"(SYSREG_EM_OFFSET) : "memory");
6823 + mmucr = sysreg_read(MMUCR);
6824 + tlbehi = sysreg_read(TLBEHI);
6825 + sysreg_write(MMUCR, SYSREG_BFINS(DRP, 0, mmucr));
6827 + tlbehi = SYSREG_BF(ASID, SYSREG_BFEXT(ASID, tlbehi));
6828 + tlbehi |= vaddr & PAGE_MASK;
6829 + tlbehi |= SYSREG_BIT(TLBEHI_V);
6831 + sysreg_write(TLBELO, page_addr | SRAM_PAGE_FLAGS);
6832 + sysreg_write(TLBEHI, tlbehi);
6835 + return (void *)(vaddr + pm_sram_start - page_addr);
6839 + * Must be called with interrupts disabled. Exceptions will be
6840 + * unmasked on return.
6842 +static void avr32_pm_unmap_sram(void)
6848 + /* Going to update TLB entry at index 0 */
6849 + mmucr = sysreg_read(MMUCR);
6850 + tlbehi = sysreg_read(TLBEHI);
6851 + sysreg_write(MMUCR, SYSREG_BFINS(DRP, 0, mmucr));
6853 + /* Clear the "valid" bit */
6854 + tlbehi = SYSREG_BF(ASID, SYSREG_BFEXT(ASID, tlbehi));
6855 + sysreg_write(TLBEHI, tlbehi);
6857 + /* Mark it as "not accessed" */
6858 + tlbarlo = sysreg_read(TLBARLO);
6859 + sysreg_write(TLBARLO, tlbarlo | 0x80000000U);
6861 + /* Update the TLB */
6864 + /* Unmask exceptions */
6865 + asm volatile("csrf %0" : : "i"(SYSREG_EM_OFFSET) : "memory");
6868 +static int avr32_pm_valid_state(suspend_state_t state)
6871 + case PM_SUSPEND_ON:
6872 + case PM_SUSPEND_STANDBY:
6873 + case PM_SUSPEND_MEM:
6881 +static int avr32_pm_enter(suspend_state_t state)
6888 + case PM_SUSPEND_STANDBY:
6889 + sram = avr32_pm_map_sram();
6891 + /* Switch to in-sram exception handlers */
6892 + evba_saved = sysreg_read(EVBA);
6893 + sysreg_write(EVBA, (unsigned long)sram);
6896 + * Save the LPR register so that we can re-enable
6897 + * SDRAM Low Power mode on resume.
6899 + lpr_saved = sdramc_readl(LPR);
6900 + pr_debug("%s: Entering standby...\n", __func__);
6901 + avr32_pm_enter_standby(SDRAMC_BASE);
6902 + sdramc_writel(LPR, lpr_saved);
6904 + /* Switch back to regular exception handlers */
6905 + sysreg_write(EVBA, evba_saved);
6907 + avr32_pm_unmap_sram();
6910 + case PM_SUSPEND_MEM:
6911 + sram = avr32_pm_map_sram();
6913 + /* Switch to in-sram exception handlers */
6914 + evba_saved = sysreg_read(EVBA);
6915 + sysreg_write(EVBA, (unsigned long)sram);
6918 + * Save the LPR register so that we can re-enable
6919 + * SDRAM Low Power mode on resume.
6921 + lpr_saved = sdramc_readl(LPR);
6922 + pr_debug("%s: Entering suspend-to-ram...\n", __func__);
6923 + avr32_pm_enter_str(SDRAMC_BASE);
6924 + sdramc_writel(LPR, lpr_saved);
6926 + /* Switch back to regular exception handlers */
6927 + sysreg_write(EVBA, evba_saved);
6929 + avr32_pm_unmap_sram();
6932 + case PM_SUSPEND_ON:
6933 + pr_debug("%s: Entering idle...\n", __func__);
6938 + pr_debug("%s: Invalid suspend state %d\n", __func__, state);
6942 + pr_debug("%s: wakeup\n", __func__);
6948 +static struct platform_suspend_ops avr32_pm_ops = {
6949 + .valid = avr32_pm_valid_state,
6950 + .enter = avr32_pm_enter,
6953 +static unsigned long avr32_pm_offset(void *symbol)
6955 + extern u8 pm_exception[];
6957 + return (unsigned long)symbol - (unsigned long)pm_exception;
6960 +static int __init avr32_pm_init(void)
6962 + extern u8 pm_exception[];
6963 + extern u8 pm_irq0[];
6964 + extern u8 pm_standby[];
6965 + extern u8 pm_suspend_to_ram[];
6966 + extern u8 pm_sram_end[];
6970 + * To keep things simple, we depend on not needing more than a
6973 + pm_sram_size = avr32_pm_offset(pm_sram_end);
6974 + if (pm_sram_size > PAGE_SIZE)
6977 + pm_sram_start = sram_alloc(pm_sram_size);
6978 + if (!pm_sram_start)
6979 + goto err_alloc_sram;
6981 + /* Grab a virtual area we can use later on. */
6982 + pm_sram_area = get_vm_area(pm_sram_size, VM_IOREMAP);
6983 + if (!pm_sram_area)
6985 + pm_sram_area->phys_addr = pm_sram_start;
6987 + local_irq_disable();
6988 + dst = avr32_pm_map_sram();
6989 + memcpy(dst, pm_exception, pm_sram_size);
6990 + flush_dcache_region(dst, pm_sram_size);
6991 + invalidate_icache_region(dst, pm_sram_size);
6992 + avr32_pm_unmap_sram();
6993 + local_irq_enable();
6995 + avr32_pm_enter_standby = dst + avr32_pm_offset(pm_standby);
6996 + avr32_pm_enter_str = dst + avr32_pm_offset(pm_suspend_to_ram);
6997 + intc_set_suspend_handler(avr32_pm_offset(pm_irq0));
6999 + suspend_set_ops(&avr32_pm_ops);
7001 + printk("AVR32 AP Power Management enabled\n");
7006 + sram_free(pm_sram_start, pm_sram_size);
7009 + pr_err("AVR32 Power Management initialization failed\n");
7012 +arch_initcall(avr32_pm_init);
7014 +++ b/arch/avr32/mach-at32ap/sdramc.h
7017 + * Register definitions for the AT32AP SDRAM Controller
7019 + * Copyright (C) 2008 Atmel Corporation
7021 + * This program is free software; you can redistribute it and/or
7022 + * modify it under the terms of the GNU General Public License
7023 + * version 2 as published by the Free Software Foundation.
7026 +/* Register offsets */
7027 +#define SDRAMC_MR 0x0000
7028 +#define SDRAMC_TR 0x0004
7029 +#define SDRAMC_CR 0x0008
7030 +#define SDRAMC_HSR 0x000c
7031 +#define SDRAMC_LPR 0x0010
7032 +#define SDRAMC_IER 0x0014
7033 +#define SDRAMC_IDR 0x0018
7034 +#define SDRAMC_IMR 0x001c
7035 +#define SDRAMC_ISR 0x0020
7036 +#define SDRAMC_MDR 0x0024
7038 +/* MR - Mode Register */
7039 +#define SDRAMC_MR_MODE_NORMAL ( 0 << 0)
7040 +#define SDRAMC_MR_MODE_NOP ( 1 << 0)
7041 +#define SDRAMC_MR_MODE_BANKS_PRECHARGE ( 2 << 0)
7042 +#define SDRAMC_MR_MODE_LOAD_MODE ( 3 << 0)
7043 +#define SDRAMC_MR_MODE_AUTO_REFRESH ( 4 << 0)
7044 +#define SDRAMC_MR_MODE_EXT_LOAD_MODE ( 5 << 0)
7045 +#define SDRAMC_MR_MODE_POWER_DOWN ( 6 << 0)
7047 +/* CR - Configuration Register */
7048 +#define SDRAMC_CR_NC_8_BITS ( 0 << 0)
7049 +#define SDRAMC_CR_NC_9_BITS ( 1 << 0)
7050 +#define SDRAMC_CR_NC_10_BITS ( 2 << 0)
7051 +#define SDRAMC_CR_NC_11_BITS ( 3 << 0)
7052 +#define SDRAMC_CR_NR_11_BITS ( 0 << 2)
7053 +#define SDRAMC_CR_NR_12_BITS ( 1 << 2)
7054 +#define SDRAMC_CR_NR_13_BITS ( 2 << 2)
7055 +#define SDRAMC_CR_NB_2_BANKS ( 0 << 4)
7056 +#define SDRAMC_CR_NB_4_BANKS ( 1 << 4)
7057 +#define SDRAMC_CR_CAS(x) ((x) << 5)
7058 +#define SDRAMC_CR_DBW_32_BITS ( 0 << 7)
7059 +#define SDRAMC_CR_DBW_16_BITS ( 1 << 7)
7060 +#define SDRAMC_CR_TWR(x) ((x) << 8)
7061 +#define SDRAMC_CR_TRC(x) ((x) << 12)
7062 +#define SDRAMC_CR_TRP(x) ((x) << 16)
7063 +#define SDRAMC_CR_TRCD(x) ((x) << 20)
7064 +#define SDRAMC_CR_TRAS(x) ((x) << 24)
7065 +#define SDRAMC_CR_TXSR(x) ((x) << 28)
7067 +/* HSR - High Speed Register */
7068 +#define SDRAMC_HSR_DA ( 1 << 0)
7070 +/* LPR - Low Power Register */
7071 +#define SDRAMC_LPR_LPCB_INHIBIT ( 0 << 0)
7072 +#define SDRAMC_LPR_LPCB_SELF_RFR ( 1 << 0)
7073 +#define SDRAMC_LPR_LPCB_PDOWN ( 2 << 0)
7074 +#define SDRAMC_LPR_LPCB_DEEP_PDOWN ( 3 << 0)
7075 +#define SDRAMC_LPR_PASR(x) ((x) << 4)
7076 +#define SDRAMC_LPR_TCSR(x) ((x) << 8)
7077 +#define SDRAMC_LPR_DS(x) ((x) << 10)
7078 +#define SDRAMC_LPR_TIMEOUT(x) ((x) << 12)
7080 +/* IER/IDR/IMR/ISR - Interrupt Enable/Disable/Mask/Status Register */
7081 +#define SDRAMC_ISR_RES ( 1 << 0)
7083 +/* MDR - Memory Device Register */
7084 +#define SDRAMC_MDR_MD_SDRAM ( 0 << 0)
7085 +#define SDRAMC_MDR_MD_LOW_PWR_SDRAM ( 1 << 0)
7087 +/* Register access macros */
7088 +#define sdramc_readl(reg) \
7089 + __raw_readl((void __iomem __force *)SDRAMC_BASE + SDRAMC_##reg)
7090 +#define sdramc_writel(reg, value) \
7091 + __raw_writel(value, (void __iomem __force *)SDRAMC_BASE + SDRAMC_##reg)
7092 --- a/arch/avr32/mach-at32ap/time-tc.c
7096 - * Copyright (C) 2004-2007 Atmel Corporation
7098 - * Based on MIPS implementation arch/mips/kernel/time.c
7099 - * Copyright 2001 MontaVista Software Inc.
7101 - * This program is free software; you can redistribute it and/or modify
7102 - * it under the terms of the GNU General Public License version 2 as
7103 - * published by the Free Software Foundation.
7106 -#include <linux/clk.h>
7107 -#include <linux/clocksource.h>
7108 -#include <linux/time.h>
7109 -#include <linux/module.h>
7110 -#include <linux/interrupt.h>
7111 -#include <linux/irq.h>
7112 -#include <linux/kernel_stat.h>
7113 -#include <linux/errno.h>
7114 -#include <linux/init.h>
7115 -#include <linux/profile.h>
7116 -#include <linux/sysdev.h>
7117 -#include <linux/err.h>
7119 -#include <asm/div64.h>
7120 -#include <asm/sysreg.h>
7121 -#include <asm/io.h>
7122 -#include <asm/sections.h>
7124 -#include <asm/arch/time.h>
7126 -/* how many counter cycles in a jiffy? */
7127 -static u32 cycles_per_jiffy;
7129 -/* the count value for the next timer interrupt */
7130 -static u32 expirelo;
7132 -/* the I/O registers of the TC module */
7133 -static void __iomem *ioregs;
7135 -cycle_t read_cycle_count(void)
7137 - return (cycle_t)timer_read(ioregs, 0, CV);
7140 -struct clocksource clocksource_avr32 = {
7143 - .read = read_cycle_count,
7144 - .mask = CLOCKSOURCE_MASK(16),
7146 - .flags = CLOCK_SOURCE_IS_CONTINUOUS,
7149 -static void avr32_timer_ack(void)
7151 - u16 count = expirelo;
7153 - /* Ack this timer interrupt and set the next one, use a u16
7154 - * variable so it will wrap around correctly */
7155 - count += cycles_per_jiffy;
7157 - timer_write(ioregs, 0, RC, expirelo);
7159 - /* Check to see if we have missed any timer interrupts */
7160 - count = timer_read(ioregs, 0, CV);
7161 - if ((count - expirelo) < 0x7fff) {
7162 - expirelo = count + cycles_per_jiffy;
7163 - timer_write(ioregs, 0, RC, expirelo);
7167 -u32 avr32_hpt_read(void)
7169 - return timer_read(ioregs, 0, CV);
7172 -static int avr32_timer_calc_div_and_set_jiffies(struct clk *pclk)
7174 - unsigned int cycles_max = (clocksource_avr32.mask + 1) / 2;
7175 - unsigned int divs[] = { 4, 8, 16, 32 };
7176 - int divs_size = ARRAY_SIZE(divs);
7178 - unsigned long count_hz;
7179 - unsigned long shift;
7180 - unsigned long mult;
7181 - int clock_div = -1;
7184 - shift = clocksource_avr32.shift;
7187 - count_hz = clk_get_rate(pclk) / divs[i];
7188 - mult = clocksource_hz2mult(count_hz, shift);
7189 - clocksource_avr32.mult = mult;
7194 - do_div(tmp, mult);
7196 - cycles_per_jiffy = tmp;
7197 - } while (cycles_per_jiffy > cycles_max && ++i < divs_size);
7199 - clock_div = i + 1;
7201 - if (clock_div > divs_size) {
7202 - pr_debug("timer: could not calculate clock divider\n");
7206 - /* Set the clock divider */
7207 - timer_write(ioregs, 0, CMR, TIMER_BF(CMR_TCCLKS, clock_div));
7212 -int avr32_hpt_init(unsigned int count)
7214 - struct resource *regs;
7221 - irq = platform_get_irq(&at32_systc0_device, 0);
7223 - pr_debug("timer: could not get irq\n");
7227 - pclk = clk_get(&at32_systc0_device.dev, "pclk");
7228 - if (IS_ERR(pclk)) {
7229 - pr_debug("timer: could not get clk: %ld\n", PTR_ERR(pclk));
7234 - regs = platform_get_resource(&at32_systc0_device, IORESOURCE_MEM, 0);
7236 - pr_debug("timer: could not get resource\n");
7237 - goto out_error_clk;
7240 - ioregs = ioremap(regs->start, regs->end - regs->start + 1);
7242 - pr_debug("timer: could not get ioregs\n");
7243 - goto out_error_clk;
7246 - ret = avr32_timer_calc_div_and_set_jiffies(pclk);
7248 - goto out_error_io;
7250 - ret = setup_irq(irq, &timer_irqaction);
7252 - pr_debug("timer: could not request irq %d: %d\n",
7254 - goto out_error_io;
7257 - expirelo = (timer_read(ioregs, 0, CV) / cycles_per_jiffy + 1)
7258 - * cycles_per_jiffy;
7260 - /* Enable clock and interrupts on RC compare */
7261 - timer_write(ioregs, 0, CCR, TIMER_BIT(CCR_CLKEN));
7262 - timer_write(ioregs, 0, IER, TIMER_BIT(IER_CPCS));
7263 - /* Set cycles to first interrupt */
7264 - timer_write(ioregs, 0, RC, expirelo);
7266 - printk(KERN_INFO "timer: AT32AP system timer/counter at 0x%p irq %d\n",
7279 -int avr32_hpt_start(void)
7281 - timer_write(ioregs, 0, CCR, TIMER_BIT(CCR_SWTRG));
7285 -irqreturn_t timer_interrupt(int irq, void *dev_id)
7287 - unsigned int sr = timer_read(ioregs, 0, SR);
7289 - if (sr & TIMER_BIT(SR_CPCS)) {
7290 - /* ack timer interrupt and try to set next interrupt */
7291 - avr32_timer_ack();
7294 - * Call the generic timer interrupt handler
7296 - write_seqlock(&xtime_lock);
7298 - write_sequnlock(&xtime_lock);
7301 - * In UP mode, we call local_timer_interrupt() to do profiling
7302 - * and process accounting.
7304 - * SMP is not supported yet.
7306 - local_timer_interrupt(irq, dev_id);
7308 - return IRQ_HANDLED;
7313 --- a/arch/avr32/Makefile
7314 +++ b/arch/avr32/Makefile
7316 core-y += arch/avr32/kernel/
7317 core-y += arch/avr32/mm/
7318 drivers-$(CONFIG_OPROFILE) += arch/avr32/oprofile/
7319 +drivers-y += arch/avr32/drivers/
7320 libs-y += arch/avr32/lib/
7322 archincdir-$(CONFIG_PLATFORM_AT32AP) := arch-at32ap
7323 --- a/arch/avr32/mm/init.c
7324 +++ b/arch/avr32/mm/init.c
7326 #include <linux/swap.h>
7327 #include <linux/init.h>
7328 #include <linux/mmzone.h>
7329 +#include <linux/module.h>
7330 #include <linux/bootmem.h>
7331 #include <linux/pagemap.h>
7332 #include <linux/nodemask.h>
7334 pgd_t swapper_pg_dir[PTRS_PER_PGD];
7336 struct page *empty_zero_page;
7337 +EXPORT_SYMBOL(empty_zero_page);
7340 * Cache of MMU context last used.
7342 unsigned long mmu_context_cache = NO_CONTEXT;
7344 -#define START_PFN (NODE_DATA(0)->bdata->node_boot_start >> PAGE_SHIFT)
7345 -#define MAX_LOW_PFN (NODE_DATA(0)->bdata->node_low_pfn)
7349 int total = 0, reserved = 0, cached = 0;
7350 --- a/arch/avr32/oprofile/op_model_avr32.c
7351 +++ b/arch/avr32/oprofile/op_model_avr32.c
7353 #include <linux/sched.h>
7354 #include <linux/types.h>
7356 -#include <asm/intc.h>
7357 #include <asm/sysreg.h>
7358 #include <asm/system.h>
7360 --- a/drivers/char/Kconfig
7361 +++ b/drivers/char/Kconfig
7365 tristate "Enhanced Real Time Clock Support"
7366 - depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390
7367 + depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 && !AVR32
7369 If you say Y here and create a character special file /dev/rtc with
7370 major number 10 and minor number 135 using mknod ("man mknod"), you
7374 tristate "Generic /dev/rtc emulation"
7375 - depends on RTC!=y && !IA64 && !ARM && !M32R && !MIPS && !SPARC && !FRV && !S390 && !SUPERH
7376 + depends on RTC!=y && !IA64 && !ARM && !M32R && !MIPS && !SPARC && !FRV && !S390 && !SUPERH && !AVR32
7378 If you say Y here and create a character special file /dev/rtc with
7379 major number 10 and minor number 135 using mknod ("man mknod"), you
7380 --- a/drivers/char/keyboard.c
7381 +++ b/drivers/char/keyboard.c
7382 @@ -1033,7 +1033,8 @@
7383 #if defined(CONFIG_X86) || defined(CONFIG_IA64) || defined(CONFIG_ALPHA) ||\
7384 defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) ||\
7385 defined(CONFIG_PARISC) || defined(CONFIG_SUPERH) ||\
7386 - (defined(CONFIG_ARM) && defined(CONFIG_KEYBOARD_ATKBD) && !defined(CONFIG_ARCH_RPC))
7387 + (defined(CONFIG_ARM) && defined(CONFIG_KEYBOARD_ATKBD) && !defined(CONFIG_ARCH_RPC)) ||\
7388 + defined(CONFIG_AVR32)
7390 #define HW_RAW(dev) (test_bit(EV_MSC, dev->evbit) && test_bit(MSC_RAW, dev->mscbit) &&\
7391 ((dev)->id.bustype == BUS_I8042) && ((dev)->id.vendor == 0x0001) && ((dev)->id.product == 0x0001))
7392 --- a/drivers/clocksource/Makefile
7393 +++ b/drivers/clocksource/Makefile
7395 +obj-$(CONFIG_ATMEL_TCB_CLKSRC) += tcb_clksrc.o
7396 obj-$(CONFIG_X86_CYCLONE_TIMER) += cyclone.o
7397 obj-$(CONFIG_X86_PM_TIMER) += acpi_pm.o
7398 obj-$(CONFIG_SCx200HR_TIMER) += scx200_hrt.o
7400 +++ b/drivers/clocksource/tcb_clksrc.c
7402 +#include <linux/init.h>
7403 +#include <linux/clocksource.h>
7404 +#include <linux/clockchips.h>
7405 +#include <linux/interrupt.h>
7406 +#include <linux/irq.h>
7408 +#include <linux/clk.h>
7409 +#include <linux/err.h>
7410 +#include <linux/ioport.h>
7411 +#include <linux/io.h>
7412 +#include <linux/platform_device.h>
7413 +#include <linux/atmel_tc.h>
7417 + * We're configured to use a specific TC block, one that's not hooked
7418 + * up to external hardware, to provide a time solution:
7420 + * - Two channels combine to create a free-running 32 bit counter
7421 + * with a base rate of 5+ MHz, packaged as a clocksource (with
7422 + * resolution better than 200 nsec).
7424 + * - The third channel may be used to provide a 16-bit clockevent
7425 + * source, used in either periodic or oneshot mode. This runs
7426 + * at 32 KiHZ, and can handle delays of up to two seconds.
7428 + * A boot clocksource and clockevent source are also currently needed,
7429 + * unless the relevant platforms (ARM/AT91, AVR32/AT32) are changed so
7430 + * this code can be used when init_timers() is called, well before most
7431 + * devices are set up. (Some low end AT91 parts, which can run uClinux,
7432 + * have only the timers in one TC block... they currently don't support
7433 + * the tclib code, because of that initialization issue.)
7435 + * REVISIT behavior during system suspend states... we should disable
7436 + * all clocks and save the power. Easily done for clockevent devices,
7437 + * but clocksources won't necessarily get the needed notifications.
7438 + * For deeper system sleep states, this will be mandatory...
7441 +static void __iomem *tcaddr;
7443 +static cycle_t tc_get_cycles(void)
7445 + unsigned long flags;
7448 + raw_local_irq_save(flags);
7450 + upper = __raw_readl(tcaddr + ATMEL_TC_REG(1, CV));
7451 + lower = __raw_readl(tcaddr + ATMEL_TC_REG(0, CV));
7452 + } while (upper != __raw_readl(tcaddr + ATMEL_TC_REG(1, CV)));
7454 + raw_local_irq_restore(flags);
7455 + return (upper << 16) | lower;
7458 +static struct clocksource clksrc = {
7459 + .name = "tcb_clksrc",
7461 + .read = tc_get_cycles,
7462 + .mask = CLOCKSOURCE_MASK(32),
7464 + .flags = CLOCK_SOURCE_IS_CONTINUOUS,
7467 +#ifdef CONFIG_GENERIC_CLOCKEVENTS
7469 +struct tc_clkevt_device {
7470 + struct clock_event_device clkevt;
7472 + void __iomem *regs;
7475 +static struct tc_clkevt_device *to_tc_clkevt(struct clock_event_device *clkevt)
7477 + return container_of(clkevt, struct tc_clkevt_device, clkevt);
7480 +/* For now, we always use the 32K clock ... this optimizes for NO_HZ,
7481 + * because using one of the divided clocks would usually mean the
7482 + * tick rate can never be less than several dozen Hz (vs 0.5 Hz).
7484 + * A divided clock could be good for high resolution timers, since
7485 + * 30.5 usec resolution can seem "low".
7487 +static u32 timer_clock;
7489 +static void tc_mode(enum clock_event_mode m, struct clock_event_device *d)
7491 + struct tc_clkevt_device *tcd = to_tc_clkevt(d);
7492 + void __iomem *regs = tcd->regs;
7494 + if (tcd->clkevt.mode == CLOCK_EVT_MODE_PERIODIC
7495 + || tcd->clkevt.mode == CLOCK_EVT_MODE_ONESHOT) {
7496 + __raw_writel(0xff, regs + ATMEL_TC_REG(2, IDR));
7497 + __raw_writel(ATMEL_TC_CLKDIS, regs + ATMEL_TC_REG(2, CCR));
7498 + clk_disable(tcd->clk);
7503 + /* By not making the gentime core emulate periodic mode on top
7504 + * of oneshot, we get lower overhead and improved accuracy.
7506 + case CLOCK_EVT_MODE_PERIODIC:
7507 + clk_enable(tcd->clk);
7509 + /* slow clock, count up to RC, then irq and restart */
7510 + __raw_writel(timer_clock
7511 + | ATMEL_TC_WAVE | ATMEL_TC_WAVESEL_UP_AUTO,
7512 + regs + ATMEL_TC_REG(2, CMR));
7513 + __raw_writel((32768 + HZ/2) / HZ, tcaddr + ATMEL_TC_REG(2, RC));
7515 + /* Enable clock and interrupts on RC compare */
7516 + __raw_writel(ATMEL_TC_CPCS, regs + ATMEL_TC_REG(2, IER));
7518 + /* go go gadget! */
7519 + __raw_writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG,
7520 + regs + ATMEL_TC_REG(2, CCR));
7523 + case CLOCK_EVT_MODE_ONESHOT:
7524 + clk_enable(tcd->clk);
7526 + /* slow clock, count up to RC, then irq and stop */
7527 + __raw_writel(timer_clock | ATMEL_TC_CPCSTOP
7528 + | ATMEL_TC_WAVE | ATMEL_TC_WAVESEL_UP_AUTO,
7529 + regs + ATMEL_TC_REG(2, CMR));
7530 + __raw_writel(ATMEL_TC_CPCS, regs + ATMEL_TC_REG(2, IER));
7532 + /* set_next_event() configures and starts the timer */
7540 +static int tc_next_event(unsigned long delta, struct clock_event_device *d)
7542 + __raw_writel(delta, tcaddr + ATMEL_TC_REG(2, RC));
7544 + /* go go gadget! */
7545 + __raw_writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG,
7546 + tcaddr + ATMEL_TC_REG(2, CCR));
7550 +static struct tc_clkevt_device clkevt = {
7552 + .name = "tc_clkevt",
7553 + .features = CLOCK_EVT_FEAT_PERIODIC
7554 + | CLOCK_EVT_FEAT_ONESHOT,
7556 + /* Should be lower than at91rm9200's system timer */
7558 + .cpumask = CPU_MASK_CPU0,
7559 + .set_next_event = tc_next_event,
7560 + .set_mode = tc_mode,
7564 +static irqreturn_t ch2_irq(int irq, void *handle)
7566 + struct tc_clkevt_device *dev = handle;
7569 + sr = __raw_readl(dev->regs + ATMEL_TC_REG(2, SR));
7570 + if (sr & ATMEL_TC_CPCS) {
7571 + dev->clkevt.event_handler(&dev->clkevt);
7572 + return IRQ_HANDLED;
7578 +static struct irqaction tc_irqaction = {
7579 + .name = "tc_clkevt",
7580 + .flags = IRQF_TIMER | IRQF_DISABLED,
7581 + .handler = ch2_irq,
7584 +static void __init setup_clkevents(struct atmel_tc *tc, int clk32k_divisor_idx)
7586 + struct clk *t2_clk = tc->clk[2];
7587 + int irq = tc->irq[2];
7589 + clkevt.regs = tc->regs;
7590 + clkevt.clk = t2_clk;
7591 + tc_irqaction.dev_id = &clkevt;
7593 + timer_clock = clk32k_divisor_idx;
7595 + clkevt.clkevt.mult = div_sc(32768, NSEC_PER_SEC, clkevt.clkevt.shift);
7596 + clkevt.clkevt.max_delta_ns
7597 + = clockevent_delta2ns(0xffff, &clkevt.clkevt);
7598 + clkevt.clkevt.min_delta_ns = clockevent_delta2ns(1, &clkevt.clkevt) + 1;
7600 + setup_irq(irq, &tc_irqaction);
7602 + clockevents_register_device(&clkevt.clkevt);
7605 +#else /* !CONFIG_GENERIC_CLOCKEVENTS */
7607 +static void __init setup_clkevents(struct atmel_tc *tc, int clk32k_divisor_idx)
7614 +static int __init tcb_clksrc_init(void)
7616 + static char bootinfo[] __initdata
7617 + = KERN_DEBUG "%s: tc%d at %d.%03d MHz\n";
7619 + struct platform_device *pdev;
7620 + struct atmel_tc *tc;
7621 + struct clk *t0_clk;
7622 + u32 rate, divided_rate = 0;
7623 + int best_divisor_idx = -1;
7624 + int clk32k_divisor_idx = -1;
7627 + tc = atmel_tc_alloc(CONFIG_ATMEL_TCB_CLKSRC_BLOCK, clksrc.name);
7629 + pr_debug("can't alloc TC for clocksource\n");
7632 + tcaddr = tc->regs;
7635 + t0_clk = tc->clk[0];
7636 + clk_enable(t0_clk);
7638 + /* How fast will we be counting? Pick something over 5 MHz. */
7639 + rate = (u32) clk_get_rate(t0_clk);
7640 + for (i = 0; i < 5; i++) {
7641 + unsigned divisor = atmel_tc_divisors[i];
7644 + /* remember 32 KiHz clock for later */
7646 + clk32k_divisor_idx = i;
7650 + tmp = rate / divisor;
7651 + pr_debug("TC: %u / %-3u [%d] --> %u\n", rate, divisor, i, tmp);
7652 + if (best_divisor_idx > 0) {
7653 + if (tmp < 5 * 1000 * 1000)
7656 + divided_rate = tmp;
7657 + best_divisor_idx = i;
7660 + clksrc.mult = clocksource_hz2mult(divided_rate, clksrc.shift);
7662 + printk(bootinfo, clksrc.name, CONFIG_ATMEL_TCB_CLKSRC_BLOCK,
7663 + divided_rate / 1000000,
7664 + ((divided_rate + 500000) % 1000000) / 1000);
7666 + /* tclib will give us three clocks no matter what the
7667 + * underlying platform supports.
7669 + clk_enable(tc->clk[1]);
7671 + /* channel 0: waveform mode, input mclk/8, clock TIOA0 on overflow */
7672 + __raw_writel(best_divisor_idx /* likely divide-by-8 */
7674 + | ATMEL_TC_WAVESEL_UP /* free-run */
7675 + | ATMEL_TC_ACPA_SET /* TIOA0 rises at 0 */
7676 + | ATMEL_TC_ACPC_CLEAR, /* (duty cycle 50%) */
7677 + tcaddr + ATMEL_TC_REG(0, CMR));
7678 + __raw_writel(0x0000, tcaddr + ATMEL_TC_REG(0, RA));
7679 + __raw_writel(0x8000, tcaddr + ATMEL_TC_REG(0, RC));
7680 + __raw_writel(0xff, tcaddr + ATMEL_TC_REG(0, IDR)); /* no irqs */
7681 + __raw_writel(ATMEL_TC_CLKEN, tcaddr + ATMEL_TC_REG(0, CCR));
7683 + /* channel 1: waveform mode, input TIOA0 */
7684 + __raw_writel(ATMEL_TC_XC1 /* input: TIOA0 */
7686 + | ATMEL_TC_WAVESEL_UP, /* free-run */
7687 + tcaddr + ATMEL_TC_REG(1, CMR));
7688 + __raw_writel(0xff, tcaddr + ATMEL_TC_REG(1, IDR)); /* no irqs */
7689 + __raw_writel(ATMEL_TC_CLKEN, tcaddr + ATMEL_TC_REG(1, CCR));
7691 + /* chain channel 0 to channel 1, then reset all the timers */
7692 + __raw_writel(ATMEL_TC_TC1XC1S_TIOA0, tcaddr + ATMEL_TC_BMR);
7693 + __raw_writel(ATMEL_TC_SYNC, tcaddr + ATMEL_TC_BCR);
7695 + /* and away we go! */
7696 + clocksource_register(&clksrc);
7698 + /* channel 2: periodic and oneshot timer support */
7699 + setup_clkevents(tc, clk32k_divisor_idx);
7703 +arch_initcall(tcb_clksrc_init);
7705 +++ b/drivers/i2c/busses/i2c-atmeltwi.c
7708 + * i2c Support for Atmel's Two-Wire Interface (TWI)
7710 + * Based on the work of Copyright (C) 2004 Rick Bronson
7711 + * Converted to 2.6 by Andrew Victor <andrew at sanpeople.com>
7712 + * Ported to AVR32 and heavily modified by Espen Krangnes
7713 + * <ekrangnes at atmel.com>
7715 + * Copyright (C) 2006 Atmel Corporation
7717 + * Borrowed heavily from the original work by:
7718 + * Copyright (C) 2000 Philip Edelbrock <phil at stimpy.netroedge.com>
7720 + * Partialy rewriten by Karel Hojdar <cmkaho at seznam.cz>
7721 + * bugs removed, interrupt routine markedly rewritten
7723 + * This program is free software; you can redistribute it and/or modify
7724 + * it under the terms of the GNU General Public License as published by
7725 + * the Free Software Foundation; either version 2 of the License, or
7726 + * (at your option) any later version.
7728 +#undef VERBOSE_DEBUG
7730 +#include <linux/module.h>
7731 +#include <linux/slab.h>
7732 +#include <linux/i2c.h>
7733 +#include <linux/init.h>
7734 +#include <linux/clk.h>
7735 +#include <linux/err.h>
7736 +#include <linux/interrupt.h>
7737 +#include <linux/platform_device.h>
7738 +#include <linux/completion.h>
7739 +#include <linux/io.h>
7741 +#include "i2c-atmeltwi.h"
7743 +static unsigned int baudrate = 100 * 1000;
7744 +module_param(baudrate, uint, S_IRUGO);
7745 +MODULE_PARM_DESC(baudrate, "The TWI baudrate");
7749 + void __iomem *regs;
7750 + struct i2c_adapter adapter;
7752 + struct completion comp;
7761 +#define to_atmel_twi(adap) container_of(adap, struct atmel_twi, adapter)
7764 + * (Re)Initialize the TWI hardware registers.
7766 +static int twi_hwinit(struct atmel_twi *twi)
7768 + unsigned long cdiv, ckdiv = 0;
7770 + /* REVISIT: wait till SCL is high before resetting; otherwise,
7771 + * some versions will wedge forever.
7774 + twi_writel(twi, IDR, ~0UL);
7775 + twi_writel(twi, CR, TWI_BIT(SWRST)); /*Reset peripheral*/
7776 + twi_readl(twi, SR);
7778 + cdiv = (clk_get_rate(twi->pclk) / (2 * baudrate)) - 4;
7780 + while (cdiv > 255) {
7785 + /* REVISIT: there are various errata to consider re CDIV and CHDIV
7786 + * here, at least on at91 parts.
7792 + twi_writel(twi, CWGR, TWI_BF(CKDIV, ckdiv)
7793 + | TWI_BF(CHDIV, cdiv)
7794 + | TWI_BF(CLDIV, cdiv));
7799 + * Waits for the i2c status register to set the specified bitmask
7800 + * Returns 0 if timed out ... ~100ms is much longer than the SMBus
7801 + * limit, but I2C has no limit at all.
7803 +static int twi_complete(struct atmel_twi *twi, u32 mask)
7805 + int timeout = msecs_to_jiffies(100);
7807 + mask |= TWI_BIT(TXCOMP);
7808 + twi->mask = mask | TWI_BIT(NACK) | TWI_BIT(OVRE);
7809 + init_completion(&twi->comp);
7811 + twi_writel(twi, IER, mask);
7813 + if (!wait_for_completion_timeout(&twi->comp, timeout)) {
7814 + /* RESET TWI interface */
7815 + twi_writel(twi, CR, TWI_BIT(SWRST));
7817 + /* Reinitialize TWI */
7820 + return -ETIMEDOUT;
7826 + * Generic i2c master transfer entrypoint.
7828 +static int twi_xfer(struct i2c_adapter *adap, struct i2c_msg *pmsg, int num)
7830 + struct atmel_twi *twi = to_atmel_twi(adap);
7833 + dev_dbg(&adap->dev, "twi_xfer: processing %d messages:\n", num);
7836 + for (i = 0; i < num; i++, pmsg++) {
7837 + twi->len = pmsg->len;
7838 + twi->buf = pmsg->buf;
7839 + twi->acks_left = pmsg->len;
7840 + twi_writel(twi, MMR, TWI_BF(DADR, pmsg->addr) |
7841 + (pmsg->flags & I2C_M_RD ? TWI_BIT(MREAD) : 0));
7842 + twi_writel(twi, IADR, TWI_BF(IADR, pmsg->addr));
7844 + dev_dbg(&adap->dev,
7845 + "#%d: %s %d byte%s %s dev 0x%02x\n",
7847 + pmsg->flags & I2C_M_RD ? "reading" : "writing",
7849 + pmsg->len > 1 ? "s" : "",
7850 + pmsg->flags & I2C_M_RD ? "from" : "to", pmsg->addr);
7853 + twi_writel(twi, CR, TWI_BIT(MSEN));
7855 + if (pmsg->flags & I2C_M_RD) {
7856 + /* cleanup after previous RX overruns */
7857 + while (twi_readl(twi, SR) & TWI_BIT(RXRDY))
7858 + twi_readl(twi, RHR);
7860 + if (twi->len == 1)
7861 + twi_writel(twi, CR,
7862 + TWI_BIT(START) | TWI_BIT(STOP));
7864 + twi_writel(twi, CR, TWI_BIT(START));
7866 + if (twi_complete(twi, TWI_BIT(RXRDY)) == -ETIMEDOUT) {
7867 + dev_dbg(&adap->dev, "RX[%d] timeout. "
7868 + "Stopped with %d bytes left\n",
7869 + i, twi->acks_left);
7870 + return -ETIMEDOUT;
7873 + twi_writel(twi, THR, twi->buf[0]);
7875 + /* REVISIT: some chips don't start automagically:
7876 + * twi_writel(twi, CR, TWI_BIT(START));
7878 + if (twi_complete(twi, TWI_BIT(TXRDY)) == -ETIMEDOUT) {
7879 + dev_dbg(&adap->dev, "TX[%d] timeout. "
7880 + "Stopped with %d bytes left\n",
7881 + i, twi->acks_left);
7882 + return -ETIMEDOUT;
7884 + /* REVISIT: an erratum workaround may be needed here;
7885 + * see sam9261 "STOP not generated" (START either).
7889 + /* Disable TWI interface */
7890 + twi_writel(twi, CR, TWI_BIT(MSDIS));
7893 + return twi->status;
7895 + /* WARNING: This driver lies about properly supporting
7896 + * repeated start, or it would *ALWAYS* return here. It
7897 + * has issued a STOP. Continuing is a false claim -- that
7898 + * a second (or third, etc.) message is part of the same
7899 + * "combined" (no STOPs between parts) message.
7902 + } /* end cur msg */
7908 +static irqreturn_t twi_interrupt(int irq, void *dev_id)
7910 + struct atmel_twi *twi = dev_id;
7911 + int status = twi_readl(twi, SR);
7913 + /* Save state for later debug prints */
7914 + int old_status = status;
7916 + if (twi->mask & status) {
7918 + status &= twi->mask;
7920 + if (status & TWI_BIT(RXRDY)) {
7921 + if ((status & TWI_BIT(OVRE)) && twi->acks_left) {
7922 + /* Note weakness in fault reporting model:
7923 + * we can't say "the first N of these data
7924 + * bytes are valid".
7926 + dev_err(&twi->adapter.dev,
7927 + "OVERRUN RX! %04x, lost %d\n",
7928 + old_status, twi->acks_left);
7929 + twi->acks_left = 0;
7930 + twi_writel(twi, CR, TWI_BIT(STOP));
7931 + twi->status = -EOVERFLOW;
7932 + } else if (twi->acks_left > 0) {
7933 + twi->buf[twi->len - twi->acks_left] =
7934 + twi_readl(twi, RHR);
7937 + if (status & TWI_BIT(TXCOMP))
7939 + if (twi->acks_left == 1)
7940 + twi_writel(twi, CR, TWI_BIT(STOP));
7942 + } else if (status & (TWI_BIT(NACK) | TWI_BIT(TXCOMP))) {
7945 + } else if (status & TWI_BIT(TXRDY)) {
7946 + if (twi->acks_left > 0) {
7947 + twi_writel(twi, THR,
7948 + twi->buf[twi->len - twi->acks_left]);
7951 + twi_writel(twi, CR, TWI_BIT(STOP));
7954 + if (twi->acks_left == 0)
7955 + twi_writel(twi, IDR, ~TWI_BIT(TXCOMP));
7958 + /* enabling this message helps trigger overruns/underruns ... */
7959 + dev_vdbg(&twi->adapter.dev,
7960 + "ISR: SR 0x%04X, mask 0x%04X, acks %i\n",
7962 + twi->acks_left ? twi->mask : TWI_BIT(TXCOMP),
7965 + return IRQ_HANDLED;
7968 + /* Note weak fault reporting model: we can't report how many
7969 + * bytes we sent before the NAK, or let upper layers choose
7970 + * whether to continue. The I2C stack doesn't allow that...
7972 + if (status & TWI_BIT(NACK)) {
7973 + dev_dbg(&twi->adapter.dev, "NACK received! %d to go\n",
7975 + twi->status = -EPIPE;
7977 + /* TX underrun morphs automagically into a premature STOP;
7978 + * we'll probably observe UVRE even when it's not documented.
7980 + } else if (twi->acks_left && (twi->mask & TWI_BIT(TXRDY))) {
7981 + dev_err(&twi->adapter.dev, "UNDERRUN TX! %04x, %d to go\n",
7982 + old_status, twi->acks_left);
7983 + twi->status = -ENOSR;
7986 + twi_writel(twi, IDR, ~0UL);
7987 + complete(&twi->comp);
7989 + dev_dbg(&twi->adapter.dev, "ISR: SR 0x%04X, acks %i --> %d\n",
7990 + old_status, twi->acks_left, twi->status);
7992 + return IRQ_HANDLED;
7997 + * Return list of supported functionality.
7999 + * NOTE: see warning above about repeated starts; this driver is falsely
8000 + * claiming to support "combined" transfers. The mid-message STOPs mean
8001 + * some slaves will never work with this driver. (Use i2c-gpio...)
8003 +static u32 twi_func(struct i2c_adapter *adapter)
8005 + return (I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL)
8006 + & ~I2C_FUNC_SMBUS_QUICK;
8009 +static struct i2c_algorithm twi_algorithm = {
8010 + .master_xfer = twi_xfer,
8011 + .functionality = twi_func,
8015 + * Main initialization routine.
8017 +static int __init twi_probe(struct platform_device *pdev)
8019 + struct atmel_twi *twi;
8020 + struct resource *regs;
8022 + struct i2c_adapter *adapter;
8025 + regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
8029 + pclk = clk_get(&pdev->dev, "twi_pclk");
8031 + return PTR_ERR(pclk);
8035 + twi = kzalloc(sizeof(struct atmel_twi), GFP_KERNEL);
8037 + dev_dbg(&pdev->dev, "can't allocate interface!\n");
8038 + goto err_alloc_twi;
8042 + twi->regs = ioremap(regs->start, regs->end - regs->start + 1);
8046 + irq = platform_get_irq(pdev, 0);
8047 + rc = request_irq(irq, twi_interrupt, 0, "twi", twi);
8049 + dev_dbg(&pdev->dev, "can't bind irq!\n");
8054 + rc = twi_hwinit(twi);
8056 + dev_err(&pdev->dev, "Unable to set baudrate\n");
8060 + adapter = &twi->adapter;
8061 + sprintf(adapter->name, "TWI");
8062 + adapter->algo = &twi_algorithm;
8063 + adapter->class = I2C_CLASS_ALL;
8064 + adapter->nr = pdev->id;
8065 + adapter->dev.parent = &pdev->dev;
8067 + platform_set_drvdata(pdev, twi);
8069 + rc = i2c_add_numbered_adapter(adapter);
8071 + dev_dbg(&pdev->dev, "Adapter %s registration failed\n",
8073 + goto err_register;
8076 + dev_info(&pdev->dev,
8077 + "Atmel TWI/I2C adapter (baudrate %dk) at 0x%08lx.\n",
8078 + baudrate/1000, (unsigned long)regs->start);
8084 + platform_set_drvdata(pdev, NULL);
8087 + free_irq(irq, twi);
8090 + iounmap(twi->regs);
8096 + clk_disable(pclk);
8102 +static int __exit twi_remove(struct platform_device *pdev)
8104 + struct atmel_twi *twi = platform_get_drvdata(pdev);
8107 + platform_set_drvdata(pdev, NULL);
8108 + res = i2c_del_adapter(&twi->adapter);
8109 + twi_writel(twi, CR, TWI_BIT(MSDIS));
8110 + iounmap(twi->regs);
8111 + clk_disable(twi->pclk);
8112 + clk_put(twi->pclk);
8113 + free_irq(twi->irq, twi);
8119 +static struct platform_driver twi_driver = {
8120 + .remove = __exit_p(twi_remove),
8122 + .name = "atmel_twi",
8123 + .owner = THIS_MODULE,
8127 +static int __init atmel_twi_init(void)
8129 + return platform_driver_probe(&twi_driver, twi_probe);
8132 +static void __exit atmel_twi_exit(void)
8134 + platform_driver_unregister(&twi_driver);
8137 +module_init(atmel_twi_init);
8138 +module_exit(atmel_twi_exit);
8140 +MODULE_AUTHOR("Espen Krangnes");
8141 +MODULE_DESCRIPTION("I2C driver for Atmel TWI");
8142 +MODULE_LICENSE("GPL");
8144 +++ b/drivers/i2c/busses/i2c-atmeltwi.h
8147 + * Register definitions for the Atmel Two-Wire Interface
8150 +#ifndef __ATMELTWI_H__
8151 +#define __ATMELTWI_H__
8153 +/* TWI register offsets */
8154 +#define TWI_CR 0x0000
8155 +#define TWI_MMR 0x0004
8156 +#define TWI_SMR 0x0008
8157 +#define TWI_IADR 0x000c
8158 +#define TWI_CWGR 0x0010
8159 +#define TWI_SR 0x0020
8160 +#define TWI_IER 0x0024
8161 +#define TWI_IDR 0x0028
8162 +#define TWI_IMR 0x002c
8163 +#define TWI_RHR 0x0030
8164 +#define TWI_THR 0x0034
8166 +/* Bitfields in CR */
8167 +#define TWI_START_OFFSET 0
8168 +#define TWI_START_SIZE 1
8169 +#define TWI_STOP_OFFSET 1
8170 +#define TWI_STOP_SIZE 1
8171 +#define TWI_MSEN_OFFSET 2
8172 +#define TWI_MSEN_SIZE 1
8173 +#define TWI_MSDIS_OFFSET 3
8174 +#define TWI_MSDIS_SIZE 1
8175 +#define TWI_SVEN_OFFSET 4
8176 +#define TWI_SVEN_SIZE 1
8177 +#define TWI_SVDIS_OFFSET 5
8178 +#define TWI_SVDIS_SIZE 1
8179 +#define TWI_SWRST_OFFSET 7
8180 +#define TWI_SWRST_SIZE 1
8182 +/* Bitfields in MMR */
8183 +#define TWI_IADRSZ_OFFSET 8
8184 +#define TWI_IADRSZ_SIZE 2
8185 +#define TWI_MREAD_OFFSET 12
8186 +#define TWI_MREAD_SIZE 1
8187 +#define TWI_DADR_OFFSET 16
8188 +#define TWI_DADR_SIZE 7
8190 +/* Bitfields in SMR */
8191 +#define TWI_SADR_OFFSET 16
8192 +#define TWI_SADR_SIZE 7
8194 +/* Bitfields in IADR */
8195 +#define TWI_IADR_OFFSET 0
8196 +#define TWI_IADR_SIZE 24
8198 +/* Bitfields in CWGR */
8199 +#define TWI_CLDIV_OFFSET 0
8200 +#define TWI_CLDIV_SIZE 8
8201 +#define TWI_CHDIV_OFFSET 8
8202 +#define TWI_CHDIV_SIZE 8
8203 +#define TWI_CKDIV_OFFSET 16
8204 +#define TWI_CKDIV_SIZE 3
8206 +/* Bitfields in SR */
8207 +#define TWI_TXCOMP_OFFSET 0
8208 +#define TWI_TXCOMP_SIZE 1
8209 +#define TWI_RXRDY_OFFSET 1
8210 +#define TWI_RXRDY_SIZE 1
8211 +#define TWI_TXRDY_OFFSET 2
8212 +#define TWI_TXRDY_SIZE 1
8213 +#define TWI_SVDIR_OFFSET 3
8214 +#define TWI_SVDIR_SIZE 1
8215 +#define TWI_SVACC_OFFSET 4
8216 +#define TWI_SVACC_SIZE 1
8217 +#define TWI_GCACC_OFFSET 5
8218 +#define TWI_GCACC_SIZE 1
8219 +#define TWI_OVRE_OFFSET 6
8220 +#define TWI_OVRE_SIZE 1
8221 +#define TWI_UNRE_OFFSET 7
8222 +#define TWI_UNRE_SIZE 1
8223 +#define TWI_NACK_OFFSET 8
8224 +#define TWI_NACK_SIZE 1
8225 +#define TWI_ARBLST_OFFSET 9
8226 +#define TWI_ARBLST_SIZE 1
8228 +/* Bitfields in RHR */
8229 +#define TWI_RXDATA_OFFSET 0
8230 +#define TWI_RXDATA_SIZE 8
8232 +/* Bitfields in THR */
8233 +#define TWI_TXDATA_OFFSET 0
8234 +#define TWI_TXDATA_SIZE 8
8236 +/* Constants for IADRSZ */
8237 +#define TWI_IADRSZ_NO_ADDR 0
8238 +#define TWI_IADRSZ_ONE_BYTE 1
8239 +#define TWI_IADRSZ_TWO_BYTES 2
8240 +#define TWI_IADRSZ_THREE_BYTES 3
8242 +/* Bit manipulation macros */
8243 +#define TWI_BIT(name) \
8244 + (1 << TWI_##name##_OFFSET)
8245 +#define TWI_BF(name, value) \
8246 + (((value) & ((1 << TWI_##name##_SIZE) - 1)) \
8247 + << TWI_##name##_OFFSET)
8248 +#define TWI_BFEXT(name, value) \
8249 + (((value) >> TWI_##name##_OFFSET) \
8250 + & ((1 << TWI_##name##_SIZE) - 1))
8251 +#define TWI_BFINS(name, value, old) \
8252 + (((old) & ~(((1 << TWI_##name##_SIZE) - 1) \
8253 + << TWI_##name##_OFFSET)) \
8254 + | TWI_BF(name, (value)))
8256 +/* Register access macros */
8257 +#define twi_readl(port, reg) \
8258 + __raw_readl((port)->regs + TWI_##reg)
8259 +#define twi_writel(port, reg, value) \
8260 + __raw_writel((value), (port)->regs + TWI_##reg)
8262 +#endif /* __ATMELTWI_H__ */
8263 --- a/drivers/i2c/busses/Kconfig
8264 +++ b/drivers/i2c/busses/Kconfig
8266 to support combined I2C messages. Use the i2c-gpio driver
8267 unless your system can cope with those limitations.
8269 +config I2C_ATMELTWI
8270 + tristate "Atmel Two-Wire Interface (TWI)"
8271 + depends on I2C && (ARCH_AT91 || PLATFORM_AT32AP)
8273 + Atmel on-chip TWI controller. Say Y if you have an AT32 or
8274 + AT91-based device and want to use its built-in TWI
8278 tristate "Au1550/Au1200 SMBus interface"
8279 depends on SOC_AU1550 || SOC_AU1200
8280 --- a/drivers/i2c/busses/Makefile
8281 +++ b/drivers/i2c/busses/Makefile
8283 obj-$(CONFIG_I2C_VOODOO3) += i2c-voodoo3.o
8284 obj-$(CONFIG_SCx200_ACB) += scx200_acb.o
8285 obj-$(CONFIG_SCx200_I2C) += scx200_i2c.o
8286 +obj-$(CONFIG_I2C_ATMELTWI) += i2c-atmeltwi.o
8288 ifeq ($(CONFIG_I2C_DEBUG_BUS),y)
8289 EXTRA_CFLAGS += -DDEBUG
8291 +++ b/drivers/input/serio/at32psif.c
8294 + * Copyright (C) 2007 Atmel Corporation
8296 + * Driver for the AT32AP700X PS/2 controller (PSIF).
8298 + * This program is free software; you can redistribute it and/or modify it
8299 + * under the terms of the GNU General Public License version 2 as published
8300 + * by the Free Software Foundation.
8302 +#include <linux/kernel.h>
8303 +#include <linux/module.h>
8304 +#include <linux/device.h>
8305 +#include <linux/init.h>
8306 +#include <linux/serio.h>
8307 +#include <linux/timer.h>
8308 +#include <linux/interrupt.h>
8309 +#include <linux/err.h>
8310 +#include <linux/io.h>
8311 +#include <linux/clk.h>
8312 +#include <linux/platform_device.h>
8314 +#include "at32psif.h"
8316 +#define PSIF_BUF_SIZE 16
8318 +#define ring_is_empty(_psif) (_psif->head == _psif->tail)
8319 +#define ring_next_head(_psif) ((_psif->head + 1) & (PSIF_BUF_SIZE - 1))
8320 +#define ring_next_tail(_psif) ((_psif->tail + 1) & (PSIF_BUF_SIZE - 1))
8323 + struct platform_device *pdev;
8326 + struct timer_list tx_timer;
8327 + void __iomem *regs;
8329 + unsigned int open;
8330 + /* Prevent concurrent writes to circular buffer. */
8332 + unsigned int head;
8333 + unsigned int tail;
8334 + unsigned char buffer[PSIF_BUF_SIZE];
8337 +static irqreturn_t psif_interrupt(int irq, void *_ptr)
8339 + struct psif *psif = _ptr;
8340 + int retval = IRQ_NONE;
8341 + unsigned int io_flags = 0;
8342 + unsigned long status;
8344 + status = psif_readl(psif, SR);
8346 + if (status & PSIF_BIT(RXRDY)) {
8347 + unsigned char val = (unsigned char) psif_readl(psif, RHR);
8349 + if (status & PSIF_BIT(PARITY))
8350 + io_flags |= SERIO_PARITY;
8351 + if (status & PSIF_BIT(OVRUN))
8352 + dev_err(&psif->pdev->dev, "overrun read error\n");
8354 + serio_interrupt(psif->io, val, io_flags);
8356 + retval = IRQ_HANDLED;
8359 + spin_lock(&psif->lock);
8361 + if (status & PSIF_BIT(TXEMPTY)) {
8362 + if (status & PSIF_BIT(NACK))
8363 + dev_err(&psif->pdev->dev, "NACK error\n");
8365 + psif_writel(psif, IDR, PSIF_BIT(TXEMPTY));
8367 + if (!ring_is_empty(psif))
8368 + mod_timer(&psif->tx_timer,
8369 + jiffies + msecs_to_jiffies(1));
8371 + retval = IRQ_HANDLED;
8374 + spin_unlock(&psif->lock);
8379 +static void psif_transmit_data(unsigned long data)
8381 + struct psif *psif = (struct psif *)data;
8382 + unsigned long flags;
8384 + spin_lock_irqsave(&psif->lock, flags);
8386 + psif_writel(psif, THR, psif->buffer[psif->tail]);
8387 + psif->tail = ring_next_tail(psif);
8389 + if (!ring_is_empty(psif))
8390 + psif_writel(psif, IER, PSIF_BIT(TXEMPTY));
8392 + spin_unlock_irqrestore(&psif->lock, flags);
8395 +static int psif_write(struct serio *io, unsigned char val)
8397 + struct psif *psif = io->port_data;
8398 + unsigned long flags;
8399 + unsigned int head;
8401 + spin_lock_irqsave(&psif->lock, flags);
8403 + head = ring_next_head(psif);
8405 + if (head != psif->tail) {
8406 + psif->buffer[psif->head] = val;
8407 + psif->head = head;
8409 + dev_err(&psif->pdev->dev, "underrun write error\n");
8412 + spin_unlock_irqrestore(&psif->lock, flags);
8414 + /* Make sure TXEMPTY interrupt is enabled. */
8415 + psif_writel(psif, IER, PSIF_BIT(TXEMPTY));
8420 +static int psif_open(struct serio *io)
8422 + struct psif *psif = io->port_data;
8425 + retval = clk_enable(psif->pclk);
8429 + psif_writel(psif, CR, PSIF_BIT(CR_TXEN) | PSIF_BIT(CR_RXEN));
8430 + psif_writel(psif, IER, PSIF_BIT(RXRDY));
8437 +static void psif_close(struct serio *io)
8439 + struct psif *psif = io->port_data;
8443 + psif_writel(psif, IDR, ~0UL);
8444 + psif_writel(psif, CR, PSIF_BIT(CR_TXDIS) | PSIF_BIT(CR_RXDIS));
8446 + clk_disable(psif->pclk);
8449 +static void psif_set_prescaler(struct psif *psif)
8451 + unsigned long prscv;
8452 + unsigned long rate = clk_get_rate(psif->pclk);
8454 + /* PRSCV = Pulse length (100 us) * PSIF module frequency. */
8455 + prscv = 100 * (rate / 1000000UL);
8457 + if (prscv > ((1<<PSIF_PSR_PRSCV_SIZE) - 1)) {
8458 + prscv = (1<<PSIF_PSR_PRSCV_SIZE) - 1;
8459 + dev_dbg(&psif->pdev->dev, "pclk too fast, "
8460 + "prescaler set to max\n");
8463 + clk_enable(psif->pclk);
8464 + psif_writel(psif, PSR, prscv);
8465 + clk_disable(psif->pclk);
8468 +static int __init psif_probe(struct platform_device *pdev)
8470 + struct resource *regs;
8471 + struct psif *psif;
8477 + psif = kzalloc(sizeof(struct psif), GFP_KERNEL);
8479 + dev_dbg(&pdev->dev, "out of memory\n");
8483 + psif->pdev = pdev;
8485 + io = kzalloc(sizeof(struct serio), GFP_KERNEL);
8487 + dev_dbg(&pdev->dev, "out of memory\n");
8489 + goto out_free_psif;
8493 + regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
8495 + dev_dbg(&pdev->dev, "no mmio resources defined\n");
8500 + psif->regs = ioremap(regs->start, regs->end - regs->start + 1);
8501 + if (!psif->regs) {
8503 + dev_dbg(&pdev->dev, "could not map I/O memory\n");
8507 + pclk = clk_get(&pdev->dev, "pclk");
8508 + if (IS_ERR(pclk)) {
8509 + dev_dbg(&pdev->dev, "could not get peripheral clock\n");
8510 + ret = PTR_ERR(pclk);
8513 + psif->pclk = pclk;
8515 + /* Reset the PSIF to enter at a known state. */
8516 + ret = clk_enable(pclk);
8518 + dev_dbg(&pdev->dev, "could not enable pclk\n");
8521 + psif_writel(psif, CR, PSIF_BIT(CR_SWRST));
8522 + clk_disable(pclk);
8524 + setup_timer(&psif->tx_timer, psif_transmit_data, (unsigned long)psif);
8526 + irq = platform_get_irq(pdev, 0);
8528 + dev_dbg(&pdev->dev, "could not get irq\n");
8532 + ret = request_irq(irq, psif_interrupt, IRQF_SHARED, "at32psif", psif);
8534 + dev_dbg(&pdev->dev, "could not request irq %d\n", irq);
8539 + io->id.type = SERIO_8042;
8540 + io->write = psif_write;
8541 + io->open = psif_open;
8542 + io->close = psif_close;
8543 + strlcpy(io->name, pdev->dev.bus_id, sizeof(io->name));
8544 + strlcpy(io->phys, pdev->dev.bus_id, sizeof(io->phys));
8545 + io->port_data = psif;
8546 + io->dev.parent = &pdev->dev;
8548 + psif_set_prescaler(psif);
8550 + spin_lock_init(&psif->lock);
8551 + serio_register_port(psif->io);
8552 + platform_set_drvdata(pdev, psif);
8554 + dev_info(&pdev->dev, "Atmel AVR32 PSIF PS/2 driver on 0x%08x irq %d\n",
8555 + (int)psif->regs, psif->irq);
8560 + clk_put(psif->pclk);
8562 + iounmap(psif->regs);
8571 +static int __exit psif_remove(struct platform_device *pdev)
8573 + struct psif *psif = platform_get_drvdata(pdev);
8575 + psif_writel(psif, IDR, ~0UL);
8576 + psif_writel(psif, CR, PSIF_BIT(CR_TXDIS) | PSIF_BIT(CR_RXDIS));
8578 + serio_unregister_port(psif->io);
8579 + iounmap(psif->regs);
8580 + free_irq(psif->irq, psif);
8581 + clk_put(psif->pclk);
8584 + platform_set_drvdata(pdev, NULL);
8590 +static int psif_suspend(struct platform_device *pdev, pm_message_t state)
8592 + struct psif *psif = platform_get_drvdata(pdev);
8595 + psif_writel(psif, CR, PSIF_BIT(CR_RXDIS) | PSIF_BIT(CR_TXDIS));
8596 + clk_disable(psif->pclk);
8602 +static int psif_resume(struct platform_device *pdev)
8604 + struct psif *psif = platform_get_drvdata(pdev);
8607 + clk_enable(psif->pclk);
8608 + psif_set_prescaler(psif);
8609 + psif_writel(psif, CR, PSIF_BIT(CR_RXEN) | PSIF_BIT(CR_TXEN));
8615 +#define psif_suspend NULL
8616 +#define psif_resume NULL
8619 +static struct platform_driver psif_driver = {
8620 + .remove = __exit_p(psif_remove),
8622 + .name = "atmel_psif",
8624 + .suspend = psif_suspend,
8625 + .resume = psif_resume,
8628 +static int __init psif_init(void)
8630 + return platform_driver_probe(&psif_driver, psif_probe);
8633 +static void __exit psif_exit(void)
8635 + platform_driver_unregister(&psif_driver);
8638 +module_init(psif_init);
8639 +module_exit(psif_exit);
8641 +MODULE_AUTHOR("Hans-Christian Egtvedt <hcegtvedt@atmel.com>");
8642 +MODULE_DESCRIPTION("Atmel AVR32 PSIF PS/2 driver");
8643 +MODULE_LICENSE("GPL");
8645 +++ b/drivers/input/serio/at32psif.h
8648 + * Copyright (C) 2007 Atmel Corporation
8650 + * Driver for the AT32AP700X PS/2 controller (PSIF).
8652 + * This program is free software; you can redistribute it and/or modify it
8653 + * under the terms of the GNU General Public License version 2 as published
8654 + * by the Free Software Foundation.
8657 +#ifndef _AT32PSIF_H
8658 +#define _AT32PSIF_H
8660 +/* PSIF register offsets */
8661 +#define PSIF_CR 0x00
8662 +#define PSIF_RHR 0x04
8663 +#define PSIF_THR 0x08
8664 +#define PSIF_SR 0x10
8665 +#define PSIF_IER 0x14
8666 +#define PSIF_IDR 0x18
8667 +#define PSIF_IMR 0x1c
8668 +#define PSIF_PSR 0x24
8670 +/* Bitfields in control register. */
8671 +#define PSIF_CR_RXDIS_OFFSET 1
8672 +#define PSIF_CR_RXDIS_SIZE 1
8673 +#define PSIF_CR_RXEN_OFFSET 0
8674 +#define PSIF_CR_RXEN_SIZE 1
8675 +#define PSIF_CR_SWRST_OFFSET 15
8676 +#define PSIF_CR_SWRST_SIZE 1
8677 +#define PSIF_CR_TXDIS_OFFSET 9
8678 +#define PSIF_CR_TXDIS_SIZE 1
8679 +#define PSIF_CR_TXEN_OFFSET 8
8680 +#define PSIF_CR_TXEN_SIZE 1
8682 +/* Bitfields in interrupt disable, enable, mask and status register. */
8683 +#define PSIF_NACK_OFFSET 8
8684 +#define PSIF_NACK_SIZE 1
8685 +#define PSIF_OVRUN_OFFSET 5
8686 +#define PSIF_OVRUN_SIZE 1
8687 +#define PSIF_PARITY_OFFSET 9
8688 +#define PSIF_PARITY_SIZE 1
8689 +#define PSIF_RXRDY_OFFSET 4
8690 +#define PSIF_RXRDY_SIZE 1
8691 +#define PSIF_TXEMPTY_OFFSET 1
8692 +#define PSIF_TXEMPTY_SIZE 1
8693 +#define PSIF_TXRDY_OFFSET 0
8694 +#define PSIF_TXRDY_SIZE 1
8696 +/* Bitfields in prescale register. */
8697 +#define PSIF_PSR_PRSCV_OFFSET 0
8698 +#define PSIF_PSR_PRSCV_SIZE 12
8700 +/* Bitfields in receive hold register. */
8701 +#define PSIF_RHR_RXDATA_OFFSET 0
8702 +#define PSIF_RHR_RXDATA_SIZE 8
8704 +/* Bitfields in transmit hold register. */
8705 +#define PSIF_THR_TXDATA_OFFSET 0
8706 +#define PSIF_THR_TXDATA_SIZE 8
8708 +/* Bit manipulation macros */
8709 +#define PSIF_BIT(name) \
8710 + (1 << PSIF_##name##_OFFSET)
8711 +#define PSIF_BF(name, value) \
8712 + (((value) & ((1 << PSIF_##name##_SIZE) - 1)) \
8713 + << PSIF_##name##_OFFSET)
8714 +#define PSIF_BFEXT(name, value)\
8715 + (((value) >> PSIF_##name##_OFFSET) \
8716 + & ((1 << PSIF_##name##_SIZE) - 1))
8717 +#define PSIF_BFINS(name, value, old) \
8718 + (((old) & ~(((1 << PSIF_##name##_SIZE) - 1) \
8719 + << PSIF_##name##_OFFSET)) \
8720 + | PSIF_BF(name, value))
8722 +/* Register access macros */
8723 +#define psif_readl(port, reg) \
8724 + __raw_readl((port)->regs + PSIF_##reg)
8725 +#define psif_writel(port, reg, value) \
8726 + __raw_writel((value), (port)->regs + PSIF_##reg)
8728 +#endif /* _AT32PSIF_H */
8729 --- a/drivers/input/serio/Kconfig
8730 +++ b/drivers/input/serio/Kconfig
8732 To compile this driver as a module, choose M here: the
8733 module will be called rpckbd.
8735 +config SERIO_AT32PSIF
8736 + tristate "AVR32 PSIF PS/2 keyboard and mouse controller"
8740 + Say Y here if you want to use the PSIF peripheral on AVR32 devices
8741 + and connect a PS/2 keyboard and/or mouse to it.
8743 + To compile this driver as a module, choose M here: the module will
8744 + be called at32psif.
8746 config SERIO_AMBAKMI
8747 tristate "AMBA KMI keyboard controller"
8749 --- a/drivers/input/serio/Makefile
8750 +++ b/drivers/input/serio/Makefile
8752 obj-$(CONFIG_SERIO_RPCKBD) += rpckbd.o
8753 obj-$(CONFIG_SERIO_SA1111) += sa1111ps2.o
8754 obj-$(CONFIG_SERIO_AMBAKMI) += ambakmi.o
8755 +obj-$(CONFIG_SERIO_AT32PSIF) += at32psif.o
8756 obj-$(CONFIG_SERIO_Q40KBD) += q40kbd.o
8757 obj-$(CONFIG_SERIO_GSCPS2) += gscps2.o
8758 obj-$(CONFIG_HP_SDC) += hp_sdc.o
8760 +++ b/drivers/misc/atmel_tclib.c
8762 +#include <linux/atmel_tc.h>
8763 +#include <linux/clk.h>
8764 +#include <linux/err.h>
8765 +#include <linux/init.h>
8766 +#include <linux/io.h>
8767 +#include <linux/ioport.h>
8768 +#include <linux/kernel.h>
8769 +#include <linux/platform_device.h>
8771 +/* Number of bytes to reserve for the iomem resource */
8772 +#define ATMEL_TC_IOMEM_SIZE 256
8776 + * This is a thin library to solve the problem of how to portably allocate
8777 + * one of the TC blocks. For simplicity, it doesn't currently expect to
8778 + * share individual timers between different drivers.
8781 +#if defined(CONFIG_AVR32)
8782 +/* AVR32 has these divide PBB */
8783 +const u8 atmel_tc_divisors[5] = { 0, 4, 8, 16, 32, };
8784 +EXPORT_SYMBOL(atmel_tc_divisors);
8786 +#elif defined(CONFIG_ARCH_AT91)
8787 +/* AT91 has these divide MCK */
8788 +const u8 atmel_tc_divisors[5] = { 2, 8, 32, 128, 0, };
8789 +EXPORT_SYMBOL(atmel_tc_divisors);
8793 +static DEFINE_SPINLOCK(tc_list_lock);
8794 +static LIST_HEAD(tc_list);
8797 + * atmel_tc_alloc - allocate a specified TC block
8798 + * @block: which block to allocate
8799 + * @name: name to be associated with the iomem resource
8801 + * Caller allocates a block. If it is available, a pointer to a
8802 + * pre-initialized struct atmel_tc is returned. The caller can access
8803 + * the registers directly through the "regs" field.
8805 +struct atmel_tc *atmel_tc_alloc(unsigned block, const char *name)
8807 + struct atmel_tc *tc;
8808 + struct platform_device *pdev = NULL;
8809 + struct resource *r;
8811 + spin_lock(&tc_list_lock);
8812 + list_for_each_entry(tc, &tc_list, node) {
8813 + if (tc->pdev->id == block) {
8819 + if (!pdev || tc->iomem)
8822 + r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
8823 + r = request_mem_region(r->start, ATMEL_TC_IOMEM_SIZE, name);
8827 + tc->regs = ioremap(r->start, ATMEL_TC_IOMEM_SIZE);
8829 + goto fail_ioremap;
8834 + spin_unlock(&tc_list_lock);
8838 + release_resource(r);
8843 +EXPORT_SYMBOL_GPL(atmel_tc_alloc);
8846 + * atmel_tc_free - release a specified TC block
8847 + * @tc: Timer/counter block that was returned by atmel_tc_alloc()
8849 + * This reverses the effect of atmel_tc_alloc(), unmapping the I/O
8850 + * registers, invalidating the resource returned by that routine and
8851 + * making the TC available to other drivers.
8853 +void atmel_tc_free(struct atmel_tc *tc)
8855 + spin_lock(&tc_list_lock);
8857 + iounmap(tc->regs);
8858 + release_resource(tc->iomem);
8862 + spin_unlock(&tc_list_lock);
8864 +EXPORT_SYMBOL_GPL(atmel_tc_free);
8866 +static int __init tc_probe(struct platform_device *pdev)
8868 + struct atmel_tc *tc;
8872 + if (!platform_get_resource(pdev, IORESOURCE_MEM, 0))
8875 + irq = platform_get_irq(pdev, 0);
8879 + tc = kzalloc(sizeof(struct atmel_tc), GFP_KERNEL);
8885 + clk = clk_get(&pdev->dev, "t0_clk");
8886 + if (IS_ERR(clk)) {
8892 + tc->clk[1] = clk_get(&pdev->dev, "t1_clk");
8893 + if (IS_ERR(tc->clk[1]))
8895 + tc->clk[2] = clk_get(&pdev->dev, "t2_clk");
8896 + if (IS_ERR(tc->clk[2]))
8900 + tc->irq[1] = platform_get_irq(pdev, 1);
8901 + if (tc->irq[1] < 0)
8903 + tc->irq[2] = platform_get_irq(pdev, 2);
8904 + if (tc->irq[2] < 0)
8907 + spin_lock(&tc_list_lock);
8908 + list_add_tail(&tc->node, &tc_list);
8909 + spin_unlock(&tc_list_lock);
8914 +static struct platform_driver tc_driver = {
8915 + .driver.name = "atmel_tcb",
8918 +static int __init tc_init(void)
8920 + return platform_driver_probe(&tc_driver, tc_probe);
8922 +arch_initcall(tc_init);
8923 --- a/drivers/misc/Kconfig
8924 +++ b/drivers/misc/Kconfig
8926 purposes including software controlled power-efficent backlights
8927 on LCD displays, motor control, and waveform generation.
8930 + bool "Atmel AT32/AT91 Timer/Counter Library"
8931 + depends on (AVR32 || ARCH_AT91)
8933 + Select this if you want a library to allocate the Timer/Counter
8934 + blocks found on many Atmel processors. This facilitates using
8935 + these blocks by different drivers despite processor differences.
8937 +config ATMEL_TCB_CLKSRC
8938 + bool "TC Block Clocksource"
8939 + depends on ATMEL_TCLIB && GENERIC_TIME
8942 + Select this to get a high precision clocksource based on a
8943 + TC block with a 5+ MHz base clock rate. Two timer channels
8944 + are combined to make a single 32-bit timer.
8946 + When GENERIC_CLOCKEVENTS is defined, the third timer channel
8947 + may be used as a clock event device supporting oneshot mode
8948 + (delays of up to two seconds) based on the 32 KiHz clock.
8950 +config ATMEL_TCB_CLKSRC_BLOCK
8952 + depends on ATMEL_TCB_CLKSRC
8953 + prompt "TC Block" if ARCH_AT91RM9200 || ARCH_AT91SAM9260 || CPU_AT32AP700X
8957 + Some chips provide more than one TC block, so you have the
8958 + choice of which one to use for the clock framework. The other
8959 + TC can be used for other purposes, such as PWM generation and
8963 tristate "Device driver for IBM RSA service processor"
8964 depends on X86 && PCI && INPUT && EXPERIMENTAL
8965 --- a/drivers/misc/Makefile
8966 +++ b/drivers/misc/Makefile
8968 obj-$(CONFIG_ASUS_LAPTOP) += asus-laptop.o
8969 obj-$(CONFIG_ATMEL_PWM) += atmel_pwm.o
8970 obj-$(CONFIG_ATMEL_SSC) += atmel-ssc.o
8971 +obj-$(CONFIG_ATMEL_TCLIB) += atmel_tclib.o
8972 obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o
8973 obj-$(CONFIG_LKDTM) += lkdtm.o
8974 obj-$(CONFIG_TIFM_CORE) += tifm_core.o
8976 +++ b/drivers/mmc/host/atmel-mci.c
8979 + * Atmel MultiMedia Card Interface driver
8981 + * Copyright (C) 2004-2006 Atmel Corporation
8983 + * This program is free software; you can redistribute it and/or modify
8984 + * it under the terms of the GNU General Public License version 2 as
8985 + * published by the Free Software Foundation.
8987 +#include <linux/blkdev.h>
8988 +#include <linux/clk.h>
8989 +#include <linux/device.h>
8990 +#include <linux/dma-mapping.h>
8991 +#include <linux/init.h>
8992 +#include <linux/interrupt.h>
8993 +#include <linux/ioport.h>
8994 +#include <linux/module.h>
8995 +#include <linux/platform_device.h>
8997 +#include <linux/mmc/host.h>
8999 +#include <asm/dma-controller.h>
9000 +#include <asm/io.h>
9001 +#include <asm/arch/board.h>
9002 +#include <asm/arch/gpio.h>
9004 +#include "atmel-mci.h"
9006 +#define DRIVER_NAME "atmel_mci"
9008 +#define MCI_DATA_ERROR_FLAGS (MCI_BIT(DCRCE) | MCI_BIT(DTOE) | \
9009 + MCI_BIT(OVRE) | MCI_BIT(UNRE))
9012 + EVENT_CMD_COMPLETE = 0,
9013 + EVENT_DATA_COMPLETE,
9016 + EVENT_STOP_COMPLETE,
9017 + EVENT_DMA_COMPLETE,
9021 +struct atmel_mci_dma {
9022 + struct dma_request_sg req;
9023 + unsigned short rx_periph_id;
9024 + unsigned short tx_periph_id;
9028 + struct mmc_host *mmc;
9029 + void __iomem *regs;
9030 + struct atmel_mci_dma dma;
9032 + struct mmc_request *mrq;
9033 + struct mmc_command *cmd;
9034 + struct mmc_data *data;
9041 + struct tasklet_struct tasklet;
9042 + unsigned long pending_events;
9043 + unsigned long completed_events;
9049 + /* For detect pin debouncing */
9050 + struct timer_list detect_timer;
9052 + unsigned long bus_hz;
9053 + unsigned long mapbase;
9055 + struct platform_device *pdev;
9057 +#ifdef CONFIG_DEBUG_FS
9058 + struct dentry *debugfs_root;
9059 + struct dentry *debugfs_regs;
9060 + struct dentry *debugfs_req;
9061 + struct dentry *debugfs_pending_events;
9062 + struct dentry *debugfs_completed_events;
9066 +/* Those printks take an awful lot of time... */
9068 +static unsigned int fmax = 15000000U;
9070 +static unsigned int fmax = 1000000U;
9072 +module_param(fmax, uint, 0444);
9073 +MODULE_PARM_DESC(fmax, "Max frequency in Hz of the MMC bus clock");
9075 +/* Test bit macros for completed events */
9076 +#define mci_cmd_is_complete(host) \
9077 + test_bit(EVENT_CMD_COMPLETE, &host->completed_events)
9078 +#define mci_data_is_complete(host) \
9079 + test_bit(EVENT_DATA_COMPLETE, &host->completed_events)
9080 +#define mci_data_error_is_complete(host) \
9081 + test_bit(EVENT_DATA_ERROR, &host->completed_events)
9082 +#define mci_stop_sent_is_complete(host) \
9083 + test_bit(EVENT_STOP_SENT, &host->completed_events)
9084 +#define mci_stop_is_complete(host) \
9085 + test_bit(EVENT_STOP_COMPLETE, &host->completed_events)
9086 +#define mci_dma_is_complete(host) \
9087 + test_bit(EVENT_DMA_COMPLETE, &host->completed_events)
9088 +#define mci_dma_error_is_complete(host) \
9089 + test_bit(EVENT_DMA_ERROR, &host->completed_events)
9091 +/* Test and clear bit macros for pending events */
9092 +#define mci_clear_cmd_is_pending(host) \
9093 + test_and_clear_bit(EVENT_CMD_COMPLETE, &host->pending_events)
9094 +#define mci_clear_data_is_pending(host) \
9095 + test_and_clear_bit(EVENT_DATA_COMPLETE, &host->pending_events)
9096 +#define mci_clear_data_error_is_pending(host) \
9097 + test_and_clear_bit(EVENT_DATA_ERROR, &host->pending_events)
9098 +#define mci_clear_stop_sent_is_pending(host) \
9099 + test_and_clear_bit(EVENT_STOP_SENT, &host->pending_events)
9100 +#define mci_clear_stop_is_pending(host) \
9101 + test_and_clear_bit(EVENT_STOP_COMPLETE, &host->pending_events)
9102 +#define mci_clear_dma_error_is_pending(host) \
9103 + test_and_clear_bit(EVENT_DMA_ERROR, &host->pending_events)
9105 +/* Test and set bit macros for completed events */
9106 +#define mci_set_cmd_is_completed(host) \
9107 + test_and_set_bit(EVENT_CMD_COMPLETE, &host->completed_events)
9108 +#define mci_set_data_is_completed(host) \
9109 + test_and_set_bit(EVENT_DATA_COMPLETE, &host->completed_events)
9110 +#define mci_set_data_error_is_completed(host) \
9111 + test_and_set_bit(EVENT_DATA_ERROR, &host->completed_events)
9112 +#define mci_set_stop_sent_is_completed(host) \
9113 + test_and_set_bit(EVENT_STOP_SENT, &host->completed_events)
9114 +#define mci_set_stop_is_completed(host) \
9115 + test_and_set_bit(EVENT_STOP_COMPLETE, &host->completed_events)
9116 +#define mci_set_dma_error_is_completed(host) \
9117 + test_and_set_bit(EVENT_DMA_ERROR, &host->completed_events)
9119 +/* Set bit macros for completed events */
9120 +#define mci_set_cmd_complete(host) \
9121 + set_bit(EVENT_CMD_COMPLETE, &host->completed_events)
9122 +#define mci_set_data_complete(host) \
9123 + set_bit(EVENT_DATA_COMPLETE, &host->completed_events)
9124 +#define mci_set_data_error_complete(host) \
9125 + set_bit(EVENT_DATA_ERROR, &host->completed_events)
9126 +#define mci_set_stop_sent_complete(host) \
9127 + set_bit(EVENT_STOP_SENT, &host->completed_events)
9128 +#define mci_set_stop_complete(host) \
9129 + set_bit(EVENT_STOP_COMPLETE, &host->completed_events)
9130 +#define mci_set_dma_complete(host) \
9131 + set_bit(EVENT_DMA_COMPLETE, &host->completed_events)
9132 +#define mci_set_dma_error_complete(host) \
9133 + set_bit(EVENT_DMA_ERROR, &host->completed_events)
9135 +/* Set bit macros for pending events */
9136 +#define mci_set_cmd_pending(host) \
9137 + set_bit(EVENT_CMD_COMPLETE, &host->pending_events)
9138 +#define mci_set_data_pending(host) \
9139 + set_bit(EVENT_DATA_COMPLETE, &host->pending_events)
9140 +#define mci_set_data_error_pending(host) \
9141 + set_bit(EVENT_DATA_ERROR, &host->pending_events)
9142 +#define mci_set_stop_sent_pending(host) \
9143 + set_bit(EVENT_STOP_SENT, &host->pending_events)
9144 +#define mci_set_stop_pending(host) \
9145 + set_bit(EVENT_STOP_COMPLETE, &host->pending_events)
9146 +#define mci_set_dma_error_pending(host) \
9147 + set_bit(EVENT_DMA_ERROR, &host->pending_events)
9149 +/* Clear bit macros for pending events */
9150 +#define mci_clear_cmd_pending(host) \
9151 + clear_bit(EVENT_CMD_COMPLETE, &host->pending_events)
9152 +#define mci_clear_data_pending(host) \
9153 + clear_bit(EVENT_DATA_COMPLETE, &host->pending_events)
9154 +#define mci_clear_data_error_pending(host) \
9155 + clear_bit(EVENT_DATA_ERROR, &host->pending_events)
9156 +#define mci_clear_stop_sent_pending(host) \
9157 + clear_bit(EVENT_STOP_SENT, &host->pending_events)
9158 +#define mci_clear_stop_pending(host) \
9159 + clear_bit(EVENT_STOP_COMPLETE, &host->pending_events)
9160 +#define mci_clear_dma_error_pending(host) \
9161 + clear_bit(EVENT_DMA_ERROR, &host->pending_events)
9164 +#ifdef CONFIG_DEBUG_FS
9165 +#include <linux/debugfs.h>
9167 +#define DBG_REQ_BUF_SIZE (4096 - sizeof(unsigned int))
9169 +struct req_dbg_data {
9170 + unsigned int nbytes;
9171 + char str[DBG_REQ_BUF_SIZE];
9174 +static int req_dbg_open(struct inode *inode, struct file *file)
9176 + struct atmel_mci *host;
9177 + struct mmc_request *mrq;
9178 + struct mmc_command *cmd, *stop;
9179 + struct mmc_data *data;
9180 + struct req_dbg_data *priv;
9182 + unsigned long n = 0;
9184 + priv = kzalloc(DBG_REQ_BUF_SIZE, GFP_KERNEL);
9189 + mutex_lock(&inode->i_mutex);
9190 + host = inode->i_private;
9192 + spin_lock_irq(&host->mmc->lock);
9198 + n = snprintf(str, DBG_REQ_BUF_SIZE,
9199 + "CMD%u(0x%x) %x %x %x %x %x (err %u)\n",
9200 + cmd->opcode, cmd->arg, cmd->flags,
9201 + cmd->resp[0], cmd->resp[1], cmd->resp[2],
9202 + cmd->resp[3], cmd->error);
9203 + if (n < DBG_REQ_BUF_SIZE && data)
9204 + n += snprintf(str + n, DBG_REQ_BUF_SIZE - n,
9205 + "DATA %u * %u (%u) %x (err %u)\n",
9206 + data->blocks, data->blksz,
9207 + data->bytes_xfered, data->flags,
9209 + if (n < DBG_REQ_BUF_SIZE && stop)
9210 + n += snprintf(str + n, DBG_REQ_BUF_SIZE - n,
9211 + "CMD%u(0x%x) %x %x %x %x %x (err %u)\n",
9212 + stop->opcode, stop->arg, stop->flags,
9213 + stop->resp[0], stop->resp[1],
9214 + stop->resp[2], stop->resp[3],
9217 + spin_unlock_irq(&host->mmc->lock);
9218 + mutex_unlock(&inode->i_mutex);
9220 + priv->nbytes = min(n, DBG_REQ_BUF_SIZE);
9221 + file->private_data = priv;
9226 +static ssize_t req_dbg_read(struct file *file, char __user *buf,
9227 + size_t nbytes, loff_t *ppos)
9229 + struct req_dbg_data *priv = file->private_data;
9231 + return simple_read_from_buffer(buf, nbytes, ppos,
9232 + priv->str, priv->nbytes);
9235 +static int req_dbg_release(struct inode *inode, struct file *file)
9237 + kfree(file->private_data);
9241 +static const struct file_operations req_dbg_fops = {
9242 + .owner = THIS_MODULE,
9243 + .open = req_dbg_open,
9244 + .llseek = no_llseek,
9245 + .read = req_dbg_read,
9246 + .release = req_dbg_release,
9249 +static int regs_dbg_open(struct inode *inode, struct file *file)
9251 + struct atmel_mci *host;
9254 + int ret = -ENOMEM;
9256 + mutex_lock(&inode->i_mutex);
9257 + host = inode->i_private;
9258 + data = kmalloc(inode->i_size, GFP_KERNEL);
9262 + spin_lock_irq(&host->mmc->lock);
9263 + for (i = 0; i < inode->i_size / 4; i++)
9264 + data[i] = __raw_readl(host->regs + i * 4);
9265 + spin_unlock_irq(&host->mmc->lock);
9267 + file->private_data = data;
9271 + mutex_unlock(&inode->i_mutex);
9276 +static ssize_t regs_dbg_read(struct file *file, char __user *buf,
9277 + size_t nbytes, loff_t *ppos)
9279 + struct inode *inode = file->f_dentry->d_inode;
9282 + mutex_lock(&inode->i_mutex);
9283 + ret = simple_read_from_buffer(buf, nbytes, ppos,
9284 + file->private_data,
9285 + file->f_dentry->d_inode->i_size);
9286 + mutex_unlock(&inode->i_mutex);
9291 +static int regs_dbg_release(struct inode *inode, struct file *file)
9293 + kfree(file->private_data);
9297 +static const struct file_operations regs_dbg_fops = {
9298 + .owner = THIS_MODULE,
9299 + .open = regs_dbg_open,
9300 + .llseek = generic_file_llseek,
9301 + .read = regs_dbg_read,
9302 + .release = regs_dbg_release,
9305 +static void atmci_init_debugfs(struct atmel_mci *host)
9307 + struct mmc_host *mmc;
9308 + struct dentry *root, *regs;
9309 + struct resource *res;
9312 + root = debugfs_create_dir(mmc_hostname(mmc), NULL);
9313 + if (IS_ERR(root) || !root)
9315 + host->debugfs_root = root;
9317 + regs = debugfs_create_file("regs", 0400, root, host, ®s_dbg_fops);
9321 + res = platform_get_resource(host->pdev, IORESOURCE_MEM, 0);
9322 + regs->d_inode->i_size = res->end - res->start + 1;
9323 + host->debugfs_regs = regs;
9325 + host->debugfs_req = debugfs_create_file("req", 0400, root,
9326 + host, &req_dbg_fops);
9327 + if (!host->debugfs_req)
9330 + host->debugfs_pending_events
9331 + = debugfs_create_u32("pending_events", 0400, root,
9332 + (u32 *)&host->pending_events);
9333 + if (!host->debugfs_pending_events)
9334 + goto err_pending_events;
9336 + host->debugfs_completed_events
9337 + = debugfs_create_u32("completed_events", 0400, root,
9338 + (u32 *)&host->completed_events);
9339 + if (!host->debugfs_completed_events)
9340 + goto err_completed_events;
9344 +err_completed_events:
9345 + debugfs_remove(host->debugfs_pending_events);
9346 +err_pending_events:
9347 + debugfs_remove(host->debugfs_req);
9349 + debugfs_remove(host->debugfs_regs);
9351 + debugfs_remove(host->debugfs_root);
9353 + host->debugfs_root = NULL;
9354 + dev_err(&host->pdev->dev,
9355 + "failed to initialize debugfs for %s\n",
9356 + mmc_hostname(mmc));
9359 +static void atmci_cleanup_debugfs(struct atmel_mci *host)
9361 + if (host->debugfs_root) {
9362 + debugfs_remove(host->debugfs_completed_events);
9363 + debugfs_remove(host->debugfs_pending_events);
9364 + debugfs_remove(host->debugfs_req);
9365 + debugfs_remove(host->debugfs_regs);
9366 + debugfs_remove(host->debugfs_root);
9367 + host->debugfs_root = NULL;
9371 +static inline void atmci_init_debugfs(struct atmel_mci *host)
9376 +static inline void atmci_cleanup_debugfs(struct atmel_mci *host)
9380 +#endif /* CONFIG_DEBUG_FS */
9382 +static inline unsigned int ns_to_clocks(struct atmel_mci *host,
9385 + return (ns * (host->bus_hz / 1000000) + 999) / 1000;
9388 +static void atmci_set_timeout(struct atmel_mci *host,
9389 + struct mmc_data *data)
9391 + static unsigned dtomul_to_shift[] = {
9392 + 0, 4, 7, 8, 10, 12, 16, 20
9395 + unsigned dtocyc, dtomul;
9397 + timeout = ns_to_clocks(host, data->timeout_ns) + data->timeout_clks;
9399 + for (dtomul = 0; dtomul < 8; dtomul++) {
9400 + unsigned shift = dtomul_to_shift[dtomul];
9401 + dtocyc = (timeout + (1 << shift) - 1) >> shift;
9406 + if (dtomul >= 8) {
9411 + dev_dbg(&host->mmc->class_dev, "setting timeout to %u cycles\n",
9412 + dtocyc << dtomul_to_shift[dtomul]);
9413 + mci_writel(host, DTOR, (MCI_BF(DTOMUL, dtomul)
9414 + | MCI_BF(DTOCYC, dtocyc)));
9418 + * Return mask with command flags to be enabled for this command.
9420 +static u32 atmci_prepare_command(struct mmc_host *mmc,
9421 + struct mmc_command *cmd)
9427 + cmdr = MCI_BF(CMDNB, cmd->opcode);
9429 + if (cmd->flags & MMC_RSP_PRESENT) {
9430 + if (cmd->flags & MMC_RSP_136)
9431 + cmdr |= MCI_BF(RSPTYP, MCI_RSPTYP_136_BIT);
9433 + cmdr |= MCI_BF(RSPTYP, MCI_RSPTYP_48_BIT);
9437 + * This should really be MAXLAT_5 for CMD2 and ACMD41, but
9438 + * it's too difficult to determine whether this is an ACMD or
9439 + * not. Better make it 64.
9441 + cmdr |= MCI_BIT(MAXLAT);
9443 + if (mmc->ios.bus_mode == MMC_BUSMODE_OPENDRAIN)
9444 + cmdr |= MCI_BIT(OPDCMD);
9446 + dev_dbg(&mmc->class_dev,
9447 + "cmd: op %02x arg %08x flags %08x, cmdflags %08lx\n",
9448 + cmd->opcode, cmd->arg, cmd->flags, (unsigned long)cmdr);
9453 +static void atmci_start_command(struct atmel_mci *host,
9454 + struct mmc_command *cmd,
9457 + WARN_ON(host->cmd);
9460 + mci_writel(host, ARGR, cmd->arg);
9461 + mci_writel(host, CMDR, cmd_flags);
9464 + dma_start_request(host->dma.req.req.dmac,
9465 + host->dma.req.req.channel);
9469 + * Returns a mask of flags to be set in the command register when the
9470 + * command to start the transfer is to be sent.
9472 +static u32 atmci_prepare_data(struct mmc_host *mmc, struct mmc_data *data)
9474 + struct atmel_mci *host = mmc_priv(mmc);
9477 + WARN_ON(host->data);
9478 + host->data = data;
9480 + atmci_set_timeout(host, data);
9481 + mci_writel(host, BLKR, (MCI_BF(BCNT, data->blocks)
9482 + | MCI_BF(BLKLEN, data->blksz)));
9483 + host->dma.req.block_size = data->blksz;
9484 + host->dma.req.nr_blocks = data->blocks;
9486 + cmd_flags = MCI_BF(TRCMD, MCI_TRCMD_START_TRANS);
9487 + if (data->flags & MMC_DATA_STREAM)
9488 + cmd_flags |= MCI_BF(TRTYP, MCI_TRTYP_STREAM);
9489 + else if (data->blocks > 1)
9490 + cmd_flags |= MCI_BF(TRTYP, MCI_TRTYP_MULTI_BLOCK);
9492 + cmd_flags |= MCI_BF(TRTYP, MCI_TRTYP_BLOCK);
9494 + if (data->flags & MMC_DATA_READ) {
9495 + cmd_flags |= MCI_BIT(TRDIR);
9496 + host->dma.req.nr_sg
9497 + = dma_map_sg(&host->pdev->dev, data->sg,
9498 + data->sg_len, DMA_FROM_DEVICE);
9499 + host->dma.req.periph_id = host->dma.rx_periph_id;
9500 + host->dma.req.direction = DMA_DIR_PERIPH_TO_MEM;
9501 + host->dma.req.data_reg = host->mapbase + MCI_RDR;
9503 + host->dma.req.nr_sg
9504 + = dma_map_sg(&host->pdev->dev, data->sg,
9505 + data->sg_len, DMA_TO_DEVICE);
9506 + host->dma.req.periph_id = host->dma.tx_periph_id;
9507 + host->dma.req.direction = DMA_DIR_MEM_TO_PERIPH;
9508 + host->dma.req.data_reg = host->mapbase + MCI_TDR;
9510 + host->dma.req.sg = data->sg;
9512 + dma_prepare_request_sg(host->dma.req.req.dmac, &host->dma.req);
9517 +static void atmci_request(struct mmc_host *mmc, struct mmc_request *mrq)
9519 + struct atmel_mci *host = mmc_priv(mmc);
9520 + struct mmc_data *data = mrq->data;
9524 + iflags = mci_readl(host, IMR);
9526 + dev_warn(&mmc->class_dev, "WARNING: IMR=0x%08x\n",
9527 + mci_readl(host, IMR));
9529 + WARN_ON(host->mrq != NULL);
9532 + * We may "know" the card is gone even though there's still an
9533 + * electrical connection. If so, we really need to communicate
9534 + * this to the MMC core since there won't be any more
9535 + * interrupts as the card is completely removed. Otherwise,
9536 + * the MMC core might believe the card is still there even
9537 + * though the card was just removed very slowly.
9539 + if (!host->present) {
9540 + mrq->cmd->error = -ENOMEDIUM;
9541 + mmc_request_done(mmc, mrq);
9546 + host->pending_events = 0;
9547 + host->completed_events = 0;
9549 + iflags = MCI_BIT(CMDRDY);
9550 + cmdflags = atmci_prepare_command(mmc, mrq->cmd);
9555 + host->stop_cmdr = atmci_prepare_command(mmc, mrq->stop);
9556 + host->stop_cmdr |= MCI_BF(TRCMD, MCI_TRCMD_STOP_TRANS);
9557 + if (!(data->flags & MMC_DATA_WRITE))
9558 + host->stop_cmdr |= MCI_BIT(TRDIR);
9559 + if (data->flags & MMC_DATA_STREAM)
9560 + host->stop_cmdr |= MCI_BF(TRTYP, MCI_TRTYP_STREAM);
9562 + host->stop_cmdr |= MCI_BF(TRTYP, MCI_TRTYP_MULTI_BLOCK);
9565 + cmdflags |= atmci_prepare_data(mmc, data);
9566 + iflags |= MCI_DATA_ERROR_FLAGS;
9569 + atmci_start_command(host, mrq->cmd, cmdflags);
9570 + mci_writel(host, IER, iflags);
9573 +static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
9575 + struct atmel_mci *host = mmc_priv(mmc);
9581 + /* Set clock rate */
9582 + clkdiv = DIV_ROUND_UP(host->bus_hz, 2 * ios->clock) - 1;
9583 + if (clkdiv > 255) {
9584 + dev_warn(&mmc->class_dev,
9585 + "clock %u too slow; using %lu\n",
9586 + ios->clock, host->bus_hz / (2 * 256));
9590 + mr = mci_readl(host, MR);
9591 + mr = MCI_BFINS(CLKDIV, clkdiv, mr)
9592 + | MCI_BIT(WRPROOF) | MCI_BIT(RDPROOF);
9593 + mci_writel(host, MR, mr);
9595 + /* Enable the MCI controller */
9596 + mci_writel(host, CR, MCI_BIT(MCIEN));
9598 + /* Disable the MCI controller */
9599 + mci_writel(host, CR, MCI_BIT(MCIDIS));
9602 + switch (ios->bus_width) {
9603 + case MMC_BUS_WIDTH_1:
9604 + mci_writel(host, SDCR, 0);
9606 + case MMC_BUS_WIDTH_4:
9607 + mci_writel(host, SDCR, MCI_BIT(SDCBUS));
9611 + switch (ios->power_mode) {
9612 + case MMC_POWER_ON:
9613 + /* Send init sequence (74 clock cycles) */
9614 + mci_writel(host, IDR, ~0UL);
9615 + mci_writel(host, CMDR, MCI_BF(SPCMD, MCI_SPCMD_INIT_CMD));
9616 + while (!(mci_readl(host, SR) & MCI_BIT(CMDRDY)))
9621 + * TODO: None of the currently available AVR32-based
9622 + * boards allow MMC power to be turned off. Implement
9623 + * power control when this can be tested properly.
9629 +static int atmci_get_ro(struct mmc_host *mmc)
9631 + int read_only = 0;
9632 + struct atmel_mci *host = mmc_priv(mmc);
9634 + if (host->wp_pin >= 0) {
9635 + read_only = gpio_get_value(host->wp_pin);
9636 + dev_dbg(&mmc->class_dev, "card is %s\n",
9637 + read_only ? "read-only" : "read-write");
9639 + dev_dbg(&mmc->class_dev,
9640 + "no pin for checking read-only switch."
9641 + " Assuming write-enable.\n");
9647 +static struct mmc_host_ops atmci_ops = {
9648 + .request = atmci_request,
9649 + .set_ios = atmci_set_ios,
9650 + .get_ro = atmci_get_ro,
9653 +static void atmci_request_end(struct mmc_host *mmc, struct mmc_request *mrq)
9655 + struct atmel_mci *host = mmc_priv(mmc);
9657 + WARN_ON(host->cmd || host->data);
9660 + mmc_request_done(mmc, mrq);
9663 +static void send_stop_cmd(struct mmc_host *mmc, struct mmc_data *data,
9666 + struct atmel_mci *host = mmc_priv(mmc);
9668 + atmci_start_command(host, data->stop, host->stop_cmdr | flags);
9669 + mci_writel(host, IER, MCI_BIT(CMDRDY));
9672 +static void atmci_data_complete(struct atmel_mci *host, struct mmc_data *data)
9674 + host->data = NULL;
9675 + dma_unmap_sg(&host->pdev->dev, data->sg, host->dma.req.nr_sg,
9676 + ((data->flags & MMC_DATA_WRITE)
9677 + ? DMA_TO_DEVICE : DMA_FROM_DEVICE));
9680 + * Data might complete before command for very short transfers
9683 + if (mci_cmd_is_complete(host)
9684 + && (!data->stop || mci_stop_is_complete(host)))
9685 + atmci_request_end(host->mmc, data->mrq);
9688 +static void atmci_command_complete(struct atmel_mci *host,
9689 + struct mmc_command *cmd, u32 status)
9691 + if (status & MCI_BIT(RTOE))
9692 + cmd->error = -ETIMEDOUT;
9693 + else if ((cmd->flags & MMC_RSP_CRC)
9694 + && (status & MCI_BIT(RCRCE)))
9695 + cmd->error = -EILSEQ;
9696 + else if (status & (MCI_BIT(RINDE) | MCI_BIT(RDIRE) | MCI_BIT(RENDE)))
9697 + cmd->error = -EIO;
9700 + dev_dbg(&host->mmc->class_dev,
9701 + "command error: op=0x%x status=0x%08x\n",
9702 + cmd->opcode, status);
9705 + dma_stop_request(host->dma.req.req.dmac,
9706 + host->dma.req.req.channel);
9707 + mci_writel(host, IDR, MCI_BIT(NOTBUSY)
9708 + | MCI_DATA_ERROR_FLAGS);
9709 + host->data = NULL;
9714 +static void atmci_detect_change(unsigned long data)
9716 + struct atmel_mci *host = (struct atmel_mci *)data;
9717 + struct mmc_request *mrq = host->mrq;
9721 + * atmci_remove() sets detect_pin to -1 before freeing the
9722 + * interrupt. We must not re-enable the interrupt if it has
9726 + if (host->detect_pin < 0)
9729 + enable_irq(gpio_to_irq(host->detect_pin));
9730 + present = !gpio_get_value(host->detect_pin);
9732 + dev_vdbg(&host->pdev->dev, "detect change: %d (was %d)\n",
9733 + present, host->present);
9735 + if (present != host->present) {
9736 + dev_dbg(&host->mmc->class_dev, "card %s\n",
9737 + present ? "inserted" : "removed");
9738 + host->present = present;
9740 + /* Reset controller if card is gone */
9742 + mci_writel(host, CR, MCI_BIT(SWRST));
9743 + mci_writel(host, IDR, ~0UL);
9744 + mci_writel(host, CR, MCI_BIT(MCIEN));
9747 + /* Clean up queue if present */
9749 + if (!mci_cmd_is_complete(host))
9750 + mrq->cmd->error = -ENOMEDIUM;
9751 + if (mrq->data && !mci_data_is_complete(host)
9752 + && !mci_data_error_is_complete(host)) {
9753 + dma_stop_request(host->dma.req.req.dmac,
9754 + host->dma.req.req.channel);
9755 + host->data->error = -ENOMEDIUM;
9756 + atmci_data_complete(host, host->data);
9758 + if (mrq->stop && !mci_stop_is_complete(host))
9759 + mrq->stop->error = -ENOMEDIUM;
9762 + atmci_request_end(host->mmc, mrq);
9765 + mmc_detect_change(host->mmc, 0);
9769 +static void atmci_tasklet_func(unsigned long priv)
9771 + struct mmc_host *mmc = (struct mmc_host *)priv;
9772 + struct atmel_mci *host = mmc_priv(mmc);
9773 + struct mmc_request *mrq = host->mrq;
9774 + struct mmc_data *data = host->data;
9776 + dev_vdbg(&mmc->class_dev,
9777 + "tasklet: pending/completed/mask %lx/%lx/%x\n",
9778 + host->pending_events, host->completed_events,
9779 + mci_readl(host, IMR));
9781 + if (mci_clear_cmd_is_pending(host)) {
9782 + mci_set_cmd_complete(host);
9783 + atmci_command_complete(host, mrq->cmd, host->cmd_status);
9784 + if (!host->data || mci_data_is_complete(host)
9785 + || mci_data_error_is_complete(host))
9786 + atmci_request_end(mmc, mrq);
9788 + if (mci_clear_stop_is_pending(host)) {
9789 + mci_set_stop_complete(host);
9790 + atmci_command_complete(host, mrq->stop, host->stop_status);
9791 + if (mci_data_is_complete(host)
9792 + || mci_data_error_is_complete(host))
9793 + atmci_request_end(mmc, mrq);
9795 + if (mci_clear_dma_error_is_pending(host)) {
9796 + mci_set_dma_error_complete(host);
9797 + mci_clear_data_pending(host);
9799 + /* DMA controller got bus error => invalid address */
9800 + data->error = -EIO;
9802 + dev_dbg(&mmc->class_dev, "dma error after %u bytes xfered\n",
9803 + host->data->bytes_xfered);
9806 + && !mci_set_stop_sent_is_completed(host))
9807 + /* TODO: Check if card is still present */
9808 + send_stop_cmd(host->mmc, data, 0);
9810 + atmci_data_complete(host, data);
9812 + if (mci_clear_data_error_is_pending(host)) {
9813 + u32 status = host->data_status;
9815 + mci_set_data_error_complete(host);
9816 + mci_clear_data_pending(host);
9818 + dma_stop_request(host->dma.req.req.dmac,
9819 + host->dma.req.req.channel);
9821 + if (status & MCI_BIT(DCRCE)) {
9822 + dev_dbg(&mmc->class_dev, "data CRC error\n");
9823 + data->error = -EILSEQ;
9824 + } else if (status & MCI_BIT(DTOE)) {
9825 + dev_dbg(&mmc->class_dev, "data timeout error\n");
9826 + data->error = -ETIMEDOUT;
9828 + dev_dbg(&mmc->class_dev, "data FIFO error\n");
9829 + data->error = -EIO;
9831 + dev_dbg(&mmc->class_dev, "bytes xfered: %u\n",
9832 + data->bytes_xfered);
9835 + && !mci_set_stop_sent_is_completed(host))
9836 + /* TODO: Check if card is still present */
9837 + send_stop_cmd(host->mmc, data, 0);
9839 + atmci_data_complete(host, data);
9841 + if (mci_clear_data_is_pending(host)) {
9842 + mci_set_data_complete(host);
9843 + data->bytes_xfered = data->blocks * data->blksz;
9844 + atmci_data_complete(host, data);
9848 +static void atmci_cmd_interrupt(struct mmc_host *mmc, u32 status)
9850 + struct atmel_mci *host = mmc_priv(mmc);
9851 + struct mmc_command *cmd = host->cmd;
9854 + * Read the response now so that we're free to send a new
9855 + * command immediately.
9857 + cmd->resp[0] = mci_readl(host, RSPR);
9858 + cmd->resp[1] = mci_readl(host, RSPR);
9859 + cmd->resp[2] = mci_readl(host, RSPR);
9860 + cmd->resp[3] = mci_readl(host, RSPR);
9862 + mci_writel(host, IDR, MCI_BIT(CMDRDY));
9865 + if (mci_stop_sent_is_complete(host)) {
9866 + host->stop_status = status;
9867 + mci_set_stop_pending(host);
9869 + struct mmc_request *mrq = host->mrq;
9871 + if (mrq->stop && mci_dma_is_complete(host)
9872 + && !mci_set_stop_sent_is_completed(host))
9873 + send_stop_cmd(host->mmc, mrq->data, 0);
9874 + host->cmd_status = status;
9875 + mci_set_cmd_pending(host);
9878 + tasklet_schedule(&host->tasklet);
9881 +static void atmci_xfer_complete(struct dma_request *_req)
9883 + struct dma_request_sg *req = to_dma_request_sg(_req);
9884 + struct atmel_mci_dma *dma;
9885 + struct atmel_mci *host;
9886 + struct mmc_data *data;
9888 + dma = container_of(req, struct atmel_mci_dma, req);
9889 + host = container_of(dma, struct atmel_mci, dma);
9890 + data = host->data;
9893 + * This callback may be called before we see the CMDRDY
9894 + * interrupt under heavy irq load (possibly caused by other
9895 + * drivers) or when interrupts are disabled for a long time.
9897 + mci_set_dma_complete(host);
9898 + if (data->stop && mci_cmd_is_complete(host)
9899 + && !mci_set_stop_sent_is_completed(host))
9900 + send_stop_cmd(host->mmc, data, 0);
9903 + * Regardless of what the documentation says, we have to wait
9904 + * for NOTBUSY even after block read operations.
9906 + * When the DMA transfer is complete, the controller may still
9907 + * be reading the CRC from the card, i.e. the data transfer is
9908 + * still in progress and we haven't seen all the potential
9911 + mci_writel(host, IER, MCI_BIT(NOTBUSY));
9914 +static void atmci_dma_error(struct dma_request *_req)
9916 + struct dma_request_sg *req = to_dma_request_sg(_req);
9917 + struct atmel_mci_dma *dma;
9918 + struct atmel_mci *host;
9920 + dma = container_of(req, struct atmel_mci_dma, req);
9921 + host = container_of(dma, struct atmel_mci, dma);
9923 + mci_writel(host, IDR, (MCI_BIT(NOTBUSY)
9924 + | MCI_DATA_ERROR_FLAGS));
9926 + mci_set_dma_error_pending(host);
9927 + tasklet_schedule(&host->tasklet);
9930 +static irqreturn_t atmci_interrupt(int irq, void *dev_id)
9932 + struct mmc_host *mmc = dev_id;
9933 + struct atmel_mci *host = mmc_priv(mmc);
9934 + u32 status, mask, pending;
9936 + spin_lock(&mmc->lock);
9938 + status = mci_readl(host, SR);
9939 + mask = mci_readl(host, IMR);
9940 + pending = status & mask;
9943 + if (pending & MCI_DATA_ERROR_FLAGS) {
9944 + mci_writel(host, IDR, (MCI_BIT(NOTBUSY)
9945 + | MCI_DATA_ERROR_FLAGS));
9946 + host->data_status = status;
9947 + mci_set_data_error_pending(host);
9948 + tasklet_schedule(&host->tasklet);
9951 + if (pending & MCI_BIT(CMDRDY))
9952 + atmci_cmd_interrupt(mmc, status);
9953 + if (pending & MCI_BIT(NOTBUSY)) {
9954 + mci_writel(host, IDR, (MCI_BIT(NOTBUSY)
9955 + | MCI_DATA_ERROR_FLAGS));
9956 + mci_set_data_pending(host);
9957 + tasklet_schedule(&host->tasklet);
9960 + status = mci_readl(host, SR);
9961 + mask = mci_readl(host, IMR);
9962 + pending = status & mask;
9963 + } while (pending);
9965 + spin_unlock(&mmc->lock);
9967 + return IRQ_HANDLED;
9970 +static irqreturn_t atmci_detect_interrupt(int irq, void *dev_id)
9972 + struct mmc_host *mmc = dev_id;
9973 + struct atmel_mci *host = mmc_priv(mmc);
9976 + * Disable interrupts until the pin has stabilized and check
9977 + * the state then. Use mod_timer() since we may be in the
9978 + * middle of the timer routine when this interrupt triggers.
9980 + disable_irq_nosync(irq);
9981 + mod_timer(&host->detect_timer, jiffies + msecs_to_jiffies(20));
9983 + return IRQ_HANDLED;
9986 +static int __devinit atmci_probe(struct platform_device *pdev)
9988 + struct mci_platform_data *board;
9989 + struct atmel_mci *host;
9990 + struct mmc_host *mmc;
9991 + struct resource *regs;
9995 + regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
9998 + irq = platform_get_irq(pdev, 0);
10002 + board = pdev->dev.platform_data;
10004 + mmc = mmc_alloc_host(sizeof(struct atmel_mci), &pdev->dev);
10008 + host = mmc_priv(mmc);
10009 + host->pdev = pdev;
10012 + host->detect_pin = board->detect_pin;
10013 + host->wp_pin = board->wp_pin;
10015 + host->detect_pin = -1;
10016 + host->wp_pin = -1;
10019 + host->mck = clk_get(&pdev->dev, "mci_clk");
10020 + if (IS_ERR(host->mck)) {
10021 + ret = PTR_ERR(host->mck);
10022 + goto out_free_host;
10024 + clk_enable(host->mck);
10027 + host->regs = ioremap(regs->start, regs->end - regs->start + 1);
10029 + goto out_disable_clk;
10031 + host->bus_hz = clk_get_rate(host->mck);
10032 + host->mapbase = regs->start;
10034 + mmc->ops = &atmci_ops;
10035 + mmc->f_min = (host->bus_hz + 511) / 512;
10036 + mmc->f_max = min((unsigned int)(host->bus_hz / 2), fmax);
10037 + mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
10038 + mmc->caps |= MMC_CAP_4_BIT_DATA;
10040 + tasklet_init(&host->tasklet, atmci_tasklet_func, (unsigned long)mmc);
10042 + ret = request_irq(irq, atmci_interrupt, 0, "mmci", mmc);
10046 + /* Assume card is present if we don't have a detect pin */
10047 + host->present = 1;
10048 + if (host->detect_pin >= 0) {
10049 + if (gpio_request(host->detect_pin, "mmc_detect")) {
10050 + dev_dbg(&mmc->class_dev, "no detect pin available\n");
10051 + host->detect_pin = -1;
10053 + host->present = !gpio_get_value(host->detect_pin);
10056 + if (host->wp_pin >= 0) {
10057 + if (gpio_request(host->wp_pin, "mmc_wp")) {
10058 + dev_dbg(&mmc->class_dev, "no WP pin available\n");
10059 + host->wp_pin = -1;
10063 + /* TODO: Get this information from platform data */
10065 + host->dma.req.req.dmac = find_dma_controller(0);
10066 + if (!host->dma.req.req.dmac) {
10067 + dev_dbg(&mmc->class_dev, "no DMA controller available\n");
10068 + goto out_free_irq;
10070 + ret = dma_alloc_channel(host->dma.req.req.dmac);
10072 + dev_dbg(&mmc->class_dev, "unable to allocate DMA channel\n");
10073 + goto out_free_irq;
10075 + host->dma.req.req.channel = ret;
10076 + host->dma.req.width = DMA_WIDTH_32BIT;
10077 + host->dma.req.req.xfer_complete = atmci_xfer_complete;
10078 + host->dma.req.req.block_complete = NULL; // atmci_block_complete;
10079 + host->dma.req.req.error = atmci_dma_error;
10080 + host->dma.rx_periph_id = 0;
10081 + host->dma.tx_periph_id = 1;
10083 + mci_writel(host, CR, MCI_BIT(SWRST));
10084 + mci_writel(host, IDR, ~0UL);
10086 + platform_set_drvdata(pdev, host);
10088 + mmc_add_host(mmc);
10090 + if (host->detect_pin >= 0) {
10091 + setup_timer(&host->detect_timer, atmci_detect_change,
10092 + (unsigned long)host);
10094 + ret = request_irq(gpio_to_irq(host->detect_pin),
10095 + atmci_detect_interrupt,
10096 + IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
10097 + DRIVER_NAME, mmc);
10099 + dev_dbg(&mmc->class_dev,
10100 + "could not request IRQ %d for detect pin\n",
10101 + gpio_to_irq(host->detect_pin));
10102 + gpio_free(host->detect_pin);
10103 + host->detect_pin = -1;
10107 + dev_info(&mmc->class_dev, "Atmel MCI controller at 0x%08lx irq %d\n",
10108 + host->mapbase, irq);
10110 + atmci_init_debugfs(host);
10115 + if (host->detect_pin >= 0)
10116 + gpio_free(host->detect_pin);
10117 + if (host->wp_pin >= 0)
10118 + gpio_free(host->wp_pin);
10119 + free_irq(irq, mmc);
10121 + iounmap(host->regs);
10123 + clk_disable(host->mck);
10124 + clk_put(host->mck);
10126 + mmc_free_host(mmc);
10130 +static int __devexit atmci_remove(struct platform_device *pdev)
10132 + struct atmel_mci *host = platform_get_drvdata(pdev);
10134 + platform_set_drvdata(pdev, NULL);
10137 + atmci_cleanup_debugfs(host);
10139 + if (host->detect_pin >= 0) {
10140 + int pin = host->detect_pin;
10142 + /* Make sure our timer doesn't enable the interrupt */
10143 + host->detect_pin = -1;
10146 + free_irq(gpio_to_irq(pin), host->mmc);
10147 + del_timer_sync(&host->detect_timer);
10148 + cancel_delayed_work(&host->mmc->detect);
10152 + mmc_remove_host(host->mmc);
10154 + mci_writel(host, IDR, ~0UL);
10155 + mci_writel(host, CR, MCI_BIT(MCIDIS));
10156 + mci_readl(host, SR);
10158 + dma_release_channel(host->dma.req.req.dmac,
10159 + host->dma.req.req.channel);
10161 + if (host->wp_pin >= 0)
10162 + gpio_free(host->wp_pin);
10164 + free_irq(platform_get_irq(pdev, 0), host->mmc);
10165 + iounmap(host->regs);
10167 + clk_disable(host->mck);
10168 + clk_put(host->mck);
10170 + mmc_free_host(host->mmc);
10175 +static struct platform_driver atmci_driver = {
10176 + .probe = atmci_probe,
10177 + .remove = __devexit_p(atmci_remove),
10179 + .name = DRIVER_NAME,
10183 +static int __init atmci_init(void)
10185 + return platform_driver_register(&atmci_driver);
10188 +static void __exit atmci_exit(void)
10190 + platform_driver_unregister(&atmci_driver);
10193 +module_init(atmci_init);
10194 +module_exit(atmci_exit);
10196 +MODULE_DESCRIPTION("Atmel Multimedia Card Interface driver");
10197 +MODULE_LICENSE("GPL");
10199 +++ b/drivers/mmc/host/atmel-mci.h
10202 + * Atmel MultiMedia Card Interface driver
10204 + * Copyright (C) 2004-2006 Atmel Corporation
10206 + * This program is free software; you can redistribute it and/or modify
10207 + * it under the terms of the GNU General Public License version 2 as
10208 + * published by the Free Software Foundation.
10210 +#ifndef __DRIVERS_MMC_ATMEL_MCI_H__
10211 +#define __DRIVERS_MMC_ATMEL_MCI_H__
10213 +/* MCI register offsets */
10214 +#define MCI_CR 0x0000
10215 +#define MCI_MR 0x0004
10216 +#define MCI_DTOR 0x0008
10217 +#define MCI_SDCR 0x000c
10218 +#define MCI_ARGR 0x0010
10219 +#define MCI_CMDR 0x0014
10220 +#define MCI_BLKR 0x0018
10221 +#define MCI_RSPR 0x0020
10222 +#define MCI_RSPR1 0x0024
10223 +#define MCI_RSPR2 0x0028
10224 +#define MCI_RSPR3 0x002c
10225 +#define MCI_RDR 0x0030
10226 +#define MCI_TDR 0x0034
10227 +#define MCI_SR 0x0040
10228 +#define MCI_IER 0x0044
10229 +#define MCI_IDR 0x0048
10230 +#define MCI_IMR 0x004c
10232 +/* Bitfields in CR */
10233 +#define MCI_MCIEN_OFFSET 0
10234 +#define MCI_MCIEN_SIZE 1
10235 +#define MCI_MCIDIS_OFFSET 1
10236 +#define MCI_MCIDIS_SIZE 1
10237 +#define MCI_PWSEN_OFFSET 2
10238 +#define MCI_PWSEN_SIZE 1
10239 +#define MCI_PWSDIS_OFFSET 3
10240 +#define MCI_PWSDIS_SIZE 1
10241 +#define MCI_SWRST_OFFSET 7
10242 +#define MCI_SWRST_SIZE 1
10244 +/* Bitfields in MR */
10245 +#define MCI_CLKDIV_OFFSET 0
10246 +#define MCI_CLKDIV_SIZE 8
10247 +#define MCI_PWSDIV_OFFSET 8
10248 +#define MCI_PWSDIV_SIZE 3
10249 +#define MCI_RDPROOF_OFFSET 11
10250 +#define MCI_RDPROOF_SIZE 1
10251 +#define MCI_WRPROOF_OFFSET 12
10252 +#define MCI_WRPROOF_SIZE 1
10253 +#define MCI_DMAPADV_OFFSET 14
10254 +#define MCI_DMAPADV_SIZE 1
10255 +#define MCI_BLKLEN_OFFSET 16
10256 +#define MCI_BLKLEN_SIZE 16
10258 +/* Bitfields in DTOR */
10259 +#define MCI_DTOCYC_OFFSET 0
10260 +#define MCI_DTOCYC_SIZE 4
10261 +#define MCI_DTOMUL_OFFSET 4
10262 +#define MCI_DTOMUL_SIZE 3
10264 +/* Bitfields in SDCR */
10265 +#define MCI_SDCSEL_OFFSET 0
10266 +#define MCI_SDCSEL_SIZE 4
10267 +#define MCI_SDCBUS_OFFSET 7
10268 +#define MCI_SDCBUS_SIZE 1
10270 +/* Bitfields in ARGR */
10271 +#define MCI_ARG_OFFSET 0
10272 +#define MCI_ARG_SIZE 32
10274 +/* Bitfields in CMDR */
10275 +#define MCI_CMDNB_OFFSET 0
10276 +#define MCI_CMDNB_SIZE 6
10277 +#define MCI_RSPTYP_OFFSET 6
10278 +#define MCI_RSPTYP_SIZE 2
10279 +#define MCI_SPCMD_OFFSET 8
10280 +#define MCI_SPCMD_SIZE 3
10281 +#define MCI_OPDCMD_OFFSET 11
10282 +#define MCI_OPDCMD_SIZE 1
10283 +#define MCI_MAXLAT_OFFSET 12
10284 +#define MCI_MAXLAT_SIZE 1
10285 +#define MCI_TRCMD_OFFSET 16
10286 +#define MCI_TRCMD_SIZE 2
10287 +#define MCI_TRDIR_OFFSET 18
10288 +#define MCI_TRDIR_SIZE 1
10289 +#define MCI_TRTYP_OFFSET 19
10290 +#define MCI_TRTYP_SIZE 2
10292 +/* Bitfields in BLKR */
10293 +#define MCI_BCNT_OFFSET 0
10294 +#define MCI_BCNT_SIZE 16
10296 +/* Bitfields in RSPRn */
10297 +#define MCI_RSP_OFFSET 0
10298 +#define MCI_RSP_SIZE 32
10300 +/* Bitfields in SR/IER/IDR/IMR */
10301 +#define MCI_CMDRDY_OFFSET 0
10302 +#define MCI_CMDRDY_SIZE 1
10303 +#define MCI_RXRDY_OFFSET 1
10304 +#define MCI_RXRDY_SIZE 1
10305 +#define MCI_TXRDY_OFFSET 2
10306 +#define MCI_TXRDY_SIZE 1
10307 +#define MCI_BLKE_OFFSET 3
10308 +#define MCI_BLKE_SIZE 1
10309 +#define MCI_DTIP_OFFSET 4
10310 +#define MCI_DTIP_SIZE 1
10311 +#define MCI_NOTBUSY_OFFSET 5
10312 +#define MCI_NOTBUSY_SIZE 1
10313 +#define MCI_ENDRX_OFFSET 6
10314 +#define MCI_ENDRX_SIZE 1
10315 +#define MCI_ENDTX_OFFSET 7
10316 +#define MCI_ENDTX_SIZE 1
10317 +#define MCI_RXBUFF_OFFSET 14
10318 +#define MCI_RXBUFF_SIZE 1
10319 +#define MCI_TXBUFE_OFFSET 15
10320 +#define MCI_TXBUFE_SIZE 1
10321 +#define MCI_RINDE_OFFSET 16
10322 +#define MCI_RINDE_SIZE 1
10323 +#define MCI_RDIRE_OFFSET 17
10324 +#define MCI_RDIRE_SIZE 1
10325 +#define MCI_RCRCE_OFFSET 18
10326 +#define MCI_RCRCE_SIZE 1
10327 +#define MCI_RENDE_OFFSET 19
10328 +#define MCI_RENDE_SIZE 1
10329 +#define MCI_RTOE_OFFSET 20
10330 +#define MCI_RTOE_SIZE 1
10331 +#define MCI_DCRCE_OFFSET 21
10332 +#define MCI_DCRCE_SIZE 1
10333 +#define MCI_DTOE_OFFSET 22
10334 +#define MCI_DTOE_SIZE 1
10335 +#define MCI_OVRE_OFFSET 30
10336 +#define MCI_OVRE_SIZE 1
10337 +#define MCI_UNRE_OFFSET 31
10338 +#define MCI_UNRE_SIZE 1
10340 +/* Constants for DTOMUL */
10341 +#define MCI_DTOMUL_1_CYCLE 0
10342 +#define MCI_DTOMUL_16_CYCLES 1
10343 +#define MCI_DTOMUL_128_CYCLES 2
10344 +#define MCI_DTOMUL_256_CYCLES 3
10345 +#define MCI_DTOMUL_1024_CYCLES 4
10346 +#define MCI_DTOMUL_4096_CYCLES 5
10347 +#define MCI_DTOMUL_65536_CYCLES 6
10348 +#define MCI_DTOMUL_1048576_CYCLES 7
10350 +/* Constants for RSPTYP */
10351 +#define MCI_RSPTYP_NO_RESP 0
10352 +#define MCI_RSPTYP_48_BIT 1
10353 +#define MCI_RSPTYP_136_BIT 2
10355 +/* Constants for SPCMD */
10356 +#define MCI_SPCMD_NO_SPEC_CMD 0
10357 +#define MCI_SPCMD_INIT_CMD 1
10358 +#define MCI_SPCMD_SYNC_CMD 2
10359 +#define MCI_SPCMD_INT_CMD 4
10360 +#define MCI_SPCMD_INT_RESP 5
10362 +/* Constants for TRCMD */
10363 +#define MCI_TRCMD_NO_TRANS 0
10364 +#define MCI_TRCMD_START_TRANS 1
10365 +#define MCI_TRCMD_STOP_TRANS 2
10367 +/* Constants for TRTYP */
10368 +#define MCI_TRTYP_BLOCK 0
10369 +#define MCI_TRTYP_MULTI_BLOCK 1
10370 +#define MCI_TRTYP_STREAM 2
10372 +/* Bit manipulation macros */
10373 +#define MCI_BIT(name) \
10374 + (1 << MCI_##name##_OFFSET)
10375 +#define MCI_BF(name,value) \
10376 + (((value) & ((1 << MCI_##name##_SIZE) - 1)) \
10377 + << MCI_##name##_OFFSET)
10378 +#define MCI_BFEXT(name,value) \
10379 + (((value) >> MCI_##name##_OFFSET) \
10380 + & ((1 << MCI_##name##_SIZE) - 1))
10381 +#define MCI_BFINS(name,value,old) \
10382 + (((old) & ~(((1 << MCI_##name##_SIZE) - 1) \
10383 + << MCI_##name##_OFFSET)) \
10384 + | MCI_BF(name,value))
10386 +/* Register access macros */
10387 +#define mci_readl(port,reg) \
10388 + __raw_readl((port)->regs + MCI_##reg)
10389 +#define mci_writel(port,reg,value) \
10390 + __raw_writel((value), (port)->regs + MCI_##reg)
10392 +#endif /* __DRIVERS_MMC_ATMEL_MCI_H__ */
10393 --- a/drivers/mmc/host/Kconfig
10394 +++ b/drivers/mmc/host/Kconfig
10399 +config MMC_ATMELMCI
10400 + tristate "Atmel Multimedia Card Interface support"
10401 + depends on AVR32 && MMC
10403 + This selects the Atmel Multimedia Card Interface. If you have
10404 + a AT91 (ARM) or AT32 (AVR32) platform with a Multimedia Card
10405 + slot, say Y or M here.
10407 + If unsure, say N.
10410 tristate "Motorola i.MX Multimedia Card Interface support"
10411 depends on ARCH_IMX
10412 --- a/drivers/mmc/host/Makefile
10413 +++ b/drivers/mmc/host/Makefile
10415 obj-$(CONFIG_MMC_AU1X) += au1xmmc.o
10416 obj-$(CONFIG_MMC_OMAP) += omap.o
10417 obj-$(CONFIG_MMC_AT91) += at91_mci.o
10418 +obj-$(CONFIG_MMC_ATMELMCI) += atmel-mci.o
10419 obj-$(CONFIG_MMC_TIFM_SD) += tifm_sd.o
10420 obj-$(CONFIG_MMC_SPI) += mmc_spi.o
10422 --- a/drivers/mtd/nand/at91_nand.c
10426 - * drivers/mtd/nand/at91_nand.c
10428 - * Copyright (C) 2003 Rick Bronson
10430 - * Derived from drivers/mtd/nand/autcpu12.c
10431 - * Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de)
10433 - * Derived from drivers/mtd/spia.c
10434 - * Copyright (C) 2000 Steven J. Hill (sjhill@cotw.com)
10436 - * This program is free software; you can redistribute it and/or modify
10437 - * it under the terms of the GNU General Public License version 2 as
10438 - * published by the Free Software Foundation.
10442 -#include <linux/slab.h>
10443 -#include <linux/module.h>
10444 -#include <linux/platform_device.h>
10445 -#include <linux/mtd/mtd.h>
10446 -#include <linux/mtd/nand.h>
10447 -#include <linux/mtd/partitions.h>
10449 -#include <asm/io.h>
10450 -#include <asm/sizes.h>
10452 -#include <asm/hardware.h>
10453 -#include <asm/arch/board.h>
10454 -#include <asm/arch/gpio.h>
10456 -struct at91_nand_host {
10457 - struct nand_chip nand_chip;
10458 - struct mtd_info mtd;
10459 - void __iomem *io_base;
10460 - struct at91_nand_data *board;
10464 - * Hardware specific access to control-lines
10466 -static void at91_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
10468 - struct nand_chip *nand_chip = mtd->priv;
10469 - struct at91_nand_host *host = nand_chip->priv;
10471 - if (cmd == NAND_CMD_NONE)
10474 - if (ctrl & NAND_CLE)
10475 - writeb(cmd, host->io_base + (1 << host->board->cle));
10477 - writeb(cmd, host->io_base + (1 << host->board->ale));
10481 - * Read the Device Ready pin.
10483 -static int at91_nand_device_ready(struct mtd_info *mtd)
10485 - struct nand_chip *nand_chip = mtd->priv;
10486 - struct at91_nand_host *host = nand_chip->priv;
10488 - return at91_get_gpio_value(host->board->rdy_pin);
10494 -static void at91_nand_enable(struct at91_nand_host *host)
10496 - if (host->board->enable_pin)
10497 - at91_set_gpio_value(host->board->enable_pin, 0);
10503 -static void at91_nand_disable(struct at91_nand_host *host)
10505 - if (host->board->enable_pin)
10506 - at91_set_gpio_value(host->board->enable_pin, 1);
10509 -#ifdef CONFIG_MTD_PARTITIONS
10510 -const char *part_probes[] = { "cmdlinepart", NULL };
10514 - * Probe for the NAND device.
10516 -static int __init at91_nand_probe(struct platform_device *pdev)
10518 - struct at91_nand_host *host;
10519 - struct mtd_info *mtd;
10520 - struct nand_chip *nand_chip;
10523 -#ifdef CONFIG_MTD_PARTITIONS
10524 - struct mtd_partition *partitions = NULL;
10525 - int num_partitions = 0;
10528 - /* Allocate memory for the device structure (and zero it) */
10529 - host = kzalloc(sizeof(struct at91_nand_host), GFP_KERNEL);
10531 - printk(KERN_ERR "at91_nand: failed to allocate device structure.\n");
10535 - host->io_base = ioremap(pdev->resource[0].start,
10536 - pdev->resource[0].end - pdev->resource[0].start + 1);
10537 - if (host->io_base == NULL) {
10538 - printk(KERN_ERR "at91_nand: ioremap failed\n");
10543 - mtd = &host->mtd;
10544 - nand_chip = &host->nand_chip;
10545 - host->board = pdev->dev.platform_data;
10547 - nand_chip->priv = host; /* link the private data structures */
10548 - mtd->priv = nand_chip;
10549 - mtd->owner = THIS_MODULE;
10551 - /* Set address of NAND IO lines */
10552 - nand_chip->IO_ADDR_R = host->io_base;
10553 - nand_chip->IO_ADDR_W = host->io_base;
10554 - nand_chip->cmd_ctrl = at91_nand_cmd_ctrl;
10556 - if (host->board->rdy_pin)
10557 - nand_chip->dev_ready = at91_nand_device_ready;
10559 - nand_chip->ecc.mode = NAND_ECC_SOFT; /* enable ECC */
10560 - nand_chip->chip_delay = 20; /* 20us command delay time */
10562 - if (host->board->bus_width_16) /* 16-bit bus width */
10563 - nand_chip->options |= NAND_BUSWIDTH_16;
10565 - platform_set_drvdata(pdev, host);
10566 - at91_nand_enable(host);
10568 - if (host->board->det_pin) {
10569 - if (at91_get_gpio_value(host->board->det_pin)) {
10570 - printk ("No SmartMedia card inserted.\n");
10576 - /* Scan to find existance of the device */
10577 - if (nand_scan(mtd, 1)) {
10582 -#ifdef CONFIG_MTD_PARTITIONS
10583 -#ifdef CONFIG_MTD_CMDLINE_PARTS
10584 - mtd->name = "at91_nand";
10585 - num_partitions = parse_mtd_partitions(mtd, part_probes,
10588 - if (num_partitions <= 0 && host->board->partition_info)
10589 - partitions = host->board->partition_info(mtd->size,
10590 - &num_partitions);
10592 - if ((!partitions) || (num_partitions == 0)) {
10593 - printk(KERN_ERR "at91_nand: No parititions defined, or unsupported device.\n");
10598 - res = add_mtd_partitions(mtd, partitions, num_partitions);
10600 - res = add_mtd_device(mtd);
10607 - nand_release(mtd);
10609 - at91_nand_disable(host);
10610 - platform_set_drvdata(pdev, NULL);
10611 - iounmap(host->io_base);
10617 - * Remove a NAND device.
10619 -static int __devexit at91_nand_remove(struct platform_device *pdev)
10621 - struct at91_nand_host *host = platform_get_drvdata(pdev);
10622 - struct mtd_info *mtd = &host->mtd;
10624 - nand_release(mtd);
10626 - at91_nand_disable(host);
10628 - iounmap(host->io_base);
10634 -static struct platform_driver at91_nand_driver = {
10635 - .probe = at91_nand_probe,
10636 - .remove = at91_nand_remove,
10638 - .name = "at91_nand",
10639 - .owner = THIS_MODULE,
10643 -static int __init at91_nand_init(void)
10645 - return platform_driver_register(&at91_nand_driver);
10649 -static void __exit at91_nand_exit(void)
10651 - platform_driver_unregister(&at91_nand_driver);
10655 -module_init(at91_nand_init);
10656 -module_exit(at91_nand_exit);
10658 -MODULE_LICENSE("GPL");
10659 -MODULE_AUTHOR("Rick Bronson");
10660 -MODULE_DESCRIPTION("NAND/SmartMedia driver for AT91RM9200");
10662 +++ b/drivers/mtd/nand/atmel_nand.c
10665 + * Copyright (C) 2003 Rick Bronson
10667 + * Derived from drivers/mtd/nand/autcpu12.c
10668 + * Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de)
10670 + * Derived from drivers/mtd/spia.c
10671 + * Copyright (C) 2000 Steven J. Hill (sjhill@cotw.com)
10674 + * Add Hardware ECC support for AT91SAM9260 / AT91SAM9263
10675 + * Richard Genoud (richard.genoud@gmail.com), Adeneo Copyright (C) 2007
10677 + * Derived from Das U-Boot source code
10678 + * (u-boot-1.1.5/board/atmel/at91sam9263ek/nand.c)
10679 + * (C) Copyright 2006 ATMEL Rousset, Lacressonniere Nicolas
10682 + * This program is free software; you can redistribute it and/or modify
10683 + * it under the terms of the GNU General Public License version 2 as
10684 + * published by the Free Software Foundation.
10688 +#include <linux/slab.h>
10689 +#include <linux/module.h>
10690 +#include <linux/platform_device.h>
10691 +#include <linux/mtd/mtd.h>
10692 +#include <linux/mtd/nand.h>
10693 +#include <linux/mtd/partitions.h>
10695 +#include <linux/gpio.h>
10696 +#include <linux/io.h>
10698 +#include <asm/arch/board.h>
10699 +#include <asm/arch/cpu.h>
10701 +#ifdef CONFIG_MTD_NAND_ATMEL_ECC_HW
10702 +#define hard_ecc 1
10704 +#define hard_ecc 0
10707 +#ifdef CONFIG_MTD_NAND_ATMEL_ECC_NONE
10713 +/* Register access macros */
10714 +#define ecc_readl(add, reg) \
10715 + __raw_readl(add + ATMEL_ECC_##reg)
10716 +#define ecc_writel(add, reg, value) \
10717 + __raw_writel((value), add + ATMEL_ECC_##reg)
10719 +#include "atmel_nand_ecc.h" /* Hardware ECC registers */
10721 +/* oob layout for large page size
10722 + * bad block info is on bytes 0 and 1
10723 + * the bytes have to be consecutives to avoid
10724 + * several NAND_CMD_RNDOUT during read
10726 +static struct nand_ecclayout atmel_oobinfo_large = {
10728 + .eccpos = {60, 61, 62, 63},
10734 +/* oob layout for small page size
10735 + * bad block info is on bytes 4 and 5
10736 + * the bytes have to be consecutives to avoid
10737 + * several NAND_CMD_RNDOUT during read
10739 +static struct nand_ecclayout atmel_oobinfo_small = {
10741 + .eccpos = {0, 1, 2, 3},
10747 +struct atmel_nand_host {
10748 + struct nand_chip nand_chip;
10749 + struct mtd_info mtd;
10750 + void __iomem *io_base;
10751 + struct atmel_nand_data *board;
10752 + struct device *dev;
10753 + void __iomem *ecc;
10759 +static void atmel_nand_enable(struct atmel_nand_host *host)
10761 + if (host->board->enable_pin)
10762 + gpio_set_value(host->board->enable_pin, 0);
10768 +static void atmel_nand_disable(struct atmel_nand_host *host)
10770 + if (host->board->enable_pin)
10771 + gpio_set_value(host->board->enable_pin, 1);
10775 + * Hardware specific access to control-lines
10777 +static void atmel_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
10779 + struct nand_chip *nand_chip = mtd->priv;
10780 + struct atmel_nand_host *host = nand_chip->priv;
10782 + if (ctrl & NAND_CTRL_CHANGE) {
10783 + if (ctrl & NAND_NCE)
10784 + atmel_nand_enable(host);
10786 + atmel_nand_disable(host);
10788 + if (cmd == NAND_CMD_NONE)
10791 + if (ctrl & NAND_CLE)
10792 + writeb(cmd, host->io_base + (1 << host->board->cle));
10794 + writeb(cmd, host->io_base + (1 << host->board->ale));
10798 + * Read the Device Ready pin.
10800 +static int atmel_nand_device_ready(struct mtd_info *mtd)
10802 + struct nand_chip *nand_chip = mtd->priv;
10803 + struct atmel_nand_host *host = nand_chip->priv;
10805 + return gpio_get_value(host->board->rdy_pin);
10809 + * Minimal-overhead PIO for data access.
10811 +static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len)
10813 + struct nand_chip *nand_chip = mtd->priv;
10815 + __raw_readsb(nand_chip->IO_ADDR_R, buf, len);
10818 +static void atmel_read_buf16(struct mtd_info *mtd, u8 *buf, int len)
10820 + struct nand_chip *nand_chip = mtd->priv;
10822 + __raw_readsw(nand_chip->IO_ADDR_R, buf, len / 2);
10825 +static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
10827 + struct nand_chip *nand_chip = mtd->priv;
10829 + __raw_writesb(nand_chip->IO_ADDR_W, buf, len);
10832 +static void atmel_write_buf16(struct mtd_info *mtd, const u8 *buf, int len)
10834 + struct nand_chip *nand_chip = mtd->priv;
10836 + __raw_writesw(nand_chip->IO_ADDR_W, buf, len / 2);
10840 + * write oob for small pages
10842 +static int atmel_nand_write_oob_512(struct mtd_info *mtd,
10843 + struct nand_chip *chip, int page)
10845 + int chunk = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad;
10846 + int eccsize = chip->ecc.size, length = mtd->oobsize;
10847 + int len, pos, status = 0;
10848 + const uint8_t *bufpoi = chip->oob_poi;
10850 + pos = eccsize + chunk;
10852 + chip->cmdfunc(mtd, NAND_CMD_SEQIN, pos, page);
10853 + len = min_t(int, length, chunk);
10854 + chip->write_buf(mtd, bufpoi, len);
10858 + chip->write_buf(mtd, bufpoi, length);
10860 + chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1);
10861 + status = chip->waitfunc(mtd, chip);
10863 + return status & NAND_STATUS_FAIL ? -EIO : 0;
10868 + * read oob for small pages
10870 +static int atmel_nand_read_oob_512(struct mtd_info *mtd,
10871 + struct nand_chip *chip, int page, int sndcmd)
10874 + chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
10877 + chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
10882 + * Calculate HW ECC
10884 + * function called after a write
10886 + * mtd: MTD block structure
10887 + * dat: raw data (unused)
10888 + * ecc_code: buffer for ECC
10890 +static int atmel_nand_calculate(struct mtd_info *mtd,
10891 + const u_char *dat, unsigned char *ecc_code)
10893 + struct nand_chip *nand_chip = mtd->priv;
10894 + struct atmel_nand_host *host = nand_chip->priv;
10895 + uint32_t *eccpos = nand_chip->ecc.layout->eccpos;
10896 + unsigned int ecc_value;
10898 + /* get the first 2 ECC bytes */
10899 + ecc_value = ecc_readl(host->ecc, PR);
10901 + ecc_code[eccpos[0]] = ecc_value & 0xFF;
10902 + ecc_code[eccpos[1]] = (ecc_value >> 8) & 0xFF;
10904 + /* get the last 2 ECC bytes */
10905 + ecc_value = ecc_readl(host->ecc, NPR) & ATMEL_ECC_NPARITY;
10907 + ecc_code[eccpos[2]] = ecc_value & 0xFF;
10908 + ecc_code[eccpos[3]] = (ecc_value >> 8) & 0xFF;
10914 + * HW ECC read page function
10916 + * mtd: mtd info structure
10917 + * chip: nand chip info structure
10918 + * buf: buffer to store read data
10920 +static int atmel_nand_read_page(struct mtd_info *mtd,
10921 + struct nand_chip *chip, uint8_t *buf)
10923 + int eccsize = chip->ecc.size;
10924 + int eccbytes = chip->ecc.bytes;
10925 + uint32_t *eccpos = chip->ecc.layout->eccpos;
10926 + uint8_t *p = buf;
10927 + uint8_t *oob = chip->oob_poi;
10928 + uint8_t *ecc_pos;
10932 + * Errata: ALE is incorrectly wired up to the ECC controller
10933 + * on the AP7000, so it will include the address cycles in the
10934 + * ECC calculation.
10936 + * Workaround: Reset the parity registers before reading the
10939 + if (cpu_is_at32ap7000()) {
10940 + struct atmel_nand_host *host = chip->priv;
10941 + ecc_writel(host->ecc, CR, ATMEL_ECC_RST);
10944 + /* read the page */
10945 + chip->read_buf(mtd, p, eccsize);
10947 + /* move to ECC position if needed */
10948 + if (eccpos[0] != 0) {
10949 + /* This only works on large pages
10950 + * because the ECC controller waits for
10951 + * NAND_CMD_RNDOUTSTART after the
10952 + * NAND_CMD_RNDOUT.
10953 + * anyway, for small pages, the eccpos[0] == 0
10955 + chip->cmdfunc(mtd, NAND_CMD_RNDOUT,
10956 + mtd->writesize + eccpos[0], -1);
10959 + /* the ECC controller needs to read the ECC just after the data */
10960 + ecc_pos = oob + eccpos[0];
10961 + chip->read_buf(mtd, ecc_pos, eccbytes);
10963 + /* check if there's an error */
10964 + stat = chip->ecc.correct(mtd, p, oob, NULL);
10967 + mtd->ecc_stats.failed++;
10969 + mtd->ecc_stats.corrected += stat;
10971 + /* get back to oob start (end of page) */
10972 + chip->cmdfunc(mtd, NAND_CMD_RNDOUT, mtd->writesize, -1);
10974 + /* read the oob */
10975 + chip->read_buf(mtd, oob, mtd->oobsize);
10981 + * HW ECC Correction
10983 + * function called after a read
10985 + * mtd: MTD block structure
10986 + * dat: raw data read from the chip
10987 + * read_ecc: ECC from the chip (unused)
10990 + * Detect and correct a 1 bit error for a page
10992 +static int atmel_nand_correct(struct mtd_info *mtd, u_char *dat,
10993 + u_char *read_ecc, u_char *isnull)
10995 + struct nand_chip *nand_chip = mtd->priv;
10996 + struct atmel_nand_host *host = nand_chip->priv;
10997 + unsigned int ecc_status;
10998 + unsigned int ecc_word, ecc_bit;
11000 + /* get the status from the Status Register */
11001 + ecc_status = ecc_readl(host->ecc, SR);
11003 + /* if there's no error */
11004 + if (likely(!(ecc_status & ATMEL_ECC_RECERR)))
11007 + /* get error bit offset (4 bits) */
11008 + ecc_bit = ecc_readl(host->ecc, PR) & ATMEL_ECC_BITADDR;
11009 + /* get word address (12 bits) */
11010 + ecc_word = ecc_readl(host->ecc, PR) & ATMEL_ECC_WORDADDR;
11013 + /* if there are multiple errors */
11014 + if (ecc_status & ATMEL_ECC_MULERR) {
11015 + /* check if it is a freshly erased block
11016 + * (filled with 0xff) */
11017 + if ((ecc_bit == ATMEL_ECC_BITADDR)
11018 + && (ecc_word == (ATMEL_ECC_WORDADDR >> 4))) {
11019 + /* the block has just been erased, return OK */
11022 + /* it doesn't seems to be a freshly
11024 + * We can't correct so many errors */
11025 + dev_dbg(host->dev, "atmel_nand : multiple errors detected."
11026 + " Unable to correct.\n");
11030 + /* if there's a single bit error : we can correct it */
11031 + if (ecc_status & ATMEL_ECC_ECCERR) {
11032 + /* there's nothing much to do here.
11033 + * the bit error is on the ECC itself.
11035 + dev_dbg(host->dev, "atmel_nand : one bit error on ECC code."
11036 + " Nothing to correct\n");
11040 + dev_dbg(host->dev, "atmel_nand : one bit error on data."
11041 + " (word offset in the page :"
11042 + " 0x%x bit offset : 0x%x)\n",
11043 + ecc_word, ecc_bit);
11044 + /* correct the error */
11045 + if (nand_chip->options & NAND_BUSWIDTH_16) {
11046 + /* 16 bits words */
11047 + ((unsigned short *) dat)[ecc_word] ^= (1 << ecc_bit);
11049 + /* 8 bits words */
11050 + dat[ecc_word] ^= (1 << ecc_bit);
11052 + dev_dbg(host->dev, "atmel_nand : error corrected\n");
11057 + * Enable HW ECC : unused on most chips
11059 +static void atmel_nand_hwctl(struct mtd_info *mtd, int mode)
11061 + if (cpu_is_at32ap7000()) {
11062 + struct nand_chip *nand_chip = mtd->priv;
11063 + struct atmel_nand_host *host = nand_chip->priv;
11064 + ecc_writel(host->ecc, CR, ATMEL_ECC_RST);
11068 +#ifdef CONFIG_MTD_PARTITIONS
11069 +static const char *part_probes[] = { "cmdlinepart", NULL };
11073 + * Probe for the NAND device.
11075 +static int __init atmel_nand_probe(struct platform_device *pdev)
11077 + struct atmel_nand_host *host;
11078 + struct mtd_info *mtd;
11079 + struct nand_chip *nand_chip;
11080 + struct resource *regs;
11081 + struct resource *mem;
11084 +#ifdef CONFIG_MTD_PARTITIONS
11085 + struct mtd_partition *partitions = NULL;
11086 + int num_partitions = 0;
11089 + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
11091 + printk(KERN_ERR "atmel_nand: can't get I/O resource mem\n");
11095 + /* Allocate memory for the device structure (and zero it) */
11096 + host = kzalloc(sizeof(struct atmel_nand_host), GFP_KERNEL);
11098 + printk(KERN_ERR "atmel_nand: failed to allocate device structure.\n");
11102 + host->io_base = ioremap(mem->start, mem->end - mem->start + 1);
11103 + if (host->io_base == NULL) {
11104 + printk(KERN_ERR "atmel_nand: ioremap failed\n");
11106 + goto err_nand_ioremap;
11109 + mtd = &host->mtd;
11110 + nand_chip = &host->nand_chip;
11111 + host->board = pdev->dev.platform_data;
11112 + host->dev = &pdev->dev;
11114 + nand_chip->priv = host; /* link the private data structures */
11115 + mtd->priv = nand_chip;
11116 + mtd->owner = THIS_MODULE;
11118 + /* Set address of NAND IO lines */
11119 + nand_chip->IO_ADDR_R = host->io_base;
11120 + nand_chip->IO_ADDR_W = host->io_base;
11121 + nand_chip->cmd_ctrl = atmel_nand_cmd_ctrl;
11123 + if (host->board->rdy_pin)
11124 + nand_chip->dev_ready = atmel_nand_device_ready;
11126 + regs = platform_get_resource(pdev, IORESOURCE_MEM, 1);
11127 + if (!regs && hard_ecc) {
11128 + printk(KERN_ERR "atmel_nand: can't get I/O resource "
11129 + "regs\nFalling back on software ECC\n");
11132 + nand_chip->ecc.mode = NAND_ECC_SOFT; /* enable ECC */
11134 + nand_chip->ecc.mode = NAND_ECC_NONE;
11135 + if (hard_ecc && regs) {
11136 + host->ecc = ioremap(regs->start, regs->end - regs->start + 1);
11137 + if (host->ecc == NULL) {
11138 + printk(KERN_ERR "atmel_nand: ioremap failed\n");
11140 + goto err_ecc_ioremap;
11142 + nand_chip->ecc.mode = NAND_ECC_HW_SYNDROME;
11143 + nand_chip->ecc.calculate = atmel_nand_calculate;
11144 + nand_chip->ecc.correct = atmel_nand_correct;
11145 + nand_chip->ecc.hwctl = atmel_nand_hwctl;
11146 + nand_chip->ecc.read_page = atmel_nand_read_page;
11147 + nand_chip->ecc.bytes = 4;
11148 + nand_chip->ecc.prepad = 0;
11149 + nand_chip->ecc.postpad = 0;
11152 + nand_chip->chip_delay = 20; /* 20us command delay time */
11154 + if (host->board->bus_width_16) { /* 16-bit bus width */
11155 + nand_chip->options |= NAND_BUSWIDTH_16;
11156 + nand_chip->read_buf = atmel_read_buf16;
11157 + nand_chip->write_buf = atmel_write_buf16;
11159 + nand_chip->read_buf = atmel_read_buf;
11160 + nand_chip->write_buf = atmel_write_buf;
11163 + platform_set_drvdata(pdev, host);
11164 + atmel_nand_enable(host);
11166 + if (host->board->det_pin) {
11167 + if (gpio_get_value(host->board->det_pin)) {
11168 + printk("No SmartMedia card inserted.\n");
11170 + goto err_no_card;
11174 + /* first scan to find the device and get the page size */
11175 + if (nand_scan_ident(mtd, 1)) {
11177 + goto err_scan_ident;
11180 + if (nand_chip->ecc.mode == NAND_ECC_HW_SYNDROME) {
11181 + /* ECC is calculated for the whole page (1 step) */
11182 + nand_chip->ecc.size = mtd->writesize;
11184 + /* set ECC page size and oob layout */
11185 + switch (mtd->writesize) {
11187 + nand_chip->ecc.layout = &atmel_oobinfo_small;
11188 + nand_chip->ecc.read_oob = atmel_nand_read_oob_512;
11189 + nand_chip->ecc.write_oob = atmel_nand_write_oob_512;
11190 + ecc_writel(host->ecc, MR, ATMEL_ECC_PAGESIZE_528);
11193 + nand_chip->ecc.layout = &atmel_oobinfo_large;
11194 + ecc_writel(host->ecc, MR, ATMEL_ECC_PAGESIZE_1056);
11197 + nand_chip->ecc.layout = &atmel_oobinfo_large;
11198 + ecc_writel(host->ecc, MR, ATMEL_ECC_PAGESIZE_2112);
11201 + nand_chip->ecc.layout = &atmel_oobinfo_large;
11202 + ecc_writel(host->ecc, MR, ATMEL_ECC_PAGESIZE_4224);
11205 + /* page size not handled by HW ECC */
11206 + /* switching back to soft ECC */
11207 + nand_chip->ecc.mode = NAND_ECC_SOFT;
11208 + nand_chip->ecc.calculate = NULL;
11209 + nand_chip->ecc.correct = NULL;
11210 + nand_chip->ecc.hwctl = NULL;
11211 + nand_chip->ecc.read_page = NULL;
11212 + nand_chip->ecc.postpad = 0;
11213 + nand_chip->ecc.prepad = 0;
11214 + nand_chip->ecc.bytes = 0;
11219 + /* second phase scan */
11220 + if (nand_scan_tail(mtd)) {
11222 + goto err_scan_tail;
11225 +#ifdef CONFIG_MTD_PARTITIONS
11226 +#ifdef CONFIG_MTD_CMDLINE_PARTS
11227 + mtd->name = "atmel_nand";
11228 + num_partitions = parse_mtd_partitions(mtd, part_probes,
11231 + if (num_partitions <= 0 && host->board->partition_info)
11232 + partitions = host->board->partition_info(mtd->size,
11233 + &num_partitions);
11235 + if ((!partitions) || (num_partitions == 0)) {
11236 + printk(KERN_ERR "atmel_nand: No parititions defined, or unsupported device.\n");
11238 + goto err_no_partitions;
11241 + res = add_mtd_partitions(mtd, partitions, num_partitions);
11243 + res = add_mtd_device(mtd);
11249 +#ifdef CONFIG_MTD_PARTITIONS
11250 +err_no_partitions:
11252 + nand_release(mtd);
11256 + atmel_nand_disable(host);
11257 + platform_set_drvdata(pdev, NULL);
11259 + iounmap(host->ecc);
11261 + iounmap(host->io_base);
11268 + * Remove a NAND device.
11270 +static int __exit atmel_nand_remove(struct platform_device *pdev)
11272 + struct atmel_nand_host *host = platform_get_drvdata(pdev);
11273 + struct mtd_info *mtd = &host->mtd;
11275 + nand_release(mtd);
11277 + atmel_nand_disable(host);
11280 + iounmap(host->ecc);
11281 + iounmap(host->io_base);
11287 +static struct platform_driver atmel_nand_driver = {
11288 + .remove = __exit_p(atmel_nand_remove),
11290 + .name = "atmel_nand",
11291 + .owner = THIS_MODULE,
11295 +static int __init atmel_nand_init(void)
11297 + return platform_driver_probe(&atmel_nand_driver, atmel_nand_probe);
11301 +static void __exit atmel_nand_exit(void)
11303 + platform_driver_unregister(&atmel_nand_driver);
11307 +module_init(atmel_nand_init);
11308 +module_exit(atmel_nand_exit);
11310 +MODULE_LICENSE("GPL");
11311 +MODULE_AUTHOR("Rick Bronson");
11312 +MODULE_DESCRIPTION("NAND/SmartMedia driver for AT91 / AVR32");
11313 +MODULE_ALIAS("platform:atmel_nand");
11315 +++ b/drivers/mtd/nand/atmel_nand_ecc.h
11318 + * Error Corrected Code Controller (ECC) - System peripherals regsters.
11319 + * Based on AT91SAM9260 datasheet revision B.
11321 + * This program is free software; you can redistribute it and/or modify it
11322 + * under the terms of the GNU General Public License as published by the
11323 + * Free Software Foundation; either version 2 of the License, or (at your
11324 + * option) any later version.
11327 +#ifndef ATMEL_NAND_ECC_H
11328 +#define ATMEL_NAND_ECC_H
11330 +#define ATMEL_ECC_CR 0x00 /* Control register */
11331 +#define ATMEL_ECC_RST (1 << 0) /* Reset parity */
11333 +#define ATMEL_ECC_MR 0x04 /* Mode register */
11334 +#define ATMEL_ECC_PAGESIZE (3 << 0) /* Page Size */
11335 +#define ATMEL_ECC_PAGESIZE_528 (0)
11336 +#define ATMEL_ECC_PAGESIZE_1056 (1)
11337 +#define ATMEL_ECC_PAGESIZE_2112 (2)
11338 +#define ATMEL_ECC_PAGESIZE_4224 (3)
11340 +#define ATMEL_ECC_SR 0x08 /* Status register */
11341 +#define ATMEL_ECC_RECERR (1 << 0) /* Recoverable Error */
11342 +#define ATMEL_ECC_ECCERR (1 << 1) /* ECC Single Bit Error */
11343 +#define ATMEL_ECC_MULERR (1 << 2) /* Multiple Errors */
11345 +#define ATMEL_ECC_PR 0x0c /* Parity register */
11346 +#define ATMEL_ECC_BITADDR (0xf << 0) /* Bit Error Address */
11347 +#define ATMEL_ECC_WORDADDR (0xfff << 4) /* Word Error Address */
11349 +#define ATMEL_ECC_NPR 0x10 /* NParity register */
11350 +#define ATMEL_ECC_NPARITY (0xffff << 0) /* NParity */
11353 --- a/drivers/mtd/nand/bf5xx_nand.c
11354 +++ b/drivers/mtd/nand/bf5xx_nand.c
11355 @@ -803,3 +803,4 @@
11356 MODULE_LICENSE("GPL");
11357 MODULE_AUTHOR(DRV_AUTHOR);
11358 MODULE_DESCRIPTION(DRV_DESC);
11359 +MODULE_ALIAS("platform:" DRV_NAME);
11360 --- a/drivers/mtd/nand/Kconfig
11361 +++ b/drivers/mtd/nand/Kconfig
11362 @@ -272,12 +272,54 @@
11364 If you say "m", the module will be called "cs553x_nand.ko".
11366 -config MTD_NAND_AT91
11367 - bool "Support for NAND Flash / SmartMedia on AT91"
11368 - depends on ARCH_AT91
11369 +config MTD_NAND_ATMEL
11370 + bool "Support for NAND Flash / SmartMedia on AT91 and AVR32"
11371 + depends on ARCH_AT91 || AVR32
11373 Enables support for NAND Flash / Smart Media Card interface
11374 - on Atmel AT91 processors.
11375 + on Atmel AT91 and AVR32 processors.
11377 + prompt "ECC management for NAND Flash / SmartMedia on AT91 / AVR32"
11378 + depends on MTD_NAND_ATMEL
11380 +config MTD_NAND_ATMEL_ECC_HW
11381 + bool "Hardware ECC"
11382 + depends on ARCH_AT91SAM9263 || ARCH_AT91SAM9260 || AVR32
11384 + Use hardware ECC instead of software ECC when the chip
11387 + The hardware ECC controller is capable of single bit error
11388 + correction and 2-bit random detection per page.
11390 + NB : hardware and software ECC schemes are incompatible.
11391 + If you switch from one to another, you'll have to erase your
11396 +config MTD_NAND_ATMEL_ECC_SOFT
11397 + bool "Software ECC"
11399 + Use software ECC.
11401 + NB : hardware and software ECC schemes are incompatible.
11402 + If you switch from one to another, you'll have to erase your
11405 +config MTD_NAND_ATMEL_ECC_NONE
11406 + bool "No ECC (testing only, DANGEROUS)"
11407 + depends on DEBUG_KERNEL
11409 + No ECC will be used.
11410 + It's not a good idea and it should be reserved for testing
11419 config MTD_NAND_CM_X270
11420 tristate "Support for NAND Flash on CM-X270 modules"
11421 --- a/drivers/mtd/nand/Makefile
11422 +++ b/drivers/mtd/nand/Makefile
11424 obj-$(CONFIG_MTD_NAND_NANDSIM) += nandsim.o
11425 obj-$(CONFIG_MTD_NAND_CS553X) += cs553x_nand.o
11426 obj-$(CONFIG_MTD_NAND_NDFC) += ndfc.o
11427 -obj-$(CONFIG_MTD_NAND_AT91) += at91_nand.o
11428 +obj-$(CONFIG_MTD_NAND_ATMEL) += atmel_nand.o
11429 obj-$(CONFIG_MTD_NAND_CM_X270) += cmx270_nand.o
11430 obj-$(CONFIG_MTD_NAND_BASLER_EXCITE) += excite_nandflash.o
11431 obj-$(CONFIG_MTD_NAND_PLATFORM) += plat_nand.o
11432 --- a/drivers/mtd/nand/ndfc.c
11433 +++ b/drivers/mtd/nand/ndfc.c
11434 @@ -317,3 +317,5 @@
11435 MODULE_LICENSE("GPL");
11436 MODULE_AUTHOR("Thomas Gleixner <tglx@linutronix.de>");
11437 MODULE_DESCRIPTION("Platform driver for NDFC");
11438 +MODULE_ALIAS("platform:ndfc-chip");
11439 +MODULE_ALIAS("platform:ndfc-nand");
11440 --- a/drivers/mtd/nand/orion_nand.c
11441 +++ b/drivers/mtd/nand/orion_nand.c
11442 @@ -169,3 +169,4 @@
11443 MODULE_LICENSE("GPL");
11444 MODULE_AUTHOR("Tzachi Perelstein");
11445 MODULE_DESCRIPTION("NAND glue for Orion platforms");
11446 +MODULE_ALIAS("platform:orion_nand");
11447 --- a/drivers/mtd/nand/plat_nand.c
11448 +++ b/drivers/mtd/nand/plat_nand.c
11449 @@ -161,3 +161,4 @@
11450 MODULE_LICENSE("GPL");
11451 MODULE_AUTHOR("Vitaly Wool");
11452 MODULE_DESCRIPTION("Simple generic NAND driver");
11453 +MODULE_ALIAS("platform:gen_nand");
11454 --- a/drivers/mtd/nand/s3c2410.c
11455 +++ b/drivers/mtd/nand/s3c2410.c
11456 @@ -927,3 +927,6 @@
11457 MODULE_LICENSE("GPL");
11458 MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
11459 MODULE_DESCRIPTION("S3C24XX MTD NAND driver");
11460 +MODULE_ALIAS("platform:s3c2410-nand");
11461 +MODULE_ALIAS("platform:s3c2412-nand");
11462 +MODULE_ALIAS("platform:s3c2440-nand");
11463 --- a/drivers/net/macb.c
11464 +++ b/drivers/net/macb.c
11465 @@ -1277,8 +1277,45 @@
11470 +static int macb_suspend(struct platform_device *pdev, pm_message_t state)
11472 + struct net_device *netdev = platform_get_drvdata(pdev);
11473 + struct macb *bp = netdev_priv(netdev);
11475 + netif_device_detach(netdev);
11477 +#ifndef CONFIG_ARCH_AT91
11478 + clk_disable(bp->hclk);
11480 + clk_disable(bp->pclk);
11485 +static int macb_resume(struct platform_device *pdev)
11487 + struct net_device *netdev = platform_get_drvdata(pdev);
11488 + struct macb *bp = netdev_priv(netdev);
11490 + clk_enable(bp->pclk);
11491 +#ifndef CONFIG_ARCH_AT91
11492 + clk_enable(bp->hclk);
11495 + netif_device_attach(netdev);
11500 +#define macb_suspend NULL
11501 +#define macb_resume NULL
11504 static struct platform_driver macb_driver = {
11505 .remove = __exit_p(macb_remove),
11506 + .suspend = macb_suspend,
11507 + .resume = macb_resume,
11511 --- a/drivers/parport/Kconfig
11512 +++ b/drivers/parport/Kconfig
11515 tristate "PC-style hardware"
11516 depends on (!SPARC64 || PCI) && !SPARC32 && !M32R && !FRV && \
11517 - (!M68K || ISA) && !MN10300
11518 + (!M68K || ISA) && !MN10300 && !AVR32
11520 You should say Y here if you have a PC-style parallel port. All
11521 IBM PC compatible computers and some Alphas have PC-style
11523 +++ b/drivers/pcmcia/at32_cf.c
11526 + * Driver for AVR32 Static Memory Controller: CompactFlash support
11528 + * Copyright (C) 2006 Atmel Norway
11530 + * This program is free software; you can redistribute it and/or
11531 + * modify it under the terms of the GNU General Public License as
11532 + * published by the Free Software Foundation; either version 2 of the
11533 + * License, or (at your option) any later version.
11535 + * This program is distributed in the hope that it will be useful, but
11536 + * WITHOUT ANY WARRANTY; without even the implied warranty of
11537 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11538 + * General Public License for more details.
11540 + * You should have received a copy of the GNU General Public License
11541 + * along with this program; if not, write to the Free Software
11542 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
11543 + * 02111-1307, USA.
11545 + * The full GNU General Public License is included in this
11546 + * distribution in the file called COPYING.
11548 +#include <linux/module.h>
11549 +#include <linux/kernel.h>
11550 +#include <linux/platform_device.h>
11551 +#include <linux/init.h>
11552 +#include <linux/device.h>
11553 +#include <linux/delay.h>
11554 +#include <linux/interrupt.h>
11555 +#include <linux/err.h>
11556 +#include <linux/clk.h>
11557 +#include <linux/dma-mapping.h>
11559 +#include <pcmcia/ss.h>
11561 +#include <asm/gpio.h>
11562 +#include <asm/io.h>
11563 +#include <asm/arch/board.h>
11565 +#include <asm/arch/smc.h>
11567 +struct at32_cf_socket {
11568 + struct pcmcia_socket socket;
11573 + struct resource res_attr;
11574 + struct resource res_mem;
11575 + struct resource res_io;
11576 + struct smc_config smc;
11577 + unsigned int irq;
11578 + unsigned int cf_cs;
11579 + socket_state_t state;
11580 + unsigned present:1;
11582 +#define to_at32_cf(sock) container_of(sock, struct at32_cf_socket, socket)
11585 + * We have the following memory layout relative to the base address:
11587 + * Alt IDE Mode: 00e0 0000 -> 00ff ffff
11588 + * True IDE Mode: 00c0 0000 -> 00df ffff
11589 + * I/O memory: 0080 0000 -> 00bf ffff
11590 + * Common memory: 0040 0000 -> 007f ffff
11591 + * Attribute memory: 0000 0000 -> 003f ffff
11593 +#define CF_ATTR_OFFSET 0x00000000
11594 +#define CF_MEM_OFFSET 0x00400000
11595 +#define CF_IO_OFFSET 0x00800000
11596 +#define CF_RES_SIZE 4096
11600 +static int pc_debug;
11601 +module_param(pc_debug, int, 0644);
11603 +static void at32_cf_debug(struct at32_cf_socket *cf, const char *func,
11604 + int level, const char *fmt, ...)
11608 + if (pc_debug > level) {
11609 + printk(KERN_DEBUG "at32_cf/%u: %s: ", cf->cf_cs, func);
11610 + va_start(args, fmt);
11611 + vprintk(fmt, args);
11616 +#define debug(cf, lvl, fmt, arg...) \
11617 + at32_cf_debug(cf, __func__, lvl, fmt, ##arg)
11620 +#define debug(cf, lvl, fmt, arg...) do { } while (0)
11623 +static inline int at32_cf_present(struct at32_cf_socket *cf)
11627 + /* If we don't have a detect pin, assume the card is present */
11628 + if (cf->detect_pin >= 0)
11629 + present = !gpio_get_value(cf->detect_pin);
11634 +static irqreturn_t at32_cf_irq(int irq, void *dev_id)
11636 + struct at32_cf_socket *cf = dev_id;
11637 + unsigned int present;
11639 + present = at32_cf_present(cf);
11640 + if (present != cf->present) {
11641 + cf->present = present;
11642 + debug(cf, 3, "card %s\n", present ? "present" : "gone");
11643 + pcmcia_parse_events(&cf->socket, SS_DETECT);
11646 + return IRQ_HANDLED;
11649 +static int at32_cf_get_status(struct pcmcia_socket *sock, u_int *value)
11651 + struct at32_cf_socket *cf;
11652 + u_int status = 0;
11654 + cf = container_of(sock, struct at32_cf_socket, socket);
11656 + if (at32_cf_present(cf)) {
11657 + /* NOTE: gpio on AP7xxx is 3.3V */
11658 + status = SS_DETECT | SS_3VCARD;
11659 + if (cf->ready_pin < 0 || gpio_get_value(cf->ready_pin))
11660 + status |= SS_READY;
11661 + if (cf->vcc_pin < 0 || gpio_get_value(cf->vcc_pin))
11662 + status |= SS_POWERON;
11669 +static int at32_cf_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
11671 + struct at32_cf_socket *cf = container_of(sock, struct at32_cf_socket, socket);
11673 + debug(cf, 2, "mask: %s%s%s%s%s%sflags: %s%s%s%s%s%sVcc %d Vpp %d irq %d\n",
11674 + (state->csc_mask==0)?"<NONE> ":"",
11675 + (state->csc_mask&SS_DETECT)?"DETECT ":"",
11676 + (state->csc_mask&SS_READY)?"READY ":"",
11677 + (state->csc_mask&SS_BATDEAD)?"BATDEAD ":"",
11678 + (state->csc_mask&SS_BATWARN)?"BATWARN ":"",
11679 + (state->csc_mask&SS_STSCHG)?"STSCHG ":"",
11680 + (state->flags==0)?"<NONE> ":"",
11681 + (state->flags&SS_PWR_AUTO)?"PWR_AUTO ":"",
11682 + (state->flags&SS_IOCARD)?"IOCARD ":"",
11683 + (state->flags&SS_RESET)?"RESET ":"",
11684 + (state->flags&SS_SPKR_ENA)?"SPKR_ENA ":"",
11685 + (state->flags&SS_OUTPUT_ENA)?"OUTPUT_ENA ":"",
11686 + state->Vcc, state->Vpp, state->io_irq);
11689 + * TODO: Allow boards to override this in case they have level
11692 + switch (state->Vcc) {
11694 + if (cf->vcc_pin >= 0)
11695 + gpio_set_value(cf->vcc_pin, 0);
11698 + if (cf->vcc_pin >= 0)
11699 + gpio_set_value(cf->vcc_pin, 1);
11705 + if (cf->reset_pin >= 0)
11706 + gpio_set_value(cf->reset_pin, state->flags & SS_RESET);
11708 + cf->state = *state;
11713 +static int at32_cf_socket_init(struct pcmcia_socket *sock)
11715 + debug(to_at32_cf(sock), 2, "called\n");
11720 +static int at32_cf_suspend(struct pcmcia_socket *sock)
11722 + debug(to_at32_cf(sock), 2, "called\n");
11724 + at32_cf_set_socket(sock, &dead_socket);
11729 +static int at32_cf_set_io_map(struct pcmcia_socket *sock,
11730 + struct pccard_io_map *map)
11732 + struct at32_cf_socket *cf = container_of(sock, struct at32_cf_socket, socket);
11735 + debug(cf, 2, "map %u speed %u start 0x%08x stop 0x%08x\n",
11736 + map->map, map->speed, map->start, map->stop);
11737 + debug(cf, 2, "flags: %s%s%s%s%s%s%s%s\n",
11738 + (map->flags == 0) ? "<NONE>":"",
11739 + (map->flags & MAP_ACTIVE) ? "ACTIVE " : "",
11740 + (map->flags & MAP_16BIT) ? "16BIT " : "",
11741 + (map->flags & MAP_AUTOSZ) ? "AUTOSZ " : "",
11742 + (map->flags & MAP_0WS) ? "0WS " : "",
11743 + (map->flags & MAP_WRPROT) ? "WRPROT " : "",
11744 + (map->flags & MAP_USE_WAIT) ? "USE_WAIT " : "",
11745 + (map->flags & MAP_PREFETCH) ? "PREFETCH " : "");
11747 + map->flags &= MAP_ACTIVE | MAP_16BIT | MAP_USE_WAIT;
11749 + if (map->flags & MAP_16BIT)
11750 + cf->smc.bus_width = 2;
11752 + cf->smc.bus_width = 1;
11754 + if (map->flags & MAP_USE_WAIT)
11755 + cf->smc.nwait_mode = 3;
11757 + cf->smc.nwait_mode = 0;
11759 + retval = smc_set_configuration(cf->cf_cs, &cf->smc);
11761 + printk(KERN_ERR "at32_cf: could not set up SMC for I/O\n");
11765 + map->start = cf->socket.io_offset;
11766 + map->stop = map->start + CF_RES_SIZE - 1;
11772 +at32_cf_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *map)
11774 + struct at32_cf_socket *cf;
11775 + struct resource *res;
11778 + cf = container_of(sock, struct at32_cf_socket, socket);
11780 + debug(cf, 2, "map %u speed %u card_start %08x\n",
11781 + map->map, map->speed, map->card_start);
11782 + debug(cf, 2, "flags: %s%s%s%s%s%s%s%s\n",
11783 + (map->flags==0)?"<NONE>":"",
11784 + (map->flags&MAP_ACTIVE)?"ACTIVE ":"",
11785 + (map->flags&MAP_16BIT)?"16BIT ":"",
11786 + (map->flags&MAP_AUTOSZ)?"AUTOSZ ":"",
11787 + (map->flags&MAP_0WS)?"0WS ":"",
11788 + (map->flags&MAP_WRPROT)?"WRPROT ":"",
11789 + (map->flags&MAP_ATTRIB)?"ATTRIB ":"",
11790 + (map->flags&MAP_USE_WAIT)?"USE_WAIT ":"");
11792 + if (map->card_start)
11795 + map->flags &= MAP_ACTIVE | MAP_ATTRIB | MAP_16BIT | MAP_USE_WAIT;
11797 + if (map->flags & MAP_ATTRIB) {
11798 + res = &cf->res_attr;
11800 + /* Linksys WCF12 seems to use WAIT when reading CIS */
11801 + map->flags |= MAP_USE_WAIT;
11803 + res = &cf->res_mem;
11806 + if (map->flags & MAP_USE_WAIT)
11807 + cf->smc.nwait_mode = 3;
11809 + cf->smc.nwait_mode = 0;
11811 + retval = smc_set_configuration(cf->cf_cs, &cf->smc);
11813 + printk(KERN_ERR "at32_cf: could not set up SMC for mem\n");
11817 + map->static_start = res->start;
11822 +static struct pccard_operations at32_cf_ops = {
11823 + .init = at32_cf_socket_init,
11824 + .suspend = at32_cf_suspend,
11825 + .get_status = at32_cf_get_status,
11826 + .set_socket = at32_cf_set_socket,
11827 + .set_io_map = at32_cf_set_io_map,
11828 + .set_mem_map = at32_cf_set_mem_map,
11831 +static int __init request_pin(struct platform_device *pdev,
11832 + unsigned int pin, const char *name)
11834 + if (gpio_request(pin, name)) {
11835 + dev_warn(&pdev->dev, "failed to request %s pin\n", name);
11842 +static struct smc_timing at32_cf_timing __initdata = {
11843 + .ncs_read_setup = 30,
11844 + .nrd_setup = 100,
11845 + .ncs_write_setup = 30,
11846 + .nwe_setup = 100,
11848 + .ncs_read_pulse = 360,
11849 + .nrd_pulse = 290,
11850 + .ncs_write_pulse = 360,
11851 + .nwe_pulse = 290,
11853 + .read_cycle = 420,
11854 + .write_cycle = 420,
11857 +static int __init at32_cf_probe(struct platform_device *pdev)
11859 + struct at32_cf_socket *cf;
11860 + struct cf_platform_data *board = pdev->dev.platform_data;
11861 + struct resource *res_skt;
11865 + dev_dbg(&pdev->dev, "probe");
11870 + res_skt = platform_get_resource(pdev, IORESOURCE_MEM, 0);
11874 + irq = platform_get_irq(pdev, 0);
11878 + cf = kzalloc(sizeof(struct at32_cf_socket), GFP_KERNEL);
11882 + cf->detect_pin = -1;
11883 + cf->reset_pin = -1;
11884 + cf->vcc_pin = -1;
11885 + cf->ready_pin = -1;
11886 + cf->cf_cs = board->cs;
11888 + if (board->detect_pin != GPIO_PIN_NONE)
11889 + cf->detect_pin = request_pin(pdev, board->detect_pin,
11891 + if (board->reset_pin != GPIO_PIN_NONE)
11892 + cf->reset_pin = request_pin(pdev, board->reset_pin,
11894 + if (board->vcc_pin != GPIO_PIN_NONE)
11895 + cf->vcc_pin = request_pin(pdev, board->vcc_pin,
11897 + if (board->ready_pin != GPIO_PIN_NONE)
11898 + /* READY is also used for irq through EIM */
11899 + cf->ready_pin = board->ready_pin;
11901 + debug(cf, 2, "pins: detect=%d reset=%d vcc=%d\n",
11902 + cf->detect_pin, cf->reset_pin, cf->vcc_pin);
11904 + cf->socket.pci_irq = irq;
11905 + cf->socket.ops = &at32_cf_ops;
11906 + cf->socket.resource_ops = &pccard_static_ops;
11907 + cf->socket.dev.parent = &pdev->dev;
11908 + cf->socket.owner = THIS_MODULE;
11909 + cf->socket.features =
11910 + SS_CAP_MEM_ALIGN | SS_CAP_STATIC_MAP | SS_CAP_PCCARD;
11911 + cf->socket.map_size = CF_RES_SIZE;
11913 + cf->res_attr.start = res_skt->start + CF_ATTR_OFFSET;
11914 + cf->res_attr.end = cf->res_attr.start + CF_RES_SIZE - 1;
11915 + cf->res_attr.name = "attribute";
11916 + cf->res_attr.flags = IORESOURCE_MEM;
11917 + ret = request_resource(res_skt, &cf->res_attr);
11919 + goto err_request_res_attr;
11921 + cf->res_mem.start = res_skt->start + CF_MEM_OFFSET;
11922 + cf->res_mem.end = cf->res_mem.start + CF_RES_SIZE - 1;
11923 + cf->res_mem.name = "memory";
11924 + cf->res_mem.flags = IORESOURCE_MEM;
11925 + ret = request_resource(res_skt, &cf->res_mem);
11927 + goto err_request_res_mem;
11929 + cf->res_io.start = res_skt->start + CF_IO_OFFSET;
11930 + cf->res_io.end = cf->res_io.start + CF_RES_SIZE - 1;
11931 + cf->res_io.name = "io";
11932 + cf->res_io.flags = IORESOURCE_MEM;
11933 + ret = request_resource(res_skt, &cf->res_io);
11935 + goto err_request_res_io;
11937 + cf->socket.io_offset = cf->res_io.start;
11939 + if (cf->detect_pin >= 0) {
11940 + ret = request_irq(gpio_to_irq(cf->detect_pin), at32_cf_irq,
11941 + IRQF_SHARED, "cf_detect", cf);
11944 + "failed to request cf_detect interrupt\n");
11945 + goto err_detect_irq;
11949 + cf->present = at32_cf_present(cf);
11951 + /* Setup SMC timings */
11952 + smc_set_timing(&cf->smc, &at32_cf_timing);
11954 + cf->smc.bus_width = 2;
11955 + cf->smc.nrd_controlled = 1;
11956 + cf->smc.nwe_controlled = 1;
11957 + cf->smc.nwait_mode = 0;
11958 + cf->smc.byte_write = 0;
11959 + cf->smc.tdf_cycles = 8;
11960 + cf->smc.tdf_mode = 0;
11962 + ret = smc_set_configuration(cf->cf_cs, &cf->smc);
11964 + debug(cf, 1, "failed to configure SMC\n", ret);
11968 + ret = pcmcia_register_socket(&cf->socket);
11970 + debug(cf, 1, "failed to register socket: %d\n", ret);
11971 + goto err_register_socket;
11974 + if (cf->reset_pin >= 0)
11975 + gpio_direction_output(cf->reset_pin, 0);
11977 + platform_set_drvdata(pdev, cf);
11979 + dev_info(&pdev->dev, "Atmel SMC CF interface at 0x%08lx\n",
11980 + (unsigned long)res_skt->start);
11984 +err_register_socket:
11986 + if (cf->detect_pin >= 0)
11987 + free_irq(gpio_to_irq(cf->detect_pin), cf);
11989 + release_resource(&cf->res_io);
11990 +err_request_res_io:
11991 + release_resource(&cf->res_mem);
11992 +err_request_res_mem:
11993 + release_resource(&cf->res_attr);
11994 +err_request_res_attr:
11995 + if (cf->vcc_pin >= 0)
11996 + gpio_free(cf->vcc_pin);
11997 + if (cf->reset_pin >= 0)
11998 + gpio_free(cf->reset_pin);
11999 + if (cf->detect_pin >= 0)
12000 + gpio_free(cf->detect_pin);
12006 +static int __exit at32_cf_remove(struct platform_device *pdev)
12008 + struct at32_cf_socket *cf = platform_get_drvdata(pdev);
12010 + pcmcia_unregister_socket(&cf->socket);
12011 + if (cf->detect_pin >= 0) {
12012 + free_irq(gpio_to_irq(cf->detect_pin), cf);
12013 + gpio_free(cf->detect_pin);
12015 + if (cf->vcc_pin >= 0)
12016 + gpio_free(cf->vcc_pin);
12017 + if (cf->reset_pin >= 0)
12018 + gpio_free(cf->reset_pin);
12020 + release_resource(&cf->res_io);
12021 + release_resource(&cf->res_mem);
12022 + release_resource(&cf->res_attr);
12024 + platform_set_drvdata(pdev, NULL);
12029 +static struct platform_driver at32_cf_driver = {
12030 + .remove = __exit_p(at32_cf_remove),
12032 + .name = "at32_cf",
12033 + .owner = THIS_MODULE,
12037 +static int __init at32_cf_init(void)
12041 + ret = platform_driver_probe(&at32_cf_driver, at32_cf_probe);
12043 + printk(KERN_ERR "at32_cf: probe failed: %d\n", ret);
12047 +static void __exit at32_cf_exit(void)
12049 + platform_driver_unregister(&at32_cf_driver);
12052 +module_init(at32_cf_init);
12053 +module_exit(at32_cf_exit);
12055 +MODULE_LICENSE("GPL");
12056 +MODULE_DESCRIPTION("Driver for SMC PCMCIA interface");
12057 +MODULE_AUTHOR("Hans-Christian Egtvedt <hcegtvedt@atmel.com>");
12058 --- a/drivers/pcmcia/Kconfig
12059 +++ b/drivers/pcmcia/Kconfig
12060 @@ -277,6 +277,13 @@
12061 Say Y here to support the CompactFlash controller on the
12062 PA Semi Electra eval board.
12065 + tristate "AT32AP CompactFlash Controller"
12066 + depends on PCMCIA && AVR32 && PLATFORM_AT32AP
12068 + Say Y here to support the CompactFlash controller on AT32 chips.
12069 + Or choose M to compile the driver as a module named "at32_cf".
12071 config PCCARD_NONSTATIC
12074 --- a/drivers/pcmcia/Makefile
12075 +++ b/drivers/pcmcia/Makefile
12077 obj-$(CONFIG_OMAP_CF) += omap_cf.o
12078 obj-$(CONFIG_AT91_CF) += at91_cf.o
12079 obj-$(CONFIG_ELECTRA_CF) += electra_cf.o
12080 +obj-$(CONFIG_AT32_CF) += at32_cf.o
12082 sa11xx_core-y += soc_common.o sa11xx_base.o
12083 pxa2xx_core-y += soc_common.o pxa2xx_base.o
12084 --- a/drivers/serial/atmel_serial.c
12085 +++ b/drivers/serial/atmel_serial.c
12086 @@ -1440,6 +1440,15 @@
12090 +static bool atmel_serial_clk_will_stop(void)
12092 +#ifdef CONFIG_ARCH_AT91
12093 + return at91_suspend_entering_slow_clock();
12099 static int atmel_serial_suspend(struct platform_device *pdev,
12100 pm_message_t state)
12102 @@ -1447,7 +1456,7 @@
12103 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
12105 if (device_may_wakeup(&pdev->dev)
12106 - && !at91_suspend_entering_slow_clock())
12107 + && !atmel_serial_clk_will_stop())
12108 enable_irq_wake(port->irq);
12110 uart_suspend_port(&atmel_uart, port);
12111 --- a/drivers/spi/atmel_spi.c
12112 +++ b/drivers/spi/atmel_spi.c
12115 struct list_head queue;
12116 struct spi_transfer *current_transfer;
12117 - unsigned long current_remaining_bytes;
12118 - struct spi_transfer *next_transfer;
12119 - unsigned long next_remaining_bytes;
12120 + unsigned long remaining_bytes;
12123 dma_addr_t buffer_dma;
12124 @@ -133,48 +131,6 @@
12125 gpio_set_value(gpio, !active);
12128 -static inline int atmel_spi_xfer_is_last(struct spi_message *msg,
12129 - struct spi_transfer *xfer)
12131 - return msg->transfers.prev == &xfer->transfer_list;
12134 -static inline int atmel_spi_xfer_can_be_chained(struct spi_transfer *xfer)
12136 - return xfer->delay_usecs == 0 && !xfer->cs_change;
12139 -static void atmel_spi_next_xfer_data(struct spi_master *master,
12140 - struct spi_transfer *xfer,
12141 - dma_addr_t *tx_dma,
12142 - dma_addr_t *rx_dma,
12145 - struct atmel_spi *as = spi_master_get_devdata(master);
12148 - /* use scratch buffer only when rx or tx data is unspecified */
12149 - if (xfer->rx_buf)
12150 - *rx_dma = xfer->rx_dma + xfer->len - len;
12152 - *rx_dma = as->buffer_dma;
12153 - if (len > BUFFER_SIZE)
12154 - len = BUFFER_SIZE;
12156 - if (xfer->tx_buf)
12157 - *tx_dma = xfer->tx_dma + xfer->len - len;
12159 - *tx_dma = as->buffer_dma;
12160 - if (len > BUFFER_SIZE)
12161 - len = BUFFER_SIZE;
12162 - memset(as->buffer, 0, len);
12163 - dma_sync_single_for_device(&as->pdev->dev,
12164 - as->buffer_dma, len, DMA_TO_DEVICE);
12171 * Submit next transfer for DMA.
12172 * lock is held, spi irq is blocked
12173 @@ -184,78 +140,53 @@
12175 struct atmel_spi *as = spi_master_get_devdata(master);
12176 struct spi_transfer *xfer;
12177 - u32 len, remaining, total;
12179 dma_addr_t tx_dma, rx_dma;
12181 - if (!as->current_transfer)
12182 - xfer = list_entry(msg->transfers.next,
12183 - struct spi_transfer, transfer_list);
12184 - else if (!as->next_transfer)
12185 - xfer = list_entry(as->current_transfer->transfer_list.next,
12186 - struct spi_transfer, transfer_list);
12192 - atmel_spi_next_xfer_data(master, xfer, &tx_dma, &rx_dma, &len);
12193 - remaining = xfer->len - len;
12195 - spi_writel(as, RPR, rx_dma);
12196 - spi_writel(as, TPR, tx_dma);
12198 - if (msg->spi->bits_per_word > 8)
12200 - spi_writel(as, RCR, len);
12201 - spi_writel(as, TCR, len);
12203 - dev_dbg(&msg->spi->dev,
12204 - " start xfer %p: len %u tx %p/%08x rx %p/%08x\n",
12205 - xfer, xfer->len, xfer->tx_buf, xfer->tx_dma,
12206 - xfer->rx_buf, xfer->rx_dma);
12208 - xfer = as->next_transfer;
12209 - remaining = as->next_remaining_bytes;
12210 + xfer = as->current_transfer;
12211 + if (!xfer || as->remaining_bytes == 0) {
12213 + xfer = list_entry(xfer->transfer_list.next,
12214 + struct spi_transfer, transfer_list);
12216 + xfer = list_entry(msg->transfers.next,
12217 + struct spi_transfer, transfer_list);
12218 + as->remaining_bytes = xfer->len;
12219 + as->current_transfer = xfer;
12222 - as->current_transfer = xfer;
12223 - as->current_remaining_bytes = remaining;
12225 - if (remaining > 0)
12227 - else if (!atmel_spi_xfer_is_last(msg, xfer)
12228 - && atmel_spi_xfer_can_be_chained(xfer)) {
12229 - xfer = list_entry(xfer->transfer_list.next,
12230 - struct spi_transfer, transfer_list);
12234 + len = as->remaining_bytes;
12236 - as->next_transfer = xfer;
12237 + tx_dma = xfer->tx_dma + xfer->len - len;
12238 + rx_dma = xfer->rx_dma + xfer->len - len;
12242 - atmel_spi_next_xfer_data(master, xfer, &tx_dma, &rx_dma, &len);
12243 - as->next_remaining_bytes = total - len;
12245 - spi_writel(as, RNPR, rx_dma);
12246 - spi_writel(as, TNPR, tx_dma);
12248 - if (msg->spi->bits_per_word > 8)
12250 - spi_writel(as, RNCR, len);
12251 - spi_writel(as, TNCR, len);
12253 - dev_dbg(&msg->spi->dev,
12254 - " next xfer %p: len %u tx %p/%08x rx %p/%08x\n",
12255 - xfer, xfer->len, xfer->tx_buf, xfer->tx_dma,
12256 - xfer->rx_buf, xfer->rx_dma);
12258 - spi_writel(as, RNCR, 0);
12259 - spi_writel(as, TNCR, 0);
12260 + /* use scratch buffer only when rx or tx data is unspecified */
12261 + if (!xfer->rx_buf) {
12262 + rx_dma = as->buffer_dma;
12263 + if (len > BUFFER_SIZE)
12264 + len = BUFFER_SIZE;
12266 + if (!xfer->tx_buf) {
12267 + tx_dma = as->buffer_dma;
12268 + if (len > BUFFER_SIZE)
12269 + len = BUFFER_SIZE;
12270 + memset(as->buffer, 0, len);
12271 + dma_sync_single_for_device(&as->pdev->dev,
12272 + as->buffer_dma, len, DMA_TO_DEVICE);
12275 + spi_writel(as, RPR, rx_dma);
12276 + spi_writel(as, TPR, tx_dma);
12278 - /* REVISIT: We're waiting for ENDRX before we start the next
12279 + as->remaining_bytes -= len;
12280 + if (msg->spi->bits_per_word > 8)
12283 + /* REVISIT: when xfer->delay_usecs == 0, the PDC "next transfer"
12284 + * mechanism might help avoid the IRQ latency between transfers
12285 + * (and improve the nCS0 errata handling on at91rm9200 chips)
12287 + * We're also waiting for ENDRX before we start the next
12288 * transfer because we need to handle some difficult timing
12289 * issues otherwise. If we wait for ENDTX in one transfer and
12290 * then starts waiting for ENDRX in the next, it's difficult
12291 @@ -265,7 +196,17 @@
12293 * It should be doable, though. Just not now...
12295 + spi_writel(as, TNCR, 0);
12296 + spi_writel(as, RNCR, 0);
12297 spi_writel(as, IER, SPI_BIT(ENDRX) | SPI_BIT(OVRES));
12299 + dev_dbg(&msg->spi->dev,
12300 + " start xfer %p: len %u tx %p/%08x rx %p/%08x imr %03x\n",
12301 + xfer, xfer->len, xfer->tx_buf, xfer->tx_dma,
12302 + xfer->rx_buf, xfer->rx_dma, spi_readl(as, IMR));
12304 + spi_writel(as, RCR, len);
12305 + spi_writel(as, TCR, len);
12306 spi_writel(as, PTCR, SPI_BIT(TXTEN) | SPI_BIT(RXTEN));
12309 @@ -363,7 +304,6 @@
12310 spin_lock(&as->lock);
12312 as->current_transfer = NULL;
12313 - as->next_transfer = NULL;
12315 /* continue if needed */
12316 if (list_empty(&as->queue) || as->stopping)
12317 @@ -447,7 +387,7 @@
12319 spi_writel(as, IDR, pending);
12321 - if (as->current_remaining_bytes == 0) {
12322 + if (as->remaining_bytes == 0) {
12323 msg->actual_length += xfer->len;
12325 if (!msg->is_dma_mapped)
12326 @@ -457,7 +397,7 @@
12327 if (xfer->delay_usecs)
12328 udelay(xfer->delay_usecs);
12330 - if (atmel_spi_xfer_is_last(msg, xfer)) {
12331 + if (msg->transfers.prev == &xfer->transfer_list) {
12332 /* report completed message */
12333 atmel_spi_msg_done(master, as, msg, 0,
12335 --- a/drivers/usb/gadget/atmel_usba_udc.c
12336 +++ b/drivers/usb/gadget/atmel_usba_udc.c
12338 #include <linux/platform_device.h>
12339 #include <linux/usb/ch9.h>
12340 #include <linux/usb/gadget.h>
12341 +#include <linux/usb/atmel_usba_udc.h>
12342 #include <linux/delay.h>
12344 #include <asm/gpio.h>
12348 static struct usba_udc the_udc;
12349 +static struct usba_ep *usba_ep;
12351 #ifdef CONFIG_USB_GADGET_DEBUG_FS
12352 #include <linux/debugfs.h>
12353 @@ -324,53 +326,28 @@
12357 -static void copy_to_fifo(void __iomem *fifo, const void *buf, int len)
12359 - unsigned long tmp;
12360 +#if defined(CONFIG_AVR32)
12362 - DBG(DBG_FIFO, "copy to FIFO (len %d):\n", len);
12363 - for (; len > 0; len -= 4, buf += 4, fifo += 4) {
12364 - tmp = *(unsigned long *)buf;
12366 - DBG(DBG_FIFO, " -> %08lx\n", tmp);
12367 - __raw_writel(tmp, fifo);
12370 - DBG(DBG_FIFO, " -> %02lx\n", tmp >> 24);
12371 - __raw_writeb(tmp >> 24, fifo);
12378 +static void toggle_bias(int is_on)
12382 -static void copy_from_fifo(void *buf, void __iomem *fifo, int len)
12383 +#elif defined(CONFIG_ARCH_AT91)
12385 +#include <asm/arch/at91_pmc.h>
12387 +static void toggle_bias(int is_on)
12390 - unsigned long *w;
12391 - unsigned char *b;
12393 - unsigned long tmp;
12395 - DBG(DBG_FIFO, "copy from FIFO (len %d):\n", len);
12396 - for (p.w = buf; len > 0; len -= 4, p.w++, fifo += 4) {
12398 - tmp = __raw_readl(fifo);
12400 - DBG(DBG_FIFO, " -> %08lx\n", tmp);
12403 - tmp = __raw_readb(fifo);
12405 - DBG(DBG_FIFO, " -> %02lx\n", tmp);
12410 + unsigned int uckr = at91_sys_read(AT91_CKGR_UCKR);
12413 + at91_sys_write(AT91_CKGR_UCKR, uckr | AT91_PMC_BIASEN);
12415 + at91_sys_write(AT91_CKGR_UCKR, uckr & ~(AT91_PMC_BIASEN));
12418 +#endif /* CONFIG_ARCH_AT91 */
12420 static void next_fifo_transaction(struct usba_ep *ep, struct usba_request *req)
12422 unsigned int transaction_len;
12423 @@ -387,7 +364,7 @@
12424 ep->ep.name, req, transaction_len,
12425 req->last_transaction ? ", done" : "");
12427 - copy_to_fifo(ep->fifo, req->req.buf + req->req.actual, transaction_len);
12428 + memcpy_toio(ep->fifo, req->req.buf + req->req.actual, transaction_len);
12429 usba_ep_writel(ep, SET_STA, USBA_TX_PK_RDY);
12430 req->req.actual += transaction_len;
12432 @@ -476,7 +453,7 @@
12433 bytecount = req->req.length - req->req.actual;
12436 - copy_from_fifo(req->req.buf + req->req.actual,
12437 + memcpy_fromio(req->req.buf + req->req.actual,
12438 ep->fifo, bytecount);
12439 req->req.actual += bytecount;
12441 @@ -1029,33 +1006,6 @@
12442 .set_selfpowered = usba_udc_set_selfpowered,
12445 -#define EP(nam, idx, maxpkt, maxbk, dma, isoc) \
12448 - .ops = &usba_ep_ops, \
12450 - .maxpacket = maxpkt, \
12452 - .udc = &the_udc, \
12453 - .queue = LIST_HEAD_INIT(usba_ep[idx].queue), \
12454 - .fifo_size = maxpkt, \
12455 - .nr_banks = maxbk, \
12457 - .can_dma = dma, \
12458 - .can_isoc = isoc, \
12461 -static struct usba_ep usba_ep[] = {
12462 - EP("ep0", 0, 64, 1, 0, 0),
12463 - EP("ep1in-bulk", 1, 512, 2, 1, 1),
12464 - EP("ep2out-bulk", 2, 512, 2, 1, 1),
12465 - EP("ep3in-int", 3, 64, 3, 1, 0),
12466 - EP("ep4out-int", 4, 64, 3, 1, 0),
12467 - EP("ep5in-iso", 5, 1024, 3, 1, 1),
12468 - EP("ep6out-iso", 6, 1024, 3, 1, 1),
12472 static struct usb_endpoint_descriptor usba_ep0_desc = {
12473 .bLength = USB_DT_ENDPOINT_SIZE,
12474 .bDescriptorType = USB_DT_ENDPOINT,
12475 @@ -1074,7 +1024,6 @@
12476 static struct usba_udc the_udc = {
12478 .ops = &usba_udc_ops,
12479 - .ep0 = &usba_ep[0].ep,
12480 .ep_list = LIST_HEAD_INIT(the_udc.gadget.ep_list),
12482 .name = "atmel_usba_udc",
12483 @@ -1231,7 +1180,7 @@
12485 usba_ep_writel(ep, CTL_ENB, USBA_EPT_ENABLE);
12486 usba_writel(udc, TST, USBA_TST_PKT_MODE);
12487 - copy_to_fifo(ep->fifo, test_packet_buffer,
12488 + memcpy_toio(ep->fifo, test_packet_buffer,
12489 sizeof(test_packet_buffer));
12490 usba_ep_writel(ep, SET_STA, USBA_TX_PK_RDY);
12491 dev_info(dev, "Entering Test_Packet mode...\n");
12492 @@ -1530,13 +1479,13 @@
12493 DBG(DBG_HW, "Packet length: %u\n", pkt_len);
12494 if (pkt_len != sizeof(crq)) {
12495 pr_warning("udc: Invalid packet length %u "
12496 - "(expected %lu)\n", pkt_len, sizeof(crq));
12497 + "(expected %zu)\n", pkt_len, sizeof(crq));
12498 set_protocol_stall(udc, ep);
12502 DBG(DBG_FIFO, "Copying ctrl request from 0x%p:\n", ep->fifo);
12503 - copy_from_fifo(crq.data, ep->fifo, sizeof(crq));
12504 + memcpy_fromio(crq.data, ep->fifo, sizeof(crq));
12506 /* Free up one bank in the FIFO so that we can
12507 * generate or receive a reply right away. */
12508 @@ -1688,6 +1637,7 @@
12509 DBG(DBG_INT, "irq, status=%#08x\n", status);
12511 if (status & USBA_DET_SUSPEND) {
12513 usba_writel(udc, INT_CLR, USBA_DET_SUSPEND);
12514 DBG(DBG_BUS, "Suspend detected\n");
12515 if (udc->gadget.speed != USB_SPEED_UNKNOWN
12516 @@ -1699,6 +1649,7 @@
12519 if (status & USBA_WAKE_UP) {
12521 usba_writel(udc, INT_CLR, USBA_WAKE_UP);
12522 DBG(DBG_BUS, "Wake Up CPU detected\n");
12524 @@ -1792,12 +1743,14 @@
12525 vbus = gpio_get_value(udc->vbus_pin);
12526 if (vbus != udc->vbus_prev) {
12528 - usba_writel(udc, CTRL, USBA_EN_USBA);
12530 + usba_writel(udc, CTRL, USBA_ENABLE_MASK);
12531 usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
12533 udc->gadget.speed = USB_SPEED_UNKNOWN;
12534 reset_all_endpoints(udc);
12535 - usba_writel(udc, CTRL, 0);
12537 + usba_writel(udc, CTRL, USBA_DISABLE_MASK);
12538 spin_unlock(&udc->lock);
12539 udc->driver->disconnect(&udc->gadget);
12540 spin_lock(&udc->lock);
12541 @@ -1850,7 +1803,8 @@
12542 /* If Vbus is present, enable the controller and wait for reset */
12543 spin_lock_irqsave(&udc->lock, flags);
12544 if (vbus_is_present(udc) && udc->vbus_prev == 0) {
12545 - usba_writel(udc, CTRL, USBA_EN_USBA);
12547 + usba_writel(udc, CTRL, USBA_ENABLE_MASK);
12548 usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
12550 spin_unlock_irqrestore(&udc->lock, flags);
12551 @@ -1883,7 +1837,8 @@
12552 spin_unlock_irqrestore(&udc->lock, flags);
12554 /* This will also disable the DP pullup */
12555 - usba_writel(udc, CTRL, 0);
12557 + usba_writel(udc, CTRL, USBA_DISABLE_MASK);
12559 driver->unbind(&udc->gadget);
12560 udc->gadget.dev.driver = NULL;
12561 @@ -1908,7 +1863,7 @@
12563 regs = platform_get_resource(pdev, IORESOURCE_MEM, CTRL_IOMEM_ID);
12564 fifo = platform_get_resource(pdev, IORESOURCE_MEM, FIFO_IOMEM_ID);
12565 - if (!regs || !fifo)
12566 + if (!regs || !fifo || !pdata)
12569 irq = platform_get_irq(pdev, 0);
12570 @@ -1953,19 +1908,48 @@
12572 /* Make sure we start from a clean slate */
12574 - usba_writel(udc, CTRL, 0);
12576 + usba_writel(udc, CTRL, USBA_DISABLE_MASK);
12579 + usba_ep = kmalloc(sizeof(struct usba_ep) * pdata->num_ep,
12582 + goto err_alloc_ep;
12584 + the_udc.gadget.ep0 = &usba_ep[0].ep;
12586 INIT_LIST_HEAD(&usba_ep[0].ep.ep_list);
12587 usba_ep[0].ep_regs = udc->regs + USBA_EPT_BASE(0);
12588 usba_ep[0].dma_regs = udc->regs + USBA_DMA_BASE(0);
12589 usba_ep[0].fifo = udc->fifo + USBA_FIFO_BASE(0);
12590 - for (i = 1; i < ARRAY_SIZE(usba_ep); i++) {
12591 + usba_ep[0].ep.ops = &usba_ep_ops;
12592 + usba_ep[0].ep.name = pdata->ep[0].name;
12593 + usba_ep[0].ep.maxpacket = pdata->ep[0].fifo_size;
12594 + usba_ep[0].udc = &the_udc;
12595 + INIT_LIST_HEAD(&usba_ep[0].queue);
12596 + usba_ep[0].fifo_size = pdata->ep[0].fifo_size;
12597 + usba_ep[0].nr_banks = pdata->ep[0].nr_banks;
12598 + usba_ep[0].index = pdata->ep[0].index;
12599 + usba_ep[0].can_dma = pdata->ep[0].can_dma;
12600 + usba_ep[0].can_isoc = pdata->ep[0].can_isoc;
12602 + for (i = 1; i < pdata->num_ep; i++) {
12603 struct usba_ep *ep = &usba_ep[i];
12605 ep->ep_regs = udc->regs + USBA_EPT_BASE(i);
12606 ep->dma_regs = udc->regs + USBA_DMA_BASE(i);
12607 ep->fifo = udc->fifo + USBA_FIFO_BASE(i);
12608 + ep->ep.ops = &usba_ep_ops;
12609 + ep->ep.name = pdata->ep[i].name;
12610 + ep->ep.maxpacket = pdata->ep[i].fifo_size;
12611 + ep->udc = &the_udc;
12612 + INIT_LIST_HEAD(&ep->queue);
12613 + ep->fifo_size = pdata->ep[i].fifo_size;
12614 + ep->nr_banks = pdata->ep[i].nr_banks;
12615 + ep->index = pdata->ep[i].index;
12616 + ep->can_dma = pdata->ep[i].can_dma;
12617 + ep->can_isoc = pdata->ep[i].can_isoc;
12619 list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list);
12621 @@ -1984,7 +1968,7 @@
12622 goto err_device_add;
12625 - if (pdata && pdata->vbus_pin != GPIO_PIN_NONE) {
12626 + if (pdata->vbus_pin >= 0) {
12627 if (!gpio_request(pdata->vbus_pin, "atmel_usba_udc")) {
12628 udc->vbus_pin = pdata->vbus_pin;
12630 @@ -2004,7 +1988,7 @@
12633 usba_init_debugfs(udc);
12634 - for (i = 1; i < ARRAY_SIZE(usba_ep); i++)
12635 + for (i = 1; i < pdata->num_ep; i++)
12636 usba_ep_init_debugfs(udc, &usba_ep[i]);
12639 @@ -2012,6 +1996,8 @@
12641 free_irq(irq, udc);
12645 iounmap(udc->fifo);
12647 iounmap(udc->regs);
12648 @@ -2029,10 +2015,11 @@
12650 struct usba_udc *udc;
12652 + struct usba_platform_data *pdata = pdev->dev.platform_data;
12654 udc = platform_get_drvdata(pdev);
12656 - for (i = 1; i < ARRAY_SIZE(usba_ep); i++)
12657 + for (i = 1; i < pdata->num_ep; i++)
12658 usba_ep_cleanup_debugfs(&usba_ep[i]);
12659 usba_cleanup_debugfs(udc);
12661 @@ -2040,6 +2027,7 @@
12662 gpio_free(udc->vbus_pin);
12664 free_irq(udc->irq, udc);
12666 iounmap(udc->fifo);
12667 iounmap(udc->regs);
12668 clk_put(udc->hclk);
12669 --- a/drivers/usb/gadget/atmel_usba_udc.h
12670 +++ b/drivers/usb/gadget/atmel_usba_udc.h
12672 #define USBA_EN_USBA (1 << 8)
12673 #define USBA_DETACH (1 << 9)
12674 #define USBA_REMOTE_WAKE_UP (1 << 10)
12675 +#define USBA_PULLD_DIS (1 << 11)
12677 +#if defined(CONFIG_AVR32)
12678 +#define USBA_ENABLE_MASK USBA_EN_USBA
12679 +#define USBA_DISABLE_MASK 0
12680 +#elif defined(CONFIG_ARCH_AT91)
12681 +#define USBA_ENABLE_MASK (USBA_EN_USBA | USBA_PULLD_DIS)
12682 +#define USBA_DISABLE_MASK USBA_DETACH
12683 +#endif /* CONFIG_ARCH_AT91 */
12685 /* Bitfields in FNUM */
12686 #define USBA_MICRO_FRAME_NUM_OFFSET 0
12687 --- a/drivers/usb/gadget/Kconfig
12688 +++ b/drivers/usb/gadget/Kconfig
12689 @@ -118,10 +118,10 @@
12690 config USB_GADGET_ATMEL_USBA
12691 boolean "Atmel USBA"
12692 select USB_GADGET_DUALSPEED
12694 + depends on AVR32 || ARCH_AT91CAP9
12696 USBA is the integrated high-speed USB Device controller on
12697 - the AT32AP700x processors from Atmel.
12698 + the AT32AP700x and AT91CAP9 processors from Atmel.
12700 config USB_ATMEL_USBA
12702 --- a/drivers/video/atmel_lcdfb.c
12703 +++ b/drivers/video/atmel_lcdfb.c
12707 #if defined(CONFIG_ARCH_AT91)
12708 -#define ATMEL_LCDFB_FBINFO_DEFAULT FBINFO_DEFAULT
12709 +#define ATMEL_LCDFB_FBINFO_DEFAULT (FBINFO_DEFAULT \
12710 + | FBINFO_PARTIAL_PAN_OK \
12711 + | FBINFO_HWACCEL_YPAN)
12713 static inline void atmel_lcdfb_update_dma2d(struct atmel_lcdfb_info *sinfo,
12714 struct fb_var_screeninfo *var)
12715 @@ -176,7 +178,7 @@
12716 .type = FB_TYPE_PACKED_PIXELS,
12717 .visual = FB_VISUAL_TRUECOLOR,
12722 .accel = FB_ACCEL_NONE,
12724 @@ -250,6 +252,8 @@
12728 + memset(info->screen_base, 0, info->fix.smem_len);
12733 @@ -634,7 +638,6 @@
12734 struct fb_info *info = sinfo->info;
12737 - memset_io(info->screen_base, 0, info->fix.smem_len);
12738 info->var.activate |= FB_ACTIVATE_FORCE | FB_ACTIVATE_NOW;
12740 dev_info(info->device,
12741 @@ -764,6 +767,11 @@
12742 info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len);
12743 if (!info->screen_base)
12744 goto release_intmem;
12747 + * Don't clear the framebuffer -- someone may have set
12748 + * up a splash image.
12751 /* alocate memory buffer */
12752 ret = atmel_lcdfb_alloc_video_memory(sinfo);
12753 --- a/fs/fs-writeback.c
12754 +++ b/fs/fs-writeback.c
12755 @@ -385,8 +385,6 @@
12756 * WB_SYNC_HOLD is a hack for sys_sync(): reattach the inode to sb->s_dirty so
12757 * that it can be located for waiting on in __writeback_single_inode().
12759 - * Called under inode_lock.
12761 * If `bdi' is non-zero then we're being asked to writeback a specific queue.
12762 * This function assumes that the blockdev superblock's inodes are backed by
12763 * a variety of queues, so all inodes are searched. For other superblocks,
12764 @@ -402,11 +400,12 @@
12765 * on the writer throttling path, and we get decent balancing between many
12766 * throttled threads: we don't want them all piling up on inode_sync_wait.
12769 -sync_sb_inodes(struct super_block *sb, struct writeback_control *wbc)
12770 +void generic_sync_sb_inodes(struct super_block *sb,
12771 + struct writeback_control *wbc)
12773 const unsigned long start = jiffies; /* livelock avoidance */
12775 + spin_lock(&inode_lock);
12776 if (!wbc->for_kupdate || list_empty(&sb->s_io))
12777 queue_io(sb, wbc->older_than_this);
12779 @@ -485,8 +484,16 @@
12780 if (!list_empty(&sb->s_more_io))
12783 + spin_unlock(&inode_lock);
12784 return; /* Leave any unwritten inodes on s_io */
12786 +EXPORT_SYMBOL_GPL(generic_sync_sb_inodes);
12788 +static void sync_sb_inodes(struct super_block *sb,
12789 + struct writeback_control *wbc)
12791 + generic_sync_sb_inodes(sb, wbc);
12795 * Start writeback of dirty pagecache data against all unlocked inodes.
12796 @@ -526,11 +533,8 @@
12797 * be unmounted by the time it is released.
12799 if (down_read_trylock(&sb->s_umount)) {
12800 - if (sb->s_root) {
12801 - spin_lock(&inode_lock);
12803 sync_sb_inodes(sb, wbc);
12804 - spin_unlock(&inode_lock);
12806 up_read(&sb->s_umount);
12808 spin_lock(&sb_lock);
12809 @@ -568,9 +572,7 @@
12810 (inodes_stat.nr_inodes - inodes_stat.nr_unused) +
12811 nr_dirty + nr_unstable;
12812 wbc.nr_to_write += wbc.nr_to_write / 2; /* Bit more for luck */
12813 - spin_lock(&inode_lock);
12814 sync_sb_inodes(sb, &wbc);
12815 - spin_unlock(&inode_lock);
12819 --- a/include/asm-avr32/arch-at32ap/board.h
12820 +++ b/include/asm-avr32/arch-at32ap/board.h
12823 #define GPIO_PIN_NONE (-1)
12826 + * Clock rates for various on-board oscillators. The number of entries
12827 + * in this array is chip-dependent.
12829 +extern unsigned long at32_board_osc_rates[];
12831 /* Add basic devices: system manager, interrupt controller, portmuxes, etc. */
12832 void at32_add_system_devices(void);
12834 @@ -36,11 +42,10 @@
12835 struct atmel_lcdfb_info;
12836 struct platform_device *
12837 at32_add_device_lcdc(unsigned int id, struct atmel_lcdfb_info *data,
12838 - unsigned long fbmem_start, unsigned long fbmem_len);
12839 + unsigned long fbmem_start, unsigned long fbmem_len,
12840 + unsigned int pin_config);
12842 -struct usba_platform_data {
12845 +struct usba_platform_data;
12846 struct platform_device *
12847 at32_add_device_usba(unsigned int id, struct usba_platform_data *data);
12850 struct platform_device *
12851 at32_add_device_ssc(unsigned int id, unsigned int flags);
12853 -struct platform_device *at32_add_device_twi(unsigned int id);
12854 -struct platform_device *at32_add_device_mci(unsigned int id);
12855 +struct i2c_board_info;
12856 +struct platform_device *at32_add_device_twi(unsigned int id,
12857 + struct i2c_board_info *b,
12860 +struct mci_platform_data {
12864 +struct platform_device *
12865 +at32_add_device_mci(unsigned int id, struct mci_platform_data *data);
12866 struct platform_device *at32_add_device_ac97c(unsigned int id);
12867 struct platform_device *at32_add_device_abdac(unsigned int id);
12870 at32_add_device_cf(unsigned int id, unsigned int extint,
12871 struct cf_platform_data *data);
12873 +struct platform_device *
12874 +at32_add_device_psif(unsigned int id);
12876 +/* NAND / SmartMedia */
12877 +struct atmel_nand_data {
12878 + int enable_pin; /* chip enable */
12879 + int det_pin; /* card detect */
12880 + int rdy_pin; /* ready/busy */
12881 + u8 ale; /* address line number connected to ALE */
12882 + u8 cle; /* address line number connected to CLE */
12883 + u8 bus_width_16; /* buswidth is 16 bit */
12884 + struct mtd_partition *(*partition_info)(int size, int *num_partitions);
12886 +struct platform_device *
12887 +at32_add_device_nand(unsigned int id, struct atmel_nand_data *data);
12889 #endif /* __ASM_ARCH_BOARD_H */
12890 --- a/include/asm-avr32/arch-at32ap/init.h
12891 +++ b/include/asm-avr32/arch-at32ap/init.h
12893 void setup_platform(void);
12894 void setup_board(void);
12896 -/* Called by setup_platform */
12897 -void at32_clock_init(void);
12898 -void at32_portmux_init(void);
12900 void at32_setup_serial_console(unsigned int usart_id);
12902 #endif /* __ASM_AVR32_AT32AP_INIT_H__ */
12904 +++ b/include/asm-avr32/arch-at32ap/pm.h
12907 + * AVR32 AP Power Management.
12909 + * Copyright (C) 2008 Atmel Corporation
12911 + * This program is free software; you can redistribute it and/or modify
12912 + * it under the terms of the GNU General Public License version 2 as
12913 + * published by the Free Software Foundation.
12915 +#ifndef __ASM_AVR32_ARCH_PM_H
12916 +#define __ASM_AVR32_ARCH_PM_H
12918 +/* Possible arguments to the "sleep" instruction */
12919 +#define CPU_SLEEP_IDLE 0
12920 +#define CPU_SLEEP_FROZEN 1
12921 +#define CPU_SLEEP_STANDBY 2
12922 +#define CPU_SLEEP_STOP 3
12923 +#define CPU_SLEEP_STATIC 5
12925 +#ifndef __ASSEMBLY__
12926 +extern void cpu_enter_idle(void);
12927 +extern void cpu_enter_standby(unsigned long sdramc_base);
12929 +extern bool disable_idle_sleep;
12931 +static inline void cpu_disable_idle_sleep(void)
12933 + disable_idle_sleep = true;
12936 +static inline void cpu_enable_idle_sleep(void)
12938 + disable_idle_sleep = false;
12941 +static inline void cpu_idle_sleep(void)
12944 + * If we're using the COUNT and COMPARE registers for
12945 + * timekeeping, we can't use the IDLE state.
12947 + if (disable_idle_sleep)
12950 + cpu_enter_idle();
12953 +void intc_set_suspend_handler(unsigned long offset);
12956 +#endif /* __ASM_AVR32_ARCH_PM_H */
12957 --- a/include/asm-avr32/arch-at32ap/portmux.h
12958 +++ b/include/asm-avr32/arch-at32ap/portmux.h
12960 void at32_select_gpio(unsigned int pin, unsigned long flags);
12961 void at32_reserve_pin(unsigned int pin);
12963 +#ifdef CONFIG_GPIO_DEV
12965 +/* Gang allocators and accessors; used by the GPIO /dev driver */
12966 +int at32_gpio_port_is_valid(unsigned int port);
12967 +int at32_select_gpio_pins(unsigned int port, u32 pins, u32 oe_mask);
12968 +void at32_deselect_pins(unsigned int port, u32 pins);
12970 +u32 at32_gpio_get_value_multiple(unsigned int port, u32 pins);
12971 +void at32_gpio_set_value_multiple(unsigned int port, u32 value, u32 mask);
12973 +#endif /* CONFIG_GPIO_DEV */
12975 #endif /* __ASM_ARCH_PORTMUX_H__ */
12977 +++ b/include/asm-avr32/arch-at32ap/sram.h
12980 + * Simple SRAM allocator
12982 + * Copyright (C) 2008 Atmel Corporation
12984 + * This program is free software; you can redistribute it and/or modify
12985 + * it under the terms of the GNU General Public License version 2 as
12986 + * published by the Free Software Foundation.
12988 +#ifndef __ASM_AVR32_ARCH_SRAM_H
12989 +#define __ASM_AVR32_ARCH_SRAM_H
12991 +#include <linux/genalloc.h>
12993 +extern struct gen_pool *sram_pool;
12995 +static inline unsigned long sram_alloc(size_t len)
13000 + return gen_pool_alloc(sram_pool, len);
13003 +static inline void sram_free(unsigned long addr, size_t len)
13005 + return gen_pool_free(sram_pool, addr, len);
13008 +#endif /* __ASM_AVR32_ARCH_SRAM_H */
13009 --- a/include/asm-avr32/arch-at32ap/time.h
13013 - * Copyright (C) 2007 Atmel Corporation
13015 - * This program is free software; you can redistribute it and/or modify
13016 - * it under the terms of the GNU General Public License version 2 as
13017 - * published by the Free Software Foundation.
13020 -#ifndef _ASM_AVR32_ARCH_AT32AP_TIME_H
13021 -#define _ASM_AVR32_ARCH_AT32AP_TIME_H
13023 -#include <linux/platform_device.h>
13025 -extern struct irqaction timer_irqaction;
13026 -extern struct platform_device at32_systc0_device;
13027 -extern void local_timer_interrupt(int irq, void *dev_id);
13029 -#define TIMER_BCR 0x000000c0
13030 -#define TIMER_BCR_SYNC 0
13031 -#define TIMER_BMR 0x000000c4
13032 -#define TIMER_BMR_TC0XC0S 0
13033 -#define TIMER_BMR_TC1XC1S 2
13034 -#define TIMER_BMR_TC2XC2S 4
13035 -#define TIMER_CCR 0x00000000
13036 -#define TIMER_CCR_CLKDIS 1
13037 -#define TIMER_CCR_CLKEN 0
13038 -#define TIMER_CCR_SWTRG 2
13039 -#define TIMER_CMR 0x00000004
13040 -#define TIMER_CMR_ABETRG 10
13041 -#define TIMER_CMR_ACPA 16
13042 -#define TIMER_CMR_ACPC 18
13043 -#define TIMER_CMR_AEEVT 20
13044 -#define TIMER_CMR_ASWTRG 22
13045 -#define TIMER_CMR_BCPB 24
13046 -#define TIMER_CMR_BCPC 26
13047 -#define TIMER_CMR_BEEVT 28
13048 -#define TIMER_CMR_BSWTRG 30
13049 -#define TIMER_CMR_BURST 4
13050 -#define TIMER_CMR_CLKI 3
13051 -#define TIMER_CMR_CPCDIS 7
13052 -#define TIMER_CMR_CPCSTOP 6
13053 -#define TIMER_CMR_CPCTRG 14
13054 -#define TIMER_CMR_EEVT 10
13055 -#define TIMER_CMR_EEVTEDG 8
13056 -#define TIMER_CMR_ENETRG 12
13057 -#define TIMER_CMR_ETRGEDG 8
13058 -#define TIMER_CMR_LDBDIS 7
13059 -#define TIMER_CMR_LDBSTOP 6
13060 -#define TIMER_CMR_LDRA 16
13061 -#define TIMER_CMR_LDRB 18
13062 -#define TIMER_CMR_TCCLKS 0
13063 -#define TIMER_CMR_WAVE 15
13064 -#define TIMER_CMR_WAVSEL 13
13065 -#define TIMER_CV 0x00000010
13066 -#define TIMER_CV_CV 0
13067 -#define TIMER_IDR 0x00000028
13068 -#define TIMER_IDR_COVFS 0
13069 -#define TIMER_IDR_CPAS 2
13070 -#define TIMER_IDR_CPBS 3
13071 -#define TIMER_IDR_CPCS 4
13072 -#define TIMER_IDR_ETRGS 7
13073 -#define TIMER_IDR_LDRAS 5
13074 -#define TIMER_IDR_LDRBS 6
13075 -#define TIMER_IDR_LOVRS 1
13076 -#define TIMER_IER 0x00000024
13077 -#define TIMER_IER_COVFS 0
13078 -#define TIMER_IER_CPAS 2
13079 -#define TIMER_IER_CPBS 3
13080 -#define TIMER_IER_CPCS 4
13081 -#define TIMER_IER_ETRGS 7
13082 -#define TIMER_IER_LDRAS 5
13083 -#define TIMER_IER_LDRBS 6
13084 -#define TIMER_IER_LOVRS 1
13085 -#define TIMER_IMR 0x0000002c
13086 -#define TIMER_IMR_COVFS 0
13087 -#define TIMER_IMR_CPAS 2
13088 -#define TIMER_IMR_CPBS 3
13089 -#define TIMER_IMR_CPCS 4
13090 -#define TIMER_IMR_ETRGS 7
13091 -#define TIMER_IMR_LDRAS 5
13092 -#define TIMER_IMR_LDRBS 6
13093 -#define TIMER_IMR_LOVRS 1
13094 -#define TIMER_RA 0x00000014
13095 -#define TIMER_RA_RA 0
13096 -#define TIMER_RB 0x00000018
13097 -#define TIMER_RB_RB 0
13098 -#define TIMER_RC 0x0000001c
13099 -#define TIMER_RC_RC 0
13100 -#define TIMER_SR 0x00000020
13101 -#define TIMER_SR_CLKSTA 16
13102 -#define TIMER_SR_COVFS 0
13103 -#define TIMER_SR_CPAS 2
13104 -#define TIMER_SR_CPBS 3
13105 -#define TIMER_SR_CPCS 4
13106 -#define TIMER_SR_ETRGS 7
13107 -#define TIMER_SR_LDRAS 5
13108 -#define TIMER_SR_LDRBS 6
13109 -#define TIMER_SR_LOVRS 1
13110 -#define TIMER_SR_MTIOA 17
13111 -#define TIMER_SR_MTIOB 18
13113 -/* Bit manipulation macros */
13114 -#define TIMER_BIT(name) (1 << TIMER_##name)
13115 -#define TIMER_BF(name,value) ((value) << TIMER_##name)
13117 -/* Register access macros */
13118 -#define timer_read(port,instance,reg) \
13119 - __raw_readl(port + (0x40 * instance) + TIMER_##reg)
13120 -#define timer_write(port,instance,reg,value) \
13121 - __raw_writel((value), port + (0x40 * instance) + TIMER_##reg)
13123 -#endif /* _ASM_AVR32_ARCH_AT32AP_TIME_H */
13124 --- a/include/asm-avr32/asm.h
13125 +++ b/include/asm-avr32/asm.h
13126 @@ -12,10 +12,10 @@
13127 #include <asm/asm-offsets.h>
13128 #include <asm/thread_info.h>
13130 -#define mask_interrupts ssrf SR_GM_BIT
13131 -#define mask_exceptions ssrf SR_EM_BIT
13132 -#define unmask_interrupts csrf SR_GM_BIT
13133 -#define unmask_exceptions csrf SR_EM_BIT
13134 +#define mask_interrupts ssrf SYSREG_GM_OFFSET
13135 +#define mask_exceptions ssrf SYSREG_EM_OFFSET
13136 +#define unmask_interrupts csrf SYSREG_GM_OFFSET
13137 +#define unmask_exceptions csrf SYSREG_EM_OFFSET
13139 #ifdef CONFIG_FRAME_POINTER
13142 +++ b/include/asm-avr32/dma-controller.h
13145 + * Copyright (C) 2005-2006 Atmel Corporation
13147 + * This program is free software; you can redistribute it and/or modify
13148 + * it under the terms of the GNU General Public License version 2 as
13149 + * published by the Free Software Foundation.
13151 +#ifndef __ASM_AVR32_DMA_CONTROLLER_H
13152 +#define __ASM_AVR32_DMA_CONTROLLER_H
13154 +#include <linux/device.h>
13156 +#define DMA_DIR_MEM_TO_MEM 0x0000
13157 +#define DMA_DIR_MEM_TO_PERIPH 0x0001
13158 +#define DMA_DIR_PERIPH_TO_MEM 0x0002
13159 +#define DMA_DIR_PERIPH_TO_PERIPH 0x0003
13161 +#define DMA_WIDTH_8BIT 0
13162 +#define DMA_WIDTH_16BIT 1
13163 +#define DMA_WIDTH_32BIT 2
13165 +struct dma_request {
13166 + struct dma_controller *dmac;
13167 + struct list_head list;
13169 + unsigned short channel;
13171 + void (*xfer_complete)(struct dma_request *req);
13172 + void (*block_complete)(struct dma_request *req);
13173 + void (*error)(struct dma_request *req);
13176 +struct dma_request_sg {
13177 + struct dma_request req;
13180 + struct scatterlist *sg;
13181 + unsigned long block_size;
13182 + unsigned int nr_blocks;
13184 + dma_addr_t data_reg;
13185 + unsigned short periph_id;
13187 + unsigned char direction;
13188 + unsigned char width;
13190 +#define to_dma_request_sg(_req) \
13191 + container_of(_req, struct dma_request_sg, req)
13193 +struct dma_request_cyclic {
13194 + struct dma_request req;
13197 + unsigned long buffer_size;
13199 + dma_addr_t buffer_start;
13200 + dma_addr_t data_reg;
13202 + unsigned short periph_id;
13203 + unsigned char direction;
13204 + unsigned char width;
13208 +#define to_dma_request_cyclic(_req) \
13209 + container_of(_req, struct dma_request_cyclic, req)
13211 +struct dma_request_memcpy {
13212 + struct dma_request req;
13214 + dma_addr_t src_addr;
13215 + unsigned int src_width;
13216 + unsigned int src_stride;
13218 + dma_addr_t dst_addr;
13219 + unsigned int dst_width;
13220 + unsigned int dst_stride;
13224 + unsigned short src_reverse:1;
13225 + unsigned short dst_reverse:1;
13227 +#define to_dma_request_memcpy(_req) \
13228 + container_of(_req, struct dma_request_memcpy, req)
13230 +struct dma_controller {
13231 + struct list_head list;
13233 + struct device *dev;
13235 + int (*alloc_channel)(struct dma_controller *dmac);
13236 + void (*release_channel)(struct dma_controller *dmac,
13238 + int (*prepare_request_sg)(struct dma_controller *dmac,
13239 + struct dma_request_sg *req);
13240 + int (*prepare_request_cyclic)(struct dma_controller *dmac,
13241 + struct dma_request_cyclic *req);
13242 + int (*prepare_request_memcpy)(struct dma_controller *dmac,
13243 + struct dma_request_memcpy *req);
13244 + int (*start_request)(struct dma_controller *dmac,
13245 + unsigned int channel);
13246 + int (*stop_request)(struct dma_controller *dmac,
13247 + unsigned int channel);
13248 + dma_addr_t (*get_current_pos)(struct dma_controller *dmac,
13249 + unsigned int channel);
13253 +dma_alloc_channel(struct dma_controller *dmac)
13255 + return dmac->alloc_channel(dmac);
13258 +static inline void
13259 +dma_release_channel(struct dma_controller *dmac, int chan)
13261 + dmac->release_channel(dmac, chan);
13265 +dma_prepare_request_sg(struct dma_controller *dmac,
13266 + struct dma_request_sg *req)
13268 + return dmac->prepare_request_sg(dmac, req);
13272 +dma_prepare_request_cyclic(struct dma_controller *dmac,
13273 + struct dma_request_cyclic *req)
13275 + return dmac->prepare_request_cyclic(dmac, req);
13279 +dma_prepare_request_memcpy(struct dma_controller *dmac,
13280 + struct dma_request_memcpy *req)
13282 + return dmac->prepare_request_memcpy(dmac, req);
13286 +dma_start_request(struct dma_controller *dmac,
13287 + unsigned int channel)
13289 + return dmac->start_request(dmac, channel);
13293 +dma_stop_request(struct dma_controller *dmac,
13294 + unsigned int channel)
13296 + return dmac->stop_request(dmac, channel);
13299 +static inline dma_addr_t
13300 +dma_get_current_pos(struct dma_controller *dmac,
13301 + unsigned int channel)
13303 + return dmac->get_current_pos(dmac, channel);
13306 +extern int register_dma_controller(struct dma_controller *dmac);
13307 +extern struct dma_controller *find_dma_controller(int id);
13309 +#endif /* __ASM_AVR32_DMA_CONTROLLER_H */
13310 --- a/include/asm-avr32/intc.h
13313 -#ifndef __ASM_AVR32_INTC_H
13314 -#define __ASM_AVR32_INTC_H
13316 -#include <linux/sysdev.h>
13317 -#include <linux/interrupt.h>
13319 -struct irq_controller;
13323 -struct platform_device;
13325 -/* Information about the internal interrupt controller */
13326 -struct intc_device {
13327 - /* ioremapped address of configuration block */
13328 - void __iomem *regs;
13330 - /* the physical device */
13331 - struct platform_device *pdev;
13333 - /* Number of interrupt lines per group. */
13334 - unsigned int irqs_per_group;
13336 - /* The highest group ID + 1 */
13337 - unsigned int nr_groups;
13340 - * Bitfield indicating which groups are actually in use. The
13341 - * size of the array is
13342 - * ceil(group_max / (8 * sizeof(unsigned int))).
13344 - unsigned int group_mask[];
13347 -struct irq_controller_class {
13349 - * A short name identifying this kind of controller.
13351 - const char *typename;
13353 - * Handle the IRQ. Must do any necessary acking and masking.
13355 - irqreturn_t (*handle)(int irq, void *dev_id, struct pt_regs *regs);
13357 - * Register a new IRQ handler.
13359 - int (*setup)(struct irq_controller *ctrl, unsigned int irq,
13360 - struct irqaction *action);
13362 - * Unregister a IRQ handler.
13364 - void (*free)(struct irq_controller *ctrl, unsigned int irq,
13367 - * Mask the IRQ in the interrupt controller.
13369 - void (*mask)(struct irq_controller *ctrl, unsigned int irq);
13371 - * Unmask the IRQ in the interrupt controller.
13373 - void (*unmask)(struct irq_controller *ctrl, unsigned int irq);
13375 - * Set the type of the IRQ. See below for possible types.
13376 - * Return -EINVAL if a given type is not supported
13378 - int (*set_type)(struct irq_controller *ctrl, unsigned int irq,
13379 - unsigned int type);
13381 - * Return the IRQ type currently set
13383 - unsigned int (*get_type)(struct irq_controller *ctrl, unsigned int irq);
13386 -struct irq_controller {
13387 - struct irq_controller_class *class;
13388 - unsigned int irq_group;
13389 - unsigned int first_irq;
13390 - unsigned int nr_irqs;
13391 - struct list_head list;
13394 -struct intc_group_desc {
13395 - struct irq_controller *ctrl;
13396 - irqreturn_t (*handle)(int, void *, struct pt_regs *);
13397 - unsigned long flags;
13399 - const char *devname;
13403 - * The internal interrupt controller. Defined in board/part-specific
13405 - * TODO: Should probably be defined per-cpu.
13407 -extern struct intc_device intc;
13409 -extern int request_internal_irq(unsigned int irq,
13410 - irqreturn_t (*handler)(int, void *, struct pt_regs *),
13411 - unsigned long irqflags,
13412 - const char *devname, void *dev_id);
13413 -extern void free_internal_irq(unsigned int irq);
13415 -/* Only used by time_init() */
13416 -extern int setup_internal_irq(unsigned int irq, struct intc_group_desc *desc);
13419 - * Set interrupt priority for a given group. `group' can be found by
13420 - * using irq_to_group(irq). Priority can be from 0 (lowest) to 3
13421 - * (highest). Higher-priority interrupts will preempt lower-priority
13422 - * interrupts (unless interrupts are masked globally).
13424 - * This function does not check for conflicts within a group.
13426 -extern int intc_set_priority(unsigned int group,
13427 - unsigned int priority);
13430 - * Returns a bitmask of pending interrupts in a group.
13432 -extern unsigned long intc_get_pending(unsigned int group);
13435 - * Register a new external interrupt controller. Returns the first
13436 - * external IRQ number that is assigned to the new controller.
13438 -extern int intc_register_controller(struct irq_controller *ctrl);
13440 -#endif /* __ASM_AVR32_INTC_H */
13441 --- a/include/asm-avr32/irq.h
13442 +++ b/include/asm-avr32/irq.h
13444 #ifndef __ASSEMBLER__
13445 int nmi_enable(void);
13446 void nmi_disable(void);
13449 + * Returns a bitmask of pending interrupts in a group.
13451 +extern unsigned long intc_get_pending(unsigned int group);
13454 #endif /* __ASM_AVR32_IOCTLS_H */
13455 --- a/include/asm-avr32/page.h
13456 +++ b/include/asm-avr32/page.h
13458 #ifndef __ASM_AVR32_PAGE_H
13459 #define __ASM_AVR32_PAGE_H
13461 +#include <linux/const.h>
13463 /* PAGE_SHIFT determines the page size */
13464 #define PAGE_SHIFT 12
13465 -#ifdef __ASSEMBLY__
13466 -#define PAGE_SIZE (1 << PAGE_SHIFT)
13468 -#define PAGE_SIZE (1UL << PAGE_SHIFT)
13470 +#define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
13471 #define PAGE_MASK (~(PAGE_SIZE-1))
13472 #define PTE_MASK PAGE_MASK
13474 --- a/include/asm-avr32/pci.h
13475 +++ b/include/asm-avr32/pci.h
13478 #define PCI_DMA_BUS_IS_PHYS (1)
13480 +#include <asm-generic/pci-dma-compat.h>
13482 #endif /* __ASM_AVR32_PCI_H__ */
13484 +++ b/include/asm-avr32/serial.h
13486 +#ifndef _ASM_SERIAL_H
13487 +#define _ASM_SERIAL_H
13490 + * This assumes you have a 1.8432 MHz clock for your UART.
13492 + * It'd be nice if someone built a serial card with a 24.576 MHz
13493 + * clock, since the 16550A is capable of handling a top speed of 1.5
13494 + * megabits/second; but this requires the faster clock.
13496 +#define BASE_BAUD (1843200 / 16)
13498 +#endif /* _ASM_SERIAL_H */
13499 --- a/include/asm-avr32/thread_info.h
13500 +++ b/include/asm-avr32/thread_info.h
13502 #define TIF_MEMDIE 6
13503 #define TIF_RESTORE_SIGMASK 7 /* restore signal mask in do_signal */
13504 #define TIF_CPU_GOING_TO_SLEEP 8 /* CPU is entering sleep 0 mode */
13505 +#define TIF_FREEZE 29
13506 #define TIF_DEBUG 30 /* debugging enabled */
13507 #define TIF_USERSPACE 31 /* true if FS sets userspace */
13510 +++ b/include/asm-avr32/xor.h
13512 +#ifndef _ASM_XOR_H
13513 +#define _ASM_XOR_H
13515 +#include <asm-generic/xor.h>
13519 +++ b/include/linux/atmel_tc.h
13522 + * Timer/Counter Unit (TC) registers.
13524 + * This program is free software; you can redistribute it and/or modify
13525 + * it under the terms of the GNU General Public License as published by
13526 + * the Free Software Foundation; either version 2 of the License, or
13527 + * (at your option) any later version.
13530 +#ifndef ATMEL_TC_H
13531 +#define ATMEL_TC_H
13533 +#include <linux/compiler.h>
13534 +#include <linux/list.h>
13537 + * Many 32-bit Atmel SOCs include one or more TC blocks, each of which holds
13538 + * three general-purpose 16-bit timers. These timers share one register bank.
13539 + * Depending on the SOC, each timer may have its own clock and IRQ, or those
13540 + * may be shared by the whole TC block.
13542 + * These TC blocks may have up to nine external pins: TCLK0..2 signals for
13543 + * clocks or clock gates, and per-timer TIOA and TIOB signals used for PWM
13544 + * or triggering. Those pins need to be set up for use with the TC block,
13545 + * else they will be used as GPIOs or for a different controller.
13547 + * Although we expect each TC block to have a platform_device node, those
13548 + * nodes are not what drivers bind to. Instead, they ask for a specific
13549 + * TC block, by number ... which is a common approach on systems with many
13550 + * timers. Then they use clk_get() and platform_get_irq() to get clock and
13557 + * struct atmel_tc - information about a Timer/Counter Block
13558 + * @pdev: physical device
13559 + * @iomem: resource associated with the I/O register
13560 + * @regs: mapping through which the I/O registers can be accessed
13561 + * @irq: irq for each of the three channels
13562 + * @clk: internal clock source for each of the three channels
13563 + * @node: list node, for tclib internal use
13565 + * On some platforms, each TC channel has its own clocks and IRQs,
13566 + * while on others, all TC channels share the same clock and IRQ.
13567 + * Drivers should clk_enable() all the clocks they need even though
13568 + * all the entries in @clk may point to the same physical clock.
13569 + * Likewise, drivers should request irqs independently for each
13570 + * channel, but they must use IRQF_SHARED in case some of the entries
13571 + * in @irq are actually the same IRQ.
13574 + struct platform_device *pdev;
13575 + struct resource *iomem;
13576 + void __iomem *regs;
13578 + struct clk *clk[3];
13579 + struct list_head node;
13582 +extern struct atmel_tc *atmel_tc_alloc(unsigned block, const char *name);
13583 +extern void atmel_tc_free(struct atmel_tc *tc);
13585 +/* platform-specific ATMEL_TC_TIMER_CLOCKx divisors (0 means 32KiHz) */
13586 +extern const u8 atmel_tc_divisors[5];
13590 + * Two registers have block-wide controls. These are: configuring the three
13591 + * "external" clocks (or event sources) used by the timer channels; and
13592 + * synchronizing the timers by resetting them all at once.
13594 + * "External" can mean "external to chip" using the TCLK0, TCLK1, or TCLK2
13595 + * signals. Or, it can mean "external to timer", using the TIOA output from
13596 + * one of the other two timers that's being run in waveform mode.
13599 +#define ATMEL_TC_BCR 0xc0 /* TC Block Control Register */
13600 +#define ATMEL_TC_SYNC (1 << 0) /* synchronize timers */
13602 +#define ATMEL_TC_BMR 0xc4 /* TC Block Mode Register */
13603 +#define ATMEL_TC_TC0XC0S (3 << 0) /* external clock 0 source */
13604 +#define ATMEL_TC_TC0XC0S_TCLK0 (0 << 0)
13605 +#define ATMEL_TC_TC0XC0S_NONE (1 << 0)
13606 +#define ATMEL_TC_TC0XC0S_TIOA1 (2 << 0)
13607 +#define ATMEL_TC_TC0XC0S_TIOA2 (3 << 0)
13608 +#define ATMEL_TC_TC1XC1S (3 << 2) /* external clock 1 source */
13609 +#define ATMEL_TC_TC1XC1S_TCLK1 (0 << 2)
13610 +#define ATMEL_TC_TC1XC1S_NONE (1 << 2)
13611 +#define ATMEL_TC_TC1XC1S_TIOA0 (2 << 2)
13612 +#define ATMEL_TC_TC1XC1S_TIOA2 (3 << 2)
13613 +#define ATMEL_TC_TC2XC2S (3 << 4) /* external clock 2 source */
13614 +#define ATMEL_TC_TC2XC2S_TCLK2 (0 << 4)
13615 +#define ATMEL_TC_TC2XC2S_NONE (1 << 4)
13616 +#define ATMEL_TC_TC2XC2S_TIOA0 (2 << 4)
13617 +#define ATMEL_TC_TC2XC2S_TIOA1 (3 << 4)
13621 + * Each TC block has three "channels", each with one counter and controls.
13623 + * Note that the semantics of ATMEL_TC_TIMER_CLOCKx (input clock selection
13624 + * when it's not "external") is silicon-specific. AT91 platforms use one
13625 + * set of definitions; AVR32 platforms use a different set. Don't hard-wire
13626 + * such knowledge into your code, use the global "atmel_tc_divisors" ...
13627 + * where index N is the divisor for clock N+1, else zero to indicate it uses
13628 + * the 32 KiHz clock.
13630 + * The timers can be chained in various ways, and operated in "waveform"
13631 + * generation mode (including PWM) or "capture" mode (to time events). In
13632 + * both modes, behavior can be configured in many ways.
13634 + * Each timer has two I/O pins, TIOA and TIOB. Waveform mode uses TIOA as a
13635 + * PWM output, and TIOB as either another PWM or as a trigger. Capture mode
13636 + * uses them only as inputs.
13638 +#define ATMEL_TC_CHAN(idx) ((idx)*0x40)
13639 +#define ATMEL_TC_REG(idx, reg) (ATMEL_TC_CHAN(idx) + ATMEL_TC_ ## reg)
13641 +#define ATMEL_TC_CCR 0x00 /* Channel Control Register */
13642 +#define ATMEL_TC_CLKEN (1 << 0) /* clock enable */
13643 +#define ATMEL_TC_CLKDIS (1 << 1) /* clock disable */
13644 +#define ATMEL_TC_SWTRG (1 << 2) /* software trigger */
13646 +#define ATMEL_TC_CMR 0x04 /* Channel Mode Register */
13648 +/* Both modes share some CMR bits */
13649 +#define ATMEL_TC_TCCLKS (7 << 0) /* clock source */
13650 +#define ATMEL_TC_TIMER_CLOCK1 (0 << 0)
13651 +#define ATMEL_TC_TIMER_CLOCK2 (1 << 0)
13652 +#define ATMEL_TC_TIMER_CLOCK3 (2 << 0)
13653 +#define ATMEL_TC_TIMER_CLOCK4 (3 << 0)
13654 +#define ATMEL_TC_TIMER_CLOCK5 (4 << 0)
13655 +#define ATMEL_TC_XC0 (5 << 0)
13656 +#define ATMEL_TC_XC1 (6 << 0)
13657 +#define ATMEL_TC_XC2 (7 << 0)
13658 +#define ATMEL_TC_CLKI (1 << 3) /* clock invert */
13659 +#define ATMEL_TC_BURST (3 << 4) /* clock gating */
13660 +#define ATMEL_TC_GATE_NONE (0 << 4)
13661 +#define ATMEL_TC_GATE_XC0 (1 << 4)
13662 +#define ATMEL_TC_GATE_XC1 (2 << 4)
13663 +#define ATMEL_TC_GATE_XC2 (3 << 4)
13664 +#define ATMEL_TC_WAVE (1 << 15) /* true = Waveform mode */
13666 +/* CAPTURE mode CMR bits */
13667 +#define ATMEL_TC_LDBSTOP (1 << 6) /* counter stops on RB load */
13668 +#define ATMEL_TC_LDBDIS (1 << 7) /* counter disable on RB load */
13669 +#define ATMEL_TC_ETRGEDG (3 << 8) /* external trigger edge */
13670 +#define ATMEL_TC_ETRGEDG_NONE (0 << 8)
13671 +#define ATMEL_TC_ETRGEDG_RISING (1 << 8)
13672 +#define ATMEL_TC_ETRGEDG_FALLING (2 << 8)
13673 +#define ATMEL_TC_ETRGEDG_BOTH (3 << 8)
13674 +#define ATMEL_TC_ABETRG (1 << 10) /* external trigger is TIOA? */
13675 +#define ATMEL_TC_CPCTRG (1 << 14) /* RC compare trigger enable */
13676 +#define ATMEL_TC_LDRA (3 << 16) /* RA loading edge (of TIOA) */
13677 +#define ATMEL_TC_LDRA_NONE (0 << 16)
13678 +#define ATMEL_TC_LDRA_RISING (1 << 16)
13679 +#define ATMEL_TC_LDRA_FALLING (2 << 16)
13680 +#define ATMEL_TC_LDRA_BOTH (3 << 16)
13681 +#define ATMEL_TC_LDRB (3 << 18) /* RB loading edge (of TIOA) */
13682 +#define ATMEL_TC_LDRB_NONE (0 << 18)
13683 +#define ATMEL_TC_LDRB_RISING (1 << 18)
13684 +#define ATMEL_TC_LDRB_FALLING (2 << 18)
13685 +#define ATMEL_TC_LDRB_BOTH (3 << 18)
13687 +/* WAVEFORM mode CMR bits */
13688 +#define ATMEL_TC_CPCSTOP (1 << 6) /* RC compare stops counter */
13689 +#define ATMEL_TC_CPCDIS (1 << 7) /* RC compare disables counter */
13690 +#define ATMEL_TC_EEVTEDG (3 << 8) /* external event edge */
13691 +#define ATMEL_TC_EEVTEDG_NONE (0 << 8)
13692 +#define ATMEL_TC_EEVTEDG_RISING (1 << 8)
13693 +#define ATMEL_TC_EEVTEDG_FALLING (2 << 8)
13694 +#define ATMEL_TC_EEVTEDG_BOTH (3 << 8)
13695 +#define ATMEL_TC_EEVT (3 << 10) /* external event source */
13696 +#define ATMEL_TC_EEVT_TIOB (0 << 10)
13697 +#define ATMEL_TC_EEVT_XC0 (1 << 10)
13698 +#define ATMEL_TC_EEVT_XC1 (2 << 10)
13699 +#define ATMEL_TC_EEVT_XC2 (3 << 10)
13700 +#define ATMEL_TC_ENETRG (1 << 12) /* external event is trigger */
13701 +#define ATMEL_TC_WAVESEL (3 << 13) /* waveform type */
13702 +#define ATMEL_TC_WAVESEL_UP (0 << 13)
13703 +#define ATMEL_TC_WAVESEL_UPDOWN (1 << 13)
13704 +#define ATMEL_TC_WAVESEL_UP_AUTO (2 << 13)
13705 +#define ATMEL_TC_WAVESEL_UPDOWN_AUTO (3 << 13)
13706 +#define ATMEL_TC_ACPA (3 << 16) /* RA compare changes TIOA */
13707 +#define ATMEL_TC_ACPA_NONE (0 << 16)
13708 +#define ATMEL_TC_ACPA_SET (1 << 16)
13709 +#define ATMEL_TC_ACPA_CLEAR (2 << 16)
13710 +#define ATMEL_TC_ACPA_TOGGLE (3 << 16)
13711 +#define ATMEL_TC_ACPC (3 << 18) /* RC compare changes TIOA */
13712 +#define ATMEL_TC_ACPC_NONE (0 << 18)
13713 +#define ATMEL_TC_ACPC_SET (1 << 18)
13714 +#define ATMEL_TC_ACPC_CLEAR (2 << 18)
13715 +#define ATMEL_TC_ACPC_TOGGLE (3 << 18)
13716 +#define ATMEL_TC_AEEVT (3 << 20) /* external event changes TIOA */
13717 +#define ATMEL_TC_AEEVT_NONE (0 << 20)
13718 +#define ATMEL_TC_AEEVT_SET (1 << 20)
13719 +#define ATMEL_TC_AEEVT_CLEAR (2 << 20)
13720 +#define ATMEL_TC_AEEVT_TOGGLE (3 << 20)
13721 +#define ATMEL_TC_ASWTRG (3 << 22) /* software trigger changes TIOA */
13722 +#define ATMEL_TC_ASWTRG_NONE (0 << 22)
13723 +#define ATMEL_TC_ASWTRG_SET (1 << 22)
13724 +#define ATMEL_TC_ASWTRG_CLEAR (2 << 22)
13725 +#define ATMEL_TC_ASWTRG_TOGGLE (3 << 22)
13726 +#define ATMEL_TC_BCPB (3 << 24) /* RB compare changes TIOB */
13727 +#define ATMEL_TC_BCPB_NONE (0 << 24)
13728 +#define ATMEL_TC_BCPB_SET (1 << 24)
13729 +#define ATMEL_TC_BCPB_CLEAR (2 << 24)
13730 +#define ATMEL_TC_BCPB_TOGGLE (3 << 24)
13731 +#define ATMEL_TC_BCPC (3 << 26) /* RC compare changes TIOB */
13732 +#define ATMEL_TC_BCPC_NONE (0 << 26)
13733 +#define ATMEL_TC_BCPC_SET (1 << 26)
13734 +#define ATMEL_TC_BCPC_CLEAR (2 << 26)
13735 +#define ATMEL_TC_BCPC_TOGGLE (3 << 26)
13736 +#define ATMEL_TC_BEEVT (3 << 28) /* external event changes TIOB */
13737 +#define ATMEL_TC_BEEVT_NONE (0 << 28)
13738 +#define ATMEL_TC_BEEVT_SET (1 << 28)
13739 +#define ATMEL_TC_BEEVT_CLEAR (2 << 28)
13740 +#define ATMEL_TC_BEEVT_TOGGLE (3 << 28)
13741 +#define ATMEL_TC_BSWTRG (3 << 30) /* software trigger changes TIOB */
13742 +#define ATMEL_TC_BSWTRG_NONE (0 << 30)
13743 +#define ATMEL_TC_BSWTRG_SET (1 << 30)
13744 +#define ATMEL_TC_BSWTRG_CLEAR (2 << 30)
13745 +#define ATMEL_TC_BSWTRG_TOGGLE (3 << 30)
13747 +#define ATMEL_TC_CV 0x10 /* counter Value */
13748 +#define ATMEL_TC_RA 0x14 /* register A */
13749 +#define ATMEL_TC_RB 0x18 /* register B */
13750 +#define ATMEL_TC_RC 0x1c /* register C */
13752 +#define ATMEL_TC_SR 0x20 /* status (read-only) */
13753 +/* Status-only flags */
13754 +#define ATMEL_TC_CLKSTA (1 << 16) /* clock enabled */
13755 +#define ATMEL_TC_MTIOA (1 << 17) /* TIOA mirror */
13756 +#define ATMEL_TC_MTIOB (1 << 18) /* TIOB mirror */
13758 +#define ATMEL_TC_IER 0x24 /* interrupt enable (write-only) */
13759 +#define ATMEL_TC_IDR 0x28 /* interrupt disable (write-only) */
13760 +#define ATMEL_TC_IMR 0x2c /* interrupt mask (read-only) */
13762 +/* Status and IRQ flags */
13763 +#define ATMEL_TC_COVFS (1 << 0) /* counter overflow */
13764 +#define ATMEL_TC_LOVRS (1 << 1) /* load overrun */
13765 +#define ATMEL_TC_CPAS (1 << 2) /* RA compare */
13766 +#define ATMEL_TC_CPBS (1 << 3) /* RB compare */
13767 +#define ATMEL_TC_CPCS (1 << 4) /* RC compare */
13768 +#define ATMEL_TC_LDRAS (1 << 5) /* RA loading */
13769 +#define ATMEL_TC_LDRBS (1 << 6) /* RB loading */
13770 +#define ATMEL_TC_ETRGS (1 << 7) /* external trigger */
13773 --- a/include/linux/fs.h
13774 +++ b/include/linux/fs.h
13775 @@ -1691,6 +1691,8 @@
13776 extern int invalidate_inode_pages2(struct address_space *mapping);
13777 extern int invalidate_inode_pages2_range(struct address_space *mapping,
13778 pgoff_t start, pgoff_t end);
13779 +extern void generic_sync_sb_inodes(struct super_block *sb,
13780 + struct writeback_control *wbc);
13781 extern int write_inode_now(struct inode *, int);
13782 extern int filemap_fdatawrite(struct address_space *);
13783 extern int filemap_flush(struct address_space *);
13785 +++ b/include/linux/usb/atmel_usba_udc.h
13788 + * Platform data definitions for Atmel USBA gadget driver.
13790 +#ifndef __LINUX_USB_USBA_H
13791 +#define __LINUX_USB_USBA_H
13793 +struct usba_ep_data {
13802 +struct usba_platform_data {
13805 + struct usba_ep_data ep[0];
13808 +#endif /* __LINUX_USB_USBA_H */
13809 --- a/include/mtd/Kbuild
13810 +++ b/include/mtd/Kbuild
13812 header-y += mtd-abi.h
13813 header-y += mtd-user.h
13814 header-y += nftl-user.h
13815 -header-y += ubi-header.h
13816 header-y += ubi-user.h
13817 --- a/include/mtd/ubi-header.h
13821 - * Copyright (c) International Business Machines Corp., 2006
13823 - * This program is free software; you can redistribute it and/or modify
13824 - * it under the terms of the GNU General Public License as published by
13825 - * the Free Software Foundation; either version 2 of the License, or
13826 - * (at your option) any later version.
13828 - * This program is distributed in the hope that it will be useful,
13829 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
13830 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13831 - * the GNU General Public License for more details.
13833 - * You should have received a copy of the GNU General Public License
13834 - * along with this program; if not, write to the Free Software
13835 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
13837 - * Authors: Artem Bityutskiy (Битюцкий Артём)
13838 - * Thomas Gleixner
13839 - * Frank Haverkamp
13845 - * This file defines the layout of UBI headers and all the other UBI on-flash
13846 - * data structures. May be included by user-space.
13849 -#ifndef __UBI_HEADER_H__
13850 -#define __UBI_HEADER_H__
13852 -#include <asm/byteorder.h>
13854 -/* The version of UBI images supported by this implementation */
13855 -#define UBI_VERSION 1
13857 -/* The highest erase counter value supported by this implementation */
13858 -#define UBI_MAX_ERASECOUNTER 0x7FFFFFFF
13860 -/* The initial CRC32 value used when calculating CRC checksums */
13861 -#define UBI_CRC32_INIT 0xFFFFFFFFU
13863 -/* Erase counter header magic number (ASCII "UBI#") */
13864 -#define UBI_EC_HDR_MAGIC 0x55424923
13865 -/* Volume identifier header magic number (ASCII "UBI!") */
13866 -#define UBI_VID_HDR_MAGIC 0x55424921
13869 - * Volume type constants used in the volume identifier header.
13871 - * @UBI_VID_DYNAMIC: dynamic volume
13872 - * @UBI_VID_STATIC: static volume
13875 - UBI_VID_DYNAMIC = 1,
13876 - UBI_VID_STATIC = 2
13880 - * Volume flags used in the volume table record.
13882 - * @UBI_VTBL_AUTORESIZE_FLG: auto-resize this volume
13884 - * %UBI_VTBL_AUTORESIZE_FLG flag can be set only for one volume in the volume
13885 - * table. UBI automatically re-sizes the volume which has this flag and makes
13886 - * the volume to be of largest possible size. This means that if after the
13887 - * initialization UBI finds out that there are available physical eraseblocks
13888 - * present on the device, it automatically appends all of them to the volume
13889 - * (the physical eraseblocks reserved for bad eraseblocks handling and other
13890 - * reserved physical eraseblocks are not taken). So, if there is a volume with
13891 - * the %UBI_VTBL_AUTORESIZE_FLG flag set, the amount of available logical
13892 - * eraseblocks will be zero after UBI is loaded, because all of them will be
13893 - * reserved for this volume. Note, the %UBI_VTBL_AUTORESIZE_FLG bit is cleared
13894 - * after the volume had been initialized.
13896 - * The auto-resize feature is useful for device production purposes. For
13897 - * example, different NAND flash chips may have different amount of initial bad
13898 - * eraseblocks, depending of particular chip instance. Manufacturers of NAND
13899 - * chips usually guarantee that the amount of initial bad eraseblocks does not
13900 - * exceed certain percent, e.g. 2%. When one creates an UBI image which will be
13901 - * flashed to the end devices in production, he does not know the exact amount
13902 - * of good physical eraseblocks the NAND chip on the device will have, but this
13903 - * number is required to calculate the volume sized and put them to the volume
13904 - * table of the UBI image. In this case, one of the volumes (e.g., the one
13905 - * which will store the root file system) is marked as "auto-resizable", and
13906 - * UBI will adjust its size on the first boot if needed.
13908 - * Note, first UBI reserves some amount of physical eraseblocks for bad
13909 - * eraseblock handling, and then re-sizes the volume, not vice-versa. This
13910 - * means that the pool of reserved physical eraseblocks will always be present.
13913 - UBI_VTBL_AUTORESIZE_FLG = 0x01,
13917 - * Compatibility constants used by internal volumes.
13919 - * @UBI_COMPAT_DELETE: delete this internal volume before anything is written
13921 - * @UBI_COMPAT_RO: attach this device in read-only mode
13922 - * @UBI_COMPAT_PRESERVE: preserve this internal volume - do not touch its
13923 - * physical eraseblocks, don't allow the wear-leveling unit to move them
13924 - * @UBI_COMPAT_REJECT: reject this UBI image
13927 - UBI_COMPAT_DELETE = 1,
13928 - UBI_COMPAT_RO = 2,
13929 - UBI_COMPAT_PRESERVE = 4,
13930 - UBI_COMPAT_REJECT = 5
13933 -/* Sizes of UBI headers */
13934 -#define UBI_EC_HDR_SIZE sizeof(struct ubi_ec_hdr)
13935 -#define UBI_VID_HDR_SIZE sizeof(struct ubi_vid_hdr)
13937 -/* Sizes of UBI headers without the ending CRC */
13938 -#define UBI_EC_HDR_SIZE_CRC (UBI_EC_HDR_SIZE - sizeof(__be32))
13939 -#define UBI_VID_HDR_SIZE_CRC (UBI_VID_HDR_SIZE - sizeof(__be32))
13942 - * struct ubi_ec_hdr - UBI erase counter header.
13943 - * @magic: erase counter header magic number (%UBI_EC_HDR_MAGIC)
13944 - * @version: version of UBI implementation which is supposed to accept this
13946 - * @padding1: reserved for future, zeroes
13947 - * @ec: the erase counter
13948 - * @vid_hdr_offset: where the VID header starts
13949 - * @data_offset: where the user data start
13950 - * @padding2: reserved for future, zeroes
13951 - * @hdr_crc: erase counter header CRC checksum
13953 - * The erase counter header takes 64 bytes and has a plenty of unused space for
13954 - * future usage. The unused fields are zeroed. The @version field is used to
13955 - * indicate the version of UBI implementation which is supposed to be able to
13956 - * work with this UBI image. If @version is greater then the current UBI
13957 - * version, the image is rejected. This may be useful in future if something
13958 - * is changed radically. This field is duplicated in the volume identifier
13961 - * The @vid_hdr_offset and @data_offset fields contain the offset of the the
13962 - * volume identifier header and user data, relative to the beginning of the
13963 - * physical eraseblock. These values have to be the same for all physical
13966 -struct ubi_ec_hdr {
13969 - __u8 padding1[3];
13970 - __be64 ec; /* Warning: the current limit is 31-bit anyway! */
13971 - __be32 vid_hdr_offset;
13972 - __be32 data_offset;
13973 - __u8 padding2[36];
13975 -} __attribute__ ((packed));
13978 - * struct ubi_vid_hdr - on-flash UBI volume identifier header.
13979 - * @magic: volume identifier header magic number (%UBI_VID_HDR_MAGIC)
13980 - * @version: UBI implementation version which is supposed to accept this UBI
13981 - * image (%UBI_VERSION)
13982 - * @vol_type: volume type (%UBI_VID_DYNAMIC or %UBI_VID_STATIC)
13983 - * @copy_flag: if this logical eraseblock was copied from another physical
13984 - * eraseblock (for wear-leveling reasons)
13985 - * @compat: compatibility of this volume (%0, %UBI_COMPAT_DELETE,
13986 - * %UBI_COMPAT_IGNORE, %UBI_COMPAT_PRESERVE, or %UBI_COMPAT_REJECT)
13987 - * @vol_id: ID of this volume
13988 - * @lnum: logical eraseblock number
13989 - * @leb_ver: version of this logical eraseblock (IMPORTANT: obsolete, to be
13990 - * removed, kept only for not breaking older UBI users)
13991 - * @data_size: how many bytes of data this logical eraseblock contains
13992 - * @used_ebs: total number of used logical eraseblocks in this volume
13993 - * @data_pad: how many bytes at the end of this physical eraseblock are not
13995 - * @data_crc: CRC checksum of the data stored in this logical eraseblock
13996 - * @padding1: reserved for future, zeroes
13997 - * @sqnum: sequence number
13998 - * @padding2: reserved for future, zeroes
13999 - * @hdr_crc: volume identifier header CRC checksum
14001 - * The @sqnum is the value of the global sequence counter at the time when this
14002 - * VID header was created. The global sequence counter is incremented each time
14003 - * UBI writes a new VID header to the flash, i.e. when it maps a logical
14004 - * eraseblock to a new physical eraseblock. The global sequence counter is an
14005 - * unsigned 64-bit integer and we assume it never overflows. The @sqnum
14006 - * (sequence number) is used to distinguish between older and newer versions of
14007 - * logical eraseblocks.
14009 - * There are 2 situations when there may be more then one physical eraseblock
14010 - * corresponding to the same logical eraseblock, i.e., having the same @vol_id
14011 - * and @lnum values in the volume identifier header. Suppose we have a logical
14012 - * eraseblock L and it is mapped to the physical eraseblock P.
14014 - * 1. Because UBI may erase physical eraseblocks asynchronously, the following
14015 - * situation is possible: L is asynchronously erased, so P is scheduled for
14016 - * erasure, then L is written to,i.e. mapped to another physical eraseblock P1,
14017 - * so P1 is written to, then an unclean reboot happens. Result - there are 2
14018 - * physical eraseblocks P and P1 corresponding to the same logical eraseblock
14019 - * L. But P1 has greater sequence number, so UBI picks P1 when it attaches the
14022 - * 2. From time to time UBI moves logical eraseblocks to other physical
14023 - * eraseblocks for wear-leveling reasons. If, for example, UBI moves L from P
14024 - * to P1, and an unclean reboot happens before P is physically erased, there
14025 - * are two physical eraseblocks P and P1 corresponding to L and UBI has to
14026 - * select one of them when the flash is attached. The @sqnum field says which
14027 - * PEB is the original (obviously P will have lower @sqnum) and the copy. But
14028 - * it is not enough to select the physical eraseblock with the higher sequence
14029 - * number, because the unclean reboot could have happen in the middle of the
14030 - * copying process, so the data in P is corrupted. It is also not enough to
14031 - * just select the physical eraseblock with lower sequence number, because the
14032 - * data there may be old (consider a case if more data was added to P1 after
14033 - * the copying). Moreover, the unclean reboot may happen when the erasure of P
14034 - * was just started, so it result in unstable P, which is "mostly" OK, but
14035 - * still has unstable bits.
14037 - * UBI uses the @copy_flag field to indicate that this logical eraseblock is a
14038 - * copy. UBI also calculates data CRC when the data is moved and stores it at
14039 - * the @data_crc field of the copy (P1). So when UBI needs to pick one physical
14040 - * eraseblock of two (P or P1), the @copy_flag of the newer one (P1) is
14041 - * examined. If it is cleared, the situation* is simple and the newer one is
14042 - * picked. If it is set, the data CRC of the copy (P1) is examined. If the CRC
14043 - * checksum is correct, this physical eraseblock is selected (P1). Otherwise
14044 - * the older one (P) is selected.
14046 - * Note, there is an obsolete @leb_ver field which was used instead of @sqnum
14047 - * in the past. But it is not used anymore and we keep it in order to be able
14048 - * to deal with old UBI images. It will be removed at some point.
14050 - * There are 2 sorts of volumes in UBI: user volumes and internal volumes.
14051 - * Internal volumes are not seen from outside and are used for various internal
14052 - * UBI purposes. In this implementation there is only one internal volume - the
14053 - * layout volume. Internal volumes are the main mechanism of UBI extensions.
14054 - * For example, in future one may introduce a journal internal volume. Internal
14055 - * volumes have their own reserved range of IDs.
14057 - * The @compat field is only used for internal volumes and contains the "degree
14058 - * of their compatibility". It is always zero for user volumes. This field
14059 - * provides a mechanism to introduce UBI extensions and to be still compatible
14060 - * with older UBI binaries. For example, if someone introduced a journal in
14061 - * future, he would probably use %UBI_COMPAT_DELETE compatibility for the
14062 - * journal volume. And in this case, older UBI binaries, which know nothing
14063 - * about the journal volume, would just delete this volume and work perfectly
14064 - * fine. This is similar to what Ext2fs does when it is fed by an Ext3fs image
14065 - * - it just ignores the Ext3fs journal.
14067 - * The @data_crc field contains the CRC checksum of the contents of the logical
14068 - * eraseblock if this is a static volume. In case of dynamic volumes, it does
14069 - * not contain the CRC checksum as a rule. The only exception is when the
14070 - * data of the physical eraseblock was moved by the wear-leveling unit, then
14071 - * the wear-leveling unit calculates the data CRC and stores it in the
14072 - * @data_crc field. And of course, the @copy_flag is %in this case.
14074 - * The @data_size field is used only for static volumes because UBI has to know
14075 - * how many bytes of data are stored in this eraseblock. For dynamic volumes,
14076 - * this field usually contains zero. The only exception is when the data of the
14077 - * physical eraseblock was moved to another physical eraseblock for
14078 - * wear-leveling reasons. In this case, UBI calculates CRC checksum of the
14079 - * contents and uses both @data_crc and @data_size fields. In this case, the
14080 - * @data_size field contains data size.
14082 - * The @used_ebs field is used only for static volumes and indicates how many
14083 - * eraseblocks the data of the volume takes. For dynamic volumes this field is
14084 - * not used and always contains zero.
14086 - * The @data_pad is calculated when volumes are created using the alignment
14087 - * parameter. So, effectively, the @data_pad field reduces the size of logical
14088 - * eraseblocks of this volume. This is very handy when one uses block-oriented
14089 - * software (say, cramfs) on top of the UBI volume.
14091 -struct ubi_vid_hdr {
14099 - __be32 leb_ver; /* obsolete, to be removed, don't use */
14100 - __be32 data_size;
14104 - __u8 padding1[4];
14106 - __u8 padding2[12];
14108 -} __attribute__ ((packed));
14110 -/* Internal UBI volumes count */
14111 -#define UBI_INT_VOL_COUNT 1
14114 - * Starting ID of internal volumes. There is reserved room for 4096 internal
14117 -#define UBI_INTERNAL_VOL_START (0x7FFFFFFF - 4096)
14119 -/* The layout volume contains the volume table */
14121 -#define UBI_LAYOUT_VOLUME_ID UBI_INTERNAL_VOL_START
14122 -#define UBI_LAYOUT_VOLUME_TYPE UBI_VID_DYNAMIC
14123 -#define UBI_LAYOUT_VOLUME_ALIGN 1
14124 -#define UBI_LAYOUT_VOLUME_EBS 2
14125 -#define UBI_LAYOUT_VOLUME_NAME "layout volume"
14126 -#define UBI_LAYOUT_VOLUME_COMPAT UBI_COMPAT_REJECT
14128 -/* The maximum number of volumes per one UBI device */
14129 -#define UBI_MAX_VOLUMES 128
14131 -/* The maximum volume name length */
14132 -#define UBI_VOL_NAME_MAX 127
14134 -/* Size of the volume table record */
14135 -#define UBI_VTBL_RECORD_SIZE sizeof(struct ubi_vtbl_record)
14137 -/* Size of the volume table record without the ending CRC */
14138 -#define UBI_VTBL_RECORD_SIZE_CRC (UBI_VTBL_RECORD_SIZE - sizeof(__be32))
14141 - * struct ubi_vtbl_record - a record in the volume table.
14142 - * @reserved_pebs: how many physical eraseblocks are reserved for this volume
14143 - * @alignment: volume alignment
14144 - * @data_pad: how many bytes are unused at the end of the each physical
14145 - * eraseblock to satisfy the requested alignment
14146 - * @vol_type: volume type (%UBI_DYNAMIC_VOLUME or %UBI_STATIC_VOLUME)
14147 - * @upd_marker: if volume update was started but not finished
14148 - * @name_len: volume name length
14149 - * @name: the volume name
14150 - * @flags: volume flags (%UBI_VTBL_AUTORESIZE_FLG)
14151 - * @padding: reserved, zeroes
14152 - * @crc: a CRC32 checksum of the record
14154 - * The volume table records are stored in the volume table, which is stored in
14155 - * the layout volume. The layout volume consists of 2 logical eraseblock, each
14156 - * of which contains a copy of the volume table (i.e., the volume table is
14157 - * duplicated). The volume table is an array of &struct ubi_vtbl_record
14158 - * objects indexed by the volume ID.
14160 - * If the size of the logical eraseblock is large enough to fit
14161 - * %UBI_MAX_VOLUMES records, the volume table contains %UBI_MAX_VOLUMES
14162 - * records. Otherwise, it contains as many records as it can fit (i.e., size of
14163 - * logical eraseblock divided by sizeof(struct ubi_vtbl_record)).
14165 - * The @upd_marker flag is used to implement volume update. It is set to %1
14166 - * before update and set to %0 after the update. So if the update operation was
14167 - * interrupted, UBI knows that the volume is corrupted.
14169 - * The @alignment field is specified when the volume is created and cannot be
14170 - * later changed. It may be useful, for example, when a block-oriented file
14171 - * system works on top of UBI. The @data_pad field is calculated using the
14172 - * logical eraseblock size and @alignment. The alignment must be multiple to the
14173 - * minimal flash I/O unit. If @alignment is 1, all the available space of
14174 - * the physical eraseblocks is used.
14176 - * Empty records contain all zeroes and the CRC checksum of those zeroes.
14178 -struct ubi_vtbl_record {
14179 - __be32 reserved_pebs;
14180 - __be32 alignment;
14185 - __u8 name[UBI_VOL_NAME_MAX+1];
14187 - __u8 padding[23];
14189 -} __attribute__ ((packed));
14191 -#endif /* !__UBI_HEADER_H__ */
14192 --- a/init/do_mounts.c
14193 +++ b/init/do_mounts.c
14194 @@ -126,8 +126,14 @@
14196 static int __init rootwait_setup(char *str)
14199 + if (*str && *str != '=')
14203 + printk(KERN_WARNING
14204 + "WARNING: \"rootwait=1\" is deprecated, "
14205 + "use \"rootwait\" instead.\n");
14210 @@ -347,7 +353,8 @@
14212 if (saved_root_name[0]) {
14213 root_device_name = saved_root_name;
14214 - if (!strncmp(root_device_name, "mtd", 3)) {
14215 + if (!strncmp(root_device_name, "mtd", 3) ||
14216 + !strncmp(root_device_name, "ubi", 3)) {
14217 mount_block_root(root_device_name, root_mountflags);
14221 +++ b/localversion-atmel
14225 +++ b/sound/avr32/ac97c.c
14228 + * Driver for the Atmel AC97 controller
14230 + * Copyright (C) 2005-2007 Atmel Corporation
14232 + * This program is free software; you can redistribute it and/or modify it
14233 + * under the terms of the GNU General Public License version 2 as published by
14234 + * the Free Software Foundation.
14236 +#include <linux/clk.h>
14237 +#include <linux/delay.h>
14238 +#include <linux/dma-mapping.h>
14239 +#include <linux/init.h>
14240 +#include <linux/interrupt.h>
14241 +#include <linux/module.h>
14242 +#include <linux/platform_device.h>
14243 +#include <linux/mutex.h>
14244 +#include <linux/io.h>
14246 +#include <sound/driver.h>
14247 +#include <sound/core.h>
14248 +#include <sound/initval.h>
14249 +#include <sound/pcm.h>
14250 +#include <sound/pcm_params.h>
14251 +#include <sound/ac97_codec.h>
14252 +#include <sound/memalloc.h>
14254 +#include <asm/dma-controller.h>
14256 +#include "ac97c.h"
14258 +/* Serialize access to opened */
14259 +static DEFINE_MUTEX(opened_mutex);
14261 +struct atmel_ac97_dma_info {
14262 + struct dma_request_cyclic req_tx;
14263 + struct dma_request_cyclic req_rx;
14264 + unsigned short rx_periph_id;
14265 + unsigned short tx_periph_id;
14268 +struct atmel_ac97 {
14269 + /* Serialize access to opened */
14271 + void __iomem *regs;
14272 + struct snd_pcm_substream *playback_substream;
14273 + struct snd_pcm_substream *capture_substream;
14274 + struct snd_card *card;
14275 + struct snd_pcm *pcm;
14276 + struct snd_ac97 *ac97;
14277 + struct snd_ac97_bus *ac97_bus;
14281 + unsigned int cur_rate;
14283 + struct platform_device *pdev;
14284 + struct atmel_ac97_dma_info dma;
14287 +#define get_chip(card) ((struct atmel_ac97 *)(card)->private_data)
14289 +#define ac97c_writel(chip, reg, val) \
14290 + __raw_writel((val), (chip)->regs + AC97C_##reg)
14291 +#define ac97c_readl(chip, reg) \
14292 + __raw_readl((chip)->regs + AC97C_##reg)
14297 +static struct snd_pcm_hardware snd_atmel_ac97_playback_hw = {
14298 + .info = (SNDRV_PCM_INFO_INTERLEAVED
14299 + | SNDRV_PCM_INFO_MMAP
14300 + | SNDRV_PCM_INFO_MMAP_VALID
14301 + | SNDRV_PCM_INFO_BLOCK_TRANSFER
14302 + | SNDRV_PCM_INFO_JOINT_DUPLEX),
14303 + .formats = (SNDRV_PCM_FMTBIT_S16_BE
14304 + | SNDRV_PCM_FMTBIT_S16_LE),
14305 + .rates = (SNDRV_PCM_RATE_CONTINUOUS),
14306 + .rate_min = 4000,
14307 + .rate_max = 48000,
14308 + .channels_min = 1,
14309 + .channels_max = 6,
14310 + .buffer_bytes_max = 64*1024,
14311 + .period_bytes_min = 512,
14312 + .period_bytes_max = 4095,
14313 + .periods_min = 8,
14314 + .periods_max = 1024,
14317 +static struct snd_pcm_hardware snd_atmel_ac97_capture_hw = {
14318 + .info = (SNDRV_PCM_INFO_INTERLEAVED
14319 + | SNDRV_PCM_INFO_MMAP
14320 + | SNDRV_PCM_INFO_MMAP_VALID
14321 + | SNDRV_PCM_INFO_BLOCK_TRANSFER
14322 + | SNDRV_PCM_INFO_JOINT_DUPLEX),
14323 + .formats = (SNDRV_PCM_FMTBIT_S16_BE
14324 + | SNDRV_PCM_FMTBIT_S16_LE),
14325 + .rates = (SNDRV_PCM_RATE_CONTINUOUS),
14326 + .rate_min = 4000,
14327 + .rate_max = 48000,
14328 + .channels_min = 1,
14329 + .channels_max = 2,
14330 + .buffer_bytes_max = 64*1024,
14331 + .period_bytes_min = 512,
14332 + .period_bytes_max = 4095,
14333 + .periods_min = 8,
14334 + .periods_max = 1024,
14341 +snd_atmel_ac97_playback_open(struct snd_pcm_substream *substream)
14343 + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
14344 + struct snd_pcm_runtime *runtime = substream->runtime;
14346 + mutex_lock(&opened_mutex);
14348 + runtime->hw = snd_atmel_ac97_playback_hw;
14349 + if (chip->cur_rate) {
14350 + runtime->hw.rate_min = chip->cur_rate;
14351 + runtime->hw.rate_max = chip->cur_rate;
14353 + if (chip->cur_format)
14354 + runtime->hw.formats = (1ULL << chip->cur_format);
14355 + mutex_unlock(&opened_mutex);
14356 + chip->playback_substream = substream;
14357 + chip->period = 0;
14362 +snd_atmel_ac97_capture_open(struct snd_pcm_substream *substream)
14364 + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
14365 + struct snd_pcm_runtime *runtime = substream->runtime;
14367 + mutex_lock(&opened_mutex);
14369 + runtime->hw = snd_atmel_ac97_capture_hw;
14370 + if (chip->cur_rate) {
14371 + runtime->hw.rate_min = chip->cur_rate;
14372 + runtime->hw.rate_max = chip->cur_rate;
14374 + if (chip->cur_format)
14375 + runtime->hw.formats = (1ULL << chip->cur_format);
14376 + mutex_unlock(&opened_mutex);
14377 + chip->capture_substream = substream;
14378 + chip->period = 0;
14382 +static int snd_atmel_ac97_playback_close(struct snd_pcm_substream *substream)
14384 + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
14385 + mutex_lock(&opened_mutex);
14387 + if (!chip->opened) {
14388 + chip->cur_rate = 0;
14389 + chip->cur_format = 0;
14391 + mutex_unlock(&opened_mutex);
14395 +static int snd_atmel_ac97_capture_close(struct snd_pcm_substream *substream)
14397 + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
14398 + mutex_lock(&opened_mutex);
14400 + if (!chip->opened) {
14401 + chip->cur_rate = 0;
14402 + chip->cur_format = 0;
14404 + mutex_unlock(&opened_mutex);
14409 +snd_atmel_ac97_playback_hw_params(struct snd_pcm_substream *substream,
14410 + struct snd_pcm_hw_params *hw_params)
14412 + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
14415 + err = snd_pcm_lib_malloc_pages(substream,
14416 + params_buffer_bytes(hw_params));
14420 + /* Set restrictions to params */
14421 + mutex_lock(&opened_mutex);
14422 + chip->cur_rate = params_rate(hw_params);
14423 + chip->cur_format = params_format(hw_params);
14424 + mutex_unlock(&opened_mutex);
14430 +snd_atmel_ac97_capture_hw_params(struct snd_pcm_substream *substream,
14431 + struct snd_pcm_hw_params *hw_params)
14433 + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
14436 + err = snd_pcm_lib_malloc_pages(substream,
14437 + params_buffer_bytes(hw_params));
14441 + /* Set restrictions to params */
14442 + mutex_lock(&opened_mutex);
14443 + chip->cur_rate = params_rate(hw_params);
14444 + chip->cur_format = params_format(hw_params);
14445 + mutex_unlock(&opened_mutex);
14450 +static int snd_atmel_ac97_playback_hw_free(struct snd_pcm_substream *substream)
14452 + return snd_pcm_lib_free_pages(substream);
14455 +static int snd_atmel_ac97_capture_hw_free(struct snd_pcm_substream *substream)
14458 + return snd_pcm_lib_free_pages(substream);
14461 +static int snd_atmel_ac97_playback_prepare(struct snd_pcm_substream *substream)
14463 + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
14464 + struct platform_device *pdev = chip->pdev;
14465 + struct snd_pcm_runtime *runtime = substream->runtime;
14466 + int block_size = frames_to_bytes(runtime, runtime->period_size);
14467 + unsigned long word = 0;
14468 + unsigned long buffer_size = 0;
14470 + dma_sync_single_for_device(&pdev->dev, runtime->dma_addr,
14471 + block_size * 2, DMA_TO_DEVICE);
14473 + /* Assign slots to channels */
14474 + switch (substream->runtime->channels) {
14476 + word |= AC97C_CH_ASSIGN(PCM_LEFT, A);
14479 + /* Assign Left and Right slot to Channel A */
14480 + word |= AC97C_CH_ASSIGN(PCM_LEFT, A)
14481 + | AC97C_CH_ASSIGN(PCM_RIGHT, A);
14484 + /* TODO: support more than two channels */
14488 + ac97c_writel(chip, OCA, word);
14490 + /* Configure sample format and size */
14491 + word = AC97C_CMR_PDCEN | AC97C_CMR_SIZE_16;
14493 + switch (runtime->format) {
14494 + case SNDRV_PCM_FORMAT_S16_LE:
14495 + word |= AC97C_CMR_CEM_LITTLE;
14497 + case SNDRV_PCM_FORMAT_S16_BE: /* fall through */
14499 + word &= ~AC97C_CMR_CEM_LITTLE;
14503 + ac97c_writel(chip, CAMR, word);
14505 + /* Set variable rate if needed */
14506 + if (runtime->rate != 48000) {
14507 + word = ac97c_readl(chip, MR);
14508 + word |= AC97C_MR_VRA;
14509 + ac97c_writel(chip, MR, word);
14511 + /* Clear Variable Rate Bit */
14512 + word = ac97c_readl(chip, MR);
14513 + word &= ~AC97C_MR_VRA;
14514 + ac97c_writel(chip, MR, word);
14518 + snd_ac97_set_rate(chip->ac97, AC97_PCM_FRONT_DAC_RATE, runtime->rate);
14520 + buffer_size = frames_to_bytes(runtime, runtime->period_size) *
14521 + runtime->periods;
14523 + chip->dma.req_tx.buffer_size = buffer_size;
14524 + chip->dma.req_tx.periods = runtime->periods;
14526 + BUG_ON(chip->dma.req_tx.buffer_size !=
14527 + (chip->dma.req_tx.periods *
14528 + frames_to_bytes(runtime, runtime->period_size)));
14530 + chip->dma.req_tx.buffer_start = runtime->dma_addr;
14531 + chip->dma.req_tx.data_reg = (dma_addr_t)(chip->regs + AC97C_CATHR + 2);
14532 + chip->dma.req_tx.periph_id = chip->dma.tx_periph_id;
14533 + chip->dma.req_tx.direction = DMA_DIR_MEM_TO_PERIPH;
14534 + chip->dma.req_tx.width = DMA_WIDTH_16BIT;
14535 + chip->dma.req_tx.dev_id = chip;
14540 +static int snd_atmel_ac97_capture_prepare(struct snd_pcm_substream *substream)
14542 + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
14543 + struct platform_device *pdev = chip->pdev;
14544 + struct snd_pcm_runtime *runtime = substream->runtime;
14545 + int block_size = frames_to_bytes(runtime, runtime->period_size);
14546 + unsigned long word = 0;
14547 + unsigned long buffer_size = 0;
14549 + dma_sync_single_for_device(&pdev->dev, runtime->dma_addr,
14550 + block_size * 2, DMA_FROM_DEVICE);
14552 + /* Assign slots to channels */
14553 + switch (substream->runtime->channels) {
14555 + word |= AC97C_CH_ASSIGN(PCM_LEFT, A);
14558 + /* Assign Left and Right slot to Channel A */
14559 + word |= AC97C_CH_ASSIGN(PCM_LEFT, A)
14560 + | AC97C_CH_ASSIGN(PCM_RIGHT, A);
14563 + /* TODO: support more than two channels */
14567 + ac97c_writel(chip, ICA, word);
14569 + /* Configure sample format and size */
14570 + word = AC97C_CMR_PDCEN | AC97C_CMR_SIZE_16;
14572 + switch (runtime->format) {
14573 + case SNDRV_PCM_FORMAT_S16_LE:
14574 + word |= AC97C_CMR_CEM_LITTLE;
14576 + case SNDRV_PCM_FORMAT_S16_BE:
14578 + word &= ~(AC97C_CMR_CEM_LITTLE);
14582 + ac97c_writel(chip, CAMR, word);
14584 + /* Set variable rate if needed */
14585 + if (runtime->rate != 48000) {
14586 + word = ac97c_readl(chip, MR);
14587 + word |= AC97C_MR_VRA;
14588 + ac97c_writel(chip, MR, word);
14590 + /* Clear Variable Rate Bit */
14591 + word = ac97c_readl(chip, MR);
14592 + word &= ~(AC97C_MR_VRA);
14593 + ac97c_writel(chip, MR, word);
14597 + snd_ac97_set_rate(chip->ac97, AC97_PCM_LR_ADC_RATE, runtime->rate);
14599 + buffer_size = frames_to_bytes(runtime, runtime->period_size) *
14600 + runtime->periods;
14602 + chip->dma.req_rx.buffer_size = buffer_size;
14603 + chip->dma.req_rx.periods = runtime->periods;
14605 + BUG_ON(chip->dma.req_rx.buffer_size !=
14606 + (chip->dma.req_rx.periods *
14607 + frames_to_bytes(runtime, runtime->period_size)));
14609 + chip->dma.req_rx.buffer_start = runtime->dma_addr;
14610 + chip->dma.req_rx.data_reg = (dma_addr_t)(chip->regs + AC97C_CARHR + 2);
14611 + chip->dma.req_rx.periph_id = chip->dma.rx_periph_id;
14612 + chip->dma.req_rx.direction = DMA_DIR_PERIPH_TO_MEM;
14613 + chip->dma.req_rx.width = DMA_WIDTH_16BIT;
14614 + chip->dma.req_rx.dev_id = chip;
14620 +snd_atmel_ac97_playback_trigger(struct snd_pcm_substream *substream, int cmd)
14622 + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
14623 + unsigned long camr;
14624 + int flags, err = 0;
14626 + spin_lock_irqsave(&chip->lock, flags);
14627 + camr = ac97c_readl(chip, CAMR);
14630 + case SNDRV_PCM_TRIGGER_START:
14631 + err = dma_prepare_request_cyclic(chip->dma.req_tx.req.dmac,
14632 + &chip->dma.req_tx);
14633 + dma_start_request(chip->dma.req_tx.req.dmac,
14634 + chip->dma.req_tx.req.channel);
14635 + camr |= AC97C_CMR_CENA;
14637 + case SNDRV_PCM_TRIGGER_STOP:
14638 + err = dma_stop_request(chip->dma.req_tx.req.dmac,
14639 + chip->dma.req_tx.req.channel);
14640 + if (chip->opened <= 1)
14641 + camr &= ~AC97C_CMR_CENA;
14648 + ac97c_writel(chip, CAMR, camr);
14650 + spin_unlock_irqrestore(&chip->lock, flags);
14655 +snd_atmel_ac97_capture_trigger(struct snd_pcm_substream *substream, int cmd)
14657 + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
14658 + unsigned long camr;
14659 + int flags, err = 0;
14661 + spin_lock_irqsave(&chip->lock, flags);
14662 + camr = ac97c_readl(chip, CAMR);
14665 + case SNDRV_PCM_TRIGGER_START:
14666 + err = dma_prepare_request_cyclic(chip->dma.req_rx.req.dmac,
14667 + &chip->dma.req_rx);
14668 + dma_start_request(chip->dma.req_rx.req.dmac,
14669 + chip->dma.req_rx.req.channel);
14670 + camr |= AC97C_CMR_CENA;
14672 + case SNDRV_PCM_TRIGGER_STOP:
14673 + err = dma_stop_request(chip->dma.req_rx.req.dmac,
14674 + chip->dma.req_rx.req.channel);
14675 + mutex_lock(&opened_mutex);
14676 + if (chip->opened <= 1)
14677 + camr &= ~AC97C_CMR_CENA;
14678 + mutex_unlock(&opened_mutex);
14685 + ac97c_writel(chip, CAMR, camr);
14687 + spin_unlock_irqrestore(&chip->lock, flags);
14691 + static snd_pcm_uframes_t
14692 +snd_atmel_ac97_playback_pointer(struct snd_pcm_substream *substream)
14694 + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
14695 + struct snd_pcm_runtime *runtime = substream->runtime;
14696 + snd_pcm_uframes_t pos;
14697 + unsigned long bytes;
14699 + bytes = (dma_get_current_pos
14700 + (chip->dma.req_tx.req.dmac,
14701 + chip->dma.req_tx.req.channel) - runtime->dma_addr);
14702 + pos = bytes_to_frames(runtime, bytes);
14703 + if (pos >= runtime->buffer_size)
14704 + pos -= runtime->buffer_size;
14709 + static snd_pcm_uframes_t
14710 +snd_atmel_ac97_capture_pointer(struct snd_pcm_substream *substream)
14712 + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
14713 + struct snd_pcm_runtime *runtime = substream->runtime;
14714 + snd_pcm_uframes_t pos;
14715 + unsigned long bytes;
14717 + bytes = (dma_get_current_pos
14718 + (chip->dma.req_rx.req.dmac,
14719 + chip->dma.req_rx.req.channel)
14720 + - runtime->dma_addr);
14721 + pos = bytes_to_frames(runtime, bytes);
14722 + if (pos >= runtime->buffer_size)
14723 + pos -= runtime->buffer_size;
14729 +static struct snd_pcm_ops atmel_ac97_playback_ops = {
14730 + .open = snd_atmel_ac97_playback_open,
14731 + .close = snd_atmel_ac97_playback_close,
14732 + .ioctl = snd_pcm_lib_ioctl,
14733 + .hw_params = snd_atmel_ac97_playback_hw_params,
14734 + .hw_free = snd_atmel_ac97_playback_hw_free,
14735 + .prepare = snd_atmel_ac97_playback_prepare,
14736 + .trigger = snd_atmel_ac97_playback_trigger,
14737 + .pointer = snd_atmel_ac97_playback_pointer,
14740 +static struct snd_pcm_ops atmel_ac97_capture_ops = {
14741 + .open = snd_atmel_ac97_capture_open,
14742 + .close = snd_atmel_ac97_capture_close,
14743 + .ioctl = snd_pcm_lib_ioctl,
14744 + .hw_params = snd_atmel_ac97_capture_hw_params,
14745 + .hw_free = snd_atmel_ac97_capture_hw_free,
14746 + .prepare = snd_atmel_ac97_capture_prepare,
14747 + .trigger = snd_atmel_ac97_capture_trigger,
14748 + .pointer = snd_atmel_ac97_capture_pointer,
14751 +static struct ac97_pcm atmel_ac97_pcm_defs[] __devinitdata = {
14756 + .slots = ((1 << AC97_SLOT_PCM_LEFT)
14757 + | (1 << AC97_SLOT_PCM_RIGHT)
14758 + | (1 << AC97_SLOT_PCM_CENTER)
14759 + | (1 << AC97_SLOT_PCM_SLEFT)
14760 + | (1 << AC97_SLOT_PCM_SRIGHT)
14761 + | (1 << AC97_SLOT_LFE)),
14769 + .slots = ((1 << AC97_SLOT_PCM_LEFT)
14770 + | (1 << AC97_SLOT_PCM_RIGHT)),
14778 + .slots = (1<<AC97_SLOT_MIC),
14783 +static int __devinit snd_atmel_ac97_pcm_new(struct atmel_ac97 *chip)
14785 + struct snd_pcm *pcm;
14788 + err = snd_ac97_pcm_assign(chip->ac97_bus,
14789 + ARRAY_SIZE(atmel_ac97_pcm_defs),
14790 + atmel_ac97_pcm_defs);
14794 + err = snd_pcm_new(chip->card, "Atmel-AC97", 0, 1, 1, &pcm);
14798 + snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
14799 + &atmel_ac97_playback_ops);
14801 + snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
14802 + &atmel_ac97_capture_ops);
14804 + snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
14805 + &chip->pdev->dev,
14806 + 128 * 1024, 128 * 1024);
14808 + pcm->private_data = chip;
14809 + pcm->info_flags = 0;
14810 + strcpy(pcm->name, "Atmel-AC97");
14819 +static int snd_atmel_ac97_mixer_new(struct atmel_ac97 *chip)
14822 + struct snd_ac97_template template;
14824 + memset(&template, 0, sizeof(template));
14825 + template.private_data = chip;
14826 + err = snd_ac97_mixer(chip->ac97_bus, &template, &chip->ac97);
14831 +static void atmel_ac97_error(struct dma_request *_req)
14833 + struct dma_request_cyclic *req = to_dma_request_cyclic(_req);
14834 + struct atmel_ac97 *chip = req->dev_id;
14836 + dev_dbg(&chip->pdev->dev, "DMA Controller error, channel %d\n",
14837 + req->req.channel);
14840 +static void atmel_ac97_block_complete(struct dma_request *_req)
14842 + struct dma_request_cyclic *req = to_dma_request_cyclic(_req);
14843 + struct atmel_ac97 *chip = req->dev_id;
14844 + if (req->periph_id == chip->dma.tx_periph_id)
14845 + snd_pcm_period_elapsed(chip->playback_substream);
14847 + snd_pcm_period_elapsed(chip->capture_substream);
14853 +static void snd_atmel_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
14854 + unsigned short val)
14856 + struct atmel_ac97 *chip = get_chip(ac97);
14857 + unsigned long word;
14858 + int timeout = 40;
14860 + word = (reg & 0x7f) << 16 | val;
14863 + if (ac97c_readl(chip, COSR) & AC97C_CSR_TXRDY) {
14864 + ac97c_writel(chip, COTHR, word);
14868 + } while (--timeout);
14870 + dev_dbg(&chip->pdev->dev, "codec write timeout\n");
14873 +static unsigned short snd_atmel_ac97_read(struct snd_ac97 *ac97,
14874 + unsigned short reg)
14876 + struct atmel_ac97 *chip = get_chip(ac97);
14877 + unsigned long word;
14878 + int timeout = 40;
14881 + word = (0x80 | (reg & 0x7f)) << 16;
14883 + if ((ac97c_readl(chip, COSR) & AC97C_CSR_RXRDY) != 0)
14884 + ac97c_readl(chip, CORHR);
14890 + if ((ac97c_readl(chip, COSR) & AC97C_CSR_TXRDY) != 0) {
14891 + ac97c_writel(chip, COTHR, word);
14895 + } while (--timeout);
14899 + goto retry_write;
14903 + if ((ac97c_readl(chip, COSR) & AC97C_CSR_RXRDY) != 0) {
14904 + unsigned short val = ac97c_readl(chip, CORHR);
14908 + } while (--timeout);
14912 + goto retry_write;
14915 + dev_dbg(&chip->pdev->dev, "codec read timeout\n");
14919 +static void snd_atmel_ac97_reset(struct atmel_ac97 *chip)
14921 + ac97c_writel(chip, MR, AC97C_MR_WRST);
14923 + ac97c_writel(chip, MR, AC97C_MR_ENA);
14926 +static void snd_atmel_ac97_destroy(struct snd_card *card)
14928 + struct atmel_ac97 *chip = get_chip(card);
14931 + iounmap(chip->regs);
14934 + clk_disable(chip->mck);
14935 + clk_put(chip->mck);
14938 + if (chip->dma.req_tx.req.dmac) {
14939 + dma_release_channel(chip->dma.req_tx.req.dmac,
14940 + chip->dma.req_tx.req.channel);
14942 + if (chip->dma.req_rx.req.dmac) {
14943 + dma_release_channel(chip->dma.req_rx.req.dmac,
14944 + chip->dma.req_rx.req.channel);
14948 +static int __devinit snd_atmel_ac97_create(struct snd_card *card,
14949 + struct platform_device *pdev)
14951 + static struct snd_ac97_bus_ops ops = {
14952 + .write = snd_atmel_ac97_write,
14953 + .read = snd_atmel_ac97_read,
14955 + struct atmel_ac97 *chip = get_chip(card);
14956 + struct resource *regs;
14960 + regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
14964 + mck = clk_get(&pdev->dev, "pclk");
14966 + return PTR_ERR(mck);
14970 + card->private_free = snd_atmel_ac97_destroy;
14972 + spin_lock_init(&chip->lock);
14973 + chip->card = card;
14974 + chip->pdev = pdev;
14976 + chip->regs = ioremap(regs->start, regs->end - regs->start + 1);
14980 + snd_card_set_dev(card, &pdev->dev);
14982 + err = snd_ac97_bus(card, 0, &ops, chip, &chip->ac97_bus);
14987 +static int __devinit snd_atmel_ac97_probe(struct platform_device *pdev)
14990 + struct snd_card *card;
14991 + struct atmel_ac97 *chip;
14995 + mutex_init(&opened_mutex);
14998 + card = snd_card_new(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
14999 + THIS_MODULE, sizeof(struct atmel_ac97));
15002 + chip = get_chip(card);
15004 + err = snd_atmel_ac97_create(card, pdev);
15006 + goto out_free_card;
15008 + snd_atmel_ac97_reset(chip);
15010 + err = snd_atmel_ac97_mixer_new(chip);
15012 + goto out_free_card;
15014 + err = snd_atmel_ac97_pcm_new(chip);
15016 + goto out_free_card;
15018 + /* TODO: Get this information from the platform device */
15019 + chip->dma.req_tx.req.dmac = find_dma_controller(0);
15020 + if (!chip->dma.req_tx.req.dmac) {
15021 + dev_dbg(&chip->pdev->dev, "DMA controller for TX missing\n");
15023 + goto out_free_card;
15025 + chip->dma.req_rx.req.dmac = find_dma_controller(0);
15026 + if (!chip->dma.req_rx.req.dmac) {
15027 + dev_dbg(&chip->pdev->dev, "DMA controller for RX missing\n");
15029 + goto out_free_card;
15032 + chip->dma.rx_periph_id = 3;
15033 + chip->dma.tx_periph_id = 4;
15035 + ch = dma_alloc_channel(chip->dma.req_tx.req.dmac);
15037 + dev_dbg(&chip->pdev->dev,
15038 + "could not allocate TX DMA channel\n");
15040 + goto out_free_card;
15042 + chip->dma.req_tx.req.channel = ch;
15043 + chip->dma.req_tx.width = DMA_WIDTH_16BIT;
15044 + chip->dma.req_tx.req.block_complete = atmel_ac97_block_complete;
15045 + chip->dma.req_tx.req.error = atmel_ac97_error;
15047 + ch = dma_alloc_channel(chip->dma.req_rx.req.dmac);
15049 + dev_dbg(&chip->pdev->dev,
15050 + "could not allocate RX DMA channel\n");
15052 + goto out_free_card;
15054 + chip->dma.req_rx.req.channel = ch;
15055 + chip->dma.req_rx.width = DMA_WIDTH_16BIT;
15056 + chip->dma.req_rx.req.block_complete = atmel_ac97_block_complete;
15057 + chip->dma.req_rx.req.error = atmel_ac97_error;
15059 + strcpy(card->driver, "atmel_ac97c");
15060 + strcpy(card->shortname, "atmel_ac97c");
15061 + sprintf(card->longname, "Atmel AVR32 AC97 controller");
15063 + err = snd_card_register(card);
15065 + goto out_free_card;
15067 + platform_set_drvdata(pdev, card);
15070 + dev_info(&pdev->dev, "Atmel AVR32 AC97 controller at 0x%p\n",
15076 + snd_card_free(card);
15083 +snd_atmel_ac97_suspend(struct platform_device *pdev, pm_message_t msg)
15085 + struct snd_card *card = platform_get_drvdata(pdev);
15086 + struct atmel_ac97 *chip = card->private_data;
15088 + clk_disable(chip->mck);
15093 +static int snd_atmel_ac97_resume(struct platform_device *pdev)
15095 + struct snd_card *card = dev_get_drvdata(pdev);
15096 + struct atmel_ac97 *chip = card->private_data;
15098 + clk_enable(chip->mck);
15103 +#define snd_atmel_ac97_suspend NULL
15104 +#define snd_atmel_ac97_resume NULL
15107 +static int __devexit snd_atmel_ac97_remove(struct platform_device *pdev)
15109 + struct snd_card *card = platform_get_drvdata(pdev);
15111 + snd_card_free(card);
15112 + platform_set_drvdata(pdev, NULL);
15116 +static struct platform_driver atmel_ac97_driver = {
15117 + .remove = __devexit_p(snd_atmel_ac97_remove),
15119 + .name = "atmel_ac97c",
15121 + .suspend = snd_atmel_ac97_suspend,
15122 + .resume = snd_atmel_ac97_resume,
15125 +static int __init atmel_ac97_init(void)
15127 + return platform_driver_probe(&atmel_ac97_driver,
15128 + snd_atmel_ac97_probe);
15130 +module_init(atmel_ac97_init);
15132 +static void __exit atmel_ac97_exit(void)
15134 + platform_driver_unregister(&atmel_ac97_driver);
15136 +module_exit(atmel_ac97_exit);
15138 +MODULE_LICENSE("GPL");
15139 +MODULE_DESCRIPTION("Driver for Atmel AC97 Controller");
15140 +MODULE_AUTHOR("Haavard Skinnemoen <hskinnemoen@atmel.com>");
15142 +++ b/sound/avr32/ac97c.h
15145 + * Register definitions for the Atmel AC97 Controller.
15147 + * Copyright (C) 2005-2006 Atmel Corporation
15149 + * This program is free software; you can redistribute it and/or modify
15150 + * it under the terms of the GNU General Public License version 2 as
15151 + * published by the Free Software Foundation.
15153 +#ifndef __SOUND_AVR32_AC97C_H
15154 +#define __SOUND_AVR32_AC97C_H
15156 +#define AC97C_MR 0x08
15157 +#define AC97C_ICA 0x10
15158 +#define AC97C_OCA 0x14
15159 +#define AC97C_CARHR 0x20
15160 +#define AC97C_CATHR 0x24
15161 +#define AC97C_CASR 0x28
15162 +#define AC97C_CAMR 0x2c
15163 +#define AC97C_CBRHR 0x30
15164 +#define AC97C_CBTHR 0x34
15165 +#define AC97C_CBSR 0x38
15166 +#define AC97C_CBMR 0x3c
15167 +#define AC97C_CORHR 0x40
15168 +#define AC97C_COTHR 0x44
15169 +#define AC97C_COSR 0x48
15170 +#define AC97C_COMR 0x4c
15171 +#define AC97C_SR 0x50
15172 +#define AC97C_IER 0x54
15173 +#define AC97C_IDR 0x58
15174 +#define AC97C_IMR 0x5c
15175 +#define AC97C_VERSION 0xfc
15177 +#define AC97C_CATPR PDC_TPR
15178 +#define AC97C_CATCR PDC_TCR
15179 +#define AC97C_CATNPR PDC_TNPR
15180 +#define AC97C_CATNCR PDC_TNCR
15181 +#define AC97C_CARPR PDC_RPR
15182 +#define AC97C_CARCR PDC_RCR
15183 +#define AC97C_CARNPR PDC_RNPR
15184 +#define AC97C_CARNCR PDC_RNCR
15185 +#define AC97C_PTCR PDC_PTCR
15187 +#define AC97C_MR_ENA (1 << 0)
15188 +#define AC97C_MR_WRST (1 << 1)
15189 +#define AC97C_MR_VRA (1 << 2)
15191 +#define AC97C_CSR_TXRDY (1 << 0)
15192 +#define AC97C_CSR_UNRUN (1 << 2)
15193 +#define AC97C_CSR_RXRDY (1 << 4)
15194 +#define AC97C_CSR_ENDTX (1 << 10)
15195 +#define AC97C_CSR_ENDRX (1 << 14)
15197 +#define AC97C_CMR_SIZE_20 (0 << 16)
15198 +#define AC97C_CMR_SIZE_18 (1 << 16)
15199 +#define AC97C_CMR_SIZE_16 (2 << 16)
15200 +#define AC97C_CMR_SIZE_10 (3 << 16)
15201 +#define AC97C_CMR_CEM_LITTLE (1 << 18)
15202 +#define AC97C_CMR_CEM_BIG (0 << 18)
15203 +#define AC97C_CMR_CENA (1 << 21)
15204 +#define AC97C_CMR_PDCEN (1 << 22)
15206 +#define AC97C_SR_CAEVT (1 << 3)
15208 +#define AC97C_CH_ASSIGN(slot, channel) \
15209 + (AC97C_CHANNEL_##channel << (3 * (AC97_SLOT_##slot - 3)))
15210 +#define AC97C_CHANNEL_NONE 0x0
15211 +#define AC97C_CHANNEL_A 0x1
15212 +#define AC97C_CHANNEL_B 0x2
15214 +#endif /* __SOUND_AVR32_AC97C_H */
15216 +++ b/sound/avr32/Kconfig
15218 +menu "AVR32 devices"
15219 + depends on SND != n && AVR32
15221 +config SND_ATMEL_AC97
15222 + tristate "Atmel AC97 Controller Driver"
15224 + select SND_AC97_CODEC
15226 + ALSA sound driver for the Atmel AC97 controller.
15230 +++ b/sound/avr32/Makefile
15232 +snd-atmel-ac97-objs := ac97c.o
15234 +obj-$(CONFIG_SND_ATMEL_AC97) += snd-atmel-ac97.o
15235 --- a/sound/Kconfig
15236 +++ b/sound/Kconfig
15239 source "sound/arm/Kconfig"
15241 +source "sound/avr32/Kconfig"
15244 source "sound/spi/Kconfig"
15246 --- a/sound/Makefile
15247 +++ b/sound/Makefile
15249 obj-$(CONFIG_SOUND_PRIME) += oss/
15250 obj-$(CONFIG_DMASOUND) += oss/
15251 obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ sh/ synth/ usb/ \
15252 - sparc/ spi/ parisc/ pcmcia/ mips/ soc/
15253 + sparc/ spi/ parisc/ pcmcia/ mips/ soc/ avr32/
15254 obj-$(CONFIG_SND_AOA) += aoa/
15256 # This one must be compilable even if sound is configured out
15258 +++ b/sound/oss/at32_abdac.c
15261 + * OSS Sound Driver for the Atmel AT32 on-chip DAC.
15263 + * Copyright (C) 2006 Atmel Corporation
15265 + * This program is free software; you can redistribute it and/or modify
15266 + * it under the terms of the GNU General Public License version 2 as
15267 + * published by the Free Software Foundation.
15269 +#include <linux/clk.h>
15270 +#include <linux/dma-mapping.h>
15271 +#include <linux/fs.h>
15272 +#include <linux/init.h>
15273 +#include <linux/interrupt.h>
15274 +#include <linux/kernel.h>
15275 +#include <linux/module.h>
15276 +#include <linux/platform_device.h>
15277 +#include <linux/sound.h>
15278 +#include <linux/soundcard.h>
15280 +#include <asm/byteorder.h>
15281 +#include <asm/dma-controller.h>
15282 +#include <asm/io.h>
15283 +#include <asm/uaccess.h>
15285 +/* We want to use the "bizarre" swap-bytes-in-each-halfword macro */
15286 +#include <linux/byteorder/swabb.h>
15288 +#include "at32_abdac.h"
15290 +#define DMA_BUFFER_SIZE 32768
15291 +#define DMA_PERIOD_SHIFT 10
15292 +#define DMA_PERIOD_SIZE (1 << DMA_PERIOD_SHIFT)
15293 +#define DMA_WRITE_THRESHOLD DMA_PERIOD_SIZE
15295 +struct sound_settings {
15296 + unsigned int format;
15297 + unsigned int channels;
15298 + unsigned int sample_rate;
15299 + /* log2(bytes per sample) */
15300 + unsigned int input_order;
15305 + void __iomem *regs;
15307 + /* head and tail refer to number of words */
15314 + struct semaphore sem;
15315 + wait_queue_head_t write_wait;
15318 + * Read at most ucount bytes from ubuf, translate to 2-channel
15319 + * signed 16-bit big endian format and write to the DMA buffer
15320 + * as long as there is room left. Return the number of bytes
15321 + * successfully copied from ubuf, or -EFAULT if the first
15322 + * sample from ubuf couldn't be read. This function is not
15323 + * called unless there is room for at least one sample (4
15324 + * bytes) in the DMA buffer.
15326 + ssize_t (*trans)(struct at32_dac *dac, const char __user *ubuf,
15329 + struct sound_settings dsp_settings;
15330 + struct dma_request_cyclic req;
15333 + struct clk *sample_clk;
15334 + struct platform_device *pdev;
15339 +static struct at32_dac *the_dac;
15341 +static inline unsigned int abdac_get_head(struct at32_dac *dac)
15343 + return dac->dma.head & ((DMA_BUFFER_SIZE / 4) - 1);
15346 +static inline unsigned int abdac_get_tail(struct at32_dac *dac)
15348 + return dac->dma.tail & ((DMA_BUFFER_SIZE / 4) - 1);
15351 +static inline unsigned int abdac_dma_space(struct at32_dac *dac)
15353 + unsigned int space;
15355 + space = ((dac->dma.tail - dac->dma.head - 1)
15356 + & ((DMA_BUFFER_SIZE / 4) - 1));
15360 +static void abdac_update_dma_tail(struct at32_dac *dac)
15362 + dma_addr_t dma_addr;
15363 + unsigned int new_tail;
15365 + if (dac->playing) {
15366 + dma_addr = dma_get_current_pos(dac->req.req.dmac,
15367 + dac->req.req.channel);
15368 + new_tail = (dma_addr - dac->req.buffer_start) / 4;
15369 + if (new_tail >= dac->dma.head
15370 + && (dac->dma.tail < dac->dma.head
15371 + || dac->dma.tail > new_tail))
15372 + dev_notice(&dac->pdev->dev, "DMA underrun detected!\n");
15373 + dac->dma.tail = new_tail;
15374 + dev_dbg(&dac->pdev->dev, "update tail: 0x%x - 0x%x = %u\n",
15375 + dma_addr, dac->req.buffer_start, dac->dma.tail);
15379 +static int abdac_start(struct at32_dac *dac)
15383 + if (dac->playing)
15386 + memset(dac->dma.buf, 0, DMA_BUFFER_SIZE);
15388 + clk_enable(dac->sample_clk);
15390 + ret = dma_prepare_request_cyclic(dac->req.req.dmac, &dac->req);
15392 + goto out_stop_clock;
15394 + dev_dbg(&dac->pdev->dev, "starting DMA...\n");
15395 + ret = dma_start_request(dac->req.req.dmac, dac->req.req.channel);
15397 + goto out_stop_request;
15399 + dac_writel(dac, CTRL, DAC_BIT(EN));
15400 + dac->playing = 1;
15405 + dma_stop_request(dac->req.req.dmac,
15406 + dac->req.req.channel);
15408 + clk_disable(dac->sample_clk);
15412 +static int abdac_stop(struct at32_dac *dac)
15414 + if (dac->playing) {
15415 + dma_stop_request(dac->req.req.dmac, dac->req.req.channel);
15416 + dac_writel(dac, DATA, 0);
15417 + dac_writel(dac, CTRL, 0);
15418 + dac->playing = 0;
15419 + clk_disable(dac->sample_clk);
15425 +static int abdac_dma_prepare(struct at32_dac *dac)
15427 + dac->dma.buf = dma_alloc_coherent(&dac->pdev->dev, DMA_BUFFER_SIZE,
15428 + &dac->req.buffer_start, GFP_KERNEL);
15429 + if (!dac->dma.buf)
15432 + dac->dma.head = dac->dma.tail = 0;
15433 + dac->req.periods = DMA_BUFFER_SIZE / DMA_PERIOD_SIZE;
15434 + dac->req.buffer_size = DMA_BUFFER_SIZE;
15439 +static void abdac_dma_cleanup(struct at32_dac *dac)
15441 + if (dac->dma.buf)
15442 + dma_free_coherent(&dac->pdev->dev, DMA_BUFFER_SIZE,
15443 + dac->dma.buf, dac->req.buffer_start);
15444 + dac->dma.buf = NULL;
15447 +static void abdac_dma_block_complete(struct dma_request *req)
15449 + struct dma_request_cyclic *creq = to_dma_request_cyclic(req);
15450 + struct at32_dac *dac = container_of(creq, struct at32_dac, req);
15452 + wake_up(&dac->write_wait);
15455 +static void abdac_dma_error(struct dma_request *req)
15457 + struct dma_request_cyclic *creq = to_dma_request_cyclic(req);
15458 + struct at32_dac *dac = container_of(creq, struct at32_dac, req);
15460 + dev_err(&dac->pdev->dev, "DMA error\n");
15463 +static irqreturn_t abdac_interrupt(int irq, void *dev_id)
15465 + struct at32_dac *dac = dev_id;
15468 + status = dac_readl(dac, INT_STATUS);
15469 + if (status & DAC_BIT(UNDERRUN)) {
15470 + dev_err(&dac->pdev->dev, "Underrun detected!\n");
15471 + dac_writel(dac, INT_CLR, DAC_BIT(UNDERRUN));
15473 + dev_err(&dac->pdev->dev, "Spurious interrupt (status=0x%x)\n",
15475 + dac_writel(dac, INT_CLR, status);
15478 + return IRQ_HANDLED;
15481 +static ssize_t trans_s16be(struct at32_dac *dac, const char __user *ubuf,
15486 + if (dac->dsp_settings.channels == 2) {
15487 + const u32 __user *up = (const u32 __user *)ubuf;
15490 + for (ret = 0; ret < (ssize_t)(ucount - 3); ret += 4) {
15491 + if (!abdac_dma_space(dac))
15494 + if (unlikely(__get_user(sample, up++))) {
15499 + dac->dma.buf[abdac_get_head(dac)] = sample;
15503 + const u16 __user *up = (const u16 __user *)ubuf;
15506 + for (ret = 0; ret < (ssize_t)(ucount - 1); ret += 2) {
15507 + if (!abdac_dma_space(dac))
15510 + if (unlikely(__get_user(sample, up++))) {
15515 + dac->dma.buf[abdac_get_head(dac)]
15516 + = (sample << 16) | sample;
15524 +static ssize_t trans_s16le(struct at32_dac *dac, const char __user *ubuf,
15529 + if (dac->dsp_settings.channels == 2) {
15530 + const u32 __user *up = (const u32 __user *)ubuf;
15533 + for (ret = 0; ret < (ssize_t)(ucount - 3); ret += 4) {
15534 + if (!abdac_dma_space(dac))
15537 + if (unlikely(__get_user(sample, up++))) {
15542 + /* Swap bytes in each halfword */
15543 + dac->dma.buf[abdac_get_head(dac)] = swahb32(sample);
15547 + const u16 __user *up = (const u16 __user *)ubuf;
15550 + for (ret = 0; ret < (ssize_t)(ucount - 1); ret += 2) {
15551 + if (!abdac_dma_space(dac))
15554 + if (unlikely(__get_user(sample, up++))) {
15559 + sample = swab16(sample);
15560 + dac->dma.buf[abdac_get_head(dac)]
15561 + = (sample << 16) | sample;
15569 +static ssize_t abdac_dma_translate_from_user(struct at32_dac *dac,
15570 + const char __user *buffer,
15573 + /* At least one buffer must be available at this point */
15574 + dev_dbg(&dac->pdev->dev, "copying %zu bytes from user...\n", count);
15576 + return dac->trans(dac, buffer, count);
15579 +static int abdac_set_format(struct at32_dac *dac, int format)
15581 + unsigned int order;
15583 + switch (format) {
15584 + case AFMT_S16_BE:
15586 + dac->trans = trans_s16be;
15588 + case AFMT_S16_LE:
15590 + dac->trans = trans_s16le;
15593 + dev_dbg(&dac->pdev->dev, "unsupported format: %d\n", format);
15597 + if (dac->dsp_settings.channels == 2)
15600 + dac->dsp_settings.input_order = order;
15601 + dac->dsp_settings.format = format;
15605 +static int abdac_set_sample_rate(struct at32_dac *dac, unsigned long rate)
15607 + unsigned long new_rate;
15610 + ret = clk_set_rate(dac->sample_clk, 256 * rate);
15614 + /* TODO: mplayer seems to have a problem with this */
15616 + new_rate = clk_get_rate(dac->sample_clk);
15617 + dac->dsp_settings.sample_rate = new_rate / 256;
15619 + dac->dsp_settings.sample_rate = rate;
15625 +static ssize_t abdac_dsp_write(struct file *file,
15626 + const char __user *buffer,
15627 + size_t count, loff_t *ppos)
15629 + struct at32_dac *dac = file->private_data;
15630 + DECLARE_WAITQUEUE(wait, current);
15631 + unsigned int avail;
15635 + /* Avoid address space checking in the translation functions */
15636 + if (!access_ok(buffer, count, VERIFY_READ))
15641 + if (!dac->dma.buf) {
15642 + ret = abdac_dma_prepare(dac);
15647 + add_wait_queue(&dac->write_wait, &wait);
15649 + while (count > 0) {
15651 + abdac_update_dma_tail(dac);
15652 + avail = abdac_dma_space(dac);
15653 + set_current_state(TASK_INTERRUPTIBLE);
15654 + if (avail >= DMA_WRITE_THRESHOLD)
15657 + if (file->f_flags & O_NONBLOCK) {
15663 + pr_debug("Going to wait (avail = %u, count = %zu)\n",
15668 + if (signal_pending(current)) {
15670 + ret = -ERESTARTSYS;
15676 + copied = abdac_dma_translate_from_user(dac, buffer, count);
15677 + if (copied < 0) {
15683 + abdac_start(dac);
15692 + remove_wait_queue(&dac->write_wait, &wait);
15693 + set_current_state(TASK_RUNNING);
15697 +static int abdac_dsp_ioctl(struct inode *inode, struct file *file,
15698 + unsigned int cmd, unsigned long arg)
15700 + struct at32_dac *dac = file->private_data;
15701 + int __user *up = (int __user *)arg;
15702 + struct audio_buf_info abinfo;
15706 + case OSS_GETVERSION:
15707 + return put_user(SOUND_VERSION, up);
15709 + case SNDCTL_DSP_SPEED:
15710 + if (get_user(val, up))
15714 + ret = abdac_set_sample_rate(dac, val);
15718 + return put_user(dac->dsp_settings.sample_rate, up);
15720 + case SNDCTL_DSP_STEREO:
15721 + if (get_user(val, up))
15724 + if (val && dac->dsp_settings.channels == 1)
15725 + dac->dsp_settings.input_order++;
15726 + else if (!val && dac->dsp_settings.channels != 1)
15727 + dac->dsp_settings.input_order--;
15728 + dac->dsp_settings.channels = val ? 2 : 1;
15731 + case SNDCTL_DSP_CHANNELS:
15732 + if (get_user(val, up))
15736 + if (val < 0 || val > 2)
15740 + dac->dsp_settings.input_order
15741 + += val - dac->dsp_settings.channels;
15742 + dac->dsp_settings.channels = val;
15744 + return put_user(val, (int *)arg);
15746 + case SNDCTL_DSP_GETFMTS:
15747 + return put_user(AFMT_S16_BE | AFMT_S16_BE, up);
15749 + case SNDCTL_DSP_SETFMT:
15750 + if (get_user(val, up))
15753 + if (val == AFMT_QUERY) {
15754 + val = dac->dsp_settings.format;
15756 + ret = abdac_set_format(dac, val);
15760 + return put_user(val, up);
15762 + case SNDCTL_DSP_GETOSPACE:
15763 + abdac_update_dma_tail(dac);
15764 + abinfo.fragsize = ((1 << dac->dsp_settings.input_order)
15765 + * (DMA_PERIOD_SIZE / 4));
15766 + abinfo.bytes = (abdac_dma_space(dac)
15767 + << dac->dsp_settings.input_order);
15768 + abinfo.fragstotal = ((DMA_BUFFER_SIZE * 4)
15769 + >> (DMA_PERIOD_SHIFT
15770 + + dac->dsp_settings.input_order));
15771 + abinfo.fragments = ((abinfo.bytes
15772 + >> dac->dsp_settings.input_order)
15773 + / (DMA_PERIOD_SIZE / 4));
15774 + pr_debug("fragments=%d fragstotal=%d fragsize=%d bytes=%d\n",
15775 + abinfo.fragments, abinfo.fragstotal, abinfo.fragsize,
15777 + return copy_to_user(up, &abinfo, sizeof(abinfo)) ? -EFAULT : 0;
15780 + dev_dbg(&dac->pdev->dev, "Unimplemented ioctl cmd: 0x%x\n", cmd);
15785 +static int abdac_dsp_open(struct inode *inode, struct file *file)
15787 + struct at32_dac *dac = the_dac;
15790 + if (file->f_mode & FMODE_READ)
15798 + dac->dma.head = dac->dma.tail = 0;
15800 + /* FIXME: What are the correct defaults? */
15801 + dac->dsp_settings.channels = 2;
15802 + abdac_set_format(dac, AFMT_S16_BE);
15803 + ret = abdac_set_sample_rate(dac, 8000);
15807 + file->private_data = dac;
15817 +static int abdac_dsp_release(struct inode *inode, struct file *file)
15819 + struct at32_dac *dac = file->private_data;
15824 + abdac_dma_cleanup(dac);
15832 +static struct file_operations abdac_dsp_fops = {
15833 + .owner = THIS_MODULE,
15834 + .llseek = no_llseek,
15835 + .write = abdac_dsp_write,
15836 + .ioctl = abdac_dsp_ioctl,
15837 + .open = abdac_dsp_open,
15838 + .release = abdac_dsp_release,
15841 +static int __init abdac_probe(struct platform_device *pdev)
15843 + struct at32_dac *dac;
15844 + struct resource *regs;
15846 + struct clk *sample_clk;
15853 + regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
15856 + irq = platform_get_irq(pdev, 0);
15860 + mck = clk_get(&pdev->dev, "pclk");
15862 + return PTR_ERR(mck);
15863 + sample_clk = clk_get(&pdev->dev, "sample_clk");
15864 + if (IS_ERR(sample_clk)) {
15865 + ret = PTR_ERR(sample_clk);
15866 + goto out_put_mck;
15871 + dac = kzalloc(sizeof(struct at32_dac), GFP_KERNEL);
15873 + goto out_disable_clk;
15875 + spin_lock_init(&dac->lock);
15876 + init_MUTEX(&dac->sem);
15877 + init_waitqueue_head(&dac->write_wait);
15878 + dac->pdev = pdev;
15880 + dac->sample_clk = sample_clk;
15882 + dac->regs = ioremap(regs->start, regs->end - regs->start + 1);
15884 + goto out_free_dac;
15886 + ret = request_irq(irq, abdac_interrupt, 0, "dac", dac);
15888 + goto out_unmap_regs;
15891 + dac->req.req.dmac = find_dma_controller(0);
15892 + if (!dac->req.req.dmac)
15893 + goto out_free_irq;
15895 + ret = dma_alloc_channel(dac->req.req.dmac);
15897 + goto out_free_irq;
15899 + dac->req.req.channel = ret;
15900 + dac->req.req.block_complete = abdac_dma_block_complete;
15901 + dac->req.req.error = abdac_dma_error;
15902 + dac->req.data_reg = regs->start + DAC_DATA;
15903 + dac->req.periph_id = 2; /* FIXME */
15904 + dac->req.direction = DMA_DIR_MEM_TO_PERIPH;
15905 + dac->req.width = DMA_WIDTH_32BIT;
15907 + /* Make sure the DAC is silent and disabled */
15908 + dac_writel(dac, DATA, 0);
15909 + dac_writel(dac, CTRL, 0);
15911 + ret = register_sound_dsp(&abdac_dsp_fops, -1);
15913 + goto out_free_dma;
15914 + dac->dev_dsp = ret;
15916 + /* TODO: Register mixer */
15919 + platform_set_drvdata(pdev, dac);
15924 + dma_release_channel(dac->req.req.dmac, dac->req.req.channel);
15926 + free_irq(irq, dac);
15928 + iounmap(dac->regs);
15932 + clk_disable(mck);
15933 + clk_put(sample_clk);
15939 +static int __exit abdac_remove(struct platform_device *pdev)
15941 + struct at32_dac *dac;
15943 + dac = platform_get_drvdata(pdev);
15945 + unregister_sound_dsp(dac->dev_dsp);
15946 + dma_release_channel(dac->req.req.dmac, dac->req.req.channel);
15947 + free_irq(platform_get_irq(pdev, 0), dac);
15948 + iounmap(dac->regs);
15949 + clk_disable(dac->mck);
15950 + clk_put(dac->sample_clk);
15951 + clk_put(dac->mck);
15953 + platform_set_drvdata(pdev, NULL);
15960 +static struct platform_driver abdac_driver = {
15961 + .remove = __exit_p(abdac_remove),
15967 +static int __init abdac_init(void)
15969 + return platform_driver_probe(&abdac_driver, abdac_probe);
15971 +module_init(abdac_init);
15973 +static void __exit abdac_exit(void)
15975 + platform_driver_unregister(&abdac_driver);
15977 +module_exit(abdac_exit);
15979 +MODULE_AUTHOR("Haavard Skinnemoen <hskinnemoen@atmel.com>");
15980 +MODULE_DESCRIPTION("Sound Driver for the Atmel AT32 ABDAC");
15981 +MODULE_LICENSE("GPL");
15983 +++ b/sound/oss/at32_abdac.h
15986 + * Register definitions for the Atmel AT32 on-chip DAC.
15988 + * Copyright (C) 2006 Atmel Corporation
15990 + * This program is free software; you can redistribute it and/or modify
15991 + * it under the terms of the GNU General Public License version 2 as
15992 + * published by the Free Software Foundation.
15994 +#ifndef __SOUND_OSS_AT32_ABDAC_H__
15995 +#define __SOUND_OSS_AT32_ABDAC_H__
15997 +/* DAC register offsets */
15998 +#define DAC_DATA 0x0000
15999 +#define DAC_CTRL 0x0008
16000 +#define DAC_INT_MASK 0x000c
16001 +#define DAC_INT_EN 0x0010
16002 +#define DAC_INT_DIS 0x0014
16003 +#define DAC_INT_CLR 0x0018
16004 +#define DAC_INT_STATUS 0x001c
16005 +#define DAC_PDC_DATA 0x0020
16007 +/* Bitfields in CTRL */
16008 +#define DAC_SWAP_OFFSET 30
16009 +#define DAC_SWAP_SIZE 1
16010 +#define DAC_EN_OFFSET 31
16011 +#define DAC_EN_SIZE 1
16013 +/* Bitfields in INT_MASK/INT_EN/INT_DIS/INT_STATUS/INT_CLR */
16014 +#define DAC_UNDERRUN_OFFSET 28
16015 +#define DAC_UNDERRUN_SIZE 1
16016 +#define DAC_TX_READY_OFFSET 29
16017 +#define DAC_TX_READY_SIZE 1
16018 +#define DAC_TX_BUFFER_EMPTY_OFFSET 30
16019 +#define DAC_TX_BUFFER_EMPTY_SIZE 1
16020 +#define DAC_CHANNEL_TX_END_OFFSET 31
16021 +#define DAC_CHANNEL_TX_END_SIZE 1
16023 +/* Bit manipulation macros */
16024 +#define DAC_BIT(name) \
16025 + (1 << DAC_##name##_OFFSET)
16026 +#define DAC_BF(name, value) \
16027 + (((value) & ((1 << DAC_##name##_SIZE) - 1)) \
16028 + << DAC_##name##_OFFSET)
16029 +#define DAC_BFEXT(name, value) \
16030 + (((value) >> DAC_##name##_OFFSET) \
16031 + & ((1 << DAC_##name##_SIZE) - 1))
16032 +#define DAC_BFINS(name, value, old) \
16033 + (((old) & ~(((1 << DAC_##name##_SIZE) - 1) \
16034 + << DAC_##name##_OFFSET)) \
16035 + | DAC_BF(name,value))
16037 +/* Register access macros */
16038 +#define dac_readl(port, reg) \
16039 + __raw_readl((port)->regs + DAC_##reg)
16040 +#define dac_writel(port, reg, value) \
16041 + __raw_writel((value), (port)->regs + DAC_##reg)
16043 +#endif /* __SOUND_OSS_AT32_ABDAC_H__ */
16044 --- a/sound/oss/Kconfig
16045 +++ b/sound/oss/Kconfig
16046 @@ -654,3 +654,7 @@
16049 depends on SOUND_SH_DAC_AUDIO
16051 +config SOUND_AT32_ABDAC
16052 + tristate "Atmel AT32 Audio Bitstream DAC (ABDAC) support"
16053 + depends on SOUND_PRIME && AVR32
16054 --- a/sound/oss/Makefile
16055 +++ b/sound/oss/Makefile
16058 # Please leave it as is, cause the link order is significant !
16060 +obj-$(CONFIG_SOUND_AT32_ABDAC) += at32_abdac.o
16061 obj-$(CONFIG_SOUND_SH_DAC_AUDIO) += sh_dac_audio.o
16062 obj-$(CONFIG_SOUND_HAL2) += hal2.o
16063 obj-$(CONFIG_SOUND_AEDSP16) += aedsp16.o
16064 --- a/sound/spi/at73c213.c
16065 +++ b/sound/spi/at73c213.c
16066 @@ -737,7 +737,7 @@
16070 -static int snd_at73c213_ssc_init(struct snd_at73c213 *chip)
16071 +static int __devinit snd_at73c213_ssc_init(struct snd_at73c213 *chip)
16074 * Continuous clock output.
16075 @@ -767,7 +767,7 @@
16079 -static int snd_at73c213_chip_init(struct snd_at73c213 *chip)
16080 +static int __devinit snd_at73c213_chip_init(struct snd_at73c213 *chip)
16083 unsigned char dac_ctrl = 0;
16084 @@ -933,7 +933,7 @@
16088 -static int snd_at73c213_probe(struct spi_device *spi)
16089 +static int __devinit snd_at73c213_probe(struct spi_device *spi)
16091 struct snd_card *card;
16092 struct snd_at73c213 *chip;