fc840f62dfda65322fe088303f29df4e24240f5a
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-sa1100 / assabet.c
1 /*
2  * linux/arch/arm/mach-sa1100/assabet.c
3  *
4  * Author: Nicolas Pitre
5  *
6  * This file contains all Assabet-specific tweaks.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as
10  * published by the Free Software Foundation.
11  */
12 #include <linux/init.h>
13 #include <linux/kernel.h>
14 #include <linux/module.h>
15 #include <linux/errno.h>
16 #include <linux/ioport.h>
17 #include <linux/platform_data/sa11x0-serial.h>
18 #include <linux/serial_core.h>
19 #include <linux/platform_device.h>
20 #include <linux/mfd/ucb1x00.h>
21 #include <linux/mtd/mtd.h>
22 #include <linux/mtd/partitions.h>
23 #include <linux/delay.h>
24 #include <linux/mm.h>
25 #include <linux/leds.h>
26 #include <linux/slab.h>
27
28 #include <video/sa1100fb.h>
29
30 #include <mach/hardware.h>
31 #include <asm/mach-types.h>
32 #include <asm/setup.h>
33 #include <asm/page.h>
34 #include <asm/pgtable-hwdef.h>
35 #include <asm/pgtable.h>
36 #include <asm/tlbflush.h>
37
38 #include <asm/mach/arch.h>
39 #include <asm/mach/flash.h>
40 #include <asm/mach/irda.h>
41 #include <asm/mach/map.h>
42 #include <mach/assabet.h>
43 #include <linux/platform_data/mfd-mcp-sa11x0.h>
44 #include <mach/irqs.h>
45
46 #include "generic.h"
47
48 #define ASSABET_BCR_DB1110 \
49         (ASSABET_BCR_SPK_OFF    | \
50          ASSABET_BCR_LED_GREEN  | ASSABET_BCR_LED_RED   | \
51          ASSABET_BCR_RS232EN    | ASSABET_BCR_LCD_12RGB | \
52          ASSABET_BCR_IRDA_MD0)
53
54 #define ASSABET_BCR_DB1111 \
55         (ASSABET_BCR_SPK_OFF    | \
56          ASSABET_BCR_LED_GREEN  | ASSABET_BCR_LED_RED   | \
57          ASSABET_BCR_RS232EN    | ASSABET_BCR_LCD_12RGB | \
58          ASSABET_BCR_CF_BUS_OFF | ASSABET_BCR_STEREO_LB | \
59          ASSABET_BCR_IRDA_MD0   | ASSABET_BCR_CF_RST)
60
61 unsigned long SCR_value = ASSABET_SCR_INIT;
62 EXPORT_SYMBOL(SCR_value);
63
64 static unsigned long BCR_value = ASSABET_BCR_DB1110;
65
66 void ASSABET_BCR_frob(unsigned int mask, unsigned int val)
67 {
68         unsigned long flags;
69
70         local_irq_save(flags);
71         BCR_value = (BCR_value & ~mask) | val;
72         ASSABET_BCR = BCR_value;
73         local_irq_restore(flags);
74 }
75
76 EXPORT_SYMBOL(ASSABET_BCR_frob);
77
78 /*
79  * The codec reset goes to three devices, so we need to release
80  * the rest when any one of these requests it.  However, that
81  * causes the ADV7171 to consume around 100mA - more than half
82  * the LCD-blanked power.
83  *
84  * With the ADV7171, LCD and backlight enabled, we go over
85  * budget on the MAX846 Li-Ion charger, and if no Li-Ion battery
86  * is connected, the Assabet crashes.
87  */
88 #define RST_UCB1X00 (1 << 0)
89 #define RST_UDA1341 (1 << 1)
90 #define RST_ADV7171 (1 << 2)
91
92 #define SDA GPIO_GPIO(15)
93 #define SCK GPIO_GPIO(18)
94 #define MOD GPIO_GPIO(17)
95
96 static void adv7171_start(void)
97 {
98         GPSR = SCK;
99         udelay(1);
100         GPSR = SDA;
101         udelay(2);
102         GPCR = SDA;
103 }
104
105 static void adv7171_stop(void)
106 {
107         GPSR = SCK;
108         udelay(2);
109         GPSR = SDA;
110         udelay(1);
111 }
112
113 static void adv7171_send(unsigned byte)
114 {
115         unsigned i;
116
117         for (i = 0; i < 8; i++, byte <<= 1) {
118                 GPCR = SCK;
119                 udelay(1);
120                 if (byte & 0x80)
121                         GPSR = SDA;
122                 else
123                         GPCR = SDA;
124                 udelay(1);
125                 GPSR = SCK;
126                 udelay(1);
127         }
128         GPCR = SCK;
129         udelay(1);
130         GPSR = SDA;
131         udelay(1);
132         GPDR &= ~SDA;
133         GPSR = SCK;
134         udelay(1);
135         if (GPLR & SDA)
136                 printk(KERN_WARNING "No ACK from ADV7171\n");
137         udelay(1);
138         GPCR = SCK | SDA;
139         udelay(1);
140         GPDR |= SDA;
141         udelay(1);
142 }
143
144 static void adv7171_write(unsigned reg, unsigned val)
145 {
146         unsigned gpdr = GPDR;
147         unsigned gplr = GPLR;
148
149         ASSABET_BCR = BCR_value | ASSABET_BCR_AUDIO_ON;
150         udelay(100);
151
152         GPCR = SDA | SCK | MOD; /* clear L3 mode to ensure UDA1341 doesn't respond */
153         GPDR = (GPDR | SCK | MOD) & ~SDA;
154         udelay(10);
155         if (!(GPLR & SDA))
156                 printk(KERN_WARNING "Something dragging SDA down?\n");
157         GPDR |= SDA;
158
159         adv7171_start();
160         adv7171_send(0x54);
161         adv7171_send(reg);
162         adv7171_send(val);
163         adv7171_stop();
164
165         /* Restore GPIO state for L3 bus */
166         GPSR = gplr & (SDA | SCK | MOD);
167         GPCR = (~gplr) & (SDA | SCK | MOD);
168         GPDR = gpdr;
169 }
170
171 static void adv7171_sleep(void)
172 {
173         /* Put the ADV7171 into sleep mode */
174         adv7171_write(0x04, 0x40);
175 }
176
177 static unsigned codec_nreset;
178
179 static void assabet_codec_reset(unsigned mask, int set)
180 {
181         unsigned long flags;
182         bool old;
183
184         local_irq_save(flags);
185         old = !codec_nreset;
186         if (set)
187                 codec_nreset &= ~mask;
188         else
189                 codec_nreset |= mask;
190
191         if (old != !codec_nreset) {
192                 if (codec_nreset) {
193                         ASSABET_BCR_set(ASSABET_BCR_NCODEC_RST);
194                         adv7171_sleep();
195                 } else {
196                         ASSABET_BCR_clear(ASSABET_BCR_NCODEC_RST);
197                 }
198         }
199         local_irq_restore(flags);
200 }
201
202 static void assabet_ucb1x00_reset(enum ucb1x00_reset state)
203 {
204         int set = state == UCB_RST_REMOVE || state == UCB_RST_SUSPEND ||
205                 state == UCB_RST_PROBE_FAIL;
206         assabet_codec_reset(RST_UCB1X00, set);
207 }
208
209 void assabet_uda1341_reset(int set)
210 {
211         assabet_codec_reset(RST_UDA1341, set);
212 }
213 EXPORT_SYMBOL(assabet_uda1341_reset);
214
215
216 /*
217  * Assabet flash support code.
218  */
219
220 #ifdef ASSABET_REV_4
221 /*
222  * Phase 4 Assabet has two 28F160B3 flash parts in bank 0:
223  */
224 static struct mtd_partition assabet_partitions[] = {
225         {
226                 .name           = "bootloader",
227                 .size           = 0x00020000,
228                 .offset         = 0,
229                 .mask_flags     = MTD_WRITEABLE,
230         }, {
231                 .name           = "bootloader params",
232                 .size           = 0x00020000,
233                 .offset         = MTDPART_OFS_APPEND,
234                 .mask_flags     = MTD_WRITEABLE,
235         }, {
236                 .name           = "jffs",
237                 .size           = MTDPART_SIZ_FULL,
238                 .offset         = MTDPART_OFS_APPEND,
239         }
240 };
241 #else
242 /*
243  * Phase 5 Assabet has two 28F128J3A flash parts in bank 0:
244  */
245 static struct mtd_partition assabet_partitions[] = {
246         {
247                 .name           = "bootloader",
248                 .size           = 0x00040000,
249                 .offset         = 0,
250                 .mask_flags     = MTD_WRITEABLE,
251         }, {
252                 .name           = "bootloader params",
253                 .size           = 0x00040000,
254                 .offset         = MTDPART_OFS_APPEND,
255                 .mask_flags     = MTD_WRITEABLE,
256         }, {
257                 .name           = "jffs",
258                 .size           = MTDPART_SIZ_FULL,
259                 .offset         = MTDPART_OFS_APPEND,
260         }
261 };
262 #endif
263
264 static struct flash_platform_data assabet_flash_data = {
265         .map_name       = "cfi_probe",
266         .parts          = assabet_partitions,
267         .nr_parts       = ARRAY_SIZE(assabet_partitions),
268 };
269
270 static struct resource assabet_flash_resources[] = {
271         DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M),
272         DEFINE_RES_MEM(SA1100_CS1_PHYS, SZ_32M),
273 };
274
275
276 /*
277  * Assabet IrDA support code.
278  */
279
280 static int assabet_irda_set_power(struct device *dev, unsigned int state)
281 {
282         static unsigned int bcr_state[4] = {
283                 ASSABET_BCR_IRDA_MD0,
284                 ASSABET_BCR_IRDA_MD1|ASSABET_BCR_IRDA_MD0,
285                 ASSABET_BCR_IRDA_MD1,
286                 0
287         };
288
289         if (state < 4) {
290                 state = bcr_state[state];
291                 ASSABET_BCR_clear(state ^ (ASSABET_BCR_IRDA_MD1|
292                                            ASSABET_BCR_IRDA_MD0));
293                 ASSABET_BCR_set(state);
294         }
295         return 0;
296 }
297
298 static void assabet_irda_set_speed(struct device *dev, unsigned int speed)
299 {
300         if (speed < 4000000)
301                 ASSABET_BCR_clear(ASSABET_BCR_IRDA_FSEL);
302         else
303                 ASSABET_BCR_set(ASSABET_BCR_IRDA_FSEL);
304 }
305
306 static struct irda_platform_data assabet_irda_data = {
307         .set_power      = assabet_irda_set_power,
308         .set_speed      = assabet_irda_set_speed,
309 };
310
311 static struct ucb1x00_plat_data assabet_ucb1x00_data = {
312         .reset          = assabet_ucb1x00_reset,
313         .gpio_base      = -1,
314         .can_wakeup     = 1,
315 };
316
317 static struct mcp_plat_data assabet_mcp_data = {
318         .mccr0          = MCCR0_ADM,
319         .sclk_rate      = 11981000,
320         .codec_pdata    = &assabet_ucb1x00_data,
321 };
322
323 static void assabet_lcd_set_visual(u32 visual)
324 {
325         u_int is_true_color = visual == FB_VISUAL_TRUECOLOR;
326
327         if (machine_is_assabet()) {
328 #if 1           // phase 4 or newer Assabet's
329                 if (is_true_color)
330                         ASSABET_BCR_set(ASSABET_BCR_LCD_12RGB);
331                 else
332                         ASSABET_BCR_clear(ASSABET_BCR_LCD_12RGB);
333 #else
334                 // older Assabet's
335                 if (is_true_color)
336                         ASSABET_BCR_clear(ASSABET_BCR_LCD_12RGB);
337                 else
338                         ASSABET_BCR_set(ASSABET_BCR_LCD_12RGB);
339 #endif
340         }
341 }
342
343 #ifndef ASSABET_PAL_VIDEO
344 static void assabet_lcd_backlight_power(int on)
345 {
346         if (on)
347                 ASSABET_BCR_set(ASSABET_BCR_LIGHT_ON);
348         else
349                 ASSABET_BCR_clear(ASSABET_BCR_LIGHT_ON);
350 }
351
352 /*
353  * Turn on/off the backlight.  When turning the backlight on, we wait
354  * 500us after turning it on so we don't cause the supplies to droop
355  * when we enable the LCD controller (and cause a hard reset.)
356  */
357 static void assabet_lcd_power(int on)
358 {
359         if (on) {
360                 ASSABET_BCR_set(ASSABET_BCR_LCD_ON);
361                 udelay(500);
362         } else
363                 ASSABET_BCR_clear(ASSABET_BCR_LCD_ON);
364 }
365
366 /*
367  * The assabet uses a sharp LQ039Q2DS54 LCD module.  It is actually
368  * takes an RGB666 signal, but we provide it with an RGB565 signal
369  * instead (def_rgb_16).
370  */
371 static struct sa1100fb_mach_info lq039q2ds54_info = {
372         .pixclock       = 171521,       .bpp            = 16,
373         .xres           = 320,          .yres           = 240,
374
375         .hsync_len      = 5,            .vsync_len      = 1,
376         .left_margin    = 61,           .upper_margin   = 3,
377         .right_margin   = 9,            .lower_margin   = 0,
378
379         .sync           = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
380
381         .lccr0          = LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
382         .lccr3          = LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2),
383
384         .backlight_power = assabet_lcd_backlight_power,
385         .lcd_power = assabet_lcd_power,
386         .set_visual = assabet_lcd_set_visual,
387 };
388 #else
389 static void assabet_pal_backlight_power(int on)
390 {
391         ASSABET_BCR_clear(ASSABET_BCR_LIGHT_ON);
392 }
393
394 static void assabet_pal_power(int on)
395 {
396         ASSABET_BCR_clear(ASSABET_BCR_LCD_ON);
397 }
398
399 static struct sa1100fb_mach_info pal_info = {
400         .pixclock       = 67797,        .bpp            = 16,
401         .xres           = 640,          .yres           = 512,
402
403         .hsync_len      = 64,           .vsync_len      = 6,
404         .left_margin    = 125,          .upper_margin   = 70,
405         .right_margin   = 115,          .lower_margin   = 36,
406
407         .lccr0          = LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
408         .lccr3          = LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(512),
409
410         .backlight_power = assabet_pal_backlight_power,
411         .lcd_power = assabet_pal_power,
412         .set_visual = assabet_lcd_set_visual,
413 };
414 #endif
415
416 #ifdef CONFIG_ASSABET_NEPONSET
417 static struct resource neponset_resources[] = {
418         DEFINE_RES_MEM(0x10000000, 0x08000000),
419         DEFINE_RES_MEM(0x18000000, 0x04000000),
420         DEFINE_RES_MEM(0x40000000, SZ_8K),
421         DEFINE_RES_IRQ(IRQ_GPIO25),
422 };
423 #endif
424
425 static void __init assabet_init(void)
426 {
427         /*
428          * Ensure that the power supply is in "high power" mode.
429          */
430         GPSR = GPIO_GPIO16;
431         GPDR |= GPIO_GPIO16;
432
433         /*
434          * Ensure that these pins are set as outputs and are driving
435          * logic 0.  This ensures that we won't inadvertently toggle
436          * the WS latch in the CPLD, and we don't float causing
437          * excessive power drain.  --rmk
438          */
439         GPCR = GPIO_SSP_TXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM;
440         GPDR |= GPIO_SSP_TXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM;
441
442         /*
443          * Also set GPIO27 as an output; this is used to clock UART3
444          * via the FPGA and as otherwise has no pullups or pulldowns,
445          * so stop it floating.
446          */
447         GPCR = GPIO_GPIO27;
448         GPDR |= GPIO_GPIO27;
449
450         /*
451          * Set up registers for sleep mode.
452          */
453         PWER = PWER_GPIO0;
454         PGSR = 0;
455         PCFR = 0;
456         PSDR = 0;
457         PPDR |= PPC_TXD3 | PPC_TXD1;
458         PPSR |= PPC_TXD3 | PPC_TXD1;
459
460         sa11x0_ppc_configure_mcp();
461
462         if (machine_has_neponset()) {
463                 /*
464                  * Angel sets this, but other bootloaders may not.
465                  *
466                  * This must precede any driver calls to BCR_set()
467                  * or BCR_clear().
468                  */
469                 ASSABET_BCR = BCR_value = ASSABET_BCR_DB1111;
470
471 #ifndef CONFIG_ASSABET_NEPONSET
472                 printk( "Warning: Neponset detected but full support "
473                         "hasn't been configured in the kernel\n" );
474 #else
475                 platform_device_register_simple("neponset", 0,
476                         neponset_resources, ARRAY_SIZE(neponset_resources));
477 #endif
478         }
479
480 #ifndef ASSABET_PAL_VIDEO
481         sa11x0_register_lcd(&lq039q2ds54_info);
482 #else
483         sa11x0_register_lcd(&pal_video);
484 #endif
485         sa11x0_register_mtd(&assabet_flash_data, assabet_flash_resources,
486                             ARRAY_SIZE(assabet_flash_resources));
487         sa11x0_register_irda(&assabet_irda_data);
488         sa11x0_register_mcp(&assabet_mcp_data);
489 }
490
491 /*
492  * On Assabet, we must probe for the Neponset board _before_
493  * paging_init() has occurred to actually determine the amount
494  * of RAM available.  To do so, we map the appropriate IO section
495  * in the page table here in order to access GPIO registers.
496  */
497 static void __init map_sa1100_gpio_regs( void )
498 {
499         unsigned long phys = __PREG(GPLR) & PMD_MASK;
500         unsigned long virt = (unsigned long)io_p2v(phys);
501         int prot = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_DOMAIN(DOMAIN_IO);
502         pmd_t *pmd;
503
504         pmd = pmd_offset(pud_offset(pgd_offset_k(virt), virt), virt);
505         *pmd = __pmd(phys | prot);
506         flush_pmd_entry(pmd);
507 }
508
509 /*
510  * Read System Configuration "Register"
511  * (taken from "Intel StrongARM SA-1110 Microprocessor Development Board
512  * User's Guide", section 4.4.1)
513  *
514  * This same scan is performed in arch/arm/boot/compressed/head-sa1100.S
515  * to set up the serial port for decompression status messages. We
516  * repeat it here because the kernel may not be loaded as a zImage, and
517  * also because it's a hassle to communicate the SCR value to the kernel
518  * from the decompressor.
519  *
520  * Note that IRQs are guaranteed to be disabled.
521  */
522 static void __init get_assabet_scr(void)
523 {
524         unsigned long uninitialized_var(scr), i;
525
526         GPDR |= 0x3fc;                  /* Configure GPIO 9:2 as outputs */
527         GPSR = 0x3fc;                   /* Write 0xFF to GPIO 9:2 */
528         GPDR &= ~(0x3fc);               /* Configure GPIO 9:2 as inputs */
529         for(i = 100; i--; )             /* Read GPIO 9:2 */
530                 scr = GPLR;
531         GPDR |= 0x3fc;                  /*  restore correct pin direction */
532         scr &= 0x3fc;                   /* save as system configuration byte. */
533         SCR_value = scr;
534 }
535
536 static void __init
537 fixup_assabet(struct tag *tags, char **cmdline, struct meminfo *mi)
538 {
539         /* This must be done before any call to machine_has_neponset() */
540         map_sa1100_gpio_regs();
541         get_assabet_scr();
542
543         if (machine_has_neponset())
544                 printk("Neponset expansion board detected\n");
545 }
546
547
548 static void assabet_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
549 {
550         if (port->mapbase == _Ser1UTCR0) {
551                 if (state)
552                         ASSABET_BCR_clear(ASSABET_BCR_RS232EN |
553                                           ASSABET_BCR_COM_RTS |
554                                           ASSABET_BCR_COM_DTR);
555                 else
556                         ASSABET_BCR_set(ASSABET_BCR_RS232EN |
557                                         ASSABET_BCR_COM_RTS |
558                                         ASSABET_BCR_COM_DTR);
559         }
560 }
561
562 /*
563  * Assabet uses COM_RTS and COM_DTR for both UART1 (com port)
564  * and UART3 (radio module).  We only handle them for UART1 here.
565  */
566 static void assabet_set_mctrl(struct uart_port *port, u_int mctrl)
567 {
568         if (port->mapbase == _Ser1UTCR0) {
569                 u_int set = 0, clear = 0;
570
571                 if (mctrl & TIOCM_RTS)
572                         clear |= ASSABET_BCR_COM_RTS;
573                 else
574                         set |= ASSABET_BCR_COM_RTS;
575
576                 if (mctrl & TIOCM_DTR)
577                         clear |= ASSABET_BCR_COM_DTR;
578                 else
579                         set |= ASSABET_BCR_COM_DTR;
580
581                 ASSABET_BCR_clear(clear);
582                 ASSABET_BCR_set(set);
583         }
584 }
585
586 static u_int assabet_get_mctrl(struct uart_port *port)
587 {
588         u_int ret = 0;
589         u_int bsr = ASSABET_BSR;
590
591         /* need 2 reads to read current value */
592         bsr = ASSABET_BSR;
593
594         if (port->mapbase == _Ser1UTCR0) {
595                 if (bsr & ASSABET_BSR_COM_DCD)
596                         ret |= TIOCM_CD;
597                 if (bsr & ASSABET_BSR_COM_CTS)
598                         ret |= TIOCM_CTS;
599                 if (bsr & ASSABET_BSR_COM_DSR)
600                         ret |= TIOCM_DSR;
601         } else if (port->mapbase == _Ser3UTCR0) {
602                 if (bsr & ASSABET_BSR_RAD_DCD)
603                         ret |= TIOCM_CD;
604                 if (bsr & ASSABET_BSR_RAD_CTS)
605                         ret |= TIOCM_CTS;
606                 if (bsr & ASSABET_BSR_RAD_DSR)
607                         ret |= TIOCM_DSR;
608                 if (bsr & ASSABET_BSR_RAD_RI)
609                         ret |= TIOCM_RI;
610         } else {
611                 ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR;
612         }
613
614         return ret;
615 }
616
617 static struct sa1100_port_fns assabet_port_fns __initdata = {
618         .set_mctrl      = assabet_set_mctrl,
619         .get_mctrl      = assabet_get_mctrl,
620         .pm             = assabet_uart_pm,
621 };
622
623 static struct map_desc assabet_io_desc[] __initdata = {
624         {       /* Board Control Register */
625                 .virtual        =  0xf1000000,
626                 .pfn            = __phys_to_pfn(0x12000000),
627                 .length         = 0x00100000,
628                 .type           = MT_DEVICE
629         }, {    /* MQ200 */
630                 .virtual        =  0xf2800000,
631                 .pfn            = __phys_to_pfn(0x4b800000),
632                 .length         = 0x00800000,
633                 .type           = MT_DEVICE
634         }
635 };
636
637 static void __init assabet_map_io(void)
638 {
639         sa1100_map_io();
640         iotable_init(assabet_io_desc, ARRAY_SIZE(assabet_io_desc));
641
642         /*
643          * Set SUS bit in SDCR0 so serial port 1 functions.
644          * Its called GPCLKR0 in my SA1110 manual.
645          */
646         Ser1SDCR0 |= SDCR0_SUS;
647         MSC1 = (MSC1 & ~0xffff) |
648                 MSC_NonBrst | MSC_32BitStMem |
649                 MSC_RdAcc(2) | MSC_WrAcc(2) | MSC_Rec(0);
650
651         if (!machine_has_neponset())
652                 sa1100_register_uart_fns(&assabet_port_fns);
653
654         /*
655          * When Neponset is attached, the first UART should be
656          * UART3.  That's what Angel is doing and many documents
657          * are stating this.
658          *
659          * We do the Neponset mapping even if Neponset support
660          * isn't compiled in so the user will still get something on
661          * the expected physical serial port.
662          *
663          * We no longer do this; not all boot loaders support it,
664          * and UART3 appears to be somewhat unreliable with blob.
665          */
666         sa1100_register_uart(0, 1);
667         sa1100_register_uart(2, 3);
668 }
669
670 /* LEDs */
671 #if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
672 struct assabet_led {
673         struct led_classdev cdev;
674         u32 mask;
675 };
676
677 /*
678  * The triggers lines up below will only be used if the
679  * LED triggers are compiled in.
680  */
681 static const struct {
682         const char *name;
683         const char *trigger;
684 } assabet_leds[] = {
685         { "assabet:red", "cpu0",},
686         { "assabet:green", "heartbeat", },
687 };
688
689 /*
690  * The LED control in Assabet is reversed:
691  *  - setting bit means turn off LED
692  *  - clearing bit means turn on LED
693  */
694 static void assabet_led_set(struct led_classdev *cdev,
695                 enum led_brightness b)
696 {
697         struct assabet_led *led = container_of(cdev,
698                         struct assabet_led, cdev);
699
700         if (b != LED_OFF)
701                 ASSABET_BCR_clear(led->mask);
702         else
703                 ASSABET_BCR_set(led->mask);
704 }
705
706 static enum led_brightness assabet_led_get(struct led_classdev *cdev)
707 {
708         struct assabet_led *led = container_of(cdev,
709                         struct assabet_led, cdev);
710
711         return (ASSABET_BCR & led->mask) ? LED_OFF : LED_FULL;
712 }
713
714 static int __init assabet_leds_init(void)
715 {
716         int i;
717
718         if (!machine_is_assabet())
719                 return -ENODEV;
720
721         for (i = 0; i < ARRAY_SIZE(assabet_leds); i++) {
722                 struct assabet_led *led;
723
724                 led = kzalloc(sizeof(*led), GFP_KERNEL);
725                 if (!led)
726                         break;
727
728                 led->cdev.name = assabet_leds[i].name;
729                 led->cdev.brightness_set = assabet_led_set;
730                 led->cdev.brightness_get = assabet_led_get;
731                 led->cdev.default_trigger = assabet_leds[i].trigger;
732
733                 if (!i)
734                         led->mask = ASSABET_BCR_LED_RED;
735                 else
736                         led->mask = ASSABET_BCR_LED_GREEN;
737
738                 if (led_classdev_register(NULL, &led->cdev) < 0) {
739                         kfree(led);
740                         break;
741                 }
742         }
743
744         return 0;
745 }
746
747 /*
748  * Since we may have triggers on any subsystem, defer registration
749  * until after subsystem_init.
750  */
751 fs_initcall(assabet_leds_init);
752 #endif
753
754 MACHINE_START(ASSABET, "Intel-Assabet")
755         .atag_offset    = 0x100,
756         .fixup          = fixup_assabet,
757         .map_io         = assabet_map_io,
758         .nr_irqs        = SA1100_NR_IRQS,
759         .init_irq       = sa1100_init_irq,
760         .init_time      = sa1100_timer_init,
761         .init_machine   = assabet_init,
762         .init_late      = sa11x0_init_late,
763 #ifdef CONFIG_SA1111
764         .dma_zone_size  = SZ_1M,
765 #endif
766         .restart        = sa11x0_restart,
767 MACHINE_END