aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-sa1100/assabet.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-sa1100/assabet.c')
-rw-r--r--arch/arm/mach-sa1100/assabet.c296
1 files changed, 62 insertions, 234 deletions
diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c
index 9a23739f702..26257df19b6 100644
--- a/arch/arm/mach-sa1100/assabet.c
+++ b/arch/arm/mach-sa1100/assabet.c
@@ -14,20 +14,15 @@
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/ioport.h> 16#include <linux/ioport.h>
17#include <linux/platform_data/sa11x0-serial.h>
18#include <linux/serial_core.h> 17#include <linux/serial_core.h>
19#include <linux/mfd/ucb1x00.h>
20#include <linux/mtd/mtd.h> 18#include <linux/mtd/mtd.h>
21#include <linux/mtd/partitions.h> 19#include <linux/mtd/partitions.h>
22#include <linux/delay.h> 20#include <linux/delay.h>
23#include <linux/mm.h> 21#include <linux/mm.h>
24#include <linux/leds.h>
25#include <linux/slab.h>
26
27#include <video/sa1100fb.h>
28 22
29#include <mach/hardware.h> 23#include <mach/hardware.h>
30#include <asm/mach-types.h> 24#include <asm/mach-types.h>
25#include <asm/irq.h>
31#include <asm/setup.h> 26#include <asm/setup.h>
32#include <asm/page.h> 27#include <asm/page.h>
33#include <asm/pgtable-hwdef.h> 28#include <asm/pgtable-hwdef.h>
@@ -38,20 +33,20 @@
38#include <asm/mach/flash.h> 33#include <asm/mach/flash.h>
39#include <asm/mach/irda.h> 34#include <asm/mach/irda.h>
40#include <asm/mach/map.h> 35#include <asm/mach/map.h>
36#include <asm/mach/serial_sa1100.h>
41#include <mach/assabet.h> 37#include <mach/assabet.h>
42#include <linux/platform_data/mfd-mcp-sa11x0.h> 38#include <mach/mcp.h>
43#include <mach/irqs.h>
44 39
45#include "generic.h" 40#include "generic.h"
46 41
47#define ASSABET_BCR_DB1110 \ 42#define ASSABET_BCR_DB1110 \
48 (ASSABET_BCR_SPK_OFF | \ 43 (ASSABET_BCR_SPK_OFF | ASSABET_BCR_QMUTE | \
49 ASSABET_BCR_LED_GREEN | ASSABET_BCR_LED_RED | \ 44 ASSABET_BCR_LED_GREEN | ASSABET_BCR_LED_RED | \
50 ASSABET_BCR_RS232EN | ASSABET_BCR_LCD_12RGB | \ 45 ASSABET_BCR_RS232EN | ASSABET_BCR_LCD_12RGB | \
51 ASSABET_BCR_IRDA_MD0) 46 ASSABET_BCR_IRDA_MD0)
52 47
53#define ASSABET_BCR_DB1111 \ 48#define ASSABET_BCR_DB1111 \
54 (ASSABET_BCR_SPK_OFF | \ 49 (ASSABET_BCR_SPK_OFF | ASSABET_BCR_QMUTE | \
55 ASSABET_BCR_LED_GREEN | ASSABET_BCR_LED_RED | \ 50 ASSABET_BCR_LED_GREEN | ASSABET_BCR_LED_RED | \
56 ASSABET_BCR_RS232EN | ASSABET_BCR_LCD_12RGB | \ 51 ASSABET_BCR_RS232EN | ASSABET_BCR_LCD_12RGB | \
57 ASSABET_BCR_CF_BUS_OFF | ASSABET_BCR_STEREO_LB | \ 52 ASSABET_BCR_CF_BUS_OFF | ASSABET_BCR_STEREO_LB | \
@@ -74,10 +69,31 @@ void ASSABET_BCR_frob(unsigned int mask, unsigned int val)
74 69
75EXPORT_SYMBOL(ASSABET_BCR_frob); 70EXPORT_SYMBOL(ASSABET_BCR_frob);
76 71
77static void assabet_ucb1x00_reset(enum ucb1x00_reset state) 72static void assabet_backlight_power(int on)
78{ 73{
79 if (state == UCB_RST_PROBE) 74#ifndef ASSABET_PAL_VIDEO
80 ASSABET_BCR_set(ASSABET_BCR_CODEC_RST); 75 if (on)
76 ASSABET_BCR_set(ASSABET_BCR_LIGHT_ON);
77 else
78#endif
79 ASSABET_BCR_clear(ASSABET_BCR_LIGHT_ON);
80}
81
82/*
83 * Turn on/off the backlight. When turning the backlight on,
84 * we wait 500us after turning it on so we don't cause the
85 * supplies to droop when we enable the LCD controller (and
86 * cause a hard reset.)
87 */
88static void assabet_lcd_power(int on)
89{
90#ifndef ASSABET_PAL_VIDEO
91 if (on) {
92 ASSABET_BCR_set(ASSABET_BCR_LCD_ON);
93 udelay(500);
94 } else
95#endif
96 ASSABET_BCR_clear(ASSABET_BCR_LCD_ON);
81} 97}
82 98
83 99
@@ -136,8 +152,15 @@ static struct flash_platform_data assabet_flash_data = {
136}; 152};
137 153
138static struct resource assabet_flash_resources[] = { 154static struct resource assabet_flash_resources[] = {
139 DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M), 155 {
140 DEFINE_RES_MEM(SA1100_CS1_PHYS, SZ_32M), 156 .start = SA1100_CS0_PHYS,
157 .end = SA1100_CS0_PHYS + SZ_32M - 1,
158 .flags = IORESOURCE_MEM,
159 }, {
160 .start = SA1100_CS1_PHYS,
161 .end = SA1100_CS1_PHYS + SZ_32M - 1,
162 .flags = IORESOURCE_MEM,
163 }
141}; 164};
142 165
143 166
@@ -176,126 +199,18 @@ static struct irda_platform_data assabet_irda_data = {
176 .set_speed = assabet_irda_set_speed, 199 .set_speed = assabet_irda_set_speed,
177}; 200};
178 201
179static struct ucb1x00_plat_data assabet_ucb1x00_data = {
180 .reset = assabet_ucb1x00_reset,
181 .gpio_base = -1,
182};
183
184static struct mcp_plat_data assabet_mcp_data = { 202static struct mcp_plat_data assabet_mcp_data = {
185 .mccr0 = MCCR0_ADM, 203 .mccr0 = MCCR0_ADM,
186 .sclk_rate = 11981000, 204 .sclk_rate = 11981000,
187 .codec_pdata = &assabet_ucb1x00_data,
188}; 205};
189 206
190static void assabet_lcd_set_visual(u32 visual)
191{
192 u_int is_true_color = visual == FB_VISUAL_TRUECOLOR;
193
194 if (machine_is_assabet()) {
195#if 1 // phase 4 or newer Assabet's
196 if (is_true_color)
197 ASSABET_BCR_set(ASSABET_BCR_LCD_12RGB);
198 else
199 ASSABET_BCR_clear(ASSABET_BCR_LCD_12RGB);
200#else
201 // older Assabet's
202 if (is_true_color)
203 ASSABET_BCR_clear(ASSABET_BCR_LCD_12RGB);
204 else
205 ASSABET_BCR_set(ASSABET_BCR_LCD_12RGB);
206#endif
207 }
208}
209
210#ifndef ASSABET_PAL_VIDEO
211static void assabet_lcd_backlight_power(int on)
212{
213 if (on)
214 ASSABET_BCR_set(ASSABET_BCR_LIGHT_ON);
215 else
216 ASSABET_BCR_clear(ASSABET_BCR_LIGHT_ON);
217}
218
219/*
220 * Turn on/off the backlight. When turning the backlight on, we wait
221 * 500us after turning it on so we don't cause the supplies to droop
222 * when we enable the LCD controller (and cause a hard reset.)
223 */
224static void assabet_lcd_power(int on)
225{
226 if (on) {
227 ASSABET_BCR_set(ASSABET_BCR_LCD_ON);
228 udelay(500);
229 } else
230 ASSABET_BCR_clear(ASSABET_BCR_LCD_ON);
231}
232
233/*
234 * The assabet uses a sharp LQ039Q2DS54 LCD module. It is actually
235 * takes an RGB666 signal, but we provide it with an RGB565 signal
236 * instead (def_rgb_16).
237 */
238static struct sa1100fb_mach_info lq039q2ds54_info = {
239 .pixclock = 171521, .bpp = 16,
240 .xres = 320, .yres = 240,
241
242 .hsync_len = 5, .vsync_len = 1,
243 .left_margin = 61, .upper_margin = 3,
244 .right_margin = 9, .lower_margin = 0,
245
246 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
247
248 .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
249 .lccr3 = LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2),
250
251 .backlight_power = assabet_lcd_backlight_power,
252 .lcd_power = assabet_lcd_power,
253 .set_visual = assabet_lcd_set_visual,
254};
255#else
256static void assabet_pal_backlight_power(int on)
257{
258 ASSABET_BCR_clear(ASSABET_BCR_LIGHT_ON);
259}
260
261static void assabet_pal_power(int on)
262{
263 ASSABET_BCR_clear(ASSABET_BCR_LCD_ON);
264}
265
266static struct sa1100fb_mach_info pal_info = {
267 .pixclock = 67797, .bpp = 16,
268 .xres = 640, .yres = 512,
269
270 .hsync_len = 64, .vsync_len = 6,
271 .left_margin = 125, .upper_margin = 70,
272 .right_margin = 115, .lower_margin = 36,
273
274 .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
275 .lccr3 = LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(512),
276
277 .backlight_power = assabet_pal_backlight_power,
278 .lcd_power = assabet_pal_power,
279 .set_visual = assabet_lcd_set_visual,
280};
281#endif
282
283#ifdef CONFIG_ASSABET_NEPONSET
284static struct resource neponset_resources[] = {
285 DEFINE_RES_MEM(0x10000000, 0x08000000),
286 DEFINE_RES_MEM(0x18000000, 0x04000000),
287 DEFINE_RES_MEM(0x40000000, SZ_8K),
288 DEFINE_RES_IRQ(IRQ_GPIO25),
289};
290#endif
291
292static void __init assabet_init(void) 207static void __init assabet_init(void)
293{ 208{
294 /* 209 /*
295 * Ensure that the power supply is in "high power" mode. 210 * Ensure that the power supply is in "high power" mode.
296 */ 211 */
297 GPSR = GPIO_GPIO16;
298 GPDR |= GPIO_GPIO16; 212 GPDR |= GPIO_GPIO16;
213 GPSR = GPIO_GPIO16;
299 214
300 /* 215 /*
301 * Ensure that these pins are set as outputs and are driving 216 * Ensure that these pins are set as outputs and are driving
@@ -303,16 +218,8 @@ static void __init assabet_init(void)
303 * the WS latch in the CPLD, and we don't float causing 218 * the WS latch in the CPLD, and we don't float causing
304 * excessive power drain. --rmk 219 * excessive power drain. --rmk
305 */ 220 */
306 GPCR = GPIO_SSP_TXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM;
307 GPDR |= GPIO_SSP_TXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM; 221 GPDR |= GPIO_SSP_TXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM;
308 222 GPCR = GPIO_SSP_TXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM;
309 /*
310 * Also set GPIO27 as an output; this is used to clock UART3
311 * via the FPGA and as otherwise has no pullups or pulldowns,
312 * so stop it floating.
313 */
314 GPCR = GPIO_GPIO27;
315 GPDR |= GPIO_GPIO27;
316 223
317 /* 224 /*
318 * Set up registers for sleep mode. 225 * Set up registers for sleep mode.
@@ -324,7 +231,8 @@ static void __init assabet_init(void)
324 PPDR |= PPC_TXD3 | PPC_TXD1; 231 PPDR |= PPC_TXD3 | PPC_TXD1;
325 PPSR |= PPC_TXD3 | PPC_TXD1; 232 PPSR |= PPC_TXD3 | PPC_TXD1;
326 233
327 sa11x0_ppc_configure_mcp(); 234 sa1100fb_lcd_power = assabet_lcd_power;
235 sa1100fb_backlight_power = assabet_backlight_power;
328 236
329 if (machine_has_neponset()) { 237 if (machine_has_neponset()) {
330 /* 238 /*
@@ -338,17 +246,9 @@ static void __init assabet_init(void)
338#ifndef CONFIG_ASSABET_NEPONSET 246#ifndef CONFIG_ASSABET_NEPONSET
339 printk( "Warning: Neponset detected but full support " 247 printk( "Warning: Neponset detected but full support "
340 "hasn't been configured in the kernel\n" ); 248 "hasn't been configured in the kernel\n" );
341#else
342 platform_device_register_simple("neponset", 0,
343 neponset_resources, ARRAY_SIZE(neponset_resources));
344#endif 249#endif
345 } 250 }
346 251
347#ifndef ASSABET_PAL_VIDEO
348 sa11x0_register_lcd(&lq039q2ds54_info);
349#else
350 sa11x0_register_lcd(&pal_video);
351#endif
352 sa11x0_register_mtd(&assabet_flash_data, assabet_flash_resources, 252 sa11x0_register_mtd(&assabet_flash_data, assabet_flash_resources,
353 ARRAY_SIZE(assabet_flash_resources)); 253 ARRAY_SIZE(assabet_flash_resources));
354 sa11x0_register_irda(&assabet_irda_data); 254 sa11x0_register_irda(&assabet_irda_data);
@@ -364,11 +264,11 @@ static void __init assabet_init(void)
364static void __init map_sa1100_gpio_regs( void ) 264static void __init map_sa1100_gpio_regs( void )
365{ 265{
366 unsigned long phys = __PREG(GPLR) & PMD_MASK; 266 unsigned long phys = __PREG(GPLR) & PMD_MASK;
367 unsigned long virt = (unsigned long)io_p2v(phys); 267 unsigned long virt = io_p2v(phys);
368 int prot = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_DOMAIN(DOMAIN_IO); 268 int prot = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_DOMAIN(DOMAIN_IO);
369 pmd_t *pmd; 269 pmd_t *pmd;
370 270
371 pmd = pmd_offset(pud_offset(pgd_offset_k(virt), virt), virt); 271 pmd = pmd_offset(pgd_offset_k(virt), virt);
372 *pmd = __pmd(phys | prot); 272 *pmd = __pmd(phys | prot);
373 flush_pmd_entry(pmd); 273 flush_pmd_entry(pmd);
374} 274}
@@ -388,7 +288,7 @@ static void __init map_sa1100_gpio_regs( void )
388 */ 288 */
389static void __init get_assabet_scr(void) 289static void __init get_assabet_scr(void)
390{ 290{
391 unsigned long uninitialized_var(scr), i; 291 unsigned long scr, i;
392 292
393 GPDR |= 0x3fc; /* Configure GPIO 9:2 as outputs */ 293 GPDR |= 0x3fc; /* Configure GPIO 9:2 as outputs */
394 GPSR = 0x3fc; /* Write 0xFF to GPIO 9:2 */ 294 GPSR = 0x3fc; /* Write 0xFF to GPIO 9:2 */
@@ -401,7 +301,8 @@ static void __init get_assabet_scr(void)
401} 301}
402 302
403static void __init 303static void __init
404fixup_assabet(struct tag *tags, char **cmdline, struct meminfo *mi) 304fixup_assabet(struct machine_desc *desc, struct tag *tags,
305 char **cmdline, struct meminfo *mi)
405{ 306{
406 /* This must be done before any call to machine_has_neponset() */ 307 /* This must be done before any call to machine_has_neponset() */
407 map_sa1100_gpio_regs(); 308 map_sa1100_gpio_regs();
@@ -512,8 +413,21 @@ static void __init assabet_map_io(void)
512 */ 413 */
513 Ser1SDCR0 |= SDCR0_SUS; 414 Ser1SDCR0 |= SDCR0_SUS;
514 415
515 if (!machine_has_neponset()) 416 if (machine_has_neponset()) {
417#ifdef CONFIG_ASSABET_NEPONSET
418 extern void neponset_map_io(void);
419
420 /*
421 * We map Neponset registers even if it isn't present since
422 * many drivers will try to probe their stuff (and fail).
423 * This is still more friendly than a kernel paging request
424 * crash.
425 */
426 neponset_map_io();
427#endif
428 } else {
516 sa1100_register_uart_fns(&assabet_port_fns); 429 sa1100_register_uart_fns(&assabet_port_fns);
430 }
517 431
518 /* 432 /*
519 * When Neponset is attached, the first UART should be 433 * When Neponset is attached, the first UART should be
@@ -531,101 +445,15 @@ static void __init assabet_map_io(void)
531 sa1100_register_uart(2, 3); 445 sa1100_register_uart(2, 3);
532} 446}
533 447
534/* LEDs */
535#if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
536struct assabet_led {
537 struct led_classdev cdev;
538 u32 mask;
539};
540
541/*
542 * The triggers lines up below will only be used if the
543 * LED triggers are compiled in.
544 */
545static const struct {
546 const char *name;
547 const char *trigger;
548} assabet_leds[] = {
549 { "assabet:red", "cpu0",},
550 { "assabet:green", "heartbeat", },
551};
552
553/*
554 * The LED control in Assabet is reversed:
555 * - setting bit means turn off LED
556 * - clearing bit means turn on LED
557 */
558static void assabet_led_set(struct led_classdev *cdev,
559 enum led_brightness b)
560{
561 struct assabet_led *led = container_of(cdev,
562 struct assabet_led, cdev);
563
564 if (b != LED_OFF)
565 ASSABET_BCR_clear(led->mask);
566 else
567 ASSABET_BCR_set(led->mask);
568}
569
570static enum led_brightness assabet_led_get(struct led_classdev *cdev)
571{
572 struct assabet_led *led = container_of(cdev,
573 struct assabet_led, cdev);
574
575 return (ASSABET_BCR & led->mask) ? LED_OFF : LED_FULL;
576}
577
578static int __init assabet_leds_init(void)
579{
580 int i;
581
582 if (!machine_is_assabet())
583 return -ENODEV;
584
585 for (i = 0; i < ARRAY_SIZE(assabet_leds); i++) {
586 struct assabet_led *led;
587
588 led = kzalloc(sizeof(*led), GFP_KERNEL);
589 if (!led)
590 break;
591
592 led->cdev.name = assabet_leds[i].name;
593 led->cdev.brightness_set = assabet_led_set;
594 led->cdev.brightness_get = assabet_led_get;
595 led->cdev.default_trigger = assabet_leds[i].trigger;
596
597 if (!i)
598 led->mask = ASSABET_BCR_LED_RED;
599 else
600 led->mask = ASSABET_BCR_LED_GREEN;
601
602 if (led_classdev_register(NULL, &led->cdev) < 0) {
603 kfree(led);
604 break;
605 }
606 }
607
608 return 0;
609}
610
611/*
612 * Since we may have triggers on any subsystem, defer registration
613 * until after subsystem_init.
614 */
615fs_initcall(assabet_leds_init);
616#endif
617 448
618MACHINE_START(ASSABET, "Intel-Assabet") 449MACHINE_START(ASSABET, "Intel-Assabet")
619 .atag_offset = 0x100, 450 .boot_params = 0xc0000100,
620 .fixup = fixup_assabet, 451 .fixup = fixup_assabet,
621 .map_io = assabet_map_io, 452 .map_io = assabet_map_io,
622 .nr_irqs = SA1100_NR_IRQS,
623 .init_irq = sa1100_init_irq, 453 .init_irq = sa1100_init_irq,
624 .timer = &sa1100_timer, 454 .timer = &sa1100_timer,
625 .init_machine = assabet_init, 455 .init_machine = assabet_init,
626 .init_late = sa11x0_init_late,
627#ifdef CONFIG_SA1111 456#ifdef CONFIG_SA1111
628 .dma_zone_size = SZ_1M, 457 .dma_zone_size = SZ_1M,
629#endif 458#endif
630 .restart = sa11x0_restart,
631MACHINE_END 459MACHINE_END