functionDefinition.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. /*
  2. * linux/arch/arm/mach-omap1/board-ams-delta.c
  3. *
  4. * Modified from board-generic.c
  5. *
  6. * Board specific inits for the Amstrad E3 (codename Delta) videophone
  7. *
  8. * Copyright (C) 2006 Jonathan McDowell <noodles@earth.li>
  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. #include <linux/basic_mmio_gpio.h>
  15. #include <linux/gpio.h>
  16. #include <linux/kernel.h>
  17. #include <linux/init.h>
  18. #include <linux/input.h>
  19. #include <linux/interrupt.h>
  20. #include <linux/leds.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/regulator/consumer.h>
  23. #include <linux/regulator/fixed.h>
  24. #include <linux/regulator/machine.h>
  25. #include <linux/serial_8250.h>
  26. #include <linux/export.h>
  27. #include <linux/omapfb.h>
  28. #include <linux/io.h>
  29. #include <linux/platform_data/gpio-omap.h>
  30. #include <media/soc_camera.h>
  31. #include <asm/serial.h>
  32. #include <asm/mach-types.h>
  33. #include <asm/mach/arch.h>
  34. #include <asm/mach/map.h>
  35. #include <mach/board-ams-delta.h>
  36. #include <linux/platform_data/keypad-omap.h>
  37. #include <mach/mux.h>
  38. #include <mach/hardware.h>
  39. #include <mach/ams-delta-fiq.h>
  40. #include <mach/camera.h>
  41. #include <mach/usb.h>
  42. #include "iomap.h"
  43. #include "common.h"
  44. static const unsigned int ams_delta_keymap[] = {
  45. KEY(0, 0, KEY_F1), /* Advert */
  46. KEY(0, 3, KEY_COFFEE), /* Games */
  47. KEY(0, 2, KEY_QUESTION), /* Directory */
  48. KEY(2, 3, KEY_CONNECT), /* Internet */
  49. KEY(1, 2, KEY_SHOP), /* Services */
  50. KEY(1, 1, KEY_PHONE), /* VoiceMail */
  51. KEY(0, 1, KEY_DELETE), /* Delete */
  52. KEY(2, 2, KEY_PLAY), /* Play */
  53. KEY(1, 0, KEY_PAGEUP), /* Up */
  54. KEY(1, 3, KEY_PAGEDOWN), /* Down */
  55. KEY(2, 0, KEY_EMAIL), /* ReadEmail */
  56. KEY(2, 1, KEY_STOP), /* Stop */
  57. /* Numeric keypad portion */
  58. KEY(0, 7, KEY_KP1),
  59. KEY(0, 6, KEY_KP2),
  60. KEY(0, 5, KEY_KP3),
  61. KEY(1, 7, KEY_KP4),
  62. KEY(1, 6, KEY_KP5),
  63. KEY(1, 5, KEY_KP6),
  64. KEY(2, 7, KEY_KP7),
  65. KEY(2, 6, KEY_KP8),
  66. KEY(2, 5, KEY_KP9),
  67. KEY(3, 6, KEY_KP0),
  68. KEY(3, 7, KEY_KPASTERISK),
  69. KEY(3, 5, KEY_KPDOT), /* # key */
  70. KEY(7, 2, KEY_NUMLOCK), /* Mute */
  71. KEY(7, 1, KEY_KPMINUS), /* Recall */
  72. KEY(6, 1, KEY_KPPLUS), /* Redial */
  73. KEY(7, 6, KEY_KPSLASH), /* Handsfree */
  74. KEY(6, 0, KEY_ENTER), /* Video */
  75. KEY(7, 4, KEY_CAMERA), /* Photo */
  76. KEY(0, 4, KEY_F2), /* Home */
  77. KEY(1, 4, KEY_F3), /* Office */
  78. KEY(2, 4, KEY_F4), /* Mobile */
  79. KEY(7, 7, KEY_F5), /* SMS */
  80. KEY(7, 5, KEY_F6), /* Email */
  81. /* QWERTY portion of keypad */
  82. KEY(3, 4, KEY_Q),
  83. KEY(3, 3, KEY_W),
  84. KEY(3, 2, KEY_E),
  85. KEY(3, 1, KEY_R),
  86. KEY(3, 0, KEY_T),
  87. KEY(4, 7, KEY_Y),
  88. KEY(4, 6, KEY_U),
  89. KEY(4, 5, KEY_I),
  90. KEY(4, 4, KEY_O),
  91. KEY(4, 3, KEY_P),
  92. KEY(4, 2, KEY_A),
  93. KEY(4, 1, KEY_S),
  94. KEY(4, 0, KEY_D),
  95. KEY(5, 7, KEY_F),
  96. KEY(5, 6, KEY_G),
  97. KEY(5, 5, KEY_H),
  98. KEY(5, 4, KEY_J),
  99. KEY(5, 3, KEY_K),
  100. KEY(5, 2, KEY_L),
  101. KEY(5, 1, KEY_Z),
  102. KEY(5, 0, KEY_X),
  103. KEY(6, 7, KEY_C),
  104. KEY(6, 6, KEY_V),
  105. KEY(6, 5, KEY_B),
  106. KEY(6, 4, KEY_N),
  107. KEY(6, 3, KEY_M),
  108. KEY(6, 2, KEY_SPACE),
  109. KEY(7, 0, KEY_LEFTSHIFT), /* Vol up */
  110. KEY(7, 3, KEY_LEFTCTRL), /* Vol down */
  111. };
  112. #define LATCH1_PHYS 0x01000000
  113. #define LATCH1_VIRT 0xEA000000
  114. #define MODEM_PHYS 0x04000000
  115. #define MODEM_VIRT 0xEB000000
  116. #define LATCH2_PHYS 0x08000000
  117. #define LATCH2_VIRT 0xEC000000
  118. static struct map_desc ams_delta_io_desc[] __initdata = {
  119. /* AMS_DELTA_LATCH1 */
  120. {
  121. .virtual = LATCH1_VIRT,
  122. .pfn = __phys_to_pfn(LATCH1_PHYS),
  123. .length = 0x01000000,
  124. .type = MT_DEVICE
  125. },
  126. /* AMS_DELTA_LATCH2 */
  127. {
  128. .virtual = LATCH2_VIRT,
  129. .pfn = __phys_to_pfn(LATCH2_PHYS),
  130. .length = 0x01000000,
  131. .type = MT_DEVICE
  132. },
  133. /* AMS_DELTA_MODEM */
  134. {
  135. .virtual = MODEM_VIRT,
  136. .pfn = __phys_to_pfn(MODEM_PHYS),
  137. .length = 0x01000000,
  138. .type = MT_DEVICE
  139. }
  140. };
  141. static struct omap_lcd_config ams_delta_lcd_config __initdata = {
  142. .ctrl_name = "internal",
  143. };
  144. static struct omap_usb_config ams_delta_usb_config __initdata = {
  145. .register_host = 1,
  146. .hmc_mode = 16,
  147. .pins[0] = 2,
  148. };
  149. #define LATCH1_GPIO_BASE 232
  150. #define LATCH1_NGPIO 8
  151. static struct resource latch1_resources[] = {
  152. [0] = {
  153. .name = "dat",
  154. .start = LATCH1_PHYS,
  155. .end = LATCH1_PHYS + (LATCH1_NGPIO - 1) / 8,
  156. .flags = IORESOURCE_MEM,
  157. },
  158. };
  159. static struct bgpio_pdata latch1_pdata = {
  160. .base = LATCH1_GPIO_BASE,
  161. .ngpio = LATCH1_NGPIO,
  162. };
  163. static struct platform_device latch1_gpio_device = {
  164. .name = "basic-mmio-gpio",
  165. .id = 0,
  166. .resource = latch1_resources,
  167. .num_resources = ARRAY_SIZE(latch1_resources),
  168. .dev = {
  169. .platform_data = &latch1_pdata,
  170. },
  171. };
  172. static struct resource latch2_resources[] = {
  173. [0] = {
  174. .name = "dat",
  175. .start = LATCH2_PHYS,
  176. .end = LATCH2_PHYS + (AMS_DELTA_LATCH2_NGPIO - 1) / 8,
  177. .flags = IORESOURCE_MEM,
  178. },
  179. };
  180. static struct bgpio_pdata latch2_pdata = {
  181. .base = AMS_DELTA_LATCH2_GPIO_BASE,
  182. .ngpio = AMS_DELTA_LATCH2_NGPIO,
  183. };
  184. static struct platform_device latch2_gpio_device = {
  185. .name = "basic-mmio-gpio",
  186. .id = 1,
  187. .resource = latch2_resources,
  188. .num_resources = ARRAY_SIZE(latch2_resources),
  189. .dev = {
  190. .platform_data = &latch2_pdata,
  191. },
  192. };
  193. static const struct gpio latch_gpios[] __initconst = {
  194. {
  195. .gpio = LATCH1_GPIO_BASE + 6,
  196. .flags = GPIOF_OUT_INIT_LOW,
  197. .label = "dockit1",
  198. },
  199. {
  200. .gpio = LATCH1_GPIO_BASE + 7,
  201. .flags = GPIOF_OUT_INIT_LOW,
  202. .label = "dockit2",
  203. },
  204. {
  205. .gpio = AMS_DELTA_GPIO_PIN_SCARD_RSTIN,
  206. .flags = GPIOF_OUT_INIT_LOW,
  207. .label = "scard_rstin",
  208. },
  209. {
  210. .gpio = AMS_DELTA_GPIO_PIN_SCARD_CMDVCC,
  211. .flags = GPIOF_OUT_INIT_LOW,
  212. .label = "scard_cmdvcc",
  213. },
  214. {
  215. .gpio = AMS_DELTA_GPIO_PIN_MODEM_CODEC,
  216. .flags = GPIOF_OUT_INIT_LOW,
  217. .label = "modem_codec",
  218. },
  219. {
  220. .gpio = AMS_DELTA_LATCH2_GPIO_BASE + 14,
  221. .flags = GPIOF_OUT_INIT_LOW,
  222. .label = "hookflash1",
  223. },
  224. {
  225. .gpio = AMS_DELTA_LATCH2_GPIO_BASE + 15,
  226. .flags = GPIOF_OUT_INIT_LOW,
  227. .label = "hookflash2",
  228. },
  229. };
  230. static struct regulator_consumer_supply modem_nreset_consumers[] = {
  231. REGULATOR_SUPPLY("RESET#", "serial8250.1"),
  232. REGULATOR_SUPPLY("POR", "cx20442-codec"),
  233. };
  234. static struct regulator_init_data modem_nreset_data = {
  235. .constraints = {
  236. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  237. .boot_on = 1,
  238. },
  239. .num_consumer_supplies = ARRAY_SIZE(modem_nreset_consumers),
  240. .consumer_supplies = modem_nreset_consumers,
  241. };
  242. static struct fixed_voltage_config modem_nreset_config = {
  243. .supply_name = "modem_nreset",
  244. .microvolts = 3300000,
  245. .gpio = AMS_DELTA_GPIO_PIN_MODEM_NRESET,
  246. .startup_delay = 25000,
  247. .enable_high = 1,
  248. .enabled_at_boot = 1,
  249. .init_data = &modem_nreset_data,
  250. };
  251. static struct platform_device modem_nreset_device = {
  252. .name = "reg-fixed-voltage",
  253. .id = -1,
  254. .dev = {
  255. .platform_data = &modem_nreset_config,
  256. },
  257. };
  258. struct modem_private_data {
  259. struct regulator *regulator;
  260. };
  261. static struct modem_private_data modem_priv;
  262. void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value)
  263. {
  264. int bit = 0;
  265. u16 bitpos = 1 << bit;
  266. for (; bit < ngpio; bit++, bitpos = bitpos << 1) {
  267. if (!(mask & bitpos))
  268. continue;
  269. else
  270. gpio_set_value(base + bit, (value & bitpos) != 0);
  271. }
  272. }
  273. EXPORT_SYMBOL(ams_delta_latch_write);
  274. static struct resource ams_delta_nand_resources[] = {
  275. [0] = {
  276. .start = OMAP1_MPUIO_BASE,
  277. .end = OMAP1_MPUIO_BASE +
  278. OMAP_MPUIO_IO_CNTL + sizeof(u32) - 1,
  279. .flags = IORESOURCE_MEM,
  280. },
  281. };