board-ams-delta.c 9.0 KB

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