devices.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. /* linux/arch/arm/mach-vt8500/devices.c
  2. *
  3. * Copyright (C) 2010 Alexey Charkov <alchark@gmail.com>
  4. *
  5. * This software is licensed under the terms of the GNU General Public
  6. * License version 2, as published by the Free Software Foundation, and
  7. * may be copied, distributed, and modified under those terms.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. */
  15. #include <linux/kernel.h>
  16. #include <linux/io.h>
  17. #include <linux/device.h>
  18. #include <linux/dma-mapping.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/pwm_backlight.h>
  21. #include <linux/memblock.h>
  22. #include <asm/mach/arch.h>
  23. #include <mach/vt8500fb.h>
  24. #include <mach/i8042.h>
  25. #include "devices.h"
  26. /* These can't use resources currently */
  27. unsigned long wmt_ic_base __initdata;
  28. unsigned long wmt_sic_base __initdata;
  29. unsigned long wmt_gpio_base __initdata;
  30. unsigned long wmt_pmc_base __initdata;
  31. unsigned long wmt_i8042_base __initdata;
  32. int wmt_nr_irqs __initdata;
  33. int wmt_timer_irq __initdata;
  34. int wmt_gpio_ext_irq[8] __initdata;
  35. /* Should remain accessible after init.
  36. * i8042 driver desperately calls for attention...
  37. */
  38. int wmt_i8042_kbd_irq;
  39. int wmt_i8042_aux_irq;
  40. static u64 fb_dma_mask = DMA_BIT_MASK(32);
  41. struct platform_device vt8500_device_lcdc = {
  42. .name = "vt8500-lcd",
  43. .id = 0,
  44. .dev = {
  45. .dma_mask = &fb_dma_mask,
  46. .coherent_dma_mask = DMA_BIT_MASK(32),
  47. },
  48. };
  49. struct platform_device vt8500_device_wm8505_fb = {
  50. .name = "wm8505-fb",
  51. .id = 0,
  52. };
  53. /* Smallest to largest */
  54. static struct vt8500fb_platform_data panels[] = {
  55. #ifdef CONFIG_WMT_PANEL_800X480
  56. {
  57. .xres_virtual = 800,
  58. .yres_virtual = 480 * 2,
  59. .mode = {
  60. .name = "800x480",
  61. .xres = 800,
  62. .yres = 480,
  63. .left_margin = 88,
  64. .right_margin = 40,
  65. .upper_margin = 32,
  66. .lower_margin = 11,
  67. .hsync_len = 0,
  68. .vsync_len = 1,
  69. .vmode = FB_VMODE_NONINTERLACED,
  70. },
  71. },
  72. #endif
  73. #ifdef CONFIG_WMT_PANEL_800X600
  74. {
  75. .xres_virtual = 800,
  76. .yres_virtual = 600 * 2,
  77. .mode = {
  78. .name = "800x600",
  79. .xres = 800,
  80. .yres = 600,
  81. .left_margin = 88,
  82. .right_margin = 40,
  83. .upper_margin = 32,
  84. .lower_margin = 11,
  85. .hsync_len = 0,
  86. .vsync_len = 1,
  87. .vmode = FB_VMODE_NONINTERLACED,
  88. },
  89. },
  90. #endif
  91. #ifdef CONFIG_WMT_PANEL_1024X576
  92. {
  93. .xres_virtual = 1024,
  94. .yres_virtual = 576 * 2,
  95. .mode = {
  96. .name = "1024x576",
  97. .xres = 1024,
  98. .yres = 576,
  99. .left_margin = 40,
  100. .right_margin = 24,
  101. .upper_margin = 32,
  102. .lower_margin = 11,
  103. .hsync_len = 96,
  104. .vsync_len = 2,
  105. .vmode = FB_VMODE_NONINTERLACED,
  106. },
  107. },
  108. #endif
  109. #ifdef CONFIG_WMT_PANEL_1024X600
  110. {
  111. .xres_virtual = 1024,
  112. .yres_virtual = 600 * 2,
  113. .mode = {
  114. .name = "1024x600",
  115. .xres = 1024,
  116. .yres = 600,
  117. .left_margin = 66,
  118. .right_margin = 2,
  119. .upper_margin = 19,
  120. .lower_margin = 1,
  121. .hsync_len = 23,
  122. .vsync_len = 8,
  123. .vmode = FB_VMODE_NONINTERLACED,
  124. },
  125. },
  126. #endif
  127. };
  128. static int current_panel_idx __initdata = ARRAY_SIZE(panels) - 1;
  129. static int __init panel_setup(char *str)
  130. {
  131. int i;
  132. for (i = 0; i < ARRAY_SIZE(panels); i++) {
  133. if (strcmp(panels[i].mode.name, str) == 0) {
  134. current_panel_idx = i;
  135. break;
  136. }
  137. }
  138. return 0;
  139. }
  140. early_param("panel", panel_setup);
  141. static inline void preallocate_fb(struct vt8500fb_platform_data *p,
  142. unsigned long align) {
  143. p->video_mem_len = (p->xres_virtual * p->yres_virtual * 4) >>
  144. (p->bpp > 16 ? 0 : (p->bpp > 8 ? 1 :
  145. (8 / p->bpp) + 1));
  146. p->video_mem_phys = (unsigned long)memblock_alloc(p->video_mem_len,
  147. align);
  148. p->video_mem_virt = phys_to_virt(p->video_mem_phys);
  149. }
  150. struct platform_device vt8500_device_uart0 = {
  151. .name = "vt8500_serial",
  152. .id = 0,
  153. };
  154. struct platform_device vt8500_device_uart1 = {
  155. .name = "vt8500_serial",
  156. .id = 1,
  157. };
  158. struct platform_device vt8500_device_uart2 = {
  159. .name = "vt8500_serial",
  160. .id = 2,
  161. };
  162. struct platform_device vt8500_device_uart3 = {
  163. .name = "vt8500_serial",
  164. .id = 3,
  165. };
  166. struct platform_device vt8500_device_uart4 = {
  167. .name = "vt8500_serial",
  168. .id = 4,
  169. };
  170. struct platform_device vt8500_device_uart5 = {
  171. .name = "vt8500_serial",
  172. .id = 5,
  173. };
  174. static u64 ehci_dma_mask = DMA_BIT_MASK(32);
  175. struct platform_device vt8500_device_ehci = {
  176. .name = "vt8500-ehci",
  177. .id = 0,
  178. .dev = {
  179. .dma_mask = &ehci_dma_mask,
  180. .coherent_dma_mask = DMA_BIT_MASK(32),
  181. },
  182. };
  183. struct platform_device vt8500_device_ge_rops = {
  184. .name = "wmt_ge_rops",
  185. .id = -1,
  186. };
  187. struct platform_device vt8500_device_pwm = {
  188. .name = "vt8500-pwm",
  189. .id = 0,
  190. };
  191. static struct platform_pwm_backlight_data vt8500_pwmbl_data = {
  192. .pwm_id = 0,
  193. .max_brightness = 128,
  194. .dft_brightness = 70,
  195. .pwm_period_ns = 250000, /* revisit when clocks are implemented */
  196. };
  197. struct platform_device vt8500_device_pwmbl = {
  198. .name = "pwm-backlight",
  199. .id = 0,
  200. .dev = {
  201. .platform_data = &vt8500_pwmbl_data,
  202. },
  203. };
  204. struct platform_device vt8500_device_rtc = {
  205. .name = "vt8500-rtc",
  206. .id = 0,
  207. };
  208. struct map_desc wmt_io_desc[] __initdata = {
  209. /* SoC MMIO registers */
  210. [0] = {
  211. .virtual = 0xf8000000,
  212. .pfn = __phys_to_pfn(0xd8000000),
  213. .length = 0x00390000, /* max of all chip variants */
  214. .type = MT_DEVICE
  215. },
  216. /* PCI I/O space, numbers tied to those in <mach/io.h> */
  217. [1] = {
  218. .virtual = 0xf0000000,
  219. .pfn = __phys_to_pfn(0xc0000000),
  220. .length = SZ_64K,
  221. .type = MT_DEVICE
  222. },
  223. };
  224. void __init vt8500_reserve_mem(void)
  225. {
  226. #ifdef CONFIG_FB_VT8500
  227. panels[current_panel_idx].bpp = 16; /* Always use RGB565 */
  228. preallocate_fb(&panels[current_panel_idx], SZ_4M);
  229. vt8500_device_lcdc.dev.platform_data = &panels[current_panel_idx];
  230. #endif
  231. }
  232. void __init wm8505_reserve_mem(void)
  233. {
  234. #if defined CONFIG_FB_WM8505
  235. panels[current_panel_idx].bpp = 32; /* Always use RGB888 */
  236. preallocate_fb(&panels[current_panel_idx], 32);
  237. vt8500_device_wm8505_fb.dev.platform_data = &panels[current_panel_idx];
  238. #endif
  239. }