board-ams-delta.c 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  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/gpio.h>
  15. #include <linux/kernel.h>
  16. #include <linux/init.h>
  17. #include <linux/input.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/leds.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/serial_8250.h>
  22. #include <linux/export.h>
  23. #include <linux/omapfb.h>
  24. #include <media/soc_camera.h>
  25. #include <asm/serial.h>
  26. #include <mach/hardware.h>
  27. #include <asm/mach-types.h>
  28. #include <asm/mach/arch.h>
  29. #include <asm/mach/map.h>
  30. #include <plat/io.h>
  31. #include <plat/board-ams-delta.h>
  32. #include <plat/keypad.h>
  33. #include <plat/mux.h>
  34. #include <plat/usb.h>
  35. #include <plat/board.h>
  36. #include "common.h"
  37. #include <mach/camera.h>
  38. #include <mach/ams-delta-fiq.h>
  39. static u8 ams_delta_latch1_reg;
  40. static u16 ams_delta_latch2_reg;
  41. static const unsigned int ams_delta_keymap[] = {
  42. KEY(0, 0, KEY_F1), /* Advert */
  43. KEY(0, 3, KEY_COFFEE), /* Games */
  44. KEY(0, 2, KEY_QUESTION), /* Directory */
  45. KEY(2, 3, KEY_CONNECT), /* Internet */
  46. KEY(1, 2, KEY_SHOP), /* Services */
  47. KEY(1, 1, KEY_PHONE), /* VoiceMail */
  48. KEY(0, 1, KEY_DELETE), /* Delete */
  49. KEY(2, 2, KEY_PLAY), /* Play */
  50. KEY(1, 0, KEY_PAGEUP), /* Up */
  51. KEY(1, 3, KEY_PAGEDOWN), /* Down */
  52. KEY(2, 0, KEY_EMAIL), /* ReadEmail */
  53. KEY(2, 1, KEY_STOP), /* Stop */
  54. /* Numeric keypad portion */
  55. KEY(0, 7, KEY_KP1),
  56. KEY(0, 6, KEY_KP2),
  57. KEY(0, 5, KEY_KP3),
  58. KEY(1, 7, KEY_KP4),
  59. KEY(1, 6, KEY_KP5),
  60. KEY(1, 5, KEY_KP6),
  61. KEY(2, 7, KEY_KP7),
  62. KEY(2, 6, KEY_KP8),
  63. KEY(2, 5, KEY_KP9),
  64. KEY(3, 6, KEY_KP0),
  65. KEY(3, 7, KEY_KPASTERISK),
  66. KEY(3, 5, KEY_KPDOT), /* # key */
  67. KEY(7, 2, KEY_NUMLOCK), /* Mute */
  68. KEY(7, 1, KEY_KPMINUS), /* Recall */
  69. KEY(6, 1, KEY_KPPLUS), /* Redial */
  70. KEY(7, 6, KEY_KPSLASH), /* Handsfree */
  71. KEY(6, 0, KEY_ENTER), /* Video */
  72. KEY(7, 4, KEY_CAMERA), /* Photo */
  73. KEY(0, 4, KEY_F2), /* Home */
  74. KEY(1, 4, KEY_F3), /* Office */
  75. KEY(2, 4, KEY_F4), /* Mobile */
  76. KEY(7, 7, KEY_F5), /* SMS */
  77. KEY(7, 5, KEY_F6), /* Email */
  78. /* QWERTY portion of keypad */
  79. KEY(3, 4, KEY_Q),
  80. KEY(3, 3, KEY_W),
  81. KEY(3, 2, KEY_E),
  82. KEY(3, 1, KEY_R),
  83. KEY(3, 0, KEY_T),
  84. KEY(4, 7, KEY_Y),
  85. KEY(4, 6, KEY_U),
  86. KEY(4, 5, KEY_I),
  87. KEY(4, 4, KEY_O),
  88. KEY(4, 3, KEY_P),
  89. KEY(4, 2, KEY_A),
  90. KEY(4, 1, KEY_S),
  91. KEY(4, 0, KEY_D),
  92. KEY(5, 7, KEY_F),
  93. KEY(5, 6, KEY_G),
  94. KEY(5, 5, KEY_H),
  95. KEY(5, 4, KEY_J),
  96. KEY(5, 3, KEY_K),
  97. KEY(5, 2, KEY_L),
  98. KEY(5, 1, KEY_Z),
  99. KEY(5, 0, KEY_X),
  100. KEY(6, 7, KEY_C),
  101. KEY(6, 6, KEY_V),
  102. KEY(6, 5, KEY_B),
  103. KEY(6, 4, KEY_N),
  104. KEY(6, 3, KEY_M),
  105. KEY(6, 2, KEY_SPACE),
  106. KEY(7, 0, KEY_LEFTSHIFT), /* Vol up */
  107. KEY(7, 3, KEY_LEFTCTRL), /* Vol down */
  108. };
  109. void ams_delta_latch1_write(u8 mask, u8 value)
  110. {
  111. ams_delta_latch1_reg &= ~mask;
  112. ams_delta_latch1_reg |= value;
  113. *(volatile __u8 *) AMS_DELTA_LATCH1_VIRT = ams_delta_latch1_reg;
  114. }
  115. void ams_delta_latch2_write(u16 mask, u16 value)
  116. {
  117. ams_delta_latch2_reg &= ~mask;
  118. ams_delta_latch2_reg |= value;
  119. *(volatile __u16 *) AMS_DELTA_LATCH2_VIRT = ams_delta_latch2_reg;
  120. }
  121. static struct map_desc ams_delta_io_desc[] __initdata = {
  122. /* AMS_DELTA_LATCH1 */
  123. {
  124. .virtual = AMS_DELTA_LATCH1_VIRT,
  125. .pfn = __phys_to_pfn(AMS_DELTA_LATCH1_PHYS),
  126. .length = 0x01000000,
  127. .type = MT_DEVICE
  128. },
  129. /* AMS_DELTA_LATCH2 */
  130. {
  131. .virtual = AMS_DELTA_LATCH2_VIRT,
  132. .pfn = __phys_to_pfn(AMS_DELTA_LATCH2_PHYS),
  133. .length = 0x01000000,
  134. .type = MT_DEVICE
  135. },
  136. /* AMS_DELTA_MODEM */
  137. {
  138. .virtual = AMS_DELTA_MODEM_VIRT,
  139. .pfn = __phys_to_pfn(AMS_DELTA_MODEM_PHYS),
  140. .length = 0x01000000,
  141. .type = MT_DEVICE
  142. }
  143. };
  144. static struct omap_lcd_config ams_delta_lcd_config = {
  145. .ctrl_name = "internal",
  146. };
  147. static struct omap_usb_config ams_delta_usb_config __initdata = {
  148. .register_host = 1,
  149. .hmc_mode = 16,
  150. .pins[0] = 2,
  151. };
  152. static struct resource ams_delta_nand_resources[] = {
  153. [0] = {
  154. .start = OMAP1_MPUIO_BASE,
  155. .end = OMAP1_MPUIO_BASE +
  156. OMAP_MPUIO_IO_CNTL + sizeof(u32) - 1,
  157. .flags = IORESOURCE_MEM,
  158. },
  159. };
  160. static struct platform_device ams_delta_nand_device = {
  161. .name = "ams-delta-nand",
  162. .id = -1,
  163. .num_resources = ARRAY_SIZE(ams_delta_nand_resources),
  164. .resource = ams_delta_nand_resources,
  165. };
  166. static struct resource ams_delta_kp_resources[] = {
  167. [0] = {
  168. .start = INT_KEYBOARD,
  169. .end = INT_KEYBOARD,
  170. .flags = IORESOURCE_IRQ,
  171. },
  172. };
  173. static const struct matrix_keymap_data ams_delta_keymap_data = {
  174. .keymap = ams_delta_keymap,
  175. .keymap_size = ARRAY_SIZE(ams_delta_keymap),
  176. };
  177. static struct omap_kp_platform_data ams_delta_kp_data __initdata = {
  178. .rows = 8,
  179. .cols = 8,
  180. .keymap_data = &ams_delta_keymap_data,
  181. .delay = 9,
  182. };
  183. static struct platform_device ams_delta_kp_device = {
  184. .name = "omap-keypad",
  185. .id = -1,
  186. .dev = {
  187. .platform_data = &ams_delta_kp_data,
  188. },
  189. .num_resources = ARRAY_SIZE(ams_delta_kp_resources),
  190. .resource = ams_delta_kp_resources,
  191. };
  192. static struct platform_device ams_delta_lcd_device = {
  193. .name = "lcd_ams_delta",
  194. .id = -1,
  195. };
  196. static struct platform_device ams_delta_led_device = {
  197. .name = "ams-delta-led",
  198. .id = -1
  199. };
  200. static struct i2c_board_info ams_delta_camera_board_info[] = {
  201. {
  202. I2C_BOARD_INFO("ov6650", 0x60),
  203. },
  204. };
  205. #ifdef CONFIG_LEDS_TRIGGERS
  206. DEFINE_LED_TRIGGER(ams_delta_camera_led_trigger);
  207. static int ams_delta_camera_power(struct device *dev, int power)
  208. {
  209. /*
  210. * turn on camera LED
  211. */
  212. if (power)
  213. led_trigger_event(ams_delta_camera_led_trigger, LED_FULL);
  214. else
  215. led_trigger_event(ams_delta_camera_led_trigger, LED_OFF);
  216. return 0;
  217. }
  218. #else
  219. #define ams_delta_camera_power NULL
  220. #endif
  221. static struct soc_camera_link ams_delta_iclink = {
  222. .bus_id = 0, /* OMAP1 SoC camera bus */
  223. .i2c_adapter_id = 1,
  224. .board_info = &ams_delta_camera_board_info[0],
  225. .module_name = "ov6650",
  226. .power = ams_delta_camera_power,
  227. };
  228. static struct platform_device ams_delta_camera_device = {
  229. .name = "soc-camera-pdrv",
  230. .id = 0,
  231. .dev = {
  232. .platform_data = &ams_delta_iclink,
  233. },
  234. };
  235. static struct omap1_cam_platform_data ams_delta_camera_platform_data = {
  236. .camexclk_khz = 12000, /* default 12MHz clock, no extra DPLL */
  237. .lclk_khz_max = 1334, /* results in 5fps CIF, 10fps QCIF */
  238. };
  239. static struct platform_device *ams_delta_devices[] __initdata = {
  240. &ams_delta_nand_device,
  241. &ams_delta_kp_device,
  242. &ams_delta_lcd_device,
  243. &ams_delta_led_device,
  244. &ams_delta_camera_device,
  245. };
  246. static void __init ams_delta_init(void)
  247. {
  248. /* mux pins for uarts */
  249. omap_cfg_reg(UART1_TX);
  250. omap_cfg_reg(UART1_RTS);
  251. /* parallel camera interface */
  252. omap_cfg_reg(H19_1610_CAM_EXCLK);
  253. omap_cfg_reg(J15_1610_CAM_LCLK);
  254. omap_cfg_reg(L18_1610_CAM_VS);
  255. omap_cfg_reg(L15_1610_CAM_HS);
  256. omap_cfg_reg(L19_1610_CAM_D0);
  257. omap_cfg_reg(K14_1610_CAM_D1);
  258. omap_cfg_reg(K15_1610_CAM_D2);
  259. omap_cfg_reg(K19_1610_CAM_D3);
  260. omap_cfg_reg(K18_1610_CAM_D4);
  261. omap_cfg_reg(J14_1610_CAM_D5);
  262. omap_cfg_reg(J19_1610_CAM_D6);
  263. omap_cfg_reg(J18_1610_CAM_D7);
  264. omap_serial_init();
  265. omap_register_i2c_bus(1, 100, NULL, 0);
  266. /* Clear latch2 (NAND, LCD, modem enable) */
  267. ams_delta_latch2_write(~0, 0);
  268. omap1_usb_init(&ams_delta_usb_config);
  269. omap1_set_camera_info(&ams_delta_camera_platform_data);
  270. #ifdef CONFIG_LEDS_TRIGGERS
  271. led_trigger_register_simple("ams_delta_camera",
  272. &ams_delta_camera_led_trigger);
  273. #endif
  274. platform_add_devices(ams_delta_devices, ARRAY_SIZE(ams_delta_devices));
  275. ams_delta_init_fiq();
  276. omap_writew(omap_readw(ARM_RSTCT1) | 0x0004, ARM_RSTCT1);
  277. omapfb_set_lcd_config(&ams_delta_lcd_config);
  278. }
  279. static struct plat_serial8250_port ams_delta_modem_ports[] = {
  280. {
  281. .membase = IOMEM(AMS_DELTA_MODEM_VIRT),
  282. .mapbase = AMS_DELTA_MODEM_PHYS,
  283. .irq = -EINVAL, /* changed later */
  284. .flags = UPF_BOOT_AUTOCONF,
  285. .irqflags = IRQF_TRIGGER_RISING,
  286. .iotype = UPIO_MEM,
  287. .regshift = 1,
  288. .uartclk = BASE_BAUD * 16,
  289. },
  290. { },
  291. };
  292. static struct platform_device ams_delta_modem_device = {
  293. .name = "serial8250",
  294. .id = PLAT8250_DEV_PLATFORM1,
  295. .dev = {
  296. .platform_data = ams_delta_modem_ports,
  297. },
  298. };
  299. static int __init ams_delta_modem_init(void)
  300. {
  301. int err;
  302. if (!machine_is_ams_delta())
  303. return -ENODEV;
  304. omap_cfg_reg(M14_1510_GPIO2);
  305. ams_delta_modem_ports[0].irq =
  306. gpio_to_irq(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
  307. err = gpio_request(AMS_DELTA_GPIO_PIN_MODEM_IRQ, "modem");
  308. if (err) {
  309. pr_err("Couldn't request gpio pin for modem\n");
  310. return err;
  311. }
  312. gpio_direction_input(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
  313. ams_delta_latch2_write(
  314. AMS_DELTA_LATCH2_MODEM_NRESET | AMS_DELTA_LATCH2_MODEM_CODEC,
  315. AMS_DELTA_LATCH2_MODEM_NRESET | AMS_DELTA_LATCH2_MODEM_CODEC);
  316. return platform_device_register(&ams_delta_modem_device);
  317. }
  318. arch_initcall(ams_delta_modem_init);
  319. static void __init ams_delta_map_io(void)
  320. {
  321. omap15xx_map_io();
  322. iotable_init(ams_delta_io_desc, ARRAY_SIZE(ams_delta_io_desc));
  323. }
  324. MACHINE_START(AMS_DELTA, "Amstrad E3 (Delta)")
  325. /* Maintainer: Jonathan McDowell <noodles@earth.li> */
  326. .atag_offset = 0x100,
  327. .map_io = ams_delta_map_io,
  328. .init_early = omap1_init_early,
  329. .reserve = omap_reserve,
  330. .init_irq = omap1_init_irq,
  331. .init_machine = ams_delta_init,
  332. .timer = &omap1_timer,
  333. .restart = omap1_restart,
  334. MACHINE_END
  335. EXPORT_SYMBOL(ams_delta_latch1_write);
  336. EXPORT_SYMBOL(ams_delta_latch2_write);