Merge branch 'pxa' into devel
[linux-2.6] / arch / arm / mach-pxa / e740_lcd.c
1 /* e740_lcd.c
2  *
3  * This file contains the definitions for the LCD timings and functions
4  * to control the LCD power / frontlighting via the w100fb driver.
5  *
6  * (c) 2005 Ian Molton <spyro@f2s.com>
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  */
13
14 #include <linux/module.h>
15 #include <linux/device.h>
16 #include <linux/fb.h>
17 #include <linux/err.h>
18 #include <linux/platform_device.h>
19
20 #include <asm/mach-types.h>
21
22 #include <video/w100fb.h>
23
24 /*
25 **potential** shutdown routine - to be investigated
26 devmem2 0x0c010528 w 0xff3fff00
27 devmem2 0x0c010190 w 0x7FFF8000
28 devmem2 0x0c0101b0 w 0x00FF0000
29 devmem2 0x0c01008c w 0x00000000
30 devmem2 0x0c010080 w 0x000000bf
31 devmem2 0x0c010098 w 0x00000015
32 devmem2 0x0c010088 w 0x4b000204
33 devmem2 0x0c010098 w 0x0000001d
34 */
35
36 static struct w100_gen_regs e740_lcd_regs = {
37         .lcd_format =            0x00008023,
38         .lcdd_cntl1 =            0x0f000000,
39         .lcdd_cntl2 =            0x0003ffff,
40         .genlcd_cntl1 =          0x00ffff03,
41         .genlcd_cntl2 =          0x003c0f03,
42         .genlcd_cntl3 =          0x000143aa,
43 };
44
45 static struct w100_mode e740_lcd_mode = {
46         .xres            = 240,
47         .yres            = 320,
48         .left_margin     = 20,
49         .right_margin    = 28,
50         .upper_margin    = 9,
51         .lower_margin    = 8,
52         .crtc_ss         = 0x80140013,
53         .crtc_ls         = 0x81150110,
54         .crtc_gs         = 0x80050005,
55         .crtc_vpos_gs    = 0x000a0009,
56         .crtc_rev        = 0x0040010a,
57         .crtc_dclk       = 0xa906000a,
58         .crtc_gclk       = 0x80050108,
59         .crtc_goe        = 0x80050108,
60         .pll_freq        = 57,
61         .pixclk_divider         = 4,
62         .pixclk_divider_rotated = 4,
63         .pixclk_src     = CLK_SRC_XTAL,
64         .sysclk_divider  = 1,
65         .sysclk_src     = CLK_SRC_PLL,
66         .crtc_ps1_active =       0x41060010,
67 };
68
69
70 static struct w100_gpio_regs e740_w100_gpio_info = {
71         .init_data1 = 0x21002103,
72         .gpio_dir1  = 0xffffdeff,
73         .gpio_oe1   = 0x03c00643,
74         .init_data2 = 0x003f003f,
75         .gpio_dir2  = 0xffffffff,
76         .gpio_oe2   = 0x000000ff,
77 };
78
79 static struct w100fb_mach_info e740_fb_info = {
80         .modelist   = &e740_lcd_mode,
81         .num_modes  = 1,
82         .regs       = &e740_lcd_regs,
83         .gpio       = &e740_w100_gpio_info,
84         .xtal_freq = 14318000,
85         .xtal_dbl   = 1,
86 };
87
88 static struct resource e740_fb_resources[] = {
89         [0] = {
90                 .start          = 0x0c000000,
91                 .end            = 0x0cffffff,
92                 .flags          = IORESOURCE_MEM,
93         },
94 };
95
96 /* ----------------------- device declarations -------------------------- */
97
98
99 static struct platform_device e740_fb_device = {
100         .name           = "w100fb",
101         .id             = -1,
102         .dev            = {
103                 .platform_data  = &e740_fb_info,
104         },
105         .num_resources  = ARRAY_SIZE(e740_fb_resources),
106         .resource       = e740_fb_resources,
107 };
108
109 static int e740_lcd_init(void)
110 {
111         int ret;
112
113         if (!machine_is_e740())
114                 return -ENODEV;
115
116         return platform_device_register(&e740_fb_device);
117 }
118
119 module_init(e740_lcd_init);
120
121 MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
122 MODULE_DESCRIPTION("e740 lcd driver");
123 MODULE_LICENSE("GPLv2");