sync hh.org
[hh.org.git] / arch / arm / mach-pxa / eseries / e800_lcd.c
blob41332b4c7dfd1c47698b6463d9ccf8b4f66f8c82
1 /* e800_lcd.c
3 * (c) Ian Molton 2005
5 * This file contains the definitions for the LCD timings and functions
6 * to control the LCD power / frontlighting via the w100fb driver.
8 */
10 #include <linux/module.h>
11 #include <linux/init.h>
12 #include <linux/kernel.h>
13 #include <linux/tty.h>
14 #include <linux/sched.h>
15 #include <linux/delay.h>
16 #include <linux/pm.h>
17 #include <linux/lcd.h>
18 #include <linux/backlight.h>
19 #include <linux/fb.h>
20 #include <linux/err.h>
21 #include <linux/platform_device.h>
24 #include <asm/mach-types.h>
25 #include <asm/hardware.h>
26 #include <asm/setup.h>
28 #include <asm/mach/arch.h>
29 #include <asm/arch/pxa-regs.h>
30 #include <asm/arch/eseries-gpio.h>
32 #include <video/w100fb.h>
34 static struct w100_gen_regs e800_lcd_regs = {
35 .lcd_format = 0x00008003,
36 .lcdd_cntl1 = 0x02a00000,
37 .lcdd_cntl2 = 0x0003ffff,
38 .genlcd_cntl1 = 0x000ff2a3,
39 .genlcd_cntl2 = 0x000002a3,
40 .genlcd_cntl3 = 0x000102aa,
43 static struct w100_mode e800_lcd_mode[2] = {
44 [0] = {
45 .xres = 480,
46 .yres = 640,
47 .left_margin = 52,
48 .right_margin = 148,
49 .upper_margin = 2,
50 .lower_margin = 6,
51 .crtc_ss = 0x80350034,
52 .crtc_ls = 0x802b0026,
53 .crtc_gs = 0x80160016,
54 .crtc_vpos_gs = 0x00020003,
55 .crtc_rev = 0x0040001d,
56 .crtc_dclk = 0xe0000000,
57 .crtc_gclk = 0x82a50049,
58 .crtc_goe = 0x80ee001c,
59 .crtc_ps1_active = 0x00000000,
60 .pll_freq = 128,
61 .pixclk_divider = 4,
62 .pixclk_divider_rotated = 6,
63 .pixclk_src = CLK_SRC_PLL,
64 .sysclk_divider = 0,
65 .sysclk_src = CLK_SRC_PLL,
67 [1] = {
68 .xres = 240,
69 .yres = 320,
70 // .bpp = 16,
71 .left_margin = 15,
72 .right_margin = 88,
73 .upper_margin = 0,
74 .lower_margin = 7,
75 .crtc_ss = 0xd010000f,
76 .crtc_ls = 0x80070003,
77 .crtc_gs = 0x80000000,
78 .crtc_vpos_gs = 0x01460147,
79 .crtc_rev = 0x00400003,
80 .crtc_dclk = 0xa1700030,
81 .crtc_gclk = 0x814b0008,
82 .crtc_goe = 0x80cc0015,
83 .crtc_ps1_active = 0x00000000,
84 .pll_freq = 100,
85 .pixclk_divider = 6, // Wince uses 14 which gives a 7MHz pclk.
86 .pixclk_divider_rotated = 6, // we want a 14MHz one (much nicer to look at)
87 .pixclk_src = CLK_SRC_PLL,
88 .sysclk_divider = 0,
89 .sysclk_src = CLK_SRC_PLL,
94 static struct w100_gpio_regs e800_w100_gpio_info = {
95 .init_data1 = 0xc13fc019,
96 .gpio_dir1 = 0x3e40df7f,
97 .gpio_oe1 = 0x003c3000,
98 .init_data2 = 0x00000000,
99 .gpio_dir2 = 0x00000000,
100 .gpio_oe2 = 0x00000000,
103 static struct w100_mem_info e800_w100_mem_info = {
104 .ext_cntl = 0x09640011,
105 .sdram_mode_reg = 0x00600021,
106 .ext_timing_cntl = 0x10001545,
107 .io_cntl = 0x7ddd7333,
108 .size = 0x1fffff,
111 static void e800_tg_change(struct w100fb_par *par) {
112 unsigned long tmp;
114 tmp = w100fb_gpio_read(W100_GPIO_PORT_A);
115 if(par->mode->xres == 480)
116 tmp |= 0x100;
117 else
118 tmp &= ~0x100;
119 w100fb_gpio_write(W100_GPIO_PORT_A, tmp);
122 static struct w100_tg_info e800_tg_info = {
123 .change = e800_tg_change,
126 static struct w100fb_mach_info e800_fb_info = {
127 .modelist = e800_lcd_mode,
128 .num_modes = 2,
129 .regs = &e800_lcd_regs,
130 .gpio = &e800_w100_gpio_info,
131 .mem = &e800_w100_mem_info,
132 .tg = &e800_tg_info,
133 .xtal_freq = 16000000,
136 static struct resource e800_fb_resources[] = {
137 [0] = {
138 .start = 0x0c000000,
139 .end = 0x0cffffff,
140 .flags = IORESOURCE_MEM,
144 /* ----------------------- device declarations -------------------------- */
147 static struct platform_device e800_fb_device = {
148 .name = "w100fb",
149 .id = -1,
150 .dev = {
151 .platform_data = &e800_fb_info,
153 .num_resources = ARRAY_SIZE(e800_fb_resources),
154 .resource = e800_fb_resources,
157 #if 0
158 static struct platform_device e800_lcd_hook_device = {
159 .name = "e800-lcd-hook",
160 .dev = {
161 .parent = &e800_fb_device.dev,
163 .id = -1,
165 #endif
167 static int e800_lcd_init (void) {
168 int ret;
170 if (!machine_is_e800 ())
171 return -ENODEV;
173 if((ret = platform_device_register(&e800_fb_device)))
174 return ret;
176 // platform_device_register(&e800_lcd_hook_device);
178 return 0;
181 static void e800_lcd_exit (void)
183 //FIXME - free the platform dev for the w100 (imageon)
186 module_init (e800_lcd_init);
187 module_exit (e800_lcd_exit);
189 MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
190 MODULE_DESCRIPTION("e800 lcd driver");
191 MODULE_LICENSE("GPLv2");