Merge branch 'linux-2.6' into merge
[linux-2.6] / arch / arm / mach-pxa / zylonite.c
1 /*
2  * linux/arch/arm/mach-pxa/zylonite.c
3  *
4  * Support for the PXA3xx Development Platform (aka Zylonite)
5  *
6  * Copyright (C) 2006 Marvell International Ltd.
7  *
8  * 2007-09-04: eric miao <eric.miao@marvell.com>
9  *             rewrite to align with latest kernel
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License version 2 as
13  * published by the Free Software Foundation.
14  */
15
16 #include <linux/module.h>
17 #include <linux/kernel.h>
18 #include <linux/interrupt.h>
19 #include <linux/init.h>
20 #include <linux/platform_device.h>
21
22 #include <asm/mach-types.h>
23 #include <asm/mach/arch.h>
24 #include <asm/hardware.h>
25 #include <asm/arch/gpio.h>
26 #include <asm/arch/pxafb.h>
27 #include <asm/arch/zylonite.h>
28
29 #include "generic.h"
30
31 int gpio_backlight;
32 int gpio_eth_irq;
33
34 int lcd_id;
35 int lcd_orientation;
36
37 static struct resource smc91x_resources[] = {
38         [0] = {
39                 .start  = ZYLONITE_ETH_PHYS + 0x300,
40                 .end    = ZYLONITE_ETH_PHYS + 0xfffff,
41                 .flags  = IORESOURCE_MEM,
42         },
43         [1] = {
44                 .start  = -1,   /* for run-time assignment */
45                 .end    = -1,
46                 .flags  = IORESOURCE_IRQ,
47         }
48 };
49
50 static struct platform_device smc91x_device = {
51         .name           = "smc91x",
52         .id             = 0,
53         .num_resources  = ARRAY_SIZE(smc91x_resources),
54         .resource       = smc91x_resources,
55 };
56
57 #if defined(CONFIG_FB_PXA) || (CONFIG_FB_PXA_MODULES)
58 static void zylonite_backlight_power(int on)
59 {
60         gpio_set_value(gpio_backlight, on);
61 }
62
63 static struct pxafb_mode_info toshiba_ltm035a776c_mode = {
64         .pixclock               = 110000,
65         .xres                   = 240,
66         .yres                   = 320,
67         .bpp                    = 16,
68         .hsync_len              = 4,
69         .left_margin            = 6,
70         .right_margin           = 4,
71         .vsync_len              = 2,
72         .upper_margin           = 2,
73         .lower_margin           = 3,
74         .sync                   = FB_SYNC_VERT_HIGH_ACT,
75 };
76
77 static struct pxafb_mode_info toshiba_ltm04c380k_mode = {
78         .pixclock               = 50000,
79         .xres                   = 640,
80         .yres                   = 480,
81         .bpp                    = 16,
82         .hsync_len              = 1,
83         .left_margin            = 0x9f,
84         .right_margin           = 1,
85         .vsync_len              = 44,
86         .upper_margin           = 0,
87         .lower_margin           = 0,
88         .sync                   = FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT,
89 };
90
91 static struct pxafb_mach_info zylonite_toshiba_lcd_info = {
92         .num_modes              = 1,
93         .lccr0                  = LCCR0_Act,
94         .lccr3                  = LCCR3_PCP,
95         .pxafb_backlight_power  = zylonite_backlight_power,
96 };
97
98 static struct pxafb_mode_info sharp_ls037_modes[] = {
99         [0] = {
100                 .pixclock       = 158000,
101                 .xres           = 240,
102                 .yres           = 320,
103                 .bpp            = 16,
104                 .hsync_len      = 4,
105                 .left_margin    = 39,
106                 .right_margin   = 39,
107                 .vsync_len      = 1,
108                 .upper_margin   = 2,
109                 .lower_margin   = 3,
110                 .sync           = 0,
111         },
112         [1] = {
113                 .pixclock       = 39700,
114                 .xres           = 480,
115                 .yres           = 640,
116                 .bpp            = 16,
117                 .hsync_len      = 8,
118                 .left_margin    = 81,
119                 .right_margin   = 81,
120                 .vsync_len      = 1,
121                 .upper_margin   = 2,
122                 .lower_margin   = 7,
123                 .sync           = 0,
124         },
125 };
126
127 static struct pxafb_mach_info zylonite_sharp_lcd_info = {
128         .modes                  = sharp_ls037_modes,
129         .num_modes              = 2,
130         .lccr0                  = LCCR0_Act,
131         .lccr3                  = LCCR3_PCP | LCCR3_HSP | LCCR3_VSP,
132         .pxafb_backlight_power  = zylonite_backlight_power,
133 };
134
135 static void __init zylonite_init_lcd(void)
136 {
137         /* backlight GPIO: output, default on */
138         gpio_direction_output(gpio_backlight, 1);
139
140         if (lcd_id & 0x20) {
141                 set_pxa_fb_info(&zylonite_sharp_lcd_info);
142                 return;
143         }
144
145         /* legacy LCD panels, it would be handy here if LCD panel type can
146          * be decided at run-time
147          */
148         if (1)
149                 zylonite_toshiba_lcd_info.modes = &toshiba_ltm035a776c_mode;
150         else
151                 zylonite_toshiba_lcd_info.modes = &toshiba_ltm04c380k_mode;
152
153         set_pxa_fb_info(&zylonite_toshiba_lcd_info);
154 }
155 #else
156 static inline void zylonite_init_lcd(void) {}
157 #endif
158
159 static void __init zylonite_init(void)
160 {
161         /* board-processor specific initialization */
162         zylonite_pxa300_init();
163         zylonite_pxa320_init();
164
165         /*
166          * Note: We depend that the bootloader set
167          * the correct value to MSC register for SMC91x.
168          */
169         smc91x_resources[1].start = gpio_to_irq(gpio_eth_irq);
170         smc91x_resources[1].end   = gpio_to_irq(gpio_eth_irq);
171         platform_device_register(&smc91x_device);
172
173         zylonite_init_lcd();
174 }
175
176 MACHINE_START(ZYLONITE, "PXA3xx Platform Development Kit (aka Zylonite)")
177         .phys_io        = 0x40000000,
178         .boot_params    = 0xa0000100,
179         .io_pg_offst    = (io_p2v(0x40000000) >> 18) & 0xfffc,
180         .map_io         = pxa_map_io,
181         .init_irq       = pxa3xx_init_irq,
182         .timer          = &pxa_timer,
183         .init_machine   = zylonite_init,
184 MACHINE_END