1 --- a/arch/arm/mach-at91/Kconfig
2 +++ b/arch/arm/mach-at91/Kconfig
3 @@ -12,18 +12,28 @@ config ARCH_AT91RM9200
5 config ARCH_AT91SAM9260
6 bool "AT91SAM9260 or AT91SAM9XE"
8 + select GENERIC_CLOCKEVENTS
10 config ARCH_AT91SAM9261
13 + select GENERIC_CLOCKEVENTS
15 config ARCH_AT91SAM9263
18 + select GENERIC_CLOCKEVENTS
20 config ARCH_AT91SAM9RL
23 + select GENERIC_CLOCKEVENTS
28 + select GENERIC_CLOCKEVENTS
32 @@ -45,7 +55,7 @@ config MACH_ONEARM
33 depends on ARCH_AT91RM9200
35 Select this if you are using Ajeco's 1ARM Single Board Computer.
36 - <http://www.ajeco.fi/products.htm>
37 + <http://www.ajeco.fi/eng/products_e.htm>
39 config ARCH_AT91RM9200DK
40 bool "Atmel AT91RM9200-DK Development board"
41 @@ -94,7 +104,7 @@ config MACH_KB9200
42 depends on ARCH_AT91RM9200
44 Select this if you are using KwikByte's KB920x board.
45 - <http://kwikbyte.com/KB9202_description_new.htm>
46 + <http://www.kwikbyte.com/KB9202.html>
48 config MACH_PICOTUX2XX
50 @@ -109,6 +119,38 @@ config MACH_KAFA
52 Select this if you are using Sperry-Sun's KAFA board.
55 + bool "Promwad Chub board"
56 + depends on ARCH_AT91RM9200
58 + Select this if you are using Promwad's Chub board.
60 +config MACH_HOMEMATIC
61 + bool "eQ-3 HomeMatic"
62 + depends on ARCH_AT91RM9200
64 + Select this if you are using eQ-3's HomeMatic device.
65 + <http://www.eq-3.com>
68 + bool "emQbit ECB_AT91 SBC"
69 + depends on ARCH_AT91RM9200
71 + Select this if you are using emQbit's ECB_AT91 board.
72 + <http://wiki.emqbit.com/free-ecb-at91>
75 + bool "Sweda TMS Board"
76 + depends on ARCH_AT91RM9200
78 + Select this if you are using Sweda TMS-100 board.
81 + bool "Toptech TT9200"
82 + depends on ARCH_AT91RM9200
84 + Select this if you are using Toptech's TT9200 board.
88 # ----------------------------------------------------------
89 @@ -133,6 +175,34 @@ config MACH_AT91SAM9260EK
90 Select this if you are using Atmel's AT91SAM9260-EK or AT91SAM9XE Evaluation Kit
91 <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3933>
94 + bool "KwikByte KB9260 (CAM60) board"
95 + depends on ARCH_AT91SAM9260
97 + Select this if you are using KwikByte's KB9260 (CAM60) board based on the Atmel AT91SAM9260.
98 + <http://www.kwikbyte.com/KB9260.html>
100 +config MACH_SAM9_L9260
101 + bool "Olimex SAM9-L9260 board"
102 + depends on ARCH_AT91SAM9260
104 + Select this if you are using Olimex's SAM9-L9260 board based on the Atmel AT91SAM9260.
105 + <http://www.olimex.com/dev/sam9-L9260.html>
107 +config MACH_USB_A9260
108 + bool "CALAO USB-A9260"
109 + depends on ARCH_AT91SAM9260
111 + Select this if you are using a Calao Systems USB-A9260.
112 + <http://www.calao-systems.com>
114 +config MACH_QIL_A9260
115 + bool "CALAO QIL-A9260 board"
116 + depends on ARCH_AT91SAM9260
118 + Select this if you are using a Calao Systems QIL-A9260 Board.
119 + <http://www.calao-systems.com>
123 # ----------------------------------------------------------
124 @@ -163,6 +233,13 @@ config MACH_AT91SAM9263EK
125 Select this if you are using Atmel's AT91SAM9263-EK Evaluation Kit.
126 <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=4057>
128 +config MACH_USB_A9263
129 + bool "CALAO USB-A9263"
130 + depends on ARCH_AT91SAM9263
132 + Select this if you are using a Calao Systems USB-A9263.
133 + <http://www.calao-systems.com>
137 # ----------------------------------------------------------
138 @@ -216,7 +293,7 @@ comment "AT91 Board Options"
140 config MTD_AT91_DATAFLASH_CARD
141 bool "Enable DataFlash Card support"
142 - depends on (ARCH_AT91RM9200DK || MACH_AT91RM9200EK || MACH_AT91SAM9260EK || MACH_AT91SAM9261EK || MACH_AT91SAM9263EK || MACH_AT91CAP9ADK)
143 + depends on (ARCH_AT91RM9200DK || MACH_AT91RM9200EK || MACH_AT91SAM9260EK || MACH_AT91SAM9261EK || MACH_AT91SAM9263EK || MACH_ECBAT91 || MACH_SAM9_L9260 || MACH_AT91CAP9ADK)
145 Enable support for the DataFlash card.
147 @@ -237,6 +314,19 @@ config AT91_PROGRAMMABLE_CLOCKS
148 Select this if you need to program one or more of the PCK0..PCK3
149 programmable clock outputs.
151 +config AT91_SLOW_CLOCK
152 + bool "Suspend-to-RAM disables main oscillator"
155 + Select this if you want Suspend-to-RAM to save the most power
156 + possible (without powering off the CPU) by disabling the PLLs
157 + and main oscillator so that only the 32 KiHz clock is available.
159 + When only that slow-clock is available, some peripherals lose
160 + functionality. Many can't issue wakeup events unless faster
161 + clocks are available. Some lose their operating state and
162 + need to be completely re-initialized.
165 int "Kernel HZ (jiffies per second)"
167 --- a/arch/arm/mach-at91/Makefile
168 +++ b/arch/arm/mach-at91/Makefile
169 @@ -28,16 +28,26 @@ obj-$(CONFIG_MACH_CARMEVA) += board-carm
170 obj-$(CONFIG_MACH_KB9200) += board-kb9202.o
171 obj-$(CONFIG_MACH_ATEB9200) += board-eb9200.o
172 obj-$(CONFIG_MACH_KAFA) += board-kafa.o
173 +obj-$(CONFIG_MACH_CHUB) += board-chub.o
174 obj-$(CONFIG_MACH_PICOTUX2XX) += board-picotux200.o
175 +obj-$(CONFIG_MACH_HOMEMATIC) += board-homematic.o
176 +obj-$(CONFIG_MACH_ECBAT91) += board-ecbat91.o
177 +obj-$(CONFIG_MACH_SWEDATMS) += board-tms.o
178 +obj-$(CONFIG_MACH_TT9200) += board-tt9200.o
180 # AT91SAM9260 board-specific support
181 obj-$(CONFIG_MACH_AT91SAM9260EK) += board-sam9260ek.o
182 +obj-$(CONFIG_MACH_CAM60) += board-cam60.o
183 +obj-$(CONFIG_MACH_SAM9_L9260) += board-sam9-l9260.o
184 +obj-$(CONFIG_MACH_USB_A9260) += board-usb-a9260.o
185 +obj-$(CONFIG_MACH_QIL_A9260) += board-qil-a9260.o
187 # AT91SAM9261 board-specific support
188 obj-$(CONFIG_MACH_AT91SAM9261EK) += board-sam9261ek.o
190 # AT91SAM9263 board-specific support
191 obj-$(CONFIG_MACH_AT91SAM9263EK) += board-sam9263ek.o
192 +obj-$(CONFIG_MACH_USB_A9263) += board-usb-a9263.o
194 # AT91SAM9RL board-specific support
195 obj-$(CONFIG_MACH_AT91SAM9RLEK) += board-sam9rlek.o
196 @@ -50,9 +60,11 @@ obj-$(CONFIG_MACH_AT91EB01) += board-eb0
200 +obj-$(CONFIG_FB_S1D13XXX) += ics1523.o
203 obj-$(CONFIG_PM) += pm.o
204 +obj-$(CONFIG_AT91_SLOW_CLOCK) += pm_slowclock.o
206 ifeq ($(CONFIG_PM_DEBUG),y)
207 CFLAGS_pm.o += -DDEBUG
208 --- a/arch/arm/mach-at91/at91cap9.c
209 +++ b/arch/arm/mach-at91/at91cap9.c
213 #include <linux/module.h>
214 +#include <linux/pm.h>
216 #include <asm/mach/arch.h>
217 #include <asm/mach/map.h>
218 +#include <asm/arch/cpu.h>
219 #include <asm/arch/at91cap9.h>
220 #include <asm/arch/at91_pmc.h>
221 #include <asm/arch/at91_rstc.h>
222 +#include <asm/arch/at91_shdwc.h>
226 @@ -288,6 +291,12 @@ static void at91cap9_reset(void)
227 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
230 +static void at91cap9_poweroff(void)
232 + at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
236 /* --------------------------------------------------------------------
237 * AT91CAP9 processor initialization
238 * -------------------------------------------------------------------- */
239 @@ -298,6 +307,7 @@ void __init at91cap9_initialize(unsigned
240 iotable_init(at91cap9_io_desc, ARRAY_SIZE(at91cap9_io_desc));
242 at91_arch_reset = at91cap9_reset;
243 + pm_power_off = at91cap9_poweroff;
244 at91_extern_irq = (1 << AT91CAP9_ID_IRQ0) | (1 << AT91CAP9_ID_IRQ1);
246 /* Init clock subsystem */
247 @@ -308,6 +318,12 @@ void __init at91cap9_initialize(unsigned
249 /* Register GPIO subsystem */
250 at91_gpio_init(at91cap9_gpio, 4);
252 + /* Remember the silicon revision */
253 + if (cpu_is_at91cap9_revB())
255 + else if (cpu_is_at91cap9_revC())
259 /* --------------------------------------------------------------------
260 --- a/arch/arm/mach-at91/at91cap9_devices.c
261 +++ b/arch/arm/mach-at91/at91cap9_devices.c
264 #include <asm/mach/arch.h>
265 #include <asm/mach/map.h>
266 +#include <asm/mach/irq.h>
268 #include <linux/dma-mapping.h>
269 #include <linux/platform_device.h>
270 -#include <linux/mtd/physmap.h>
271 +#include <linux/i2c-gpio.h>
273 #include <video/atmel_lcdc.h>
275 #include <asm/arch/board.h>
276 +#include <asm/arch/cpu.h>
277 #include <asm/arch/gpio.h>
278 #include <asm/arch/at91cap9.h>
279 -#include <asm/arch/at91sam926x_mc.h>
280 #include <asm/arch/at91cap9_matrix.h>
281 +#include <asm/arch/at91sam9_smc.h>
285 @@ -69,6 +71,9 @@ void __init at91_add_device_usbh(struct
289 + if (cpu_is_at91cap9_revB())
290 + set_irq_type(AT91CAP9_ID_UHP, IRQT_HIGH);
292 /* Enable VBus control for UHP ports */
293 for (i = 0; i < data->ports; i++) {
294 if (data->vbus_pin[i])
295 @@ -84,6 +89,110 @@ void __init at91_add_device_usbh(struct
298 /* --------------------------------------------------------------------
299 + * USB HS Device (Gadget)
300 + * -------------------------------------------------------------------- */
302 +#if defined(CONFIG_USB_GADGET_ATMEL_USBA) || defined(CONFIG_USB_GADGET_ATMEL_USBA_MODULE)
304 +static struct resource usba_udc_resources[] = {
306 + .start = AT91CAP9_UDPHS_FIFO,
307 + .end = AT91CAP9_UDPHS_FIFO + SZ_512K - 1,
308 + .flags = IORESOURCE_MEM,
311 + .start = AT91CAP9_BASE_UDPHS,
312 + .end = AT91CAP9_BASE_UDPHS + SZ_1K - 1,
313 + .flags = IORESOURCE_MEM,
316 + .start = AT91CAP9_ID_UDPHS,
317 + .end = AT91CAP9_ID_UDPHS,
318 + .flags = IORESOURCE_IRQ,
322 +#define EP(nam, idx, maxpkt, maxbk, dma, isoc) \
326 + .fifo_size = maxpkt, \
327 + .nr_banks = maxbk, \
329 + .can_isoc = isoc, \
332 +static struct usba_ep_data usba_udc_ep[] = {
333 + EP("ep0", 0, 64, 1, 0, 0),
334 + EP("ep1", 1, 1024, 3, 1, 1),
335 + EP("ep2", 2, 1024, 3, 1, 1),
336 + EP("ep3", 3, 1024, 2, 1, 1),
337 + EP("ep4", 4, 1024, 2, 1, 1),
338 + EP("ep5", 5, 1024, 2, 1, 0),
339 + EP("ep6", 6, 1024, 2, 1, 0),
340 + EP("ep7", 7, 1024, 2, 0, 0),
346 + * pdata doesn't have room for any endpoints, so we need to
347 + * append room for the ones we need right after it.
350 + struct usba_platform_data pdata;
351 + struct usba_ep_data ep[8];
354 +static struct platform_device at91_usba_udc_device = {
355 + .name = "atmel_usba_udc",
358 + .platform_data = &usba_udc_data.pdata,
360 + .resource = usba_udc_resources,
361 + .num_resources = ARRAY_SIZE(usba_udc_resources),
364 +void __init at91_add_device_usba(struct usba_platform_data *data)
366 + if (cpu_is_at91cap9_revB()) {
367 + set_irq_type(AT91CAP9_ID_UDPHS, IRQT_HIGH);
368 + at91_sys_write(AT91_MATRIX_UDPHS, AT91_MATRIX_SELECT_UDPHS |
369 + AT91_MATRIX_UDPHS_BYPASS_LOCK);
372 + at91_sys_write(AT91_MATRIX_UDPHS, AT91_MATRIX_SELECT_UDPHS);
375 + * Invalid pins are 0 on AT91, but the usba driver is shared
376 + * with AVR32, which use negative values instead. Once/if
377 + * gpio_is_valid() is ported to AT91, revisit this code.
379 + usba_udc_data.pdata.vbus_pin = -EINVAL;
380 + usba_udc_data.pdata.num_ep = ARRAY_SIZE(usba_udc_ep);
381 + memcpy(usba_udc_data.ep, usba_udc_ep, sizeof(usba_udc_ep));;
383 + if (data && data->vbus_pin > 0) {
384 + at91_set_gpio_input(data->vbus_pin, 0);
385 + at91_set_deglitch(data->vbus_pin, 1);
386 + usba_udc_data.pdata.vbus_pin = data->vbus_pin;
389 + /* Pullup pin is handled internally by USB device peripheral */
392 + at91_clock_associate("utmi_clk", &at91_usba_udc_device.dev, "hclk");
393 + at91_clock_associate("udphs_clk", &at91_usba_udc_device.dev, "pclk");
395 + platform_device_register(&at91_usba_udc_device);
398 +void __init at91_add_device_usba(struct usba_platform_data *data) {}
402 +/* --------------------------------------------------------------------
404 * -------------------------------------------------------------------- */
406 @@ -246,7 +355,7 @@ void __init at91_add_device_mmc(short mm
410 - at91_clock_associate("mci0_clk", &at91cap9_mmc1_device.dev, "mci_clk");
411 + at91_clock_associate("mci0_clk", &at91cap9_mmc0_device.dev, "mci_clk");
412 platform_device_register(&at91cap9_mmc0_device);
415 @@ -283,10 +392,15 @@ static struct at91_nand_data nand_data;
416 #define NAND_BASE AT91_CHIPSELECT_3
418 static struct resource nand_resources[] = {
422 .end = NAND_BASE + SZ_256M - 1,
423 .flags = IORESOURCE_MEM,
426 + .start = AT91_BASE_SYS + AT91_ECC,
427 + .end = AT91_BASE_SYS + AT91_ECC + SZ_512 - 1,
428 + .flags = IORESOURCE_MEM,
432 @@ -344,6 +458,7 @@ void __init at91_add_device_nand(struct
433 void __init at91_add_device_nand(struct at91_nand_data *data) {}
437 /* --------------------------------------------------------------------
439 * -------------------------------------------------------------------- */
440 @@ -532,17 +647,64 @@ void __init at91_add_device_spi(struct s
443 /* --------------------------------------------------------------------
444 + * Timer/Counter block
445 + * -------------------------------------------------------------------- */
447 +#ifdef CONFIG_ATMEL_TCLIB
449 +static struct resource tcb_resources[] = {
451 + .start = AT91CAP9_BASE_TCB0,
452 + .end = AT91CAP9_BASE_TCB0 + SZ_16K - 1,
453 + .flags = IORESOURCE_MEM,
456 + .start = AT91CAP9_ID_TCB,
457 + .end = AT91CAP9_ID_TCB,
458 + .flags = IORESOURCE_IRQ,
462 +static struct platform_device at91cap9_tcb_device = {
463 + .name = "atmel_tcb",
465 + .resource = tcb_resources,
466 + .num_resources = ARRAY_SIZE(tcb_resources),
469 +static void __init at91_add_device_tc(void)
471 + /* this chip has one clock and irq for all three TC channels */
472 + at91_clock_associate("tcb_clk", &at91cap9_tcb_device.dev, "t0_clk");
473 + platform_device_register(&at91cap9_tcb_device);
476 +static void __init at91_add_device_tc(void) { }
480 +/* --------------------------------------------------------------------
482 * -------------------------------------------------------------------- */
484 +static struct resource rtt_resources[] = {
486 + .start = AT91_BASE_SYS + AT91_RTT,
487 + .end = AT91_BASE_SYS + AT91_RTT + SZ_16 - 1,
488 + .flags = IORESOURCE_MEM,
492 static struct platform_device at91cap9_rtt_device = {
495 - .num_resources = 0,
497 + .resource = rtt_resources,
498 + .num_resources = ARRAY_SIZE(rtt_resources),
501 static void __init at91_add_device_rtt(void)
503 + device_init_wakeup(&at91cap9_rtt_device.dev, 1);
504 platform_device_register(&at91cap9_rtt_device);
507 @@ -660,6 +822,9 @@ void __init at91_add_device_lcdc(struct
511 + if (cpu_is_at91cap9_revB())
512 + set_irq_type(AT91CAP9_ID_LCDC, IRQT_HIGH);
514 at91_set_A_periph(AT91_PIN_PC1, 0); /* LCDHSYNC */
515 at91_set_A_periph(AT91_PIN_PC2, 0); /* LCDDOTCK */
516 at91_set_A_periph(AT91_PIN_PC3, 0); /* LCDDEN */
517 @@ -990,7 +1155,7 @@ static inline void configure_usart2_pins
518 at91_set_B_periph(AT91_PIN_PD6, 0); /* CTS2 */
521 -static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
522 +static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
523 struct platform_device *atmel_default_console_device; /* the serial console device */
525 void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
526 @@ -1031,8 +1196,6 @@ void __init at91_set_serial_console(unsi
528 if (portnr < ATMEL_MAX_UART)
529 atmel_default_console_device = at91_uarts[portnr];
530 - if (!atmel_default_console_device)
531 - printk(KERN_INFO "AT91: No default serial console defined.\n");
534 void __init at91_add_device_serial(void)
535 @@ -1043,6 +1206,9 @@ void __init at91_add_device_serial(void)
537 platform_device_register(at91_uarts[i]);
540 + if (!atmel_default_console_device)
541 + printk(KERN_INFO "AT91: No default serial console defined.\n");
544 void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
545 @@ -1060,6 +1226,7 @@ static int __init at91_add_standard_devi
547 at91_add_device_rtt();
548 at91_add_device_watchdog();
549 + at91_add_device_tc();
553 --- a/arch/arm/mach-at91/at91rm9200_devices.c
554 +++ b/arch/arm/mach-at91/at91rm9200_devices.c
555 @@ -513,7 +513,18 @@ void __init at91_add_device_i2c(struct i
557 * -------------------------------------------------------------------- */
559 -#if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
560 +#if defined(CONFIG_AT91_SPI) || defined(CONFIG_AT91_SPI_MODULE) /* legacy SPI driver */
561 +#define SPI_DEVNAME "at91_spi"
563 +#elif defined(CONFIG_SPI_AT91) || defined(CONFIG_SPI_AT91_MODULE) /* SPI bitbanging driver */
564 +#define SPI_DEVNAME "at91_spi"
566 +#elif defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE) /* new SPI driver */
567 +#define SPI_DEVNAME "atmel_spi"
572 static u64 spi_dmamask = DMA_BIT_MASK(32);
574 static struct resource spi_resources[] = {
575 @@ -530,7 +541,7 @@ static struct resource spi_resources[] =
578 static struct platform_device at91rm9200_spi_device = {
579 - .name = "atmel_spi",
580 + .name = SPI_DEVNAME,
583 .dma_mask = &spi_dmamask,
584 @@ -563,6 +574,12 @@ void __init at91_add_device_spi(struct s
586 at91_set_gpio_output(cs_pin, 1);
588 +#if defined(CONFIG_AT91_SPI) || defined(CONFIG_AT91_SPI_MODULE)
590 + * Force peripheral mode when using the legacy SPI driver.
592 + at91_set_A_periph(cs_pin, 0);
595 /* pass chip-select pin to driver */
596 devices[i].controller_data = (void *) cs_pin;
597 @@ -577,6 +594,90 @@ void __init at91_add_device_spi(struct s
600 /* --------------------------------------------------------------------
601 + * Timer/Counter blocks
602 + * -------------------------------------------------------------------- */
604 +#ifdef CONFIG_ATMEL_TCLIB
606 +static struct resource tcb0_resources[] = {
608 + .start = AT91RM9200_BASE_TCB0,
609 + .end = AT91RM9200_BASE_TCB0 + SZ_16K - 1,
610 + .flags = IORESOURCE_MEM,
613 + .start = AT91RM9200_ID_TC0,
614 + .end = AT91RM9200_ID_TC0,
615 + .flags = IORESOURCE_IRQ,
618 + .start = AT91RM9200_ID_TC1,
619 + .end = AT91RM9200_ID_TC1,
620 + .flags = IORESOURCE_IRQ,
623 + .start = AT91RM9200_ID_TC2,
624 + .end = AT91RM9200_ID_TC2,
625 + .flags = IORESOURCE_IRQ,
629 +static struct platform_device at91rm9200_tcb0_device = {
630 + .name = "atmel_tcb",
632 + .resource = tcb0_resources,
633 + .num_resources = ARRAY_SIZE(tcb0_resources),
636 +static struct resource tcb1_resources[] = {
638 + .start = AT91RM9200_BASE_TCB1,
639 + .end = AT91RM9200_BASE_TCB1 + SZ_16K - 1,
640 + .flags = IORESOURCE_MEM,
643 + .start = AT91RM9200_ID_TC3,
644 + .end = AT91RM9200_ID_TC3,
645 + .flags = IORESOURCE_IRQ,
648 + .start = AT91RM9200_ID_TC4,
649 + .end = AT91RM9200_ID_TC4,
650 + .flags = IORESOURCE_IRQ,
653 + .start = AT91RM9200_ID_TC5,
654 + .end = AT91RM9200_ID_TC5,
655 + .flags = IORESOURCE_IRQ,
659 +static struct platform_device at91rm9200_tcb1_device = {
660 + .name = "atmel_tcb",
662 + .resource = tcb1_resources,
663 + .num_resources = ARRAY_SIZE(tcb1_resources),
666 +static void __init at91_add_device_tc(void)
668 + /* this chip has a separate clock and irq for each TC channel */
669 + at91_clock_associate("tc0_clk", &at91rm9200_tcb0_device.dev, "t0_clk");
670 + at91_clock_associate("tc1_clk", &at91rm9200_tcb0_device.dev, "t1_clk");
671 + at91_clock_associate("tc2_clk", &at91rm9200_tcb0_device.dev, "t2_clk");
672 + platform_device_register(&at91rm9200_tcb0_device);
674 + at91_clock_associate("tc3_clk", &at91rm9200_tcb1_device.dev, "t0_clk");
675 + at91_clock_associate("tc4_clk", &at91rm9200_tcb1_device.dev, "t1_clk");
676 + at91_clock_associate("tc5_clk", &at91rm9200_tcb1_device.dev, "t2_clk");
677 + platform_device_register(&at91rm9200_tcb1_device);
680 +static void __init at91_add_device_tc(void) { }
684 +/* --------------------------------------------------------------------
686 * -------------------------------------------------------------------- */
688 @@ -589,6 +690,7 @@ static struct platform_device at91rm9200
690 static void __init at91_add_device_rtc(void)
692 + device_init_wakeup(&at91rm9200_rtc_device.dev, 1);
693 platform_device_register(&at91rm9200_rtc_device);
696 @@ -1019,7 +1121,7 @@ static inline void configure_usart3_pins
697 at91_set_B_periph(AT91_PIN_PB0, 0); /* RTS3 */
700 -static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
701 +static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
702 struct platform_device *atmel_default_console_device; /* the serial console device */
704 void __init __deprecated at91_init_serial(struct at91_uart_config *config)
705 @@ -1110,8 +1212,6 @@ void __init at91_set_serial_console(unsi
707 if (portnr < ATMEL_MAX_UART)
708 atmel_default_console_device = at91_uarts[portnr];
709 - if (!atmel_default_console_device)
710 - printk(KERN_INFO "AT91: No default serial console defined.\n");
713 void __init at91_add_device_serial(void)
714 @@ -1122,6 +1222,9 @@ void __init at91_add_device_serial(void)
716 platform_device_register(at91_uarts[i]);
719 + if (!atmel_default_console_device)
720 + printk(KERN_INFO "AT91: No default serial console defined.\n");
723 void __init __deprecated at91_init_serial(struct at91_uart_config *config) {}
724 @@ -1141,6 +1244,7 @@ static int __init at91_add_standard_devi
726 at91_add_device_rtc();
727 at91_add_device_watchdog();
728 + at91_add_device_tc();
732 --- a/arch/arm/mach-at91/at91rm9200_time.c
733 +++ b/arch/arm/mach-at91/at91rm9200_time.c
734 @@ -136,8 +136,6 @@ clkevt32k_next_event(unsigned long delta
740 /* Use "raw" primitives so we behave correctly on RT kernels. */
741 raw_local_irq_save(flags);
743 --- a/arch/arm/mach-at91/at91sam9260.c
744 +++ b/arch/arm/mach-at91/at91sam9260.c
748 #include <linux/module.h>
749 +#include <linux/pm.h>
751 #include <asm/mach/arch.h>
752 #include <asm/mach/map.h>
754 #include <asm/arch/at91sam9260.h>
755 #include <asm/arch/at91_pmc.h>
756 #include <asm/arch/at91_rstc.h>
757 +#include <asm/arch/at91_shdwc.h>
761 @@ -267,6 +269,11 @@ static void at91sam9260_reset(void)
762 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
765 +static void at91sam9260_poweroff(void)
767 + at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
771 /* --------------------------------------------------------------------
772 * AT91SAM9260 processor initialization
773 @@ -304,6 +311,7 @@ void __init at91sam9260_initialize(unsig
774 iotable_init(at91sam9260_sram_desc, ARRAY_SIZE(at91sam9260_sram_desc));
776 at91_arch_reset = at91sam9260_reset;
777 + pm_power_off = at91sam9260_poweroff;
778 at91_extern_irq = (1 << AT91SAM9260_ID_IRQ0) | (1 << AT91SAM9260_ID_IRQ1)
779 | (1 << AT91SAM9260_ID_IRQ2);
781 --- a/arch/arm/mach-at91/at91sam9260_devices.c
782 +++ b/arch/arm/mach-at91/at91sam9260_devices.c
784 #include <asm/arch/board.h>
785 #include <asm/arch/gpio.h>
786 #include <asm/arch/at91sam9260.h>
787 -#include <asm/arch/at91sam926x_mc.h>
788 #include <asm/arch/at91sam9260_matrix.h>
789 +#include <asm/arch/at91sam9_smc.h>
793 @@ -288,10 +288,15 @@ static struct at91_nand_data nand_data;
794 #define NAND_BASE AT91_CHIPSELECT_3
796 static struct resource nand_resources[] = {
800 .end = NAND_BASE + SZ_256M - 1,
801 .flags = IORESOURCE_MEM,
804 + .start = AT91_BASE_SYS + AT91_ECC,
805 + .end = AT91_BASE_SYS + AT91_ECC + SZ_512 - 1,
806 + .flags = IORESOURCE_MEM,
810 @@ -540,6 +545,90 @@ void __init at91_add_device_spi(struct s
813 /* --------------------------------------------------------------------
814 + * Timer/Counter blocks
815 + * -------------------------------------------------------------------- */
817 +#ifdef CONFIG_ATMEL_TCLIB
819 +static struct resource tcb0_resources[] = {
821 + .start = AT91SAM9260_BASE_TCB0,
822 + .end = AT91SAM9260_BASE_TCB0 + SZ_16K - 1,
823 + .flags = IORESOURCE_MEM,
826 + .start = AT91SAM9260_ID_TC0,
827 + .end = AT91SAM9260_ID_TC0,
828 + .flags = IORESOURCE_IRQ,
831 + .start = AT91SAM9260_ID_TC1,
832 + .end = AT91SAM9260_ID_TC1,
833 + .flags = IORESOURCE_IRQ,
836 + .start = AT91SAM9260_ID_TC2,
837 + .end = AT91SAM9260_ID_TC2,
838 + .flags = IORESOURCE_IRQ,
842 +static struct platform_device at91sam9260_tcb0_device = {
843 + .name = "atmel_tcb",
845 + .resource = tcb0_resources,
846 + .num_resources = ARRAY_SIZE(tcb0_resources),
849 +static struct resource tcb1_resources[] = {
851 + .start = AT91SAM9260_BASE_TCB1,
852 + .end = AT91SAM9260_BASE_TCB1 + SZ_16K - 1,
853 + .flags = IORESOURCE_MEM,
856 + .start = AT91SAM9260_ID_TC3,
857 + .end = AT91SAM9260_ID_TC3,
858 + .flags = IORESOURCE_IRQ,
861 + .start = AT91SAM9260_ID_TC4,
862 + .end = AT91SAM9260_ID_TC4,
863 + .flags = IORESOURCE_IRQ,
866 + .start = AT91SAM9260_ID_TC5,
867 + .end = AT91SAM9260_ID_TC5,
868 + .flags = IORESOURCE_IRQ,
872 +static struct platform_device at91sam9260_tcb1_device = {
873 + .name = "atmel_tcb",
875 + .resource = tcb1_resources,
876 + .num_resources = ARRAY_SIZE(tcb1_resources),
879 +static void __init at91_add_device_tc(void)
881 + /* this chip has a separate clock and irq for each TC channel */
882 + at91_clock_associate("tc0_clk", &at91sam9260_tcb0_device.dev, "t0_clk");
883 + at91_clock_associate("tc1_clk", &at91sam9260_tcb0_device.dev, "t1_clk");
884 + at91_clock_associate("tc2_clk", &at91sam9260_tcb0_device.dev, "t2_clk");
885 + platform_device_register(&at91sam9260_tcb0_device);
887 + at91_clock_associate("tc3_clk", &at91sam9260_tcb1_device.dev, "t0_clk");
888 + at91_clock_associate("tc4_clk", &at91sam9260_tcb1_device.dev, "t1_clk");
889 + at91_clock_associate("tc5_clk", &at91sam9260_tcb1_device.dev, "t2_clk");
890 + platform_device_register(&at91sam9260_tcb1_device);
893 +static void __init at91_add_device_tc(void) { }
897 +/* --------------------------------------------------------------------
899 * -------------------------------------------------------------------- */
901 @@ -553,13 +642,14 @@ static struct resource rtt_resources[] =
903 static struct platform_device at91sam9260_rtt_device = {
907 .resource = rtt_resources,
908 .num_resources = ARRAY_SIZE(rtt_resources),
911 static void __init at91_add_device_rtt(void)
913 + device_init_wakeup(&at91sam9260_rtt_device.dev, 1);
914 platform_device_register(&at91sam9260_rtt_device);
917 @@ -962,7 +1052,7 @@ static inline void configure_usart5_pins
918 at91_set_A_periph(AT91_PIN_PB13, 0); /* RXD5 */
921 -static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
922 +static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
923 struct platform_device *atmel_default_console_device; /* the serial console device */
925 void __init __deprecated at91_init_serial(struct at91_uart_config *config)
926 @@ -1073,8 +1163,6 @@ void __init at91_set_serial_console(unsi
928 if (portnr < ATMEL_MAX_UART)
929 atmel_default_console_device = at91_uarts[portnr];
930 - if (!atmel_default_console_device)
931 - printk(KERN_INFO "AT91: No default serial console defined.\n");
934 void __init at91_add_device_serial(void)
935 @@ -1085,6 +1173,9 @@ void __init at91_add_device_serial(void)
937 platform_device_register(at91_uarts[i]);
940 + if (!atmel_default_console_device)
941 + printk(KERN_INFO "AT91: No default serial console defined.\n");
944 void __init __deprecated at91_init_serial(struct at91_uart_config *config) {}
945 @@ -1103,6 +1194,7 @@ static int __init at91_add_standard_devi
947 at91_add_device_rtt();
948 at91_add_device_watchdog();
949 + at91_add_device_tc();
953 --- a/arch/arm/mach-at91/at91sam9261.c
954 +++ b/arch/arm/mach-at91/at91sam9261.c
958 #include <linux/module.h>
959 +#include <linux/pm.h>
961 #include <asm/mach/arch.h>
962 #include <asm/mach/map.h>
963 #include <asm/arch/at91sam9261.h>
964 #include <asm/arch/at91_pmc.h>
965 #include <asm/arch/at91_rstc.h>
966 +#include <asm/arch/at91_shdwc.h>
970 @@ -245,6 +247,11 @@ static void at91sam9261_reset(void)
971 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
974 +static void at91sam9261_poweroff(void)
976 + at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
980 /* --------------------------------------------------------------------
981 * AT91SAM9261 processor initialization
982 @@ -256,6 +263,7 @@ void __init at91sam9261_initialize(unsig
983 iotable_init(at91sam9261_io_desc, ARRAY_SIZE(at91sam9261_io_desc));
985 at91_arch_reset = at91sam9261_reset;
986 + pm_power_off = at91sam9261_poweroff;
987 at91_extern_irq = (1 << AT91SAM9261_ID_IRQ0) | (1 << AT91SAM9261_ID_IRQ1)
988 | (1 << AT91SAM9261_ID_IRQ2);
990 --- a/arch/arm/mach-at91/at91sam9261_devices.c
991 +++ b/arch/arm/mach-at91/at91sam9261_devices.c
993 #include <asm/arch/gpio.h>
994 #include <asm/arch/at91sam9261.h>
995 #include <asm/arch/at91sam9261_matrix.h>
996 -#include <asm/arch/at91sam926x_mc.h>
997 +#include <asm/arch/at91sam9_smc.h>
1001 @@ -548,6 +548,55 @@ void __init at91_add_device_lcdc(struct
1004 /* --------------------------------------------------------------------
1005 + * Timer/Counter block
1006 + * -------------------------------------------------------------------- */
1008 +#ifdef CONFIG_ATMEL_TCLIB
1010 +static struct resource tcb_resources[] = {
1012 + .start = AT91SAM9261_BASE_TCB0,
1013 + .end = AT91SAM9261_BASE_TCB0 + SZ_16K - 1,
1014 + .flags = IORESOURCE_MEM,
1017 + .start = AT91SAM9261_ID_TC0,
1018 + .end = AT91SAM9261_ID_TC0,
1019 + .flags = IORESOURCE_IRQ,
1022 + .start = AT91SAM9261_ID_TC1,
1023 + .end = AT91SAM9261_ID_TC1,
1024 + .flags = IORESOURCE_IRQ,
1027 + .start = AT91SAM9261_ID_TC2,
1028 + .end = AT91SAM9261_ID_TC2,
1029 + .flags = IORESOURCE_IRQ,
1033 +static struct platform_device at91sam9261_tcb_device = {
1034 + .name = "atmel_tcb",
1036 + .resource = tcb_resources,
1037 + .num_resources = ARRAY_SIZE(tcb_resources),
1040 +static void __init at91_add_device_tc(void)
1042 + /* this chip has a separate clock and irq for each TC channel */
1043 + at91_clock_associate("tc0_clk", &at91sam9261_tcb_device.dev, "t0_clk");
1044 + at91_clock_associate("tc1_clk", &at91sam9261_tcb_device.dev, "t1_clk");
1045 + at91_clock_associate("tc2_clk", &at91sam9261_tcb_device.dev, "t2_clk");
1046 + platform_device_register(&at91sam9261_tcb_device);
1049 +static void __init at91_add_device_tc(void) { }
1053 +/* --------------------------------------------------------------------
1055 * -------------------------------------------------------------------- */
1057 @@ -561,13 +610,14 @@ static struct resource rtt_resources[] =
1059 static struct platform_device at91sam9261_rtt_device = {
1063 .resource = rtt_resources,
1064 .num_resources = ARRAY_SIZE(rtt_resources),
1067 static void __init at91_add_device_rtt(void)
1069 + device_init_wakeup(&at91sam9261_rtt_device.dev, 1);
1070 platform_device_register(&at91sam9261_rtt_device);
1073 @@ -938,7 +988,7 @@ static inline void configure_usart2_pins
1074 at91_set_B_periph(AT91_PIN_PA16, 0); /* CTS2 */
1077 -static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
1078 +static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
1079 struct platform_device *atmel_default_console_device; /* the serial console device */
1081 void __init __deprecated at91_init_serial(struct at91_uart_config *config)
1082 @@ -1019,8 +1069,6 @@ void __init at91_set_serial_console(unsi
1084 if (portnr < ATMEL_MAX_UART)
1085 atmel_default_console_device = at91_uarts[portnr];
1086 - if (!atmel_default_console_device)
1087 - printk(KERN_INFO "AT91: No default serial console defined.\n");
1090 void __init at91_add_device_serial(void)
1091 @@ -1031,6 +1079,9 @@ void __init at91_add_device_serial(void)
1093 platform_device_register(at91_uarts[i]);
1096 + if (!atmel_default_console_device)
1097 + printk(KERN_INFO "AT91: No default serial console defined.\n");
1100 void __init __deprecated at91_init_serial(struct at91_uart_config *config) {}
1101 @@ -1050,6 +1101,7 @@ static int __init at91_add_standard_devi
1103 at91_add_device_rtt();
1104 at91_add_device_watchdog();
1105 + at91_add_device_tc();
1109 --- a/arch/arm/mach-at91/at91sam9263.c
1110 +++ b/arch/arm/mach-at91/at91sam9263.c
1114 #include <linux/module.h>
1115 +#include <linux/pm.h>
1117 #include <asm/mach/arch.h>
1118 #include <asm/mach/map.h>
1119 #include <asm/arch/at91sam9263.h>
1120 #include <asm/arch/at91_pmc.h>
1121 #include <asm/arch/at91_rstc.h>
1122 +#include <asm/arch/at91_shdwc.h>
1124 #include "generic.h"
1126 @@ -271,6 +273,11 @@ static void at91sam9263_reset(void)
1127 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
1130 +static void at91sam9263_poweroff(void)
1132 + at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
1136 /* --------------------------------------------------------------------
1137 * AT91SAM9263 processor initialization
1138 @@ -282,6 +289,7 @@ void __init at91sam9263_initialize(unsig
1139 iotable_init(at91sam9263_io_desc, ARRAY_SIZE(at91sam9263_io_desc));
1141 at91_arch_reset = at91sam9263_reset;
1142 + pm_power_off = at91sam9263_poweroff;
1143 at91_extern_irq = (1 << AT91SAM9263_ID_IRQ0) | (1 << AT91SAM9263_ID_IRQ1);
1145 /* Init clock subsystem */
1146 --- a/arch/arm/mach-at91/at91sam9263_devices.c
1147 +++ b/arch/arm/mach-at91/at91sam9263_devices.c
1149 #include <asm/arch/board.h>
1150 #include <asm/arch/gpio.h>
1151 #include <asm/arch/at91sam9263.h>
1152 -#include <asm/arch/at91sam926x_mc.h>
1153 #include <asm/arch/at91sam9263_matrix.h>
1154 +#include <asm/arch/at91sam9_smc.h>
1156 #include "generic.h"
1158 @@ -308,7 +308,7 @@ void __init at91_add_device_mmc(short mm
1162 - at91_clock_associate("mci0_clk", &at91sam9263_mmc1_device.dev, "mci_clk");
1163 + at91_clock_associate("mci0_clk", &at91sam9263_mmc0_device.dev, "mci_clk");
1164 platform_device_register(&at91sam9263_mmc0_device);
1167 @@ -358,10 +358,15 @@ static struct at91_nand_data nand_data;
1168 #define NAND_BASE AT91_CHIPSELECT_3
1170 static struct resource nand_resources[] = {
1174 .end = NAND_BASE + SZ_256M - 1,
1175 .flags = IORESOURCE_MEM,
1178 + .start = AT91_BASE_SYS + AT91_ECC0,
1179 + .end = AT91_BASE_SYS + AT91_ECC0 + SZ_512 - 1,
1180 + .flags = IORESOURCE_MEM,
1184 @@ -783,6 +788,43 @@ void __init at91_add_device_isi(void) {}
1187 /* --------------------------------------------------------------------
1188 + * Timer/Counter block
1189 + * -------------------------------------------------------------------- */
1191 +#ifdef CONFIG_ATMEL_TCLIB
1193 +static struct resource tcb_resources[] = {
1195 + .start = AT91SAM9263_BASE_TCB0,
1196 + .end = AT91SAM9263_BASE_TCB0 + SZ_16K - 1,
1197 + .flags = IORESOURCE_MEM,
1200 + .start = AT91SAM9263_ID_TCB,
1201 + .end = AT91SAM9263_ID_TCB,
1202 + .flags = IORESOURCE_IRQ,
1206 +static struct platform_device at91sam9263_tcb_device = {
1207 + .name = "atmel_tcb",
1209 + .resource = tcb_resources,
1210 + .num_resources = ARRAY_SIZE(tcb_resources),
1213 +static void __init at91_add_device_tc(void)
1215 + /* this chip has one clock and irq for all three TC channels */
1216 + at91_clock_associate("tcb_clk", &at91sam9263_tcb_device.dev, "t0_clk");
1217 + platform_device_register(&at91sam9263_tcb_device);
1220 +static void __init at91_add_device_tc(void) { }
1224 +/* --------------------------------------------------------------------
1226 * -------------------------------------------------------------------- */
1228 @@ -818,7 +860,9 @@ static struct platform_device at91sam926
1230 static void __init at91_add_device_rtt(void)
1232 + device_init_wakeup(&at91sam9263_rtt0_device.dev, 1);
1233 platform_device_register(&at91sam9263_rtt0_device);
1234 + device_init_wakeup(&at91sam9263_rtt1_device.dev, 1);
1235 platform_device_register(&at91sam9263_rtt1_device);
1238 @@ -933,9 +977,6 @@ static inline void configure_ssc1_pins(u
1242 - * Return the device node so that board init code can use it as the
1243 - * parent for the device node reflecting how it's used on this board.
1245 * SSC controllers are accessed through library code, instead of any
1246 * kind of all-singing/all-dancing driver. For example one could be
1247 * used by a particular I2S audio codec's driver, while another one
1248 @@ -1146,7 +1187,7 @@ static inline void configure_usart2_pins
1249 at91_set_B_periph(AT91_PIN_PD6, 0); /* CTS2 */
1252 -static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
1253 +static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
1254 struct platform_device *atmel_default_console_device; /* the serial console device */
1256 void __init __deprecated at91_init_serial(struct at91_uart_config *config)
1257 @@ -1227,8 +1268,6 @@ void __init at91_set_serial_console(unsi
1259 if (portnr < ATMEL_MAX_UART)
1260 atmel_default_console_device = at91_uarts[portnr];
1261 - if (!atmel_default_console_device)
1262 - printk(KERN_INFO "AT91: No default serial console defined.\n");
1265 void __init at91_add_device_serial(void)
1266 @@ -1239,9 +1278,12 @@ void __init at91_add_device_serial(void)
1268 platform_device_register(at91_uarts[i]);
1271 + if (!atmel_default_console_device)
1272 + printk(KERN_INFO "AT91: No default serial console defined.\n");
1275 -void __init at91_init_serial(struct at91_uart_config *config) {}
1276 +void __init __deprecated at91_init_serial(struct at91_uart_config *config) {}
1277 void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
1278 void __init at91_set_serial_console(unsigned portnr) {}
1279 void __init at91_add_device_serial(void) {}
1280 @@ -1257,6 +1299,7 @@ static int __init at91_add_standard_devi
1282 at91_add_device_rtt();
1283 at91_add_device_watchdog();
1284 + at91_add_device_tc();
1288 --- a/arch/arm/mach-at91/at91sam926x_time.c
1289 +++ b/arch/arm/mach-at91/at91sam926x_time.c
1292 - * linux/arch/arm/mach-at91/at91sam926x_time.c
1293 + * at91sam926x_time.c - Periodic Interval Timer (PIT) for at91sam926x
1295 * Copyright (C) 2005-2006 M. Amine SAYA, ATMEL Rousset, France
1296 * Revision 2005 M. Nicolas Diremdjian, ATMEL Rousset, France
1297 + * Converted to ClockSource/ClockEvents by David Brownell.
1299 * This program is free software; you can redistribute it and/or modify
1300 * it under the terms of the GNU General Public License version 2 as
1301 * published by the Free Software Foundation.
1304 -#include <linux/init.h>
1305 #include <linux/interrupt.h>
1306 #include <linux/irq.h>
1307 #include <linux/kernel.h>
1308 -#include <linux/sched.h>
1309 -#include <linux/time.h>
1310 +#include <linux/clk.h>
1311 +#include <linux/clockchips.h>
1313 -#include <asm/hardware.h>
1314 -#include <asm/io.h>
1315 #include <asm/mach/time.h>
1317 #include <asm/arch/at91_pit.h>
1318 @@ -26,85 +23,167 @@
1319 #define PIT_CPIV(x) ((x) & AT91_PIT_CPIV)
1320 #define PIT_PICNT(x) (((x) & AT91_PIT_PICNT) >> 20)
1322 +static u32 pit_cycle; /* write-once */
1323 +static u32 pit_cnt; /* access only w/system irq blocked */
1327 - * Returns number of microseconds since last timer interrupt. Note that interrupts
1328 - * will have been disabled by do_gettimeofday()
1329 - * 'LATCH' is hwclock ticks (see CLOCK_TICK_RATE in timex.h) per jiffy.
1330 + * Clocksource: just a monotonic counter of MCK/16 cycles.
1331 + * We don't care whether or not PIT irqs are enabled.
1333 -static unsigned long at91sam926x_gettimeoffset(void)
1334 +static cycle_t read_pit_clk(void)
1336 - unsigned long elapsed;
1337 - unsigned long t = at91_sys_read(AT91_PIT_PIIR);
1338 + unsigned long flags;
1342 + raw_local_irq_save(flags);
1343 + elapsed = pit_cnt;
1344 + t = at91_sys_read(AT91_PIT_PIIR);
1345 + raw_local_irq_restore(flags);
1347 + elapsed += PIT_PICNT(t) * pit_cycle;
1348 + elapsed += PIT_CPIV(t);
1352 +static struct clocksource pit_clk = {
1355 + .read = read_pit_clk,
1357 + .flags = CLOCK_SOURCE_IS_CONTINUOUS,
1361 - elapsed = (PIT_PICNT(t) * LATCH) + PIT_CPIV(t); /* hardware clock cycles */
1363 + * Clockevent device: interrupts every 1/HZ (== pit_cycles * MCK/16)
1366 +pit_clkevt_mode(enum clock_event_mode mode, struct clock_event_device *dev)
1368 + unsigned long flags;
1370 - return (unsigned long)(elapsed * jiffies_to_usecs(1)) / LATCH;
1372 + case CLOCK_EVT_MODE_PERIODIC:
1373 + /* update clocksource counter, then enable the IRQ */
1374 + raw_local_irq_save(flags);
1375 + pit_cnt += pit_cycle * PIT_PICNT(at91_sys_read(AT91_PIT_PIVR));
1376 + at91_sys_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN
1377 + | AT91_PIT_PITIEN);
1378 + raw_local_irq_restore(flags);
1380 + case CLOCK_EVT_MODE_ONESHOT:
1383 + case CLOCK_EVT_MODE_SHUTDOWN:
1384 + case CLOCK_EVT_MODE_UNUSED:
1385 + /* disable irq, leaving the clocksource active */
1386 + at91_sys_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN);
1388 + case CLOCK_EVT_MODE_RESUME:
1393 +static struct clock_event_device pit_clkevt = {
1395 + .features = CLOCK_EVT_FEAT_PERIODIC,
1398 + .cpumask = CPU_MASK_CPU0,
1399 + .set_mode = pit_clkevt_mode,
1404 * IRQ handler for the timer.
1406 -static irqreturn_t at91sam926x_timer_interrupt(int irq, void *dev_id)
1407 +static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)
1409 - volatile long nr_ticks;
1411 - if (at91_sys_read(AT91_PIT_SR) & AT91_PIT_PITS) { /* This is a shared interrupt */
1412 - /* Get number to ticks performed before interrupt and clear PIT interrupt */
1413 + /* The PIT interrupt may be disabled, and is shared */
1414 + if ((pit_clkevt.mode == CLOCK_EVT_MODE_PERIODIC)
1415 + && (at91_sys_read(AT91_PIT_SR) & AT91_PIT_PITS)) {
1416 + unsigned nr_ticks;
1418 + /* Get number of ticks performed before irq, and ack it */
1419 nr_ticks = PIT_PICNT(at91_sys_read(AT91_PIT_PIVR));
1422 + pit_cnt += pit_cycle;
1423 + pit_clkevt.event_handler(&pit_clkevt);
1429 - return IRQ_NONE; /* not handled */
1435 -static struct irqaction at91sam926x_timer_irq = {
1436 +static struct irqaction at91sam926x_pit_irq = {
1437 .name = "at91_tick",
1438 .flags = IRQF_SHARED | IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
1439 - .handler = at91sam926x_timer_interrupt
1440 + .handler = at91sam926x_pit_interrupt
1443 -void at91sam926x_timer_reset(void)
1444 +static void at91sam926x_pit_reset(void)
1446 - /* Disable timer */
1447 + /* Disable timer and irqs */
1448 at91_sys_write(AT91_PIT_MR, 0);
1450 - /* Clear any pending interrupts */
1451 - (void) at91_sys_read(AT91_PIT_PIVR);
1452 + /* Clear any pending interrupts, wait for PIT to stop counting */
1453 + while (PIT_CPIV(at91_sys_read(AT91_PIT_PIVR)) != 0)
1456 - /* Set Period Interval timer and enable its interrupt */
1457 - at91_sys_write(AT91_PIT_MR, (LATCH & AT91_PIT_PIV) | AT91_PIT_PITIEN | AT91_PIT_PITEN);
1458 + /* Start PIT but don't enable IRQ */
1459 + at91_sys_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN);
1463 - * Set up timer interrupt.
1464 + * Set up both clocksource and clockevent support.
1466 -void __init at91sam926x_timer_init(void)
1467 +static void __init at91sam926x_pit_init(void)
1469 + unsigned long pit_rate;
1473 + * Use our actual MCK to figure out how many MCK/16 ticks per
1474 + * 1/HZ period (instead of a compile-time constant LATCH).
1476 + pit_rate = clk_get_rate(clk_get(NULL, "mck")) / 16;
1477 + pit_cycle = (pit_rate + HZ/2) / HZ;
1478 + WARN_ON(((pit_cycle - 1) & ~AT91_PIT_PIV) != 0);
1480 /* Initialize and enable the timer */
1481 - at91sam926x_timer_reset();
1482 + at91sam926x_pit_reset();
1484 - /* Make IRQs happen for the system timer. */
1485 - setup_irq(AT91_ID_SYS, &at91sam926x_timer_irq);
1487 + * Register clocksource. The high order bits of PIV are unused,
1488 + * so this isn't a 32-bit counter unless we get clockevent irqs.
1490 + pit_clk.mult = clocksource_hz2mult(pit_rate, pit_clk.shift);
1491 + bits = 12 /* PICNT */ + ilog2(pit_cycle) /* PIV */;
1492 + pit_clk.mask = CLOCKSOURCE_MASK(bits);
1493 + clocksource_register(&pit_clk);
1495 + /* Set up irq handler */
1496 + setup_irq(AT91_ID_SYS, &at91sam926x_pit_irq);
1498 + /* Set up and register clockevents */
1499 + pit_clkevt.mult = div_sc(pit_rate, NSEC_PER_SEC, pit_clkevt.shift);
1500 + clockevents_register_device(&pit_clkevt);
1504 -static void at91sam926x_timer_suspend(void)
1505 +static void at91sam926x_pit_suspend(void)
1508 at91_sys_write(AT91_PIT_MR, 0);
1511 -#define at91sam926x_timer_suspend NULL
1514 struct sys_timer at91sam926x_timer = {
1515 - .init = at91sam926x_timer_init,
1516 - .offset = at91sam926x_gettimeoffset,
1517 - .suspend = at91sam926x_timer_suspend,
1518 - .resume = at91sam926x_timer_reset,
1519 + .init = at91sam926x_pit_init,
1520 + .suspend = at91sam926x_pit_suspend,
1521 + .resume = at91sam926x_pit_reset,
1524 --- a/arch/arm/mach-at91/at91sam9rl.c
1525 +++ b/arch/arm/mach-at91/at91sam9rl.c
1529 #include <linux/module.h>
1530 +#include <linux/pm.h>
1532 #include <asm/mach/arch.h>
1533 #include <asm/mach/map.h>
1535 #include <asm/arch/at91sam9rl.h>
1536 #include <asm/arch/at91_pmc.h>
1537 #include <asm/arch/at91_rstc.h>
1538 +#include <asm/arch/at91_shdwc.h>
1540 #include "generic.h"
1542 @@ -244,6 +246,11 @@ static void at91sam9rl_reset(void)
1543 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
1546 +static void at91sam9rl_poweroff(void)
1548 + at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
1552 /* --------------------------------------------------------------------
1553 * AT91SAM9RL processor initialization
1554 @@ -274,6 +281,7 @@ void __init at91sam9rl_initialize(unsign
1555 iotable_init(at91sam9rl_sram_desc, ARRAY_SIZE(at91sam9rl_sram_desc));
1557 at91_arch_reset = at91sam9rl_reset;
1558 + pm_power_off = at91sam9rl_poweroff;
1559 at91_extern_irq = (1 << AT91SAM9RL_ID_IRQ0);
1561 /* Init clock subsystem */
1562 --- a/arch/arm/mach-at91/at91sam9rl_devices.c
1563 +++ b/arch/arm/mach-at91/at91sam9rl_devices.c
1564 @@ -20,12 +20,107 @@
1565 #include <asm/arch/gpio.h>
1566 #include <asm/arch/at91sam9rl.h>
1567 #include <asm/arch/at91sam9rl_matrix.h>
1568 -#include <asm/arch/at91sam926x_mc.h>
1569 +#include <asm/arch/at91sam9_smc.h>
1571 #include "generic.h"
1574 /* --------------------------------------------------------------------
1575 + * USB HS Device (Gadget)
1576 + * -------------------------------------------------------------------- */
1578 +#if defined(CONFIG_USB_GADGET_ATMEL_USBA) || defined(CONFIG_USB_GADGET_ATMEL_USBA_MODULE)
1580 +static struct resource usba_udc_resources[] = {
1582 + .start = AT91SAM9RL_UDPHS_FIFO,
1583 + .end = AT91SAM9RL_UDPHS_FIFO + SZ_512K - 1,
1584 + .flags = IORESOURCE_MEM,
1587 + .start = AT91SAM9RL_BASE_UDPHS,
1588 + .end = AT91SAM9RL_BASE_UDPHS + SZ_1K - 1,
1589 + .flags = IORESOURCE_MEM,
1592 + .start = AT91SAM9RL_ID_UDPHS,
1593 + .end = AT91SAM9RL_ID_UDPHS,
1594 + .flags = IORESOURCE_IRQ,
1598 +#define EP(nam, idx, maxpkt, maxbk, dma, isoc) \
1602 + .fifo_size = maxpkt, \
1603 + .nr_banks = maxbk, \
1605 + .can_isoc = isoc, \
1608 +static struct usba_ep_data usba_udc_ep[] __initdata = {
1609 + EP("ep0", 0, 64, 1, 0, 0),
1610 + EP("ep1", 1, 1024, 2, 1, 1),
1611 + EP("ep2", 2, 1024, 2, 1, 1),
1612 + EP("ep3", 3, 1024, 3, 1, 0),
1613 + EP("ep4", 4, 1024, 3, 1, 0),
1614 + EP("ep5", 5, 1024, 3, 1, 1),
1615 + EP("ep6", 6, 1024, 3, 1, 1),
1621 + * pdata doesn't have room for any endpoints, so we need to
1622 + * append room for the ones we need right after it.
1625 + struct usba_platform_data pdata;
1626 + struct usba_ep_data ep[7];
1629 +static struct platform_device at91_usba_udc_device = {
1630 + .name = "atmel_usba_udc",
1633 + .platform_data = &usba_udc_data.pdata,
1635 + .resource = usba_udc_resources,
1636 + .num_resources = ARRAY_SIZE(usba_udc_resources),
1639 +void __init at91_add_device_usba(struct usba_platform_data *data)
1642 + * Invalid pins are 0 on AT91, but the usba driver is shared
1643 + * with AVR32, which use negative values instead. Once/if
1644 + * gpio_is_valid() is ported to AT91, revisit this code.
1646 + usba_udc_data.pdata.vbus_pin = -EINVAL;
1647 + usba_udc_data.pdata.num_ep = ARRAY_SIZE(usba_udc_ep);
1648 + memcpy(usba_udc_data.ep, usba_udc_ep, sizeof(usba_udc_ep));;
1650 + if (data && data->vbus_pin > 0) {
1651 + at91_set_gpio_input(data->vbus_pin, 0);
1652 + at91_set_deglitch(data->vbus_pin, 1);
1653 + usba_udc_data.pdata.vbus_pin = data->vbus_pin;
1656 + /* Pullup pin is handled internally by USB device peripheral */
1659 + at91_clock_associate("utmi_clk", &at91_usba_udc_device.dev, "hclk");
1660 + at91_clock_associate("udphs_clk", &at91_usba_udc_device.dev, "pclk");
1662 + platform_device_register(&at91_usba_udc_device);
1665 +void __init at91_add_device_usba(struct usba_platform_data *data) {}
1669 +/* --------------------------------------------------------------------
1671 * -------------------------------------------------------------------- */
1673 @@ -105,10 +200,15 @@ static struct at91_nand_data nand_data;
1674 #define NAND_BASE AT91_CHIPSELECT_3
1676 static struct resource nand_resources[] = {
1680 .end = NAND_BASE + SZ_256M - 1,
1681 .flags = IORESOURCE_MEM,
1684 + .start = AT91_BASE_SYS + AT91_ECC,
1685 + .end = AT91_BASE_SYS + AT91_ECC + SZ_512 - 1,
1686 + .flags = IORESOURCE_MEM,
1690 @@ -385,6 +485,100 @@ void __init at91_add_device_lcdc(struct
1693 /* --------------------------------------------------------------------
1694 + * Timer/Counter block
1695 + * -------------------------------------------------------------------- */
1697 +#ifdef CONFIG_ATMEL_TCLIB
1699 +static struct resource tcb_resources[] = {
1701 + .start = AT91SAM9RL_BASE_TCB0,
1702 + .end = AT91SAM9RL_BASE_TCB0 + SZ_16K - 1,
1703 + .flags = IORESOURCE_MEM,
1706 + .start = AT91SAM9RL_ID_TC0,
1707 + .end = AT91SAM9RL_ID_TC0,
1708 + .flags = IORESOURCE_IRQ,
1711 + .start = AT91SAM9RL_ID_TC1,
1712 + .end = AT91SAM9RL_ID_TC1,
1713 + .flags = IORESOURCE_IRQ,
1716 + .start = AT91SAM9RL_ID_TC2,
1717 + .end = AT91SAM9RL_ID_TC2,
1718 + .flags = IORESOURCE_IRQ,
1722 +static struct platform_device at91sam9rl_tcb_device = {
1723 + .name = "atmel_tcb",
1725 + .resource = tcb_resources,
1726 + .num_resources = ARRAY_SIZE(tcb_resources),
1729 +static void __init at91_add_device_tc(void)
1731 + /* this chip has a separate clock and irq for each TC channel */
1732 + at91_clock_associate("tc0_clk", &at91sam9rl_tcb_device.dev, "t0_clk");
1733 + at91_clock_associate("tc1_clk", &at91sam9rl_tcb_device.dev, "t1_clk");
1734 + at91_clock_associate("tc2_clk", &at91sam9rl_tcb_device.dev, "t2_clk");
1735 + platform_device_register(&at91sam9rl_tcb_device);
1738 +static void __init at91_add_device_tc(void) { }
1742 +/* --------------------------------------------------------------------
1744 + * -------------------------------------------------------------------- */
1746 +#if defined(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) || defined(CONFIG_TOUCHSCREEN_ATMEL_TSADCC_MODULE)
1747 +static u64 tsadcc_dmamask = DMA_BIT_MASK(32);
1749 +static struct resource tsadcc_resources[] = {
1751 + .start = AT91SAM9RL_BASE_TSC,
1752 + .end = AT91SAM9RL_BASE_TSC + SZ_16K - 1,
1753 + .flags = IORESOURCE_MEM,
1756 + .start = AT91SAM9RL_ID_TSC,
1757 + .end = AT91SAM9RL_ID_TSC,
1758 + .flags = IORESOURCE_IRQ,
1762 +static struct platform_device at91_tsadcc_device = {
1763 + .name = "atmel_tsadcc",
1766 + .dma_mask = &tsadcc_dmamask,
1767 + .coherent_dma_mask = DMA_BIT_MASK(32),
1769 + .resource = tsadcc_resources,
1770 + .num_resources = ARRAY_SIZE(tsadcc_resources),
1773 +void __init at91_add_device_tsadcc(void)
1775 + at91_set_A_periph(AT91_PIN_PA17, 0); /* AD0_XR */
1776 + at91_set_A_periph(AT91_PIN_PA18, 0); /* AD1_XL */
1777 + at91_set_A_periph(AT91_PIN_PA19, 0); /* AD2_YT */
1778 + at91_set_A_periph(AT91_PIN_PA20, 0); /* AD3_TB */
1780 + platform_device_register(&at91_tsadcc_device);
1783 +void __init at91_add_device_tsadcc(void) {}
1787 +/* --------------------------------------------------------------------
1789 * -------------------------------------------------------------------- */
1791 @@ -397,6 +591,7 @@ static struct platform_device at91sam9rl
1793 static void __init at91_add_device_rtc(void)
1795 + device_init_wakeup(&at91sam9rl_rtc_device.dev, 1);
1796 platform_device_register(&at91sam9rl_rtc_device);
1799 @@ -418,13 +613,14 @@ static struct resource rtt_resources[] =
1801 static struct platform_device at91sam9rl_rtt_device = {
1805 .resource = rtt_resources,
1806 .num_resources = ARRAY_SIZE(rtt_resources),
1809 static void __init at91_add_device_rtt(void)
1811 + device_init_wakeup(&at91sam9rl_rtt_device.dev, 1);
1812 platform_device_register(&at91sam9rl_rtt_device);
1815 @@ -539,9 +735,6 @@ static inline void configure_ssc1_pins(u
1819 - * Return the device node so that board init code can use it as the
1820 - * parent for the device node reflecting how it's used on this board.
1822 * SSC controllers are accessed through library code, instead of any
1823 * kind of all-singing/all-dancing driver. For example one could be
1824 * used by a particular I2S audio codec's driver, while another one
1825 @@ -802,7 +995,7 @@ static inline void configure_usart3_pins
1826 at91_set_B_periph(AT91_PIN_PD3, 0); /* CTS3 */
1829 -static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
1830 +static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
1831 struct platform_device *atmel_default_console_device; /* the serial console device */
1833 void __init __deprecated at91_init_serial(struct at91_uart_config *config)
1834 @@ -893,8 +1086,6 @@ void __init at91_set_serial_console(unsi
1836 if (portnr < ATMEL_MAX_UART)
1837 atmel_default_console_device = at91_uarts[portnr];
1838 - if (!atmel_default_console_device)
1839 - printk(KERN_INFO "AT91: No default serial console defined.\n");
1842 void __init at91_add_device_serial(void)
1843 @@ -905,6 +1096,9 @@ void __init at91_add_device_serial(void)
1845 platform_device_register(at91_uarts[i]);
1848 + if (!atmel_default_console_device)
1849 + printk(KERN_INFO "AT91: No default serial console defined.\n");
1852 void __init __deprecated at91_init_serial(struct at91_uart_config *config) {}
1853 @@ -925,6 +1119,7 @@ static int __init at91_add_standard_devi
1854 at91_add_device_rtc();
1855 at91_add_device_rtt();
1856 at91_add_device_watchdog();
1857 + at91_add_device_tc();
1862 +++ b/arch/arm/mach-at91/board-cam60.c
1865 + * KwikByte CAM60 (KB9260)
1867 + * based on board-sam9260ek.c
1868 + * Copyright (C) 2005 SAN People
1869 + * Copyright (C) 2006 Atmel
1871 + * This program is free software; you can redistribute it and/or modify
1872 + * it under the terms of the GNU General Public License as published by
1873 + * the Free Software Foundation; either version 2 of the License, or
1874 + * (at your option) any later version.
1876 + * This program is distributed in the hope that it will be useful,
1877 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1878 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1879 + * GNU General Public License for more details.
1881 + * You should have received a copy of the GNU General Public License
1882 + * along with this program; if not, write to the Free Software
1883 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1886 +#include <linux/types.h>
1887 +#include <linux/init.h>
1888 +#include <linux/mm.h>
1889 +#include <linux/module.h>
1890 +#include <linux/platform_device.h>
1891 +#include <linux/spi/spi.h>
1892 +#include <linux/spi/flash.h>
1894 +#include <asm/hardware.h>
1895 +#include <asm/setup.h>
1896 +#include <asm/mach-types.h>
1897 +#include <asm/irq.h>
1899 +#include <asm/mach/arch.h>
1900 +#include <asm/mach/map.h>
1901 +#include <asm/mach/irq.h>
1903 +#include <asm/arch/board.h>
1904 +#include <asm/arch/gpio.h>
1906 +#include "generic.h"
1909 +static void __init cam60_map_io(void)
1911 + /* Initialize processor: 10 MHz crystal */
1912 + at91sam9260_initialize(10000000);
1914 + /* DGBU on ttyS0. (Rx & Tx only) */
1915 + at91_register_uart(0, 0, 0);
1917 + /* set serial console to ttyS0 (ie, DBGU) */
1918 + at91_set_serial_console(0);
1921 +static void __init cam60_init_irq(void)
1923 + at91sam9260_init_interrupts(NULL);
1930 +static struct at91_usbh_data __initdata cam60_usbh_data = {
1938 +#if defined(CONFIG_MTD_DATAFLASH)
1939 +static struct mtd_partition __initdata cam60_spi_partitions[] = {
1947 + .offset = MTDPART_OFS_NXTBLK,
1948 + .size = 256 * 1056,
1952 + .offset = MTDPART_OFS_NXTBLK,
1953 + .size = 2222 * 1056,
1956 + .name = "file system",
1957 + .offset = MTDPART_OFS_NXTBLK,
1958 + .size = MTDPART_SIZ_FULL,
1962 +static struct flash_platform_data __initdata cam60_spi_flash_platform_data = {
1963 + .name = "spi_flash",
1964 + .parts = cam60_spi_partitions,
1965 + .nr_parts = ARRAY_SIZE(cam60_spi_partitions)
1969 +static struct spi_board_info cam60_spi_devices[] = {
1970 +#if defined(CONFIG_MTD_DATAFLASH)
1971 + { /* DataFlash chip */
1972 + .modalias = "mtd_dataflash",
1974 + .max_speed_hz = 15 * 1000 * 1000,
1976 + .platform_data = &cam60_spi_flash_platform_data
1983 + * MACB Ethernet device
1985 +static struct __initdata at91_eth_data cam60_macb_data = {
1986 + .phy_irq_pin = AT91_PIN_PB5,
1994 +static struct mtd_partition __initdata cam60_nand_partition[] = {
1996 + .name = "nand_fs",
1998 + .size = MTDPART_SIZ_FULL,
2002 +static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
2004 + *num_partitions = ARRAY_SIZE(cam60_nand_partition);
2005 + return cam60_nand_partition;
2008 +static struct at91_nand_data __initdata cam60_nand_data = {
2011 + // .det_pin = ... not there
2012 + .rdy_pin = AT91_PIN_PA9,
2013 + .enable_pin = AT91_PIN_PA7,
2014 + .partition_info = nand_partitions,
2018 +static void __init cam60_board_init(void)
2021 + at91_add_device_serial();
2023 + at91_add_device_spi(cam60_spi_devices, ARRAY_SIZE(cam60_spi_devices));
2025 + at91_add_device_eth(&cam60_macb_data);
2027 + /* enable USB power supply circuit */
2028 + at91_set_gpio_output(AT91_PIN_PB18, 1);
2029 + at91_add_device_usbh(&cam60_usbh_data);
2031 + at91_add_device_nand(&cam60_nand_data);
2034 +MACHINE_START(CAM60, "KwikByte CAM60")
2035 + /* Maintainer: KwikByte */
2036 + .phys_io = AT91_BASE_SYS,
2037 + .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
2038 + .boot_params = AT91_SDRAM_BASE + 0x100,
2039 + .timer = &at91sam926x_timer,
2040 + .map_io = cam60_map_io,
2041 + .init_irq = cam60_init_irq,
2042 + .init_machine = cam60_board_init,
2044 --- a/arch/arm/mach-at91/board-cap9adk.c
2045 +++ b/arch/arm/mach-at91/board-cap9adk.c
2047 #include <asm/hardware.h>
2048 #include <asm/setup.h>
2049 #include <asm/mach-types.h>
2050 -#include <asm/irq.h>
2052 #include <asm/mach/arch.h>
2053 #include <asm/mach/map.h>
2054 -#include <asm/mach/irq.h>
2056 #include <asm/arch/board.h>
2057 #include <asm/arch/gpio.h>
2058 #include <asm/arch/at91cap9_matrix.h>
2059 -#include <asm/arch/at91sam926x_mc.h>
2060 +#include <asm/arch/at91sam9_smc.h>
2062 #include "generic.h"
2064 @@ -78,6 +76,12 @@ static struct at91_usbh_data __initdata
2069 + * USB HS Device port
2071 +static struct usba_platform_data __initdata cap9adk_usba_udc_data = {
2072 + .vbus_pin = AT91_PIN_PB31,
2076 * ADS7846 Touchscreen
2077 @@ -130,7 +134,7 @@ static struct spi_board_info cap9adk_spi
2079 .modalias = "ads7846",
2080 .chip_select = 3, /* can be 2 or 3, depending on J2 jumper */
2081 - .max_speed_hz = 125000 * 26, /* (max sample rate @ 3V) * (cmd + data + overhead) */
2082 + .max_speed_hz = 125000 * 16, /* max sample rate * clocks per sample */
2084 .platform_data = &ads_info,
2085 .irq = AT91_PIN_PC4,
2086 @@ -324,8 +328,9 @@ static void __init cap9adk_board_init(vo
2088 at91_add_device_serial();
2090 - set_irq_type(AT91CAP9_ID_UHP, IRQT_HIGH);
2091 at91_add_device_usbh(&cap9adk_usbh_data);
2093 + at91_add_device_usba(&cap9adk_usba_udc_data);
2095 at91_add_device_spi(cap9adk_spi_devices, ARRAY_SIZE(cap9adk_spi_devices));
2097 @@ -341,7 +346,6 @@ static void __init cap9adk_board_init(vo
2099 at91_add_device_i2c(NULL, 0);
2100 /* LCD Controller */
2101 - set_irq_type(AT91CAP9_ID_LCDC, IRQT_HIGH);
2102 at91_add_device_lcdc(&cap9adk_lcdc_data);
2104 at91_add_device_ac97(&cap9adk_ac97_data);
2105 --- a/arch/arm/mach-at91/board-carmeva.c
2106 +++ b/arch/arm/mach-at91/board-carmeva.c
2108 #include "generic.h"
2112 - * Serial port configuration.
2113 - * 0 .. 3 = USART0 .. USART3
2116 -static struct at91_uart_config __initdata carmeva_uart_config = {
2117 - .console_tty = 0, /* ttyS0 */
2119 - .tty_map = { 4, 1, -1, -1, -1 } /* ttyS0, ..., ttyS4 */
2122 static void __init carmeva_map_io(void)
2124 /* Initialize processor: 20.000 MHz crystal */
2125 at91rm9200_initialize(20000000, AT91RM9200_BGA);
2127 - /* Setup the serial ports and console */
2128 - at91_init_serial(&carmeva_uart_config);
2129 + /* DBGU on ttyS0. (Rx & Tx only) */
2130 + at91_register_uart(0, 0, 0);
2132 + /* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
2133 + at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
2134 + | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
2137 + /* set serial console to ttyS0 (ie, DBGU) */
2138 + at91_set_serial_console(0);
2141 static void __init carmeva_init_irq(void)
2142 @@ -117,6 +114,30 @@ static struct spi_board_info carmeva_spi
2146 +static struct gpio_led carmeva_leds[] = {
2147 + { /* "user led 1", LED9 */
2149 + .gpio = AT91_PIN_PA21,
2151 + .default_trigger = "heartbeat",
2153 + { /* "user led 2", LED10 */
2155 + .gpio = AT91_PIN_PA25,
2158 + { /* "user led 3", LED11 */
2160 + .gpio = AT91_PIN_PA26,
2163 + { /* "user led 4", LED12 */
2165 + .gpio = AT91_PIN_PA18,
2170 static void __init carmeva_board_init(void)
2173 @@ -135,6 +156,8 @@ static void __init carmeva_board_init(vo
2174 // at91_add_device_cf(&carmeva_cf_data);
2176 at91_add_device_mmc(0, &carmeva_mmc_data);
2178 + at91_gpio_leds(carmeva_leds, ARRAY_SIZE(carmeva_leds));
2181 MACHINE_START(CARMEVA, "Carmeva")
2183 +++ b/arch/arm/mach-at91/board-chub.c
2186 + * linux/arch/arm/mach-at91/board-chub.c
2188 + * Copyright (C) 2005 SAN People, adapted for Promwad Chub board
2191 + * This program is free software; you can redistribute it and/or modify
2192 + * it under the terms of the GNU General Public License as published by
2193 + * the Free Software Foundation; either version 2 of the License, or
2194 + * (at your option) any later version.
2196 + * This program is distributed in the hope that it will be useful,
2197 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2198 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2199 + * GNU General Public License for more details.
2201 + * You should have received a copy of the GNU General Public License
2202 + * along with this program; if not, write to the Free Software
2203 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2206 +#include <linux/types.h>
2207 +#include <linux/init.h>
2208 +#include <linux/mm.h>
2209 +#include <linux/module.h>
2210 +#include <linux/platform_device.h>
2212 +#include <asm/hardware.h>
2213 +#include <asm/setup.h>
2214 +#include <asm/mach-types.h>
2215 +#include <asm/irq.h>
2217 +#include <asm/mach/arch.h>
2218 +#include <asm/mach/map.h>
2219 +#include <asm/mach/irq.h>
2221 +#include <asm/arch/board.h>
2222 +#include <asm/arch/gpio.h>
2224 +#include "generic.h"
2227 + * Serial port configuration.
2228 + * 0 .. 3 = USART0 .. USART3
2231 +static struct at91_uart_config __initdata chub_uart_config = {
2232 + .console_tty = 0, /* ttyS0 */
2234 + .tty_map = { 4, 0, 1, 2, 3 } /* ttyS0, ..., ttyS4 */
2237 +static void __init chub_init_irq(void)
2239 + at91rm9200_init_interrupts(NULL);
2242 +static void __init chub_map_io(void)
2244 + /* Initialize clocks: 18.432 MHz crystal */
2245 + at91rm9200_initialize(18432000, AT91RM9200_PQFP);
2247 + /* Setup the serial ports and console */
2248 + at91_init_serial(&chub_uart_config);
2251 +static struct at91_eth_data __initdata chub_eth_data = {
2252 + .phy_irq_pin = AT91_PIN_PB29,
2256 +static struct mtd_partition __initdata chub_nand_partition[] = {
2258 + .name = "NAND Partition 1",
2260 + .size = MTDPART_SIZ_FULL,
2264 +static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
2266 + *num_partitions = ARRAY_SIZE(chub_nand_partition);
2267 + return chub_nand_partition;
2270 +static struct at91_nand_data __initdata chub_nand_data = {
2273 + .enable_pin = AT91_PIN_PA27,
2274 + .partition_info = nand_partitions,
2277 +static struct spi_board_info chub_spi_devices[] = {
2278 + { /* DataFlash chip */
2279 + .modalias = "mtd_dataflash",
2281 + .max_speed_hz = 15 * 1000 * 1000,
2285 +static void __init chub_board_init(void)
2288 + at91_add_device_serial();
2290 + at91_add_device_i2c(NULL, 0);
2292 + at91_add_device_eth(&chub_eth_data);
2294 + at91_add_device_spi(chub_spi_devices, ARRAY_SIZE(chub_spi_devices));
2296 + at91_add_device_nand(&chub_nand_data);
2297 + /* Disable write protect for NAND */
2298 + at91_set_gpio_output(AT91_PIN_PB7, 1);
2299 + /* Power enable for 3x RS-232 and 1x RS-485 */
2300 + at91_set_gpio_output(AT91_PIN_PB9, 1);
2301 + /* Disable write protect for FRAM */
2302 + at91_set_gpio_output(AT91_PIN_PA21, 1);
2303 + /* Disable write protect for Dataflash */
2304 + at91_set_gpio_output(AT91_PIN_PA19, 1);
2307 +MACHINE_START(CHUB, "Promwad Chub")
2308 + /* Maintainer: Ivan Kuten AT Promwad DOT com */
2309 + .phys_io = AT91_BASE_SYS,
2310 + .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
2311 + .boot_params = AT91_SDRAM_BASE + 0x100,
2312 + .timer = &at91rm9200_timer,
2313 + .map_io = chub_map_io,
2314 + .init_irq = chub_init_irq,
2315 + .init_machine = chub_board_init,
2317 --- a/arch/arm/mach-at91/board-csb337.c
2318 +++ b/arch/arm/mach-at91/board-csb337.c
2319 @@ -61,6 +61,7 @@ static void __init csb337_map_io(void)
2321 /* Setup the LEDs */
2322 at91_init_leds(AT91_PIN_PB0, AT91_PIN_PB1);
2323 + at91_set_gpio_output(AT91_PIN_PB2, 1); /* third (unused) LED */
2325 /* Setup the serial ports and console */
2326 at91_init_serial(&csb337_uart_config);
2327 @@ -202,11 +203,11 @@ static struct platform_device csb300_but
2329 static void __init csb300_add_device_buttons(void)
2331 - at91_set_gpio_input(AT91_PIN_PB29, 0); /* sw0 */
2332 + at91_set_gpio_input(AT91_PIN_PB29, 1); /* sw0 */
2333 at91_set_deglitch(AT91_PIN_PB29, 1);
2334 - at91_set_gpio_input(AT91_PIN_PB28, 0); /* sw1 */
2335 + at91_set_gpio_input(AT91_PIN_PB28, 1); /* sw1 */
2336 at91_set_deglitch(AT91_PIN_PB28, 1);
2337 - at91_set_gpio_input(AT91_PIN_PA21, 0); /* sw2 */
2338 + at91_set_gpio_input(AT91_PIN_PA21, 1); /* sw2 */
2339 at91_set_deglitch(AT91_PIN_PA21, 1);
2341 platform_device_register(&csb300_button_device);
2342 @@ -233,7 +234,7 @@ static struct gpio_led csb_leds[] = {
2343 .gpio = AT91_PIN_PB0,
2345 .default_trigger = "ide-disk",
2351 --- a/arch/arm/mach-at91/board-csb637.c
2352 +++ b/arch/arm/mach-at91/board-csb637.c
2354 #include "generic.h"
2358 - * Serial port configuration.
2359 - * 0 .. 3 = USART0 .. USART3
2362 -static struct at91_uart_config __initdata csb637_uart_config = {
2363 - .console_tty = 0, /* ttyS0 */
2365 - .tty_map = { 4, 1, -1, -1, -1 } /* ttyS0, ..., ttyS4 */
2368 static void __init csb637_map_io(void)
2370 /* Initialize processor: 3.6864 MHz crystal */
2371 at91rm9200_initialize(3686400, AT91RM9200_BGA);
2373 - /* Setup the LEDs */
2374 - at91_init_leds(AT91_PIN_PB2, AT91_PIN_PB2);
2375 + /* DBGU on ttyS0. (Rx & Tx only) */
2376 + at91_register_uart(0, 0, 0);
2378 - /* Setup the serial ports and console */
2379 - at91_init_serial(&csb637_uart_config);
2380 + /* make console=ttyS0 (ie, DBGU) the default */
2381 + at91_set_serial_console(0);
2384 static void __init csb637_init_irq(void)
2385 @@ -118,8 +107,19 @@ static struct platform_device csb_flash
2386 .num_resources = ARRAY_SIZE(csb_flash_resources),
2389 +static struct gpio_led csb_leds[] = {
2392 + .gpio = AT91_PIN_PB2,
2394 + .default_trigger = "heartbeat",
2398 static void __init csb637_board_init(void)
2401 + at91_gpio_leds(csb_leds, ARRAY_SIZE(csb_leds));
2403 at91_add_device_serial();
2405 --- a/arch/arm/mach-at91/board-dk.c
2406 +++ b/arch/arm/mach-at91/board-dk.c
2408 #include <linux/init.h>
2409 #include <linux/mm.h>
2410 #include <linux/module.h>
2411 +#include <linux/dma-mapping.h>
2412 #include <linux/platform_device.h>
2413 #include <linux/spi/spi.h>
2414 #include <linux/mtd/physmap.h>
2416 #include "generic.h"
2420 - * Serial port configuration.
2421 - * 0 .. 3 = USART0 .. USART3
2424 -static struct at91_uart_config __initdata dk_uart_config = {
2425 - .console_tty = 0, /* ttyS0 */
2427 - .tty_map = { 4, 1, -1, -1, -1 } /* ttyS0, ..., ttyS4 */
2430 static void __init dk_map_io(void)
2432 /* Initialize processor: 18.432 MHz crystal */
2433 @@ -64,8 +54,16 @@ static void __init dk_map_io(void)
2434 /* Setup the LEDs */
2435 at91_init_leds(AT91_PIN_PB2, AT91_PIN_PB2);
2437 - /* Setup the serial ports and console */
2438 - at91_init_serial(&dk_uart_config);
2439 + /* DBGU on ttyS0. (Rx & Tx only) */
2440 + at91_register_uart(0, 0, 0);
2442 + /* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
2443 + at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
2444 + | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
2447 + /* set serial console to ttyS0 (ie, DBGU) */
2448 + at91_set_serial_console(0);
2451 static void __init dk_init_irq(void)
2452 @@ -73,6 +71,185 @@ static void __init dk_init_irq(void)
2453 at91rm9200_init_interrupts(NULL);
2456 +#if defined(CONFIG_FB_S1D13XXX) || defined(CONFIG_FB_S1D13XXX_MODULE)
2457 +#include <video/s1d13xxxfb.h>
2458 +#include <asm/arch/ics1523.h>
2460 +/* EPSON S1D13806 FB */
2461 +#define AT91_FB_REG_BASE 0x30000000L
2462 +#define AT91_FB_REG_SIZE 0x200
2463 +#define AT91_FB_VMEM_BASE 0x30200000L
2464 +#define AT91_FB_VMEM_SIZE 0x140000L
2466 +static void dk_init_video(void)
2468 + /* NWAIT Signal */
2469 + at91_set_A_periph(AT91_PIN_PC6, 0);
2471 + /* Initialization of the Static Memory Controller for Chip Select 2 */
2472 + at91_sys_write(AT91_SMC_CSR(2), AT91_SMC_DBW_16 /* 16 bit */
2473 + | AT91_SMC_WSEN | AT91_SMC_NWS_(4) /* wait states */
2474 + | AT91_SMC_TDF_(1) /* float time */
2477 + at91_ics1523_init();
2480 +/* CRT: (active) 640x480 60Hz (PCLK=CLKI=25.175MHz)
2481 + Memory: Embedded SDRAM (MCLK=CLKI3=50.000MHz) (BUSCLK=60.000MHz) */
2482 +static const struct s1d13xxxfb_regval dk_s1dfb_initregs[] = {
2483 + {S1DREG_MISC, 0x00}, /* Enable Memory/Register select bit */
2484 + {S1DREG_COM_DISP_MODE, 0x00}, /* disable display output */
2485 + {S1DREG_GPIO_CNF0, 0x00},
2486 + {S1DREG_GPIO_CNF1, 0x00},
2487 + {S1DREG_GPIO_CTL0, 0x08},
2488 + {S1DREG_GPIO_CTL1, 0x00},
2489 + {S1DREG_CLK_CNF, 0x01}, /* no divide, MCLK source is CLKI3 0x02*/
2490 + {S1DREG_LCD_CLK_CNF, 0x00},
2491 + {S1DREG_CRT_CLK_CNF, 0x00},
2492 + {S1DREG_MPLUG_CLK_CNF, 0x00},
2493 + {S1DREG_CPU2MEM_WST_SEL, 0x01}, /* 2*period(MCLK) - 4ns > period(BCLK) */
2494 + {S1DREG_SDRAM_REF_RATE, 0x03}, /* 32768 <= MCLK <= 50000 (MHz) */
2495 + {S1DREG_SDRAM_TC0, 0x00}, /* MCLK source freq (MHz): */
2496 + {S1DREG_SDRAM_TC1, 0x01}, /* 42 <= MCLK <= 50 */
2497 + {S1DREG_MEM_CNF, 0x80}, /* SDRAM Initialization - needed before mem access */
2498 + {S1DREG_PANEL_TYPE, 0x25}, /* std TFT 16bit, 8bit SCP format 2, single passive LCD */
2499 + {S1DREG_MOD_RATE, 0x00}, /* toggle every FPFRAME */
2500 + {S1DREG_LCD_DISP_HWIDTH, 0x4F}, /* 680 pix */
2501 + {S1DREG_LCD_NDISP_HPER, 0x12}, /* 152 pix */
2502 + {S1DREG_TFT_FPLINE_START, 0x01}, /* 13 pix */
2503 + {S1DREG_TFT_FPLINE_PWIDTH, 0x0B}, /* 96 pix */
2504 + {S1DREG_LCD_DISP_VHEIGHT0, 0xDF},
2505 + {S1DREG_LCD_DISP_VHEIGHT1, 0x01}, /* 480 lines */
2506 + {S1DREG_LCD_NDISP_VPER, 0x2C}, /* 44 lines */
2507 + {S1DREG_TFT_FPFRAME_START, 0x0A}, /* 10 lines */
2508 + {S1DREG_TFT_FPFRAME_PWIDTH, 0x01}, /* 2 lines */
2509 + {S1DREG_LCD_DISP_MODE, 0x05}, /* 16 bpp */
2510 + {S1DREG_LCD_MISC, 0x00}, /* dithering enabled, dual panel buffer enabled */
2511 + {S1DREG_LCD_DISP_START0, 0x00},
2512 + {S1DREG_LCD_DISP_START1, 0xC8},
2513 + {S1DREG_LCD_DISP_START2, 0x00},
2514 + {S1DREG_LCD_MEM_OFF0, 0x80},
2515 + {S1DREG_LCD_MEM_OFF1, 0x02},
2516 + {S1DREG_LCD_PIX_PAN, 0x00},
2517 + {S1DREG_LCD_DISP_FIFO_HTC, 0x3B},
2518 + {S1DREG_LCD_DISP_FIFO_LTC, 0x3C},
2519 + {S1DREG_CRT_DISP_HWIDTH, 0x4F}, /* 680 pix */
2520 + {S1DREG_CRT_NDISP_HPER, 0x13}, /* 160 pix */
2521 + {S1DREG_CRT_HRTC_START, 0x01}, /* 13 pix */
2522 + {S1DREG_CRT_HRTC_PWIDTH, 0x0B}, /* 96 pix */
2523 + {S1DREG_CRT_DISP_VHEIGHT0, 0xDF},
2524 + {S1DREG_CRT_DISP_VHEIGHT1, 0x01}, /* 480 lines */
2525 + {S1DREG_CRT_NDISP_VPER, 0x2B}, /* 44 lines */
2526 + {S1DREG_CRT_VRTC_START, 0x09}, /* 10 lines */
2527 + {S1DREG_CRT_VRTC_PWIDTH, 0x01}, /* 2 lines */
2528 + {S1DREG_TV_OUT_CTL, 0x10},
2529 + {S1DREG_CRT_DISP_MODE, 0x05}, /* 16 bpp */
2530 + {S1DREG_CRT_DISP_START0, 0x00},
2531 + {S1DREG_CRT_DISP_START1, 0x00},
2532 + {S1DREG_CRT_DISP_START2, 0x00},
2533 + {S1DREG_CRT_MEM_OFF0, 0x80},
2534 + {S1DREG_CRT_MEM_OFF1, 0x02},
2535 + {S1DREG_CRT_PIX_PAN, 0x00},
2536 + {S1DREG_CRT_DISP_FIFO_HTC, 0x3B},
2537 + {S1DREG_CRT_DISP_FIFO_LTC, 0x3C},
2538 + {S1DREG_LCD_CUR_CTL, 0x00}, /* inactive */
2539 + {S1DREG_LCD_CUR_START, 0x01},
2540 + {S1DREG_LCD_CUR_XPOS0, 0x00},
2541 + {S1DREG_LCD_CUR_XPOS1, 0x00},
2542 + {S1DREG_LCD_CUR_YPOS0, 0x00},
2543 + {S1DREG_LCD_CUR_YPOS1, 0x00},
2544 + {S1DREG_LCD_CUR_BCTL0, 0x00},
2545 + {S1DREG_LCD_CUR_GCTL0, 0x00},
2546 + {S1DREG_LCD_CUR_RCTL0, 0x00},
2547 + {S1DREG_LCD_CUR_BCTL1, 0x1F},
2548 + {S1DREG_LCD_CUR_GCTL1, 0x3F},
2549 + {S1DREG_LCD_CUR_RCTL1, 0x1F},
2550 + {S1DREG_LCD_CUR_FIFO_HTC, 0x00},
2551 + {S1DREG_CRT_CUR_CTL, 0x00}, /* inactive */
2552 + {S1DREG_CRT_CUR_START, 0x01},
2553 + {S1DREG_CRT_CUR_XPOS0, 0x00},
2554 + {S1DREG_CRT_CUR_XPOS1, 0x00},
2555 + {S1DREG_CRT_CUR_YPOS0, 0x00},
2556 + {S1DREG_CRT_CUR_YPOS1, 0x00},
2557 + {S1DREG_CRT_CUR_BCTL0, 0x00},
2558 + {S1DREG_CRT_CUR_GCTL0, 0x00},
2559 + {S1DREG_CRT_CUR_RCTL0, 0x00},
2560 + {S1DREG_CRT_CUR_BCTL1, 0x1F},
2561 + {S1DREG_CRT_CUR_GCTL1, 0x3F},
2562 + {S1DREG_CRT_CUR_RCTL1, 0x1F},
2563 + {S1DREG_CRT_CUR_FIFO_HTC, 0x00},
2564 + {S1DREG_BBLT_CTL0, 0x00},
2565 + {S1DREG_BBLT_CTL0, 0x00},
2566 + {S1DREG_BBLT_CC_EXP, 0x00},
2567 + {S1DREG_BBLT_OP, 0x00},
2568 + {S1DREG_BBLT_SRC_START0, 0x00},
2569 + {S1DREG_BBLT_SRC_START1, 0x00},
2570 + {S1DREG_BBLT_SRC_START2, 0x00},
2571 + {S1DREG_BBLT_DST_START0, 0x00},
2572 + {S1DREG_BBLT_DST_START1, 0x00},
2573 + {S1DREG_BBLT_DST_START2, 0x00},
2574 + {S1DREG_BBLT_MEM_OFF0, 0x00},
2575 + {S1DREG_BBLT_MEM_OFF1, 0x00},
2576 + {S1DREG_BBLT_WIDTH0, 0x00},
2577 + {S1DREG_BBLT_WIDTH1, 0x00},
2578 + {S1DREG_BBLT_HEIGHT0, 0x00},
2579 + {S1DREG_BBLT_HEIGHT1, 0x00},
2580 + {S1DREG_BBLT_BGC0, 0x00},
2581 + {S1DREG_BBLT_BGC1, 0x00},
2582 + {S1DREG_BBLT_FGC0, 0x00},
2583 + {S1DREG_BBLT_FGC1, 0x00},
2584 + {S1DREG_LKUP_MODE, 0x00}, /* LCD LUT r | LCD and CRT/TV LUT w */
2585 + {S1DREG_LKUP_ADDR, 0x00},
2586 + {S1DREG_PS_CNF, 0x00}, /* Power Save disable */
2587 + {S1DREG_PS_STATUS, 0x02}, /* LCD Panel down, mem up */
2588 + {S1DREG_CPU2MEM_WDOGT, 0x00},
2589 + {S1DREG_COM_DISP_MODE, 0x02}, /* enable CRT display output */
2592 +static struct s1d13xxxfb_pdata dk_s1dfb_pdata = {
2593 + .initregs = dk_s1dfb_initregs,
2594 + .initregssize = ARRAY_SIZE(dk_s1dfb_initregs),
2595 + .platform_init_video = dk_init_video,
2598 +static u64 s1dfb_dmamask = DMA_BIT_MASK(32);
2600 +static struct resource dk_s1dfb_resource[] = {
2601 + [0] = { /* video mem */
2602 + .name = "s1d13806 memory",
2603 + .start = AT91_FB_VMEM_BASE,
2604 + .end = AT91_FB_VMEM_BASE + AT91_FB_VMEM_SIZE -1,
2605 + .flags = IORESOURCE_MEM,
2607 + [1] = { /* video registers */
2608 + .name = "s1d13806 registers",
2609 + .start = AT91_FB_REG_BASE,
2610 + .end = AT91_FB_REG_BASE + AT91_FB_REG_SIZE -1,
2611 + .flags = IORESOURCE_MEM,
2615 +static struct platform_device dk_s1dfb_device = {
2616 + .name = "s1d13806fb",
2619 + .dma_mask = &s1dfb_dmamask,
2620 + .coherent_dma_mask = DMA_BIT_MASK(32),
2621 + .platform_data = &dk_s1dfb_pdata,
2623 + .resource = dk_s1dfb_resource,
2624 + .num_resources = ARRAY_SIZE(dk_s1dfb_resource),
2627 +static void __init dk_add_device_video(void)
2629 + platform_device_register(&dk_s1dfb_device);
2632 +static void __init dk_add_device_video(void) {}
2635 static struct at91_eth_data __initdata dk_eth_data = {
2636 .phy_irq_pin = AT91_PIN_PC4,
2638 @@ -164,7 +341,7 @@ static struct at91_nand_data __initdata
2639 #define DK_FLASH_SIZE 0x200000
2641 static struct physmap_flash_data dk_flash_data = {
2646 static struct resource dk_flash_resource = {
2647 @@ -223,8 +400,12 @@ static void __init dk_board_init(void)
2648 platform_device_register(&dk_flash);
2650 at91_gpio_leds(dk_leds, ARRAY_SIZE(dk_leds));
2651 + /* SSC (to LM4549 audio codec) */
2652 + at91_add_device_ssc(AT91RM9200_ID_SSC1, ATMEL_SSC_TD | ATMEL_SSC_RX);
2653 + /* SSC (to SI3021 line interface) */
2654 + at91_add_device_ssc(AT91RM9200_ID_SSC2, ATMEL_SSC_TD | ATMEL_SSC_TK | ATMEL_SSC_RD | ATMEL_SSC_RF);
2656 -// dk_add_device_video();
2657 + dk_add_device_video();
2660 MACHINE_START(AT91RM9200DK, "Atmel AT91RM9200-DK")
2661 --- a/arch/arm/mach-at91/board-eb9200.c
2662 +++ b/arch/arm/mach-at91/board-eb9200.c
2664 #include "generic.h"
2668 - * Serial port configuration.
2669 - * 0 .. 3 = USART0 .. USART3
2672 -static struct at91_uart_config __initdata eb9200_uart_config = {
2673 - .console_tty = 0, /* ttyS0 */
2675 - .tty_map = { 4, 1, -1, -1, -1 } /* ttyS0, ..., ttyS4 */
2678 static void __init eb9200_map_io(void)
2680 /* Initialize processor: 18.432 MHz crystal */
2681 at91rm9200_initialize(18432000, AT91RM9200_BGA);
2683 - /* Setup the serial ports and console */
2684 - at91_init_serial(&eb9200_uart_config);
2685 + /* DBGU on ttyS0. (Rx & Tx only) */
2686 + at91_register_uart(0, 0, 0);
2688 + /* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
2689 + at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
2690 + | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
2693 + /* USART2 on ttyS2. (Rx, Tx) - IRDA */
2694 + at91_register_uart(AT91RM9200_ID_US2, 2, 0);
2696 + /* set serial console to ttyS0 (ie, DBGU) */
2697 + at91_set_serial_console(0);
2700 static void __init eb9200_init_irq(void)
2702 +++ b/arch/arm/mach-at91/board-ecbat91.c
2705 + * linux/arch/arm/mach-at91rm9200/board-ecbat91.c
2706 + * Copyright (C) 2007 emQbit.com.
2708 + * We started from board-dk.c, which is Copyright (C) 2005 SAN People.
2710 + * This program is free software; you can redistribute it and/or modify
2711 + * it under the terms of the GNU General Public License as published by
2712 + * the Free Software Foundation; either version 2 of the License, or
2713 + * (at your option) any later version.
2715 + * This program is distributed in the hope that it will be useful,
2716 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2717 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2718 + * GNU General Public License for more details.
2720 + * You should have received a copy of the GNU General Public License
2721 + * along with this program; if not, write to the Free Software
2722 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2725 +#include <linux/types.h>
2726 +#include <linux/init.h>
2727 +#include <linux/mm.h>
2728 +#include <linux/module.h>
2729 +#include <linux/platform_device.h>
2730 +#include <linux/spi/spi.h>
2731 +#include <linux/spi/flash.h>
2733 +#include <asm/hardware.h>
2734 +#include <asm/setup.h>
2735 +#include <asm/mach-types.h>
2736 +#include <asm/irq.h>
2738 +#include <asm/mach/arch.h>
2739 +#include <asm/mach/map.h>
2740 +#include <asm/mach/irq.h>
2742 +#include <asm/arch/board.h>
2743 +#include <asm/arch/gpio.h>
2745 +#include "generic.h"
2748 +static void __init ecb_at91map_io(void)
2750 + /* Initialize processor: 18.432 MHz crystal */
2751 + at91rm9200_initialize(18432000, AT91RM9200_PQFP);
2753 + /* Setup the LEDs */
2754 + at91_init_leds(AT91_PIN_PC7, AT91_PIN_PC7);
2756 + /* DBGU on ttyS0. (Rx & Tx only) */
2757 + at91_register_uart(0, 0, 0);
2759 + /* USART0 on ttyS1. (Rx & Tx only) */
2760 + at91_register_uart(AT91RM9200_ID_US0, 1, 0);
2762 + /* set serial console to ttyS0 (ie, DBGU) */
2763 + at91_set_serial_console(0);
2766 +static void __init ecb_at91init_irq(void)
2768 + at91rm9200_init_interrupts(NULL);
2771 +static struct at91_eth_data __initdata ecb_at91eth_data = {
2772 + .phy_irq_pin = AT91_PIN_PC4,
2776 +static struct at91_usbh_data __initdata ecb_at91usbh_data = {
2780 +static struct at91_mmc_data __initdata ecb_at91mmc_data = {
2786 +#if defined(CONFIG_MTD_DATAFLASH)
2787 +static struct mtd_partition __initdata my_flash0_partitions[] =
2790 + .name = "Darrell-loader",
2796 + .offset = MTDPART_OFS_NXTBLK,
2797 + .size = 110 * 1056,
2799 + { /* 1336 (167 blocks) pages * 1056 bytes = 0x158700 bytes */
2800 + .name = "Uoot-env",
2801 + .offset = MTDPART_OFS_NXTBLK,
2804 + { /* 1336 (167 blocks) pages * 1056 bytes = 0x158700 bytes */
2806 + .offset = MTDPART_OFS_NXTBLK,
2807 + .size = 1534 * 1056,
2809 + { /* 190200 - jffs2 root filesystem */
2810 + .name = "Filesystem",
2811 + .offset = MTDPART_OFS_NXTBLK,
2812 + .size = MTDPART_SIZ_FULL, /* 26 sectors */
2816 +static struct flash_platform_data __initdata my_flash0_platform = {
2817 + .name = "Removable flash card",
2818 + .parts = my_flash0_partitions,
2819 + .nr_parts = ARRAY_SIZE(my_flash0_partitions)
2824 +static struct spi_board_info __initdata ecb_at91spi_devices[] = {
2825 + { /* DataFlash chip */
2826 + .modalias = "mtd_dataflash",
2828 + .max_speed_hz = 10 * 1000 * 1000,
2830 +#if defined(CONFIG_MTD_DATAFLASH)
2831 + .platform_data = &my_flash0_platform,
2834 + { /* User accessable spi - cs1 (250KHz) */
2835 + .modalias = "spi-cs1",
2837 + .max_speed_hz = 250 * 1000,
2839 + { /* User accessable spi - cs2 (1MHz) */
2840 + .modalias = "spi-cs2",
2842 + .max_speed_hz = 1 * 1000 * 1000,
2844 + { /* User accessable spi - cs3 (10MHz) */
2845 + .modalias = "spi-cs3",
2847 + .max_speed_hz = 10 * 1000 * 1000,
2851 +static void __init ecb_at91board_init(void)
2854 + at91_add_device_serial();
2857 + at91_add_device_eth(&ecb_at91eth_data);
2860 + at91_add_device_usbh(&ecb_at91usbh_data);
2863 + at91_add_device_i2c(NULL, 0);
2866 + at91_add_device_mmc(0, &ecb_at91mmc_data);
2869 + at91_add_device_spi(ecb_at91spi_devices, ARRAY_SIZE(ecb_at91spi_devices));
2872 +MACHINE_START(ECBAT91, "emQbit's ECB_AT91")
2873 + /* Maintainer: emQbit.com */
2874 + .phys_io = AT91_BASE_SYS,
2875 + .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
2876 + .boot_params = AT91_SDRAM_BASE + 0x100,
2877 + .timer = &at91rm9200_timer,
2878 + .map_io = ecb_at91map_io,
2879 + .init_irq = ecb_at91init_irq,
2880 + .init_machine = ecb_at91board_init,
2882 --- a/arch/arm/mach-at91/board-ek.c
2883 +++ b/arch/arm/mach-at91/board-ek.c
2885 #include <linux/init.h>
2886 #include <linux/mm.h>
2887 #include <linux/module.h>
2888 +#include <linux/dma-mapping.h>
2889 #include <linux/platform_device.h>
2890 #include <linux/spi/spi.h>
2891 #include <linux/mtd/physmap.h>
2893 #include "generic.h"
2897 - * Serial port configuration.
2898 - * 0 .. 3 = USART0 .. USART3
2901 -static struct at91_uart_config __initdata ek_uart_config = {
2902 - .console_tty = 0, /* ttyS0 */
2904 - .tty_map = { 4, 1, -1, -1, -1 } /* ttyS0, ..., ttyS4 */
2907 static void __init ek_map_io(void)
2909 /* Initialize processor: 18.432 MHz crystal */
2910 @@ -64,8 +54,16 @@ static void __init ek_map_io(void)
2911 /* Setup the LEDs */
2912 at91_init_leds(AT91_PIN_PB1, AT91_PIN_PB2);
2914 - /* Setup the serial ports and console */
2915 - at91_init_serial(&ek_uart_config);
2916 + /* DBGU on ttyS0. (Rx & Tx only) */
2917 + at91_register_uart(0, 0, 0);
2919 + /* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
2920 + at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
2921 + | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
2924 + /* set serial console to ttyS0 (ie, DBGU) */
2925 + at91_set_serial_console(0);
2928 static void __init ek_init_irq(void)
2929 @@ -73,6 +71,187 @@ static void __init ek_init_irq(void)
2930 at91rm9200_init_interrupts(NULL);
2933 +#if defined(CONFIG_FB_S1D13XXX) || defined(CONFIG_FB_S1D13XXX_MODULE)
2934 +#include <video/s1d13xxxfb.h>
2935 +#include <asm/arch/ics1523.h>
2937 +/* EPSON S1D13806 FB */
2938 +#define AT91_FB_REG_BASE 0x40000000L
2939 +#define AT91_FB_REG_SIZE 0x200
2940 +#define AT91_FB_VMEM_BASE 0x40200000L
2941 +#define AT91_FB_VMEM_SIZE 0x140000L
2943 +static void ek_init_video(void)
2945 + /* NWAIT Signal */
2946 + at91_set_A_periph(AT91_PIN_PC6, 0);
2948 + /* Initialization of the Static Memory Controller for Chip Select 3 */
2949 + at91_sys_write(AT91_SMC_CSR(3), AT91_SMC_DBW_16 /* 16 bit */
2950 + | AT91_SMC_WSEN | AT91_SMC_NWS_(5) /* wait states */
2951 + | AT91_SMC_TDF_(1) /* float time */
2954 + at91_ics1523_init();
2957 +/* CRT: (active) 640x480 60Hz (PCLK=CLKI=25.175MHz)
2958 + Memory: Embedded SDRAM (MCLK=CLKI3=50.000MHz) (BUSCLK=60.000MHz) */
2959 +static const struct s1d13xxxfb_regval ek_s1dfb_initregs[] = {
2960 + {S1DREG_MISC, 0x00}, /* Enable Memory/Register select bit */
2961 + {S1DREG_COM_DISP_MODE, 0x00}, /* disable display output */
2962 + {S1DREG_GPIO_CNF0, 0xFF}, // 0x00
2963 + {S1DREG_GPIO_CNF1, 0x1F}, // 0x08
2964 + {S1DREG_GPIO_CTL0, 0x00},
2965 + {S1DREG_GPIO_CTL1, 0x00},
2966 + {S1DREG_CLK_CNF, 0x01}, /* no divide, MCLK source is CLKI3 0x02*/
2967 + {S1DREG_LCD_CLK_CNF, 0x00},
2968 + {S1DREG_CRT_CLK_CNF, 0x00},
2969 + {S1DREG_MPLUG_CLK_CNF, 0x00},
2970 + {S1DREG_CPU2MEM_WST_SEL, 0x01}, /* 2*period(MCLK) - 4ns > period(BCLK) */
2971 + {S1DREG_SDRAM_REF_RATE, 0x03}, /* 32768 <= MCLK <= 50000 (MHz) */
2972 + {S1DREG_SDRAM_TC0, 0x00}, /* MCLK source freq (MHz): */
2973 + {S1DREG_SDRAM_TC1, 0x01}, /* 42 <= MCLK <= 50 */
2974 + {S1DREG_MEM_CNF, 0x80}, /* SDRAM Initialization - needed before mem access */
2975 + {S1DREG_PANEL_TYPE, 0x25}, /* std TFT 16bit, 8bit SCP format 2, single passive LCD */
2976 + {S1DREG_MOD_RATE, 0x00}, /* toggle every FPFRAME */
2977 + {S1DREG_LCD_DISP_HWIDTH, 0x4F}, /* 680 pix */
2978 + {S1DREG_LCD_NDISP_HPER, 0x12}, /* 152 pix */
2979 + {S1DREG_TFT_FPLINE_START, 0x01}, /* 13 pix */
2980 + {S1DREG_TFT_FPLINE_PWIDTH, 0x0B}, /* 96 pix */
2981 + {S1DREG_LCD_DISP_VHEIGHT0, 0xDF},
2982 + {S1DREG_LCD_DISP_VHEIGHT1, 0x01}, /* 480 lines */
2983 + {S1DREG_LCD_NDISP_VPER, 0x2C}, /* 44 lines */
2984 + {S1DREG_TFT_FPFRAME_START, 0x0A}, /* 10 lines */
2985 + {S1DREG_TFT_FPFRAME_PWIDTH, 0x01}, /* 2 lines */
2986 + {S1DREG_LCD_DISP_MODE, 0x05}, /* 16 bpp */
2987 + {S1DREG_LCD_MISC, 0x00}, /* dithering enabled, dual panel buffer enabled */
2988 + {S1DREG_LCD_DISP_START0, 0x00},
2989 + {S1DREG_LCD_DISP_START1, 0xC8},
2990 + {S1DREG_LCD_DISP_START2, 0x00},
2991 + {S1DREG_LCD_MEM_OFF0, 0x80},
2992 + {S1DREG_LCD_MEM_OFF1, 0x02},
2993 + {S1DREG_LCD_PIX_PAN, 0x00},
2994 + {S1DREG_LCD_DISP_FIFO_HTC, 0x3B},
2995 + {S1DREG_LCD_DISP_FIFO_LTC, 0x3C},
2996 + {S1DREG_CRT_DISP_HWIDTH, 0x4F}, /* 680 pix */
2997 + {S1DREG_CRT_NDISP_HPER, 0x13}, /* 160 pix */
2998 + {S1DREG_CRT_HRTC_START, 0x01}, /* 13 pix */
2999 + {S1DREG_CRT_HRTC_PWIDTH, 0x0B}, /* 96 pix */
3000 + {S1DREG_CRT_DISP_VHEIGHT0, 0xDF},
3001 + {S1DREG_CRT_DISP_VHEIGHT1, 0x01}, /* 480 lines */
3002 + {S1DREG_CRT_NDISP_VPER, 0x2B}, /* 44 lines */
3003 + {S1DREG_CRT_VRTC_START, 0x09}, /* 10 lines */
3004 + {S1DREG_CRT_VRTC_PWIDTH, 0x01}, /* 2 lines */
3005 + {S1DREG_TV_OUT_CTL, 0x10},
3008 + {S1DREG_CRT_DISP_MODE, 0x05}, /* 16 bpp */
3009 + {S1DREG_CRT_DISP_START0, 0x00},
3010 + {S1DREG_CRT_DISP_START1, 0x00},
3011 + {S1DREG_CRT_DISP_START2, 0x00},
3012 + {S1DREG_CRT_MEM_OFF0, 0x80},
3013 + {S1DREG_CRT_MEM_OFF1, 0x02},
3014 + {S1DREG_CRT_PIX_PAN, 0x00},
3015 + {S1DREG_CRT_DISP_FIFO_HTC, 0x3B},
3016 + {S1DREG_CRT_DISP_FIFO_LTC, 0x3C},
3017 + {S1DREG_LCD_CUR_CTL, 0x00}, /* inactive */
3018 + {S1DREG_LCD_CUR_START, 0x01},
3019 + {S1DREG_LCD_CUR_XPOS0, 0x00},
3020 + {S1DREG_LCD_CUR_XPOS1, 0x00},
3021 + {S1DREG_LCD_CUR_YPOS0, 0x00},
3022 + {S1DREG_LCD_CUR_YPOS1, 0x00},
3023 + {S1DREG_LCD_CUR_BCTL0, 0x00},
3024 + {S1DREG_LCD_CUR_GCTL0, 0x00},
3025 + {S1DREG_LCD_CUR_RCTL0, 0x00},
3026 + {S1DREG_LCD_CUR_BCTL1, 0x1F},
3027 + {S1DREG_LCD_CUR_GCTL1, 0x3F},
3028 + {S1DREG_LCD_CUR_RCTL1, 0x1F},
3029 + {S1DREG_LCD_CUR_FIFO_HTC, 0x00},
3030 + {S1DREG_CRT_CUR_CTL, 0x00}, /* inactive */
3031 + {S1DREG_CRT_CUR_START, 0x01},
3032 + {S1DREG_CRT_CUR_XPOS0, 0x00},
3033 + {S1DREG_CRT_CUR_XPOS1, 0x00},
3034 + {S1DREG_CRT_CUR_YPOS0, 0x00},
3035 + {S1DREG_CRT_CUR_YPOS1, 0x00},
3036 + {S1DREG_CRT_CUR_BCTL0, 0x00},
3037 + {S1DREG_CRT_CUR_GCTL0, 0x00},
3038 + {S1DREG_CRT_CUR_RCTL0, 0x00},
3039 + {S1DREG_CRT_CUR_BCTL1, 0x1F},
3040 + {S1DREG_CRT_CUR_GCTL1, 0x3F},
3041 + {S1DREG_CRT_CUR_RCTL1, 0x1F},
3042 + {S1DREG_CRT_CUR_FIFO_HTC, 0x00},
3043 + {S1DREG_BBLT_CTL0, 0x00},
3044 + {S1DREG_BBLT_CTL0, 0x00},
3045 + {S1DREG_BBLT_CC_EXP, 0x00},
3046 + {S1DREG_BBLT_OP, 0x00},
3047 + {S1DREG_BBLT_SRC_START0, 0x00},
3048 + {S1DREG_BBLT_SRC_START1, 0x00},
3049 + {S1DREG_BBLT_SRC_START2, 0x00},
3050 + {S1DREG_BBLT_DST_START0, 0x00},
3051 + {S1DREG_BBLT_DST_START1, 0x00},
3052 + {S1DREG_BBLT_DST_START2, 0x00},
3053 + {S1DREG_BBLT_MEM_OFF0, 0x00},
3054 + {S1DREG_BBLT_MEM_OFF1, 0x00},
3055 + {S1DREG_BBLT_WIDTH0, 0x00},
3056 + {S1DREG_BBLT_WIDTH1, 0x00},
3057 + {S1DREG_BBLT_HEIGHT0, 0x00},
3058 + {S1DREG_BBLT_HEIGHT1, 0x00},
3059 + {S1DREG_BBLT_BGC0, 0x00},
3060 + {S1DREG_BBLT_BGC1, 0x00},
3061 + {S1DREG_BBLT_FGC0, 0x00},
3062 + {S1DREG_BBLT_FGC1, 0x00},
3063 + {S1DREG_LKUP_MODE, 0x00}, /* LCD LUT r | LCD and CRT/TV LUT w */
3064 + {S1DREG_LKUP_ADDR, 0x00},
3065 + {S1DREG_PS_CNF, 0x10}, /* Power Save disable */
3066 + {S1DREG_PS_STATUS, 0x02}, /* LCD Panel down, mem up */
3067 + {S1DREG_CPU2MEM_WDOGT, 0x00},
3068 + {S1DREG_COM_DISP_MODE, 0x02}, /* enable CRT display output */
3071 +static struct s1d13xxxfb_pdata ek_s1dfb_pdata = {
3072 + .initregs = ek_s1dfb_initregs,
3073 + .initregssize = ARRAY_SIZE(ek_s1dfb_initregs),
3074 + .platform_init_video = ek_init_video,
3077 +static u64 s1dfb_dmamask = DMA_BIT_MASK(32);
3079 +static struct resource ek_s1dfb_resource[] = {
3080 + [0] = { /* video mem */
3081 + .name = "s1d13806 memory",
3082 + .start = AT91_FB_VMEM_BASE,
3083 + .end = AT91_FB_VMEM_BASE + AT91_FB_VMEM_SIZE -1,
3084 + .flags = IORESOURCE_MEM,
3086 + [1] = { /* video registers */
3087 + .name = "s1d13806 registers",
3088 + .start = AT91_FB_REG_BASE,
3089 + .end = AT91_FB_REG_BASE + AT91_FB_REG_SIZE -1,
3090 + .flags = IORESOURCE_MEM,
3094 +static struct platform_device ek_s1dfb_device = {
3095 + .name = "s1d13806fb",
3098 + .dma_mask = &s1dfb_dmamask,
3099 + .coherent_dma_mask = DMA_BIT_MASK(32),
3100 + .platform_data = &ek_s1dfb_pdata,
3102 + .resource = ek_s1dfb_resource,
3103 + .num_resources = ARRAY_SIZE(ek_s1dfb_resource),
3106 +static void __init ek_add_device_video(void)
3108 + platform_device_register(&ek_s1dfb_device);
3111 +static void __init ek_add_device_video(void) {}
3114 static struct at91_eth_data __initdata ek_eth_data = {
3115 .phy_irq_pin = AT91_PIN_PC4,
3117 @@ -122,7 +301,7 @@ static struct i2c_board_info __initdata
3118 #define EK_FLASH_SIZE 0x200000
3120 static struct physmap_flash_data ek_flash_data = {
3125 static struct resource ek_flash_resource = {
3126 @@ -189,7 +368,7 @@ static void __init ek_board_init(void)
3128 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
3130 -// ek_add_device_video();
3131 + ek_add_device_video();
3134 MACHINE_START(AT91RM9200EK, "Atmel AT91RM9200-EK")
3136 +++ b/arch/arm/mach-at91/board-homematic.c
3139 + * linux/arch/arm/mach-at91/board-homematic.c
3141 + * Copyright (C) 2007 eQ-3 Entwicklung GmbH
3144 + * Copyright (C) 2005 SAN People
3146 + * This program is free software; you can redistribute it and/or modify
3147 + * it under the terms of the GNU General Public License as published by
3148 + * the Free Software Foundation; either version 2 of the License, or
3149 + * (at your option) any later version.
3151 + * This program is distributed in the hope that it will be useful,
3152 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3153 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3154 + * GNU General Public License for more details.
3156 + * You should have received a copy of the GNU General Public License
3157 + * along with this program; if not, write to the Free Software
3158 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3161 +#include <linux/types.h>
3162 +#include <linux/init.h>
3163 +#include <linux/mm.h>
3164 +#include <linux/module.h>
3165 +#include <linux/platform_device.h>
3166 +#include <linux/spi/spi.h>
3167 +#include <linux/mtd/physmap.h>
3169 +#include <asm/hardware.h>
3170 +#include <asm/setup.h>
3171 +#include <asm/mach-types.h>
3172 +#include <asm/irq.h>
3174 +#include <asm/mach/arch.h>
3175 +#include <asm/mach/map.h>
3176 +#include <asm/mach/irq.h>
3178 +#include <asm/arch/board.h>
3179 +#include <asm/arch/gpio.h>
3180 +#include <asm/arch/at91rm9200_mc.h>
3182 +#include "generic.h"
3186 + * Serial port configuration.
3187 + * 0 .. 3 = USART0 .. USART3
3190 +static struct at91_uart_config __initdata homematic_uart_config = {
3191 + .console_tty = 0, /* ttyS0 */
3193 + .tty_map = { 4, 1, -1, -1, -1 } /* ttyS0, ..., ttyS4 */
3196 +static void __init homematic_map_io(void)
3198 + /* Initialize processor: 18.432 MHz crystal */
3199 + at91rm9200_initialize(18432000, AT91RM9200_BGA);
3201 + /* Setup the serial ports and console */
3202 + at91_init_serial(&homematic_uart_config);
3205 +static void __init homematic_init_irq(void)
3207 + at91rm9200_init_interrupts(NULL);
3210 +static struct at91_eth_data __initdata homematic_eth_data = {
3211 + .phy_irq_pin = AT91_PIN_PC4,
3215 +static struct at91_usbh_data __initdata homematic_usbh_data = {
3219 +static struct at91_udc_data __initdata homematic_udc_data = {
3220 + .vbus_pin = AT91_PIN_PD4,
3221 + .pullup_pin = AT91_PIN_PD5,
3224 +static struct at91_mmc_data __initdata homematic_mmc_data = {
3229 +static struct spi_board_info homematic_spi_devices[] = {
3230 + { /* DataFlash chip */
3231 + .modalias = "mtd_dataflash",
3233 + .max_speed_hz = 15 * 1000 * 1000,
3237 +static struct mtd_partition __initdata homematic_nand_partition[] = {
3241 + .size = 0x02000000,
3243 + .name = "storage",
3244 + .offset = 0x02000000,
3245 + .size = MTDPART_SIZ_FULL,
3249 +static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
3251 + *num_partitions = ARRAY_SIZE(homematic_nand_partition);
3252 + return homematic_nand_partition;
3255 +static struct at91_nand_data __initdata homematic_nand_data = {
3258 +// .det_pin = AT91_PIN_PB1,
3259 + .rdy_pin = AT91_PIN_PC2,
3260 + .enable_pin = AT91_PIN_PC0,
3261 + .partition_info = nand_partitions,
3264 +static void __init homematic_board_init(void)
3267 + at91_add_device_serial();
3269 + at91_add_device_eth(&homematic_eth_data);
3271 + at91_add_device_usbh(&homematic_usbh_data);
3273 + at91_add_device_udc(&homematic_udc_data);
3274 + at91_set_multi_drive(homematic_udc_data.pullup_pin, 1); /* pullup_pin is connected to reset */
3276 + at91_add_device_i2c(NULL, 0);
3278 + at91_add_device_spi(homematic_spi_devices, ARRAY_SIZE(homematic_spi_devices));
3279 +#ifdef CONFIG_MTD_AT91_DATAFLASH_CARD
3280 + /* DataFlash card */
3281 + at91_set_gpio_output(AT91_PIN_PB7, 0);
3284 + at91_set_gpio_output(AT91_PIN_PB7, 1); /* this MMC card slot can optionally use SPI signaling (CS3). */
3285 + at91_add_device_mmc(0, &homematic_mmc_data);
3288 + at91_add_device_nand(&homematic_nand_data);
3291 +MACHINE_START(HOMEMATIC, "HomeMatic")
3292 + /* Maintainer: eQ-3 */
3293 + .phys_io = AT91_BASE_SYS,
3294 + .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
3295 + .boot_params = AT91_SDRAM_BASE + 0x100,
3296 + .timer = &at91rm9200_timer,
3297 + .map_io = homematic_map_io,
3298 + .init_irq = homematic_init_irq,
3299 + .init_machine = homematic_board_init,
3301 --- a/arch/arm/mach-at91/board-kb9202.c
3302 +++ b/arch/arm/mach-at91/board-kb9202.c
3304 #include <asm/arch/board.h>
3305 #include <asm/arch/gpio.h>
3307 -#include "generic.h"
3308 +#include <asm/arch/at91rm9200_mc.h>
3310 +#include "generic.h"
3313 - * Serial port configuration.
3314 - * 0 .. 3 = USART0 .. USART3
3317 -static struct at91_uart_config __initdata kb9202_uart_config = {
3318 - .console_tty = 0, /* ttyS0 */
3320 - .tty_map = { 4, 0, 1, -1, -1 } /* ttyS0, ..., ttyS4 */
3323 static void __init kb9202_map_io(void)
3325 @@ -59,8 +50,20 @@ static void __init kb9202_map_io(void)
3326 /* Set up the LEDs */
3327 at91_init_leds(AT91_PIN_PC19, AT91_PIN_PC18);
3329 - /* Setup the serial ports and console */
3330 - at91_init_serial(&kb9202_uart_config);
3331 + /* DBGU on ttyS0. (Rx & Tx only) */
3332 + at91_register_uart(0, 0, 0);
3334 + /* USART0 on ttyS1 (Rx & Tx only) */
3335 + at91_register_uart(AT91RM9200_ID_US0, 1, 0);
3337 + /* USART1 on ttyS2 (Rx & Tx only) - IRDA (optional) */
3338 + at91_register_uart(AT91RM9200_ID_US1, 2, 0);
3340 + /* USART3 on ttyS3 (Rx, Tx, CTS, RTS) - RS485 (optional) */
3341 + at91_register_uart(AT91RM9200_ID_US3, 3, ATMEL_UART_CTS | ATMEL_UART_RTS);
3343 + /* set serial console to ttyS0 (ie, DBGU) */
3344 + at91_set_serial_console(0);
3347 static void __init kb9202_init_irq(void)
3348 @@ -111,6 +114,48 @@ static struct at91_nand_data __initdata
3349 .partition_info = nand_partitions,
3353 +#if defined(CONFIG_FB_S1D15605)
3354 +#warning "The Reset pin must be passed via platform_data, not this way"
3355 +static struct resource kb9202_lcd_resources[] = {
3357 + .start = AT91_CHIPSELECT_2,
3358 + .end = AT91_CHIPSELECT_2 + 0x200FF,
3359 + .flags = IORESOURCE_MEM
3361 + [1] = { /* reset pin */
3362 + .start = AT91_PIN_PC22,
3363 + .end = AT91_PIN_PC22,
3364 + .flags = IORESOURCE_MEM
3368 +static struct platform_device kb9202_lcd_device = {
3369 + .name = "s1d15605fb",
3371 + .num_resources = ARRAY_SIZE(kb9202_lcd_resources),
3372 + .resource = kb9202_lcd_resources,
3375 +static void __init kb9202_add_device_lcd(void)
3377 + /* In case the boot loader did not set the chip select mode and timing */
3378 + at91_sys_write(AT91_SMC_CSR(2),
3379 + AT91_SMC_WSEN | AT91_SMC_NWS_(18) | AT91_SMC_TDF_(1) | AT91_SMC_DBW_8 |
3380 + AT91_SMC_RWSETUP_(1) | AT91_SMC_RWHOLD_(1));
3382 + /* Backlight pin = output, off */
3383 + at91_set_gpio_output(AT91_PIN_PC23, 0);
3385 + /* Reset pin = output, in reset */
3386 + at91_set_gpio_output(AT91_PIN_PC22, 0);
3388 + platform_device_register(&kb9202_lcd_device);
3391 +static void __init kb9202_add_device_lcd(void) {}
3394 static void __init kb9202_board_init(void)
3397 @@ -129,6 +174,8 @@ static void __init kb9202_board_init(voi
3398 at91_add_device_spi(NULL, 0);
3400 at91_add_device_nand(&kb9202_nand_data);
3402 + kb9202_add_device_lcd();
3405 MACHINE_START(KB9200, "KB920x")
3407 +++ b/arch/arm/mach-at91/board-qil-a9260.c
3410 + * linux/arch/arm/mach-at91/board-qil-a9260.c
3412 + * Copyright (C) 2005 SAN People
3413 + * Copyright (C) 2006 Atmel
3414 + * Copyright (C) 2007 Calao-systems
3416 + * This program is free software; you can redistribute it and/or modify
3417 + * it under the terms of the GNU General Public License as published by
3418 + * the Free Software Foundation; either version 2 of the License, or
3419 + * (at your option) any later version.
3421 + * This program is distributed in the hope that it will be useful,
3422 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3423 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3424 + * GNU General Public License for more details.
3426 + * You should have received a copy of the GNU General Public License
3427 + * along with this program; if not, write to the Free Software
3428 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3431 +#include <linux/types.h>
3432 +#include <linux/init.h>
3433 +#include <linux/mm.h>
3434 +#include <linux/module.h>
3435 +#include <linux/platform_device.h>
3436 +#include <linux/spi/spi.h>
3437 +#include <linux/gpio_keys.h>
3438 +#include <linux/input.h>
3439 +#include <linux/clk.h>
3441 +#include <asm/hardware.h>
3442 +#include <asm/setup.h>
3443 +#include <asm/mach-types.h>
3444 +#include <asm/irq.h>
3446 +#include <asm/mach/arch.h>
3447 +#include <asm/mach/map.h>
3448 +#include <asm/mach/irq.h>
3450 +#include <asm/arch/board.h>
3451 +#include <asm/arch/gpio.h>
3452 +#include <asm/arch/at91_shdwc.h>
3454 +#include "generic.h"
3457 +static void __init ek_map_io(void)
3459 + /* Initialize processor: 12.000 MHz crystal */
3460 + at91sam9260_initialize(12000000);
3462 + /* DGBU on ttyS0. (Rx & Tx only) */
3463 + at91_register_uart(0, 0, 0);
3465 + /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
3466 + at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
3467 + | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
3470 + /* USART1 on ttyS2. (Rx, Tx, CTS, RTS) */
3471 + at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
3473 + /* USART2 on ttyS3. (Rx, Tx, CTS, RTS) */
3474 + at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_CTS | ATMEL_UART_RTS);
3476 + /* set serial console to ttyS1 (ie, USART0) */
3477 + at91_set_serial_console(1);
3481 +static void __init ek_init_irq(void)
3483 + at91sam9260_init_interrupts(NULL);
3490 +static struct at91_usbh_data __initdata ek_usbh_data = {
3497 +static struct at91_udc_data __initdata ek_udc_data = {
3498 + .vbus_pin = AT91_PIN_PC5,
3499 + .pullup_pin = 0, /* pull-up driven by UDC */
3505 +static struct spi_board_info ek_spi_devices[] = {
3506 +#if defined(CONFIG_RTC_DRV_M41T94)
3507 + { /* M41T94 RTC */
3508 + .modalias = "m41t94",
3510 + .max_speed_hz = 1 * 1000 * 1000,
3517 + * MACB Ethernet device
3519 +static struct at91_eth_data __initdata ek_macb_data = {
3520 + .phy_irq_pin = AT91_PIN_PA31,
3527 +static struct mtd_partition __initdata ek_nand_partition[] = {
3529 + .name = "Uboot & Kernel",
3530 + .offset = 0x00000000,
3531 + .size = 16 * 1024 * 1024,
3534 + .name = "Root FS",
3535 + .offset = 0x01000000,
3536 + .size = 120 * 1024 * 1024,
3540 + .offset = 0x08800000,
3541 + .size = 120 * 1024 * 1024,
3545 +static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
3547 + *num_partitions = ARRAY_SIZE(ek_nand_partition);
3548 + return ek_nand_partition;
3551 +static struct at91_nand_data __initdata ek_nand_data = {
3554 +// .det_pin = ... not connected
3555 + .rdy_pin = AT91_PIN_PC13,
3556 + .enable_pin = AT91_PIN_PC14,
3557 + .partition_info = nand_partitions,
3558 +#if defined(CONFIG_MTD_NAND_AT91_BUSWIDTH_16)
3559 + .bus_width_16 = 1,
3561 + .bus_width_16 = 0,
3568 +static struct at91_mmc_data __initdata ek_mmc_data = {
3571 +// .det_pin = ... not connected
3572 +// .wp_pin = ... not connected
3573 +// .vcc_pin = ... not connected
3579 +#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
3580 +static struct gpio_keys_button ek_buttons[] = {
3581 + { /* USER PUSH BUTTON */
3582 + .code = KEY_ENTER,
3583 + .gpio = AT91_PIN_PB10,
3585 + .desc = "user_pb",
3590 +static struct gpio_keys_platform_data ek_button_data = {
3591 + .buttons = ek_buttons,
3592 + .nbuttons = ARRAY_SIZE(ek_buttons),
3595 +static struct platform_device ek_button_device = {
3596 + .name = "gpio-keys",
3598 + .num_resources = 0,
3600 + .platform_data = &ek_button_data,
3604 +static void __init ek_add_device_buttons(void)
3606 + at91_set_GPIO_periph(AT91_PIN_PB10, 1); /* user push button, pull up enabled */
3607 + at91_set_deglitch(AT91_PIN_PB10, 1);
3609 + platform_device_register(&ek_button_device);
3612 +static void __init ek_add_device_buttons(void) {}
3618 +static struct gpio_led ek_leds[] = {
3619 + { /* user_led (green) */
3620 + .name = "user_led",
3621 + .gpio = AT91_PIN_PB21,
3623 + .default_trigger = "heartbeat",
3627 +static void __init ek_board_init(void)
3630 + at91_add_device_serial();
3632 + at91_add_device_usbh(&ek_usbh_data);
3634 + at91_add_device_udc(&ek_udc_data);
3636 + at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
3638 + at91_add_device_nand(&ek_nand_data);
3640 + at91_add_device_i2c(NULL, 0);
3642 + at91_add_device_eth(&ek_macb_data);
3644 + at91_add_device_mmc(0, &ek_mmc_data);
3645 + /* Push Buttons */
3646 + ek_add_device_buttons();
3648 + at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
3649 + /* shutdown controller, wakeup button (5 msec low) */
3650 + at91_sys_write(AT91_SHDW_MR, AT91_SHDW_CPTWK0_(10) | AT91_SHDW_WKMODE0_LOW
3651 + | AT91_SHDW_RTTWKEN);
3654 +MACHINE_START(QIL_A9260, "CALAO QIL_A9260")
3655 + /* Maintainer: calao-systems */
3656 + .phys_io = AT91_BASE_SYS,
3657 + .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
3658 + .boot_params = AT91_SDRAM_BASE + 0x100,
3659 + .timer = &at91sam926x_timer,
3660 + .map_io = ek_map_io,
3661 + .init_irq = ek_init_irq,
3662 + .init_machine = ek_board_init,
3665 +++ b/arch/arm/mach-at91/board-sam9-l9260.c
3668 + * linux/arch/arm/mach-at91/board-sam9-l9260.c
3670 + * Copyright (C) 2005 SAN People
3671 + * Copyright (C) 2006 Atmel
3672 + * Copyright (C) 2007 Olimex Ltd
3674 + * This program is free software; you can redistribute it and/or modify
3675 + * it under the terms of the GNU General Public License as published by
3676 + * the Free Software Foundation; either version 2 of the License, or
3677 + * (at your option) any later version.
3679 + * This program is distributed in the hope that it will be useful,
3680 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3681 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3682 + * GNU General Public License for more details.
3684 + * You should have received a copy of the GNU General Public License
3685 + * along with this program; if not, write to the Free Software
3686 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3689 +#include <linux/types.h>
3690 +#include <linux/init.h>
3691 +#include <linux/mm.h>
3692 +#include <linux/module.h>
3693 +#include <linux/platform_device.h>
3694 +#include <linux/spi/spi.h>
3696 +#include <asm/hardware.h>
3697 +#include <asm/setup.h>
3698 +#include <asm/mach-types.h>
3699 +#include <asm/irq.h>
3701 +#include <asm/mach/arch.h>
3702 +#include <asm/mach/map.h>
3703 +#include <asm/mach/irq.h>
3705 +#include <asm/arch/board.h>
3706 +#include <asm/arch/gpio.h>
3708 +#include "generic.h"
3711 +static void __init ek_map_io(void)
3713 + /* Initialize processor: 18.432 MHz crystal */
3714 + at91sam9260_initialize(18432000);
3716 + /* Setup the LEDs */
3717 + at91_init_leds(AT91_PIN_PA9, AT91_PIN_PA6);
3719 + /* DBGU on ttyS0. (Rx & Tx only) */
3720 + at91_register_uart(0, 0, 0);
3722 + /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
3723 + at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
3724 + | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
3727 + /* USART1 on ttyS2. (Rx, Tx, CTS, RTS) */
3728 + at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
3730 + /* set serial console to ttyS0 (ie, DBGU) */
3731 + at91_set_serial_console(0);
3734 +static void __init ek_init_irq(void)
3736 + at91sam9260_init_interrupts(NULL);
3743 +static struct at91_usbh_data __initdata ek_usbh_data = {
3750 +static struct at91_udc_data __initdata ek_udc_data = {
3751 + .vbus_pin = AT91_PIN_PC5,
3752 + .pullup_pin = 0, /* pull-up driven by UDC */
3759 +static struct spi_board_info ek_spi_devices[] = {
3760 +#if !defined(CONFIG_MMC_AT91)
3761 + { /* DataFlash chip */
3762 + .modalias = "mtd_dataflash",
3764 + .max_speed_hz = 15 * 1000 * 1000,
3767 +#if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
3768 + { /* DataFlash card */
3769 + .modalias = "mtd_dataflash",
3771 + .max_speed_hz = 15 * 1000 * 1000,
3780 + * MACB Ethernet device
3782 +static struct at91_eth_data __initdata ek_macb_data = {
3783 + .phy_irq_pin = AT91_PIN_PA7,
3791 +static struct mtd_partition __initdata ek_nand_partition[] = {
3793 + .name = "Bootloader Area",
3795 + .size = 10 * 1024 * 1024,
3798 + .name = "User Area",
3799 + .offset = 10 * 1024 * 1024,
3800 + .size = MTDPART_SIZ_FULL,
3804 +static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
3806 + *num_partitions = ARRAY_SIZE(ek_nand_partition);
3807 + return ek_nand_partition;
3810 +static struct at91_nand_data __initdata ek_nand_data = {
3813 +// .det_pin = ... not connected
3814 + .rdy_pin = AT91_PIN_PC13,
3815 + .enable_pin = AT91_PIN_PC14,
3816 + .partition_info = nand_partitions,
3817 +#if defined(CONFIG_MTD_NAND_AT91_BUSWIDTH_16)
3818 + .bus_width_16 = 1,
3820 + .bus_width_16 = 0,
3828 +static struct at91_mmc_data __initdata ek_mmc_data = {
3831 + .det_pin = AT91_PIN_PC8,
3832 + .wp_pin = AT91_PIN_PC4,
3833 +// .vcc_pin = ... not connected
3836 +static void __init ek_board_init(void)
3839 + at91_add_device_serial();
3841 + at91_add_device_usbh(&ek_usbh_data);
3843 + at91_add_device_udc(&ek_udc_data);
3845 + at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
3847 + at91_add_device_nand(&ek_nand_data);
3849 + at91_add_device_eth(&ek_macb_data);
3851 + at91_add_device_mmc(0, &ek_mmc_data);
3853 + at91_add_device_i2c(NULL, 0);
3856 +MACHINE_START(SAM9_L9260, "Olimex SAM9-L9260")
3857 + /* Maintainer: Olimex */
3858 + .phys_io = AT91_BASE_SYS,
3859 + .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
3860 + .boot_params = AT91_SDRAM_BASE + 0x100,
3861 + .timer = &at91sam926x_timer,
3862 + .map_io = ek_map_io,
3863 + .init_irq = ek_init_irq,
3864 + .init_machine = ek_board_init,
3866 --- a/arch/arm/mach-at91/board-sam9260ek.c
3867 +++ b/arch/arm/mach-at91/board-sam9260ek.c
3869 #include <linux/module.h>
3870 #include <linux/platform_device.h>
3871 #include <linux/spi/spi.h>
3872 +#include <linux/spi/at73c213.h>
3873 +#include <linux/clk.h>
3874 +#include <linux/gpio_keys.h>
3875 +#include <linux/input.h>
3877 #include <asm/hardware.h>
3878 #include <asm/setup.h>
3881 #include <asm/arch/board.h>
3882 #include <asm/arch/gpio.h>
3883 -#include <asm/arch/at91sam926x_mc.h>
3884 +#include <asm/arch/at91_shdwc.h>
3886 #include "generic.h"
3890 - * Serial port configuration.
3891 - * 0 .. 5 = USART0 .. USART5
3894 -static struct at91_uart_config __initdata ek_uart_config = {
3895 - .console_tty = 0, /* ttyS0 */
3897 - .tty_map = { 6, 0, 1, -1, -1, -1, -1 } /* ttyS0, ..., ttyS6 */
3900 static void __init ek_map_io(void)
3902 /* Initialize processor: 18.432 MHz crystal */
3903 at91sam9260_initialize(18432000);
3905 - /* Setup the serial ports and console */
3906 - at91_init_serial(&ek_uart_config);
3907 + /* DGBU on ttyS0. (Rx & Tx only) */
3908 + at91_register_uart(0, 0, 0);
3910 + /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
3911 + at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
3912 + | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
3915 + /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
3916 + at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
3918 + /* set serial console to ttyS0 (ie, DBGU) */
3919 + at91_set_serial_console(0);
3922 static void __init ek_init_irq(void)
3923 @@ -85,6 +89,35 @@ static struct at91_udc_data __initdata e
3929 +static struct at73c213_board_info at73c213_data = {
3931 + .shortname = "AT91SAM9260-EK external DAC",
3934 +#if defined(CONFIG_SND_AT73C213) || defined(CONFIG_SND_AT73C213_MODULE)
3935 +static void __init at73c213_set_clk(struct at73c213_board_info *info)
3940 + pck0 = clk_get(NULL, "pck0");
3941 + plla = clk_get(NULL, "plla");
3943 + /* AT73C213 MCK Clock */
3944 + at91_set_B_periph(AT91_PIN_PC1, 0); /* PCK0 */
3946 + clk_set_parent(pck0, plla);
3949 + info->dac_clk = pck0;
3952 +static void __init at73c213_set_clk(struct at73c213_board_info *info) {}
3958 static struct spi_board_info ek_spi_devices[] = {
3959 @@ -110,6 +143,8 @@ static struct spi_board_info ek_spi_devi
3961 .max_speed_hz = 10 * 1000 * 1000,
3963 + .mode = SPI_MODE_1,
3964 + .platform_data = &at73c213_data,
3968 @@ -172,6 +207,74 @@ static struct at91_mmc_data __initdata e
3969 // .vcc_pin = ... not connected
3976 +static struct gpio_led ek_leds[] = {
3977 + { /* "bottom" led, green, userled1 to be defined */
3979 + .gpio = AT91_PIN_PA6,
3981 + .default_trigger = "none",
3983 + { /* "power" led, yellow */
3985 + .gpio = AT91_PIN_PA9,
3986 + .default_trigger = "heartbeat",
3994 +#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
3995 +static struct gpio_keys_button ek_buttons[] = {
3997 + .gpio = AT91_PIN_PA30,
3999 + .desc = "Button 3",
4004 + .gpio = AT91_PIN_PA31,
4006 + .desc = "Button 4",
4012 +static struct gpio_keys_platform_data ek_button_data = {
4013 + .buttons = ek_buttons,
4014 + .nbuttons = ARRAY_SIZE(ek_buttons),
4017 +static struct platform_device ek_button_device = {
4018 + .name = "gpio-keys",
4020 + .num_resources = 0,
4022 + .platform_data = &ek_button_data,
4026 +static void __init ek_add_device_buttons(void)
4028 + at91_set_gpio_input(AT91_PIN_PA30, 1); /* btn3 */
4029 + at91_set_deglitch(AT91_PIN_PA30, 1);
4030 + at91_set_gpio_input(AT91_PIN_PA31, 1); /* btn4 */
4031 + at91_set_deglitch(AT91_PIN_PA31, 1);
4033 + platform_device_register(&ek_button_device);
4036 +static void __init ek_add_device_buttons(void) {}
4040 static void __init ek_board_init(void)
4043 @@ -190,6 +293,16 @@ static void __init ek_board_init(void)
4044 at91_add_device_mmc(0, &ek_mmc_data);
4046 at91_add_device_i2c(NULL, 0);
4047 + /* SSC (to AT73C213) */
4048 + at73c213_set_clk(&at73c213_data);
4049 + at91_add_device_ssc(AT91SAM9260_ID_SSC, ATMEL_SSC_TX);
4051 + at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
4052 + /* Push Buttons */
4053 + ek_add_device_buttons();
4054 + /* shutdown controller, wakeup button (5 msec low) */
4055 + at91_sys_write(AT91_SHDW_MR, AT91_SHDW_CPTWK0_(10) | AT91_SHDW_WKMODE0_LOW
4056 + | AT91_SHDW_RTTWKEN);
4059 MACHINE_START(AT91SAM9260EK, "Atmel AT91SAM9260-EK")
4060 --- a/arch/arm/mach-at91/board-sam9261ek.c
4061 +++ b/arch/arm/mach-at91/board-sam9261ek.c
4063 #include <linux/platform_device.h>
4064 #include <linux/spi/spi.h>
4065 #include <linux/spi/ads7846.h>
4066 +#include <linux/spi/at73c213.h>
4067 +#include <linux/clk.h>
4068 #include <linux/dm9000.h>
4069 #include <linux/fb.h>
4070 #include <linux/gpio_keys.h>
4073 #include <asm/arch/board.h>
4074 #include <asm/arch/gpio.h>
4075 -#include <asm/arch/at91sam926x_mc.h>
4076 +#include <asm/arch/at91sam9_smc.h>
4077 +#include <asm/arch/at91_shdwc.h>
4079 #include "generic.h"
4083 - * Serial port configuration.
4084 - * 0 .. 2 = USART0 .. USART2
4087 -static struct at91_uart_config __initdata ek_uart_config = {
4088 - .console_tty = 0, /* ttyS0 */
4090 - .tty_map = { 3, -1, -1, -1 } /* ttyS0, ..., ttyS3 */
4093 static void __init ek_map_io(void)
4095 /* Initialize processor: 18.432 MHz crystal */
4096 @@ -68,8 +60,11 @@ static void __init ek_map_io(void)
4097 /* Setup the LEDs */
4098 at91_init_leds(AT91_PIN_PA13, AT91_PIN_PA14);
4100 - /* Setup the serial ports and console */
4101 - at91_init_serial(&ek_uart_config);
4102 + /* DGBU on ttyS0. (Rx & Tx only) */
4103 + at91_register_uart(0, 0, 0);
4105 + /* set serial console to ttyS0 (ie, DBGU) */
4106 + at91_set_serial_console(0);
4109 static void __init ek_init_irq(void)
4110 @@ -239,6 +234,35 @@ static void __init ek_add_device_ts(void
4116 +static struct at73c213_board_info at73c213_data = {
4118 + .shortname = "AT91SAM9261-EK external DAC",
4121 +#if defined(CONFIG_SND_AT73C213) || defined(CONFIG_SND_AT73C213_MODULE)
4122 +static void __init at73c213_set_clk(struct at73c213_board_info *info)
4127 + pck2 = clk_get(NULL, "pck2");
4128 + plla = clk_get(NULL, "plla");
4130 + /* AT73C213 MCK Clock */
4131 + at91_set_B_periph(AT91_PIN_PB31, 0); /* PCK2 */
4133 + clk_set_parent(pck2, plla);
4136 + info->dac_clk = pck2;
4139 +static void __init at73c213_set_clk(struct at73c213_board_info *info) {}
4145 static struct spi_board_info ek_spi_devices[] = {
4146 @@ -252,10 +276,11 @@ static struct spi_board_info ek_spi_devi
4148 .modalias = "ads7846",
4150 - .max_speed_hz = 125000 * 26, /* (max sample rate @ 3V) * (cmd + data + overhead) */
4151 + .max_speed_hz = 125000 * 16, /* max sample rate * clocks per sample */
4153 .platform_data = &ads_info,
4154 .irq = AT91SAM9261_ID_IRQ0,
4155 + .controller_data = (void *) AT91_PIN_PA28, /* CS pin */
4158 #if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
4159 @@ -271,6 +296,9 @@ static struct spi_board_info ek_spi_devi
4161 .max_speed_hz = 10 * 1000 * 1000,
4163 + .mode = SPI_MODE_1,
4164 + .platform_data = &at73c213_data,
4165 + .controller_data = (void*) AT91_PIN_PA29, /* default for CS3 is PA6, but it must be PA29 */
4169 @@ -408,24 +436,28 @@ static struct gpio_keys_button ek_button
4176 .gpio = AT91_PIN_PA26,
4183 .gpio = AT91_PIN_PA25,
4190 .gpio = AT91_PIN_PA24,
4198 @@ -445,13 +477,13 @@ static struct platform_device ek_button_
4200 static void __init ek_add_device_buttons(void)
4202 - at91_set_gpio_input(AT91_PIN_PA27, 0); /* btn0 */
4203 + at91_set_gpio_input(AT91_PIN_PA27, 1); /* btn0 */
4204 at91_set_deglitch(AT91_PIN_PA27, 1);
4205 - at91_set_gpio_input(AT91_PIN_PA26, 0); /* btn1 */
4206 + at91_set_gpio_input(AT91_PIN_PA26, 1); /* btn1 */
4207 at91_set_deglitch(AT91_PIN_PA26, 1);
4208 - at91_set_gpio_input(AT91_PIN_PA25, 0); /* btn2 */
4209 + at91_set_gpio_input(AT91_PIN_PA25, 1); /* btn2 */
4210 at91_set_deglitch(AT91_PIN_PA25, 1);
4211 - at91_set_gpio_input(AT91_PIN_PA24, 0); /* btn3 */
4212 + at91_set_gpio_input(AT91_PIN_PA24, 1); /* btn3 */
4213 at91_set_deglitch(AT91_PIN_PA24, 1);
4215 platform_device_register(&ek_button_device);
4216 @@ -460,6 +492,29 @@ static void __init ek_add_device_buttons
4217 static void __init ek_add_device_buttons(void) {}
4223 +static struct gpio_led ek_leds[] = {
4224 + { /* "bottom" led, green, userled1 to be defined */
4226 + .gpio = AT91_PIN_PA14,
4228 + .default_trigger = "none",
4230 + { /* "top" led, green, userled2 to be defined */
4232 + .gpio = AT91_PIN_PA13,
4234 + .default_trigger = "none",
4236 + { /* "power" led, yellow */
4238 + .gpio = AT91_PIN_PA23,
4239 + .default_trigger = "heartbeat",
4243 static void __init ek_board_init(void)
4246 @@ -481,6 +536,9 @@ static void __init ek_board_init(void)
4247 at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
4250 + /* SSC (to AT73C213) */
4251 + at73c213_set_clk(&at73c213_data);
4252 + at91_add_device_ssc(AT91SAM9261_ID_SSC1, ATMEL_SSC_TX);
4255 at91_add_device_mmc(0, &ek_mmc_data);
4256 @@ -489,6 +547,11 @@ static void __init ek_board_init(void)
4257 at91_add_device_lcdc(&ek_lcdc_data);
4259 ek_add_device_buttons();
4261 + at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
4262 + /* shutdown controller, wakeup button (5 msec low) */
4263 + at91_sys_write(AT91_SHDW_MR, AT91_SHDW_CPTWK0_(10) | AT91_SHDW_WKMODE0_LOW
4264 + | AT91_SHDW_RTTWKEN);
4267 MACHINE_START(AT91SAM9261EK, "Atmel AT91SAM9261-EK")
4268 --- a/arch/arm/mach-at91/board-sam9263ek.c
4269 +++ b/arch/arm/mach-at91/board-sam9263ek.c
4272 #include <asm/arch/board.h>
4273 #include <asm/arch/gpio.h>
4274 -#include <asm/arch/at91sam926x_mc.h>
4275 +#include <asm/arch/at91_shdwc.h>
4277 #include "generic.h"
4281 - * Serial port configuration.
4282 - * 0 .. 2 = USART0 .. USART2
4285 -static struct at91_uart_config __initdata ek_uart_config = {
4286 - .console_tty = 0, /* ttyS0 */
4288 - .tty_map = { 3, 0, -1, -1, } /* ttyS0, ..., ttyS3 */
4291 static void __init ek_map_io(void)
4293 /* Initialize processor: 16.367 MHz crystal */
4294 at91sam9263_initialize(16367660);
4296 - /* Setup the serial ports and console */
4297 - at91_init_serial(&ek_uart_config);
4298 + /* DGBU on ttyS0. (Rx & Tx only) */
4299 + at91_register_uart(0, 0, 0);
4301 + /* USART0 on ttyS1. (Rx, Tx, RTS, CTS) */
4302 + at91_register_uart(AT91SAM9263_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
4304 + /* set serial console to ttyS0 (ie, DBGU) */
4305 + at91_set_serial_console(0);
4308 static void __init ek_init_irq(void)
4309 @@ -141,7 +136,7 @@ static struct spi_board_info ek_spi_devi
4311 .modalias = "ads7846",
4313 - .max_speed_hz = 125000 * 26, /* (max sample rate @ 3V) * (cmd + data + overhead) */
4314 + .max_speed_hz = 125000 * 16, /* max sample rate * clocks per sample */
4316 .platform_data = &ads_info,
4317 .irq = AT91SAM9263_ID_IRQ1,
4318 @@ -301,9 +296,9 @@ static struct platform_device ek_button_
4320 static void __init ek_add_device_buttons(void)
4322 - at91_set_GPIO_periph(AT91_PIN_PC5, 0); /* left button */
4323 + at91_set_GPIO_periph(AT91_PIN_PC5, 1); /* left button */
4324 at91_set_deglitch(AT91_PIN_PC5, 1);
4325 - at91_set_GPIO_periph(AT91_PIN_PC4, 0); /* right button */
4326 + at91_set_GPIO_periph(AT91_PIN_PC4, 1); /* right button */
4327 at91_set_deglitch(AT91_PIN_PC4, 1);
4329 platform_device_register(&ek_button_device);
4330 @@ -341,7 +336,7 @@ static struct gpio_led ek_leds[] = {
4332 .gpio = AT91_PIN_PB7,
4333 .default_trigger = "heartbeat",
4339 @@ -374,6 +369,9 @@ static void __init ek_board_init(void)
4340 at91_add_device_ac97(&ek_ac97_data);
4342 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
4343 + /* shutdown controller, wakeup button (5 msec low) */
4344 + at91_sys_write(AT91_SHDW_MR, AT91_SHDW_CPTWK0_(10) | AT91_SHDW_WKMODE0_LOW
4345 + | AT91_SHDW_RTTWKEN);
4348 MACHINE_START(AT91SAM9263EK, "Atmel AT91SAM9263-EK")
4349 --- a/arch/arm/mach-at91/board-sam9rlek.c
4350 +++ b/arch/arm/mach-at91/board-sam9rlek.c
4353 #include <asm/arch/board.h>
4354 #include <asm/arch/gpio.h>
4355 -#include <asm/arch/at91sam926x_mc.h>
4356 +#include <asm/arch/at91_shdwc.h>
4358 #include "generic.h"
4362 - * Serial port configuration.
4363 - * 0 .. 3 = USART0 .. USART3
4366 -static struct at91_uart_config __initdata ek_uart_config = {
4367 - .console_tty = 0, /* ttyS0 */
4369 - .tty_map = { 4, 0, -1, -1, -1 } /* ttyS0, ..., ttyS4 */
4372 static void __init ek_map_io(void)
4374 /* Initialize processor: 12.000 MHz crystal */
4375 at91sam9rl_initialize(12000000);
4377 - /* Setup the serial ports and console */
4378 - at91_init_serial(&ek_uart_config);
4379 + /* DGBU on ttyS0. (Rx & Tx only) */
4380 + at91_register_uart(0, 0, 0);
4382 + /* USART0 on ttyS1. (Rx, Tx, CTS, RTS) */
4383 + at91_register_uart(AT91SAM9RL_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
4385 + /* set serial console to ttyS0 (ie, DBGU) */
4386 + at91_set_serial_console(0);
4389 static void __init ek_init_irq(void)
4390 @@ -61,6 +56,14 @@ static void __init ek_init_irq(void)
4394 + * USB HS Device port
4396 +static struct usba_platform_data __initdata ek_usba_udc_data = {
4397 + .vbus_pin = AT91_PIN_PA8,
4404 static struct at91_mmc_data __initdata ek_mmc_data = {
4405 @@ -180,6 +183,8 @@ static void __init ek_board_init(void)
4408 at91_add_device_serial();
4410 + at91_add_device_usba(&ek_usba_udc_data);
4412 at91_add_device_i2c(NULL, 0);
4414 @@ -190,6 +195,9 @@ static void __init ek_board_init(void)
4415 at91_add_device_mmc(0, &ek_mmc_data);
4416 /* LCD Controller */
4417 at91_add_device_lcdc(&ek_lcdc_data);
4418 + /* shutdown controller, wakeup button (5 msec low) */
4419 + at91_sys_write(AT91_SHDW_MR, AT91_SHDW_CPTWK0_(10) | AT91_SHDW_WKMODE0_LOW
4420 + | AT91_SHDW_RTTWKEN);
4423 MACHINE_START(AT91SAM9RLEK, "Atmel AT91SAM9RL-EK")
4425 +++ b/arch/arm/mach-at91/board-tms.c
4428 +* linux/arch/arm/mach-at91/board-tms.c
4430 +* Copyright (C) 2005 SAN People
4432 +* Adapted from board-dk to sweda TMS-100 by Luiz de Barros <lboneto@gmail.com>
4434 +* This program is free software; you can redistribute it and/or modify
4435 +* it under the terms of the GNU General Public License as published by
4436 +* the Free Software Foundation; either version 2 of the License, or
4437 +* (at your option) any later version.
4439 +* This program is distributed in the hope that it will be useful,
4440 +* but WITHOUT ANY WARRANTY; without even the implied warranty of
4441 +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4442 +* GNU General Public License for more details.
4444 +* You should have received a copy of the GNU General Public License
4445 +* along with this program; if not, write to the Free Software
4446 +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
4449 +#include <linux/types.h>
4450 +#include <linux/init.h>
4451 +#include <linux/mm.h>
4452 +#include <linux/module.h>
4453 +#include <linux/platform_device.h>
4454 +#include <linux/spi/spi.h>
4455 +#include <linux/mtd/physmap.h>
4457 +#include <asm/hardware.h>
4458 +#include <asm/setup.h>
4459 +#include <asm/mach-types.h>
4460 +#include <asm/irq.h>
4462 +#include <asm/mach/arch.h>
4463 +#include <asm/mach/map.h>
4464 +#include <asm/mach/irq.h>
4466 +#include <asm/arch/board.h>
4467 +#include <asm/arch/gpio.h>
4468 +#include <asm/arch/at91rm9200_mc.h>
4470 +#include "generic.h"
4471 +#include <linux/serial_8250.h>
4474 +#define SERIAL_FLAGS (UPF_BOOT_AUTOCONF | UPF_IOREMAP| UPF_SHARE_IRQ)
4475 +#define SERIAL_CLK (1843200)
4478 +/*---------------------------------------------------------------------
4482 +#define PORT(_base, _irq) \
4484 + .mapbase = _base, \
4486 + .uartclk = SERIAL_CLK, \
4487 + .iotype = UPIO_MEM, \
4489 + .flags = SERIAL_FLAGS, \
4492 +static struct plat_serial8250_port tms_data[] = {
4493 + PORT(0x70000000, AT91_PIN_PC3),
4494 + PORT(0x80000000, AT91_PIN_PC5),
4498 +static struct platform_device tms_device = {
4499 + .name = "serial8250",
4500 + .id = PLAT8250_DEV_PLATFORM,
4503 + .platform_data = &tms_data,
4507 +static void setup_external_uart(void)
4509 + at91_sys_write(AT91_SMC_CSR(2),
4514 + | AT91_SMC_NWS_(32) /* wait states */
4515 + | AT91_SMC_RWSETUP_(6) /* setup time */
4516 + | AT91_SMC_RWHOLD_(4) /* hold time */
4519 + at91_sys_write(AT91_SMC_CSR(6),
4524 + | AT91_SMC_NWS_(32) /* wait states */
4525 + | AT91_SMC_RWSETUP_(6) /* setup time */
4526 + | AT91_SMC_RWHOLD_(4) /* hold time */
4529 + at91_sys_write(AT91_SMC_CSR(7),
4534 + | AT91_SMC_NWS_(32) /* wait states */
4535 + | AT91_SMC_RWSETUP_(6) /* setup time */
4536 + | AT91_SMC_RWHOLD_(4) /* hold time */
4539 + platform_device_register(&tms_device);
4544 + * Serial port configuration.
4545 + * 0 .. 3 = USART0 .. USART3
4548 +static struct at91_uart_config __initdata tms_uart_config = {
4549 + .console_tty = 0, /* ttyS0 */
4551 + .tty_map = { 4, 0, 1, 2, 3 } /* ttyS0, ..., ttyS4 */
4554 +static void __init tms_map_io(void)
4556 + /* Initialize processor: 18.432 MHz crystal */
4557 + at91rm9200_initialize(18432000, AT91RM9200_BGA);
4559 + /* Setup the LEDs */
4560 + at91_init_leds(AT91_PIN_PB2, AT91_PIN_PB2);
4562 + /* Setup the serial ports and console */
4563 + at91_init_serial(&tms_uart_config);
4566 +static void __init tms_init_irq(void)
4568 + at91rm9200_init_interrupts(NULL);
4572 +static struct at91_eth_data __initdata tms_eth_data = {
4573 + .phy_irq_pin = AT91_PIN_PC4,
4577 +static struct at91_usbh_data __initdata tms_usbh_data = {
4581 +static struct spi_board_info tms_spi_devices[] = {
4582 + { /* DataFlash chip */
4583 + .modalias = "mtd_dataflash",
4585 + .max_speed_hz = 15 * 1000 * 1000,
4587 + { /* DataFlash chip */
4588 + .modalias = "mtd_dataflash",
4590 + .max_speed_hz = 15 * 1000 * 1000,
4594 +static struct i2c_board_info __initdata tms_i2c_devices[] = {
4596 + I2C_BOARD_INFO("isl1208", 0x6f),
4600 +static void __init tms_board_init(void)
4603 + at91_add_device_serial();
4605 + at91_add_device_eth(&tms_eth_data);
4606 + at91_add_device_usbh(&tms_usbh_data);
4608 + at91_add_device_i2c(tms_i2c_devices, ARRAY_SIZE(tms_i2c_devices));
4610 + at91_add_device_spi(tms_spi_devices, ARRAY_SIZE(tms_spi_devices));
4611 + /* Two port external UART */
4612 + setup_external_uart();
4615 +MACHINE_START(SWEDATMS, "Sweda TMS-100 Board")
4616 + /* Maintainer: Luiz de Barros */
4617 + .phys_io = AT91_BASE_SYS,
4618 + .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
4619 + .boot_params = AT91_SDRAM_BASE + 0x100,
4620 + .timer = &at91rm9200_timer,
4621 + .map_io = tms_map_io,
4622 + .init_irq = tms_init_irq,
4623 + .init_machine = tms_board_init,
4626 +++ b/arch/arm/mach-at91/board-tt9200.c
4629 + * linux/arch/arm/mach-at91rm9200/board-tt9200.c
4630 + * Copyright (C) 2007 Toptechnology
4632 + * Based on board-ecbat91.c
4634 + * This program is free software; you can redistribute it and/or modify
4635 + * it under the terms of the GNU General Public License as published by
4636 + * the Free Software Foundation; either version 2 of the License, or
4637 + * (at your option) any later version.
4639 + * This program is distributed in the hope that it will be useful,
4640 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4641 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4642 + * GNU General Public License for more details.
4644 + * You should have received a copy of the GNU General Public License
4645 + * along with this program; if not, write to the Free Software
4646 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
4649 +#include <linux/types.h>
4650 +#include <linux/init.h>
4651 +#include <linux/mm.h>
4652 +#include <linux/module.h>
4653 +#include <linux/platform_device.h>
4654 +#include <linux/spi/spi.h>
4655 +#include <linux/spi/flash.h>
4657 +#include <asm/hardware.h>
4658 +#include <asm/setup.h>
4659 +#include <asm/mach-types.h>
4660 +#include <asm/irq.h>
4662 +#include <asm/mach/arch.h>
4663 +#include <asm/mach/map.h>
4664 +#include <asm/mach/irq.h>
4666 +#include <asm/arch/board.h>
4667 +#include <asm/arch/gpio.h>
4669 +#include "generic.h"
4672 +static void __init tt9200_map_io(void)
4674 + /* Initialize processor: 18.432 MHz crystal */
4675 + at91rm9200_initialize(18432000, AT91RM9200_PQFP);
4677 + /* Setup the LEDs */
4678 + at91_init_leds(AT91_PIN_PB27, AT91_PIN_PB27);
4680 + /* DBGU on ttyS0. (Rx & Tx only) */
4681 + at91_register_uart(0, 0, 0);
4683 + /* USART0 on ttyS1. (Rx & Tx only) */
4684 + at91_register_uart(AT91RM9200_ID_US0, 1, 0);
4686 + /* USART1 on ttyS2. (Rx & Tx only) */
4687 + at91_register_uart(AT91RM9200_ID_US1, 2, 0);
4689 + /* USART2 on ttyS3. (Rx & Tx only) */
4690 + at91_register_uart(AT91RM9200_ID_US2, 3, 0);
4692 + /* USART3 on ttyS4. (Rx, Tx, CTS, RTS) */
4693 + at91_register_uart(AT91RM9200_ID_US3, 4, ATMEL_UART_CTS | ATMEL_UART_RTS);
4695 + /* Console on ttyS0 (ie, DBGU) */
4696 + at91_set_serial_console(0);
4699 +static void __init tt9200_init_irq(void)
4701 + at91rm9200_init_interrupts(NULL);
4704 +static struct at91_eth_data __initdata tt9200_eth_data = {
4705 + .phy_irq_pin = AT91_PIN_PB29,
4709 +static struct at91_usbh_data __initdata tt9200_usbh_data = {
4713 +static struct i2c_board_info __initdata tt9200_i2c_devices[] = {
4715 + I2C_BOARD_INFO("rtc-m41t80", 0x68),
4720 +static struct at91_mmc_data __initdata tt9200_mmc_data = {
4726 +#if defined(CONFIG_MTD_DATAFLASH)
4727 +static struct mtd_partition __initdata tt9200_flash_partitions[] =
4730 + .name = "Darrell",
4732 + .size = 12 * 1056,
4736 + .offset = MTDPART_OFS_NXTBLK,
4737 + .size = 110 * 1056,
4740 + .name = "U-boot env",
4741 + .offset = MTDPART_OFS_NXTBLK,
4746 + .offset = MTDPART_OFS_NXTBLK,
4747 + .size = 1534 * 1056,
4750 + .name = "Filesystem",
4751 + .offset = MTDPART_OFS_NXTBLK,
4752 + .size = MTDPART_SIZ_FULL,
4756 +static struct flash_platform_data __initdata tt9200_flash_platform = {
4757 + .name = "SPI Dataflash",
4758 + .parts = tt9200_flash_partitions,
4759 + .nr_parts = ARRAY_SIZE(tt9200_flash_partitions)
4764 +static struct spi_board_info __initdata tt9200_spi_devices[] = {
4765 + { /* DataFlash chip */
4766 + .modalias = "mtd_dataflash",
4769 + .max_speed_hz = 5 * 1000 * 1000,
4771 +#if defined(CONFIG_MTD_DATAFLASH)
4772 + .platform_data = &tt9200_flash_platform,
4777 +static struct gpio_led tt9200_leds[] = {
4780 + .gpio = AT91_PIN_PB27,
4782 + .default_trigger = "heartbeat",
4786 +static void __init tt9200_board_init(void)
4789 + at91_add_device_serial();
4792 + at91_add_device_eth(&tt9200_eth_data);
4795 + at91_add_device_usbh(&tt9200_usbh_data);
4798 + at91_add_device_i2c(tt9200_i2c_devices, ARRAY_SIZE(tt9200_i2c_devices));
4801 + at91_add_device_mmc(0, &tt9200_mmc_data);
4804 + at91_gpio_leds(tt9200_leds, ARRAY_SIZE(tt9200_leds));
4807 + at91_add_device_spi(tt9200_spi_devices, ARRAY_SIZE(tt9200_spi_devices));
4810 +MACHINE_START(TT9200, "Toptech TT9200")
4811 + /* Maintainer: toptech.com.ar */
4812 + .phys_io = AT91_BASE_SYS,
4813 + .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
4814 + .boot_params = AT91_SDRAM_BASE + 0x100,
4815 + .timer = &at91rm9200_timer,
4816 + .map_io = tt9200_map_io,
4817 + .init_irq = tt9200_init_irq,
4818 + .init_machine = tt9200_board_init,
4821 +++ b/arch/arm/mach-at91/board-usb-a9260.c
4824 + * linux/arch/arm/mach-at91/board-usb-a9260.c
4826 + * Copyright (C) 2005 SAN People
4827 + * Copyright (C) 2006 Atmel
4828 + * Copyright (C) 2007 Calao-systems
4830 + * This program is free software; you can redistribute it and/or modify
4831 + * it under the terms of the GNU General Public License as published by
4832 + * the Free Software Foundation; either version 2 of the License, or
4833 + * (at your option) any later version.
4835 + * This program is distributed in the hope that it will be useful,
4836 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4837 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4838 + * GNU General Public License for more details.
4840 + * You should have received a copy of the GNU General Public License
4841 + * along with this program; if not, write to the Free Software
4842 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
4845 +#include <linux/types.h>
4846 +#include <linux/init.h>
4847 +#include <linux/mm.h>
4848 +#include <linux/module.h>
4849 +#include <linux/platform_device.h>
4850 +#include <linux/spi/spi.h>
4851 +#include <linux/gpio_keys.h>
4852 +#include <linux/input.h>
4853 +#include <linux/clk.h>
4855 +#include <asm/hardware.h>
4856 +#include <asm/setup.h>
4857 +#include <asm/mach-types.h>
4858 +#include <asm/irq.h>
4860 +#include <asm/mach/arch.h>
4861 +#include <asm/mach/map.h>
4862 +#include <asm/mach/irq.h>
4864 +#include <asm/arch/board.h>
4865 +#include <asm/arch/gpio.h>
4866 +#include <asm/arch/at91_shdwc.h>
4868 +#include "generic.h"
4871 +static void __init ek_map_io(void)
4873 + /* Initialize processor: 12.000 MHz crystal */
4874 + at91sam9260_initialize(12000000);
4876 + /* DGBU on ttyS0. (Rx & Tx only) */
4877 + at91_register_uart(0, 0, 0);
4879 + /* set serial console to ttyS0 (ie, DBGU) */
4880 + at91_set_serial_console(0);
4883 +static void __init ek_init_irq(void)
4885 + at91sam9260_init_interrupts(NULL);
4892 +static struct at91_usbh_data __initdata ek_usbh_data = {
4899 +static struct at91_udc_data __initdata ek_udc_data = {
4900 + .vbus_pin = AT91_PIN_PC5,
4901 + .pullup_pin = 0, /* pull-up driven by UDC */
4905 + * MACB Ethernet device
4907 +static struct at91_eth_data __initdata ek_macb_data = {
4908 + .phy_irq_pin = AT91_PIN_PA31,
4915 +static struct mtd_partition __initdata ek_nand_partition[] = {
4917 + .name = "Uboot & Kernel",
4918 + .offset = 0x00000000,
4919 + .size = 16 * 1024 * 1024,
4922 + .name = "Root FS",
4923 + .offset = 0x01000000,
4924 + .size = 120 * 1024 * 1024,
4928 + .offset = 0x08800000,
4929 + .size = 120 * 1024 * 1024,
4933 +static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
4935 + *num_partitions = ARRAY_SIZE(ek_nand_partition);
4936 + return ek_nand_partition;
4939 +static struct at91_nand_data __initdata ek_nand_data = {
4942 +// .det_pin = ... not connected
4943 + .rdy_pin = AT91_PIN_PC13,
4944 + .enable_pin = AT91_PIN_PC14,
4945 + .partition_info = nand_partitions,
4946 +#if defined(CONFIG_MTD_NAND_AT91_BUSWIDTH_16)
4947 + .bus_width_16 = 1,
4949 + .bus_width_16 = 0,
4957 +#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
4958 +static struct gpio_keys_button ek_buttons[] = {
4959 + { /* USER PUSH BUTTON */
4960 + .code = KEY_ENTER,
4961 + .gpio = AT91_PIN_PB10,
4963 + .desc = "user_pb",
4968 +static struct gpio_keys_platform_data ek_button_data = {
4969 + .buttons = ek_buttons,
4970 + .nbuttons = ARRAY_SIZE(ek_buttons),
4973 +static struct platform_device ek_button_device = {
4974 + .name = "gpio-keys",
4976 + .num_resources = 0,
4978 + .platform_data = &ek_button_data,
4982 +static void __init ek_add_device_buttons(void)
4984 + at91_set_GPIO_periph(AT91_PIN_PB10, 1); /* user push button, pull up enabled */
4985 + at91_set_deglitch(AT91_PIN_PB10, 1);
4987 + platform_device_register(&ek_button_device);
4990 +static void __init ek_add_device_buttons(void) {}
4996 +static struct gpio_led ek_leds[] = {
4997 + { /* user_led (green) */
4998 + .name = "user_led",
4999 + .gpio = AT91_PIN_PB21,
5001 + .default_trigger = "heartbeat",
5005 +static void __init ek_board_init(void)
5008 + at91_add_device_serial();
5010 + at91_add_device_usbh(&ek_usbh_data);
5012 + at91_add_device_udc(&ek_udc_data);
5014 + at91_add_device_nand(&ek_nand_data);
5016 + at91_add_device_i2c(NULL, 0);
5018 + at91_add_device_eth(&ek_macb_data);
5019 + /* Push Buttons */
5020 + ek_add_device_buttons();
5022 + at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
5023 + /* shutdown controller, wakeup button (5 msec low) */
5024 + at91_sys_write(AT91_SHDW_MR, AT91_SHDW_CPTWK0_(10) | AT91_SHDW_WKMODE0_LOW
5025 + | AT91_SHDW_RTTWKEN);
5028 +MACHINE_START(USB_A9260, "CALAO USB_A9260")
5029 + /* Maintainer: calao-systems */
5030 + .phys_io = AT91_BASE_SYS,
5031 + .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
5032 + .boot_params = AT91_SDRAM_BASE + 0x100,
5033 + .timer = &at91sam926x_timer,
5034 + .map_io = ek_map_io,
5035 + .init_irq = ek_init_irq,
5036 + .init_machine = ek_board_init,
5039 +++ b/arch/arm/mach-at91/board-usb-a9263.c
5042 + * linux/arch/arm/mach-at91/board-usb-a9263.c
5044 + * Copyright (C) 2005 SAN People
5045 + * Copyright (C) 2007 Atmel Corporation.
5046 + * Copyright (C) 2007 Calao-systems
5048 + * This program is free software; you can redistribute it and/or modify
5049 + * it under the terms of the GNU General Public License as published by
5050 + * the Free Software Foundation; either version 2 of the License, or
5051 + * (at your option) any later version.
5053 + * This program is distributed in the hope that it will be useful,
5054 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
5055 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5056 + * GNU General Public License for more details.
5058 + * You should have received a copy of the GNU General Public License
5059 + * along with this program; if not, write to the Free Software
5060 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
5063 +#include <linux/types.h>
5064 +#include <linux/init.h>
5065 +#include <linux/mm.h>
5066 +#include <linux/module.h>
5067 +#include <linux/platform_device.h>
5068 +#include <linux/spi/spi.h>
5069 +#include <linux/gpio_keys.h>
5070 +#include <linux/input.h>
5072 +#include <asm/hardware.h>
5073 +#include <asm/setup.h>
5074 +#include <asm/mach-types.h>
5075 +#include <asm/irq.h>
5077 +#include <asm/mach/arch.h>
5078 +#include <asm/mach/map.h>
5079 +#include <asm/mach/irq.h>
5081 +#include <asm/arch/board.h>
5082 +#include <asm/arch/gpio.h>
5083 +#include <asm/arch/at91_shdwc.h>
5085 +#include "generic.h"
5088 +static void __init ek_map_io(void)
5090 + /* Initialize processor: 12.00 MHz crystal */
5091 + at91sam9263_initialize(12000000);
5093 + /* DGBU on ttyS0. (Rx & Tx only) */
5094 + at91_register_uart(0, 0, 0);
5096 + /* set serial console to ttyS0 (ie, DBGU) */
5097 + at91_set_serial_console(0);
5100 +static void __init ek_init_irq(void)
5102 + at91sam9263_init_interrupts(NULL);
5109 +static struct at91_usbh_data __initdata ek_usbh_data = {
5116 +static struct at91_udc_data __initdata ek_udc_data = {
5117 + .vbus_pin = AT91_PIN_PB11,
5118 + .pullup_pin = 0, /* pull-up driven by UDC */
5124 +static struct spi_board_info ek_spi_devices[] = {
5125 +#if !defined(CONFIG_MMC_AT91)
5126 + { /* DataFlash chip */
5127 + .modalias = "mtd_dataflash",
5129 + .max_speed_hz = 15 * 1000 * 1000,
5136 + * MACB Ethernet device
5138 +static struct at91_eth_data __initdata ek_macb_data = {
5139 + .phy_irq_pin = AT91_PIN_PE31,
5146 +static struct mtd_partition __initdata ek_nand_partition[] = {
5148 + .name = "Linux Kernel",
5149 + .offset = 0x00000000,
5150 + .size = 16 * 1024 * 1024,
5153 + .name = "Root FS",
5154 + .offset = 0x01000000,
5155 + .size = 120 * 1024 * 1024,
5159 + .offset = 0x08800000,
5160 + .size = 120 * 1024 * 1024,
5164 +static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
5166 + *num_partitions = ARRAY_SIZE(ek_nand_partition);
5167 + return ek_nand_partition;
5170 +static struct at91_nand_data __initdata ek_nand_data = {
5173 +// .det_pin = ... not connected
5174 + .rdy_pin = AT91_PIN_PA22,
5175 + .enable_pin = AT91_PIN_PD15,
5176 + .partition_info = nand_partitions,
5177 +#if defined(CONFIG_MTD_NAND_AT91_BUSWIDTH_16)
5178 + .bus_width_16 = 1,
5180 + .bus_width_16 = 0,
5187 +#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
5188 +static struct gpio_keys_button ek_buttons[] = {
5189 + { /* USER PUSH BUTTON */
5190 + .code = KEY_ENTER,
5191 + .gpio = AT91_PIN_PB10,
5193 + .desc = "user_pb",
5198 +static struct gpio_keys_platform_data ek_button_data = {
5199 + .buttons = ek_buttons,
5200 + .nbuttons = ARRAY_SIZE(ek_buttons),
5203 +static struct platform_device ek_button_device = {
5204 + .name = "gpio-keys",
5206 + .num_resources = 0,
5208 + .platform_data = &ek_button_data,
5212 +static void __init ek_add_device_buttons(void)
5214 + at91_set_GPIO_periph(AT91_PIN_PB10, 1); /* user push button, pull up enabled */
5215 + at91_set_deglitch(AT91_PIN_PB10, 1);
5217 + platform_device_register(&ek_button_device);
5220 +static void __init ek_add_device_buttons(void) {}
5226 +static struct gpio_led ek_leds[] = {
5227 + { /* user_led (green) */
5228 + .name = "user_led",
5229 + .gpio = AT91_PIN_PB21,
5231 + .default_trigger = "heartbeat",
5236 +static void __init ek_board_init(void)
5239 + at91_add_device_serial();
5241 + at91_add_device_usbh(&ek_usbh_data);
5243 + at91_add_device_udc(&ek_udc_data);
5245 + at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
5247 + at91_add_device_eth(&ek_macb_data);
5249 + at91_add_device_nand(&ek_nand_data);
5251 + at91_add_device_i2c(NULL, 0);
5252 + /* Push Buttons */
5253 + ek_add_device_buttons();
5255 + at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
5256 + /* shutdown controller, wakeup button (5 msec low) */
5257 + at91_sys_write(AT91_SHDW_MR, AT91_SHDW_CPTWK0_(10) | AT91_SHDW_WKMODE0_LOW
5258 + | AT91_SHDW_RTTWKEN);
5261 +MACHINE_START(USB_A9263, "CALAO USB_A9263")
5262 + /* Maintainer: calao-systems */
5263 + .phys_io = AT91_BASE_SYS,
5264 + .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
5265 + .boot_params = AT91_SDRAM_BASE + 0x100,
5266 + .timer = &at91sam926x_timer,
5267 + .map_io = ek_map_io,
5268 + .init_irq = ek_init_irq,
5269 + .init_machine = ek_board_init,
5271 --- a/arch/arm/mach-at91/clock.c
5272 +++ b/arch/arm/mach-at91/clock.c
5274 #include <asm/arch/cpu.h>
5277 +#include "generic.h"
5281 @@ -113,12 +114,34 @@ static void pmc_sys_mode(struct clk *clk
5282 at91_sys_write(AT91_PMC_SCDR, clk->pmc_mask);
5285 +static void pmc_uckr_mode(struct clk *clk, int is_on)
5287 + unsigned int uckr = at91_sys_read(AT91_CKGR_UCKR);
5290 + is_on = AT91_PMC_LOCKU;
5291 + at91_sys_write(AT91_CKGR_UCKR, uckr | clk->pmc_mask);
5293 + at91_sys_write(AT91_CKGR_UCKR, uckr & ~(clk->pmc_mask));
5297 + } while ((at91_sys_read(AT91_PMC_SR) & AT91_PMC_LOCKU) != is_on);
5300 /* USB function clocks (PLLB must be 48 MHz) */
5301 static struct clk udpck = {
5304 .mode = pmc_sys_mode,
5306 +static struct clk utmi_clk = {
5307 + .name = "utmi_clk",
5308 + .parent = &main_clk,
5309 + .pmc_mask = AT91_PMC_UPLLEN, /* in CKGR_UCKR */
5310 + .mode = pmc_uckr_mode,
5311 + .type = CLK_TYPE_PLL,
5313 static struct clk uhpck = {
5316 @@ -254,6 +277,23 @@ EXPORT_SYMBOL(clk_get_rate);
5318 /*------------------------------------------------------------------------*/
5322 +int clk_must_disable(struct clk *clk)
5324 + if (!at91_suspend_entering_slow_clock())
5327 + while (clk->parent)
5328 + clk = clk->parent;
5329 + return clk != &clk32k;
5331 +EXPORT_SYMBOL(clk_must_disable);
5335 +/*------------------------------------------------------------------------*/
5337 #ifdef CONFIG_AT91_PROGRAMMABLE_CLOCKS
5340 @@ -362,7 +402,7 @@ static void __init init_programmable_clo
5342 static int at91_clk_show(struct seq_file *s, void *unused)
5344 - u32 scsr, pcsr, sr;
5345 + u32 scsr, pcsr, uckr = 0, sr;
5348 seq_printf(s, "SCSR = %8x\n", scsr = at91_sys_read(AT91_PMC_SCSR));
5349 @@ -370,7 +410,10 @@ static int at91_clk_show(struct seq_file
5350 seq_printf(s, "MOR = %8x\n", at91_sys_read(AT91_CKGR_MOR));
5351 seq_printf(s, "MCFR = %8x\n", at91_sys_read(AT91_CKGR_MCFR));
5352 seq_printf(s, "PLLA = %8x\n", at91_sys_read(AT91_CKGR_PLLAR));
5353 - seq_printf(s, "PLLB = %8x\n", at91_sys_read(AT91_CKGR_PLLBR));
5354 + if (!cpu_is_at91sam9rl())
5355 + seq_printf(s, "PLLB = %8x\n", at91_sys_read(AT91_CKGR_PLLBR));
5356 + if (cpu_is_at91cap9() || cpu_is_at91sam9rl())
5357 + seq_printf(s, "UCKR = %8x\n", uckr = at91_sys_read(AT91_CKGR_UCKR));
5358 seq_printf(s, "MCKR = %8x\n", at91_sys_read(AT91_PMC_MCKR));
5359 seq_printf(s, "SR = %8x\n", sr = at91_sys_read(AT91_PMC_SR));
5361 @@ -383,6 +426,8 @@ static int at91_clk_show(struct seq_file
5362 state = (scsr & clk->pmc_mask) ? "on" : "off";
5363 else if (clk->mode == pmc_periph_mode)
5364 state = (pcsr & clk->pmc_mask) ? "on" : "off";
5365 + else if (clk->mode == pmc_uckr_mode)
5366 + state = (uckr & clk->pmc_mask) ? "on" : "off";
5367 else if (clk->pmc_mask)
5368 state = (sr & clk->pmc_mask) ? "on" : "off";
5369 else if (clk == &clk32k || clk == &main_clk)
5370 @@ -583,6 +628,17 @@ int __init at91_clock_init(unsigned long
5371 uhpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, at91_pllb_usb_init);
5374 + * USB HS clock init
5376 + if (cpu_is_at91cap9() || cpu_is_at91sam9rl()) {
5378 + * multiplier is hard-wired to 40
5379 + * (obtain the USB High Speed 480 MHz when input is 12 MHz)
5381 + utmi_clk.rate_hz = 40 * utmi_clk.parent->rate_hz;
5385 * MCK and CPU derive from one of those primary clocks.
5386 * For now, assume this parentage won't change.
5388 @@ -599,6 +655,9 @@ int __init at91_clock_init(unsigned long
5389 for (i = 0; i < ARRAY_SIZE(standard_pmc_clocks); i++)
5390 list_add_tail(&standard_pmc_clocks[i]->node, &clocks);
5392 + if (cpu_is_at91cap9() || cpu_is_at91sam9rl())
5393 + list_add_tail(&utmi_clk.node, &clocks);
5395 /* MCK and CPU clock are "always on" */
5398 --- a/arch/arm/mach-at91/generic.h
5399 +++ b/arch/arm/mach-at91/generic.h
5400 @@ -41,6 +41,7 @@ extern void __init at91_clock_associate(
5401 /* Power Management */
5402 extern void at91_irq_suspend(void);
5403 extern void at91_irq_resume(void);
5404 +extern int at91_suspend_entering_slow_clock(void);
5407 #define AT91RM9200_PQFP 3 /* AT91RM9200 PQFP package has 3 banks */
5408 --- a/arch/arm/mach-at91/gpio.c
5409 +++ b/arch/arm/mach-at91/gpio.c
5410 @@ -490,7 +490,8 @@ postcore_initcall(at91_gpio_debugfs_init
5412 /*--------------------------------------------------------------------------*/
5414 -/* This lock class tells lockdep that GPIO irqs are in a different
5416 + * This lock class tells lockdep that GPIO irqs are in a different
5417 * category than their parents, so it won't report false recursion.
5419 static struct lock_class_key gpio_lock_class;
5420 @@ -557,6 +558,7 @@ void __init at91_gpio_init(struct at91_g
5421 data->regbase = data->offset + (void __iomem *)AT91_VA_BASE_SYS;
5423 /* AT91SAM9263_ID_PIOCDE groups PIOC, PIOD, PIOE */
5424 + /* AT91CAP9_ID_PIOABCD groups PIOA, PIOB, PIOC, PIOD */
5425 if (last && last->id == data->id)
5429 +++ b/arch/arm/mach-at91/ics1523.c
5432 + * arch/arm/mach-at91rm9200/ics1523.c
5434 + * Copyright (C) 2003 ATMEL Rousset
5436 + * This program is free software; you can redistribute it and/or modify
5437 + * it under the terms of the GNU General Public License as published by
5438 + * the Free Software Foundation; either version 2 of the License, or
5439 + * (at your option) any later version.
5441 + * This program is distributed in the hope that it will be useful,
5442 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
5443 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5444 + * GNU General Public License for more details.
5446 + * You should have received a copy of the GNU General Public License
5447 + * along with this program; if not, write to the Free Software
5448 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
5451 +#include <asm/hardware.h>
5452 +#include <asm/io.h>
5454 +#include <linux/clk.h>
5455 +#include <linux/delay.h>
5456 +#include <linux/err.h>
5457 +#include <linux/init.h>
5458 +#include <linux/kernel.h>
5460 +#include <asm/arch/ics1523.h>
5461 +#include <asm/arch/at91_twi.h>
5462 +#include <asm/arch/gpio.h>
5465 +#define AT91_TWI_ERROR (AT91_TWI_NACK | AT91_TWI_UNRE | AT91_TWI_OVRE)
5468 +static void __iomem *twi_base;
5470 +#define at91_twi_read(reg) __raw_readl(twi_base + (reg))
5471 +#define at91_twi_write(reg, val) __raw_writel((val), twi_base + (reg))
5474 +/* -----------------------------------------------------------------------------
5475 + * Initialization of TWI CLOCK
5476 + * ----------------------------------------------------------------------------- */
5478 +static void at91_ics1523_SetTwiClock(unsigned int mck_khz)
5482 + /* Here, CKDIV = 1 and CHDIV = CLDIV ==> CLDIV = CHDIV = 1/4*((Fmclk/FTWI) -6) */
5483 + sclock = (10*mck_khz / ICS_TRANSFER_RATE);
5484 + if (sclock % 10 >= 5)
5485 + sclock = (sclock /10) - 5;
5487 + sclock = (sclock /10)- 6;
5488 + sclock = (sclock + (4 - sclock %4)) >> 2; /* div 4 */
5490 + at91_twi_write(AT91_TWI_CWGR, 0x00010000 | sclock | (sclock << 8));
5493 +/* -----------------------------------------------------------------------------
5494 + * Read a byte with TWI Interface from the Clock Generator ICS1523
5495 + * ----------------------------------------------------------------------------- */
5497 +static int at91_ics1523_ReadByte(unsigned char reg_address, unsigned char *data_in)
5499 + int Status, nb_trial;
5501 + at91_twi_write(AT91_TWI_MMR, AT91_TWI_MREAD | AT91_TWI_IADRSZ_1 | ((ICS_ADDR << 16) & AT91_TWI_DADR));
5502 + at91_twi_write(AT91_TWI_IADR, reg_address);
5503 + at91_twi_write(AT91_TWI_CR, AT91_TWI_START | AT91_TWI_STOP);
5505 + /* Program temporizing period (300us) */
5508 + /* Wait TXcomplete ... */
5510 + Status = at91_twi_read(AT91_TWI_SR);
5511 + while (!(Status & AT91_TWI_TXCOMP) && (nb_trial < 10)) {
5513 + Status = at91_twi_read(AT91_TWI_SR);
5516 + if (Status & AT91_TWI_TXCOMP) {
5517 + *data_in = (unsigned char) at91_twi_read(AT91_TWI_RHR);
5518 + return ICS1523_ACCESS_OK;
5521 + return ICS1523_ACCESS_ERROR;
5524 +/* -----------------------------------------------------------------------------
5525 + * Write a byte with TWI Interface to the Clock Generator ICS1523
5526 + * ----------------------------------------------------------------------------- */
5528 +static int at91_ics1523_WriteByte(unsigned char reg_address, unsigned char data_out)
5530 + int Status, nb_trial;
5532 + at91_twi_write(AT91_TWI_MMR, AT91_TWI_IADRSZ_1 | ((ICS_ADDR << 16) & AT91_TWI_DADR));
5533 + at91_twi_write(AT91_TWI_IADR, reg_address);
5534 + at91_twi_write(AT91_TWI_THR, data_out);
5535 + at91_twi_write(AT91_TWI_CR, AT91_TWI_START | AT91_TWI_STOP);
5537 + /* Program temporizing period (300us) */
5541 + Status = at91_twi_read(AT91_TWI_SR);
5542 + while (!(Status & AT91_TWI_TXCOMP) && (nb_trial < 10)) {
5544 + if (Status & AT91_TWI_ERROR) {
5545 + /* If Underrun OR NACK - Start again */
5546 + at91_twi_write(AT91_TWI_CR, AT91_TWI_START | AT91_TWI_STOP);
5548 + /* Program temporizing period (300us) */
5551 + Status = at91_twi_read(AT91_TWI_SR);
5554 + if (Status & AT91_TWI_TXCOMP)
5555 + return ICS1523_ACCESS_OK;
5557 + return ICS1523_ACCESS_ERROR;
5560 +/* -----------------------------------------------------------------------------
5561 + * Initialization of the Clock Generator ICS1523
5562 + * ----------------------------------------------------------------------------- */
5564 +int at91_ics1523_init(void)
5567 + int ack = ICS1523_ACCESS_OK;
5568 + unsigned int status = 0xffffffff;
5569 + struct clk *twi_clk;
5571 + /* Map in TWI peripheral */
5572 + twi_base = ioremap(AT91RM9200_BASE_TWI, SZ_16K);
5576 + /* pins used for TWI interface */
5577 + at91_set_A_periph(AT91_PIN_PA25, 0); /* TWD */
5578 + at91_set_multi_drive(AT91_PIN_PA25, 1);
5579 + at91_set_A_periph(AT91_PIN_PA26, 0); /* TWCK */
5580 + at91_set_multi_drive(AT91_PIN_PA26, 1);
5582 + /* Enable the TWI clock */
5583 + twi_clk = clk_get(NULL, "twi_clk");
5584 + if (IS_ERR(twi_clk))
5585 + return ICS1523_ACCESS_ERROR;
5586 + clk_enable(twi_clk);
5588 + /* Disable interrupts */
5589 + at91_twi_write(AT91_TWI_IDR, -1);
5591 + /* Reset peripheral */
5592 + at91_twi_write(AT91_TWI_CR, AT91_TWI_SWRST);
5594 + /* Set Master mode */
5595 + at91_twi_write(AT91_TWI_CR, AT91_TWI_MSEN);
5597 + /* Set TWI Clock Waveform Generator Register */
5598 + at91_ics1523_SetTwiClock(60000); /* MCK in KHz = 60000 KHz */
5600 + /* ICS1523 Initialisation */
5601 + ack |= at91_ics1523_WriteByte ((unsigned char) ICS_ICR, (unsigned char) 0);
5602 + ack |= at91_ics1523_WriteByte ((unsigned char) ICS_OE, (unsigned char) (ICS_OEF | ICS_OET2 | ICS_OETCK));
5603 + ack |= at91_ics1523_WriteByte ((unsigned char) ICS_OD, (unsigned char) (ICS_INSEL | 0x7F));
5604 + ack |= at91_ics1523_WriteByte ((unsigned char) ICS_DPAO, (unsigned char) 0);
5609 + ack |= at91_ics1523_WriteByte ((unsigned char) ICS_ICR, (unsigned char) (ICS_ENDLS | ICS_ENPLS | ICS_PDEN /*| ICS_FUNCSEL*/));
5610 + ack |= at91_ics1523_WriteByte ((unsigned char) ICS_LCR, (unsigned char) (ICS_PSD | ICS_PFD));
5611 + ack |= at91_ics1523_WriteByte ((unsigned char) ICS_FD0, (unsigned char) 0x39) ; /* 0x7A */
5612 + ack |= at91_ics1523_WriteByte ((unsigned char) ICS_FD1, (unsigned char) 0x00);
5613 + ack |= at91_ics1523_WriteByte ((unsigned char) ICS_SWRST, (unsigned char) (ICS_PLLR));
5615 + /* Program 1ms temporizing period */
5618 + at91_ics1523_ReadByte ((unsigned char) ICS_SR, (char *)&status);
5619 + } while (!((unsigned int) status & (unsigned int) ICS_PLLLOCK) && (nb_trial < 10));
5621 + ack |= at91_ics1523_WriteByte ((unsigned char) ICS_DPAC, (unsigned char) 0x03) ; /* 0x01 */
5622 + ack |= at91_ics1523_WriteByte ((unsigned char) ICS_SWRST, (unsigned char) (ICS_DPAR));
5624 + /* Program 1ms temporizing period */
5627 + ack |= at91_ics1523_WriteByte ((unsigned char) ICS_DPAO, (unsigned char) 0x00);
5629 + /* Program 1ms temporizing period */
5632 + /* All done - cleanup */
5633 + iounmap(twi_base);
5634 + clk_disable(twi_clk);
5639 --- a/arch/arm/mach-at91/pm.c
5640 +++ b/arch/arm/mach-at91/pm.c
5641 @@ -26,12 +26,144 @@
5642 #include <asm/mach-types.h>
5644 #include <asm/arch/at91_pmc.h>
5645 -#include <asm/arch/at91rm9200_mc.h>
5646 #include <asm/arch/gpio.h>
5647 #include <asm/arch/cpu.h>
5649 #include "generic.h"
5651 +#ifdef CONFIG_ARCH_AT91RM9200
5652 +#include <asm/arch/at91rm9200_mc.h>
5655 + * The AT91RM9200 goes into self-refresh mode with this command, and will
5656 + * terminate self-refresh automatically on the next SDRAM access.
5658 +#define sdram_selfrefresh_enable() at91_sys_write(AT91_SDRAMC_SRR, 1)
5659 +#define sdram_selfrefresh_disable() do {} while (0)
5661 +#elif defined(CONFIG_ARCH_AT91CAP9)
5662 +#include <asm/arch/at91cap9_ddrsdr.h>
5664 +static u32 saved_lpr;
5666 +static inline void sdram_selfrefresh_enable(void)
5670 + saved_lpr = at91_sys_read(AT91_DDRSDRC_LPR);
5672 + lpr = saved_lpr & ~AT91_DDRSDRC_LPCB;
5673 + at91_sys_write(AT91_DDRSDRC_LPR, lpr | AT91_DDRSDRC_LPCB_SELF_REFRESH);
5676 +#define sdram_selfrefresh_disable() at91_sys_write(AT91_DDRSDRC_LPR, saved_lpr)
5679 +#include <asm/arch/at91sam9_sdramc.h>
5681 +#ifdef CONFIG_ARCH_AT91SAM9263
5683 + * FIXME either or both the SDRAM controllers (EB0, EB1) might be in use;
5684 + * handle those cases both here and in the Suspend-To-RAM support.
5686 +#define AT91_SDRAMC AT91_SDRAMC0
5687 +#warning Assuming EB1 SDRAM controller is *NOT* used
5690 +static u32 saved_lpr;
5692 +static inline void sdram_selfrefresh_enable(void)
5696 + saved_lpr = at91_sys_read(AT91_SDRAMC_LPR);
5698 + lpr = saved_lpr & ~AT91_SDRAMC_LPCB;
5699 + at91_sys_write(AT91_SDRAMC_LPR, lpr | AT91_SDRAMC_LPCB_SELF_REFRESH);
5702 +#define sdram_selfrefresh_disable() at91_sys_write(AT91_SDRAMC_LPR, saved_lpr)
5705 + * FIXME: The AT91SAM9263 has a second EBI controller which may have
5706 + * additional SDRAM. pm_slowclock.S will require a similar fix.
5713 + * Show the reason for the previous system reset.
5715 +#if defined(AT91_SHDWC)
5717 +#include <asm/arch/at91_rstc.h>
5718 +#include <asm/arch/at91_shdwc.h>
5720 +static void __init show_reset_status(void)
5722 + static char reset[] __initdata = "reset";
5724 + static char general[] __initdata = "general";
5725 + static char wakeup[] __initdata = "wakeup";
5726 + static char watchdog[] __initdata = "watchdog";
5727 + static char software[] __initdata = "software";
5728 + static char user[] __initdata = "user";
5729 + static char unknown[] __initdata = "unknown";
5731 + static char signal[] __initdata = "signal";
5732 + static char rtc[] __initdata = "rtc";
5733 + static char rtt[] __initdata = "rtt";
5734 + static char restore[] __initdata = "power-restored";
5736 + char *reason, *r2 = reset;
5737 + u32 reset_type, wake_type;
5739 + reset_type = at91_sys_read(AT91_RSTC_SR) & AT91_RSTC_RSTTYP;
5740 + wake_type = at91_sys_read(AT91_SHDW_SR);
5742 + switch (reset_type) {
5743 + case AT91_RSTC_RSTTYP_GENERAL:
5746 + case AT91_RSTC_RSTTYP_WAKEUP:
5747 + /* board-specific code enabled the wakeup sources */
5750 + /* "wakeup signal" */
5751 + if (wake_type & AT91_SHDW_WAKEUP0)
5755 + if (wake_type & AT91_SHDW_RTTWK) /* rtt wakeup */
5757 + else if (wake_type & AT91_SHDW_RTCWK) /* rtc wakeup */
5759 + else if (wake_type == 0) /* power-restored wakeup */
5761 + else /* unknown wakeup */
5765 + case AT91_RSTC_RSTTYP_WATCHDOG:
5766 + reason = watchdog;
5768 + case AT91_RSTC_RSTTYP_SOFTWARE:
5769 + reason = software;
5771 + case AT91_RSTC_RSTTYP_USER:
5778 + pr_info("AT91: Starting after %s %s\n", reason, r2);
5781 +static void __init show_reset_status(void) {}
5785 static int at91_pm_valid_state(suspend_state_t state)
5787 @@ -62,6 +194,7 @@ static int at91_pm_begin(suspend_state_t
5788 * Verify that all the clocks are correct before entering
5791 +#warning "This should probably be moved to clocks.c"
5792 static int at91_pm_verify_clocks(void)
5795 @@ -107,24 +240,24 @@ static int at91_pm_verify_clocks(void)
5799 - * Call this from platform driver suspend() to see how deeply to suspend.
5800 + * This is called from clk_must_disable(), to see how deeply to suspend.
5801 * For example, some controllers (like OHCI) need one of the PLL clocks
5802 * in order to act as a wakeup source, and those are not available when
5803 * going into slow clock mode.
5805 - * REVISIT: generalize as clk_will_be_available(clk)? Other platforms have
5806 - * the very same problem (but not using at91 main_clk), and it'd be better
5807 - * to add one generic API rather than lots of platform-specific ones.
5809 int at91_suspend_entering_slow_clock(void)
5811 return (target_state == PM_SUSPEND_MEM);
5813 -EXPORT_SYMBOL(at91_suspend_entering_slow_clock);
5816 static void (*slow_clock)(void);
5818 +#ifdef CONFIG_AT91_SLOW_CLOCK
5819 +extern void at91_slow_clock(void);
5820 +extern u32 at91_slow_clock_sz;
5824 static int at91_pm_enter(suspend_state_t state)
5826 @@ -158,11 +291,14 @@ static int at91_pm_enter(suspend_state_t
5827 * turning off the main oscillator; reverse on wakeup.
5830 +#ifdef CONFIG_AT91_SLOW_CLOCK
5831 + /* copy slow_clock handler to SRAM, and call it */
5832 + memcpy(slow_clock, at91_slow_clock, at91_slow_clock_sz);
5837 - /* DEVELOPMENT ONLY */
5838 - pr_info("AT91: PM - no slow clock mode yet ...\n");
5839 + pr_info("AT91: PM - no slow clock mode enabled ...\n");
5840 /* FALLTHROUGH leaving master clock alone */
5843 @@ -175,13 +311,15 @@ static int at91_pm_enter(suspend_state_t
5844 case PM_SUSPEND_STANDBY:
5846 * NOTE: the Wait-for-Interrupt instruction needs to be
5847 - * in icache so the SDRAM stays in self-refresh mode until
5848 - * the wakeup IRQ occurs.
5849 + * in icache so no SDRAM accesses are needed until the
5850 + * wakeup IRQ occurs and self-refresh is terminated.
5852 asm("b 1f; .align 5; 1:");
5853 asm("mcr p15, 0, r0, c7, c10, 4"); /* drain write buffer */
5854 - at91_sys_write(AT91_SDRAMC_SRR, 1); /* self-refresh mode */
5855 - /* fall though to next state */
5856 + sdram_selfrefresh_enable();
5857 + asm("mcr p15, 0, r0, c7, c0, 4"); /* wait for interrupt */
5858 + sdram_selfrefresh_disable();
5862 asm("mcr p15, 0, r0, c7, c0, 4"); /* wait for interrupt */
5863 @@ -196,6 +334,7 @@ static int at91_pm_enter(suspend_state_t
5864 at91_sys_read(AT91_AIC_IPR) & at91_sys_read(AT91_AIC_IMR));
5867 + sdram_selfrefresh_disable();
5868 target_state = PM_SUSPEND_ON;
5871 @@ -220,21 +359,20 @@ static struct platform_suspend_ops at91_
5873 static int __init at91_pm_init(void)
5875 - printk("AT91: Power Management\n");
5877 -#ifdef CONFIG_AT91_PM_SLOW_CLOCK
5878 - /* REVISIT allocations of SRAM should be dynamically managed.
5879 - * FIQ handlers and other components will want SRAM/TCM too...
5881 - slow_clock = (void *) (AT91_VA_BASE_SRAM + (3 * SZ_4K));
5882 - memcpy(slow_clock, at91rm9200_slow_clock, at91rm9200_slow_clock_sz);
5883 +#ifdef CONFIG_AT91_SLOW_CLOCK
5884 + slow_clock = (void *) (AT91_IO_VIRT_BASE - at91_slow_clock_sz);
5887 - /* Disable SDRAM low-power mode. Cannot be used with self-refresh. */
5888 + pr_info("AT91: Power Management%s\n", (slow_clock ? " (with slow clock mode)" : ""));
5890 +#ifdef CONFIG_ARCH_AT91RM9200
5891 + /* AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. */
5892 at91_sys_write(AT91_SDRAMC_LPR, 0);
5895 suspend_set_ops(&at91_pm_ops);
5897 + show_reset_status();
5900 arch_initcall(at91_pm_init);
5902 +++ b/arch/arm/mach-at91/pm_slowclock.S
5905 + * arch/arm/mach-at91/pm_slow_clock.S
5907 + * Copyright (C) 2006 Savin Zlobec
5909 + * AT91SAM9 support:
5910 + * Copyright (C) 2007 Anti Sullin <anti.sullin@artecdesign.ee
5912 + * This program is free software; you can redistribute it and/or modify
5913 + * it under the terms of the GNU General Public License version 2 as
5914 + * published by the Free Software Foundation.
5918 +#include <linux/linkage.h>
5919 +#include <asm/hardware.h>
5920 +#include <asm/arch/at91_pmc.h>
5922 +#ifdef CONFIG_ARCH_AT91RM9200
5923 +#include <asm/arch/at91rm9200_mc.h>
5924 +#elif defined(CONFIG_ARCH_AT91CAP9)
5925 +#include <asm/arch/at91cap9_ddrsdr.h>
5927 +#include <asm/arch/at91sam9_sdramc.h>
5931 +#ifdef CONFIG_ARCH_AT91SAM9263
5933 + * FIXME either or both the SDRAM controllers (EB0, EB1) might be in use;
5934 + * handle those cases both here and in the Suspend-To-RAM support.
5936 +#define AT91_SDRAMC AT91_SDRAMC0
5937 +#warning Assuming EB1 SDRAM controller is *NOT* used
5941 + * When SLOWDOWN_MASTER_CLOCK is defined we will also slow down the Master
5942 + * clock during suspend by adjusting its prescalar and divisor.
5943 + * NOTE: This hasn't been shown to be stable on SAM9s; and on the RM9200 there
5944 + * are errata regarding adjusting the prescalar and divisor.
5946 +#undef SLOWDOWN_MASTER_CLOCK
5948 +#define MCKRDY_TIMEOUT 1000
5949 +#define MOSCRDY_TIMEOUT 1000
5950 +#define PLLALOCK_TIMEOUT 1000
5951 +#define PLLBLOCK_TIMEOUT 1000
5955 + * Wait until master clock is ready (after switching master clock source)
5957 + .macro wait_mckrdy
5958 + mov r4, #MCKRDY_TIMEOUT
5962 + ldr r3, [r1, #(AT91_PMC_SR - AT91_PMC)]
5963 + tst r3, #AT91_PMC_MCKRDY
5969 + * Wait until master oscillator has stabilized.
5971 + .macro wait_moscrdy
5972 + mov r4, #MOSCRDY_TIMEOUT
5976 + ldr r3, [r1, #(AT91_PMC_SR - AT91_PMC)]
5977 + tst r3, #AT91_PMC_MOSCS
5983 + * Wait until PLLA has locked.
5985 + .macro wait_pllalock
5986 + mov r4, #PLLALOCK_TIMEOUT
5990 + ldr r3, [r1, #(AT91_PMC_SR - AT91_PMC)]
5991 + tst r3, #AT91_PMC_LOCKA
5997 + * Wait until PLLB has locked.
5999 + .macro wait_pllblock
6000 + mov r4, #PLLBLOCK_TIMEOUT
6004 + ldr r3, [r1, #(AT91_PMC_SR - AT91_PMC)]
6005 + tst r3, #AT91_PMC_LOCKB
6012 +ENTRY(at91_slow_clock)
6013 + /* Save registers on stack */
6014 + stmfd sp!, {r0 - r12, lr}
6018 + * R1 = Base address of AT91_PMC
6019 + * R2 = Base address of AT91_SDRAMC (or AT91_SYS on AT91RM9200)
6020 + * R3 = temporary register
6021 + * R4 = temporary register
6023 + ldr r1, .at91_va_base_pmc
6024 + ldr r2, .at91_va_base_sdramc
6026 + /* Drain write buffer */
6027 + mcr p15, 0, r0, c7, c10, 4
6029 +#ifdef CONFIG_ARCH_AT91RM9200
6030 + /* Put SDRAM in self-refresh mode */
6032 + str r3, [r2, #AT91_SDRAMC_SRR]
6033 +#elif defined(CONFIG_ARCH_AT91CAP9)
6034 + /* Enable SDRAM self-refresh mode */
6035 + ldr r3, [r2, #AT91_DDRSDRC_LPR - AT91_DDRSDRC]
6036 + str r3, .saved_sam9_lpr
6038 + mov r3, #AT91_DDRSDRC_LPCB_SELF_REFRESH
6039 + str r3, [r2, #AT91_DDRSDRC_LPR - AT91_DDRSDRC]
6041 + /* Enable SDRAM self-refresh mode */
6042 + ldr r3, [r2, #AT91_SDRAMC_LPR - AT91_SDRAMC]
6043 + str r3, .saved_sam9_lpr
6045 + mov r3, #AT91_SDRAMC_LPCB_SELF_REFRESH
6046 + str r3, [r2, #AT91_SDRAMC_LPR - AT91_SDRAMC]
6049 + /* Save Master clock setting */
6050 + ldr r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)]
6051 + str r3, .saved_mckr
6054 + * Set the Master clock source to slow clock
6056 + bic r3, r3, #AT91_PMC_CSS
6057 + str r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)]
6061 +#ifdef SLOWDOWN_MASTER_CLOCK
6063 + * Set the Master Clock PRES and MDIV fields.
6065 + * See AT91RM9200 errata #27 and #28 for details.
6068 + str r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)]
6073 + /* Save PLLA setting and disable it */
6074 + ldr r3, [r1, #(AT91_CKGR_PLLAR - AT91_PMC)]
6075 + str r3, .saved_pllar
6077 + mov r3, #AT91_PMC_PLLCOUNT
6078 + orr r3, r3, #(1 << 29) /* bit 29 always set */
6079 + str r3, [r1, #(AT91_CKGR_PLLAR - AT91_PMC)]
6083 + /* Save PLLB setting and disable it */
6084 + ldr r3, [r1, #(AT91_CKGR_PLLBR - AT91_PMC)]
6085 + str r3, .saved_pllbr
6087 + mov r3, #AT91_PMC_PLLCOUNT
6088 + str r3, [r1, #(AT91_CKGR_PLLBR - AT91_PMC)]
6092 + /* Turn off the main oscillator */
6093 + ldr r3, [r1, #(AT91_CKGR_MOR - AT91_PMC)]
6094 + bic r3, r3, #AT91_PMC_MOSCEN
6095 + str r3, [r1, #(AT91_CKGR_MOR - AT91_PMC)]
6097 + /* Wait for interrupt */
6098 + mcr p15, 0, r0, c7, c0, 4
6100 + /* Turn on the main oscillator */
6101 + ldr r3, [r1, #(AT91_CKGR_MOR - AT91_PMC)]
6102 + orr r3, r3, #AT91_PMC_MOSCEN
6103 + str r3, [r1, #(AT91_CKGR_MOR - AT91_PMC)]
6107 + /* Restore PLLB setting */
6108 + ldr r3, .saved_pllbr
6109 + str r3, [r1, #(AT91_CKGR_PLLBR - AT91_PMC)]
6113 + /* Restore PLLA setting */
6114 + ldr r3, .saved_pllar
6115 + str r3, [r1, #(AT91_CKGR_PLLAR - AT91_PMC)]
6119 +#ifdef SLOWDOWN_MASTER_CLOCK
6121 + * First set PRES if it was not 0,
6122 + * than set CSS and MDIV fields.
6124 + * See AT91RM9200 errata #27 and #28 for details.
6126 + ldr r3, .saved_mckr
6127 + tst r3, #AT91_PMC_PRES
6129 + and r3, r3, #AT91_PMC_PRES
6130 + str r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)]
6136 + * Restore master clock setting
6138 +2: ldr r3, .saved_mckr
6139 + str r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)]
6143 +#ifdef CONFIG_ARCH_AT91RM9200
6144 + /* Do nothing - self-refresh is automatically disabled. */
6145 +#elif defined(CONFIG_ARCH_AT91CAP9)
6146 + /* Restore LPR on AT91CAP9 */
6147 + ldr r3, .saved_sam9_lpr
6148 + str r3, [r2, #AT91_DDRSDRC_LPR - AT91_DDRSDRC]
6150 + /* Restore LPR on AT91SAM9 */
6151 + ldr r3, .saved_sam9_lpr
6152 + str r3, [r2, #AT91_SDRAMC_LPR - AT91_SDRAMC]
6155 + /* Restore registers, and return */
6156 + ldmfd sp!, {r0 - r12, pc}
6172 + .word AT91_VA_BASE_SYS + AT91_PMC
6174 +#ifdef CONFIG_ARCH_AT91RM9200
6175 +.at91_va_base_sdramc:
6176 + .word AT91_VA_BASE_SYS
6177 +#elif defined(CONFIG_ARCH_AT91CAP9)
6178 +.at91_va_base_sdramc:
6179 + .word AT91_VA_BASE_SYS + AT91_DDRSDRC
6181 +.at91_va_base_sdramc:
6182 + .word AT91_VA_BASE_SYS + AT91_SDRAMC
6185 +ENTRY(at91_slow_clock_sz)
6186 + .word .-at91_slow_clock
6187 --- a/arch/arm/mach-ks8695/Makefile
6188 +++ b/arch/arm/mach-ks8695/Makefile
6189 @@ -11,5 +11,8 @@ obj- :=
6190 # PCI support is optional
6191 obj-$(CONFIG_PCI) += pci.o
6194 +obj-$(CONFIG_LEDS) += leds.o
6196 # Board-specific support
6197 obj-$(CONFIG_MACH_KS8695) += board-micrel.o
6198 --- a/arch/arm/mach-ks8695/devices.c
6199 +++ b/arch/arm/mach-ks8695/devices.c
6200 @@ -176,6 +176,27 @@ static void __init ks8695_add_device_wat
6204 +/* --------------------------------------------------------------------
6206 + * -------------------------------------------------------------------- */
6208 +#if defined(CONFIG_LEDS)
6209 +short ks8695_leds_cpu = -1;
6210 +short ks8695_leds_timer = -1;
6212 +void __init ks8695_init_leds(u8 cpu_led, u8 timer_led)
6214 + /* Enable GPIO to access the LEDs */
6215 + gpio_direction_output(cpu_led, 1);
6216 + gpio_direction_output(timer_led, 1);
6218 + ks8695_leds_cpu = cpu_led;
6219 + ks8695_leds_timer = timer_led;
6222 +void __init ks8695_init_leds(u8 cpu_led, u8 timer_led) {}
6225 /* -------------------------------------------------------------------- */
6228 --- a/arch/arm/mach-ks8695/gpio.c
6229 +++ b/arch/arm/mach-ks8695/gpio.c
6230 @@ -136,9 +136,9 @@ int __init_or_module gpio_direction_outp
6231 /* set line state */
6232 x = __raw_readl(KS8695_GPIO_VA + KS8695_IOPD);
6239 __raw_writel(x, KS8695_GPIO_VA + KS8695_IOPD);
6241 /* set pin as output */
6242 @@ -168,9 +168,9 @@ void gpio_set_value(unsigned int pin, un
6243 /* set output line state */
6244 x = __raw_readl(KS8695_GPIO_VA + KS8695_IOPD);
6251 __raw_writel(x, KS8695_GPIO_VA + KS8695_IOPD);
6253 local_irq_restore(flags);
6254 @@ -189,7 +189,7 @@ int gpio_get_value(unsigned int pin)
6257 x = __raw_readl(KS8695_GPIO_VA + KS8695_IOPD);
6258 - return (x & (1 << pin)) != 0;
6259 + return (x & IOPD_(pin)) != 0;
6261 EXPORT_SYMBOL(gpio_get_value);
6264 +++ b/arch/arm/mach-ks8695/leds.c
6267 + * LED driver for KS8695-based boards.
6269 + * Copyright (C) Andrew Victor
6271 + * This program is free software; you can redistribute it and/or modify
6272 + * it under the terms of the GNU General Public License version 2 as
6273 + * published by the Free Software Foundation.
6276 +#include <linux/kernel.h>
6277 +#include <linux/module.h>
6278 +#include <linux/init.h>
6280 +#include <asm/mach-types.h>
6281 +#include <asm/leds.h>
6282 +#include <asm/arch/devices.h>
6283 +#include <asm/arch/gpio.h>
6286 +static inline void ks8695_led_on(unsigned int led)
6288 + gpio_set_value(led, 0);
6291 +static inline void ks8695_led_off(unsigned int led)
6293 + gpio_set_value(led, 1);
6296 +static inline void ks8695_led_toggle(unsigned int led)
6298 + unsigned long is_off = gpio_get_value(led);
6300 + ks8695_led_on(led);
6302 + ks8695_led_off(led);
6307 + * Handle LED events.
6309 +static void ks8695_leds_event(led_event_t evt)
6311 + unsigned long flags;
6313 + local_irq_save(flags);
6316 + case led_start: /* System startup */
6317 + ks8695_led_on(ks8695_leds_cpu);
6320 + case led_stop: /* System stop / suspend */
6321 + ks8695_led_off(ks8695_leds_cpu);
6324 +#ifdef CONFIG_LEDS_TIMER
6325 + case led_timer: /* Every 50 timer ticks */
6326 + ks8695_led_toggle(ks8695_leds_timer);
6330 +#ifdef CONFIG_LEDS_CPU
6331 + case led_idle_start: /* Entering idle state */
6332 + ks8695_led_off(ks8695_leds_cpu);
6335 + case led_idle_end: /* Exit idle state */
6336 + ks8695_led_on(ks8695_leds_cpu);
6344 + local_irq_restore(flags);
6348 +static int __init leds_init(void)
6350 + if ((ks8695_leds_timer == -1) || (ks8695_leds_cpu == -1))
6353 + leds_event = ks8695_leds_event;
6355 + leds_event(led_start);
6359 +__initcall(leds_init);
6360 --- a/arch/arm/mach-ks8695/pci.c
6361 +++ b/arch/arm/mach-ks8695/pci.c
6362 @@ -141,7 +141,7 @@ static struct pci_ops ks8695_pci_ops = {
6363 .write = ks8695_pci_writeconfig,
6366 -static struct pci_bus *ks8695_pci_scan_bus(int nr, struct pci_sys_data *sys)
6367 +static struct pci_bus* __init ks8695_pci_scan_bus(int nr, struct pci_sys_data *sys)
6369 return pci_scan_bus(sys->busnr, &ks8695_pci_ops, sys);
6371 --- a/drivers/char/Kconfig
6372 +++ b/drivers/char/Kconfig
6373 @@ -1056,5 +1056,21 @@ config DEVPORT
6375 source "drivers/s390/char/Kconfig"
6378 + bool "SPI driver (legacy) for AT91RM9200 processors"
6379 + depends on ARCH_AT91RM9200
6382 + The SPI driver gives access to this serial bus on the AT91RM9200
6386 + bool "SPI device interface (legacy) for AT91RM9200 processors"
6387 + depends on ARCH_AT91RM9200 && AT91_SPI
6390 + The SPI driver gives user mode access to this serial
6391 + bus on the AT91RM9200 processor.
6395 --- a/drivers/char/Makefile
6396 +++ b/drivers/char/Makefile
6397 @@ -98,6 +98,8 @@ obj-$(CONFIG_GPIO_DEVICE) += gpio_dev.o
6398 obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o
6399 obj-$(CONFIG_GPIO_TB0219) += tb0219.o
6400 obj-$(CONFIG_TELCLOCK) += tlclk.o
6401 +obj-$(CONFIG_AT91_SPI) += at91_spi.o
6402 +obj-$(CONFIG_AT91_SPIDEV) += at91_spidev.o
6404 obj-$(CONFIG_MWAVE) += mwave/
6405 obj-$(CONFIG_AGP) += agp/
6407 +++ b/drivers/char/at91_spi.c
6410 + * Serial Peripheral Interface (SPI) driver for the Atmel AT91RM9200 (Thunder)
6412 + * Copyright (C) SAN People (Pty) Ltd
6414 + * This program is free software; you can redistribute it and/or
6415 + * modify it under the terms of the GNU General Public License
6416 + * as published by the Free Software Foundation; either version
6417 + * 2 of the License, or (at your option) any later version.
6420 +#include <linux/init.h>
6421 +#include <linux/dma-mapping.h>
6422 +#include <linux/module.h>
6423 +#include <linux/sched.h>
6424 +#include <linux/completion.h>
6425 +#include <linux/interrupt.h>
6426 +#include <linux/clk.h>
6427 +#include <linux/platform_device.h>
6428 +#include <linux/atmel_pdc.h>
6429 +#include <asm/io.h>
6430 +#include <asm/semaphore.h>
6432 +#include <asm/arch/at91_spi.h>
6433 +#include <asm/arch/board.h>
6434 +#include <asm/arch/spi.h>
6438 +static struct spi_local spi_dev[NR_SPI_DEVICES]; /* state of the SPI devices */
6439 +static int spi_enabled = 0;
6440 +static struct semaphore spi_lock; /* protect access to SPI bus */
6441 +static int current_device = -1; /* currently selected SPI device */
6442 +static struct clk *spi_clk; /* SPI clock */
6443 +static void __iomem *spi_base; /* SPI peripheral base-address */
6445 +DECLARE_COMPLETION(transfer_complete);
6448 +#define at91_spi_read(reg) __raw_readl(spi_base + (reg))
6449 +#define at91_spi_write(reg, val) __raw_writel((val), spi_base + (reg))
6452 +/* ......................................................................... */
6455 + * Access and enable the SPI bus.
6456 + * This MUST be called before any transfers are performed.
6458 +void spi_access_bus(short device)
6460 + /* Ensure that requested device is valid */
6461 + if ((device < 0) || (device >= NR_SPI_DEVICES))
6462 + panic("at91_spi: spi_access_bus called with invalid device");
6464 + if (spi_enabled == 0) {
6465 + clk_enable(spi_clk); /* Enable Peripheral clock */
6466 + at91_spi_write(AT91_SPI_CR, AT91_SPI_SPIEN); /* Enable SPI */
6468 + printk("SPI on\n");
6473 + /* Lock the SPI bus */
6475 + current_device = device;
6477 + /* Configure SPI bus for device */
6478 + at91_spi_write(AT91_SPI_MR, AT91_SPI_MSTR | AT91_SPI_MODFDIS | (spi_dev[device].pcs << 16));
6482 + * Relinquish control of the SPI bus.
6484 +void spi_release_bus(short device)
6486 + if (device != current_device)
6487 + panic("at91_spi: spi_release called with invalid device");
6489 + /* Release the SPI bus */
6490 + current_device = -1;
6494 + if (spi_enabled == 0) {
6495 + at91_spi_write(AT91_SPI_CR, AT91_SPI_SPIDIS); /* Disable SPI */
6496 + clk_disable(spi_clk); /* Disable Peripheral clock */
6498 + printk("SPI off\n");
6504 + * Perform a data transfer over the SPI bus
6506 +int spi_transfer(struct spi_transfer_list* list)
6508 + struct spi_local *device = (struct spi_local *) &spi_dev[current_device];
6512 + panic("at91_spi: spi_transfer called with NULL transfer list");
6513 + if (current_device == -1)
6514 + panic("at91_spi: spi_transfer called without acquiring bus");
6517 + printk("SPI transfer start [%i]\n", list->nr_transfers);
6520 + /* If we are in 16-bit mode, we need to modify what we pass to the PDC */
6521 + tx_size = (at91_spi_read(AT91_SPI_CSR(current_device)) & AT91_SPI_BITS_16) ? 2 : 1;
6523 + /* Store transfer list */
6524 + device->xfers = list;
6527 + /* Assume there must be at least one transfer */
6528 + device->tx = dma_map_single(NULL, list->tx[0], list->txlen[0], DMA_TO_DEVICE);
6529 + device->rx = dma_map_single(NULL, list->rx[0], list->rxlen[0], DMA_FROM_DEVICE);
6531 + /* Program PDC registers */
6532 + at91_spi_write(ATMEL_PDC_TPR, device->tx);
6533 + at91_spi_write(ATMEL_PDC_RPR, device->rx);
6534 + at91_spi_write(ATMEL_PDC_TCR, list->txlen[0] / tx_size);
6535 + at91_spi_write(ATMEL_PDC_RCR, list->rxlen[0] / tx_size);
6537 + /* Is there a second transfer? */
6538 + if (list->nr_transfers > 1) {
6539 + device->txnext = dma_map_single(NULL, list->tx[1], list->txlen[1], DMA_TO_DEVICE);
6540 + device->rxnext = dma_map_single(NULL, list->rx[1], list->rxlen[1], DMA_FROM_DEVICE);
6542 + /* Program Next PDC registers */
6543 + at91_spi_write(ATMEL_PDC_TNPR, device->txnext);
6544 + at91_spi_write(ATMEL_PDC_RNPR, device->rxnext);
6545 + at91_spi_write(ATMEL_PDC_TNCR, list->txlen[1] / tx_size);
6546 + at91_spi_write(ATMEL_PDC_RNCR, list->rxlen[1] / tx_size);
6549 + device->txnext = 0;
6550 + device->rxnext = 0;
6551 + at91_spi_write(ATMEL_PDC_TNCR, 0);
6552 + at91_spi_write(ATMEL_PDC_RNCR, 0);
6555 + // TODO: If we are doing consecutive transfers (at high speed, or
6556 + // small buffers), then it might be worth modifying the 'Delay between
6557 + // Consecutive Transfers' in the CSR registers.
6558 + // This is an issue if we cannot chain the next buffer fast enough
6559 + // in the interrupt handler.
6561 + /* Enable transmitter and receiver */
6562 + at91_spi_write(ATMEL_PDC_PTCR, ATMEL_PDC_RXTEN | ATMEL_PDC_TXTEN);
6564 + at91_spi_write(AT91_SPI_IER, AT91_SPI_ENDRX); /* enable buffer complete interrupt */
6565 + wait_for_completion(&transfer_complete);
6568 + printk("SPI transfer end\n");
6574 +/* ......................................................................... */
6577 + * Handle interrupts from the SPI controller.
6579 +static irqreturn_t at91spi_interrupt(int irq, void *dev_id)
6581 + unsigned int status;
6582 + struct spi_local *device = (struct spi_local *) &spi_dev[current_device];
6583 + struct spi_transfer_list *list = device->xfers;
6586 + printk("SPI interrupt %i\n", current_device);
6590 + panic("at91_spi: spi_interrupt with a NULL transfer list");
6592 + status = at91_spi_read(AT91_SPI_SR) & at91_spi_read(AT91_SPI_IMR); /* read status */
6594 + dma_unmap_single(NULL, device->tx, list->txlen[list->curr], DMA_TO_DEVICE);
6595 + dma_unmap_single(NULL, device->rx, list->rxlen[list->curr], DMA_FROM_DEVICE);
6597 + device->tx = device->txnext; /* move next transfer to current transfer */
6598 + device->rx = device->rxnext;
6600 + list->curr = list->curr + 1;
6601 + if (list->curr == list->nr_transfers) { /* all transfers complete */
6602 + at91_spi_write(AT91_SPI_IDR, AT91_SPI_ENDRX); /* disable interrupt */
6604 + /* Disable transmitter and receiver */
6605 + at91_spi_write(ATMEL_PDC_PTCR, ATMEL_PDC_RXTDIS | ATMEL_PDC_TXTDIS);
6607 + device->xfers = NULL;
6608 + complete(&transfer_complete);
6610 + else if (list->curr+1 == list->nr_transfers) { /* no more next transfers */
6611 + device->txnext = 0;
6612 + device->rxnext = 0;
6613 + at91_spi_write(ATMEL_PDC_TNCR, 0);
6614 + at91_spi_write(ATMEL_PDC_RNCR, 0);
6617 + int i = (list->curr)+1;
6619 + /* If we are in 16-bit mode, we need to modify what we pass to the PDC */
6620 + int tx_size = (at91_spi_read(AT91_SPI_CSR(current_device)) & AT91_SPI_BITS_16) ? 2 : 1;
6622 + device->txnext = dma_map_single(NULL, list->tx[i], list->txlen[i], DMA_TO_DEVICE);
6623 + device->rxnext = dma_map_single(NULL, list->rx[i], list->rxlen[i], DMA_FROM_DEVICE);
6624 + at91_spi_write(ATMEL_PDC_TNPR, device->txnext);
6625 + at91_spi_write(ATMEL_PDC_RNPR, device->rxnext);
6626 + at91_spi_write(ATMEL_PDC_TNCR, list->txlen[i] / tx_size);
6627 + at91_spi_write(ATMEL_PDC_RNCR, list->rxlen[i] / tx_size);
6629 + return IRQ_HANDLED;
6632 +/* ......................................................................... */
6635 + * Initialize the SPI controller
6637 +static int __init at91spi_probe(struct platform_device *pdev)
6640 + unsigned long scbr;
6641 + struct resource *res;
6643 + init_MUTEX(&spi_lock);
6645 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
6649 + if (!request_mem_region(res->start, res->end - res->start + 1, "at91_spi"))
6652 + spi_base = ioremap(res->start, res->end - res->start + 1);
6654 + release_mem_region(res->start, res->end - res->start + 1);
6658 + spi_clk = clk_get(NULL, "spi_clk");
6659 + if (IS_ERR(spi_clk)) {
6660 + printk(KERN_ERR "at91_spi: no clock defined\n");
6661 + iounmap(spi_base);
6662 + release_mem_region(res->start, res->end - res->start + 1);
6666 + at91_spi_write(AT91_SPI_CR, AT91_SPI_SWRST); /* software reset of SPI controller */
6669 + * Calculate the correct SPI baud-rate divisor.
6671 + scbr = clk_get_rate(spi_clk) / (2 * DEFAULT_SPI_CLK);
6672 + scbr = scbr + 1; /* round up */
6674 + printk(KERN_INFO "at91_spi: Baud rate set to %ld\n", clk_get_rate(spi_clk) / (2 * scbr));
6676 + /* Set Chip Select registers to good defaults */
6677 + for (i = 0; i < 4; i++) {
6678 + at91_spi_write(AT91_SPI_CSR(i), AT91_SPI_CPOL | AT91_SPI_BITS_8 | (16 << 16) | (scbr << 8));
6681 + at91_spi_write(ATMEL_PDC_PTCR, ATMEL_PDC_RXTDIS | ATMEL_PDC_TXTDIS);
6683 + memset(&spi_dev, 0, sizeof(spi_dev));
6684 + spi_dev[0].pcs = 0xE;
6685 + spi_dev[1].pcs = 0xD;
6686 + spi_dev[2].pcs = 0xB;
6687 + spi_dev[3].pcs = 0x7;
6689 + if (request_irq(AT91RM9200_ID_SPI, at91spi_interrupt, 0, "spi", NULL)) {
6691 + iounmap(spi_base);
6692 + release_mem_region(res->start, res->end - res->start + 1);
6696 + at91_spi_write(AT91_SPI_CR, AT91_SPI_SPIEN); /* Enable SPI */
6701 +static int __devexit at91spi_remove(struct platform_device *pdev)
6703 + struct resource *res;
6705 + at91_spi_write(AT91_SPI_CR, AT91_SPI_SPIDIS); /* Disable SPI */
6708 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
6709 + iounmap(spi_base);
6710 + release_mem_region(res->start, res->end - res->start + 1);
6712 + free_irq(AT91RM9200_ID_SPI, 0);
6716 +static struct platform_driver at91spi_driver = {
6717 + .probe = at91spi_probe,
6718 + .remove = __devexit_p(at91spi_remove),
6720 + .name = "at91_spi",
6721 + .owner = THIS_MODULE,
6725 +static int __init at91spi_init(void)
6727 + return platform_driver_register(&at91spi_driver);
6730 +static void __exit at91spi_exit(void)
6732 + platform_driver_unregister(&at91spi_driver);
6735 +EXPORT_SYMBOL(spi_access_bus);
6736 +EXPORT_SYMBOL(spi_release_bus);
6737 +EXPORT_SYMBOL(spi_transfer);
6739 +module_init(at91spi_init);
6740 +module_exit(at91spi_exit);
6742 +MODULE_LICENSE("GPL")
6743 +MODULE_AUTHOR("Andrew Victor")
6744 +MODULE_DESCRIPTION("SPI driver for Atmel AT91RM9200")
6745 +MODULE_ALIAS("platform:at91_spi");
6747 +++ b/drivers/char/at91_spidev.c
6750 + * User-space interface to the SPI bus on Atmel AT91RM9200
6752 + * Copyright (C) 2003 SAN People (Pty) Ltd
6754 + * Based on SPI driver by Rick Bronson
6756 + * This program is free software; you can redistribute it and/or
6757 + * modify it under the terms of the GNU General Public License
6758 + * as published by the Free Software Foundation; either version
6759 + * 2 of the License, or (at your option) any later version.
6762 +#include <linux/module.h>
6763 +#include <linux/init.h>
6764 +#include <linux/slab.h>
6765 +#include <linux/highmem.h>
6766 +#include <linux/pagemap.h>
6767 +#include <asm/arch/spi.h>
6769 +#ifdef CONFIG_DEVFS_FS
6770 +#include <linux/devfs_fs_kernel.h>
6774 +#undef DEBUG_SPIDEV
6776 +/* ......................................................................... */
6779 + * Read or Write to SPI bus.
6781 +static ssize_t spidev_rd_wr(struct file *file, char *buf, size_t count, loff_t *offset)
6783 + unsigned int spi_device = (unsigned int) file->private_data;
6785 + struct mm_struct * mm;
6786 + struct page ** maplist;
6787 + struct spi_transfer_list* list;
6790 + unsigned int ofs, pagelen;
6797 + list = kmalloc(sizeof(struct spi_transfer_list), GFP_KERNEL);
6804 + pgcount = ((unsigned long)buf+count+PAGE_SIZE-1)/PAGE_SIZE - (unsigned long)buf/PAGE_SIZE;
6806 + if (pgcount >= MAX_SPI_TRANSFERS) {
6811 + maplist = kmalloc (pgcount * sizeof (struct page *), GFP_KERNEL);
6817 + flush_cache_all();
6818 + down_read(&mm->mmap_sem);
6819 + err= get_user_pages(current, mm, (unsigned long)buf, pgcount, 1, 0, maplist, NULL);
6820 + up_read(&mm->mmap_sem);
6829 +#ifdef DEBUG_SPIDEV
6830 + printk("spidev_rd_rw: %i %i\n", count, pgcount);
6833 + /* Set default return value = transfer length */
6837 + * At this point, the virtual area buf[0] .. buf[count-1] will have
6838 + * corresponding pages mapped in the physical memory and locked until
6839 + * we unmap the kiobuf. The pages cannot be swapped out or moved
6842 + ofs = (unsigned long) buf & (PAGE_SIZE -1);
6843 + pagelen = PAGE_SIZE - ofs;
6844 + if (count < pagelen)
6847 + for (i = 0; i < pgcount; i++) {
6848 + flush_dcache_page(maplist[i]);
6850 + list->tx[i] = list->rx[i] = page_address(maplist[i]) + ofs;
6851 + list->txlen[i] = list->rxlen[i] = pagelen;
6853 +#ifdef DEBUG_SPIDEV
6854 + printk(" %i: %x (%i)\n", i, list->tx[i], list->txlen[i]);
6857 + ofs = 0; /* all subsequent transfers start at beginning of a page */
6858 + count = count - pagelen;
6859 + pagelen = (count < PAGE_SIZE) ? count : PAGE_SIZE;
6861 + list->nr_transfers = pgcount;
6863 + /* Perform transfer on SPI bus */
6864 + spi_access_bus(spi_device);
6865 + spi_transfer(list);
6866 + spi_release_bus(spi_device);
6868 + while (pgcount--) {
6869 + page_cache_release (maplist[pgcount]);
6871 + flush_cache_all();
6879 +static int spidev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
6881 + int spi_device = MINOR(inode->i_rdev);
6883 + if (spi_device >= NR_SPI_DEVICES)
6886 + // TODO: This interface can be used to configure the SPI bus.
6887 + // Configurable options could include: Speed, Clock Polarity, Clock Phase
6891 + return -ENOIOCTLCMD;
6896 + * Open the SPI device
6898 +static int spidev_open(struct inode *inode, struct file *file)
6900 + unsigned int spi_device = MINOR(inode->i_rdev);
6902 + if (spi_device >= NR_SPI_DEVICES)
6906 + * 'private_data' is actually a pointer, but we overload it with the
6907 + * value we want to store.
6909 + file->private_data = (void *)spi_device;
6915 + * Close the SPI device
6917 +static int spidev_close(struct inode *inode, struct file *file)
6922 +/* ......................................................................... */
6924 +static struct file_operations spidev_fops = {
6925 + .owner = THIS_MODULE,
6926 + .llseek = no_llseek,
6927 + .read = spidev_rd_wr,
6928 + .write = (int (*) (struct file *file, const char *buf, size_t count, loff_t *offset))spidev_rd_wr,
6929 + .ioctl = spidev_ioctl,
6930 + .open = spidev_open,
6931 + .release = spidev_close,
6935 + * Install the SPI /dev interface driver
6937 +static int __init at91_spidev_init(void)
6939 +#ifdef CONFIG_DEVFS_FS
6943 + if (register_chrdev(SPI_MAJOR, "spi", &spidev_fops)) {
6944 + printk(KERN_ERR "at91_spidev: Unable to get major %d for SPI bus\n", SPI_MAJOR);
6948 +#ifdef CONFIG_DEVFS_FS
6949 + devfs_mk_dir("spi");
6950 + for (i = 0; i < NR_SPI_DEVICES; i++) {
6951 + devfs_mk_cdev(MKDEV(SPI_MAJOR, i), S_IFCHR | S_IRUSR | S_IWUSR, "spi/%d",i);
6954 + printk(KERN_INFO "AT91 SPI driver loaded\n");
6960 + * Remove the SPI /dev interface driver
6962 +static void __exit at91_spidev_exit(void)
6964 +#ifdef CONFIG_DEVFS_FS
6966 + for (i = 0; i < NR_SPI_DEVICES; i++) {
6967 + devfs_remove("spi/%d", i);
6970 + devfs_remove("spi");
6973 + unregister_chrdev(SPI_MAJOR, "spi");
6976 +module_init(at91_spidev_init);
6977 +module_exit(at91_spidev_exit);
6979 +MODULE_LICENSE("GPL")
6980 +MODULE_AUTHOR("Andrew Victor")
6981 +MODULE_DESCRIPTION("SPI /dev interface for Atmel AT91RM9200")
6982 --- a/drivers/i2c/busses/Kconfig
6983 +++ b/drivers/i2c/busses/Kconfig
6984 @@ -88,6 +88,14 @@ config I2C_AT91
6985 to support combined I2C messages. Use the i2c-gpio driver
6986 unless your system can cope with those limitations.
6988 +config I2C_AT91_CLOCKRATE
6989 + prompt "Atmel AT91 I2C/TWI clock-rate"
6990 + depends on I2C_AT91
6994 + Set the AT91 I2C/TWI clock-rate.
6997 tristate "Au1550/Au1200 SMBus interface"
6998 depends on SOC_AU1550 || SOC_AU1200
6999 @@ -626,6 +634,14 @@ config I2C_VOODOO3
7000 This driver can also be built as a module. If so, the module
7001 will be called i2c-voodoo3.
7004 + tristate "PCA9564"
7006 + select I2C_ALGOPCA
7008 + This driver support the Philips PCA 9564 Parallel bus to I2C
7012 tristate "PCA9564 on an ISA bus"
7014 --- a/drivers/i2c/busses/Makefile
7015 +++ b/drivers/i2c/busses/Makefile
7016 @@ -29,6 +29,7 @@ obj-$(CONFIG_I2C_OMAP) += i2c-omap.o
7017 obj-$(CONFIG_I2C_PARPORT) += i2c-parport.o
7018 obj-$(CONFIG_I2C_PARPORT_LIGHT) += i2c-parport-light.o
7019 obj-$(CONFIG_I2C_PASEMI) += i2c-pasemi.o
7020 +obj-$(CONFIG_I2C_PCA) += i2c-pca.o
7021 obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o
7022 obj-$(CONFIG_I2C_PIIX4) += i2c-piix4.o
7023 obj-$(CONFIG_I2C_PMCMSP) += i2c-pmcmsp.o
7024 --- a/drivers/i2c/busses/i2c-at91.c
7025 +++ b/drivers/i2c/busses/i2c-at91.c
7027 #include <asm/arch/board.h>
7028 #include <asm/arch/cpu.h>
7030 -#define TWI_CLOCK 100000 /* Hz. max 400 Kbits/sec */
7032 +/* Clockrate is configurable - max 400 Kbits/sec */
7033 +static unsigned int clockrate = CONFIG_I2C_AT91_CLOCKRATE;
7034 +module_param(clockrate, uint, 0);
7035 +MODULE_PARM_DESC(clockrate, "The TWI clockrate");
7037 static struct clk *twi_clk;
7038 static void __iomem *twi_base;
7039 @@ -53,7 +56,7 @@ static void __devinit at91_twi_hwinit(vo
7040 at91_twi_write(AT91_TWI_CR, AT91_TWI_MSEN); /* Set Master mode */
7042 /* Calcuate clock dividers */
7043 - cdiv = (clk_get_rate(twi_clk) / (2 * TWI_CLOCK)) - 3;
7044 + cdiv = (clk_get_rate(twi_clk) / (2 * clockrate)) - 3;
7045 cdiv = cdiv + 1; /* round up */
7047 while (cdiv > 255) {
7048 @@ -61,11 +64,12 @@ static void __devinit at91_twi_hwinit(vo
7052 - if (cpu_is_at91rm9200()) { /* AT91RM9200 Errata #22 */
7054 - printk(KERN_ERR "AT91 I2C: Invalid TWI_CLOCK value!\n");
7057 + if (cpu_is_at91rm9200() && (ckdiv > 5)) { /* AT91RM9200 Errata #22 */
7058 + printk(KERN_ERR "AT91 I2C: Invalid TWI clockrate!\n");
7060 + } else if (ckdiv > 7) {
7061 + printk(KERN_ERR "AT91 I2C: Invalid TWI clockrate!\n");
7065 at91_twi_write(AT91_TWI_CWGR, (ckdiv << 16) | (cdiv << 8) | cdiv);
7067 +++ b/drivers/i2c/busses/i2c-pca.c
7070 + * Platform driver for PCA9564 I2C bus controller.
7072 + * (C) 2006 Andrew Victor
7074 + * Based on i2c-pca-isa.c driver for PCA9564 on ISA boards
7075 + * Copyright (C) 2004 Arcom Control Systems
7077 + * This program is free software; you can redistribute it and/or modify
7078 + * it under the terms of the GNU General Public License as published by
7079 + * the Free Software Foundation; either version 2 of the License, or
7080 + * (at your option) any later version.
7082 + * This program is distributed in the hope that it will be useful,
7083 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
7084 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7085 + * GNU General Public License for more details.
7087 + * You should have received a copy of the GNU General Public License
7088 + * along with this program; if not, write to the Free Software
7089 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
7092 +#include <linux/kernel.h>
7093 +#include <linux/module.h>
7094 +#include <linux/moduleparam.h>
7095 +#include <linux/delay.h>
7096 +#include <linux/init.h>
7097 +#include <linux/interrupt.h>
7098 +#include <linux/wait.h>
7099 +#include <linux/platform_device.h>
7101 +#include <linux/i2c.h>
7102 +#include <linux/i2c-algo-pca.h>
7104 +#include <asm/io.h>
7106 +#include "../algos/i2c-algo-pca.h"
7108 +#define PCA_OWN_ADDRESS 0x55 /* our address for slave mode */
7109 +#define PCA_CLOCK I2C_PCA_CON_59kHz
7111 +//#define REG_SHIFT 2
7112 +#define REG_SHIFT 0
7116 +#define PCA_IO_SIZE 4
7118 +static void __iomem *base_addr;
7120 +static wait_queue_head_t pca_wait;
7122 +static int pca_getown(struct i2c_algo_pca_data *adap)
7124 + return PCA_OWN_ADDRESS;
7127 +static int pca_getclock(struct i2c_algo_pca_data *adap)
7132 +static void pca_writebyte(struct i2c_algo_pca_data *adap, int reg, int val)
7135 + static char *names[] = { "T/O", "DAT", "ADR", "CON" };
7136 + printk("*** write %s at %#lx <= %#04x\n", names[reg], (unsigned long) base_addr+reg, val);
7139 + outb(val, base_addr + (reg << REG_SHIFT));
7142 +static int pca_readbyte(struct i2c_algo_pca_data *adap, int reg)
7147 + res = inb(base_addr + (reg << REG_SHIFT));
7150 + static char *names[] = { "STA", "DAT", "ADR", "CON" };
7151 + printk("*** read %s => %#04x\n", names[reg], res);
7157 +static int pca_waitforinterrupt(struct i2c_algo_pca_data *adap)
7162 + ret = wait_event_interruptible(pca_wait,
7163 + pca_readbyte(adap, I2C_PCA_CON) & I2C_PCA_CON_SI);
7165 + while ((pca_readbyte(adap, I2C_PCA_CON) & I2C_PCA_CON_SI) == 0)
7171 +static irqreturn_t pca_handler(int this_irq, void *dev_id)
7173 + wake_up_interruptible(&pca_wait);
7174 + return IRQ_HANDLED;
7177 +static struct i2c_algo_pca_data pca_i2c_data = {
7178 + .get_own = pca_getown,
7179 + .get_clock = pca_getclock,
7180 + .write_byte = pca_writebyte,
7181 + .read_byte = pca_readbyte,
7182 + .wait_for_interrupt = pca_waitforinterrupt,
7185 +static struct i2c_adapter pca_i2c_ops = {
7186 + .owner = THIS_MODULE,
7187 + .id = I2C_HW_A_PLAT,
7188 + .algo_data = &pca_i2c_data,
7189 + .name = "PCA9564",
7190 + .class = I2C_CLASS_HWMON,
7193 +static int __devinit pca_i2c_probe(struct platform_device *pdev)
7195 + struct resource *res;
7197 + init_waitqueue_head(&pca_wait);
7199 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
7203 + if (!request_mem_region(res->start, PCA_IO_SIZE, "PCA9564"))
7206 + base_addr = ioremap(res->start, PCA_IO_SIZE);
7207 + if (base_addr == NULL)
7210 + irq = platform_get_irq(pdev, 0);
7212 + if (request_irq(irq, pca_handler, 0, "pca9564", NULL) < 0) {
7213 + printk(KERN_ERR "i2c-pca: Request irq%d failed\n", irq);
7218 + /* set up the driverfs linkage to our parent device */
7219 + pca_i2c_ops.dev.parent = &pdev->dev;
7221 + if (i2c_pca_add_bus(&pca_i2c_ops) < 0) {
7222 + printk(KERN_ERR "i2c-pca: Failed to add i2c bus\n");
7230 + free_irq(irq, &pca_i2c_ops);
7233 + iounmap(base_addr);
7236 + release_mem_region(res->start, PCA_IO_SIZE);
7240 +static int __devexit pca_i2c_remove(struct platform_device *pdev)
7242 + struct resource *res;
7244 + i2c_del_adapter(&pca_i2c_ops);
7247 + free_irq(irq, NULL);
7249 + iounmap(base_addr);
7251 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
7252 + release_mem_region(res->start, PCA_IO_SIZE);
7257 +static struct platform_driver pca_i2c_driver = {
7258 + .probe = pca_i2c_probe,
7259 + .remove = __devexit_p(pca_i2c_remove),
7261 + .name = "pca9564",
7262 + .owner = THIS_MODULE,
7266 +static int __init pca_i2c_init(void)
7268 + return platform_driver_register(&pca_i2c_driver);
7271 +static void __exit pca_i2c_exit(void)
7273 + platform_driver_unregister(&pca_i2c_driver);
7276 +module_init(pca_i2c_init);
7277 +module_exit(pca_i2c_exit);
7279 +MODULE_AUTHOR("Andrew Victor");
7280 +MODULE_DESCRIPTION("PCA9564 platform driver");
7281 +MODULE_LICENSE("GPL");
7282 --- a/drivers/mmc/host/at91_mci.c
7283 +++ b/drivers/mmc/host/at91_mci.c
7284 @@ -659,13 +659,14 @@ static void at91_mci_set_ios(struct mmc_
7285 /* maybe switch power to the card */
7286 if (host->board->vcc_pin) {
7287 switch (ios->power_mode) {
7288 - case MMC_POWER_OFF:
7289 - gpio_set_value(host->board->vcc_pin, 0);
7291 - case MMC_POWER_UP:
7292 - case MMC_POWER_ON:
7293 - gpio_set_value(host->board->vcc_pin, 1);
7295 + case MMC_POWER_OFF:
7296 + gpio_set_value(host->board->vcc_pin, 0);
7298 + case MMC_POWER_UP:
7299 + gpio_set_value(host->board->vcc_pin, 1);
7306 --- a/drivers/mtd/devices/Kconfig
7307 +++ b/drivers/mtd/devices/Kconfig
7308 @@ -270,5 +270,17 @@ config MTD_DOCPROBE_55AA
7309 LinuxBIOS or if you need to recover a DiskOnChip Millennium on which
7310 you have managed to wipe the first block.
7313 +config MTD_AT91_DATAFLASH
7314 + tristate "AT91RM9200 DataFlash AT45DBxxx (legacy driver)"
7315 + depends on MTD && ARCH_AT91RM9200 && AT91_SPI
7317 + This enables access to the DataFlash (AT45DBxxx) on the AT91RM9200.
7318 + If you have such a board, say 'Y'.
7320 +config DATAFLASH_ALWAYS_ADD_DEVICE
7321 + bool "Register whole DataFlash device"
7322 + depends on MTD_AT91_DATAFLASH
7324 + Always add the whole DataFlash device when using MTD partitions.
7327 --- a/drivers/mtd/devices/Makefile
7328 +++ b/drivers/mtd/devices/Makefile
7329 @@ -17,3 +17,4 @@ obj-$(CONFIG_MTD_LART) += lart.o
7330 obj-$(CONFIG_MTD_BLOCK2MTD) += block2mtd.o
7331 obj-$(CONFIG_MTD_DATAFLASH) += mtd_dataflash.o
7332 obj-$(CONFIG_MTD_M25P80) += m25p80.o
7333 +obj-$(CONFIG_MTD_AT91_DATAFLASH)+= at91_dataflash.o
7335 +++ b/drivers/mtd/devices/at91_dataflash.c
7338 + * Atmel DataFlash driver for Atmel AT91RM9200 (Thunder)
7340 + * Copyright (C) SAN People (Pty) Ltd
7342 + * This program is free software; you can redistribute it and/or
7343 + * modify it under the terms of the GNU General Public License
7344 + * as published by the Free Software Foundation; either version
7345 + * 2 of the License, or (at your option) any later version.
7348 +#include <linux/module.h>
7349 +#include <linux/init.h>
7350 +#include <linux/slab.h>
7351 +#include <linux/pci.h>
7352 +#include <linux/mtd/mtd.h>
7353 +#include <linux/mtd/partitions.h>
7355 +#include <asm/mach-types.h>
7357 +#include <asm/arch/spi.h>
7360 +#undef DEBUG_DATAFLASH
7362 +#define DATAFLASH_MAX_DEVICES 4 /* max number of dataflash devices */
7364 +#define OP_READ_CONTINUOUS 0xE8
7365 +#define OP_READ_PAGE 0xD2
7366 +#define OP_READ_BUFFER1 0xD4
7367 +#define OP_READ_BUFFER2 0xD6
7368 +#define OP_READ_STATUS 0xD7
7370 +#define OP_ERASE_PAGE 0x81
7371 +#define OP_ERASE_BLOCK 0x50
7373 +#define OP_TRANSFER_BUF1 0x53
7374 +#define OP_TRANSFER_BUF2 0x55
7375 +#define OP_COMPARE_BUF1 0x60
7376 +#define OP_COMPARE_BUF2 0x61
7378 +#define OP_PROGRAM_VIA_BUF1 0x82
7379 +#define OP_PROGRAM_VIA_BUF2 0x85
7381 +struct dataflash_local
7383 + int spi; /* SPI chip-select number */
7385 + unsigned int page_size; /* number of bytes per page */
7386 + unsigned short page_offset; /* page offset in flash address */
7390 +/* Detected DataFlash devices */
7391 +static struct mtd_info* mtd_devices[DATAFLASH_MAX_DEVICES];
7392 +static int nr_devices = 0;
7394 +/* ......................................................................... */
7396 +#ifdef CONFIG_MTD_PARTITIONS
7398 +static struct mtd_partition static_partitions_2M[] =
7401 + .name = "bootloader",
7403 + .size = 1 * 32 * 8 * 528, /* 1st sector = 32 blocks * 8 pages * 528 bytes */
7404 + .mask_flags = MTD_WRITEABLE, /* read-only */
7408 + .offset = MTDPART_OFS_NXTBLK,
7409 + .size = 6 * 32 * 8 * 528, /* 6 sectors */
7412 + .name = "filesystem",
7413 + .offset = MTDPART_OFS_NXTBLK,
7414 + .size = MTDPART_SIZ_FULL, /* rest = 9 sectors */
7418 +static struct mtd_partition static_partitions_4M[] =
7421 + .name = "bootloader",
7423 + .size = 1 * 64 * 8 * 528, /* 1st sector = 64 blocks * 8 pages * 528 bytes */
7424 + .mask_flags = MTD_WRITEABLE, /* read-only */
7428 + .offset = MTDPART_OFS_NXTBLK,
7429 + .size = 4 * 64 * 8 * 528, /* 4 sectors */
7432 + .name = "filesystem",
7433 + .offset = MTDPART_OFS_NXTBLK,
7434 + .size = MTDPART_SIZ_FULL, /* rest = 11 sectors */
7438 +#if defined(CONFIG_MACH_KAFA)
7439 +static struct mtd_partition static_partitions_8M[] =
7444 + size: 16 * 1056, /* 160 Kb */
7445 + mask_flags: MTD_WRITEABLE, /* read-only */
7449 + offset: MTDPART_OFS_APPEND, /* Sperry, NXTBLK is broken */
7450 + size: 128 * 1056, /* 1 MB */
7454 + offset: MTDPART_OFS_APPEND, /* Sperry, NXTBLK is broken */
7455 + size: 1024 * 1056, /* 1 MB */
7458 + name: "filesystem",
7459 + offset: MTDPART_OFS_APPEND, /* Sperry, NXTBLK is broken */
7460 + size: MTDPART_SIZ_FULL,
7464 +#elif defined(CONFIG_MACH_MULTMDP)
7466 +static struct mtd_partition static_partitions_8M[] =
7469 + .name = "bootloader",
7471 + .size = 12 * 1056, /* 1st sector = 32 blocks * 8 pages * 1056 bytes */
7472 + .mask_flags = MTD_WRITEABLE, /* read-only */
7475 + .name = "configuration",
7476 + .offset = MTDPART_OFS_NXTBLK,
7477 + .size = 20 * 1056,
7481 + .offset = MTDPART_OFS_NXTBLK,
7482 + .size = 1520 * 1056,
7485 + .name = "filesystem",
7486 + .offset = MTDPART_OFS_NXTBLK,
7487 + .size = MTDPART_SIZ_FULL,
7493 +static struct mtd_partition static_partitions_8M[] =
7496 + .name = "bootloader",
7498 + .size = 1 * 32 * 8 * 1056, /* 1st sector = 32 blocks * 8 pages * 1056 bytes */
7499 + .mask_flags = MTD_WRITEABLE, /* read-only */
7503 + .offset = MTDPART_OFS_NXTBLK,
7504 + .size = 5 * 32 * 8 * 1056, /* 5 sectors */
7507 + .name = "filesystem",
7508 + .offset = MTDPART_OFS_NXTBLK,
7509 + .size = MTDPART_SIZ_FULL, /* rest = 26 sectors */
7514 +static const char *part_probes[] = { "cmdlinepart", NULL, };
7518 +/* ......................................................................... */
7520 +/* Allocate a single SPI transfer descriptor. We're assuming that if multiple
7521 + SPI transfers occur at the same time, spi_access_bus() will serialize them.
7522 + If this is not valid, then either (i) each dataflash 'priv' structure
7523 + needs it's own transfer descriptor, (ii) we lock this one, or (iii) use
7524 + another mechanism. */
7525 +static struct spi_transfer_list* spi_transfer_desc;
7528 + * Perform a SPI transfer to access the DataFlash device.
7530 +static int do_spi_transfer(int nr, char* tx, int tx_len, char* rx, int rx_len,
7531 + char* txnext, int txnext_len, char* rxnext, int rxnext_len)
7533 + struct spi_transfer_list* list = spi_transfer_desc;
7535 + list->tx[0] = tx; list->txlen[0] = tx_len;
7536 + list->rx[0] = rx; list->rxlen[0] = rx_len;
7538 + list->tx[1] = txnext; list->txlen[1] = txnext_len;
7539 + list->rx[1] = rxnext; list->rxlen[1] = rxnext_len;
7541 + list->nr_transfers = nr;
7543 + return spi_transfer(list);
7546 +/* ......................................................................... */
7549 + * Poll the DataFlash device until it is READY.
7551 +static void at91_dataflash_waitready(void)
7553 + char* command = kmalloc(2, GFP_KERNEL);
7559 + command[0] = OP_READ_STATUS;
7562 + do_spi_transfer(1, command, 2, command, 2, NULL, 0, NULL, 0);
7563 + } while ((command[1] & 0x80) == 0);
7569 + * Return the status of the DataFlash device.
7571 +static unsigned short at91_dataflash_status(void)
7573 + unsigned short status;
7574 + char* command = kmalloc(2, GFP_KERNEL);
7579 + command[0] = OP_READ_STATUS;
7582 + do_spi_transfer(1, command, 2, command, 2, NULL, 0, NULL, 0);
7583 + status = command[1];
7589 +/* ......................................................................... */
7592 + * Erase blocks of flash.
7594 +static int at91_dataflash_erase(struct mtd_info *mtd, struct erase_info *instr)
7596 + struct dataflash_local *priv = (struct dataflash_local *) mtd->priv;
7597 + unsigned int pageaddr;
7600 +#ifdef DEBUG_DATAFLASH
7601 + printk("dataflash_erase: addr=%i len=%i\n", instr->addr, instr->len);
7604 + /* Sanity checks */
7605 + if (instr->addr + instr->len > mtd->size)
7607 + if ((instr->len % mtd->erasesize != 0) || (instr->len % priv->page_size != 0))
7609 + if ((instr->addr % priv->page_size) != 0)
7612 + command = kmalloc(4, GFP_KERNEL);
7616 + while (instr->len > 0) {
7617 + /* Calculate flash page address */
7618 + pageaddr = (instr->addr / priv->page_size) << priv->page_offset;
7620 + command[0] = OP_ERASE_PAGE;
7621 + command[1] = (pageaddr & 0x00FF0000) >> 16;
7622 + command[2] = (pageaddr & 0x0000FF00) >> 8;
7624 +#ifdef DEBUG_DATAFLASH
7625 + printk("ERASE: (%x) %x %x %x [%i]\n", command[0], command[1], command[2], command[3], pageaddr);
7628 + /* Send command to SPI device */
7629 + spi_access_bus(priv->spi);
7630 + do_spi_transfer(1, command, 4, command, 4, NULL, 0, NULL, 0);
7632 + at91_dataflash_waitready(); /* poll status until ready */
7633 + spi_release_bus(priv->spi);
7635 + instr->addr += priv->page_size; /* next page */
7636 + instr->len -= priv->page_size;
7641 + /* Inform MTD subsystem that erase is complete */
7642 + instr->state = MTD_ERASE_DONE;
7643 + if (instr->callback)
7644 + instr->callback(instr);
7650 + * Read from the DataFlash device.
7651 + * from : Start offset in flash device
7652 + * len : Amount to read
7653 + * retlen : About of data actually read
7654 + * buf : Buffer containing the data
7656 +static int at91_dataflash_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
7658 + struct dataflash_local *priv = (struct dataflash_local *) mtd->priv;
7659 + unsigned int addr;
7662 +#ifdef DEBUG_DATAFLASH
7663 + printk("dataflash_read: %lli .. %lli\n", from, from+len);
7668 + /* Sanity checks */
7671 + if (from + len > mtd->size)
7674 + /* Calculate flash page/byte address */
7675 + addr = (((unsigned)from / priv->page_size) << priv->page_offset) + ((unsigned)from % priv->page_size);
7677 + command = kmalloc(8, GFP_KERNEL);
7681 + command[0] = OP_READ_CONTINUOUS;
7682 + command[1] = (addr & 0x00FF0000) >> 16;
7683 + command[2] = (addr & 0x0000FF00) >> 8;
7684 + command[3] = (addr & 0x000000FF);
7685 +#ifdef DEBUG_DATAFLASH
7686 + printk("READ: (%x) %x %x %x\n", command[0], command[1], command[2], command[3]);
7689 + /* Send command to SPI device */
7690 + spi_access_bus(priv->spi);
7691 + do_spi_transfer(2, command, 8, command, 8, buf, len, buf, len);
7692 + spi_release_bus(priv->spi);
7700 + * Write to the DataFlash device.
7701 + * to : Start offset in flash device
7702 + * len : Amount to write
7703 + * retlen : Amount of data actually written
7704 + * buf : Buffer containing the data
7706 +static int at91_dataflash_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf)
7708 + struct dataflash_local *priv = (struct dataflash_local *) mtd->priv;
7709 + unsigned int pageaddr, addr, offset, writelen;
7712 + unsigned short status;
7715 + char* tmpbuf = NULL;
7717 +#ifdef DEBUG_DATAFLASH
7718 + printk("dataflash_write: %lli .. %lli\n", to, to+len);
7723 + /* Sanity checks */
7726 + if (to + len > mtd->size)
7729 + command = kmalloc(4, GFP_KERNEL);
7733 + pageaddr = ((unsigned)to / priv->page_size);
7734 + offset = ((unsigned)to % priv->page_size);
7735 + if (offset + len > priv->page_size)
7736 + writelen = priv->page_size - offset;
7739 + writebuf = (u_char *)buf;
7742 + /* Allocate temporary buffer */
7743 + tmpbuf = kmalloc(priv->page_size, GFP_KERNEL);
7749 + /* Gain access to the SPI bus */
7750 + spi_access_bus(priv->spi);
7752 + while (remaining > 0) {
7753 +#ifdef DEBUG_DATAFLASH
7754 + printk("write @ %i:%i len=%i\n", pageaddr, offset, writelen);
7757 + /* (1) Transfer to Buffer1 */
7758 + if (writelen != priv->page_size) {
7759 + addr = pageaddr << priv->page_offset;
7760 + command[0] = OP_TRANSFER_BUF1;
7761 + command[1] = (addr & 0x00FF0000) >> 16;
7762 + command[2] = (addr & 0x0000FF00) >> 8;
7764 +#ifdef DEBUG_DATAFLASH
7765 + printk("TRANSFER: (%x) %x %x %x\n", command[0], command[1], command[2], command[3]);
7767 + do_spi_transfer(1, command, 4, command, 4, NULL, 0, NULL, 0);
7768 + at91_dataflash_waitready();
7771 + /* (2) Program via Buffer1 */
7772 + addr = (pageaddr << priv->page_offset) + offset;
7773 + command[0] = OP_PROGRAM_VIA_BUF1;
7774 + command[1] = (addr & 0x00FF0000) >> 16;
7775 + command[2] = (addr & 0x0000FF00) >> 8;
7776 + command[3] = (addr & 0x000000FF);
7777 +#ifdef DEBUG_DATAFLASH
7778 + printk("PROGRAM: (%x) %x %x %x\n", command[0], command[1], command[2], command[3]);
7780 + do_spi_transfer(2, command, 4, command, 4, writebuf, writelen, tmpbuf, writelen);
7781 + at91_dataflash_waitready();
7783 + /* (3) Compare to Buffer1 */
7784 + addr = pageaddr << priv->page_offset;
7785 + command[0] = OP_COMPARE_BUF1;
7786 + command[1] = (addr & 0x00FF0000) >> 16;
7787 + command[2] = (addr & 0x0000FF00) >> 8;
7789 +#ifdef DEBUG_DATAFLASH
7790 + printk("COMPARE: (%x) %x %x %x\n", command[0], command[1], command[2], command[3]);
7792 + do_spi_transfer(1, command, 4, command, 4, NULL, 0, NULL, 0);
7793 + at91_dataflash_waitready();
7795 + /* Get result of the compare operation */
7796 + status = at91_dataflash_status();
7797 + if (status & 0x40) {
7798 + printk("at91_dataflash: Write error on page %i\n", pageaddr);
7804 + remaining = remaining - writelen;
7807 + writebuf += writelen;
7808 + *retlen += writelen;
7810 + if (remaining > priv->page_size)
7811 + writelen = priv->page_size;
7813 + writelen = remaining;
7816 + /* Release SPI bus */
7817 + spi_release_bus(priv->spi);
7824 +/* ......................................................................... */
7827 + * Initialize and register DataFlash device with MTD subsystem.
7829 +static int __init add_dataflash(int channel, char *name, int IDsize,
7830 + int nr_pages, int pagesize, int pageoffset)
7832 + struct mtd_info *device;
7833 + struct dataflash_local *priv;
7834 +#ifdef CONFIG_MTD_PARTITIONS
7835 + struct mtd_partition *mtd_parts = 0;
7836 + int mtd_parts_nr = 0;
7839 + if (nr_devices >= DATAFLASH_MAX_DEVICES) {
7840 + printk(KERN_ERR "at91_dataflash: Too many devices detected\n");
7844 + device = kmalloc(sizeof(struct mtd_info) + strlen(name) + 8, GFP_KERNEL);
7847 + memset(device, 0, sizeof(struct mtd_info));
7849 + device->name = (char *)&device[1];
7850 + sprintf(device->name, "%s.spi%d", name, channel);
7851 + device->size = nr_pages * pagesize;
7852 + device->erasesize = pagesize;
7853 + device->writesize = pagesize;
7854 + device->owner = THIS_MODULE;
7855 + device->type = MTD_DATAFLASH;
7856 + device->flags = MTD_WRITEABLE;
7857 + device->erase = at91_dataflash_erase;
7858 + device->read = at91_dataflash_read;
7859 + device->write = at91_dataflash_write;
7861 + priv = (struct dataflash_local *) kmalloc(sizeof(struct dataflash_local), GFP_KERNEL);
7866 + memset(priv, 0, sizeof(struct dataflash_local));
7868 + priv->spi = channel;
7869 + priv->page_size = pagesize;
7870 + priv->page_offset = pageoffset;
7871 + device->priv = priv;
7873 + mtd_devices[nr_devices] = device;
7875 + printk("at91_dataflash: %s detected [spi%i] (%i bytes)\n", name, channel, device->size);
7877 +#ifdef CONFIG_MTD_PARTITIONS
7878 +#ifdef CONFIG_MTD_CMDLINE_PARTS
7879 + mtd_parts_nr = parse_mtd_partitions(device, part_probes, &mtd_parts, 0);
7881 + if (mtd_parts_nr <= 0) {
7884 + mtd_parts = static_partitions_2M;
7885 + mtd_parts_nr = ARRAY_SIZE(static_partitions_2M);
7888 + mtd_parts = static_partitions_4M;
7889 + mtd_parts_nr = ARRAY_SIZE(static_partitions_4M);
7892 + mtd_parts = static_partitions_8M;
7893 + mtd_parts_nr = ARRAY_SIZE(static_partitions_8M);
7898 + if (mtd_parts_nr > 0) {
7899 +#ifdef CONFIG_DATAFLASH_ALWAYS_ADD_DEVICE
7900 + add_mtd_device(device);
7902 + return add_mtd_partitions(device, mtd_parts, mtd_parts_nr);
7905 + return add_mtd_device(device); /* add whole device */
7909 + * Detect and initialize DataFlash device connected to specified SPI channel.
7911 + * Device Density ID code Nr Pages Page Size Page offset
7912 + * AT45DB011B 1Mbit (128K) xx0011xx (0x0c) 512 264 9
7913 + * AT45DB021B 2Mbit (256K) xx0101xx (0x14) 1025 264 9
7914 + * AT45DB041B 4Mbit (512K) xx0111xx (0x1c) 2048 264 9
7915 + * AT45DB081B 8Mbit (1M) xx1001xx (0x24) 4096 264 9
7916 + * AT45DB0161B 16Mbit (2M) xx1011xx (0x2c) 4096 528 10
7917 + * AT45DB0321B 32Mbit (4M) xx1101xx (0x34) 8192 528 10
7918 + * AT45DB0642 64Mbit (8M) xx1111xx (0x3c) 8192 1056 11
7919 + * AT45DB1282 128Mbit (16M) xx0100xx (0x10) 16384 1056 11
7921 +static int __init at91_dataflash_detect(int channel)
7924 + unsigned short status;
7926 + spi_access_bus(channel);
7927 + status = at91_dataflash_status();
7928 + spi_release_bus(channel);
7929 + if (status != 0xff) { /* no dataflash device there */
7930 + switch (status & 0x3c) {
7931 + case 0x0c: /* 0 0 1 1 */
7932 + res = add_dataflash(channel, "AT45DB011B", SZ_128K, 512, 264, 9);
7934 + case 0x14: /* 0 1 0 1 */
7935 + res = add_dataflash(channel, "AT45DB021B", SZ_256K, 1025, 264, 9);
7937 + case 0x1c: /* 0 1 1 1 */
7938 + res = add_dataflash(channel, "AT45DB041B", SZ_512K, 2048, 264, 9);
7940 + case 0x24: /* 1 0 0 1 */
7941 + res = add_dataflash(channel, "AT45DB081B", SZ_1M, 4096, 264, 9);
7943 + case 0x2c: /* 1 0 1 1 */
7944 + res = add_dataflash(channel, "AT45DB161B", SZ_2M, 4096, 528, 10);
7946 + case 0x34: /* 1 1 0 1 */
7947 + res = add_dataflash(channel, "AT45DB321B", SZ_4M, 8192, 528, 10);
7949 + case 0x3c: /* 1 1 1 1 */
7950 + res = add_dataflash(channel, "AT45DB642", SZ_8M, 8192, 1056, 11);
7952 +// Currently unsupported since Atmel removed the "Main Memory Program via Buffer" commands.
7953 +// case 0x10: /* 0 1 0 0 */
7954 +// res = add_dataflash(channel, "AT45DB1282", SZ_16M, 16384, 1056, 11);
7957 + printk(KERN_ERR "at91_dataflash: Unknown device (%x)\n", status & 0x3c);
7964 +static int __init at91_dataflash_init(void)
7966 + spi_transfer_desc = kmalloc(sizeof(struct spi_transfer_list), GFP_KERNEL);
7967 + if (!spi_transfer_desc)
7970 + /* DataFlash (SPI chip select 0) */
7971 + at91_dataflash_detect(0);
7973 + if (machine_is_sweda_tms())
7974 + at91_dataflash_detect(1); /* DataFlash device (SPI chip select 1) */
7976 +#ifdef CONFIG_MTD_AT91_DATAFLASH_CARD
7977 + /* DataFlash card (SPI chip select 3) */
7978 + at91_dataflash_detect(3);
7984 +static void __exit at91_dataflash_exit(void)
7988 + for (i = 0; i < DATAFLASH_MAX_DEVICES; i++) {
7989 + if (mtd_devices[i]) {
7990 +#ifdef CONFIG_MTD_PARTITIONS
7991 + del_mtd_partitions(mtd_devices[i]);
7993 + del_mtd_device(mtd_devices[i]);
7995 + kfree(mtd_devices[i]->priv);
7996 + kfree(mtd_devices[i]);
8000 + kfree(spi_transfer_desc);
8004 +module_init(at91_dataflash_init);
8005 +module_exit(at91_dataflash_exit);
8007 +MODULE_LICENSE("GPL");
8008 +MODULE_AUTHOR("Andrew Victor");
8009 +MODULE_DESCRIPTION("DataFlash driver for Atmel AT91RM9200");
8010 --- a/drivers/mtd/nand/Kconfig
8011 +++ b/drivers/mtd/nand/Kconfig
8012 @@ -273,12 +273,53 @@ config MTD_NAND_CS553X
8013 If you say "m", the module will be called "cs553x_nand.ko".
8015 config MTD_NAND_AT91
8016 - bool "Support for NAND Flash / SmartMedia on AT91"
8017 + tristate "Support for NAND Flash / SmartMedia on AT91"
8018 depends on ARCH_AT91
8020 Enables support for NAND Flash / Smart Media Card interface
8021 on Atmel AT91 processors.
8024 + prompt "ECC management for NAND Flash / SmartMedia on AT91"
8025 + depends on MTD_NAND_AT91
8027 +config MTD_NAND_AT91_ECC_SOFT
8028 + bool "Software ECC"
8029 + depends on MTD_NAND_AT91
8031 + Uses software ECC.
8033 + NB : hardware and software ECC schemes are incompatible.
8034 + If you switch from one to another, you'll have to erase your
8037 +config MTD_NAND_AT91_ECC_HW
8038 + bool "Hardware ECC"
8039 + depends on MTD_NAND_AT91 && (ARCH_AT91SAM9260 || ARCH_AT91SAM9263 || ARCH_AT91SAM9RL || ARCH_AT91CAP9)
8041 + Uses hardware ECC provided by the AT91 processor
8042 + instead of software ECC.
8043 + The hardware ECC controller is capable of single bit error
8044 + correction and 2-bit random detection per page.
8046 + NB : hardware and software ECC schemes are incompatible.
8047 + If you switch from one to another, you'll have to erase your
8052 +config MTD_NAND_AT91_ECC_NONE
8053 + bool "No ECC (Testing Only)"
8054 + depends on MTD_NAND_AT91
8056 + No ECC will be used.
8057 + It's not a good idea and it should be reserved for testing
8064 config MTD_NAND_CM_X270
8065 tristate "Support for NAND Flash on CM-X270 modules"
8066 depends on MTD_NAND && MACH_ARMCORE
8067 --- a/drivers/mtd/nand/at91_nand.c
8068 +++ b/drivers/mtd/nand/at91_nand.c
8070 * Derived from drivers/mtd/spia.c
8071 * Copyright (C) 2000 Steven J. Hill (sjhill@cotw.com)
8074 + * Add Hardware ECC support for AT91SAM9260 / AT91SAM9263
8075 + * Richard Genoud (richard.genoud@gmail.com), Adeneo Copyright (C) 2007
8077 + * Derived from Das U-Boot source code
8078 + * (u-boot-1.1.5/board/atmel/at91sam9263ek/nand.c)
8079 + * (C) Copyright 2006 ATMEL Rousset, Lacressonniere Nicolas
8082 * This program is free software; you can redistribute it and/or modify
8083 * it under the terms of the GNU General Public License version 2 as
8084 * published by the Free Software Foundation.
8086 #include <asm/hardware.h>
8087 #include <asm/arch/board.h>
8088 #include <asm/arch/gpio.h>
8089 +#include <asm/arch/at91_ecc.h>
8091 +#ifdef CONFIG_MTD_NAND_AT91_ECC_HW
8097 +#ifdef CONFIG_MTD_NAND_AT91_ECC_NONE
8103 +/* Register access macros */
8104 +#define ecc_readl(base, reg) __raw_readl(base + reg)
8105 +#define ecc_writel(base, reg, value) __raw_writel((value), base + reg)
8109 + * OOB layout for large page size.
8110 + * bad block info is on bytes 0 and 1
8111 + * the bytes must be consecutives to avoid several NAND_CMD_RNDOUT during read.
8113 +static struct nand_ecclayout at91_oobinfo_large = {
8115 + .eccpos = {60, 61, 62, 63},
8116 + .oobfree = { {2, 58} },
8120 + * OOB layout for small page size
8121 + * bad block info is on bytes 4 and 5
8122 + * the bytes must be consecutives to avoid several NAND_CMD_RNDOUT during read.
8124 +static struct nand_ecclayout at91_oobinfo_small = {
8126 + .eccpos = {0, 1, 2, 3},
8127 + .oobfree = { {6, 10} },
8130 struct at91_nand_host {
8131 struct nand_chip nand_chip;
8132 struct mtd_info mtd;
8133 void __iomem *io_base;
8134 struct at91_nand_data *board;
8135 + struct device *dev;
8136 + void __iomem *ecc;
8140 + * Enable NAND chip-select.
8142 +static void at91_nand_enable(struct at91_nand_host *host)
8144 + if (host->board->enable_pin)
8145 + at91_set_gpio_value(host->board->enable_pin, 0);
8149 + * Disable NAND chip-select.
8151 +static void at91_nand_disable(struct at91_nand_host *host)
8153 + if (host->board->enable_pin)
8154 + at91_set_gpio_value(host->board->enable_pin, 1);
8158 * Hardware specific access to control-lines
8160 static void at91_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
8161 @@ -44,6 +113,13 @@ static void at91_nand_cmd_ctrl(struct mt
8162 struct nand_chip *nand_chip = mtd->priv;
8163 struct at91_nand_host *host = nand_chip->priv;
8165 + if (ctrl & NAND_CTRL_CHANGE) {
8166 + if (ctrl & NAND_NCE)
8167 + at91_nand_enable(host);
8169 + at91_nand_disable(host);
8172 if (cmd == NAND_CMD_NONE)
8175 @@ -65,27 +141,249 @@ static int at91_nand_device_ready(struct
8180 + * write oob for small pages
8182 -static void at91_nand_enable(struct at91_nand_host *host)
8183 +static int at91_nand_write_oob_512(struct mtd_info *mtd,
8184 + struct nand_chip *chip, int page)
8186 - if (host->board->enable_pin)
8187 - at91_set_gpio_value(host->board->enable_pin, 0);
8188 + int chunk = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad;
8189 + int eccsize = chip->ecc.size, length = mtd->oobsize;
8190 + int len, pos, status = 0;
8191 + const uint8_t *bufpoi = chip->oob_poi;
8193 + pos = eccsize + chunk;
8195 + chip->cmdfunc(mtd, NAND_CMD_SEQIN, pos, page);
8196 + len = min_t(int, length, chunk);
8197 + chip->write_buf(mtd, bufpoi, len);
8201 + chip->write_buf(mtd, bufpoi, length);
8203 + chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1);
8204 + status = chip->waitfunc(mtd, chip);
8206 + return status & NAND_STATUS_FAIL ? -EIO : 0;
8212 + * read oob for small pages
8214 -static void at91_nand_disable(struct at91_nand_host *host)
8215 +static int at91_nand_read_oob_512(struct mtd_info *mtd,
8216 + struct nand_chip *chip, int page, int sndcmd)
8218 - if (host->board->enable_pin)
8219 - at91_set_gpio_value(host->board->enable_pin, 1);
8221 + chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
8224 + chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
8229 + * Calculate HW ECC
8231 + * mtd: MTD block structure
8232 + * dat: raw data (unused)
8233 + * ecc_code: buffer for ECC
8235 +static int at91_nand_calculate(struct mtd_info *mtd,
8236 + const u_char *dat, unsigned char *ecc_code)
8238 + struct nand_chip *nand_chip = mtd->priv;
8239 + struct at91_nand_host *host = nand_chip->priv;
8240 + uint32_t *eccpos = nand_chip->ecc.layout->eccpos;
8241 + unsigned int ecc_value;
8243 + /* get the first 2 ECC bytes */
8244 + ecc_value = ecc_readl(host->ecc, AT91_ECC_PR) & (AT91_ECC_BITADDR | AT91_ECC_WORDADDR);
8246 + ecc_code[eccpos[0]] = ecc_value & 0xFF;
8247 + ecc_code[eccpos[1]] = (ecc_value >> 8) & 0xFF;
8249 + /* get the last 2 ECC bytes */
8250 + ecc_value = ecc_readl(host->ecc, AT91_ECC_NPR) & AT91_ECC_NPARITY;
8252 + ecc_code[eccpos[2]] = ecc_value & 0xFF;
8253 + ecc_code[eccpos[3]] = (ecc_value >> 8) & 0xFF;
8259 + * HW ECC read page function
8261 + * mtd: mtd info structure
8262 + * chip: nand chip info structure
8263 + * buf: buffer to store read data
8265 +static int at91_nand_read_page(struct mtd_info *mtd,
8266 + struct nand_chip *chip, uint8_t *buf)
8268 + int eccsize = chip->ecc.size;
8269 + int eccbytes = chip->ecc.bytes;
8270 + uint32_t *eccpos = chip->ecc.layout->eccpos;
8272 + uint8_t *oob = chip->oob_poi;
8276 + /* read the page */
8277 + chip->read_buf(mtd, p, eccsize);
8279 + /* move to ECC position if needed */
8280 + if (eccpos[0] != 0) {
8282 + * This only works on large pages because the ECC controller
8283 + * waits for NAND_CMD_RNDOUTSTART after the NAND_CMD_RNDOUT.
8284 + * Anyway, for small pages, the eccpos[0] == 0
8286 + chip->cmdfunc(mtd, NAND_CMD_RNDOUT,
8287 + mtd->writesize + eccpos[0], -1);
8290 + /* the ECC controller needs to read the ECC just after the data */
8291 + ecc_pos = oob + eccpos[0];
8292 + chip->read_buf(mtd, ecc_pos, eccbytes);
8294 + /* check if there's an error */
8295 + stat = chip->ecc.correct(mtd, p, oob, NULL);
8298 + mtd->ecc_stats.failed++;
8300 + mtd->ecc_stats.corrected += stat;
8302 + /* get back to oob start (end of page) */
8303 + chip->cmdfunc(mtd, NAND_CMD_RNDOUT, mtd->writesize, -1);
8305 + /* read the oob */
8306 + chip->read_buf(mtd, oob, mtd->oobsize);
8312 + * HW ECC Correction
8314 + * mtd: MTD block structure
8315 + * dat: raw data read from the chip
8316 + * read_ecc: ECC from the chip (unused)
8319 + * Detect and correct a 1 bit error for a page
8321 +static int at91_nand_correct(struct mtd_info *mtd, u_char *dat,
8322 + u_char *read_ecc, u_char *isnull)
8324 + struct nand_chip *nand_chip = mtd->priv;
8325 + struct at91_nand_host *host = nand_chip->priv;
8326 + unsigned int ecc_status;
8327 + unsigned int ecc_word, ecc_bit;
8329 + /* get the status from the Status Register */
8330 + ecc_status = ecc_readl(host->ecc, AT91_ECC_SR);
8332 + /* if there's no error */
8333 + if (likely(!(ecc_status & AT91_ECC_RECERR)))
8336 + /* get error bit offset (4 bits) */
8337 + ecc_bit = ecc_readl(host->ecc, AT91_ECC_PR) & AT91_ECC_BITADDR;
8338 + /* get word address (12 bits) */
8339 + ecc_word = ecc_readl(host->ecc, AT91_ECC_PR) & AT91_ECC_WORDADDR;
8342 + /* if there are multiple errors */
8343 + if (ecc_status & AT91_ECC_MULERR) {
8344 + /* Check if it is a freshly erased block (filled with 0xff) */
8345 + if ((ecc_bit == AT91_ECC_BITADDR)
8346 + && (ecc_word == (AT91_ECC_WORDADDR >> 4))) {
8347 + /* the block has just been erased, return OK */
8351 + * It doesn't seems to be a freshly-erased block.
8352 + * We can't correct so many errors.
8354 + dev_dbg(host->dev, "at91_nand : multiple errors detected."
8355 + " Unable to correct.\n");
8359 + /* if there's a single bit error : we can correct it */
8360 + if (ecc_status & AT91_ECC_ECCERR) {
8362 + * There's nothing much to do here.
8363 + * The bit error is on the ECC itself.
8365 + dev_dbg(host->dev, "at91_nand : one bit error on ECC code."
8366 + " Nothing to correct\n");
8370 + dev_dbg(host->dev, "at91_nand : one bit error on data."
8371 + " (word offset in the page :"
8372 + " 0x%x bit offset : 0x%x)\n",
8373 + ecc_word, ecc_bit);
8374 + /* correct the error */
8375 + if (nand_chip->options & NAND_BUSWIDTH_16) {
8376 + /* 16 bits words */
8377 + ((unsigned short *) dat)[ecc_word] ^= (1 << ecc_bit);
8379 + /* 8 bits words */
8380 + dat[ecc_word] ^= (1 << ecc_bit);
8382 + dev_dbg(host->dev, "at91_nand : error corrected\n");
8387 + * Enable HW ECC : unsused
8389 +static void at91_nand_hwctl(struct mtd_info *mtd, int mode) { ; }
8392 + * Over-ride the standard functions with our optimized versions.
8393 + * We can use read/write blocks to move data to/from the controller.
8395 +static void at91_read_buf8(struct mtd_info *mtd, u8 *buf, int len)
8397 + struct nand_chip *nand_chip = mtd->priv;
8399 + __raw_readsb(nand_chip->IO_ADDR_R, buf, len);
8402 +static void at91_read_buf16(struct mtd_info *mtd, u8 *buf, int len)
8404 + struct nand_chip *nand_chip = mtd->priv;
8406 + __raw_readsw(nand_chip->IO_ADDR_R, buf, len / 2);
8409 +static void at91_write_buf8(struct mtd_info *mtd, const u8 *buf, int len)
8411 + struct nand_chip *nand_chip = mtd->priv;
8413 + __raw_writesb(nand_chip->IO_ADDR_W, buf, len);
8416 +static void at91_write_buf16(struct mtd_info *mtd, const u8 *buf, int len)
8418 + struct nand_chip *nand_chip = mtd->priv;
8420 + __raw_writesw(nand_chip->IO_ADDR_W, buf, len / 2);
8424 #ifdef CONFIG_MTD_PARTITIONS
8425 -const char *part_probes[] = { "cmdlinepart", NULL };
8426 +static const char *part_probes[] = { "cmdlinepart", NULL };
8429 +static char* ecc_modes[] __initdata = { "No", "Software", "Hardware" };
8432 * Probe for the NAND device.
8434 @@ -94,6 +392,8 @@ static int __init at91_nand_probe(struct
8435 struct at91_nand_host *host;
8436 struct mtd_info *mtd;
8437 struct nand_chip *nand_chip;
8438 + struct resource *regs;
8439 + struct resource *mem;
8442 #ifdef CONFIG_MTD_PARTITIONS
8443 @@ -108,8 +408,13 @@ static int __init at91_nand_probe(struct
8447 - host->io_base = ioremap(pdev->resource[0].start,
8448 - pdev->resource[0].end - pdev->resource[0].start + 1);
8449 + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
8451 + printk(KERN_ERR "at91_nand: can't get I/O resource mem\n");
8455 + host->io_base = ioremap(mem->start, mem->end - mem->start + 1);
8456 if (host->io_base == NULL) {
8457 printk(KERN_ERR "at91_nand: ioremap failed\n");
8459 @@ -119,6 +424,7 @@ static int __init at91_nand_probe(struct
8461 nand_chip = &host->nand_chip;
8462 host->board = pdev->dev.platform_data;
8463 + host->dev = &pdev->dev;
8465 nand_chip->priv = host; /* link the private data structures */
8466 mtd->priv = nand_chip;
8467 @@ -132,11 +438,40 @@ static int __init at91_nand_probe(struct
8468 if (host->board->rdy_pin)
8469 nand_chip->dev_ready = at91_nand_device_ready;
8471 + regs = platform_get_resource(pdev, IORESOURCE_MEM, 1);
8472 + if (!regs && hard_ecc) {
8473 + printk(KERN_ERR "at91_nand: can't get I/O resource "
8474 + "regs\nFalling back on software ECC\n");
8477 nand_chip->ecc.mode = NAND_ECC_SOFT; /* enable ECC */
8479 + nand_chip->ecc.mode = NAND_ECC_NONE;
8480 + if (hard_ecc && regs) {
8481 + host->ecc = (void __force __iomem *) (AT91_VA_BASE_SYS - AT91_BASE_SYS);
8482 + host->ecc += regs->start;
8484 + nand_chip->ecc.mode = NAND_ECC_HW_SYNDROME; /* HW SYNDROME ECC */
8485 + nand_chip->ecc.calculate = at91_nand_calculate; /* function called after a write */
8486 + nand_chip->ecc.correct = at91_nand_correct; /* function called after a read */
8487 + nand_chip->ecc.hwctl = at91_nand_hwctl; /* unused */
8488 + nand_chip->ecc.read_page = at91_nand_read_page; /* read page function */
8489 + nand_chip->ecc.bytes = 4; /* 4 ECC bytes for any page size */
8490 + nand_chip->ecc.prepad = 0;
8491 + nand_chip->ecc.postpad = 0;
8494 nand_chip->chip_delay = 20; /* 20us command delay time */
8496 - if (host->board->bus_width_16) /* 16-bit bus width */
8497 + if (host->board->bus_width_16) { /* 16-bit bus width */
8498 nand_chip->options |= NAND_BUSWIDTH_16;
8499 + nand_chip->read_buf = at91_read_buf16;
8500 + nand_chip->write_buf = at91_write_buf16;
8503 + nand_chip->read_buf = at91_read_buf8;
8504 + nand_chip->write_buf = at91_write_buf8;
8507 platform_set_drvdata(pdev, host);
8508 at91_nand_enable(host);
8509 @@ -149,8 +484,60 @@ static int __init at91_nand_probe(struct
8513 - /* Scan to find existance of the device */
8514 - if (nand_scan(mtd, 1)) {
8515 + /* first scan to find the device and get the page size */
8516 + if (nand_scan_ident(mtd, 1)) {
8521 + if (nand_chip->ecc.mode == NAND_ECC_HW_SYNDROME) {
8522 + /* ECC is calculated for the whole page (1 step) */
8523 + nand_chip->ecc.size = mtd->writesize;
8525 + /* set ECC page size and oob layout */
8526 + switch (mtd->writesize) {
8528 + nand_chip->ecc.layout = &at91_oobinfo_small;
8529 + nand_chip->ecc.read_oob = at91_nand_read_oob_512;
8530 + nand_chip->ecc.write_oob = at91_nand_write_oob_512;
8531 + ecc_writel(host->ecc, AT91_ECC_MR, AT91_ECC_PAGESIZE_528);
8534 + nand_chip->ecc.layout = &at91_oobinfo_large;
8535 + ecc_writel(host->ecc, AT91_ECC_MR, AT91_ECC_PAGESIZE_1056);
8538 + nand_chip->ecc.layout = &at91_oobinfo_large;
8539 + ecc_writel(host->ecc, AT91_ECC_MR, AT91_ECC_PAGESIZE_2112);
8542 + nand_chip->ecc.layout = &at91_oobinfo_large;
8543 + ecc_writel(host->ecc, AT91_ECC_MR, AT91_ECC_PAGESIZE_4224);
8547 + * Page size not supported by HW ECC.
8548 + * So switch back to soft ECC
8550 + nand_chip->ecc.mode = NAND_ECC_SOFT;
8551 + nand_chip->ecc.calculate = NULL;
8552 + nand_chip->ecc.correct = NULL;
8553 + nand_chip->ecc.hwctl = NULL;
8554 + nand_chip->ecc.read_page = NULL;
8555 + nand_chip->ecc.postpad = 0;
8556 + nand_chip->ecc.prepad = 0;
8557 + nand_chip->ecc.bytes = 0;
8562 + printk(KERN_INFO "AT91 NAND: %i-bit, %s ECC\n",
8563 + (nand_chip->options & NAND_BUSWIDTH_16) ? 16 : 8,
8564 + ecc_modes[nand_chip->ecc.mode]
8567 + /* second phase scan */
8568 + if (nand_scan_tail(mtd)) {
8572 @@ -179,8 +566,11 @@ static int __init at91_nand_probe(struct
8576 +#ifdef CONFIG_MTD_PARTITIONS
8582 at91_nand_disable(host);
8583 platform_set_drvdata(pdev, NULL);
8584 @@ -192,7 +582,7 @@ out:
8586 * Remove a NAND device.
8588 -static int __devexit at91_nand_remove(struct platform_device *pdev)
8589 +static int __exit at91_nand_remove(struct platform_device *pdev)
8591 struct at91_nand_host *host = platform_get_drvdata(pdev);
8592 struct mtd_info *mtd = &host->mtd;
8593 @@ -208,8 +598,7 @@ static int __devexit at91_nand_remove(st
8596 static struct platform_driver at91_nand_driver = {
8597 - .probe = at91_nand_probe,
8598 - .remove = at91_nand_remove,
8599 + .remove = __exit_p(at91_nand_remove),
8601 .name = "at91_nand",
8602 .owner = THIS_MODULE,
8603 @@ -218,7 +607,7 @@ static struct platform_driver at91_nand_
8605 static int __init at91_nand_init(void)
8607 - return platform_driver_register(&at91_nand_driver);
8608 + return platform_driver_probe(&at91_nand_driver, at91_nand_probe);
8612 @@ -233,4 +622,4 @@ module_exit(at91_nand_exit);
8614 MODULE_LICENSE("GPL");
8615 MODULE_AUTHOR("Rick Bronson");
8616 -MODULE_DESCRIPTION("NAND/SmartMedia driver for AT91RM9200");
8617 +MODULE_DESCRIPTION("NAND/SmartMedia driver for AT91RM9200 / AT91SAM9 / AT91CAP9");
8618 --- a/drivers/net/arm/Kconfig
8619 +++ b/drivers/net/arm/Kconfig
8620 @@ -47,3 +47,10 @@ config EP93XX_ETH
8622 This is a driver for the ethernet hardware included in EP93xx CPUs.
8623 Say Y if you are building a kernel for EP93xx based devices.
8625 +config ARM_KS8695_ETHER
8626 + tristate "KS8695 Ethernet support"
8627 + depends on NET_ETHERNET && ARM && ARCH_KS8695
8629 + If you wish to compile a kernel for an KS8695-based board
8630 + and enable Ethernet support, then select this option.
8631 --- a/drivers/net/arm/Makefile
8632 +++ b/drivers/net/arm/Makefile
8633 @@ -9,3 +9,4 @@ obj-$(CONFIG_ARM_ETHER3) += ether3.o
8634 obj-$(CONFIG_ARM_ETHER1) += ether1.o
8635 obj-$(CONFIG_ARM_AT91_ETHER) += at91_ether.o
8636 obj-$(CONFIG_EP93XX_ETH) += ep93xx_eth.o
8637 +obj-$(CONFIG_ARM_KS8695_ETHER) += ks8695_ether.o
8638 --- a/drivers/net/arm/at91_ether.c
8639 +++ b/drivers/net/arm/at91_ether.c
8640 @@ -220,7 +220,7 @@ static irqreturn_t at91ether_phy_interru
8641 if (!(phy & (1 << 0)))
8644 - else if (lp->phy_type == MII_KS8721_ID) {
8645 + else if ((lp->phy_type == MII_KS8721_ID) || (lp->phy_type == MII_KSZ8041_ID)) {
8646 read_phy(lp->phy_address, MII_TPISTATUS, &phy); /* ack interrupt in Micrel PHY */
8647 if (!(phy & ((1 << 2) | 1)))
8649 @@ -286,7 +286,7 @@ static void enable_phyirq(struct net_dev
8650 dsintr = (1 << 15) | ( 1 << 14);
8651 write_phy(lp->phy_address, MII_BCMINTR_REG, dsintr);
8653 - else if (lp->phy_type == MII_KS8721_ID) { /* for Micrel PHY */
8654 + else if ((lp->phy_type == MII_KS8721_ID) || (lp->phy_type == MII_KSZ8041_ID)) { /* for Micrel PHY */
8655 dsintr = (1 << 10) | ( 1 << 8);
8656 write_phy(lp->phy_address, MII_TPISTATUS, dsintr);
8658 @@ -341,7 +341,7 @@ static void disable_phyirq(struct net_de
8659 dsintr = ~(1 << 14);
8660 write_phy(lp->phy_address, MII_BCMINTR_REG, dsintr);
8662 - else if (lp->phy_type == MII_KS8721_ID) { /* for Micrel PHY */
8663 + else if ((lp->phy_type == MII_KS8721_ID) || (lp->phy_type == MII_KSZ8041_ID)) { /* for Micrel PHY */
8664 read_phy(lp->phy_address, MII_TPISTATUS, &dsintr);
8665 dsintr = ~((1 << 10) | (1 << 8));
8666 write_phy(lp->phy_address, MII_TPISTATUS, dsintr);
8667 @@ -820,7 +820,7 @@ static int at91ether_tx(struct sk_buff *
8669 lp->skb_length = skb->len;
8670 lp->skb_physaddr = dma_map_single(NULL, skb->data, skb->len, DMA_TO_DEVICE);
8671 - lp->stats.tx_bytes += skb->len;
8672 + dev->stats.tx_bytes += skb->len;
8674 /* Set address of the data in the Transmit Address register */
8675 at91_emac_write(AT91_EMAC_TAR, lp->skb_physaddr);
8676 @@ -843,34 +843,32 @@ static int at91ether_tx(struct sk_buff *
8678 static struct net_device_stats *at91ether_stats(struct net_device *dev)
8680 - struct at91_private *lp = netdev_priv(dev);
8681 - int ale, lenerr, seqe, lcol, ecol;
8682 + int ale, lenerr, seqe, ecol;
8684 if (netif_running(dev)) {
8685 - lp->stats.rx_packets += at91_emac_read(AT91_EMAC_OK); /* Good frames received */
8686 + dev->stats.rx_packets += at91_emac_read(AT91_EMAC_OK); /* Good frames received */
8687 ale = at91_emac_read(AT91_EMAC_ALE);
8688 - lp->stats.rx_frame_errors += ale; /* Alignment errors */
8689 + dev->stats.rx_frame_errors += ale; /* Alignment errors */
8690 lenerr = at91_emac_read(AT91_EMAC_ELR) + at91_emac_read(AT91_EMAC_USF);
8691 - lp->stats.rx_length_errors += lenerr; /* Excessive Length or Undersize Frame error */
8692 + dev->stats.rx_length_errors += lenerr; /* Excessive Length or Undersize Frame error */
8693 seqe = at91_emac_read(AT91_EMAC_SEQE);
8694 - lp->stats.rx_crc_errors += seqe; /* CRC error */
8695 - lp->stats.rx_fifo_errors += at91_emac_read(AT91_EMAC_DRFC); /* Receive buffer not available */
8696 - lp->stats.rx_errors += (ale + lenerr + seqe
8697 + dev->stats.rx_crc_errors += seqe; /* CRC error */
8698 + dev->stats.rx_fifo_errors += at91_emac_read(AT91_EMAC_DRFC); /* Receive buffer not available */
8699 + dev->stats.rx_errors += (ale + lenerr + seqe
8700 + at91_emac_read(AT91_EMAC_CDE) + at91_emac_read(AT91_EMAC_RJB));
8702 - lp->stats.tx_packets += at91_emac_read(AT91_EMAC_FRA); /* Frames successfully transmitted */
8703 - lp->stats.tx_fifo_errors += at91_emac_read(AT91_EMAC_TUE); /* Transmit FIFO underruns */
8704 - lp->stats.tx_carrier_errors += at91_emac_read(AT91_EMAC_CSE); /* Carrier Sense errors */
8705 - lp->stats.tx_heartbeat_errors += at91_emac_read(AT91_EMAC_SQEE);/* Heartbeat error */
8706 + dev->stats.tx_packets += at91_emac_read(AT91_EMAC_FRA); /* Frames successfully transmitted */
8707 + dev->stats.tx_fifo_errors += at91_emac_read(AT91_EMAC_TUE); /* Transmit FIFO underruns */
8708 + dev->stats.tx_carrier_errors += at91_emac_read(AT91_EMAC_CSE); /* Carrier Sense errors */
8709 + dev->stats.tx_heartbeat_errors += at91_emac_read(AT91_EMAC_SQEE);/* Heartbeat error */
8711 - lcol = at91_emac_read(AT91_EMAC_LCOL);
8712 + dev->stats.tx_window_errors += at91_emac_read(AT91_EMAC_LCOL); /* Late collisions */
8713 ecol = at91_emac_read(AT91_EMAC_ECOL);
8714 - lp->stats.tx_window_errors += lcol; /* Late collisions */
8715 - lp->stats.tx_aborted_errors += ecol; /* 16 collisions */
8716 + dev->stats.tx_aborted_errors += ecol; /* 16 collisions */
8718 - lp->stats.collisions += (at91_emac_read(AT91_EMAC_SCOL) + at91_emac_read(AT91_EMAC_MCOL) + lcol + ecol);
8719 + dev->stats.collisions += (at91_emac_read(AT91_EMAC_SCOL) + at91_emac_read(AT91_EMAC_MCOL) + ecol);
8721 - return &lp->stats;
8722 + return &dev->stats;
8726 @@ -896,16 +894,16 @@ static void at91ether_rx(struct net_devi
8728 skb->protocol = eth_type_trans(skb, dev);
8729 dev->last_rx = jiffies;
8730 - lp->stats.rx_bytes += pktlen;
8731 + dev->stats.rx_bytes += pktlen;
8735 - lp->stats.rx_dropped += 1;
8736 + dev->stats.rx_dropped += 1;
8737 printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name);
8740 if (dlist->descriptors[lp->rxBuffIndex].size & EMAC_MULTICAST)
8741 - lp->stats.multicast++;
8742 + dev->stats.multicast++;
8744 dlist->descriptors[lp->rxBuffIndex].addr &= ~EMAC_DESC_DONE; /* reset ownership bit */
8745 if (lp->rxBuffIndex == MAX_RX_DESCR-1) /* wrap after last buffer */
8746 @@ -934,7 +932,7 @@ static irqreturn_t at91ether_interrupt(i
8747 if (intstatus & AT91_EMAC_TCOM) { /* Transmit complete */
8748 /* The TCOM bit is set even if the transmission failed. */
8749 if (intstatus & (AT91_EMAC_TUND | AT91_EMAC_RTRY))
8750 - lp->stats.tx_errors += 1;
8751 + dev->stats.tx_errors += 1;
8754 dev_kfree_skb_irq(lp->skb);
8755 @@ -978,15 +976,22 @@ static int __init at91ether_setup(unsign
8756 struct net_device *dev;
8757 struct at91_private *lp;
8760 + struct resource *res;
8762 DECLARE_MAC_BUF(mac);
8764 dev = alloc_etherdev(sizeof(struct at91_private));
8768 - dev->base_addr = AT91_VA_BASE_EMAC;
8769 - dev->irq = AT91RM9200_ID_EMAC;
8770 + /* Get I/O base address and IRQ */
8771 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
8776 + dev->base_addr = res->start;
8777 + dev->irq = platform_get_irq(pdev, 0);
8779 /* Install the interrupt handler */
8780 if (request_irq(dev->irq, at91ether_interrupt, 0, dev->name, dev)) {
8781 @@ -1043,7 +1048,9 @@ static int __init at91ether_setup(unsign
8782 } else if (machine_is_csb337()) {
8783 /* mix link activity status into LED2 link state */
8784 write_phy(phy_address, MII_LEDCTRL_REG, 0x0d22);
8786 + } else if (machine_is_ecbat91())
8787 + write_phy(phy_address, MII_LEDCTRL_REG, 0x156A);
8790 spin_unlock_irq(&lp->lock);
8792 @@ -1058,12 +1065,12 @@ static int __init at91ether_setup(unsign
8793 lp->phy_address = phy_address; /* MDI address of PHY */
8795 /* Register the network interface */
8796 - res = register_netdev(dev);
8798 + ret = register_netdev(dev);
8800 free_irq(dev->irq, dev);
8802 dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys);
8807 /* Determine current link speed */
8808 @@ -1101,6 +1108,8 @@ static int __init at91ether_setup(unsign
8809 printk(KERN_INFO "%s: National Semiconductor DP83848 PHY\n", dev->name);
8810 else if (phy_type == MII_AC101L_ID)
8811 printk(KERN_INFO "%s: Altima AC101L PHY\n", dev->name);
8812 + else if (phy_type == MII_KSZ8041_ID)
8813 + printk(KERN_INFO "%s: Micrel KSZ8041 PHY\n", dev->name);
8814 else if (phy_type == MII_KS8721_ID)
8815 printk(KERN_INFO "%s: Micrel KS8721 PHY\n", dev->name);
8816 else if (phy_type == MII_T78Q21x3_ID)
8817 @@ -1146,6 +1155,7 @@ static int __init at91ether_probe(struct
8818 case MII_DP83847_ID: /* National Semiconductor DP83847: */
8819 case MII_DP83848_ID: /* National Semiconductor DP83848: */
8820 case MII_AC101L_ID: /* Altima AC101L: PHY_ID1 = 0x22, PHY_ID2 = 0x5520 */
8821 + case MII_KSZ8041_ID: /* Micrel KSZ8041: PHY_ID1 = 0x22, PHY_ID2 = 0x1512 */
8822 case MII_KS8721_ID: /* Micrel KS8721: PHY_ID1 = 0x22, PHY_ID2 = 0x1610 */
8823 case MII_T78Q21x3_ID: /* Teridian 78Q21x3: PHY_ID1 = 0x0E, PHY_ID2 = 7237 */
8824 case MII_LAN83C185_ID: /* SMSC LAN83C185: PHY_ID1 = 0x0007, PHY_ID2 = 0xC0A1 */
8825 @@ -1246,3 +1256,4 @@ module_exit(at91ether_exit)
8826 MODULE_LICENSE("GPL");
8827 MODULE_DESCRIPTION("AT91RM9200 EMAC Ethernet driver");
8828 MODULE_AUTHOR("Andrew Victor");
8829 +MODULE_ALIAS("platform:" DRV_NAME);
8830 --- a/drivers/net/arm/at91_ether.h
8831 +++ b/drivers/net/arm/at91_ether.h
8833 /* Altima AC101L PHY */
8834 #define MII_AC101L_ID 0x00225520
8836 +/* Micrel KSZ8041 PHY */
8837 +#define MII_KSZ8041_ID 0x00221510
8839 /* Micrel KS8721 PHY */
8840 #define MII_KS8721_ID 0x00221610
8842 @@ -84,7 +87,6 @@ struct recv_desc_bufs
8846 - struct net_device_stats stats;
8847 struct mii_if_info mii; /* ethtool support */
8848 struct at91_eth_data board_data; /* board-specific configuration */
8849 struct clk *ether_clk; /* clock */
8851 +++ b/drivers/net/arm/ks8695_ether.c
8854 + * Ethernet driver for the Kendin/Micrel KS8695.
8856 + * Copyright (C) 2006 Andrew Victor
8858 + * This program is free software; you can redistribute it and/or
8859 + * modify it under the terms of the GNU General Public License
8860 + * as published by the Free Software Foundation; either version
8861 + * 2 of the License, or (at your option) any later version.
8864 +#include <linux/module.h>
8865 +#include <linux/init.h>
8866 +#include <linux/mii.h>
8867 +#include <linux/netdevice.h>
8868 +#include <linux/etherdevice.h>
8869 +#include <linux/skbuff.h>
8870 +#include <linux/dma-mapping.h>
8871 +#include <linux/delay.h>
8872 +#include <linux/ethtool.h>
8873 +#include <linux/platform_device.h>
8875 +#include <asm/io.h>
8876 +#include <asm/mach/irq.h>
8877 +#include <asm/uaccess.h>
8878 +#include <asm/arch/regs-wan.h>
8879 +#include <asm/arch/regs-lan.h>
8880 +#include <asm/arch/regs-hpna.h>
8881 +#include <asm/arch/regs-switch.h>
8882 +#include <asm/arch/regs-misc.h>
8884 +#include <asm/arch/regs-irq.h>
8886 +#include "ks8695_ether.h"
8889 +#define DRV_NAME "ks8695_ether"
8890 +#define DRV_VERSION "0.01"
8892 +/* ..................................................................... */
8894 +static inline unsigned long ks8695_read(struct net_device *dev, unsigned int reg)
8896 + return __raw_readl(dev->base_addr + reg);
8899 +static inline void ks8695_write(struct net_device *dev, unsigned int reg, unsigned long value)
8901 + __raw_writel(value, dev->base_addr + reg);
8905 +/* ......................... ADDRESS MANAGEMENT ........................ */
8907 +#define KS8695_NR_ADDRESSES 16
8910 + * Add the specified multicast addresses to the Additional Station
8911 + * Address registers.
8913 +static void ks8695_set_mcast_address(struct net_device *dev, struct dev_mc_list *addr, int nr_addr)
8915 + unsigned long low, high;
8918 + /* Set multicast addresses in Additional Station Address registers */
8919 + for (i = 0; i < nr_addr; i++, addr = addr->next) {
8920 + if (!addr) break; /* unexpected end of list */
8921 + else if (i == KS8695_NR_ADDRESSES) break; /* too many addresses */
8923 + low = (addr->dmi_addr[2] << 24) | (addr->dmi_addr[3] << 16) | (addr->dmi_addr[4] << 8) | (addr->dmi_addr[5]);
8924 + high = (addr->dmi_addr[0] << 8) | (addr->dmi_addr[1]);
8926 + ks8695_write(dev, KS8695_WMAAL_(i), low);
8927 + ks8695_write(dev, KS8695_WMAAH_(i), WMAAH_E | high);
8930 + /* Clear the remaining Additional Station Addresses */
8931 + for (; i < KS8695_NR_ADDRESSES; i++) {
8932 + ks8695_write(dev, KS8695_WMAAL_(i), 0);
8933 + ks8695_write(dev, KS8695_WMAAH_(i), 0);
8938 + * Enable/Disable promiscuous and multicast modes.
8940 +static void ks8695eth_set_multi(struct net_device *dev)
8942 + unsigned long ctrl;
8944 + ctrl = ks8695_read(dev, KS8695_WMDRXC);
8946 + if (dev->flags & IFF_PROMISC) /* enable promiscuous mode */
8947 + ctrl |= WMDRXC_WMRA;
8948 + else if (dev->flags & ~IFF_PROMISC) /* disable promiscuous mode */
8949 + ctrl &= ~WMDRXC_WMRA;
8951 + if (dev->flags & IFF_ALLMULTI) /* enable all multicast mode */
8952 + ctrl |= WMDRXC_WMRM;
8953 + else if (dev->mc_count > KS8695_NR_ADDRESSES) /* more specific multicast addresses than can be handled in hardware */
8954 + ctrl |= WMDRXC_WMRM;
8955 + else if (dev->mc_count > 0) { /* enable specific multicasts */
8956 + ctrl &= ~WMDRXC_WMRM;
8957 + ks8695_set_mcast_address(dev, dev->mc_list, dev->mc_count);
8959 + else if (dev->flags & ~IFF_ALLMULTI) { /* disable multicast mode */
8960 + ctrl &= ~WMDRXC_WMRM;
8961 + ks8695_set_mcast_address(dev, NULL, 0);
8964 + ks8695_write(dev, KS8695_WMDRXC, ctrl);
8968 + * Program the hardware MAC address from dev->dev_addr.
8970 +static void update_mac_address(struct net_device *dev)
8972 + unsigned long low, high;
8974 + low = (dev->dev_addr[2] << 24) | (dev->dev_addr[3] << 16) | (dev->dev_addr[4] << 8) | (dev->dev_addr[5]);
8975 + high = (dev->dev_addr[0] << 8) | (dev->dev_addr[1]);
8977 + ks8695_write(dev, KS8695_WMAL, low);
8978 + ks8695_write(dev, KS8695_WMAH, high);
8982 + * Store the new hardware address in dev->dev_addr, and update the MAC.
8984 +static int ks8695eth_set_mac(struct net_device *dev, void* addr)
8986 + struct sockaddr *address = addr;
8987 + DECLARE_MAC_BUF(mac);
8989 + if (!is_valid_ether_addr(address->sa_data))
8990 + return -EADDRNOTAVAIL;
8992 + memcpy(dev->dev_addr, address->sa_data, dev->addr_len);
8993 + update_mac_address(dev);
8995 + printk("%s: Setting MAC address to %s\n", dev->name, print_mac(mac, dev->dev_addr));
9001 + * Retrieve the MAC address set by the bootloader.
9003 +static void __init get_mac_address(struct net_device *dev)
9005 + unsigned char addr[6];
9006 + unsigned long low, high;
9008 + low = ks8695_read(dev, KS8695_WMAL);
9009 + high = ks8695_read(dev, KS8695_WMAH);
9011 + addr[0] = (high & 0xff00) >> 8;
9012 + addr[1] = (high & 0xff);
9013 + addr[2] = (low & 0xff000000) >> 24;
9014 + addr[3] = (low & 0xff0000) >> 16;
9015 + addr[4] = (low & 0xff00) >> 8;
9016 + addr[5] = (low & 0xff);
9018 + if (is_valid_ether_addr(addr))
9019 + memcpy(dev->dev_addr, &addr, 6);
9023 +/* ......................... ETHTOOL SUPPORT ........................... */
9026 + * Get device-specific settings.
9028 +static int ks8695eth_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
9030 + unsigned long ctrl;
9032 + /* the defaults for all ports */
9033 + cmd->supported = SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full
9034 + | SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full
9035 + | SUPPORTED_TP | SUPPORTED_MII;
9036 + cmd->advertising = ADVERTISED_TP | ADVERTISED_MII;
9037 + cmd->port = PORT_MII;
9038 + cmd->transceiver = XCVR_INTERNAL;
9040 + if (dev->base_addr == KS8695_HPNA_VA) {
9041 + cmd->phy_address = 0;
9042 + cmd->autoneg = AUTONEG_DISABLE; /* not supported for HPNA */
9044 + ctrl = __raw_readl(KS8695_MISC_VA + KS8695_HMC);
9045 + cmd->speed = (ctrl & HMC_HSS) ? SPEED_100 : SPEED_10;
9046 + cmd->duplex = (ctrl & HMC_HDS) ? DUPLEX_FULL : DUPLEX_HALF;
9048 + else if (dev->base_addr == KS8695_WAN_VA) {
9049 + cmd->supported |= (SUPPORTED_Autoneg | SUPPORTED_Pause);
9050 + cmd->phy_address = 0;
9052 + ctrl = __raw_readl(KS8695_MISC_VA + KS8695_WMC);
9053 + if ((ctrl & WMC_WAND) == 0) { /* auto-negotiation is enabled */
9054 + cmd->advertising |= ADVERTISED_Autoneg;
9055 + if (ctrl & WMC_WANA100F)
9056 + cmd->advertising |= ADVERTISED_100baseT_Full;
9057 + if (ctrl & WMC_WANA100H)
9058 + cmd->advertising |= ADVERTISED_100baseT_Half;
9059 + if (ctrl & WMC_WANA10F)
9060 + cmd->advertising |= ADVERTISED_10baseT_Full;
9061 + if (ctrl & WMC_WANA10H)
9062 + cmd->advertising |= ADVERTISED_10baseT_Half;
9063 + if (ctrl & WMC_WANAP)
9064 + cmd->advertising |= ADVERTISED_Pause;
9065 + cmd->autoneg = AUTONEG_ENABLE;
9067 + cmd->speed = (ctrl & WMC_WSS) ? SPEED_100 : SPEED_10;
9068 + cmd->duplex = (ctrl & WMC_WDS) ? DUPLEX_FULL : DUPLEX_HALF;
9070 + else { /* auto-negotiation is disabled */
9071 + cmd->autoneg = AUTONEG_DISABLE;
9073 + cmd->speed = (ctrl & WMC_WANF100) ? SPEED_100 : SPEED_10;
9074 + cmd->duplex = (ctrl & WMC_WANFF) ? DUPLEX_FULL : DUPLEX_HALF;
9077 + else if (dev->base_addr == KS8695_LAN_VA) {
9078 + // TODO: Implement for Switch ports
9085 + * Set device-specific settings.
9087 +static int ks8695eth_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
9089 + unsigned long ctrl;
9091 + if ((cmd->speed != SPEED_10) && (cmd->speed != SPEED_100))
9093 + if ((cmd->duplex != DUPLEX_HALF) && (cmd->duplex != DUPLEX_FULL))
9095 + if (cmd->port != PORT_MII)
9097 + if (cmd->transceiver != XCVR_INTERNAL)
9099 + if ((cmd->autoneg != AUTONEG_DISABLE) && (cmd->autoneg != AUTONEG_ENABLE))
9102 + if (cmd->autoneg == AUTONEG_ENABLE) {
9103 + if ((cmd->advertising & (ADVERTISED_10baseT_Half |
9104 + ADVERTISED_10baseT_Full |
9105 + ADVERTISED_100baseT_Half |
9106 + ADVERTISED_100baseT_Full)) == 0)
9109 + if (dev->base_addr == KS8695_HPNA_VA)
9110 + return -EINVAL; /* HPNA does not support auto-negotiation. */
9111 + else if (dev->base_addr == KS8695_WAN_VA) {
9112 + ctrl = __raw_readl(KS8695_MISC_VA + KS8695_WMC);
9114 + ctrl &= ~(WMC_WAND | WMC_WANA100F | WMC_WANA100H | WMC_WANA10F | WMC_WANA10H);
9115 + if (cmd->advertising & ADVERTISED_100baseT_Full)
9116 + ctrl |= WMC_WANA100F;
9117 + if (cmd->advertising & ADVERTISED_100baseT_Half)
9118 + ctrl |= WMC_WANA100H;
9119 + if (cmd->advertising & ADVERTISED_10baseT_Full)
9120 + ctrl |= WMC_WANA10F;
9121 + if (cmd->advertising & ADVERTISED_10baseT_Half)
9122 + ctrl |= WMC_WANA10H;
9124 + ctrl |= WMC_WANR; /* force a re-negotiation */
9125 + __raw_writel(ctrl, KS8695_MISC_VA + KS8695_WMC);
9127 + else if (dev->base_addr == KS8695_LAN_VA) {
9128 + // TODO: Implement for Switch ports
9133 + if (dev->base_addr == KS8695_HPNA_VA) {
9134 + ctrl = __raw_readl(KS8695_MISC_VA + KS8695_HMC);
9136 + ctrl &= ~(HMC_HSS | HMC_HDS);
9137 + if (cmd->speed == SPEED_100)
9139 + if (cmd->duplex == DUPLEX_FULL)
9142 + __raw_writel(ctrl, KS8695_MISC_VA + KS8695_HMC);
9144 + else if (dev->base_addr == KS8695_WAN_VA) {
9145 + ctrl = __raw_readl(KS8695_MISC_VA + KS8695_WMC);
9147 + ctrl |= WMC_WAND; /* disable auto-negotiation */
9148 + ctrl &= ~(WMC_WANF100 | WMC_WANFF);
9149 + if (cmd->speed == SPEED_100)
9150 + ctrl |= WMC_WANF100;
9151 + if (cmd->duplex == DUPLEX_FULL)
9152 + ctrl |= WMC_WANFF;
9154 + __raw_writel(ctrl, KS8695_MISC_VA + KS8695_WMC);
9156 + else if (dev->base_addr == KS8695_LAN_VA) {
9157 + // TODO: Implement for Switch ports
9165 + * Restart the auto-negotiation.
9167 +static int ks8695eth_nwayreset(struct net_device *dev)
9169 + unsigned long ctrl;
9171 + if (dev->base_addr == KS8695_HPNA_VA) /* HPNA has no auto-negotiation */
9173 + else if (dev->base_addr == KS8695_WAN_VA) {
9174 + ctrl = __raw_readl(KS8695_MISC_VA + KS8695_WMC);
9176 + if ((ctrl & WMC_WAND) == 0)
9177 + __raw_writel(ctrl | WMC_WANR, KS8695_MISC_VA + KS8695_WMC);
9179 + return -EINVAL; /* auto-negitiation not enabled */
9181 + else if (dev->base_addr == KS8695_LAN_VA) {
9182 + // TODO: Implement for Switch ports
9188 +static void ks8695eth_get_pause(struct net_device *dev, struct ethtool_pauseparam *param)
9190 + unsigned long ctrl;
9192 + if (dev->base_addr == KS8695_HPNA_VA)
9194 + else if (dev->base_addr == KS8695_WAN_VA) {
9195 + ctrl = __raw_readl(KS8695_MISC_VA + KS8695_WMC); /* advertise Pause */
9196 + param->autoneg = (ctrl & WMC_WANAP);
9198 + ctrl = ks8695_read(dev, KS8695_WMDRXC); /* current Tx Flow-control */
9199 + param->rx_pause = (ctrl & WMDRXC_WMRFCE);
9201 + ctrl = ks8695_read(dev, KS8695_WMDRXC); /* current Rx Flow-control */
9202 + param->tx_pause = (ctrl & WMDTXC_WMTFCE);
9204 + else if (dev->base_addr == KS8695_LAN_VA) {
9205 + // TODO: Implement for Switch ports
9209 +static int ks8695eth_set_pause(struct net_device *dev, struct ethtool_pauseparam *param)
9216 +static u32 ks8695eth_get_link(struct net_device *dev)
9218 + unsigned long ctrl;
9220 + if (dev->base_addr == KS8695_HPNA_VA)
9221 + return 1; /* HPNA always has link */
9222 + else if (dev->base_addr == KS8695_WAN_VA) {
9223 + ctrl = __raw_readl(KS8695_MISC_VA + KS8695_WMC);
9224 + return (ctrl & WMC_WLS);
9226 + else if (dev->base_addr == KS8695_LAN_VA) {
9227 + // TODO: Implement for Switch ports
9234 + * Report driver information.
9236 +static void ks8695eth_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
9238 + strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
9239 + strlcpy(info->version, DRV_VERSION, sizeof(info->version));
9240 + strlcpy(info->bus_info, dev->dev.parent->bus_id, sizeof(info->bus_info));
9243 +static struct ethtool_ops ks8695eth_ethtool_ops = {
9244 + .get_settings = ks8695eth_get_settings,
9245 + .set_settings = ks8695eth_set_settings,
9246 + .get_drvinfo = ks8695eth_get_drvinfo,
9247 + .nway_reset = ks8695eth_nwayreset,
9248 + .get_pauseparam = ks8695eth_get_pause,
9249 + .set_pauseparam = ks8695eth_set_pause,
9250 + .get_link = ks8695eth_get_link,
9254 +/* ................................ MAC ................................ */
9257 + * Setup the RX DMA descriptors, and enable and start the DMA receiver.
9259 +static void ks8695eth_start_rx(struct net_device *dev)
9261 + struct ks8695eth_priv *lp = (struct ks8695eth_priv *) dev->priv;
9262 + unsigned long ctrl;
9265 + /* Setup the DMA descriptors */
9266 + for (i = 0; i < MAX_RX_DESC; i++) {
9267 + lp->rxdma[i].length = MAX_RXBUF_SIZE;
9268 + lp->rxdma[i].addr = (unsigned long) lp->rxSkb[i].dma;
9269 + lp->rxdma[i].next = (unsigned long) lp->rxdma_phys + (sizeof(struct rx_descriptor) * (i+1));
9270 + lp->rxdma[i].status = RDES_OWN;
9273 + /* Create ring of DMA descriptors */
9274 + lp->rxdma[MAX_RX_DESC-1].next = (unsigned long) lp->rxdma_phys; /* phys address of 1st descriptor */
9276 + /* Reset receive index (since hardware was reset) */
9279 + /* Program address of 1st descriptor in KS8695 */
9280 + ks8695_write(dev, KS8695_WRDLB, (unsigned long) lp->rxdma_phys);
9282 + /* Enable and start the DMA Receiver */
9283 + ctrl = ks8695_read(dev, KS8695_WMDRXC);
9284 + ks8695_write(dev, KS8695_WMDRXC, ctrl | WMDRXC_WMRE);
9285 + ks8695_write(dev, KS8695_WMDRSC, 0);
9289 + * Stop the DMA receiver.
9291 +static void ks8695eth_stop_rx(struct net_device *dev)
9293 + unsigned long ctrl;
9295 + /* Disable receive DMA */
9296 + ctrl = ks8695_read(dev, KS8695_WMDRXC);
9297 + ks8695_write(dev, KS8695_WMDRXC, ctrl & ~WMDRXC_WMRE);
9301 + * Setup the TX DMA descriptors, and enable DMA transmitter.
9303 +static void ks8695eth_start_tx(struct net_device *dev)
9305 + struct ks8695eth_priv *lp = (struct ks8695eth_priv *) dev->priv;
9306 + unsigned long ctrl;
9309 + /* Setup the DMA descriptors */
9310 + for (i = 0; i < MAX_TX_DESC; i++) {
9311 + lp->txdma[i].ownership = 0;
9312 + lp->txdma[i].status = 0;
9313 + lp->txdma[i].addr = 0;
9314 + lp->txdma[i].next = (unsigned long) lp->txdma_phys + (sizeof(struct tx_descriptor) * (i+1));
9317 + /* Create ring of DMA descriptors */
9318 + lp->txdma[MAX_TX_DESC-1].next = (unsigned long) lp->txdma_phys; /* phys address of 1st desc */
9320 + /* Reset transmit indexes (since hardware was reset) */
9324 + /* Program address of 1st descriptor in KS8695 */
9325 + ks8695_write(dev, KS8695_WTDLB, (unsigned long) lp->txdma_phys);
9327 + /* Enable the DMA transmitter (will be started on first packet) */
9328 + ctrl = ks8695_read(dev, KS8695_WMDTXC);
9329 + ks8695_write(dev, KS8695_WMDTXC, ctrl | WMDTXC_WMTE);
9333 + * Stop the DMA transmitter.
9335 +static void ks8695eth_stop_tx(struct net_device *dev)
9337 + struct ks8695eth_priv *lp = (struct ks8695eth_priv *) dev->priv;
9338 + unsigned long ctrl;
9341 + /* Disable transmit DMA */
9342 + ctrl = ks8695_read(dev, KS8695_WMDTXC);
9343 + ks8695_write(dev, KS8695_WMDTXC, ctrl & ~WMDTXC_WMTE);
9345 + /* Clear any pending skb's still on transmit queue */
9346 + for (i = 0; i < MAX_TX_DESC; i++) {
9347 + lp->txdma[i].ownership = 0;
9348 + lp->txdma[i].status = 0;
9349 + lp->txdma[i].addr = 0;
9351 + if (lp->txSkb[i].skb) {
9352 + dma_unmap_single(lp->dev, lp->txSkb[i].dma, lp->txSkb[i].length, DMA_TO_DEVICE);
9353 + dev_kfree_skb_irq(lp->txSkb[i].skb);
9354 + lp->txSkb[i].skb = NULL;
9360 + * Reset the MAC hardware.
9362 +static void ks8695eth_hw_reset(struct net_device *dev)
9364 + /* Perform hardware reset */
9365 + ks8695_write(dev, KS8695_WMDTXC, WMDTXC_WMTRST);
9366 + while (ks8695_read(dev, KS8695_WMDTXC) & WMDTXC_WMTRST) { barrier(); }
9368 + /* Initialize the hardware */
9369 + ks8695_write(dev, KS8695_WMDRXC, WMDRXC_WMRU | WMDRXC_WMRB); /* RX: receive Unicast & Broadcast */
9370 + ks8695_write(dev, KS8695_WMDTXC, WMDTXC_WMTEP | WMDTXC_WMTAC); /* TX: add Padding & CRC */
9372 + // TODO: Can set Rx/Tx PBL: (Micrel using 8)
9373 + // TODO: Enable hardware checksumming.
9374 + // TODO: Enable Rx/Tx flow-control
9378 + * Enable or Disable the IRQs associated with a network interface.
9380 +static void ks8695eth_set_irq(struct net_device *dev, short enable)
9382 + struct ks8695eth_priv *lp = (struct ks8695eth_priv *) dev->priv;
9385 + for (i = 0; i < NR_IRQS; i++) {
9386 + if (lp->irqs & (1 << i)) {
9396 + * Open the ethernet interface.
9398 +static int ks8695eth_open(struct net_device *dev)
9400 + if (!is_valid_ether_addr(dev->dev_addr))
9401 + return -EADDRNOTAVAIL;
9403 + /* MUST reset hardware in _open() */
9404 + ks8695eth_hw_reset(dev);
9406 + /* Update the MAC address (incase user has changed it) */
9407 + update_mac_address(dev);
9410 + ks8695eth_start_tx(dev);
9411 + ks8695eth_start_rx(dev);
9413 + /* Enable interrupts */
9414 + ks8695eth_set_irq(dev, 1);
9416 + netif_start_queue(dev);
9421 + * Close the ethernet interface.
9423 +static int ks8695eth_close(struct net_device *dev)
9426 + ks8695eth_stop_rx(dev);
9427 + ks8695eth_stop_tx(dev);
9429 + /* Disable interrupts */
9430 + ks8695eth_set_irq(dev, 0);
9432 + netif_stop_queue(dev);
9437 + * Return the current statistics.
9439 +static struct net_device_stats *ks8695eth_stats(struct net_device *dev)
9441 + return &dev->stats;
9445 + * Queue a packet for transmission in next TX DMA descriptor.
9447 +static int ks8695eth_xmit_frame(struct sk_buff *skb, struct net_device *dev)
9449 + struct ks8695eth_priv *lp = (struct ks8695eth_priv *) dev->priv;
9452 + /* Packets are added to head of array */
9455 + /* Store packet information */
9456 + lp->txSkb[i].skb = skb;
9457 + lp->txSkb[i].length = skb->len;
9458 + lp->txSkb[i].dma = dma_map_single(lp->dev, skb->data, skb->len, DMA_TO_DEVICE);
9460 + spin_lock_irq(&lp->tx_lock);
9462 + /* Set Tx descriptor information */
9463 + lp->txdma[i].addr = lp->txSkb[i].dma;
9464 + lp->txdma[i].status = TDES_IC | TDES_FS | TDES_LS | (lp->txSkb[i].length & TDES_TBS);
9465 + lp->txdma[i].ownership = TDES_OWN;
9467 + /* Start the DMA transmitter (if necessary) */
9468 + ks8695_write(dev, KS8695_WMDTSC, 0);
9470 + lp->tx_head = (lp->tx_head + 1) % MAX_TX_DESC;
9471 + if (lp->tx_head == lp->tx_tail) /* no more descriptors */
9472 + netif_stop_queue(dev);
9474 + spin_unlock_irq(&lp->tx_lock);
9476 + dev->trans_start = jiffies;
9480 +/* ..................................................................... */
9483 + * The link state of the WAN port has changed.
9484 + * (Called from interrupt context)
9486 +static void ks8695eth_wan_link(struct net_device *dev)
9488 + unsigned long ctrl;
9490 + ctrl = __raw_readl(KS8695_MISC_VA + KS8695_WMC);
9491 + if (ctrl & WMC_WLS) {
9492 + netif_carrier_on(dev);
9493 + printk(KERN_INFO "%s: Link is now %s-%s\n", dev->name,
9494 + (ctrl & WMC_WSS) ? "100" : "10",
9495 + (ctrl & WMC_WDS) ? "FullDuplex" : "HalfDuplex");
9498 + netif_carrier_off(dev);
9499 + printk(KERN_INFO "%s: Link down.\n", dev->name);
9503 +/* ..................................................................... */
9506 + * A frame has been received. Exteract from buffer descriptor and deliver to
9508 + * (Called from interrupt context)
9510 +static void ks8695eth_rx_interrupt(struct net_device *dev)
9512 + struct ks8695eth_priv *lp = (struct ks8695eth_priv *) dev->priv;
9513 + struct sk_buff *skb;
9514 + unsigned long flags;
9515 + unsigned int pktlen;
9517 + while (!(lp->rxdma[lp->rx_idx].status & RDES_OWN)) {
9518 + flags = lp->rxdma[lp->rx_idx].status;
9520 + if ((flags & (RDES_FS | RDES_LS)) != (RDES_FS | RDES_LS)) {
9521 + printk(KERN_ERR "%s: Spanning packet detected\n", dev->name);
9525 + /* handle errors */
9526 + if (flags & (RDES_ES | RDES_RE)) {
9527 + dev->stats.rx_errors++;
9529 + if (flags & RDES_TL) /* Frame too long */
9530 + dev->stats.rx_length_errors++;
9531 + else if (flags & RDES_RF) /* Runt frame */
9532 + dev->stats.rx_length_errors++;
9533 + else if (flags & RDES_CE) /* CRC error */
9534 + dev->stats.rx_crc_errors++;
9535 + else if (flags & RDES_RE) /* MII error */
9536 + dev->stats.rx_missed_errors++;
9537 + // TODO: If hardware checksumming, then check IP/TCP/UDP errors.
9542 + pktlen = flags & RDES_FLEN;
9543 + pktlen = pktlen - 4; /* remove CRC */
9545 + // OLD CALL: consistent_sync(lp->rxSkb[lp->rx_idx].skb->data, MAX_RXBUF_SIZE, DMA_FROM_DEVICE);
9546 + dma_sync_single_for_cpu(lp->dev, lp->rxSkb[lp->rx_idx].dma, MAX_RXBUF_SIZE, DMA_FROM_DEVICE);
9548 + skb = dev_alloc_skb(pktlen+2); /* +2 to align IP header */
9550 + dev->stats.rx_dropped++;
9551 + printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name);
9555 + skb_reserve(skb, 2); /* align IP header */
9556 + memcpy(skb_put(skb, pktlen), lp->rxSkb[lp->rx_idx].skb->data, pktlen);
9558 + skb->protocol = eth_type_trans(skb, dev);
9561 + /* update statistics */
9562 + dev->stats.rx_packets++;
9563 + dev->stats.rx_bytes += pktlen;
9564 + if (flags & RDES_MF)
9565 + dev->stats.multicast++;
9566 + dev->last_rx = jiffies;
9569 + lp->rxdma[lp->rx_idx].status = RDES_OWN; /* reset ownership bit */
9571 + lp->rx_idx = (lp->rx_idx + 1) % MAX_RX_DESC; /* next descriptor */
9574 + /* restart DMA receiver incase it was suspended */
9575 + ks8695_write(dev, KS8695_WMDRSC, 0);
9579 + * A packet has been transmitted.
9580 + * (Called from interrupt context)
9582 +static void ks8695eth_tx_interrupt(struct net_device *dev)
9584 + struct ks8695eth_priv *lp = (struct ks8695eth_priv *) dev->priv;
9587 + /* Packets are removed from tail of array */
9590 + // TODO: Loop through multiple times?
9592 + if (lp->txSkb[i].skb) {
9593 + /* update statistics */
9594 + dev->stats.tx_packets++;
9595 + dev->stats.tx_bytes += lp->txSkb[i].length;
9598 + dma_unmap_single(lp->dev, lp->txSkb[i].dma, lp->txSkb[i].length, DMA_TO_DEVICE);
9599 + dev_kfree_skb_irq(lp->txSkb[i].skb);
9600 + lp->txSkb[i].skb = NULL;
9602 + /* Not necessary to clear descriptor since we still own it */
9605 + lp->tx_tail = (lp->tx_tail + 1) % MAX_TX_DESC;
9607 + netif_wake_queue(dev);
9611 + * MAC interrupt handler
9613 +static irqreturn_t ks8695eth_interrupt(int irq, void *dev_id)
9615 + struct net_device *dev = (struct net_device *) dev_id;
9618 + case KS8695_IRQ_LAN_RX_STATUS:
9619 + case KS8695_IRQ_HPNA_RX_STATUS:
9620 + case KS8695_IRQ_WAN_RX_STATUS:
9621 + ks8695eth_rx_interrupt(dev);
9622 + return IRQ_HANDLED;
9624 + case KS8695_IRQ_LAN_TX_STATUS:
9625 + case KS8695_IRQ_HPNA_TX_STATUS:
9626 + case KS8695_IRQ_WAN_TX_STATUS:
9627 + ks8695eth_tx_interrupt(dev);
9628 + return IRQ_HANDLED;
9630 + case KS8695_IRQ_WAN_LINK:
9631 + ks8695eth_wan_link(dev);
9632 + return IRQ_HANDLED;
9640 +/* ..................................................................... */
9643 + * Initialize the WAN hardware to known defaults.
9645 +static void __init ks8695eth_init_wan(void)
9647 + unsigned long ctrl;
9649 + /* Support auto-negotiation */
9650 + ctrl = WMC_WANAP | WMC_WANA100F | WMC_WANA100H | WMC_WANA10F | WMC_WANA10H;
9652 + /* LED0 = Activity , LED1 = Link */
9653 + ctrl |= (WLED0S_ACTIVITY | WLED1S_LINK);
9655 + /* Restart Auto-negotiation */
9658 + __raw_writel(ctrl, KS8695_MISC_VA + KS8695_WMC);
9660 + __raw_writel(0, KS8695_MISC_VA + KS8695_WPPM);
9661 + __raw_writel(0, KS8695_MISC_VA + KS8695_PPS);
9665 + * Initialize the LAN Switch hardware to known defaults.
9667 +static void __init ks8695eth_init_switch(void)
9669 + unsigned long ctrl;
9671 + ctrl = 0x40819e00; /* default */
9673 + /* LED0 = Speed LED1 = Link/Activity */
9674 + ctrl &= ~(SEC0_LLED1S | SEC0_LLED0S);
9675 + ctrl |= (LLED0S_LINK | LLED1S_LINK_ACTIVITY);
9677 + /* Enable Switch */
9678 + ctrl |= SEC0_ENABLE;
9680 + __raw_writel(ctrl, KS8695_SWITCH_VA + KS8695_SEC0);
9682 + __raw_writel(0x9400100, KS8695_SWITCH_VA + KS8695_SEC1); /* reset defaults */
9685 +static int ks8695eth_hook_irqs(struct platform_device *pdev, struct net_device *dev, unsigned long *irqset)
9687 + struct resource *res;
9690 + while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, i))) {
9691 + set_irq_flags(res->start, IRQF_VALID | IRQF_NOAUTOEN);
9693 + ret = request_irq(res->start, ks8695eth_interrupt, IRQF_DISABLED | IRQF_SHARED, res->name, dev);
9695 + printk(KERN_ERR "%s: return_irq %u failed\n", dev->name, res->start);
9699 + *irqset |= (1 << res->start);
9701 + // TODO: Can set different priorities for interrupts [0x BB AA FF].
9709 +static int __init ks8695eth_probe(struct platform_device *pdev)
9711 + struct net_device *dev;
9712 + struct ks8695eth_priv *lp;
9713 + struct resource *res;
9714 + int i = 0, ret, size;
9715 + DECLARE_MAC_BUF(mac);
9717 + /* Create ethernet device */
9718 + dev = alloc_etherdev(sizeof(struct ks8695eth_priv));
9722 + /* Get I/O base address */
9723 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
9728 + dev->base_addr = res->start;
9730 + lp = (struct ks8695eth_priv *) dev->priv;
9732 + /* Retreive MAC address before the MAC registers are reset */
9733 + get_mac_address(dev);
9735 + /* Reset the hardware */
9736 + ks8695_write(dev, KS8695_WMDTXC, WMDTXC_WMTRST);
9737 + while (ks8695_read(dev, KS8695_WMDTXC) & WMDTXC_WMTRST) { barrier(); }
9740 + dev->irq = platform_get_irq(pdev, 0);
9741 + ret = ks8695eth_hook_irqs(pdev, dev, &lp->irqs);
9746 + /* Allocate DMA-able memory for Tx descriptor */
9747 + size = sizeof(struct tx_descriptor) * MAX_TX_DESC;
9748 + lp->txdma = dma_alloc_coherent(&pdev->dev, size, &lp->txdma_phys, GFP_KERNEL);
9749 + if (lp->txdma == NULL) {
9754 + memset(lp->txdma, 0, size);
9758 + /* Allocate DMA-able memory for Rx descriptor */
9759 + size = sizeof(struct rx_descriptor) * MAX_RX_DESC;
9760 + lp->rxdma = dma_alloc_coherent(&pdev->dev, size, &lp->rxdma_phys, GFP_KERNEL);
9761 + if (lp->rxdma == NULL) {
9763 + // Free TX descriptor memory.
9767 + memset(lp->rxdma, 0, size);
9770 + /* Allocate DMA-able memory for Rx Data */
9771 + for (i = 0; i < MAX_RX_DESC; i++) {
9772 + lp->rxSkb[i].skb = alloc_skb(MAX_RXBUF_SIZE, GFP_KERNEL);
9773 + if (lp->rxSkb[i].skb == NULL) {
9777 + lp->rxSkb[i].length = MAX_RXBUF_SIZE;
9778 + lp->rxSkb[i].dma = dma_map_single(&pdev->dev, lp->rxSkb[i].skb->data, MAX_RXBUF_SIZE, DMA_FROM_DEVICE);
9781 + spin_lock_init(&lp->tx_lock);
9783 + platform_set_drvdata(pdev, dev);
9786 + dev->open = ks8695eth_open;
9787 + dev->stop = ks8695eth_close;
9788 + dev->hard_start_xmit = ks8695eth_xmit_frame;
9789 + dev->get_stats = ks8695eth_stats;
9790 + dev->set_multicast_list = ks8695eth_set_multi;
9791 + dev->set_mac_address = ks8695eth_set_mac;
9792 + dev->ethtool_ops = &ks8695eth_ethtool_ops;
9794 + SET_NETDEV_DEV(dev, &pdev->dev);
9795 + lp->dev = &pdev->dev;
9797 + if (dev->base_addr == KS8695_WAN_VA)
9798 + ks8695eth_init_wan();
9799 + else if (dev->base_addr == KS8695_LAN_VA)
9800 + ks8695eth_init_switch();
9802 + /* Register the network interface */
9803 + ret = register_netdev(dev);
9807 +// dma_free_coherent(&pdev->dev, sizeof(struct ks8695_tx_dma), lp->txdma, lp->txdma_phys);
9808 +// dma_free_coherent(&pdev->dev, sizeof(struct ks8695_rx_dma), lp->rxdma, lp->rxdma_phys);
9812 + printk(KERN_INFO "%s: KS8695 ethernet (%s)\n", dev->name, print_mac(mac, dev->dev_addr));
9817 +static int __devexit ks8695eth_remove(struct platform_device *pdev)
9819 + struct net_device *dev = platform_get_drvdata(pdev);
9820 +// struct ks8695eth_priv *lp = (struct ks8695eth_priv *) dev->priv;
9822 + unregister_netdev(dev);
9825 +// dma_free_coherent(&pdev->dev, sizeof(struct ks8695_tx_dma), lp->txdma, lp->txdma_phys);
9826 +// dma_free_coherent(&pdev->dev, sizeof(struct ks8695_rx_dma), lp->rxdma, lp->rxdma_phys);
9828 + platform_set_drvdata(pdev, NULL);
9833 +static struct platform_driver ks8695ether_driver = {
9834 + .probe = ks8695eth_probe,
9835 + .remove = __devexit_p(ks8695eth_remove),
9840 + .owner = THIS_MODULE,
9845 +static int __init ks8695eth_init(void)
9847 + return platform_driver_register(&ks8695ether_driver);
9850 +static void __exit ks8695eth_exit(void)
9852 + platform_driver_unregister(&ks8695ether_driver);
9855 +module_init(ks8695eth_init);
9856 +module_exit(ks8695eth_exit);
9858 +MODULE_LICENSE("GPL");
9859 +MODULE_DESCRIPTION("KS8695 Ethernet driver");
9860 +MODULE_AUTHOR("Andrew Victor");
9861 +MODULE_ALIAS("platform:" DRV_NAME);
9863 +++ b/drivers/net/arm/ks8695_ether.h
9866 + * Ethernet driver for the Micrel/Kendin KS8695 (Centaur)
9868 + * (C) 2006 Andrew Victor
9872 +#ifndef KS8695_ETHERNET
9873 +#define KS8695_ETHERNET
9875 +/* .... Hardware Descriptors ................................................ */
9877 +struct rx_descriptor {
9878 + unsigned long status;
9879 + unsigned long length;
9880 + unsigned long addr;
9881 + unsigned long next;
9884 +#define RDES_OWN (1 << 31) /* Ownership */
9885 +#define RDES_FS (1 << 30) /* First Descriptor */
9886 +#define RDES_LS (1 << 29) /* Last Descriptor */
9887 +#define RDES_IPE (1 << 28) /* IP Checksum error */
9888 +#define RDES_TCPE (1 << 27) /* TCP Checksum error */
9889 +#define RDES_UDPE (1 << 26) /* UDP Checksum error */
9890 +#define RDES_ES (1 << 25) /* Error summary */
9891 +#define RDES_MF (1 << 24) /* Multicast Frame */
9892 +#define RDES_RE (1 << 19) /* MII Error reported */
9893 +#define RDES_TL (1 << 18) /* Frame too Long */
9894 +#define RDES_RF (1 << 17) /* Runt Frame */
9895 +#define RDES_CE (1 << 16) /* CRC error */
9896 +#define RDES_FT (1 << 15) /* Frame Type */
9897 +#define RDES_FLEN (0x7ff) /* Frame Length */
9899 +#define RDES_RER (1 << 25) /* Receive End of Ring */
9900 +#define RDES_RBS (0x7ff) /* Receive Buffer Size */
9903 +struct tx_descriptor {
9904 + unsigned long ownership;
9905 + unsigned long status;
9906 + unsigned long addr;
9907 + unsigned long next;
9910 +#define TDES_OWN (1 << 31) /* Ownership */
9912 +#define TDES_IC (1 << 31) /* Interrupt on Completion */
9913 +#define TDES_FS (1 << 30) /* First Segment */
9914 +#define TDES_LS (1 << 29) /* Last Segment */
9915 +#define TDES_IPCKG (1 << 28) /* IP Checksum generate */
9916 +#define TDES_TCPCKG (1 << 27) /* TCP Checksum generate */
9917 +#define TDES_UDPCKG (1 << 26) /* UDP Checksum generate */
9918 +#define TDES_TER (1 << 25) /* Transmit End of Ring */
9919 +#define TDES_TBS (0x7ff) /* Transmit Buffer Size */
9922 +/* .... ..................................................................... */
9924 +#define MAX_RX_DESC 16 /* number of receive descriptors */
9925 +#define MAX_TX_DESC 8 /* number of transmit descriptors */
9926 +#define MAX_RXBUF_SIZE 0x600 /* 1518 rounded-up */
9928 +struct ks8695_buffer
9930 + struct sk_buff *skb;
9932 + unsigned long length;
9936 +struct ks8695eth_priv
9938 + struct device *dev;
9939 + unsigned long irqs; /* IRQ bitset */
9942 + struct tx_descriptor *txdma; /* Tx DMA descriptors */
9943 + dma_addr_t txdma_phys; /* TX DMA descriptors (phys address) */
9944 + unsigned int tx_head; /* descriptor index (add) */
9945 + unsigned int tx_tail; /* descriptor index (remove) */
9946 + spinlock_t tx_lock;
9947 + struct ks8695_buffer txSkb[MAX_TX_DESC]; /* packets being transmitted */
9950 + struct rx_descriptor *rxdma; /* Rx DMA descriptors */
9951 + dma_addr_t rxdma_phys; /* Rx DMA descriptors (phys address) */
9952 + unsigned int rx_idx; /* descriptor index */
9953 + struct ks8695_buffer rxSkb[MAX_RX_DESC];
9957 --- a/drivers/rtc/Kconfig
9958 +++ b/drivers/rtc/Kconfig
9959 @@ -487,12 +487,12 @@ config RTC_DRV_AT91RM9200
9960 this is powered by the backup power supply.
9962 config RTC_DRV_AT91SAM9
9963 - tristate "AT91SAM9x"
9964 + tristate "AT91SAM9x or AT91CAP9"
9965 depends on ARCH_AT91 && !(ARCH_AT91RM9200 || ARCH_AT91X40)
9967 - RTC driver for the Atmel AT91SAM9x internal RTT (Real Time Timer).
9968 - These timers are powered by the backup power supply (such as a
9969 - small coin cell battery), but do not need to be used as RTCs.
9970 + RTC driver for the Atmel AT91SAM9x and AT91CAP9 internal RTT (Real
9971 + Time Timer). These timers are powered by the backup power supply
9972 + (such as a small coin cell battery), but do not need to be used as RTCs.
9974 (On AT91SAM9rl chips you probably want to use the dedicated RTC
9975 module and leave the RTT available for other uses.)
9976 --- a/drivers/rtc/rtc-at91rm9200.c
9977 +++ b/drivers/rtc/rtc-at91rm9200.c
9979 #include <linux/completion.h>
9981 #include <asm/uaccess.h>
9982 -#include <asm/rtc.h>
9984 -#include <asm/mach/time.h>
9986 #include <asm/arch/at91_rtc.h>
9988 @@ -307,12 +304,6 @@ static int __init at91_rtc_probe(struct
9992 - /* cpu init code should really have flagged this device as
9993 - * being wake-capable; if it didn't, do that here.
9995 - if (!device_can_wakeup(&pdev->dev))
9996 - device_init_wakeup(&pdev->dev, 1);
9998 rtc = rtc_device_register(pdev->name, &pdev->dev,
9999 &at91_rtc_ops, THIS_MODULE);
10001 --- a/drivers/rtc/rtc-at91sam9.c
10002 +++ b/drivers/rtc/rtc-at91sam9.c
10005 #include <asm/mach/time.h>
10006 #include <asm/arch/board.h>
10007 +#include <asm/arch/cpu.h>
10008 #include <asm/arch/at91_rtt.h>
10011 @@ -150,6 +151,9 @@ static int at91_rtc_settime(struct devic
10016 + * Read alarm time and date in RTC
10018 static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
10020 struct sam9_rtc *rtc = dev_get_drvdata(dev);
10021 @@ -176,6 +180,9 @@ static int at91_rtc_readalarm(struct dev
10026 + * Set alarm time and date in RTC
10028 static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
10030 struct sam9_rtc *rtc = dev_get_drvdata(dev);
10031 @@ -321,10 +328,6 @@ static int __init at91_rtc_probe(struct
10035 - /* platform setup code should have handled this; sigh */
10036 - if (!device_can_wakeup(&pdev->dev))
10037 - device_init_wakeup(&pdev->dev, 1);
10039 platform_set_drvdata(pdev, rtc);
10040 rtc->rtt = (void __force __iomem *) (AT91_VA_BASE_SYS - AT91_BASE_SYS);
10041 rtc->rtt += r->start;
10042 --- a/drivers/spi/Kconfig
10043 +++ b/drivers/spi/Kconfig
10044 @@ -113,6 +113,15 @@ config SPI_GPIO
10049 + tristate "AT91RM9200 Bitbang SPI Master"
10050 + depends on SPI_MASTER && ARCH_AT91RM9200 && !SPI_ATMEL && EXPERIMENTAL
10051 + select SPI_BITBANG
10053 + This is dumb PIO bitbanging driver for the Atmel AT91RM9200.
10054 + The SPI_ATMEL driver will be its replacement, using the native
10055 + SPI hardware and its DMA controller.
10058 tristate "Freescale iMX SPI controller"
10059 depends on SPI_MASTER && ARCH_IMX && EXPERIMENTAL
10060 --- a/drivers/spi/Makefile
10061 +++ b/drivers/spi/Makefile
10062 @@ -29,6 +29,7 @@ obj-$(CONFIG_SPI_S3C24XX) += spi_s3c24x
10063 obj-$(CONFIG_SPI_TXX9) += spi_txx9.o
10064 obj-$(CONFIG_SPI_XILINX) += xilinx_spi.o
10065 obj-$(CONFIG_SPI_SH_SCI) += spi_sh_sci.o
10066 +obj-$(CONFIG_SPI_AT91) += spi_at91_bitbang.o
10067 # ... add above this line ...
10069 # SPI protocol drivers (device/link on bus)
10071 +++ b/drivers/spi/spi_at91_bitbang.c
10074 + * at91_spi.c - at91 SPI driver (BOOTSTRAP/BITBANG VERSION)
10076 + * Copyright (C) 2006 David Brownell
10078 + * This program is free software; you can redistribute it and/or modify
10079 + * it under the terms of the GNU General Public License as published by
10080 + * the Free Software Foundation; either version 2 of the License, or
10081 + * (at your option) any later version.
10083 + * This program is distributed in the hope that it will be useful,
10084 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
10085 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10086 + * GNU General Public License for more details.
10088 + * You should have received a copy of the GNU General Public License
10089 + * along with this program; if not, write to the Free Software
10090 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
10092 +#include <linux/kernel.h>
10093 +#include <linux/init.h>
10094 +#include <linux/platform_device.h>
10096 +#include <linux/spi/spi.h>
10097 +#include <linux/spi/spi_bitbang.h>
10099 +#include <asm/arch/gpio.h>
10103 + * FIXME this bitbanging version is just to help bootstrap systems until
10104 + * there's a native SPI+IRQ+DMA controller driver ... such a driver should
10105 + * be a drop-in replacement for this one, and much faster.
10109 + * - other at91 parts (like at91sam9) have multiple controllers
10110 + * and different pin muxing; this version is at91rm9200 specfic.
10112 + * - at91sam9261 SPI0 pins are directly muxed with MMC/SD pins.
10114 + * - rm9200 spi chipselects drop wrongly, so the native driver
10115 + * will need to use gpios much like this does.
10117 + * - real hardware only allows 8..16 bits per word, while this
10118 + * bitbanger allows 1..32 (incompatible superset).
10120 + * - this disregards clock parameters. with inlined gpio calls,
10121 + * gcc 3.4.4 produces about 1.5 mbit/sec, more than 2x faster
10122 + * than using the subroutined veresion from txrx_word().
10124 + * - suspend/resume and <linux/clk.h> support is missing ...
10127 +#define spi_miso_bit AT91_PIN_PA0
10128 +#define spi_mosi_bit AT91_PIN_PA1
10129 +#define spi_sck_bit AT91_PIN_PA2
10132 + struct spi_bitbang bitbang;
10133 + struct platform_device *pdev;
10136 +/*----------------------------------------------------------------------*/
10138 +static inline void setsck(struct spi_device *spi, int is_on)
10140 + at91_set_gpio_value(spi_sck_bit, is_on);
10143 +static inline void setmosi(struct spi_device *spi, int is_on)
10145 + at91_set_gpio_value(spi_mosi_bit, is_on);
10148 +static inline int getmiso(struct spi_device *spi)
10150 + return at91_get_gpio_value(spi_miso_bit);
10153 +static void at91_spi_chipselect(struct spi_device *spi, int is_active)
10155 + unsigned long cs = (unsigned long) spi->controller_data;
10157 + /* set default clock polarity */
10159 + setsck(spi, spi->mode & SPI_CPOL);
10161 + /* only support active-low (default) */
10162 + at91_set_gpio_value(cs, !is_active);
10166 + * NOTE: this is "as fast as we can"; it should be a function of
10167 + * the device clock ...
10169 +#define spidelay(X) do{} while(0)
10171 +#define EXPAND_BITBANG_TXRX
10172 +#include <linux/spi/spi_bitbang.h>
10174 +static u32 at91_spi_txrx_word_mode0(struct spi_device *spi,
10175 + unsigned nsecs, u32 word, u8 bits)
10177 + return bitbang_txrx_be_cpha0(spi, nsecs, 0, word, 8);
10180 +static u32 at91_spi_txrx_word_mode1(struct spi_device *spi,
10181 + unsigned nsecs, u32 word, u8 bits)
10183 + return bitbang_txrx_be_cpha1(spi, nsecs, 0, word, 8);
10186 +static u32 at91_spi_txrx_word_mode2(struct spi_device *spi,
10187 + unsigned nsecs, u32 word, u8 bits)
10189 + return bitbang_txrx_be_cpha0(spi, nsecs, 1, word, 8);
10192 +static u32 at91_spi_txrx_word_mode3(struct spi_device *spi,
10193 + unsigned nsecs, u32 word, u8 bits)
10195 + return bitbang_txrx_be_cpha1(spi, nsecs, 1, word, 8);
10198 +/*----------------------------------------------------------------------*/
10200 +static int __init at91_spi_probe(struct platform_device *pdev)
10203 + struct spi_master *master;
10204 + struct at91_spi *at91_spi;
10206 + if (pdev->id != 0) /* SPI0 bus */
10209 + master = spi_alloc_master(&pdev->dev, sizeof *at91_spi);
10213 + at91_spi = spi_master_get_devdata(master);
10214 + at91_spi->pdev = pdev;
10215 + platform_set_drvdata(pdev, at91_spi);
10217 + /* SPI and bitbang hookup */
10218 + master->bus_num = 0;
10219 + master->num_chipselect = 4;
10221 + at91_spi->bitbang.master = spi_master_get(master);
10222 + at91_spi->bitbang.chipselect = at91_spi_chipselect;
10223 + at91_spi->bitbang.txrx_word[SPI_MODE_0] = at91_spi_txrx_word_mode0;
10224 + at91_spi->bitbang.txrx_word[SPI_MODE_1] = at91_spi_txrx_word_mode1;
10225 + at91_spi->bitbang.txrx_word[SPI_MODE_2] = at91_spi_txrx_word_mode2;
10226 + at91_spi->bitbang.txrx_word[SPI_MODE_3] = at91_spi_txrx_word_mode3;
10228 + status = spi_bitbang_start(&at91_spi->bitbang);
10230 + (void) spi_master_put(at91_spi->bitbang.master);
10235 +static int __exit at91_spi_remove(struct platform_device *pdev)
10237 + struct at91_spi *at91_spi = platform_get_drvdata(pdev);
10240 + /* stop() unregisters child devices too */
10241 + status = spi_bitbang_stop(&at91_spi->bitbang);
10242 + (void) spi_master_put(at91_spi->bitbang.master);
10244 + platform_set_drvdata(pdev, NULL);
10248 +static struct platform_driver at91_spi_driver = {
10249 + .probe = at91_spi_probe,
10250 + .remove = __exit_p(at91_spi_remove),
10252 + .name = "at91_spi",
10253 + .owner = THIS_MODULE,
10257 +static int __init at91_spi_init(void)
10259 + at91_set_gpio_output(spi_sck_bit, 0);
10260 + at91_set_gpio_output(spi_mosi_bit, 0);
10261 + at91_set_gpio_input(spi_miso_bit, 1 /* pullup */);
10263 + /* register driver */
10264 + return platform_driver_register(&at91_spi_driver);
10267 +static void __exit at91_spi_exit(void)
10269 + platform_driver_unregister(&at91_spi_driver);
10272 +device_initcall(at91_spi_init);
10273 +module_exit(at91_spi_exit);
10275 +MODULE_ALIAS("at91_spi.0");
10277 +MODULE_DESCRIPTION("AT91 SPI support (BOOTSTRAP/BITBANG VERSION)");
10278 +MODULE_AUTHOR("David Brownell");
10279 +MODULE_LICENSE("GPL");
10280 +MODULE_ALIAS("platform:at91_spi");
10281 --- a/drivers/usb/gadget/Kconfig
10282 +++ b/drivers/usb/gadget/Kconfig
10283 @@ -118,10 +118,10 @@ config USB_AMD5536UDC
10284 config USB_GADGET_ATMEL_USBA
10285 boolean "Atmel USBA"
10286 select USB_GADGET_DUALSPEED
10288 + depends on AVR32 || ARCH_AT91CAP9 || ARCH_AT91SAM9RL
10290 USBA is the integrated high-speed USB Device controller on
10291 - the AT32AP700x processors from Atmel.
10292 + the AT32AP700x, some AT91SAM9 and AT91CAP9 processors from Atmel.
10294 config USB_ATMEL_USBA
10296 --- a/drivers/usb/gadget/at91_udc.c
10297 +++ b/drivers/usb/gadget/at91_udc.c
10298 @@ -1827,7 +1827,7 @@ static int at91udc_suspend(struct platfo
10300 if ((!udc->suspended && udc->addr)
10302 - || at91_suspend_entering_slow_clock()) {
10303 + || clk_must_disable(udc->fclk)) {
10307 --- a/drivers/usb/gadget/atmel_usba_udc.c
10308 +++ b/drivers/usb/gadget/atmel_usba_udc.c
10310 #include <linux/platform_device.h>
10311 #include <linux/usb/ch9.h>
10312 #include <linux/usb/gadget.h>
10313 +#include <linux/usb/atmel_usba_udc.h>
10314 #include <linux/delay.h>
10316 #include <asm/gpio.h>
10320 static struct usba_udc the_udc;
10321 +static struct usba_ep *usba_ep;
10323 #ifdef CONFIG_USB_GADGET_DEBUG_FS
10324 #include <linux/debugfs.h>
10325 @@ -324,53 +326,6 @@ static int vbus_is_present(struct usba_u
10329 -static void copy_to_fifo(void __iomem *fifo, const void *buf, int len)
10331 - unsigned long tmp;
10333 - DBG(DBG_FIFO, "copy to FIFO (len %d):\n", len);
10334 - for (; len > 0; len -= 4, buf += 4, fifo += 4) {
10335 - tmp = *(unsigned long *)buf;
10337 - DBG(DBG_FIFO, " -> %08lx\n", tmp);
10338 - __raw_writel(tmp, fifo);
10341 - DBG(DBG_FIFO, " -> %02lx\n", tmp >> 24);
10342 - __raw_writeb(tmp >> 24, fifo);
10351 -static void copy_from_fifo(void *buf, void __iomem *fifo, int len)
10354 - unsigned long *w;
10355 - unsigned char *b;
10357 - unsigned long tmp;
10359 - DBG(DBG_FIFO, "copy from FIFO (len %d):\n", len);
10360 - for (p.w = buf; len > 0; len -= 4, p.w++, fifo += 4) {
10362 - tmp = __raw_readl(fifo);
10364 - DBG(DBG_FIFO, " -> %08lx\n", tmp);
10367 - tmp = __raw_readb(fifo);
10369 - DBG(DBG_FIFO, " -> %02lx\n", tmp);
10376 static void next_fifo_transaction(struct usba_ep *ep, struct usba_request *req)
10378 unsigned int transaction_len;
10379 @@ -387,7 +342,7 @@ static void next_fifo_transaction(struct
10380 ep->ep.name, req, transaction_len,
10381 req->last_transaction ? ", done" : "");
10383 - copy_to_fifo(ep->fifo, req->req.buf + req->req.actual, transaction_len);
10384 + memcpy_toio(ep->fifo, req->req.buf + req->req.actual, transaction_len);
10385 usba_ep_writel(ep, SET_STA, USBA_TX_PK_RDY);
10386 req->req.actual += transaction_len;
10388 @@ -476,7 +431,7 @@ static void receive_data(struct usba_ep
10389 bytecount = req->req.length - req->req.actual;
10392 - copy_from_fifo(req->req.buf + req->req.actual,
10393 + memcpy_fromio(req->req.buf + req->req.actual,
10394 ep->fifo, bytecount);
10395 req->req.actual += bytecount;
10397 @@ -1029,33 +984,6 @@ static const struct usb_gadget_ops usba_
10398 .set_selfpowered = usba_udc_set_selfpowered,
10401 -#define EP(nam, idx, maxpkt, maxbk, dma, isoc) \
10404 - .ops = &usba_ep_ops, \
10406 - .maxpacket = maxpkt, \
10408 - .udc = &the_udc, \
10409 - .queue = LIST_HEAD_INIT(usba_ep[idx].queue), \
10410 - .fifo_size = maxpkt, \
10411 - .nr_banks = maxbk, \
10413 - .can_dma = dma, \
10414 - .can_isoc = isoc, \
10417 -static struct usba_ep usba_ep[] = {
10418 - EP("ep0", 0, 64, 1, 0, 0),
10419 - EP("ep1in-bulk", 1, 512, 2, 1, 1),
10420 - EP("ep2out-bulk", 2, 512, 2, 1, 1),
10421 - EP("ep3in-int", 3, 64, 3, 1, 0),
10422 - EP("ep4out-int", 4, 64, 3, 1, 0),
10423 - EP("ep5in-iso", 5, 1024, 3, 1, 1),
10424 - EP("ep6out-iso", 6, 1024, 3, 1, 1),
10428 static struct usb_endpoint_descriptor usba_ep0_desc = {
10429 .bLength = USB_DT_ENDPOINT_SIZE,
10430 .bDescriptorType = USB_DT_ENDPOINT,
10431 @@ -1074,7 +1002,6 @@ static void nop_release(struct device *d
10432 static struct usba_udc the_udc = {
10434 .ops = &usba_udc_ops,
10435 - .ep0 = &usba_ep[0].ep,
10436 .ep_list = LIST_HEAD_INIT(the_udc.gadget.ep_list),
10438 .name = "atmel_usba_udc",
10439 @@ -1231,7 +1158,7 @@ static int do_test_mode(struct usba_udc
10441 usba_ep_writel(ep, CTL_ENB, USBA_EPT_ENABLE);
10442 usba_writel(udc, TST, USBA_TST_PKT_MODE);
10443 - copy_to_fifo(ep->fifo, test_packet_buffer,
10444 + memcpy_toio(ep->fifo, test_packet_buffer,
10445 sizeof(test_packet_buffer));
10446 usba_ep_writel(ep, SET_STA, USBA_TX_PK_RDY);
10447 dev_info(dev, "Entering Test_Packet mode...\n");
10448 @@ -1530,13 +1457,13 @@ restart:
10449 DBG(DBG_HW, "Packet length: %u\n", pkt_len);
10450 if (pkt_len != sizeof(crq)) {
10451 pr_warning("udc: Invalid packet length %u "
10452 - "(expected %lu)\n", pkt_len, sizeof(crq));
10453 + "(expected %zu)\n", pkt_len, sizeof(crq));
10454 set_protocol_stall(udc, ep);
10458 DBG(DBG_FIFO, "Copying ctrl request from 0x%p:\n", ep->fifo);
10459 - copy_from_fifo(crq.data, ep->fifo, sizeof(crq));
10460 + memcpy_fromio(crq.data, ep->fifo, sizeof(crq));
10462 /* Free up one bank in the FIFO so that we can
10463 * generate or receive a reply right away. */
10464 @@ -1908,7 +1835,7 @@ static int __init usba_udc_probe(struct
10466 regs = platform_get_resource(pdev, IORESOURCE_MEM, CTRL_IOMEM_ID);
10467 fifo = platform_get_resource(pdev, IORESOURCE_MEM, FIFO_IOMEM_ID);
10468 - if (!regs || !fifo)
10469 + if (!regs || !fifo || !pdata)
10472 irq = platform_get_irq(pdev, 0);
10473 @@ -1956,16 +1883,44 @@ static int __init usba_udc_probe(struct
10474 usba_writel(udc, CTRL, 0);
10477 + usba_ep = kmalloc(sizeof(struct usba_ep) * pdata->num_ep,
10480 + goto err_alloc_ep;
10482 + the_udc.gadget.ep0 = &usba_ep[0].ep;
10484 INIT_LIST_HEAD(&usba_ep[0].ep.ep_list);
10485 usba_ep[0].ep_regs = udc->regs + USBA_EPT_BASE(0);
10486 usba_ep[0].dma_regs = udc->regs + USBA_DMA_BASE(0);
10487 usba_ep[0].fifo = udc->fifo + USBA_FIFO_BASE(0);
10488 - for (i = 1; i < ARRAY_SIZE(usba_ep); i++) {
10489 + usba_ep[0].ep.ops = &usba_ep_ops;
10490 + usba_ep[0].ep.name = pdata->ep[0].name;
10491 + usba_ep[0].ep.maxpacket = pdata->ep[0].fifo_size;
10492 + usba_ep[0].udc = &the_udc;
10493 + INIT_LIST_HEAD(&usba_ep[0].queue);
10494 + usba_ep[0].fifo_size = pdata->ep[0].fifo_size;
10495 + usba_ep[0].nr_banks = pdata->ep[0].nr_banks;
10496 + usba_ep[0].index = pdata->ep[0].index;
10497 + usba_ep[0].can_dma = pdata->ep[0].can_dma;
10498 + usba_ep[0].can_isoc = pdata->ep[0].can_isoc;
10500 + for (i = 1; i < pdata->num_ep; i++) {
10501 struct usba_ep *ep = &usba_ep[i];
10503 ep->ep_regs = udc->regs + USBA_EPT_BASE(i);
10504 ep->dma_regs = udc->regs + USBA_DMA_BASE(i);
10505 ep->fifo = udc->fifo + USBA_FIFO_BASE(i);
10506 + ep->ep.ops = &usba_ep_ops;
10507 + ep->ep.name = pdata->ep[i].name;
10508 + ep->ep.maxpacket = pdata->ep[i].fifo_size;
10509 + ep->udc = &the_udc;
10510 + INIT_LIST_HEAD(&ep->queue);
10511 + ep->fifo_size = pdata->ep[i].fifo_size;
10512 + ep->nr_banks = pdata->ep[i].nr_banks;
10513 + ep->index = pdata->ep[i].index;
10514 + ep->can_dma = pdata->ep[i].can_dma;
10515 + ep->can_isoc = pdata->ep[i].can_isoc;
10517 list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list);
10519 @@ -1984,7 +1939,7 @@ static int __init usba_udc_probe(struct
10520 goto err_device_add;
10523 - if (pdata && pdata->vbus_pin != GPIO_PIN_NONE) {
10524 + if (pdata->vbus_pin >= 0) {
10525 if (!gpio_request(pdata->vbus_pin, "atmel_usba_udc")) {
10526 udc->vbus_pin = pdata->vbus_pin;
10528 @@ -2004,7 +1959,7 @@ static int __init usba_udc_probe(struct
10531 usba_init_debugfs(udc);
10532 - for (i = 1; i < ARRAY_SIZE(usba_ep); i++)
10533 + for (i = 1; i < pdata->num_ep; i++)
10534 usba_ep_init_debugfs(udc, &usba_ep[i]);
10537 @@ -2012,6 +1967,8 @@ static int __init usba_udc_probe(struct
10539 free_irq(irq, udc);
10543 iounmap(udc->fifo);
10545 iounmap(udc->regs);
10546 @@ -2029,10 +1986,11 @@ static int __exit usba_udc_remove(struct
10548 struct usba_udc *udc;
10550 + struct usba_platform_data *pdata = pdev->dev.platform_data;
10552 udc = platform_get_drvdata(pdev);
10554 - for (i = 1; i < ARRAY_SIZE(usba_ep); i++)
10555 + for (i = 1; i < pdata->num_ep; i++)
10556 usba_ep_cleanup_debugfs(&usba_ep[i]);
10557 usba_cleanup_debugfs(udc);
10559 --- a/drivers/usb/host/ohci-at91.c
10560 +++ b/drivers/usb/host/ohci-at91.c
10561 @@ -330,7 +330,7 @@ ohci_hcd_at91_drv_suspend(struct platfor
10563 * REVISIT: some boards will be able to turn VBUS off...
10565 - if (at91_suspend_entering_slow_clock()) {
10566 + if (clk_must_disable(fclk)) {
10567 ohci_usb_reset (ohci);
10570 --- a/drivers/video/Kconfig
10571 +++ b/drivers/video/Kconfig
10572 @@ -889,6 +889,17 @@ config FB_EPSON1355
10573 framebuffer. Product specs at
10574 <http://www.erd.epson.com/vdc/html/products.htm>.
10576 +config FB_S1D15605
10577 + tristate "Epson S1D15605 framebuffer support"
10579 + default m if MACH_KB9200
10580 + select FB_CFB_FILLRECT
10581 + select FB_CFB_COPYAREA
10582 + select FB_CFB_IMAGEBLIT
10584 + Build in support for the S1D15605 Epson Research 128x64
10585 + LCD controller as a framebuffer.
10588 tristate "Epson S1D13XXX framebuffer support"
10590 --- a/drivers/video/Makefile
10591 +++ b/drivers/video/Makefile
10592 @@ -87,7 +87,8 @@ obj-$(CONFIG_FB_G364) += g36
10593 obj-$(CONFIG_FB_SA1100) += sa1100fb.o
10594 obj-$(CONFIG_FB_HIT) += hitfb.o
10595 obj-$(CONFIG_FB_EPSON1355) += epson1355fb.o
10596 -obj-$(CONFIG_FB_ATMEL) += atmel_lcdfb.o
10597 +obj-$(CONFIG_FB_S1D15605) += s1d15605fb.o
10598 +obj-$(CONFIG_FB_ATMEL) += atmel_lcdfb.o
10599 obj-$(CONFIG_FB_PVR2) += pvr2fb.o
10600 obj-$(CONFIG_FB_VOODOO1) += sstfb.o
10601 obj-$(CONFIG_FB_ARMCLCD) += amba-clcd.o
10602 --- a/drivers/video/atmel_lcdfb.c
10603 +++ b/drivers/video/atmel_lcdfb.c
10605 #define ATMEL_LCDC_CVAL_DEFAULT 0xc8
10606 #define ATMEL_LCDC_DMA_BURST_LEN 8
10608 -#if defined(CONFIG_ARCH_AT91SAM9263) || defined(CONFIG_ARCH_AT91CAP9)
10609 +#if defined(CONFIG_ARCH_AT91SAM9263) || defined(CONFIG_ARCH_AT91CAP9) || defined(CONFIG_ARCH_AT91SAM9RL)
10610 #define ATMEL_LCDC_FIFO_SIZE 2048
10612 #define ATMEL_LCDC_FIFO_SIZE 512
10613 @@ -903,11 +903,45 @@ static int __exit atmel_lcdfb_remove(str
10617 -static struct platform_driver atmel_lcdfb_driver = {
10618 - .remove = __exit_p(atmel_lcdfb_remove),
10621 +static int atmel_lcdfb_suspend(struct platform_device *pdev, pm_message_t mesg)
10623 + struct fb_info *info = platform_get_drvdata(pdev);
10624 + struct atmel_lcdfb_info *sinfo = info->par;
10626 + sinfo->saved_lcdcon = lcdc_readl(sinfo, ATMEL_LCDC_CONTRAST_VAL);
10627 + lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, 0);
10628 + if (sinfo->atmel_lcdfb_power_control)
10629 + sinfo->atmel_lcdfb_power_control(0);
10630 + atmel_lcdfb_stop_clock(sinfo);
10632 -// FIXME need suspend, resume
10636 +static int atmel_lcdfb_resume(struct platform_device *pdev)
10638 + struct fb_info *info = platform_get_drvdata(pdev);
10639 + struct atmel_lcdfb_info *sinfo = info->par;
10641 + atmel_lcdfb_start_clock(sinfo);
10642 + if (sinfo->atmel_lcdfb_power_control)
10643 + sinfo->atmel_lcdfb_power_control(1);
10644 + lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, sinfo->saved_lcdcon);
10650 +#define atmel_lcdfb_suspend NULL
10651 +#define atmel_lcdfb_resume NULL
10655 +static struct platform_driver atmel_lcdfb_driver = {
10656 + .remove = __exit_p(atmel_lcdfb_remove),
10657 + .suspend = atmel_lcdfb_suspend,
10658 + .resume = atmel_lcdfb_resume,
10660 .name = "atmel_lcdfb",
10661 .owner = THIS_MODULE,
10662 --- a/drivers/video/backlight/Kconfig
10663 +++ b/drivers/video/backlight/Kconfig
10664 @@ -112,3 +112,11 @@ config BACKLIGHT_CARILLO_RANCH
10666 If you have a Intel LE80578 (Carillo Ranch) say Y to enable the
10669 +config BACKLIGHT_KB920x
10670 + tristate "KwikByte KB9202 Backlight Driver"
10671 + depends on BACKLIGHT_CLASS_DEVICE && MACH_KB9200
10674 + If you have a KwikByte KB9202 board, say Y to enable the
10675 + backlight driver.
10676 --- a/drivers/video/backlight/Makefile
10677 +++ b/drivers/video/backlight/Makefile
10678 @@ -10,3 +10,4 @@ obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomo
10679 obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o
10680 obj-$(CONFIG_BACKLIGHT_PROGEAR) += progear_bl.o
10681 obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o
10682 +obj-$(CONFIG_BACKLIGHT_KB920x) += kb920x_bl.o
10684 +++ b/drivers/video/backlight/kb920x_bl.c
10687 + * Backlight Driver for KB9202
10689 + * Copyright (c) 2006 KwikByte
10691 + * Based on Sharp's Corgi Backlight Driver
10693 + * This file is subject to the terms and conditions of the GNU General Public
10694 + * License. See the file "COPYING" in the main directory of this archive
10695 + * for more details.
10698 +#include <linux/module.h>
10699 +#include <linux/kernel.h>
10700 +#include <linux/init.h>
10701 +#include <linux/platform_device.h>
10702 +#include <linux/spinlock.h>
10703 +#include <linux/fb.h>
10704 +#include <linux/backlight.h>
10706 +#include <asm/arch/gpio.h>
10708 +/* The backlight is on(1)/off(0) */
10709 +#define KB9202_DEFAULT_INTENSITY 1
10710 +#define KB9202_MAX_INTENSITY 1
10712 +static int kb9202bl_suspended;
10713 +static int current_intensity = 0;
10714 +static DEFINE_SPINLOCK(bl_lock);
10716 +static int kb9202bl_set_intensity(struct backlight_device *bd)
10718 + unsigned long flags;
10719 + int intensity = bd->props.brightness;
10721 + if (bd->props.power != FB_BLANK_UNBLANK)
10723 + if (bd->props.fb_blank != FB_BLANK_UNBLANK)
10725 + if (kb9202bl_suspended)
10728 + if ((!current_intensity) && (bd->props.power == FB_BLANK_UNBLANK))
10731 + spin_lock_irqsave(&bl_lock, flags);
10733 + gpio_set_value(AT91_PIN_PC23, 1);
10735 + gpio_set_value(AT91_PIN_PC23, 0);
10736 + spin_unlock_irqrestore(&bl_lock, flags);
10738 + current_intensity = intensity;
10743 +static int kb9202bl_get_intensity(struct backlight_device *bd)
10745 + return current_intensity;
10748 +static struct backlight_ops kb9202bl_ops = {
10749 + .get_brightness = kb9202bl_get_intensity,
10750 + .update_status = kb9202bl_set_intensity,
10753 +static int __init kb9202bl_probe(struct platform_device *pdev)
10755 + struct backlight_device *bd;
10757 + bd = backlight_device_register ("kb9202-bl", &pdev->dev, NULL, &kb9202bl_ops);
10759 + return PTR_ERR(bd);
10761 + platform_set_drvdata(pdev, bd);
10763 + bd->props.max_brightness = KB9202_MAX_INTENSITY;
10764 + bd->props.brightness = KB9202_DEFAULT_INTENSITY;
10765 + (void) kb9202bl_set_intensity(bd);
10770 +static int kb9202bl_remove(struct platform_device *pdev)
10772 + struct backlight_device *bd = platform_get_drvdata(pdev);
10774 + bd->props.brightness = 0;
10775 + bd->props.power = 0;
10776 + (void) kb9202bl_set_intensity(bd);
10778 + backlight_device_unregister(bd);
10784 +static int kb9202bl_suspend(struct platform_device *pdev, pm_message_t state)
10786 + struct backlight_device *bd = platform_get_drvdata(pdev);
10788 + kb9202bl_suspended = 1;
10789 + (void) kb9202bl_set_intensity(bd);
10793 +static int kb9202bl_resume(struct platform_device *pdev)
10795 + struct backlight_device *bd = platform_get_drvdata(pdev);
10797 + kb9202bl_suspended = 0;
10798 + (void) kb9202bl_set_intensity(bd);
10802 +#define kb9202bl_suspend NULL
10803 +#define kb9202bl_resume NULL
10806 +static struct platform_driver kb9202bl_driver = {
10807 + .probe = kb9202bl_probe,
10808 + .remove = kb9202bl_remove,
10809 + .suspend = kb9202bl_suspend,
10810 + .resume = kb9202bl_resume,
10812 + .name = "kb9202-bl",
10813 + .owner = THIS_MODULE,
10817 +static struct platform_device *kb9202bl_device;
10819 +static int __init kb9202bl_init(void)
10823 + ret = platform_driver_register(&kb9202bl_driver);
10825 + kb9202bl_device = platform_device_alloc("kb9202-bl", -1);
10826 + if (!kb9202bl_device)
10829 + ret = platform_device_add(kb9202bl_device);
10831 + platform_device_put(kb9202bl_device);
10832 + platform_driver_unregister(&kb9202bl_driver);
10838 +static void __exit kb9202bl_exit(void)
10840 + platform_device_unregister(kb9202bl_device);
10841 + platform_driver_unregister(&kb9202bl_driver);
10844 +module_init(kb9202bl_init);
10845 +module_exit(kb9202bl_exit);
10847 +MODULE_AUTHOR("KwikByte <kb9200_dev@kwikbyte.com>");
10848 +MODULE_DESCRIPTION("KB9202 Backlight Driver");
10849 +MODULE_LICENSE("GPL");
10851 +++ b/drivers/video/s1d15605fb.c
10854 + * drivers/video/s1d15605.c
10856 + * Adapted from several sources including:
10857 + * 1) Driver for AT91 LCD Controller
10858 + * Copyright (C) 2006 Atmel
10860 + * 2) Copyright (C) 2005 S. Kevin Hester
10862 + * This file is subject to the terms and conditions of the GNU General Public
10863 + * License. See the file COPYING in the main directory of this archive for
10866 + * This is a basic framebuffer driver for the Optrex F-51320 128x64 mono LCD
10867 + * display. This display uses a clone of the common Epson SED 1531 display
10870 + * I've heavily borrowed code from the vfb.c driver.
10872 + * This program is free software; you can redistribute it and/or modify
10873 + * it under the terms of the GNU General Public License as published by
10874 + * the Free Software Foundation; either version 2 of the License, or
10875 + * (at your option) any later version.
10877 + * This program is distributed in the hope that it will be useful,
10878 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
10879 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10880 + * GNU General Public License for more details.
10882 + * You should have received a copy of the GNU General Public License
10883 + * along with this program; if not, write to the Free Software
10884 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
10888 +#define MSG(string, args...) printk("s1d15605fb:" string, ##args)
10890 +#define MSG(string, args...)
10893 +#include <linux/kernel.h>
10894 +#include <linux/platform_device.h>
10895 +#include <linux/dma-mapping.h>
10896 +#include <linux/interrupt.h>
10897 +#include <linux/clk.h>
10898 +#include <linux/fb.h>
10899 +#include <linux/init.h>
10900 +#include <linux/delay.h>
10902 +#include <asm/uaccess.h>
10904 +#include <asm/arch/board.h>
10905 +#include <asm/arch/gpio.h>
10907 +#ifdef CONFIG_PMAC_BACKLIGHT
10908 +#include <asm/backlight.h>
10911 +#define VIDEOWIDTH 128
10912 +#define VIDEOHEIGHT 64
10913 +#define VIDEODEPTH 1 /* bits/pixel */
10914 +#define VIDEOWIDTH_BYTES ((VIDEOWIDTH * VIDEODEPTH) / 8)
10916 +/* The number of bytes that actually go to the device */
10917 +#define ACTUALVIDEOMEMSIZE (VIDEOWIDTH_BYTES * VIDEOHEIGHT)
10918 +#define VIDEOMEMSIZE PAGE_SIZE
10920 +static struct fb_var_screeninfo s1d15605_default __initdata = {
10921 + .xres = VIDEOWIDTH,
10922 + .yres = VIDEOHEIGHT,
10923 + .xres_virtual = VIDEOWIDTH,
10924 + .yres_virtual = VIDEOHEIGHT,
10925 + .bits_per_pixel = VIDEODEPTH,
10926 + .red = { 0, 1, 0 },
10927 + .green = { 0, 1, 0 },
10928 + .blue = { 0, 1, 0 },
10929 + .activate = FB_ACTIVATE_NOW,
10930 + .pixclock = 20000,
10931 + .vmode = FB_VMODE_NONINTERLACED,
10934 +static struct fb_fix_screeninfo s1d15605_fix __initdata = {
10935 + .id = "s1d15605",
10936 + .type = FB_TYPE_PACKED_PIXELS,
10937 + .visual = FB_VISUAL_MONO10,
10941 + .accel = FB_ACCEL_NONE,
10944 +struct s1d15605fb_info {
10945 + struct fb_info *info;
10947 + unsigned long reset_pin;
10948 + struct platform_device *pdev;
10952 + * LCD device interface
10954 +#define RESET_DISPLAY 0xE2
10955 +#define LCD_BIAS_1_9 0xA2
10956 +#define ADC_SELECT_REVERSE 0xA1
10957 +#define COMMON_OUTPUT_NORMAL 0xC0
10958 +#define V5_RESISTOR_RATIO 0x26
10959 +#define ELECTRONIC_VOLUME_SET 0x81
10960 +#define ELECTRONIC_VOLUME_INIT 0x20
10961 +#define POWER_CONTROL_SET 0x28
10962 +#define VOLTAGE_REGULATOR 0x02
10963 +#define VOLTAGE_FOLLOWER 0x01
10964 +#define BOOSTER_CIRCUIT 0x04
10965 +#define DISPLAY_ON 0xAF
10966 +#define START_LINE_SET 0x40
10967 +#define PAGE_ADDRESS_SET 0xB0
10968 +#define COLUMN_ADDRESS_HIGH 0x10
10969 +#define COLUMN_ADDRESS_LOW 0x00
10970 +#define RESISTOR_RATIO_START 0x20
10972 +#define NUM_OF_PAGES 8
10973 +#define NUM_OF_COLUMNS 128
10975 +#define WRITE_COMMAND(x) __raw_writeb((x), (sinfo)->mmio)
10976 +#define READ_COMMAND __raw_readb((sinfo)->mmio)
10977 +#define WRITE_DATA(x) __raw_writeb((x), (sinfo)->mmio + (0x10000))
10978 +#define READ_DATA __raw_readb((sinfo)->mmio + (0x10000))
10982 + * s1d15605fb_resize_framebuffer
10984 + * Free allocated space if different. Allocate on new of changed.
10985 + * Returns -ENOMEM if the new framebuffer can not be allocated,
10986 + * zero on success.
10988 +static int s1d15605fb_resize_framebuffer(struct s1d15605fb_info *sinfo)
10990 + struct fb_info *info = sinfo->info;
10991 + struct fb_fix_screeninfo *fix = &info->fix;
10992 + struct fb_var_screeninfo *var = &info->var;
10993 + unsigned int new_size;
10996 + new_size = ((var->xres_virtual * var->yres_virtual * var->bits_per_pixel) / 8);
10998 + MSG("%s: x (%d) y (%d) bpp (%d): new size 0x%08x\n", __FUNCTION__,
10999 + var->xres_virtual, var->yres_virtual, var->bits_per_pixel, new_size);
11001 + if (new_size == fix->smem_len)
11004 + if (fix->smem_len) {
11005 + kfree(info->screen_base);
11008 + new_vaddr = kmalloc(new_size, GFP_KERNEL);
11010 + if (!new_vaddr) {
11011 + fix->smem_len = 0;
11015 + info->screen_base = new_vaddr;
11016 + fix->smem_start = (unsigned)new_vaddr;
11017 + fix->smem_len = new_size;
11018 + fix->line_length = (var->xres_virtual * var->bits_per_pixel) / 8;
11020 + dev_info(info->device,
11021 + "%luKiB frame buffer at %08lx (mapped at %p)\n",
11022 + (unsigned long)info->fix.smem_len / 1024,
11023 + (unsigned long)info->fix.smem_start,
11024 + info->screen_base);
11031 + * The s1d15605 seems to be divided into eight 128 pixel wide pages (from top to
11032 + * bottom) each page seems to be eight pixels high, where these eight pixels are
11035 +static void s1d15605_update(struct fb_info *info)
11037 + struct s1d15605fb_info *sinfo = info->par;
11038 + int page, i, row, colmask;
11039 + u8 retVal, *rowPtr;
11041 + WRITE_COMMAND(START_LINE_SET);
11042 + for (page = 0; page < NUM_OF_PAGES; ++page) {
11043 + WRITE_COMMAND(PAGE_ADDRESS_SET + page);
11044 + WRITE_COMMAND(COLUMN_ADDRESS_HIGH);
11045 + WRITE_COMMAND(COLUMN_ADDRESS_LOW);
11047 + for (i = 0; i < NUM_OF_COLUMNS; ++i)
11049 + /* point of opportunity: optimization */
11050 + colmask = (1 << (i & 0x7));
11051 + rowPtr = (u8*)(info->screen_base);
11052 + rowPtr += (VIDEOWIDTH_BYTES * 8 * page);
11053 + rowPtr += (i >> 3);
11055 + for (row = 0; row < 8; ++row)
11057 + retVal = (retVal >> 1) | (((*rowPtr) & colmask) ? 0x80 : 0);
11058 + rowPtr += VIDEOWIDTH_BYTES;
11060 + WRITE_DATA(retVal);
11064 + WRITE_COMMAND(DISPLAY_ON);
11069 + * Setting the video mode has been split into two parts.
11070 + * First part, xxxfb_check_var, must not write anything
11071 + * to hardware, it should only verify and adjust var.
11072 + * This means it doesn't alter par but it does use hardware
11073 + * data from it to check this var.
11075 +static int s1d15605_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
11078 + * Some very basic checks
11084 + if (var->xres > var->xres_virtual)
11085 + var->xres_virtual = var->xres;
11086 + if (var->yres > var->yres_virtual)
11087 + var->yres_virtual = var->yres;
11089 + if(var->bits_per_pixel > VIDEODEPTH)
11095 + if (((var->yres_virtual * var->bits_per_pixel * var->yres_virtual) >> 3) >
11096 + ACTUALVIDEOMEMSIZE)
11100 + * Now that we checked it we alter var. The reason being is that the video
11101 + * mode passed in might not work but slight changes to it might make it
11102 + * work. This way we let the user know what is acceptable.
11104 + switch (var->bits_per_pixel) {
11106 + var->red.offset = var->green.offset = var->blue.offset = 0;
11107 + var->red.length = var->green.length = var->blue.length
11108 + = var->bits_per_pixel;
11114 + var->xoffset = var->yoffset = 0;
11115 + var->red.msb_right = var->green.msb_right = var->blue.msb_right =
11116 + var->transp.msb_right = 0;
11123 + * This routine actually sets the video mode. It's in here where we
11124 + * the hardware state info->par and fix which can be affected by the
11125 + * change in par. For this driver it doesn't do much.
11127 +static int s1d15605_set_par(struct fb_info *info)
11131 + MSG("%s:\n", __func__);
11132 + MSG(" * resolution: %ux%u (%ux%u virtual)\n",
11133 + info->var.xres, info->var.yres,
11134 + info->var.xres_virtual, info->var.yres_virtual);
11136 + ret = s1d15605fb_resize_framebuffer(info->par);
11138 + info->fix.visual = FB_VISUAL_MONO10;
11144 + * Set a single color register. The values supplied are already
11145 + * rounded down to the hardware's capabilities (according to the
11146 + * entries in the var structure). Return != 0 for invalid regno.
11148 +static int s1d15605_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
11149 + u_int transp, struct fb_info *info)
11151 + if (regno > 1) /* no. of hw registers - we only do mono now */
11159 + * Currently, the routine will simply shut-off the backlight and prevent
11160 + * updates/refreshes. Modify according to application.
11162 + * 0 unblank, 1 blank, 2 no vsync, 3 no hsync, 4 off
11164 +static int s1d15605_blank(int blank, struct fb_info *info)
11166 +#ifdef CONFIG_PMAC_BACKLIGHT
11168 + pmac_backlight->props.power = FB_BLANK_POWERDOWN;
11170 + pmac_backlight->props.power = FB_BLANK_UNBLANK;
11171 + backlight_update_status(pmac_backlight);
11178 + * Pan or Wrap the Display
11180 + * This call looks only at xoffset, yoffset and the FB_VMODE_YWRAP flag
11183 +static int s1d15605_pan_display(struct fb_var_screeninfo *var,
11184 + struct fb_info *info)
11186 + if (var->vmode & FB_VMODE_YWRAP) {
11187 + if (var->yoffset < 0
11188 + || var->yoffset >= info->var.yres_virtual
11192 + if (var->xoffset + var->xres > info->var.xres_virtual ||
11193 + var->yoffset + var->yres > info->var.yres_virtual)
11196 + info->var.xoffset = var->xoffset;
11197 + info->var.yoffset = var->yoffset;
11198 + if (var->vmode & FB_VMODE_YWRAP)
11199 + info->var.vmode |= FB_VMODE_YWRAP;
11201 + info->var.vmode &= ~FB_VMODE_YWRAP;
11207 +static void s1d15605_copyarea(struct fb_info *info, const struct fb_copyarea *region)
11209 + cfb_copyarea(info, region);
11210 + s1d15605_update(info);
11214 +static void s1d15605_fillrect (struct fb_info *info, const struct fb_fillrect *rect)
11216 + cfb_fillrect(info, rect);
11217 + s1d15605_update(info);
11221 +static void s1d15605_imageblit(struct fb_info *p, const struct fb_image *image)
11223 + cfb_imageblit(p, image);
11224 + s1d15605_update(p);
11229 + * Write the users data to our framebuffer, and then trigger a psuedo DMA
11231 +static ssize_t s1d15605_write(struct fb_info *info, const char *buf,
11232 + size_t count, loff_t *ppos)
11234 + unsigned long p = *ppos;
11237 + if (p > info->fix.smem_len)
11239 + if (count >= info->fix.smem_len)
11240 + count = info->fix.smem_len;
11242 + if (count + p > info->fix.smem_len) {
11243 + count = info->fix.smem_len - p;
11249 + base_addr = info->screen_base;
11250 + count -= copy_from_user(base_addr+p, buf, count);
11255 + s1d15605_update(info);
11263 +#ifdef USE_PRIVATE_VMA_FXS
11264 +static void s1d15605_vma_open(struct vm_area_struct *vma)
11266 + // FIXME - store stats in the device data via vm_private_data
11270 +static void s1d15605_vma_close(struct vm_area_struct *vma)
11272 + // FIXME - store stats in the device data via vm_private_data
11276 +static struct page *s1d15605_vma_nopage(struct vm_area_struct *vma,
11277 + unsigned long address, int *type)
11279 + struct page *page;
11280 + struct fb_info *info = vma->vm_private_data;
11282 + page = virt_to_page(info->screen_base);
11285 + // FIXME - now someone has a link to our page, start periodically blitting
11286 + // latest updates to the actual device.
11292 +static struct vm_operations_struct s1d15605_vm_ops = {
11293 + .open = s1d15605_vma_open,
11294 + .close = s1d15605_vma_close,
11295 + .nopage = s1d15605_vma_nopage
11299 +/* We don't do much here - because we have special vm_ops */
11300 +static int s1d15605_mmap(struct fb_info *info, struct vm_area_struct *vma)
11302 + vma->vm_ops = &s1d15605_vm_ops;
11303 + vma->vm_flags |= VM_RESERVED;
11304 + vma->vm_private_data = info;
11305 + s1d15605_vma_open(vma);
11309 +#endif /* USE_PRIVATE_VMA_FXS */
11312 +static struct fb_ops s1d15605fb_ops = {
11313 + .owner = THIS_MODULE,
11314 + .fb_check_var = s1d15605_check_var,
11315 + .fb_set_par = s1d15605_set_par,
11316 + .fb_setcolreg = s1d15605_setcolreg,
11317 + .fb_blank = s1d15605_blank,
11318 +// .fb_pan_display = s1d15605_pan_display,
11319 + .fb_fillrect = s1d15605_fillrect,
11320 + .fb_copyarea = s1d15605_copyarea,
11321 + .fb_imageblit = s1d15605_imageblit,
11322 + .fb_write = s1d15605_write,
11323 +#ifdef USE_PRIVATE_VMA_FXS
11324 + .fb_mmap = s1d15605_mmap,
11329 +static void s1d15605_device_init(struct s1d15605fb_info *sinfo) {
11333 + /* release the reset line by reading the device - proto hardware */
11334 + value = READ_COMMAND;
11335 + value = READ_COMMAND;
11337 +#ifdef CONFIG_MACH_KB9200
11338 + /* new boards have dedicated reset line */
11339 + gpio_set_value(sinfo->reset_pin, 1);
11342 + /* initialize the device within 5ms */
11343 + WRITE_COMMAND(RESET_DISPLAY);
11344 + WRITE_COMMAND(LCD_BIAS_1_9);
11345 + WRITE_COMMAND(ADC_SELECT_REVERSE);
11346 + WRITE_COMMAND(COMMON_OUTPUT_NORMAL);
11347 + WRITE_COMMAND(V5_RESISTOR_RATIO);
11348 + WRITE_COMMAND(ELECTRONIC_VOLUME_SET);
11349 + WRITE_COMMAND(ELECTRONIC_VOLUME_INIT);
11350 + WRITE_COMMAND(POWER_CONTROL_SET | VOLTAGE_REGULATOR | VOLTAGE_FOLLOWER | BOOSTER_CIRCUIT);
11351 + WRITE_COMMAND(DISPLAY_ON);
11353 + WRITE_COMMAND(RESISTOR_RATIO_START + 4);
11354 + WRITE_COMMAND(ELECTRONIC_VOLUME_SET);
11355 + WRITE_COMMAND(0x33);
11359 +static int __init s1d15605fb_probe(struct platform_device *pdev)
11361 + struct device *dev = &pdev->dev;
11362 + struct fb_info *info;
11363 + struct s1d15605fb_info *sinfo;
11366 + MSG("%s\n", __func__);
11368 + if (!(info = framebuffer_alloc(sizeof(struct s1d15605fb_info), dev))) {
11369 + dev_err(dev, "Cannot allocate framebuffer struct\n");
11373 + sinfo = info->par;
11374 + sinfo->info = info;
11375 + sinfo->pdev = pdev;
11377 + if (pdev->num_resources < 2) {
11378 + dev_err(dev, "Resources unusable\n");
11383 + info->fbops = &s1d15605fb_ops;
11384 + strcpy(info->fix.id, pdev->name);
11386 + info->fix.mmio_start = pdev->resource[0].start;
11387 + info->fix.mmio_len = pdev->resource[0].end - pdev->resource[0].start + 1;
11388 + sinfo->reset_pin = pdev->resource[1].start;
11390 + ret = s1d15605fb_resize_framebuffer(sinfo);
11392 + dev_err(dev, "Cannot resize framebuffer: %d\n", ret);
11396 + if (!request_mem_region(info->fix.mmio_start,
11397 + info->fix.mmio_len, pdev->name)) {
11402 + sinfo->mmio = ioremap(info->fix.mmio_start, info->fix.mmio_len);
11403 + if (!sinfo->mmio) {
11404 + dev_err(dev, "Cannot map LCD memory region\n");
11405 + goto release_mem;
11408 + s1d15605_device_init(sinfo);
11410 + ret = fb_find_mode(&info->var, info, NULL, NULL, 0, NULL, 1);
11412 + if (!ret || (ret == 4))
11413 + info->var = s1d15605_default;
11415 + info->fix = s1d15605_fix;
11416 + info->flags = FBINFO_FLAG_DEFAULT |
11417 +/* FBINFO_HWACCEL_YPAN | */
11418 + FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
11420 + ret = register_framebuffer(info);
11422 + dev_err(dev, "Failed to register framebuffer device: %d\n", ret);
11426 + dev_set_drvdata(dev, info);
11428 + memset(info->screen_base, 0, info->fix.smem_len);
11429 + info->var.activate |= FB_ACTIVATE_NOW;
11430 + ret = fb_set_var(info, &info->var);
11432 + dev_warn(dev, "Unable to set display parameters\n");
11435 + info->var.activate &= ~(FB_ACTIVATE_FORCE | FB_ACTIVATE_NOW);
11437 + dev_dbg(dev, "%s SUCCESS\n", __func__);
11439 + dev_info(dev, "Driver $Revision: 1.1 $\n");
11444 + iounmap(sinfo->mmio);
11446 + release_mem_region(info->fix.mmio_start, info->fix.mmio_len);
11448 + kfree(info->screen_base);
11451 + framebuffer_release(info);
11453 + dev_dbg(dev, "%s FAILED\n", __func__);
11458 +static int __exit s1d15605fb_remove(struct platform_device *pdev)
11460 + struct device *dev = &pdev->dev;
11461 + struct fb_info *info = dev_get_drvdata(dev);
11462 + struct s1d15605fb_info *sinfo = info->par;
11467 + unregister_framebuffer(info);
11469 + iounmap(sinfo->mmio);
11470 + release_mem_region(info->fix.mmio_start, info->fix.mmio_len);
11472 + kfree(info->screen_base);
11474 + dev_set_drvdata(dev, NULL);
11475 + framebuffer_release(info);
11480 +static struct platform_driver s1d15605fb_driver = {
11481 + .remove = __exit_p(s1d15605fb_remove),
11483 + .name = "s1d15605fb",
11484 + .owner = THIS_MODULE,
11489 +static int __init s1d15605fb_init(void)
11491 + return platform_driver_probe(&s1d15605fb_driver, s1d15605fb_probe);
11495 +static void __exit s1d15605fb_exit(void)
11497 + platform_driver_unregister(&s1d15605fb_driver);
11501 +module_init(s1d15605fb_init);
11502 +module_exit(s1d15605fb_exit);
11505 +MODULE_AUTHOR("KwikByte");
11506 +MODULE_DESCRIPTION("Epson S1D15605 LCD Controller framebuffer driver");
11507 +MODULE_LICENSE("GPL");
11508 --- a/drivers/watchdog/Kconfig
11509 +++ b/drivers/watchdog/Kconfig
11510 @@ -66,6 +66,14 @@ config AT91RM9200_WATCHDOG
11511 Watchdog timer embedded into AT91RM9200 chips. This will reboot your
11512 system when the timeout is reached.
11514 +config AT91SAM9_WATCHDOG
11515 + tristate "AT91SAM9 watchdog"
11516 + depends on ARCH_AT91 && !ARCH_AT91RM9200
11517 + select WATCHDOG_NOWAYOUT
11519 + Watchdog timer embedded into AT91SAM9 chips. This will reboot your
11520 + system when the timeout is reached.
11522 config 21285_WATCHDOG
11523 tristate "DC21285 watchdog"
11524 depends on FOOTBRIDGE
11525 --- a/drivers/watchdog/Makefile
11526 +++ b/drivers/watchdog/Makefile
11527 @@ -26,6 +26,7 @@ obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb.
11530 obj-$(CONFIG_AT91RM9200_WATCHDOG) += at91rm9200_wdt.o
11531 +obj-$(CONFIG_AT91SAM9_WATCHDOG) += at91sam9_wdt.o
11532 obj-$(CONFIG_OMAP_WATCHDOG) += omap_wdt.o
11533 obj-$(CONFIG_21285_WATCHDOG) += wdt285.o
11534 obj-$(CONFIG_977_WATCHDOG) += wdt977.o
11536 +++ b/drivers/watchdog/at91sam9_wdt.c
11539 + * Watchdog driver for Atmel AT91SAM9x processors.
11541 + * Copyright (C) 2007 Renaud CERRATO r.cerrato@til-technologies.fr
11543 + * This program is free software; you can redistribute it and/or
11544 + * modify it under the terms of the GNU General Public License
11545 + * as published by the Free Software Foundation; either version
11546 + * 2 of the License, or (at your option) any later version.
11550 + * The Watchdog Timer Mode Register can be only written to once. If the
11551 + * timeout need to be set from Linux, be sure that the bootstrap or the
11552 + * bootloader doesn't write to this register.
11555 +#include <linux/errno.h>
11556 +#include <linux/fs.h>
11557 +#include <linux/init.h>
11558 +#include <linux/kernel.h>
11559 +#include <linux/miscdevice.h>
11560 +#include <linux/module.h>
11561 +#include <linux/moduleparam.h>
11562 +#include <linux/platform_device.h>
11563 +#include <linux/types.h>
11564 +#include <linux/watchdog.h>
11565 +#include <linux/bitops.h>
11566 +#include <linux/uaccess.h>
11568 +#include <asm/arch/at91_wdt.h>
11571 +#define WDT_MAX_TIME 16 /* seconds */
11573 +static int wdt_timeout = -1; /* invalid */
11575 +module_param(wdt_timeout, int, 0);
11576 +MODULE_PARM_DESC(wdt_timeout, "Watchdog time in seconds. (default = disabled)");
11579 +static unsigned long at91wdt_busy;
11581 +/* ......................................................................... */
11584 + * Reload the watchdog timer. (ie, pat the watchdog)
11586 +static void inline at91_wdt_reload(void)
11588 + at91_sys_write(AT91_WDT_CR, AT91_WDT_KEY | AT91_WDT_WDRSTT);
11591 +/* ......................................................................... */
11594 + * Watchdog device is opened, and watchdog starts running.
11596 +static int at91_wdt_open(struct inode *inode, struct file *file)
11598 + if (test_and_set_bit(0, &at91wdt_busy))
11601 + return nonseekable_open(inode, file);
11605 + * Close the watchdog device.
11607 +static int at91_wdt_close(struct inode *inode, struct file *file)
11609 + clear_bit(0, &at91wdt_busy);
11614 + * Change the watchdog time interval.
11616 +static int at91_wdt_settimeout(int new_time)
11618 + unsigned int reg, mr;
11620 + * All counting occurs at SLOW_CLOCK / 128 = 256 Hz
11622 + * Since WDV is a 12-bit counter, the maximum period is
11623 + * 4096 / 256 = 16 seconds.
11625 + if ((new_time <= 0) || (new_time > WDT_MAX_TIME))
11628 + wdt_timeout = new_time;
11630 + /* Program the Watchdog */
11631 + reg = AT91_WDT_WDRSTEN /* causes watchdog reset */
11632 + | AT91_WDT_WDRPROC /* causes processor reset */
11633 + | AT91_WDT_WDDBGHLT /* disabled in debug mode */
11634 + | AT91_WDT_WDD /* restart at any time */
11635 + | (((wdt_timeout * 256) - 1) & AT91_WDT_WDV); /* timer value */
11636 + at91_sys_write(AT91_WDT_MR, reg);
11638 + /* Check if watchdog could be programmed */
11639 + mr = at91_sys_read(AT91_WDT_MR);
11641 + printk(KERN_ERR "at91sam9_wdt: Watchdog register already programmed.\n");
11645 + at91_wdt_reload();
11647 + printk(KERN_INFO "AT91SAM9 Watchdog enabled (%d seconds, nowayout)\n", wdt_timeout);
11651 +static struct watchdog_info at91_wdt_info = {
11652 + .identity = "at91sam9 watchdog",
11653 + .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
11657 + * Handle commands from user-space.
11659 +static int at91_wdt_ioctl(struct inode *inode, struct file *file,
11660 + unsigned int cmd, unsigned long arg)
11662 + void __user *argp = (void __user *)arg;
11663 + int __user *p = argp;
11664 + int new_value, err;
11667 + case WDIOC_KEEPALIVE:
11668 + at91_wdt_reload(); /* pat the watchdog */
11671 + case WDIOC_GETSUPPORT:
11672 + return copy_to_user(argp, &at91_wdt_info, sizeof(at91_wdt_info)) ? -EFAULT : 0;
11674 + case WDIOC_SETTIMEOUT:
11675 + if (get_user(new_value, p))
11678 + err = at91_wdt_settimeout(new_value);
11682 + return put_user(wdt_timeout, p); /* return current value */
11684 + case WDIOC_GETTIMEOUT:
11685 + return put_user(wdt_timeout, p);
11687 + case WDIOC_GETSTATUS:
11688 + case WDIOC_GETBOOTSTATUS:
11689 + return put_user(0, p);
11695 + * Pat the watchdog whenever device is written to.
11697 +static ssize_t at91_wdt_write(struct file *file, const char *data, size_t len, loff_t *ppos)
11699 + at91_wdt_reload(); /* pat the watchdog */
11703 +/* ......................................................................... */
11705 +static const struct file_operations at91wdt_fops = {
11706 + .owner = THIS_MODULE,
11707 + .llseek = no_llseek,
11708 + .ioctl = at91_wdt_ioctl,
11709 + .open = at91_wdt_open,
11710 + .release = at91_wdt_close,
11711 + .write = at91_wdt_write,
11714 +static struct miscdevice at91wdt_miscdev = {
11715 + .minor = WATCHDOG_MINOR,
11716 + .name = "watchdog",
11717 + .fops = &at91wdt_fops,
11720 +static int __init at91wdt_probe(struct platform_device *pdev)
11724 + if (at91wdt_miscdev.parent)
11726 + at91wdt_miscdev.parent = &pdev->dev;
11728 + res = misc_register(&at91wdt_miscdev);
11732 + /* Set watchdog */
11733 + if (at91_wdt_settimeout(wdt_timeout) == -EINVAL) {
11734 + pr_info("at91sam9_wdt: invalid timeout (must be between 1 and %d)\n", WDT_MAX_TIME);
11741 +static int __exit at91wdt_remove(struct platform_device *pdev)
11745 + res = misc_deregister(&at91wdt_miscdev);
11747 + at91wdt_miscdev.parent = NULL;
11754 +static int at91wdt_suspend(struct platform_device *pdev, pm_message_t message)
11759 +static int at91wdt_resume(struct platform_device *pdev)
11765 +#define at91wdt_suspend NULL
11766 +#define at91wdt_resume NULL
11769 +static struct platform_driver at91wdt_driver = {
11770 + .remove = __exit_p(at91wdt_remove),
11771 + .suspend = at91wdt_suspend,
11772 + .resume = at91wdt_resume,
11774 + .name = "at91_wdt",
11775 + .owner = THIS_MODULE,
11779 +static int __init at91sam_wdt_init(void)
11781 + return platform_driver_probe(&at91wdt_driver, at91wdt_probe);
11784 +static void __exit at91sam_wdt_exit(void)
11786 + platform_driver_unregister(&at91wdt_driver);
11789 +module_init(at91sam_wdt_init);
11790 +module_exit(at91sam_wdt_exit);
11792 +MODULE_AUTHOR("Renaud CERRATO");
11793 +MODULE_DESCRIPTION("Watchdog driver for Atmel AT91SAM9x processors");
11794 +MODULE_LICENSE("GPL");
11795 +MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
11796 +MODULE_ALIAS("platform:at91_wdt");
11797 --- a/include/asm-arm/arch-at91/at91_ecc.h
11798 +++ b/include/asm-arm/arch-at91/at91_ecc.h
11801 * include/asm-arm/arch-at91/at91_ecc.h
11803 + * Copyright (C) 2007 Andrew Victor
11804 + * Copyright (C) 2007 Atmel Corporation.
11806 * Error Corrected Code Controller (ECC) - System peripherals regsters.
11807 * Based on AT91SAM9260 datasheet revision B.
11809 @@ -13,26 +16,26 @@
11813 -#define AT91_ECC_CR (AT91_ECC + 0x00) /* Control register */
11814 +#define AT91_ECC_CR 0x00 /* Control register */
11815 #define AT91_ECC_RST (1 << 0) /* Reset parity */
11817 -#define AT91_ECC_MR (AT91_ECC + 0x04) /* Mode register */
11818 +#define AT91_ECC_MR 0x04 /* Mode register */
11819 #define AT91_ECC_PAGESIZE (3 << 0) /* Page Size */
11820 #define AT91_ECC_PAGESIZE_528 (0)
11821 #define AT91_ECC_PAGESIZE_1056 (1)
11822 #define AT91_ECC_PAGESIZE_2112 (2)
11823 #define AT91_ECC_PAGESIZE_4224 (3)
11825 -#define AT91_ECC_SR (AT91_ECC + 0x08) /* Status register */
11826 +#define AT91_ECC_SR 0x08 /* Status register */
11827 #define AT91_ECC_RECERR (1 << 0) /* Recoverable Error */
11828 #define AT91_ECC_ECCERR (1 << 1) /* ECC Single Bit Error */
11829 #define AT91_ECC_MULERR (1 << 2) /* Multiple Errors */
11831 -#define AT91_ECC_PR (AT91_ECC + 0x0c) /* Parity register */
11832 +#define AT91_ECC_PR 0x0c /* Parity register */
11833 #define AT91_ECC_BITADDR (0xf << 0) /* Bit Error Address */
11834 #define AT91_ECC_WORDADDR (0xfff << 4) /* Word Error Address */
11836 -#define AT91_ECC_NPR (AT91_ECC + 0x10) /* NParity register */
11837 +#define AT91_ECC_NPR 0x10 /* NParity register */
11838 #define AT91_ECC_NPARITY (0xffff << 0) /* NParity */
11841 --- a/include/asm-arm/arch-at91/at91_pit.h
11842 +++ b/include/asm-arm/arch-at91/at91_pit.h
11845 * include/asm-arm/arch-at91/at91_pit.h
11847 + * Copyright (C) 2007 Andrew Victor
11848 + * Copyright (C) 2007 Atmel Corporation.
11850 * Periodic Interval Timer (PIT) - System peripherals regsters.
11851 * Based on AT91SAM9261 datasheet revision D.
11853 --- a/include/asm-arm/arch-at91/at91_pmc.h
11854 +++ b/include/asm-arm/arch-at91/at91_pmc.h
11856 #define AT91_PMC_PCK (1 << 0) /* Processor Clock */
11857 #define AT91RM9200_PMC_UDP (1 << 1) /* USB Devcice Port Clock [AT91RM9200 only] */
11858 #define AT91RM9200_PMC_MCKUDP (1 << 2) /* USB Device Port Master Clock Automatic Disable on Suspend [AT91RM9200 only] */
11859 +#define AT91CAP9_PMC_DDR (1 << 2) /* DDR Clock [AT91CAP9 revC only] */
11860 #define AT91RM9200_PMC_UHP (1 << 4) /* USB Host Port Clock [AT91RM9200 only] */
11861 #define AT91SAM926x_PMC_UHP (1 << 6) /* USB Host Port Clock [AT91SAM926x only] */
11862 #define AT91CAP9_PMC_UHP (1 << 6) /* USB Host Port Clock [AT91CAP9 only] */
11863 @@ -39,10 +40,14 @@
11864 #define AT91_PMC_PCSR (AT91_PMC + 0x18) /* Peripheral Clock Status Register */
11866 #define AT91_CKGR_UCKR (AT91_PMC + 0x1C) /* UTMI Clock Register [SAM9RL, CAP9] */
11867 +#define AT91_PMC_UPLLEN (1 << 16) /* UTMI PLL Enable */
11868 +#define AT91_PMC_UPLLCOUNT (0xf << 20) /* UTMI PLL Start-up Time */
11869 +#define AT91_PMC_BIASEN (1 << 24) /* UTMI BIAS Enable */
11870 +#define AT91_PMC_BIASCOUNT (0xf << 28) /* UTMI PLL Start-up Time */
11872 #define AT91_CKGR_MOR (AT91_PMC + 0x20) /* Main Oscillator Register [not on SAM9RL] */
11873 #define AT91_PMC_MOSCEN (1 << 0) /* Main Oscillator Enable */
11874 -#define AT91_PMC_OSCBYPASS (1 << 1) /* Oscillator Bypass [AT91SAM926x only] */
11875 +#define AT91_PMC_OSCBYPASS (1 << 1) /* Oscillator Bypass [SAM9x, CAP9] */
11876 #define AT91_PMC_OSCOUNT (0xff << 8) /* Main Oscillator Start-up Time */
11878 #define AT91_CKGR_MCFR (AT91_PMC + 0x24) /* Main Clock Frequency Register */
11880 #define AT91_PMC_OUT (3 << 14) /* PLL Clock Frequency Range */
11881 #define AT91_PMC_MUL (0x7ff << 16) /* PLL Multiplier */
11882 #define AT91_PMC_USBDIV (3 << 28) /* USB Divisor (PLLB only) */
11883 +#define AT91CAP9_PMC_USBDIV (0xf << 28) /* USB Divisor (PLLB only) [AT91CAP9 revC only] */
11884 #define AT91_PMC_USBDIV_1 (0 << 28)
11885 #define AT91_PMC_USBDIV_2 (1 << 28)
11886 #define AT91_PMC_USBDIV_4 (2 << 28)
11887 @@ -76,10 +82,13 @@
11888 #define AT91_PMC_PRES_32 (5 << 2)
11889 #define AT91_PMC_PRES_64 (6 << 2)
11890 #define AT91_PMC_MDIV (3 << 8) /* Master Clock Division */
11891 -#define AT91_PMC_MDIV_1 (0 << 8)
11892 -#define AT91_PMC_MDIV_2 (1 << 8)
11893 -#define AT91_PMC_MDIV_3 (2 << 8)
11894 -#define AT91_PMC_MDIV_4 (3 << 8)
11895 +#define AT91RM9200_PMC_MDIV_1 (0 << 8) /* [AT91RM9200 only] */
11896 +#define AT91RM9200_PMC_MDIV_2 (1 << 8)
11897 +#define AT91RM9200_PMC_MDIV_3 (2 << 8)
11898 +#define AT91RM9200_PMC_MDIV_4 (3 << 8)
11899 +#define AT91SAM9_PMC_MDIV_1 (0 << 8) /* [SAM9,CAP9 only] */
11900 +#define AT91SAM9_PMC_MDIV_2 (1 << 8)
11901 +#define AT91SAM9_PMC_MDIV_4 (2 << 8)
11903 #define AT91_PMC_PCKR(n) (AT91_PMC + 0x40 + ((n) * 4)) /* Programmable Clock 0-3 Registers */
11905 @@ -90,10 +99,17 @@
11906 #define AT91_PMC_LOCKA (1 << 1) /* PLLA Lock */
11907 #define AT91_PMC_LOCKB (1 << 2) /* PLLB Lock */
11908 #define AT91_PMC_MCKRDY (1 << 3) /* Master Clock */
11909 +#define AT91_PMC_LOCKU (1 << 6) /* UPLL Lock [AT91CAP9 only] */
11910 +#define AT91_PMC_OSCSEL (1 << 7) /* Slow Clock Oscillator [AT91CAP9 revC only] */
11911 #define AT91_PMC_PCK0RDY (1 << 8) /* Programmable Clock 0 */
11912 #define AT91_PMC_PCK1RDY (1 << 9) /* Programmable Clock 1 */
11913 #define AT91_PMC_PCK2RDY (1 << 10) /* Programmable Clock 2 */
11914 #define AT91_PMC_PCK3RDY (1 << 11) /* Programmable Clock 3 */
11915 #define AT91_PMC_IMR (AT91_PMC + 0x6c) /* Interrupt Mask Register */
11917 +#define AT91_PMC_PROT (AT91_PMC + 0xe4) /* Protect Register [AT91CAP9 revC only] */
11918 +#define AT91_PMC_PROTKEY 0x504d4301 /* Activation Code */
11920 +#define AT91_PMC_VER (AT91_PMC + 0xfc) /* PMC Module Version [AT91CAP9 only] */
11923 --- a/include/asm-arm/arch-at91/at91_rstc.h
11924 +++ b/include/asm-arm/arch-at91/at91_rstc.h
11927 * include/asm-arm/arch-at91/at91_rstc.h
11929 + * Copyright (C) 2007 Andrew Victor
11930 + * Copyright (C) 2007 Atmel Corporation.
11932 * Reset Controller (RSTC) - System peripherals regsters.
11933 * Based on AT91SAM9261 datasheet revision D.
11935 --- a/include/asm-arm/arch-at91/at91_rtt.h
11936 +++ b/include/asm-arm/arch-at91/at91_rtt.h
11939 * include/asm-arm/arch-at91/at91_rtt.h
11941 + * Copyright (C) 2007 Andrew Victor
11942 + * Copyright (C) 2007 Atmel Corporation.
11944 * Real-time Timer (RTT) - System peripherals regsters.
11945 * Based on AT91SAM9261 datasheet revision D.
11947 --- a/include/asm-arm/arch-at91/at91_shdwc.h
11948 +++ b/include/asm-arm/arch-at91/at91_shdwc.h
11951 * include/asm-arm/arch-at91/at91_shdwc.h
11953 + * Copyright (C) 2007 Andrew Victor
11954 + * Copyright (C) 2007 Atmel Corporation.
11956 * Shutdown Controller (SHDWC) - System peripherals regsters.
11957 * Based on AT91SAM9261 datasheet revision D.
11959 @@ -24,10 +27,12 @@
11960 #define AT91_SHDW_WKMODE0_LOW 2
11961 #define AT91_SHDW_WKMODE0_ANYLEVEL 3
11962 #define AT91_SHDW_CPTWK0 (0xf << 4) /* Counter On Wake Up 0 */
11963 +#define AT91_SHDW_CPTWK0_(x) ((x) << 4)
11964 #define AT91_SHDW_RTTWKEN (1 << 16) /* Real Time Timer Wake-up Enable */
11966 #define AT91_SHDW_SR (AT91_SHDWC + 0x08) /* Shut Down Status Register */
11967 #define AT91_SHDW_WAKEUP0 (1 << 0) /* Wake-up 0 Status */
11968 #define AT91_SHDW_RTTWK (1 << 16) /* Real-time Timer Wake-up */
11969 +#define AT91_SHDW_RTCWK (1 << 17) /* Real-time Clock Wake-up [SAM9RL] */
11973 +++ b/include/asm-arm/arch-at91/at91_tsc.h
11976 + * include/asm-arm/arch-at91/at91_tsc.h
11978 + * Copyright (C) 2008 Andrew Victor
11980 + * Touch Screen ADC Controller (TSC)
11981 + * Based on AT91SAM9RL64 preliminary draft datasheet.
11983 + * This program is free software; you can redistribute it and/or modify it
11984 + * under the terms of the GNU General Public License as published by the
11985 + * Free Software Foundation; either version 2 of the License, or (at your
11986 + * option) any later version.
11989 +#ifndef AT91_TSC_H
11990 +#define AT91_TSC_H
11992 +#define AT91_TSADCC_CR 0x00 /* Control register */
11993 +#define AT91_TSADCC_SWRST (1 << 0) /* Software Reset*/
11994 +#define AT91_TSADCC_START (1 << 1) /* Start conversion */
11996 +#define AT91_TSADCC_MR 0x04 /* Mode register */
11997 +#define AT91_TSADCC_TSAMOD (3 << 0) /* ADC mode */
11998 +#define AT91_TSADCC_LOWRES (1 << 4) /* Resolution selection */
11999 +#define AT91_TSADCC_SLEEP (1 << 5) /* Sleep mode */
12000 +#define AT91_TSADCC_PENDET (1 << 6) /* Pen Detect selection */
12001 +#define AT91_TSADCC_PRESCAL (0x3f << 8) /* Prescalar Rate Selection */
12002 +#define AT91_TSADCC_STARTUP (0x7f << 16) /* Start Up time */
12003 +#define AT91_TSADCC_SHTIM (0xf << 24) /* Sample & Hold time */
12004 +#define AT91_TSADCC_PENDBC (0xf << 28) /* Pen Detect debouncing time */
12006 +#define AT91_TSADCC_TRGR 0x08 /* Trigger register */
12007 +#define AT91_TSADCC_TRGMOD (7 << 0) /* Trigger mode */
12008 +#define AT91_TSADCC_TRGMOD_NONE (0 << 0)
12009 +#define AT91_TSADCC_TRGMOD_EXT_RISING (1 << 0)
12010 +#define AT91_TSADCC_TRGMOD_EXT_FALLING (2 << 0)
12011 +#define AT91_TSADCC_TRGMOD_EXT_ANY (3 << 0)
12012 +#define AT91_TSADCC_TRGMOD_PENDET (4 << 0)
12013 +#define AT91_TSADCC_TRGMOD_PERIOD (5 << 0)
12014 +#define AT91_TSADCC_TRGMOD_CONTINUOUS (6 << 0)
12015 +#define AT91_TSADCC_TRGPER (0xffff << 16) /* Trigger period */
12017 +#define AT91_TSADCC_TSR 0x0C /* Touch Screen register */
12018 +#define AT91_TSADCC_TSFREQ (0xf << 0) /* TS Frequency in Interleaved mode */
12019 +#define AT91_TSADCC_TSSHTIM (0xf << 24) /* Sample & Hold time */
12021 +#define AT91_TSADCC_CHER 0x10 /* Channel Enable register */
12022 +#define AT91_TSADCC_CHDR 0x14 /* Channel Disable register */
12023 +#define AT91_TSADCC_CHSR 0x18 /* Channel Status register */
12024 +#define AT91_TSADCC_CH(n) (1 << (n)) /* Channel number */
12026 +#define AT91_TSADCC_SR 0x1C /* Status register */
12027 +#define AT91_TSADCC_EOC(n) (1 << ((n)+0)) /* End of conversion for channel N */
12028 +#define AT91_TSADCC_OVRE(n) (1 << ((n)+8)) /* Overrun error for channel N */
12029 +#define AT91_TSADCC_DRDY (1 << 16) /* Data Ready */
12030 +#define AT91_TSADCC_GOVRE (1 << 17) /* General Overrun Error */
12031 +#define AT91_TSADCC_ENDRX (1 << 18) /* End of RX Buffer */
12032 +#define AT91_TSADCC_RXBUFF (1 << 19) /* TX Buffer full */
12033 +#define AT91_TSADCC_PENCNT (1 << 20) /* Pen contact */
12034 +#define AT91_TSADCC_NOCNT (1 << 21) /* No contact */
12036 +#define AT91_TSADCC_LCDR 0x20 /* Last Converted Data register */
12037 +#define AT91_TSADCC_DATA (0x3ff << 0) /* Channel data */
12039 +#define AT91_TSADCC_IER 0x24 /* Interrupt Enable register */
12040 +#define AT91_TSADCC_IDR 0x28 /* Interrupt Disable register */
12041 +#define AT91_TSADCC_IMR 0x2C /* Interrupt Mask register */
12042 +#define AT91_TSADCC_CDR0 0x30 /* Channel Data 0 */
12043 +#define AT91_TSADCC_CDR1 0x34 /* Channel Data 1 */
12044 +#define AT91_TSADCC_CDR2 0x38 /* Channel Data 2 */
12045 +#define AT91_TSADCC_CDR3 0x3C /* Channel Data 3 */
12046 +#define AT91_TSADCC_CDR4 0x40 /* Channel Data 4 */
12047 +#define AT91_TSADCC_CDR5 0x44 /* Channel Data 5 */
12051 --- a/include/asm-arm/arch-at91/at91_wdt.h
12052 +++ b/include/asm-arm/arch-at91/at91_wdt.h
12055 * include/asm-arm/arch-at91/at91_wdt.h
12057 + * Copyright (C) 2007 Andrew Victor
12058 + * Copyright (C) 2007 Atmel Corporation.
12060 * Watchdog Timer (WDT) - System peripherals regsters.
12061 * Based on AT91SAM9261 datasheet revision D.
12063 --- a/include/asm-arm/arch-at91/at91cap9.h
12064 +++ b/include/asm-arm/arch-at91/at91cap9.h
12065 @@ -101,7 +101,10 @@
12066 #define AT91_RTT (0xfffffd20 - AT91_BASE_SYS)
12067 #define AT91_PIT (0xfffffd30 - AT91_BASE_SYS)
12068 #define AT91_WDT (0xfffffd40 - AT91_BASE_SYS)
12069 -#define AT91_GPBR (0xfffffd50 - AT91_BASE_SYS)
12070 +#define AT91_SCKCR (0xfffffd50 - AT91_BASE_SYS)
12071 +#define AT91_GPBR (cpu_is_at91cap9_revB() ? \
12072 + (0xfffffd50 - AT91_BASE_SYS) : \
12073 + (0xfffffd60 - AT91_BASE_SYS))
12075 #define AT91_USART0 AT91CAP9_BASE_US0
12076 #define AT91_USART1 AT91CAP9_BASE_US1
12077 @@ -118,7 +121,7 @@
12078 #define AT91CAP9_ROM_SIZE (32 * SZ_1K) /* Internal ROM size (32Kb) */
12080 #define AT91CAP9_LCDC_BASE 0x00500000 /* LCD Controller */
12081 -#define AT91CAP9_UDPHS_BASE 0x00600000 /* USB High Speed Device Port */
12082 +#define AT91CAP9_UDPHS_FIFO 0x00600000 /* USB High Speed Device Port */
12083 #define AT91CAP9_UHP_BASE 0x00700000 /* USB Host controller */
12085 #define CONFIG_DRAM_BASE AT91_CHIPSELECT_6
12087 +++ b/include/asm-arm/arch-at91/at91cap9_ddrsdr.h
12090 + * include/asm-arm/arch-at91/at91cap9_ddrsdr.h
12092 + * (C) 2008 Andrew Victor
12094 + * DDR/SDR Controller (DDRSDRC) - System peripherals registers.
12095 + * Based on AT91CAP9 datasheet revision B.
12097 + * This program is free software; you can redistribute it and/or modify
12098 + * it under the terms of the GNU General Public License as published by
12099 + * the Free Software Foundation; either version 2 of the License, or
12100 + * (at your option) any later version.
12103 +#ifndef AT91CAP9_DDRSDR_H
12104 +#define AT91CAP9_DDRSDR_H
12106 +#define AT91_DDRSDRC_MR (AT91_DDRSDRC + 0x00) /* Mode Register */
12107 +#define AT91_DDRSDRC_MODE (0xf << 0) /* Command Mode */
12108 +#define AT91_DDRSDRC_MODE_NORMAL 0
12109 +#define AT91_DDRSDRC_MODE_NOP 1
12110 +#define AT91_DDRSDRC_MODE_PRECHARGE 2
12111 +#define AT91_DDRSDRC_MODE_LMR 3
12112 +#define AT91_DDRSDRC_MODE_REFRESH 4
12113 +#define AT91_DDRSDRC_MODE_EXT_LMR 5
12114 +#define AT91_DDRSDRC_MODE_DEEP 6
12116 +#define AT91_DDRSDRC_RTR (AT91_DDRSDRC + 0x04) /* Refresh Timer Register */
12117 +#define AT91_DDRSDRC_COUNT (0xfff << 0) /* Refresh Timer Counter */
12119 +#define AT91_DDRSDRC_CR (AT91_DDRSDRC + 0x08) /* Configuration Register */
12120 +#define AT91_DDRSDRC_NC (3 << 0) /* Number of Column Bits */
12121 +#define AT91_DDRSDRC_NC_SDR8 (0 << 0)
12122 +#define AT91_DDRSDRC_NC_SDR9 (1 << 0)
12123 +#define AT91_DDRSDRC_NC_SDR10 (2 << 0)
12124 +#define AT91_DDRSDRC_NC_SDR11 (3 << 0)
12125 +#define AT91_DDRSDRC_NC_DDR9 (0 << 0)
12126 +#define AT91_DDRSDRC_NC_DDR10 (1 << 0)
12127 +#define AT91_DDRSDRC_NC_DDR11 (2 << 0)
12128 +#define AT91_DDRSDRC_NC_DDR12 (3 << 0)
12129 +#define AT91_DDRSDRC_NR (3 << 2) /* Number of Row Bits */
12130 +#define AT91_DDRSDRC_NR_11 (0 << 2)
12131 +#define AT91_DDRSDRC_NR_12 (1 << 2)
12132 +#define AT91_DDRSDRC_NR_13 (2 << 2)
12133 +#define AT91_DDRSDRC_CAS (7 << 4) /* CAS Latency */
12134 +#define AT91_DDRSDRC_CAS_2 (2 << 4)
12135 +#define AT91_DDRSDRC_CAS_3 (3 << 4)
12136 +#define AT91_DDRSDRC_CAS_25 (6 << 4)
12137 +#define AT91_DDRSDRC_DLL (1 << 7) /* Reset DLL */
12138 +#define AT91_DDRSDRC_DICDS (1 << 8) /* Output impedance control */
12140 +#define AT91_DDRSDRC_T0PR (AT91_DDRSDRC + 0x0C) /* Timing 0 Register */
12141 +#define AT91_DDRSDRC_TRAS (0xf << 0) /* Active to Precharge delay */
12142 +#define AT91_DDRSDRC_TRCD (0xf << 4) /* Row to Column delay */
12143 +#define AT91_DDRSDRC_TWR (0xf << 8) /* Write recovery delay */
12144 +#define AT91_DDRSDRC_TRC (0xf << 12) /* Row cycle delay */
12145 +#define AT91_DDRSDRC_TRP (0xf << 16) /* Row precharge delay */
12146 +#define AT91_DDRSDRC_TRRD (0xf << 20) /* Active BankA to BankB */
12147 +#define AT91_DDRSDRC_TWTR (1 << 24) /* Internal Write to Read delay */
12148 +#define AT91_DDRSDRC_TMRD (0xf << 28) /* Load mode to active/refresh delay */
12150 +#define AT91_DDRSDRC_T1PR (AT91_DDRSDRC + 0x10) /* Timing 1 Register */
12151 +#define AT91_DDRSDRC_TRFC (0x1f << 0) /* Row Cycle Delay */
12152 +#define AT91_DDRSDRC_TXSNR (0xff << 8) /* Exit self-refresh to non-read */
12153 +#define AT91_DDRSDRC_TXSRD (0xff << 16) /* Exit self-refresh to read */
12154 +#define AT91_DDRSDRC_TXP (0xf << 24) /* Exit power-down delay */
12156 +#define AT91_DDRSDRC_LPR (AT91_DDRSDRC + 0x18) /* Low Power Register */
12157 +#define AT91_DDRSDRC_LPCB (3 << 0) /* Low-power Configurations */
12158 +#define AT91_DDRSDRC_LPCB_DISABLE 0
12159 +#define AT91_DDRSDRC_LPCB_SELF_REFRESH 1
12160 +#define AT91_DDRSDRC_LPCB_POWER_DOWN 2
12161 +#define AT91_DDRSDRC_LPCB_DEEP_POWER_DOWN 3
12162 +#define AT91_DDRSDRC_CLKFR (1 << 2) /* Clock Frozen */
12163 +#define AT91_DDRSDRC_PASR (7 << 4) /* Partial Array Self Refresh */
12164 +#define AT91_DDRSDRC_TCSR (3 << 8) /* Temperature Compensated Self Refresh */
12165 +#define AT91_DDRSDRC_DS (3 << 10) /* Drive Strength */
12166 +#define AT91_DDRSDRC_TIMEOUT (3 << 12) /* Time to define when Low Power Mode is enabled */
12167 +#define AT91_DDRSDRC_TIMEOUT_0_CLK_CYCLES (0 << 12)
12168 +#define AT91_DDRSDRC_TIMEOUT_64_CLK_CYCLES (1 << 12)
12169 +#define AT91_DDRSDRC_TIMEOUT_128_CLK_CYCLES (2 << 12)
12171 +#define AT91_DDRSDRC_MDR (AT91_DDRSDRC + 0x1C) /* Memory Device Register */
12172 +#define AT91_DDRSDRC_MD (3 << 0) /* Memory Device Type */
12173 +#define AT91_DDRSDRC_MD_SDR 0
12174 +#define AT91_DDRSDRC_MD_LOW_POWER_SDR 1
12175 +#define AT91_DDRSDRC_MD_DDR 2
12176 +#define AT91_DDRSDRC_MD_LOW_POWER_DDR 3
12178 +#define AT91_DDRSDRC_DLLR (AT91_DDRSDRC + 0x20) /* DLL Information Register */
12179 +#define AT91_DDRSDRC_MDINC (1 << 0) /* Master Delay increment */
12180 +#define AT91_DDRSDRC_MDDEC (1 << 1) /* Master Delay decrement */
12181 +#define AT91_DDRSDRC_MDOVF (1 << 2) /* Master Delay Overflow */
12182 +#define AT91_DDRSDRC_SDCOVF (1 << 3) /* Slave Delay Correction Overflow */
12183 +#define AT91_DDRSDRC_SDCUDF (1 << 4) /* Slave Delay Correction Underflow */
12184 +#define AT91_DDRSDRC_SDERF (1 << 5) /* Slave Delay Correction error */
12185 +#define AT91_DDRSDRC_MDVAL (0xff << 8) /* Master Delay value */
12186 +#define AT91_DDRSDRC_SDVAL (0xff << 16) /* Slave Delay value */
12187 +#define AT91_DDRSDRC_SDCVAL (0xff << 24) /* Slave Delay Correction value */
12191 --- a/include/asm-arm/arch-at91/at91cap9_matrix.h
12192 +++ b/include/asm-arm/arch-at91/at91cap9_matrix.h
12193 @@ -106,6 +106,11 @@
12194 #define AT91_MPBS0_SFR (AT91_MATRIX + 0x114) /* MPBlock Slave 0 Special Function Register */
12195 #define AT91_MPBS1_SFR (AT91_MATRIX + 0x11C) /* MPBlock Slave 1 Special Function Register */
12197 +#define AT91_MATRIX_UDPHS (AT91_MATRIX + 0x118) /* USBHS Special Function Register [AT91CAP9 only] */
12198 +#define AT91_MATRIX_SELECT_UDPHS (0 << 31) /* select High Speed UDP */
12199 +#define AT91_MATRIX_SELECT_UDP (1 << 31) /* select standard UDP */
12200 +#define AT91_MATRIX_UDPHS_BYPASS_LOCK (1 << 30) /* bypass lock bit */
12202 #define AT91_MATRIX_EBICSA (AT91_MATRIX + 0x120) /* EBI Chip Select Assignment Register */
12203 #define AT91_MATRIX_EBI_CS1A (1 << 1) /* Chip Select 1 Assignment */
12204 #define AT91_MATRIX_EBI_CS1A_SMC (0 << 1)
12205 --- a/include/asm-arm/arch-at91/at91sam9260_matrix.h
12206 +++ b/include/asm-arm/arch-at91/at91sam9260_matrix.h
12209 * include/asm-arm/arch-at91/at91sam9260_matrix.h
12211 + * Copyright (C) 2007 Atmel Corporation.
12213 * Memory Controllers (MATRIX, EBI) - System peripherals registers.
12214 * Based on AT91SAM9260 datasheet revision B.
12216 --- a/include/asm-arm/arch-at91/at91sam9261_matrix.h
12217 +++ b/include/asm-arm/arch-at91/at91sam9261_matrix.h
12220 * include/asm-arm/arch-at91/at91sam9261_matrix.h
12222 + * Copyright (C) 2007 Atmel Corporation.
12224 * Memory Controllers (MATRIX, EBI) - System peripherals registers.
12225 * Based on AT91SAM9261 datasheet revision D.
12227 --- a/include/asm-arm/arch-at91/at91sam926x_mc.h
12231 - * include/asm-arm/arch-at91/at91sam926x_mc.h
12233 - * Memory Controllers (SMC, SDRAMC) - System peripherals registers.
12234 - * Based on AT91SAM9261 datasheet revision D.
12236 - * This program is free software; you can redistribute it and/or modify
12237 - * it under the terms of the GNU General Public License as published by
12238 - * the Free Software Foundation; either version 2 of the License, or
12239 - * (at your option) any later version.
12242 -#ifndef AT91SAM926x_MC_H
12243 -#define AT91SAM926x_MC_H
12245 -/* SDRAM Controller (SDRAMC) registers */
12246 -#define AT91_SDRAMC_MR (AT91_SDRAMC + 0x00) /* SDRAM Controller Mode Register */
12247 -#define AT91_SDRAMC_MODE (0xf << 0) /* Command Mode */
12248 -#define AT91_SDRAMC_MODE_NORMAL 0
12249 -#define AT91_SDRAMC_MODE_NOP 1
12250 -#define AT91_SDRAMC_MODE_PRECHARGE 2
12251 -#define AT91_SDRAMC_MODE_LMR 3
12252 -#define AT91_SDRAMC_MODE_REFRESH 4
12253 -#define AT91_SDRAMC_MODE_EXT_LMR 5
12254 -#define AT91_SDRAMC_MODE_DEEP 6
12256 -#define AT91_SDRAMC_TR (AT91_SDRAMC + 0x04) /* SDRAM Controller Refresh Timer Register */
12257 -#define AT91_SDRAMC_COUNT (0xfff << 0) /* Refresh Timer Counter */
12259 -#define AT91_SDRAMC_CR (AT91_SDRAMC + 0x08) /* SDRAM Controller Configuration Register */
12260 -#define AT91_SDRAMC_NC (3 << 0) /* Number of Column Bits */
12261 -#define AT91_SDRAMC_NC_8 (0 << 0)
12262 -#define AT91_SDRAMC_NC_9 (1 << 0)
12263 -#define AT91_SDRAMC_NC_10 (2 << 0)
12264 -#define AT91_SDRAMC_NC_11 (3 << 0)
12265 -#define AT91_SDRAMC_NR (3 << 2) /* Number of Row Bits */
12266 -#define AT91_SDRAMC_NR_11 (0 << 2)
12267 -#define AT91_SDRAMC_NR_12 (1 << 2)
12268 -#define AT91_SDRAMC_NR_13 (2 << 2)
12269 -#define AT91_SDRAMC_NB (1 << 4) /* Number of Banks */
12270 -#define AT91_SDRAMC_NB_2 (0 << 4)
12271 -#define AT91_SDRAMC_NB_4 (1 << 4)
12272 -#define AT91_SDRAMC_CAS (3 << 5) /* CAS Latency */
12273 -#define AT91_SDRAMC_CAS_1 (1 << 5)
12274 -#define AT91_SDRAMC_CAS_2 (2 << 5)
12275 -#define AT91_SDRAMC_CAS_3 (3 << 5)
12276 -#define AT91_SDRAMC_DBW (1 << 7) /* Data Bus Width */
12277 -#define AT91_SDRAMC_DBW_32 (0 << 7)
12278 -#define AT91_SDRAMC_DBW_16 (1 << 7)
12279 -#define AT91_SDRAMC_TWR (0xf << 8) /* Write Recovery Delay */
12280 -#define AT91_SDRAMC_TRC (0xf << 12) /* Row Cycle Delay */
12281 -#define AT91_SDRAMC_TRP (0xf << 16) /* Row Precharge Delay */
12282 -#define AT91_SDRAMC_TRCD (0xf << 20) /* Row to Column Delay */
12283 -#define AT91_SDRAMC_TRAS (0xf << 24) /* Active to Precharge Delay */
12284 -#define AT91_SDRAMC_TXSR (0xf << 28) /* Exit Self Refresh to Active Delay */
12286 -#define AT91_SDRAMC_LPR (AT91_SDRAMC + 0x10) /* SDRAM Controller Low Power Register */
12287 -#define AT91_SDRAMC_LPCB (3 << 0) /* Low-power Configurations */
12288 -#define AT91_SDRAMC_LPCB_DISABLE 0
12289 -#define AT91_SDRAMC_LPCB_SELF_REFRESH 1
12290 -#define AT91_SDRAMC_LPCB_POWER_DOWN 2
12291 -#define AT91_SDRAMC_LPCB_DEEP_POWER_DOWN 3
12292 -#define AT91_SDRAMC_PASR (7 << 4) /* Partial Array Self Refresh */
12293 -#define AT91_SDRAMC_TCSR (3 << 8) /* Temperature Compensated Self Refresh */
12294 -#define AT91_SDRAMC_DS (3 << 10) /* Drive Strenght */
12295 -#define AT91_SDRAMC_TIMEOUT (3 << 12) /* Time to define when Low Power Mode is enabled */
12296 -#define AT91_SDRAMC_TIMEOUT_0_CLK_CYCLES (0 << 12)
12297 -#define AT91_SDRAMC_TIMEOUT_64_CLK_CYCLES (1 << 12)
12298 -#define AT91_SDRAMC_TIMEOUT_128_CLK_CYCLES (2 << 12)
12300 -#define AT91_SDRAMC_IER (AT91_SDRAMC + 0x14) /* SDRAM Controller Interrupt Enable Register */
12301 -#define AT91_SDRAMC_IDR (AT91_SDRAMC + 0x18) /* SDRAM Controller Interrupt Disable Register */
12302 -#define AT91_SDRAMC_IMR (AT91_SDRAMC + 0x1C) /* SDRAM Controller Interrupt Mask Register */
12303 -#define AT91_SDRAMC_ISR (AT91_SDRAMC + 0x20) /* SDRAM Controller Interrupt Status Register */
12304 -#define AT91_SDRAMC_RES (1 << 0) /* Refresh Error Status */
12306 -#define AT91_SDRAMC_MDR (AT91_SDRAMC + 0x24) /* SDRAM Memory Device Register */
12307 -#define AT91_SDRAMC_MD (3 << 0) /* Memory Device Type */
12308 -#define AT91_SDRAMC_MD_SDRAM 0
12309 -#define AT91_SDRAMC_MD_LOW_POWER_SDRAM 1
12312 -/* Static Memory Controller (SMC) registers */
12313 -#define AT91_SMC_SETUP(n) (AT91_SMC + 0x00 + ((n)*0x10)) /* Setup Register for CS n */
12314 -#define AT91_SMC_NWESETUP (0x3f << 0) /* NWE Setup Length */
12315 -#define AT91_SMC_NWESETUP_(x) ((x) << 0)
12316 -#define AT91_SMC_NCS_WRSETUP (0x3f << 8) /* NCS Setup Length in Write Access */
12317 -#define AT91_SMC_NCS_WRSETUP_(x) ((x) << 8)
12318 -#define AT91_SMC_NRDSETUP (0x3f << 16) /* NRD Setup Length */
12319 -#define AT91_SMC_NRDSETUP_(x) ((x) << 16)
12320 -#define AT91_SMC_NCS_RDSETUP (0x3f << 24) /* NCS Setup Length in Read Access */
12321 -#define AT91_SMC_NCS_RDSETUP_(x) ((x) << 24)
12323 -#define AT91_SMC_PULSE(n) (AT91_SMC + 0x04 + ((n)*0x10)) /* Pulse Register for CS n */
12324 -#define AT91_SMC_NWEPULSE (0x7f << 0) /* NWE Pulse Length */
12325 -#define AT91_SMC_NWEPULSE_(x) ((x) << 0)
12326 -#define AT91_SMC_NCS_WRPULSE (0x7f << 8) /* NCS Pulse Length in Write Access */
12327 -#define AT91_SMC_NCS_WRPULSE_(x)((x) << 8)
12328 -#define AT91_SMC_NRDPULSE (0x7f << 16) /* NRD Pulse Length */
12329 -#define AT91_SMC_NRDPULSE_(x) ((x) << 16)
12330 -#define AT91_SMC_NCS_RDPULSE (0x7f << 24) /* NCS Pulse Length in Read Access */
12331 -#define AT91_SMC_NCS_RDPULSE_(x)((x) << 24)
12333 -#define AT91_SMC_CYCLE(n) (AT91_SMC + 0x08 + ((n)*0x10)) /* Cycle Register for CS n */
12334 -#define AT91_SMC_NWECYCLE (0x1ff << 0 ) /* Total Write Cycle Length */
12335 -#define AT91_SMC_NWECYCLE_(x) ((x) << 0)
12336 -#define AT91_SMC_NRDCYCLE (0x1ff << 16) /* Total Read Cycle Length */
12337 -#define AT91_SMC_NRDCYCLE_(x) ((x) << 16)
12339 -#define AT91_SMC_MODE(n) (AT91_SMC + 0x0c + ((n)*0x10)) /* Mode Register for CS n */
12340 -#define AT91_SMC_READMODE (1 << 0) /* Read Mode */
12341 -#define AT91_SMC_WRITEMODE (1 << 1) /* Write Mode */
12342 -#define AT91_SMC_EXNWMODE (3 << 4) /* NWAIT Mode */
12343 -#define AT91_SMC_EXNWMODE_DISABLE (0 << 4)
12344 -#define AT91_SMC_EXNWMODE_FROZEN (2 << 4)
12345 -#define AT91_SMC_EXNWMODE_READY (3 << 4)
12346 -#define AT91_SMC_BAT (1 << 8) /* Byte Access Type */
12347 -#define AT91_SMC_BAT_SELECT (0 << 8)
12348 -#define AT91_SMC_BAT_WRITE (1 << 8)
12349 -#define AT91_SMC_DBW (3 << 12) /* Data Bus Width */
12350 -#define AT91_SMC_DBW_8 (0 << 12)
12351 -#define AT91_SMC_DBW_16 (1 << 12)
12352 -#define AT91_SMC_DBW_32 (2 << 12)
12353 -#define AT91_SMC_TDF (0xf << 16) /* Data Float Time. */
12354 -#define AT91_SMC_TDF_(x) ((x) << 16)
12355 -#define AT91_SMC_TDFMODE (1 << 20) /* TDF Optimization - Enabled */
12356 -#define AT91_SMC_PMEN (1 << 24) /* Page Mode Enabled */
12357 -#define AT91_SMC_PS (3 << 28) /* Page Size */
12358 -#define AT91_SMC_PS_4 (0 << 28)
12359 -#define AT91_SMC_PS_8 (1 << 28)
12360 -#define AT91_SMC_PS_16 (2 << 28)
12361 -#define AT91_SMC_PS_32 (3 << 28)
12363 -#if defined(AT91_SMC1) /* The AT91SAM9263 has 2 Static Memory contollers */
12364 -#define AT91_SMC1_SETUP(n) (AT91_SMC1 + 0x00 + ((n)*0x10)) /* Setup Register for CS n */
12365 -#define AT91_SMC1_PULSE(n) (AT91_SMC1 + 0x04 + ((n)*0x10)) /* Pulse Register for CS n */
12366 -#define AT91_SMC1_CYCLE(n) (AT91_SMC1 + 0x08 + ((n)*0x10)) /* Cycle Register for CS n */
12367 -#define AT91_SMC1_MODE(n) (AT91_SMC1 + 0x0c + ((n)*0x10)) /* Mode Register for CS n */
12372 +++ b/include/asm-arm/arch-at91/at91sam9_sdramc.h
12375 + * include/asm-arm/arch-at91/at91sam9_sdramc.h
12377 + * Copyright (C) 2007 Andrew Victor
12378 + * Copyright (C) 2007 Atmel Corporation.
12380 + * SDRAM Controllers (SDRAMC) - System peripherals registers.
12381 + * Based on AT91SAM9261 datasheet revision D.
12383 + * This program is free software; you can redistribute it and/or modify
12384 + * it under the terms of the GNU General Public License as published by
12385 + * the Free Software Foundation; either version 2 of the License, or
12386 + * (at your option) any later version.
12389 +#ifndef AT91SAM9_SDRAMC_H
12390 +#define AT91SAM9_SDRAMC_H
12392 +/* SDRAM Controller (SDRAMC) registers */
12393 +#define AT91_SDRAMC_MR (AT91_SDRAMC + 0x00) /* SDRAM Controller Mode Register */
12394 +#define AT91_SDRAMC_MODE (0xf << 0) /* Command Mode */
12395 +#define AT91_SDRAMC_MODE_NORMAL 0
12396 +#define AT91_SDRAMC_MODE_NOP 1
12397 +#define AT91_SDRAMC_MODE_PRECHARGE 2
12398 +#define AT91_SDRAMC_MODE_LMR 3
12399 +#define AT91_SDRAMC_MODE_REFRESH 4
12400 +#define AT91_SDRAMC_MODE_EXT_LMR 5
12401 +#define AT91_SDRAMC_MODE_DEEP 6
12403 +#define AT91_SDRAMC_TR (AT91_SDRAMC + 0x04) /* SDRAM Controller Refresh Timer Register */
12404 +#define AT91_SDRAMC_COUNT (0xfff << 0) /* Refresh Timer Counter */
12406 +#define AT91_SDRAMC_CR (AT91_SDRAMC + 0x08) /* SDRAM Controller Configuration Register */
12407 +#define AT91_SDRAMC_NC (3 << 0) /* Number of Column Bits */
12408 +#define AT91_SDRAMC_NC_8 (0 << 0)
12409 +#define AT91_SDRAMC_NC_9 (1 << 0)
12410 +#define AT91_SDRAMC_NC_10 (2 << 0)
12411 +#define AT91_SDRAMC_NC_11 (3 << 0)
12412 +#define AT91_SDRAMC_NR (3 << 2) /* Number of Row Bits */
12413 +#define AT91_SDRAMC_NR_11 (0 << 2)
12414 +#define AT91_SDRAMC_NR_12 (1 << 2)
12415 +#define AT91_SDRAMC_NR_13 (2 << 2)
12416 +#define AT91_SDRAMC_NB (1 << 4) /* Number of Banks */
12417 +#define AT91_SDRAMC_NB_2 (0 << 4)
12418 +#define AT91_SDRAMC_NB_4 (1 << 4)
12419 +#define AT91_SDRAMC_CAS (3 << 5) /* CAS Latency */
12420 +#define AT91_SDRAMC_CAS_1 (1 << 5)
12421 +#define AT91_SDRAMC_CAS_2 (2 << 5)
12422 +#define AT91_SDRAMC_CAS_3 (3 << 5)
12423 +#define AT91_SDRAMC_DBW (1 << 7) /* Data Bus Width */
12424 +#define AT91_SDRAMC_DBW_32 (0 << 7)
12425 +#define AT91_SDRAMC_DBW_16 (1 << 7)
12426 +#define AT91_SDRAMC_TWR (0xf << 8) /* Write Recovery Delay */
12427 +#define AT91_SDRAMC_TRC (0xf << 12) /* Row Cycle Delay */
12428 +#define AT91_SDRAMC_TRP (0xf << 16) /* Row Precharge Delay */
12429 +#define AT91_SDRAMC_TRCD (0xf << 20) /* Row to Column Delay */
12430 +#define AT91_SDRAMC_TRAS (0xf << 24) /* Active to Precharge Delay */
12431 +#define AT91_SDRAMC_TXSR (0xf << 28) /* Exit Self Refresh to Active Delay */
12433 +#define AT91_SDRAMC_LPR (AT91_SDRAMC + 0x10) /* SDRAM Controller Low Power Register */
12434 +#define AT91_SDRAMC_LPCB (3 << 0) /* Low-power Configurations */
12435 +#define AT91_SDRAMC_LPCB_DISABLE 0
12436 +#define AT91_SDRAMC_LPCB_SELF_REFRESH 1
12437 +#define AT91_SDRAMC_LPCB_POWER_DOWN 2
12438 +#define AT91_SDRAMC_LPCB_DEEP_POWER_DOWN 3
12439 +#define AT91_SDRAMC_PASR (7 << 4) /* Partial Array Self Refresh */
12440 +#define AT91_SDRAMC_TCSR (3 << 8) /* Temperature Compensated Self Refresh */
12441 +#define AT91_SDRAMC_DS (3 << 10) /* Drive Strength */
12442 +#define AT91_SDRAMC_TIMEOUT (3 << 12) /* Time to define when Low Power Mode is enabled */
12443 +#define AT91_SDRAMC_TIMEOUT_0_CLK_CYCLES (0 << 12)
12444 +#define AT91_SDRAMC_TIMEOUT_64_CLK_CYCLES (1 << 12)
12445 +#define AT91_SDRAMC_TIMEOUT_128_CLK_CYCLES (2 << 12)
12447 +#define AT91_SDRAMC_IER (AT91_SDRAMC + 0x14) /* SDRAM Controller Interrupt Enable Register */
12448 +#define AT91_SDRAMC_IDR (AT91_SDRAMC + 0x18) /* SDRAM Controller Interrupt Disable Register */
12449 +#define AT91_SDRAMC_IMR (AT91_SDRAMC + 0x1C) /* SDRAM Controller Interrupt Mask Register */
12450 +#define AT91_SDRAMC_ISR (AT91_SDRAMC + 0x20) /* SDRAM Controller Interrupt Status Register */
12451 +#define AT91_SDRAMC_RES (1 << 0) /* Refresh Error Status */
12453 +#define AT91_SDRAMC_MDR (AT91_SDRAMC + 0x24) /* SDRAM Memory Device Register */
12454 +#define AT91_SDRAMC_MD (3 << 0) /* Memory Device Type */
12455 +#define AT91_SDRAMC_MD_SDRAM 0
12456 +#define AT91_SDRAMC_MD_LOW_POWER_SDRAM 1
12461 +++ b/include/asm-arm/arch-at91/at91sam9_smc.h
12464 + * include/asm-arm/arch-at91/at91sam9_smc.h
12466 + * Copyright (C) 2007 Andrew Victor
12467 + * Copyright (C) 2007 Atmel Corporation.
12469 + * Static Memory Controllers (SMC) - System peripherals registers.
12470 + * Based on AT91SAM9261 datasheet revision D.
12472 + * This program is free software; you can redistribute it and/or modify
12473 + * it under the terms of the GNU General Public License as published by
12474 + * the Free Software Foundation; either version 2 of the License, or
12475 + * (at your option) any later version.
12478 +#ifndef AT91SAM9_SMC_H
12479 +#define AT91SAM9_SMC_H
12481 +#define AT91_SMC_SETUP(n) (AT91_SMC + 0x00 + ((n)*0x10)) /* Setup Register for CS n */
12482 +#define AT91_SMC_NWESETUP (0x3f << 0) /* NWE Setup Length */
12483 +#define AT91_SMC_NWESETUP_(x) ((x) << 0)
12484 +#define AT91_SMC_NCS_WRSETUP (0x3f << 8) /* NCS Setup Length in Write Access */
12485 +#define AT91_SMC_NCS_WRSETUP_(x) ((x) << 8)
12486 +#define AT91_SMC_NRDSETUP (0x3f << 16) /* NRD Setup Length */
12487 +#define AT91_SMC_NRDSETUP_(x) ((x) << 16)
12488 +#define AT91_SMC_NCS_RDSETUP (0x3f << 24) /* NCS Setup Length in Read Access */
12489 +#define AT91_SMC_NCS_RDSETUP_(x) ((x) << 24)
12491 +#define AT91_SMC_PULSE(n) (AT91_SMC + 0x04 + ((n)*0x10)) /* Pulse Register for CS n */
12492 +#define AT91_SMC_NWEPULSE (0x7f << 0) /* NWE Pulse Length */
12493 +#define AT91_SMC_NWEPULSE_(x) ((x) << 0)
12494 +#define AT91_SMC_NCS_WRPULSE (0x7f << 8) /* NCS Pulse Length in Write Access */
12495 +#define AT91_SMC_NCS_WRPULSE_(x)((x) << 8)
12496 +#define AT91_SMC_NRDPULSE (0x7f << 16) /* NRD Pulse Length */
12497 +#define AT91_SMC_NRDPULSE_(x) ((x) << 16)
12498 +#define AT91_SMC_NCS_RDPULSE (0x7f << 24) /* NCS Pulse Length in Read Access */
12499 +#define AT91_SMC_NCS_RDPULSE_(x)((x) << 24)
12501 +#define AT91_SMC_CYCLE(n) (AT91_SMC + 0x08 + ((n)*0x10)) /* Cycle Register for CS n */
12502 +#define AT91_SMC_NWECYCLE (0x1ff << 0 ) /* Total Write Cycle Length */
12503 +#define AT91_SMC_NWECYCLE_(x) ((x) << 0)
12504 +#define AT91_SMC_NRDCYCLE (0x1ff << 16) /* Total Read Cycle Length */
12505 +#define AT91_SMC_NRDCYCLE_(x) ((x) << 16)
12507 +#define AT91_SMC_MODE(n) (AT91_SMC + 0x0c + ((n)*0x10)) /* Mode Register for CS n */
12508 +#define AT91_SMC_READMODE (1 << 0) /* Read Mode */
12509 +#define AT91_SMC_WRITEMODE (1 << 1) /* Write Mode */
12510 +#define AT91_SMC_EXNWMODE (3 << 4) /* NWAIT Mode */
12511 +#define AT91_SMC_EXNWMODE_DISABLE (0 << 4)
12512 +#define AT91_SMC_EXNWMODE_FROZEN (2 << 4)
12513 +#define AT91_SMC_EXNWMODE_READY (3 << 4)
12514 +#define AT91_SMC_BAT (1 << 8) /* Byte Access Type */
12515 +#define AT91_SMC_BAT_SELECT (0 << 8)
12516 +#define AT91_SMC_BAT_WRITE (1 << 8)
12517 +#define AT91_SMC_DBW (3 << 12) /* Data Bus Width */
12518 +#define AT91_SMC_DBW_8 (0 << 12)
12519 +#define AT91_SMC_DBW_16 (1 << 12)
12520 +#define AT91_SMC_DBW_32 (2 << 12)
12521 +#define AT91_SMC_TDF (0xf << 16) /* Data Float Time. */
12522 +#define AT91_SMC_TDF_(x) ((x) << 16)
12523 +#define AT91_SMC_TDFMODE (1 << 20) /* TDF Optimization - Enabled */
12524 +#define AT91_SMC_PMEN (1 << 24) /* Page Mode Enabled */
12525 +#define AT91_SMC_PS (3 << 28) /* Page Size */
12526 +#define AT91_SMC_PS_4 (0 << 28)
12527 +#define AT91_SMC_PS_8 (1 << 28)
12528 +#define AT91_SMC_PS_16 (2 << 28)
12529 +#define AT91_SMC_PS_32 (3 << 28)
12531 +#if defined(AT91_SMC1) /* The AT91SAM9263 has 2 Static Memory contollers */
12532 +#define AT91_SMC1_SETUP(n) (AT91_SMC1 + 0x00 + ((n)*0x10)) /* Setup Register for CS n */
12533 +#define AT91_SMC1_PULSE(n) (AT91_SMC1 + 0x04 + ((n)*0x10)) /* Pulse Register for CS n */
12534 +#define AT91_SMC1_CYCLE(n) (AT91_SMC1 + 0x08 + ((n)*0x10)) /* Cycle Register for CS n */
12535 +#define AT91_SMC1_MODE(n) (AT91_SMC1 + 0x0c + ((n)*0x10)) /* Mode Register for CS n */
12539 --- a/include/asm-arm/arch-at91/at91sam9rl.h
12540 +++ b/include/asm-arm/arch-at91/at91sam9rl.h
12541 @@ -110,6 +110,6 @@
12542 #define AT91SAM9RL_ROM_SIZE (2 * SZ_16K) /* Internal ROM size (32Kb) */
12544 #define AT91SAM9RL_LCDC_BASE 0x00500000 /* LCD Controller */
12545 -#define AT91SAM9RL_UDPHS_BASE 0x00600000 /* USB Device HS controller */
12546 +#define AT91SAM9RL_UDPHS_FIFO 0x00600000 /* USB Device HS controller */
12549 --- a/include/asm-arm/arch-at91/board.h
12550 +++ b/include/asm-arm/arch-at91/board.h
12552 #include <linux/i2c.h>
12553 #include <linux/leds.h>
12554 #include <linux/spi/spi.h>
12555 +#include <linux/usb/atmel_usba_udc.h>
12558 struct at91_udc_data {
12559 @@ -45,6 +46,9 @@ struct at91_udc_data {
12561 extern void __init at91_add_device_udc(struct at91_udc_data *data);
12563 + /* USB High Speed Device */
12564 +extern void __init at91_add_device_usba(struct usba_platform_data *data);
12566 /* Compact Flash */
12567 struct at91_cf_data {
12568 u8 irq_pin; /* I/O IRQ */
12569 @@ -158,6 +162,9 @@ extern void __init at91_add_device_ac97(
12571 extern void __init at91_add_device_isi(void);
12573 + /* Touchscreen Controller */
12574 +extern void __init at91_add_device_tsadcc(void);
12577 extern void __init at91_init_leds(u8 cpu_led, u8 timer_led);
12578 extern void __init at91_gpio_leds(struct gpio_led *leds, int nr);
12579 --- a/include/asm-arm/arch-at91/cpu.h
12580 +++ b/include/asm-arm/arch-at91/cpu.h
12581 @@ -48,6 +48,17 @@ static inline unsigned long at91_arch_id
12582 return (at91_sys_read(AT91_DBGU_CIDR) & AT91_CIDR_ARCH);
12585 +#ifdef CONFIG_ARCH_AT91CAP9
12586 +#include <asm/arch/at91_pmc.h>
12588 +#define ARCH_REVISION_CAP9_B 0x399
12589 +#define ARCH_REVISION_CAP9_C 0x601
12591 +static inline unsigned long at91cap9_rev_identify(void)
12593 + return (at91_sys_read(AT91_PMC_VER));
12597 #ifdef CONFIG_ARCH_AT91RM9200
12598 #define cpu_is_at91rm9200() (at91_cpu_identify() == ARCH_ID_AT91RM9200)
12599 @@ -83,8 +94,12 @@ static inline unsigned long at91_arch_id
12601 #ifdef CONFIG_ARCH_AT91CAP9
12602 #define cpu_is_at91cap9() (at91_cpu_identify() == ARCH_ID_AT91CAP9)
12603 +#define cpu_is_at91cap9_revB() (at91cap9_rev_identify() == ARCH_REVISION_CAP9_B)
12604 +#define cpu_is_at91cap9_revC() (at91cap9_rev_identify() == ARCH_REVISION_CAP9_C)
12606 #define cpu_is_at91cap9() (0)
12607 +#define cpu_is_at91cap9_revB() (0)
12608 +#define cpu_is_at91cap9_revC() (0)
12613 +++ b/include/asm-arm/arch-at91/ics1523.h
12615 +//*----------------------------------------------------------------------------
12616 +//* ATMEL Microcontroller Software Support - ROUSSET -
12617 +//*----------------------------------------------------------------------------
12618 +//* The software is delivered "AS IS" without warranty or condition of any
12619 +//* kind, either express, implied or statutory. This includes without
12620 +//* limitation any warranty or condition with respect to merchantability or
12621 +//* fitness for any particular purpose, or against the infringements of
12622 +//* intellectual property rights of others.
12623 +//*----------------------------------------------------------------------------
12624 +//* File Name : ics1523.h
12625 +//* Object : Clock Generator Prototyping File.
12627 +//* 1.0 08/28/02 ED : Creation
12628 +//* 1.2 13/01/03 FB : Update on lib V3
12629 +//*----------------------------------------------------------------------------
12634 +/*-------------------------------------------*/
12635 +/* ICS1523 TWI Serial Clock Definition */
12636 +/*-------------------------------------------*/
12638 +#define ICS_MIN_CLOCK 100 /* Min Frequency Access Clock KHz */
12639 +#define ICS_MAX_CLOCK 400 /* Max Frequency Access Clock KHz */
12640 +#define ICS_TRANSFER_RATE ICS_MAX_CLOCK /* Transfer speed to apply */
12642 +#define ICS_WRITE_CLK_PNB 30 /* TWCK Clock Periods required to write */
12643 +#define ICS_READ_CLK_PNB 40 /* TWCK Clock Periods required to read */
12645 +/*-------------------------------------------*/
12646 +/* ICS1523 Write Operation Definition */
12647 +/*-------------------------------------------*/
12649 +#define ICS1523_ACCESS_OK 0 /* OK */
12650 +#define ICS1523_ACCESS_ERROR -1 /* NOK */
12652 +/*-------------------------------------------*/
12653 +/* ICS1523 Device Addresses Definition */
12654 +/*-------------------------------------------*/
12656 +#define ICS_ADDR 0x26 /* Device Address */
12658 +/*--------------------------------------------------*/
12659 +/* ICS1523 Registers Internal Addresses Definition */
12660 +/*--------------------------------------------------*/
12662 +#define ICS_ICR 0x0 /* Input Control Register */
12663 +#define ICS_LCR 0x1 /* Loop Control Register */
12664 +#define ICS_FD0 0x2 /* PLL FeedBack Divider LSBs */
12665 +#define ICS_FD1 0x3 /* PLL FeedBack Divider MSBs */
12666 +#define ICS_DPAO 0x4 /* Dynamic Phase Aligner Offset */
12667 +#define ICS_DPAC 0x5 /* Dynamic Phase Aligner Resolution */
12668 +#define ICS_OE 0x6 /* Output Enables Register */
12669 +#define ICS_OD 0x7 /* Osc Divider Register */
12670 +#define ICS_SWRST 0x8 /* DPA & PLL Reset Register */
12671 +#define ICS_VID 0x10 /* Chip Version Register */
12672 +#define ICS_RID 0x11 /* Chip Revision Register */
12673 +#define ICS_SR 0x12 /* Status Register */
12675 +/*------------------------------------------------------*/
12676 +/* ICS1523 Input Control Register Bits Definition */
12677 +/*------------------------------------------------------*/
12679 +#define ICS_PDEN 0x1 /* Phase Detector Enable */
12680 +#define ICS_PDPOL 0x2 /* Phase Detector Enable Polarity */
12681 +#define ICS_REFPOL 0x4 /* External Reference Polarity */
12682 +#define ICS_FBKPOL 0x8 /* External Feedback Polarity */
12683 +#define ICS_FBKSEL 0x10 /* External Feedback Select */
12684 +#define ICS_FUNCSEL 0x20 /* Function Out Select */
12685 +#define ICS_ENPLS 0x40 /* Enable PLL Lock/Ref Status Output */
12686 +#define ICS_ENDLS 0x80 /* Enable DPA Lock/Ref Status Output */
12688 +/*-----------------------------------------------------*/
12689 +/* ICS1523 Loop Control Register Bits Definition */
12690 +/*-----------------------------------------------------*/
12692 +#define ICS_PFD 0x7 /* Phase Detector Gain */
12693 +#define ICS_PSD 0x30 /* Post-Scaler Divider */
12695 +/*----------------------------------------------------*/
12696 +/* ICS1523 PLL FeedBack Divider LSBs Definition */
12697 +/*----------------------------------------------------*/
12699 +#define ICS_FBDL 0xFF /* PLL FeedBack Divider LSBs */
12701 +/*----------------------------------------------------*/
12702 +/* ICS1523 PLL FeedBack Divider MSBs Definition */
12703 +/*----------------------------------------------------*/
12705 +#define ICS_FBDM 0xF /* PLL FeedBack Divider MSBs */
12707 +/*------------------------------------------------------------*/
12708 +/* ICS1523 Dynamic Phase Aligner Offset Bits Definition */
12709 +/*------------------------------------------------------------*/
12711 +#define ICS_DPAOS 0x2F /* Dynamic Phase Aligner Offset */
12712 +#define ICS_FILSEL 0x80 /* Loop Filter Select */
12714 +/*----------------------------------------------------------------*/
12715 +/* ICS1523 Dynamic Phase Aligner Resolution Bits Definition */
12716 +/*----------------------------------------------------------------*/
12718 +#define ICS_DPARES 0x3 /* Dynamic Phase Aligner Resolution */
12719 +#define ICS_MMREV 0xFC /* Metal Mask Revision Number */
12721 +/*-------------------------------------------------------*/
12722 +/* ICS1523 Output Enables Register Bits Definition */
12723 +/*-------------------------------------------------------*/
12725 +#define ICS_OEPCK 0x1 /* Output Enable for PECL PCLK Outputs */
12726 +#define ICS_OETCK 0x2 /* Output Enable for STTL CLK Output */
12727 +#define ICS_OEP2 0x4 /* Output Enable for PECL CLK/2 Outputs */
12728 +#define ICS_OET2 0x8 /* Output Enable for STTL CLK/2 Output */
12729 +#define ICS_OEF 0x10 /* Output Enable for STTL FUNC Output */
12730 +#define ICS_CLK2INV 0x20 /* CLK/2 Invert */
12731 +#define ICS_OSCL 0xC0 /* SSTL Clock Scaler */
12733 +/*----------------------------------------------------*/
12734 +/* ICS1523 Osc Divider Register Bits Definition */
12735 +/*----------------------------------------------------*/
12737 +#define ICS_OSCDIV 0x7F /* Oscillator Divider Modulus */
12738 +#define ICS_INSEL 0x80 /* Input Select */
12740 +/*---------------------------------------------------*/
12741 +/* ICS1523 DPA & PLL Reset Register Definition */
12742 +/*---------------------------------------------------*/
12744 +#define ICS_DPAR 0x0A /* DPA Reset Command */
12745 +#define ICS_PLLR 0x50 /* PLL Reset Command */
12747 +/*------------------------------------------------*/
12748 +/* ICS1523 Chip Version Register Definition */
12749 +/*------------------------------------------------*/
12751 +#define ICS_CHIPV 0xFF /* Chip Version */
12753 +/*-------------------------------------------------*/
12754 +/* ICS1523 Chip Revision Register Definition */
12755 +/*-------------------------------------------------*/
12757 +#define ICS_CHIPR 0xFF /* Chip Revision */
12759 +/*------------------------------------------*/
12760 +/* ICS1523 Status Register Definition */
12761 +/*------------------------------------------*/
12763 +#define ICS_DPALOCK 0x1 /* DPA Lock Status */
12764 +#define ICS_PLLLOCK 0x2 /* PLL Lock Status */
12766 +int at91_ics1523_init(void);
12768 +#endif /* ics1523_h */
12770 +++ b/include/asm-arm/arch-at91/spi.h
12773 + * Serial Peripheral Interface (SPI) driver for the Atmel AT91RM9200
12775 + * (c) SAN People (Pty) Ltd
12777 + * This program is free software; you can redistribute it and/or
12778 + * modify it under the terms of the GNU General Public License
12779 + * as published by the Free Software Foundation; either version
12780 + * 2 of the License, or (at your option) any later version.
12783 +#ifndef AT91_LEGACY_SPI_H
12784 +#define AT91_LEGACY_SPI_H
12786 +#define SPI_MAJOR 153 /* registered device number */
12788 +#define DEFAULT_SPI_CLK 6000000
12791 +/* Maximum number of buffers in a single SPI transfer.
12792 + * DataFlash uses maximum of 2
12793 + * spidev interface supports up to 8.
12795 +#define MAX_SPI_TRANSFERS 8
12796 +#define NR_SPI_DEVICES 4 /* number of devices on SPI bus */
12799 + * Describes the buffers for a SPI transfer.
12800 + * A transmit & receive buffer must be specified for each transfer
12802 +struct spi_transfer_list {
12803 + void* tx[MAX_SPI_TRANSFERS]; /* transmit */
12804 + int txlen[MAX_SPI_TRANSFERS];
12805 + void* rx[MAX_SPI_TRANSFERS]; /* receive */
12806 + int rxlen[MAX_SPI_TRANSFERS];
12807 + int nr_transfers; /* number of transfers */
12808 + int curr; /* current transfer */
12811 +struct spi_local {
12812 + unsigned int pcs; /* Peripheral Chip Select value */
12814 + struct spi_transfer_list *xfers; /* current transfer list */
12815 + dma_addr_t tx, rx; /* DMA address for current transfer */
12816 + dma_addr_t txnext, rxnext; /* DMA address for next transfer */
12820 +/* Exported functions */
12821 +extern void spi_access_bus(short device);
12822 +extern void spi_release_bus(short device);
12823 +extern int spi_transfer(struct spi_transfer_list* list);
12826 --- a/include/asm-arm/arch-at91/timex.h
12827 +++ b/include/asm-arm/arch-at91/timex.h
12828 @@ -27,14 +27,29 @@
12830 #define CLOCK_TICK_RATE (AT91_SLOW_CLOCK)
12832 -#elif defined(CONFIG_ARCH_AT91SAM9260) || defined(CONFIG_ARCH_AT91SAM9261)
12833 +#elif defined(CONFIG_ARCH_AT91SAM9260)
12835 +#if defined(CONFIG_MACH_USB_A9260) || defined(CONFIG_MACH_QIL_A9260)
12836 +#define AT91SAM9_MASTER_CLOCK 90000000
12838 +#define AT91SAM9_MASTER_CLOCK 99300000
12841 +#define CLOCK_TICK_RATE (AT91SAM9_MASTER_CLOCK/16)
12843 +#elif defined(CONFIG_ARCH_AT91SAM9261)
12845 #define AT91SAM9_MASTER_CLOCK 99300000
12846 #define CLOCK_TICK_RATE (AT91SAM9_MASTER_CLOCK/16)
12848 #elif defined(CONFIG_ARCH_AT91SAM9263)
12850 +#if defined(CONFIG_MACH_USB_A9263)
12851 +#define AT91SAM9_MASTER_CLOCK 90000000
12853 #define AT91SAM9_MASTER_CLOCK 99959500
12856 #define CLOCK_TICK_RATE (AT91SAM9_MASTER_CLOCK/16)
12858 #elif defined(CONFIG_ARCH_AT91SAM9RL)
12859 --- a/include/asm-arm/arch-ks8695/devices.h
12860 +++ b/include/asm-arm/arch-ks8695/devices.h
12861 @@ -18,6 +18,11 @@ extern void __init ks8695_add_device_wan
12862 extern void __init ks8695_add_device_lan(void);
12863 extern void __init ks8695_add_device_hpna(void);
12866 +extern short ks8695_leds_cpu;
12867 +extern short ks8695_leds_timer;
12868 +extern void __init ks8695_init_leds(u8 cpu_led, u8 timer_led);
12871 #define KS8695_MODE_PCI 0
12872 #define KS8695_MODE_MINIPCI 1
12873 --- a/include/linux/clk.h
12874 +++ b/include/linux/clk.h
12875 @@ -121,4 +121,24 @@ int clk_set_parent(struct clk *clk, stru
12877 struct clk *clk_get_parent(struct clk *clk);
12880 + * clk_must_disable - report whether a clock's users must disable it
12881 + * @clk: one node in the clock tree
12883 + * This routine returns true only if the upcoming system state requires
12884 + * disabling the specified clock.
12886 + * It's common for platform power states to constrain certain clocks (and
12887 + * their descendants) to be unavailable, while other states allow that
12888 + * clock to be active. A platform's power states often include an "all on"
12889 + * mode; system wide sleep states like "standby" or "suspend-to-RAM"; and
12890 + * operating states which sacrifice functionality for lower power usage.
12892 + * The constraint value is commonly tested in device driver suspend(), to
12893 + * leave clocks active if they are needed for features like wakeup events.
12894 + * On platforms that support reduced functionality operating states, the
12895 + * constraint may also need to be tested during resume() and probe() calls.
12897 +int clk_must_disable(struct clk *clk);
12900 --- a/include/linux/i2c-id.h
12901 +++ b/include/linux/i2c-id.h
12902 @@ -131,6 +131,7 @@
12904 /* --- PCA 9564 based algorithms */
12905 #define I2C_HW_A_ISA 0x1a0000 /* generic ISA Bus interface card */
12906 +#define I2C_HW_A_PLAT 0x1a0001 /* generic platform_bus interface */
12908 /* --- PowerPC on-chip adapters */
12909 #define I2C_HW_OCP 0x120000 /* IBM on-chip I2C adapter */
12911 +++ b/include/linux/usb/atmel_usba_udc.h
12914 +* Platform data definitions for Atmel USBA gadget driver.
12916 +#ifndef __LINUX_USB_USBA_H
12917 +#define __LINUX_USB_USBA_H
12919 +struct usba_ep_data {
12928 +struct usba_platform_data {
12931 + struct usba_ep_data ep[0];
12934 +#endif /* __LINUX_USB_USBA_H */
12936 --- a/include/video/atmel_lcdc.h
12937 +++ b/include/video/atmel_lcdc.h
12938 @@ -39,6 +39,7 @@ struct atmel_lcdfb_info {
12941 bool lcdcon_is_backlight;
12945 unsigned int default_lcdcon2;
12946 --- a/sound/soc/at91/eti_b1_wm8731.c
12947 +++ b/sound/soc/at91/eti_b1_wm8731.c
12949 #include <sound/soc.h>
12950 #include <sound/soc-dapm.h>
12952 -#include <asm/arch/hardware.h>
12953 -#include <asm/arch/at91_pio.h>
12954 +#include <asm/hardware.h>
12955 #include <asm/arch/gpio.h>
12957 #include "../codecs/wm8731.h"
12962 -#define AT91_PIO_TF1 (1 << (AT91_PIN_PB6 - PIN_BASE) % 32)
12963 -#define AT91_PIO_TK1 (1 << (AT91_PIN_PB7 - PIN_BASE) % 32)
12964 -#define AT91_PIO_TD1 (1 << (AT91_PIN_PB8 - PIN_BASE) % 32)
12965 -#define AT91_PIO_RD1 (1 << (AT91_PIN_PB9 - PIN_BASE) % 32)
12966 -#define AT91_PIO_RK1 (1 << (AT91_PIN_PB10 - PIN_BASE) % 32)
12967 -#define AT91_PIO_RF1 (1 << (AT91_PIN_PB11 - PIN_BASE) % 32)
12969 static struct clk *pck1_clk;
12970 static struct clk *pllb_clk;
12972 @@ -276,7 +268,6 @@ static struct platform_device *eti_b1_sn
12973 static int __init eti_b1_init(void)
12976 - u32 ssc_pio_lines;
12977 struct at91_ssc_periph *ssc = eti_b1_dai.cpu_dai->private_data;
12979 if (!request_mem_region(AT91RM9200_BASE_SSC1, SZ_16K, "soc-audio")) {
12980 @@ -310,19 +301,12 @@ static int __init eti_b1_init(void)
12981 goto fail_io_unmap;
12984 - ssc_pio_lines = AT91_PIO_TF1 | AT91_PIO_TK1 | AT91_PIO_TD1
12985 - | AT91_PIO_RD1 /* | AT91_PIO_RK1 */ | AT91_PIO_RF1;
12987 - /* Reset all PIO registers and assign lines to peripheral A */
12988 - at91_sys_write(AT91_PIOB + PIO_PDR, ssc_pio_lines);
12989 - at91_sys_write(AT91_PIOB + PIO_ODR, ssc_pio_lines);
12990 - at91_sys_write(AT91_PIOB + PIO_IFDR, ssc_pio_lines);
12991 - at91_sys_write(AT91_PIOB + PIO_CODR, ssc_pio_lines);
12992 - at91_sys_write(AT91_PIOB + PIO_IDR, ssc_pio_lines);
12993 - at91_sys_write(AT91_PIOB + PIO_MDDR, ssc_pio_lines);
12994 - at91_sys_write(AT91_PIOB + PIO_PUDR, ssc_pio_lines);
12995 - at91_sys_write(AT91_PIOB + PIO_ASR, ssc_pio_lines);
12996 - at91_sys_write(AT91_PIOB + PIO_OWDR, ssc_pio_lines);
12997 + at91_set_A_periph(AT91_PIN_PB6, 0); /* TF1 */
12998 + at91_set_A_periph(AT91_PIN_PB7, 0); /* TK1 */
12999 + at91_set_A_periph(AT91_PIN_PB8, 0); /* TD1 */
13000 + at91_set_A_periph(AT91_PIN_PB9, 0); /* RD1 */
13001 +/* at91_set_A_periph(AT91_PIN_PB10, 0);*/ /* RK1 */
13002 + at91_set_A_periph(AT91_PIN_PB11, 0); /* RF1 */
13005 * Set PCK1 parent to PLLB and its rate to 12 Mhz.
13006 --- a/sound/spi/at73c213.c
13007 +++ b/sound/spi/at73c213.c
13008 @@ -114,7 +114,11 @@ snd_at73c213_write_reg(struct snd_at73c2
13009 static struct snd_pcm_hardware snd_at73c213_playback_hw = {
13010 .info = SNDRV_PCM_INFO_INTERLEAVED |
13011 SNDRV_PCM_INFO_BLOCK_TRANSFER,
13012 +#ifdef __BIG_ENDIAN
13013 .formats = SNDRV_PCM_FMTBIT_S16_BE,
13015 + .formats = SNDRV_PCM_FMTBIT_S16_LE,
13017 .rates = SNDRV_PCM_RATE_CONTINUOUS,
13018 .rate_min = 8000, /* Replaced by chip->bitrate later. */
13019 .rate_max = 50000, /* Replaced by chip->bitrate later. */