board-ams-delta.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  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/driver.h>
  15. #include <linux/gpio/machine.h>
  16. #include <linux/gpio.h>
  17. #include <linux/kernel.h>
  18. #include <linux/init.h>
  19. #include <linux/input.h>
  20. #include <linux/interrupt.h>
  21. #include <linux/leds.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/regulator/consumer.h>
  24. #include <linux/regulator/fixed.h>
  25. #include <linux/regulator/machine.h>
  26. #include <linux/serial_8250.h>
  27. #include <linux/export.h>
  28. #include <linux/omapfb.h>
  29. #include <linux/io.h>
  30. #include <linux/platform_data/gpio-omap.h>
  31. #include <media/soc_camera.h>
  32. #include <asm/serial.h>
  33. #include <asm/mach-types.h>
  34. #include <asm/mach/arch.h>
  35. #include <asm/mach/map.h>
  36. #include <mach/board-ams-delta.h>
  37. #include <linux/platform_data/keypad-omap.h>
  38. #include <mach/mux.h>
  39. #include <mach/hardware.h>
  40. #include <mach/ams-delta-fiq.h>
  41. #include "camera.h"
  42. #include <mach/usb.h>
  43. #include "iomap.h"
  44. #include "common.h"
  45. static const unsigned int ams_delta_keymap[] = {
  46. KEY(0, 0, KEY_F1), /* Advert */
  47. KEY(0, 3, KEY_COFFEE), /* Games */
  48. KEY(0, 2, KEY_QUESTION), /* Directory */
  49. KEY(2, 3, KEY_CONNECT), /* Internet */
  50. KEY(1, 2, KEY_SHOP), /* Services */
  51. KEY(1, 1, KEY_PHONE), /* VoiceMail */
  52. KEY(0, 1, KEY_DELETE), /* Delete */
  53. KEY(2, 2, KEY_PLAY), /* Play */
  54. KEY(1, 0, KEY_PAGEUP), /* Up */
  55. KEY(1, 3, KEY_PAGEDOWN), /* Down */
  56. KEY(2, 0, KEY_EMAIL), /* ReadEmail */
  57. KEY(2, 1, KEY_STOP), /* Stop */
  58. /* Numeric keypad portion */
  59. KEY(0, 7, KEY_KP1),
  60. KEY(0, 6, KEY_KP2),
  61. KEY(0, 5, KEY_KP3),
  62. KEY(1, 7, KEY_KP4),
  63. KEY(1, 6, KEY_KP5),
  64. KEY(1, 5, KEY_KP6),
  65. KEY(2, 7, KEY_KP7),
  66. KEY(2, 6, KEY_KP8),
  67. KEY(2, 5, KEY_KP9),
  68. KEY(3, 6, KEY_KP0),
  69. KEY(3, 7, KEY_KPASTERISK),
  70. KEY(3, 5, KEY_KPDOT), /* # key */
  71. KEY(7, 2, KEY_NUMLOCK), /* Mute */
  72. KEY(7, 1, KEY_KPMINUS), /* Recall */
  73. KEY(6, 1, KEY_KPPLUS), /* Redial */
  74. KEY(7, 6, KEY_KPSLASH), /* Handsfree */
  75. KEY(6, 0, KEY_ENTER), /* Video */
  76. KEY(7, 4, KEY_CAMERA), /* Photo */
  77. KEY(0, 4, KEY_F2), /* Home */
  78. KEY(1, 4, KEY_F3), /* Office */
  79. KEY(2, 4, KEY_F4), /* Mobile */
  80. KEY(7, 7, KEY_F5), /* SMS */
  81. KEY(7, 5, KEY_F6), /* Email */
  82. /* QWERTY portion of keypad */
  83. KEY(3, 4, KEY_Q),
  84. KEY(3, 3, KEY_W),
  85. KEY(3, 2, KEY_E),
  86. KEY(3, 1, KEY_R),
  87. KEY(3, 0, KEY_T),
  88. KEY(4, 7, KEY_Y),
  89. KEY(4, 6, KEY_U),
  90. KEY(4, 5, KEY_I),
  91. KEY(4, 4, KEY_O),
  92. KEY(4, 3, KEY_P),
  93. KEY(4, 2, KEY_A),
  94. KEY(4, 1, KEY_S),
  95. KEY(4, 0, KEY_D),
  96. KEY(5, 7, KEY_F),
  97. KEY(5, 6, KEY_G),
  98. KEY(5, 5, KEY_H),
  99. KEY(5, 4, KEY_J),
  100. KEY(5, 3, KEY_K),
  101. KEY(5, 2, KEY_L),
  102. KEY(5, 1, KEY_Z),
  103. KEY(5, 0, KEY_X),
  104. KEY(6, 7, KEY_C),
  105. KEY(6, 6, KEY_V),
  106. KEY(6, 5, KEY_B),
  107. KEY(6, 4, KEY_N),
  108. KEY(6, 3, KEY_M),
  109. KEY(6, 2, KEY_SPACE),
  110. KEY(7, 0, KEY_LEFTSHIFT), /* Vol up */
  111. KEY(7, 3, KEY_LEFTCTRL), /* Vol down */
  112. };
  113. #define LATCH1_PHYS 0x01000000
  114. #define LATCH1_VIRT 0xEA000000
  115. #define MODEM_PHYS 0x04000000
  116. #define MODEM_VIRT 0xEB000000
  117. #define LATCH2_PHYS 0x08000000
  118. #define LATCH2_VIRT 0xEC000000
  119. static struct map_desc ams_delta_io_desc[] __initdata = {
  120. /* AMS_DELTA_LATCH1 */
  121. {
  122. .virtual = LATCH1_VIRT,
  123. .pfn = __phys_to_pfn(LATCH1_PHYS),
  124. .length = 0x01000000,
  125. .type = MT_DEVICE
  126. },
  127. /* AMS_DELTA_LATCH2 */
  128. {
  129. .virtual = LATCH2_VIRT,
  130. .pfn = __phys_to_pfn(LATCH2_PHYS),
  131. .length = 0x01000000,
  132. .type = MT_DEVICE
  133. },
  134. /* AMS_DELTA_MODEM */
  135. {
  136. .virtual = MODEM_VIRT,
  137. .pfn = __phys_to_pfn(MODEM_PHYS),
  138. .length = 0x01000000,
  139. .type = MT_DEVICE
  140. }
  141. };
  142. static const struct omap_lcd_config ams_delta_lcd_config __initconst = {
  143. .ctrl_name = "internal",
  144. };
  145. static struct omap_usb_config ams_delta_usb_config __initdata = {
  146. .register_host = 1,
  147. .hmc_mode = 16,
  148. .pins[0] = 2,
  149. };
  150. #define LATCH1_GPIO_BASE 232
  151. #define LATCH1_NGPIO 8
  152. static struct resource latch1_resources[] = {
  153. [0] = {
  154. .name = "dat",
  155. .start = LATCH1_PHYS,
  156. .end = LATCH1_PHYS + (LATCH1_NGPIO - 1) / 8,
  157. .flags = IORESOURCE_MEM,
  158. },
  159. };
  160. static struct bgpio_pdata latch1_pdata = {
  161. .base = LATCH1_GPIO_BASE,
  162. .ngpio = LATCH1_NGPIO,
  163. };
  164. static struct platform_device latch1_gpio_device = {
  165. .name = "basic-mmio-gpio",
  166. .id = 0,
  167. .resource = latch1_resources,
  168. .num_resources = ARRAY_SIZE(latch1_resources),
  169. .dev = {
  170. .platform_data = &latch1_pdata,
  171. },
  172. };
  173. static struct resource latch2_resources[] = {
  174. [0] = {
  175. .name = "dat",
  176. .start = LATCH2_PHYS,
  177. .end = LATCH2_PHYS + (AMS_DELTA_LATCH2_NGPIO - 1) / 8,
  178. .flags = IORESOURCE_MEM,
  179. },
  180. };
  181. #define LATCH2_LABEL "latch2"
  182. static struct bgpio_pdata latch2_pdata = {
  183. .label = LATCH2_LABEL,
  184. .base = AMS_DELTA_LATCH2_GPIO_BASE,
  185. .ngpio = AMS_DELTA_LATCH2_NGPIO,
  186. };
  187. static struct platform_device latch2_gpio_device = {
  188. .name = "basic-mmio-gpio",
  189. .id = 1,
  190. .resource = latch2_resources,
  191. .num_resources = ARRAY_SIZE(latch2_resources),
  192. .dev = {
  193. .platform_data = &latch2_pdata,
  194. },
  195. };
  196. #define LATCH2_PIN_LCD_VBLEN 0
  197. #define LATCH2_PIN_LCD_NDISP 1
  198. #define LATCH2_PIN_NAND_NCE 2
  199. #define LATCH2_PIN_NAND_NRE 3
  200. #define LATCH2_PIN_NAND_NWP 4
  201. #define LATCH2_PIN_NAND_NWE 5
  202. #define LATCH2_PIN_NAND_ALE 6
  203. #define LATCH2_PIN_NAND_CLE 7
  204. #define LATCH2_PIN_KEYBRD_PWR 8
  205. #define LATCH2_PIN_KEYBRD_DATAOUT 9
  206. #define LATCH2_PIN_SCARD_RSTIN 10
  207. #define LATCH2_PIN_SCARD_CMDVCC 11
  208. #define LATCH2_PIN_MODEM_NRESET 12
  209. #define LATCH2_PIN_MODEM_CODEC 13
  210. #define LATCH2_PIN_HOOKFLASH1 14
  211. #define LATCH2_PIN_HOOKFLASH2 15
  212. static const struct gpio latch_gpios[] __initconst = {
  213. {
  214. .gpio = LATCH1_GPIO_BASE + 6,
  215. .flags = GPIOF_OUT_INIT_LOW,
  216. .label = "dockit1",
  217. },
  218. {
  219. .gpio = LATCH1_GPIO_BASE + 7,
  220. .flags = GPIOF_OUT_INIT_LOW,
  221. .label = "dockit2",
  222. },
  223. {
  224. .gpio = AMS_DELTA_GPIO_PIN_SCARD_RSTIN,
  225. .flags = GPIOF_OUT_INIT_LOW,
  226. .label = "scard_rstin",
  227. },
  228. {
  229. .gpio = AMS_DELTA_GPIO_PIN_SCARD_CMDVCC,
  230. .flags = GPIOF_OUT_INIT_LOW,
  231. .label = "scard_cmdvcc",
  232. },
  233. {
  234. .gpio = AMS_DELTA_LATCH2_GPIO_BASE + 14,
  235. .flags = GPIOF_OUT_INIT_LOW,
  236. .label = "hookflash1",
  237. },
  238. {
  239. .gpio = AMS_DELTA_LATCH2_GPIO_BASE + 15,
  240. .flags = GPIOF_OUT_INIT_LOW,
  241. .label = "hookflash2",
  242. },
  243. };
  244. static struct regulator_consumer_supply modem_nreset_consumers[] = {
  245. REGULATOR_SUPPLY("RESET#", "serial8250.1"),
  246. REGULATOR_SUPPLY("POR", "cx20442-codec"),
  247. };
  248. static struct regulator_init_data modem_nreset_data = {
  249. .constraints = {
  250. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  251. .boot_on = 1,
  252. },
  253. .num_consumer_supplies = ARRAY_SIZE(modem_nreset_consumers),
  254. .consumer_supplies = modem_nreset_consumers,
  255. };
  256. static struct fixed_voltage_config modem_nreset_config = {
  257. .supply_name = "modem_nreset",
  258. .microvolts = 3300000,
  259. .gpio = AMS_DELTA_GPIO_PIN_MODEM_NRESET,
  260. .startup_delay = 25000,
  261. .enable_high = 1,
  262. .enabled_at_boot = 1,
  263. .init_data = &modem_nreset_data,
  264. };
  265. static struct platform_device modem_nreset_device = {
  266. .name = "reg-fixed-voltage",
  267. .id = -1,
  268. .dev = {
  269. .platform_data = &modem_nreset_config,
  270. },
  271. };
  272. struct modem_private_data {
  273. struct regulator *regulator;
  274. };
  275. static struct modem_private_data modem_priv;
  276. void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value)
  277. {
  278. int bit = 0;
  279. u16 bitpos = 1 << bit;
  280. for (; bit < ngpio; bit++, bitpos = bitpos << 1) {
  281. if (!(mask & bitpos))
  282. continue;
  283. else
  284. gpio_set_value(base + bit, (value & bitpos) != 0);
  285. }
  286. }
  287. EXPORT_SYMBOL(ams_delta_latch_write);
  288. static struct resource ams_delta_nand_resources[] = {
  289. [0] = {
  290. .start = OMAP1_MPUIO_BASE,
  291. .end = OMAP1_MPUIO_BASE +
  292. OMAP_MPUIO_IO_CNTL + sizeof(u32) - 1,
  293. .flags = IORESOURCE_MEM,
  294. },
  295. };
  296. static struct platform_device ams_delta_nand_device = {
  297. .name = "ams-delta-nand",
  298. .id = -1,
  299. .num_resources = ARRAY_SIZE(ams_delta_nand_resources),
  300. .resource = ams_delta_nand_resources,
  301. };
  302. #define OMAP_GPIO_LABEL "gpio-0-15"
  303. static struct gpiod_lookup_table ams_delta_nand_gpio_table = {
  304. .table = {
  305. GPIO_LOOKUP(OMAP_GPIO_LABEL, AMS_DELTA_GPIO_PIN_NAND_RB, "rdy",
  306. 0),
  307. GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NCE, "nce", 0),
  308. GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NRE, "nre", 0),
  309. GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NWP, "nwp", 0),
  310. GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NWE, "nwe", 0),
  311. GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_ALE, "ale", 0),
  312. GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_CLE, "cle", 0),
  313. { },
  314. },
  315. };
  316. static struct resource ams_delta_kp_resources[] = {
  317. [0] = {
  318. .start = INT_KEYBOARD,
  319. .end = INT_KEYBOARD,
  320. .flags = IORESOURCE_IRQ,
  321. },
  322. };
  323. static const struct matrix_keymap_data ams_delta_keymap_data = {
  324. .keymap = ams_delta_keymap,
  325. .keymap_size = ARRAY_SIZE(ams_delta_keymap),
  326. };
  327. static struct omap_kp_platform_data ams_delta_kp_data = {
  328. .rows = 8,
  329. .cols = 8,
  330. .keymap_data = &ams_delta_keymap_data,
  331. .delay = 9,
  332. };
  333. static struct platform_device ams_delta_kp_device = {
  334. .name = "omap-keypad",
  335. .id = -1,
  336. .dev = {
  337. .platform_data = &ams_delta_kp_data,
  338. },
  339. .num_resources = ARRAY_SIZE(ams_delta_kp_resources),
  340. .resource = ams_delta_kp_resources,
  341. };
  342. static struct platform_device ams_delta_lcd_device = {
  343. .name = "lcd_ams_delta",
  344. .id = -1,
  345. };
  346. static struct gpiod_lookup_table ams_delta_lcd_gpio_table = {
  347. .table = {
  348. GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_LCD_VBLEN, "vblen", 0),
  349. GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_LCD_NDISP, "ndisp", 0),
  350. { },
  351. },
  352. };
  353. static const struct gpio_led gpio_leds[] __initconst = {
  354. {
  355. .name = "camera",
  356. .gpio = LATCH1_GPIO_BASE + 0,
  357. .default_state = LEDS_GPIO_DEFSTATE_OFF,
  358. #ifdef CONFIG_LEDS_TRIGGERS
  359. .default_trigger = "ams_delta_camera",
  360. #endif
  361. },
  362. {
  363. .name = "advert",
  364. .gpio = LATCH1_GPIO_BASE + 1,
  365. .default_state = LEDS_GPIO_DEFSTATE_OFF,
  366. },
  367. {
  368. .name = "email",
  369. .gpio = LATCH1_GPIO_BASE + 2,
  370. .default_state = LEDS_GPIO_DEFSTATE_OFF,
  371. },
  372. {
  373. .name = "handsfree",
  374. .gpio = LATCH1_GPIO_BASE + 3,
  375. .default_state = LEDS_GPIO_DEFSTATE_OFF,
  376. },
  377. {
  378. .name = "voicemail",
  379. .gpio = LATCH1_GPIO_BASE + 4,
  380. .default_state = LEDS_GPIO_DEFSTATE_OFF,
  381. },
  382. {
  383. .name = "voice",
  384. .gpio = LATCH1_GPIO_BASE + 5,
  385. .default_state = LEDS_GPIO_DEFSTATE_OFF,
  386. },
  387. };
  388. static const struct gpio_led_platform_data leds_pdata __initconst = {
  389. .leds = gpio_leds,
  390. .num_leds = ARRAY_SIZE(gpio_leds),
  391. };
  392. static struct i2c_board_info ams_delta_camera_board_info[] = {
  393. {
  394. I2C_BOARD_INFO("ov6650", 0x60),
  395. },
  396. };
  397. #ifdef CONFIG_LEDS_TRIGGERS
  398. DEFINE_LED_TRIGGER(ams_delta_camera_led_trigger);
  399. static int ams_delta_camera_power(struct device *dev, int power)
  400. {
  401. /*
  402. * turn on camera LED
  403. */
  404. if (power)
  405. led_trigger_event(ams_delta_camera_led_trigger, LED_FULL);
  406. else
  407. led_trigger_event(ams_delta_camera_led_trigger, LED_OFF);
  408. return 0;
  409. }
  410. #else
  411. #define ams_delta_camera_power NULL
  412. #endif
  413. static struct soc_camera_link ams_delta_iclink = {
  414. .bus_id = 0, /* OMAP1 SoC camera bus */
  415. .i2c_adapter_id = 1,
  416. .board_info = &ams_delta_camera_board_info[0],
  417. .module_name = "ov6650",
  418. .power = ams_delta_camera_power,
  419. };
  420. static struct platform_device ams_delta_camera_device = {
  421. .name = "soc-camera-pdrv",
  422. .id = 0,
  423. .dev = {
  424. .platform_data = &ams_delta_iclink,
  425. },
  426. };
  427. static struct omap1_cam_platform_data ams_delta_camera_platform_data = {
  428. .camexclk_khz = 12000, /* default 12MHz clock, no extra DPLL */
  429. .lclk_khz_max = 1334, /* results in 5fps CIF, 10fps QCIF */
  430. };
  431. static struct platform_device ams_delta_audio_device = {
  432. .name = "ams-delta-audio",
  433. .id = -1,
  434. };
  435. static struct gpiod_lookup_table ams_delta_audio_gpio_table = {
  436. .table = {
  437. GPIO_LOOKUP(OMAP_GPIO_LABEL, AMS_DELTA_GPIO_PIN_HOOK_SWITCH,
  438. "hook_switch", 0),
  439. GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_MODEM_CODEC,
  440. "modem_codec", 0),
  441. { },
  442. },
  443. };
  444. static struct platform_device cx20442_codec_device = {
  445. .name = "cx20442-codec",
  446. .id = -1,
  447. };
  448. static struct gpiod_lookup_table ams_delta_serio_gpio_table = {
  449. .table = {
  450. GPIO_LOOKUP(OMAP_GPIO_LABEL, AMS_DELTA_GPIO_PIN_KEYBRD_DATA,
  451. "data", 0),
  452. GPIO_LOOKUP(OMAP_GPIO_LABEL, AMS_DELTA_GPIO_PIN_KEYBRD_CLK,
  453. "clock", 0),
  454. GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_KEYBRD_PWR,
  455. "power", 0),
  456. GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_KEYBRD_DATAOUT,
  457. "dataout", 0),
  458. { },
  459. },
  460. };
  461. static struct platform_device *ams_delta_devices[] __initdata = {
  462. &latch1_gpio_device,
  463. &latch2_gpio_device,
  464. &ams_delta_kp_device,
  465. &ams_delta_camera_device,
  466. &ams_delta_audio_device,
  467. };
  468. static struct platform_device *late_devices[] __initdata = {
  469. &ams_delta_nand_device,
  470. &ams_delta_lcd_device,
  471. &cx20442_codec_device,
  472. };
  473. static struct gpiod_lookup_table *ams_delta_gpio_tables[] __initdata = {
  474. &ams_delta_audio_gpio_table,
  475. &ams_delta_serio_gpio_table,
  476. };
  477. static struct gpiod_lookup_table *late_gpio_tables[] __initdata = {
  478. &ams_delta_lcd_gpio_table,
  479. &ams_delta_nand_gpio_table,
  480. };
  481. static void __init ams_delta_init(void)
  482. {
  483. /* mux pins for uarts */
  484. omap_cfg_reg(UART1_TX);
  485. omap_cfg_reg(UART1_RTS);
  486. /* parallel camera interface */
  487. omap_cfg_reg(H19_1610_CAM_EXCLK);
  488. omap_cfg_reg(J15_1610_CAM_LCLK);
  489. omap_cfg_reg(L18_1610_CAM_VS);
  490. omap_cfg_reg(L15_1610_CAM_HS);
  491. omap_cfg_reg(L19_1610_CAM_D0);
  492. omap_cfg_reg(K14_1610_CAM_D1);
  493. omap_cfg_reg(K15_1610_CAM_D2);
  494. omap_cfg_reg(K19_1610_CAM_D3);
  495. omap_cfg_reg(K18_1610_CAM_D4);
  496. omap_cfg_reg(J14_1610_CAM_D5);
  497. omap_cfg_reg(J19_1610_CAM_D6);
  498. omap_cfg_reg(J18_1610_CAM_D7);
  499. omap_serial_init();
  500. omap_register_i2c_bus(1, 100, NULL, 0);
  501. omap1_usb_init(&ams_delta_usb_config);
  502. omap1_set_camera_info(&ams_delta_camera_platform_data);
  503. #ifdef CONFIG_LEDS_TRIGGERS
  504. led_trigger_register_simple("ams_delta_camera",
  505. &ams_delta_camera_led_trigger);
  506. #endif
  507. gpio_led_register_device(-1, &leds_pdata);
  508. platform_add_devices(ams_delta_devices, ARRAY_SIZE(ams_delta_devices));
  509. /*
  510. * As soon as devices have been registered, assign their dev_names
  511. * to respective GPIO lookup tables before they are added.
  512. */
  513. ams_delta_audio_gpio_table.dev_id =
  514. dev_name(&ams_delta_audio_device.dev);
  515. /*
  516. * No device name is assigned to GPIO lookup table for serio device
  517. * as long as serio driver is not converted to platform device driver.
  518. */
  519. gpiod_add_lookup_tables(ams_delta_gpio_tables,
  520. ARRAY_SIZE(ams_delta_gpio_tables));
  521. ams_delta_init_fiq();
  522. omap_writew(omap_readw(ARM_RSTCT1) | 0x0004, ARM_RSTCT1);
  523. omapfb_set_lcd_config(&ams_delta_lcd_config);
  524. }
  525. static void modem_pm(struct uart_port *port, unsigned int state, unsigned old)
  526. {
  527. struct modem_private_data *priv = port->private_data;
  528. int ret;
  529. if (IS_ERR(priv->regulator))
  530. return;
  531. if (state == old)
  532. return;
  533. if (state == 0)
  534. ret = regulator_enable(priv->regulator);
  535. else if (old == 0)
  536. ret = regulator_disable(priv->regulator);
  537. else
  538. ret = 0;
  539. if (ret)
  540. dev_warn(port->dev,
  541. "ams_delta modem_pm: failed to %sable regulator: %d\n",
  542. state ? "dis" : "en", ret);
  543. }
  544. static struct plat_serial8250_port ams_delta_modem_ports[] = {
  545. {
  546. .membase = IOMEM(MODEM_VIRT),
  547. .mapbase = MODEM_PHYS,
  548. .irq = -EINVAL, /* changed later */
  549. .flags = UPF_BOOT_AUTOCONF,
  550. .irqflags = IRQF_TRIGGER_RISING,
  551. .iotype = UPIO_MEM,
  552. .regshift = 1,
  553. .uartclk = BASE_BAUD * 16,
  554. .pm = modem_pm,
  555. .private_data = &modem_priv,
  556. },
  557. { },
  558. };
  559. static struct platform_device ams_delta_modem_device = {
  560. .name = "serial8250",
  561. .id = PLAT8250_DEV_PLATFORM1,
  562. .dev = {
  563. .platform_data = ams_delta_modem_ports,
  564. },
  565. };
  566. static int __init late_init(void)
  567. {
  568. int err;
  569. if (!machine_is_ams_delta())
  570. return -ENODEV;
  571. err = gpio_request_array(latch_gpios, ARRAY_SIZE(latch_gpios));
  572. if (err) {
  573. pr_err("Couldn't take over latch1/latch2 GPIO pins\n");
  574. return err;
  575. }
  576. platform_add_devices(late_devices, ARRAY_SIZE(late_devices));
  577. /*
  578. * As soon as devices have been registered, assign their dev_names
  579. * to respective GPIO lookup tables before they are added.
  580. */
  581. ams_delta_lcd_gpio_table.dev_id = dev_name(&ams_delta_lcd_device.dev);
  582. ams_delta_nand_gpio_table.dev_id = dev_name(&ams_delta_nand_device.dev);
  583. gpiod_add_lookup_tables(late_gpio_tables, ARRAY_SIZE(late_gpio_tables));
  584. err = platform_device_register(&modem_nreset_device);
  585. if (err) {
  586. pr_err("Couldn't register the modem regulator device\n");
  587. return err;
  588. }
  589. omap_cfg_reg(M14_1510_GPIO2);
  590. ams_delta_modem_ports[0].irq =
  591. gpio_to_irq(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
  592. err = gpio_request(AMS_DELTA_GPIO_PIN_MODEM_IRQ, "modem");
  593. if (err) {
  594. pr_err("Couldn't request gpio pin for modem\n");
  595. return err;
  596. }
  597. gpio_direction_input(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
  598. /* Initialize the modem_nreset regulator consumer before use */
  599. modem_priv.regulator = ERR_PTR(-ENODEV);
  600. ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC,
  601. AMS_DELTA_LATCH2_MODEM_CODEC);
  602. err = platform_device_register(&ams_delta_modem_device);
  603. if (err)
  604. goto gpio_free;
  605. /*
  606. * Once the modem device is registered, the modem_nreset
  607. * regulator can be requested on behalf of that device.
  608. */
  609. modem_priv.regulator = regulator_get(&ams_delta_modem_device.dev,
  610. "RESET#");
  611. if (IS_ERR(modem_priv.regulator)) {
  612. err = PTR_ERR(modem_priv.regulator);
  613. goto unregister;
  614. }
  615. return 0;
  616. unregister:
  617. platform_device_unregister(&ams_delta_modem_device);
  618. gpio_free:
  619. gpio_free(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
  620. return err;
  621. }
  622. static void __init ams_delta_init_late(void)
  623. {
  624. omap1_init_late();
  625. late_init();
  626. }
  627. static void __init ams_delta_map_io(void)
  628. {
  629. omap15xx_map_io();
  630. iotable_init(ams_delta_io_desc, ARRAY_SIZE(ams_delta_io_desc));
  631. }
  632. MACHINE_START(AMS_DELTA, "Amstrad E3 (Delta)")
  633. /* Maintainer: Jonathan McDowell <noodles@earth.li> */
  634. .atag_offset = 0x100,
  635. .map_io = ams_delta_map_io,
  636. .init_early = omap1_init_early,
  637. .init_irq = omap1_init_irq,
  638. .handle_irq = omap1_handle_irq,
  639. .init_machine = ams_delta_init,
  640. .init_late = ams_delta_init_late,
  641. .init_time = omap1_timer_init,
  642. .restart = omap1_restart,
  643. MACHINE_END