magician.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*
  2. * Support for HTC Magician PDA phones:
  3. * i-mate JAM, O2 Xda mini, Orange SPV M500, Qtek s100, Qtek s110
  4. * and T-Mobile MDA Compact.
  5. *
  6. * Copyright (c) 2006-2007 Philipp Zabel
  7. *
  8. * Based on hx4700.c, spitz.c and others.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. *
  14. */
  15. #include <linux/kernel.h>
  16. #include <linux/init.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/gpio_keys.h>
  19. #include <linux/input.h>
  20. #include <linux/mtd/mtd.h>
  21. #include <linux/mtd/map.h>
  22. #include <linux/mtd/physmap.h>
  23. #include <asm/gpio.h>
  24. #include <asm/hardware.h>
  25. #include <asm/mach-types.h>
  26. #include <asm/mach/arch.h>
  27. #include <asm/arch/magician.h>
  28. #include <asm/arch/pxa-regs.h>
  29. #include <asm/arch/pxafb.h>
  30. #include <asm/arch/irda.h>
  31. #include <asm/arch/ohci.h>
  32. #include "generic.h"
  33. /*
  34. * IRDA
  35. */
  36. static void magician_irda_transceiver_mode(struct device *dev, int mode)
  37. {
  38. gpio_set_value(GPIO83_MAGICIAN_nIR_EN, mode & IR_OFF);
  39. }
  40. static struct pxaficp_platform_data magician_ficp_info = {
  41. .transceiver_cap = IR_SIRMODE | IR_OFF,
  42. .transceiver_mode = magician_irda_transceiver_mode,
  43. };
  44. /*
  45. * GPIO Keys
  46. */
  47. static struct gpio_keys_button magician_button_table[] = {
  48. {KEY_POWER, GPIO0_MAGICIAN_KEY_POWER, 0, "Power button"},
  49. {KEY_ESC, GPIO37_MAGICIAN_KEY_HANGUP, 0, "Hangup button"},
  50. {KEY_F10, GPIO38_MAGICIAN_KEY_CONTACTS, 0, "Contacts button"},
  51. {KEY_CALENDAR, GPIO90_MAGICIAN_KEY_CALENDAR, 0, "Calendar button"},
  52. {KEY_CAMERA, GPIO91_MAGICIAN_KEY_CAMERA, 0, "Camera button"},
  53. {KEY_UP, GPIO93_MAGICIAN_KEY_UP, 0, "Up button"},
  54. {KEY_DOWN, GPIO94_MAGICIAN_KEY_DOWN, 0, "Down button"},
  55. {KEY_LEFT, GPIO95_MAGICIAN_KEY_LEFT, 0, "Left button"},
  56. {KEY_RIGHT, GPIO96_MAGICIAN_KEY_RIGHT, 0, "Right button"},
  57. {KEY_KPENTER, GPIO97_MAGICIAN_KEY_ENTER, 0, "Action button"},
  58. {KEY_RECORD, GPIO98_MAGICIAN_KEY_RECORD, 0, "Record button"},
  59. {KEY_VOLUMEUP, GPIO100_MAGICIAN_KEY_VOL_UP, 0, "Volume up"},
  60. {KEY_VOLUMEDOWN, GPIO101_MAGICIAN_KEY_VOL_DOWN, 0, "Volume down"},
  61. {KEY_PHONE, GPIO102_MAGICIAN_KEY_PHONE, 0, "Phone button"},
  62. {KEY_PLAY, GPIO99_MAGICIAN_HEADPHONE_IN, 0, "Headset button"},
  63. };
  64. static struct gpio_keys_platform_data gpio_keys_data = {
  65. .buttons = magician_button_table,
  66. .nbuttons = ARRAY_SIZE(magician_button_table),
  67. };
  68. static struct platform_device gpio_keys = {
  69. .name = "gpio-keys",
  70. .dev = {
  71. .platform_data = &gpio_keys_data,
  72. },
  73. .id = -1,
  74. };
  75. /*
  76. * LCD - Toppoly TD028STEB1
  77. */
  78. static struct pxafb_mode_info toppoly_modes[] = {
  79. {
  80. .pixclock = 96153,
  81. .bpp = 16,
  82. .xres = 240,
  83. .yres = 320,
  84. .hsync_len = 11,
  85. .vsync_len = 3,
  86. .left_margin = 19,
  87. .upper_margin = 2,
  88. .right_margin = 10,
  89. .lower_margin = 2,
  90. .sync = 0,
  91. },
  92. };
  93. static struct pxafb_mach_info toppoly_info = {
  94. .modes = toppoly_modes,
  95. .num_modes = 1,
  96. .fixed_modes = 1,
  97. .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
  98. .lccr3 = LCCR3_PixRsEdg,
  99. };
  100. /*
  101. * Backlight
  102. */
  103. static void magician_set_bl_intensity(int intensity)
  104. {
  105. if (intensity) {
  106. PWM_CTRL0 = 1;
  107. PWM_PERVAL0 = 0xc8;
  108. PWM_PWDUTY0 = intensity;
  109. pxa_set_cken(CKEN_PWM0, 1);
  110. } else {
  111. pxa_set_cken(CKEN_PWM0, 0);
  112. }
  113. }
  114. static struct generic_bl_info backlight_info = {
  115. .default_intensity = 0x64,
  116. .limit_mask = 0x0b,
  117. .max_intensity = 0xc7,
  118. .set_bl_intensity = magician_set_bl_intensity,
  119. };
  120. static struct platform_device backlight = {
  121. .name = "corgi-bl",
  122. .dev = {
  123. .platform_data = &backlight_info,
  124. },
  125. .id = -1,
  126. };
  127. /*
  128. * USB OHCI
  129. */
  130. static int magician_ohci_init(struct device *dev)
  131. {
  132. UHCHR = (UHCHR | UHCHR_SSEP2 | UHCHR_PCPL | UHCHR_CGR) &
  133. ~(UHCHR_SSEP1 | UHCHR_SSEP3 | UHCHR_SSE);
  134. return 0;
  135. }
  136. static struct pxaohci_platform_data magician_ohci_info = {
  137. .port_mode = PMM_PERPORT_MODE,
  138. .init = magician_ohci_init,
  139. .power_budget = 0,
  140. };
  141. /*
  142. * StrataFlash
  143. */
  144. #define PXA_CS_SIZE 0x04000000
  145. static struct resource strataflash_resource = {
  146. .start = PXA_CS0_PHYS,
  147. .end = PXA_CS0_PHYS + PXA_CS_SIZE - 1,
  148. .flags = IORESOURCE_MEM,
  149. };
  150. static struct physmap_flash_data strataflash_data = {
  151. .width = 4,
  152. };
  153. static struct platform_device strataflash = {
  154. .name = "physmap-flash",
  155. .id = -1,
  156. .num_resources = 1,
  157. .resource = &strataflash_resource,
  158. .dev = {
  159. .platform_data = &strataflash_data,
  160. },
  161. };
  162. /*
  163. * Platform devices
  164. */
  165. static struct platform_device *devices[] __initdata = {
  166. &gpio_keys,
  167. &backlight,
  168. &strataflash,
  169. };
  170. static void __init magician_init(void)
  171. {
  172. platform_add_devices(devices, ARRAY_SIZE(devices));
  173. pxa_set_ohci_info(&magician_ohci_info);
  174. pxa_set_ficp_info(&magician_ficp_info);
  175. set_pxa_fb_info(&toppoly_info);
  176. }
  177. MACHINE_START(MAGICIAN, "HTC Magician")
  178. .phys_io = 0x40000000,
  179. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  180. .boot_params = 0xa0000100,
  181. .map_io = pxa_map_io,
  182. .init_irq = pxa27x_init_irq,
  183. .init_machine = magician_init,
  184. .timer = &pxa_timer,
  185. MACHINE_END