magician.c 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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/mfd/htc-egpio.h>
  21. #include <linux/mtd/mtd.h>
  22. #include <linux/mtd/map.h>
  23. #include <linux/mtd/physmap.h>
  24. #include <asm/gpio.h>
  25. #include <asm/hardware.h>
  26. #include <asm/mach-types.h>
  27. #include <asm/mach/arch.h>
  28. #include <asm/arch/magician.h>
  29. #include <asm/arch/pxa-regs.h>
  30. #include <asm/arch/pxafb.h>
  31. #include <asm/arch/i2c.h>
  32. #include <asm/arch/irda.h>
  33. #include <asm/arch/ohci.h>
  34. #include "generic.h"
  35. /*
  36. * IRDA
  37. */
  38. static void magician_irda_transceiver_mode(struct device *dev, int mode)
  39. {
  40. gpio_set_value(GPIO83_MAGICIAN_nIR_EN, mode & IR_OFF);
  41. }
  42. static struct pxaficp_platform_data magician_ficp_info = {
  43. .transceiver_cap = IR_SIRMODE | IR_OFF,
  44. .transceiver_mode = magician_irda_transceiver_mode,
  45. };
  46. /*
  47. * GPIO Keys
  48. */
  49. static struct gpio_keys_button magician_button_table[] = {
  50. {KEY_POWER, GPIO0_MAGICIAN_KEY_POWER, 0, "Power button"},
  51. {KEY_ESC, GPIO37_MAGICIAN_KEY_HANGUP, 0, "Hangup button"},
  52. {KEY_F10, GPIO38_MAGICIAN_KEY_CONTACTS, 0, "Contacts button"},
  53. {KEY_CALENDAR, GPIO90_MAGICIAN_KEY_CALENDAR, 0, "Calendar button"},
  54. {KEY_CAMERA, GPIO91_MAGICIAN_KEY_CAMERA, 0, "Camera button"},
  55. {KEY_UP, GPIO93_MAGICIAN_KEY_UP, 0, "Up button"},
  56. {KEY_DOWN, GPIO94_MAGICIAN_KEY_DOWN, 0, "Down button"},
  57. {KEY_LEFT, GPIO95_MAGICIAN_KEY_LEFT, 0, "Left button"},
  58. {KEY_RIGHT, GPIO96_MAGICIAN_KEY_RIGHT, 0, "Right button"},
  59. {KEY_KPENTER, GPIO97_MAGICIAN_KEY_ENTER, 0, "Action button"},
  60. {KEY_RECORD, GPIO98_MAGICIAN_KEY_RECORD, 0, "Record button"},
  61. {KEY_VOLUMEUP, GPIO100_MAGICIAN_KEY_VOL_UP, 0, "Volume up"},
  62. {KEY_VOLUMEDOWN, GPIO101_MAGICIAN_KEY_VOL_DOWN, 0, "Volume down"},
  63. {KEY_PHONE, GPIO102_MAGICIAN_KEY_PHONE, 0, "Phone button"},
  64. {KEY_PLAY, GPIO99_MAGICIAN_HEADPHONE_IN, 0, "Headset button"},
  65. };
  66. static struct gpio_keys_platform_data gpio_keys_data = {
  67. .buttons = magician_button_table,
  68. .nbuttons = ARRAY_SIZE(magician_button_table),
  69. };
  70. static struct platform_device gpio_keys = {
  71. .name = "gpio-keys",
  72. .dev = {
  73. .platform_data = &gpio_keys_data,
  74. },
  75. .id = -1,
  76. };
  77. /*
  78. * EGPIO (Xilinx CPLD)
  79. *
  80. * 7 32-bit aligned 8-bit registers: 3x output, 1x irq, 3x input
  81. */
  82. static struct resource egpio_resources[] = {
  83. [0] = {
  84. .start = PXA_CS3_PHYS,
  85. .end = PXA_CS3_PHYS + 0x20,
  86. .flags = IORESOURCE_MEM,
  87. },
  88. [1] = {
  89. .start = gpio_to_irq(GPIO13_MAGICIAN_CPLD_IRQ),
  90. .end = gpio_to_irq(GPIO13_MAGICIAN_CPLD_IRQ),
  91. .flags = IORESOURCE_IRQ,
  92. },
  93. };
  94. static struct htc_egpio_chip egpio_chips[] = {
  95. [0] = {
  96. .reg_start = 0,
  97. .gpio_base = MAGICIAN_EGPIO(0, 0),
  98. .num_gpios = 24,
  99. .direction = HTC_EGPIO_OUTPUT,
  100. .initial_values = 0x40, /* EGPIO_MAGICIAN_GSM_RESET */
  101. },
  102. [1] = {
  103. .reg_start = 4,
  104. .gpio_base = MAGICIAN_EGPIO(4, 0),
  105. .num_gpios = 24,
  106. .direction = HTC_EGPIO_INPUT,
  107. },
  108. };
  109. static struct htc_egpio_platform_data egpio_info = {
  110. .reg_width = 8,
  111. .bus_width = 32,
  112. .irq_base = IRQ_BOARD_START,
  113. .num_irqs = 4,
  114. .ack_register = 3,
  115. .chip = egpio_chips,
  116. .num_chips = ARRAY_SIZE(egpio_chips),
  117. };
  118. static struct platform_device egpio = {
  119. .name = "htc-egpio",
  120. .id = -1,
  121. .resource = egpio_resources,
  122. .num_resources = ARRAY_SIZE(egpio_resources),
  123. .dev = {
  124. .platform_data = &egpio_info,
  125. },
  126. };
  127. /*
  128. * LCD - Toppoly TD028STEB1
  129. */
  130. static struct pxafb_mode_info toppoly_modes[] = {
  131. {
  132. .pixclock = 96153,
  133. .bpp = 16,
  134. .xres = 240,
  135. .yres = 320,
  136. .hsync_len = 11,
  137. .vsync_len = 3,
  138. .left_margin = 19,
  139. .upper_margin = 2,
  140. .right_margin = 10,
  141. .lower_margin = 2,
  142. .sync = 0,
  143. },
  144. };
  145. static struct pxafb_mach_info toppoly_info = {
  146. .modes = toppoly_modes,
  147. .num_modes = 1,
  148. .fixed_modes = 1,
  149. .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
  150. .lccr3 = LCCR3_PixRsEdg,
  151. };
  152. /*
  153. * Backlight
  154. */
  155. static void magician_set_bl_intensity(int intensity)
  156. {
  157. if (intensity) {
  158. PWM_CTRL0 = 1;
  159. PWM_PERVAL0 = 0xc8;
  160. PWM_PWDUTY0 = intensity;
  161. pxa_set_cken(CKEN_PWM0, 1);
  162. } else {
  163. pxa_set_cken(CKEN_PWM0, 0);
  164. }
  165. }
  166. static struct generic_bl_info backlight_info = {
  167. .default_intensity = 0x64,
  168. .limit_mask = 0x0b,
  169. .max_intensity = 0xc7,
  170. .set_bl_intensity = magician_set_bl_intensity,
  171. };
  172. static struct platform_device backlight = {
  173. .name = "generic-bl",
  174. .dev = {
  175. .platform_data = &backlight_info,
  176. },
  177. .id = -1,
  178. };
  179. /*
  180. * USB OHCI
  181. */
  182. static int magician_ohci_init(struct device *dev)
  183. {
  184. UHCHR = (UHCHR | UHCHR_SSEP2 | UHCHR_PCPL | UHCHR_CGR) &
  185. ~(UHCHR_SSEP1 | UHCHR_SSEP3 | UHCHR_SSE);
  186. return 0;
  187. }
  188. static struct pxaohci_platform_data magician_ohci_info = {
  189. .port_mode = PMM_PERPORT_MODE,
  190. .init = magician_ohci_init,
  191. .power_budget = 0,
  192. };
  193. /*
  194. * StrataFlash
  195. */
  196. #define PXA_CS_SIZE 0x04000000
  197. static struct resource strataflash_resource = {
  198. .start = PXA_CS0_PHYS,
  199. .end = PXA_CS0_PHYS + PXA_CS_SIZE - 1,
  200. .flags = IORESOURCE_MEM,
  201. };
  202. static struct physmap_flash_data strataflash_data = {
  203. .width = 4,
  204. };
  205. static struct platform_device strataflash = {
  206. .name = "physmap-flash",
  207. .id = -1,
  208. .resource = &strataflash_resource,
  209. .num_resources = 1,
  210. .dev = {
  211. .platform_data = &strataflash_data,
  212. },
  213. };
  214. /*
  215. * Platform devices
  216. */
  217. static struct platform_device *devices[] __initdata = {
  218. &gpio_keys,
  219. &egpio,
  220. &backlight,
  221. &strataflash,
  222. };
  223. static void __init magician_init(void)
  224. {
  225. platform_add_devices(devices, ARRAY_SIZE(devices));
  226. pxa_set_i2c_info(NULL);
  227. pxa_set_ohci_info(&magician_ohci_info);
  228. pxa_set_ficp_info(&magician_ficp_info);
  229. set_pxa_fb_info(&toppoly_info);
  230. }
  231. MACHINE_START(MAGICIAN, "HTC Magician")
  232. .phys_io = 0x40000000,
  233. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  234. .boot_params = 0xa0000100,
  235. .map_io = pxa_map_io,
  236. .init_irq = pxa27x_init_irq,
  237. .init_machine = magician_init,
  238. .timer = &pxa_timer,
  239. MACHINE_END