e800_lcd.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /* e800_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. #include <linux/module.h>
  14. #include <linux/device.h>
  15. #include <linux/fb.h>
  16. #include <linux/err.h>
  17. #include <linux/platform_device.h>
  18. #include <asm/mach-types.h>
  19. #include <video/w100fb.h>
  20. static struct w100_gen_regs e800_lcd_regs = {
  21. .lcd_format = 0x00008003,
  22. .lcdd_cntl1 = 0x02a00000,
  23. .lcdd_cntl2 = 0x0003ffff,
  24. .genlcd_cntl1 = 0x000ff2a3,
  25. .genlcd_cntl2 = 0x000002a3,
  26. .genlcd_cntl3 = 0x000102aa,
  27. };
  28. static struct w100_mode e800_lcd_mode[2] = {
  29. [0] = {
  30. .xres = 480,
  31. .yres = 640,
  32. .left_margin = 52,
  33. .right_margin = 148,
  34. .upper_margin = 2,
  35. .lower_margin = 6,
  36. .crtc_ss = 0x80350034,
  37. .crtc_ls = 0x802b0026,
  38. .crtc_gs = 0x80160016,
  39. .crtc_vpos_gs = 0x00020003,
  40. .crtc_rev = 0x0040001d,
  41. .crtc_dclk = 0xe0000000,
  42. .crtc_gclk = 0x82a50049,
  43. .crtc_goe = 0x80ee001c,
  44. .crtc_ps1_active = 0x00000000,
  45. .pll_freq = 128,
  46. .pixclk_divider = 4,
  47. .pixclk_divider_rotated = 6,
  48. .pixclk_src = CLK_SRC_PLL,
  49. .sysclk_divider = 0,
  50. .sysclk_src = CLK_SRC_PLL,
  51. },
  52. [1] = {
  53. .xres = 240,
  54. .yres = 320,
  55. .left_margin = 15,
  56. .right_margin = 88,
  57. .upper_margin = 0,
  58. .lower_margin = 7,
  59. .crtc_ss = 0xd010000f,
  60. .crtc_ls = 0x80070003,
  61. .crtc_gs = 0x80000000,
  62. .crtc_vpos_gs = 0x01460147,
  63. .crtc_rev = 0x00400003,
  64. .crtc_dclk = 0xa1700030,
  65. .crtc_gclk = 0x814b0008,
  66. .crtc_goe = 0x80cc0015,
  67. .crtc_ps1_active = 0x00000000,
  68. .pll_freq = 100,
  69. .pixclk_divider = 6, /* Wince uses 14 which gives a 7MHz pclk. */
  70. .pixclk_divider_rotated = 6, /* we want a 14MHz one (much nicer to look at) */
  71. .pixclk_src = CLK_SRC_PLL,
  72. .sysclk_divider = 0,
  73. .sysclk_src = CLK_SRC_PLL,
  74. }
  75. };
  76. static struct w100_gpio_regs e800_w100_gpio_info = {
  77. .init_data1 = 0xc13fc019,
  78. .gpio_dir1 = 0x3e40df7f,
  79. .gpio_oe1 = 0x003c3000,
  80. .init_data2 = 0x00000000,
  81. .gpio_dir2 = 0x00000000,
  82. .gpio_oe2 = 0x00000000,
  83. };
  84. static struct w100_mem_info e800_w100_mem_info = {
  85. .ext_cntl = 0x09640011,
  86. .sdram_mode_reg = 0x00600021,
  87. .ext_timing_cntl = 0x10001545,
  88. .io_cntl = 0x7ddd7333,
  89. .size = 0x1fffff,
  90. };
  91. static void e800_tg_change(struct w100fb_par *par)
  92. {
  93. unsigned long tmp;
  94. tmp = w100fb_gpio_read(W100_GPIO_PORT_A);
  95. if (par->mode->xres == 480)
  96. tmp |= 0x100;
  97. else
  98. tmp &= ~0x100;
  99. w100fb_gpio_write(W100_GPIO_PORT_A, tmp);
  100. }
  101. static struct w100_tg_info e800_tg_info = {
  102. .change = e800_tg_change,
  103. };
  104. static struct w100fb_mach_info e800_fb_info = {
  105. .modelist = e800_lcd_mode,
  106. .num_modes = 2,
  107. .regs = &e800_lcd_regs,
  108. .gpio = &e800_w100_gpio_info,
  109. .mem = &e800_w100_mem_info,
  110. .tg = &e800_tg_info,
  111. .xtal_freq = 16000000,
  112. };
  113. static struct resource e800_fb_resources[] = {
  114. [0] = {
  115. .start = 0x0c000000,
  116. .end = 0x0cffffff,
  117. .flags = IORESOURCE_MEM,
  118. },
  119. };
  120. /* ----------------------- device declarations -------------------------- */
  121. static struct platform_device e800_fb_device = {
  122. .name = "w100fb",
  123. .id = -1,
  124. .dev = {
  125. .platform_data = &e800_fb_info,
  126. },
  127. .num_resources = ARRAY_SIZE(e800_fb_resources),
  128. .resource = e800_fb_resources,
  129. };
  130. static int e800_lcd_init(void)
  131. {
  132. if (!machine_is_e800())
  133. return -ENODEV;
  134. return platform_device_register(&e800_fb_device);
  135. }
  136. module_init(e800_lcd_init);
  137. MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
  138. MODULE_DESCRIPTION("e800 lcd driver");
  139. MODULE_LICENSE("GPLv2");