Advertisement
Guest User

Untitled

a guest
Jan 12th, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 69.49 KB | None | 0 0
  1. /*
  2. * Board support file for Nokia RM-680/696.
  3. *
  4. * Copyright (C) 2010 Nokia
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10.  
  11. #include <linux/io.h>
  12. #include <linux/i2c.h>
  13. #include <linux/gpio.h>
  14. #include <plat/mux.h>
  15. #include <linux/init.h>
  16. #include <linux/i2c.h>
  17. #include <linux/i2c/twl.h>
  18. #include <linux/input/atmel_mxt.h>
  19. #include <linux/input/eci.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/omapfb.h>
  22. #include <linux/opp.h>
  23. #include <linux/regulator/fixed.h>
  24. #include <linux/regulator/machine.h>
  25. #include <linux/regulator/consumer.h>
  26. #include <linux/wl12xx.h>
  27. #include <linux/spi/spi.h>
  28. #include <linux/spi/vibra.h>
  29. #include <linux/cpu.h>
  30. #include <linux/opp.h>
  31. #include <linux/hsi/hsi.h>
  32. #include <linux/cmt.h>
  33. #include <linux/lis3lv02d.h>
  34. #include <linux/leds-lp5521.h>
  35. #include <linux/usb/musb.h>
  36. #include <linux/mfd/wl1273-core.h>
  37. #include <linux/mfd/aci.h>
  38. #include <sound/tpa6130a2-plat.h>
  39. #include <sound/tlv320dac33-plat.h>
  40. #include <linux/i2c/apds990x.h>
  41. #include <linux/i2c/ak8975.h> //RM696
  42. #include <linux/nfc/pn544.h> //RM696
  43. #include <linux/i2c/bcm4751-gps.h>
  44.  
  45. #include <asm/mach/arch.h>
  46. #include <asm/mach-types.h>
  47. #include <asm/system_info.h>
  48.  
  49. #include <plat/i2c.h>
  50. #include <plat/mmc.h>
  51. #include <plat/usb.h>
  52. #include <plat/gpmc.h>
  53. #include "common.h"
  54. #include <plat/onenand.h>
  55. #include <plat/display.h>
  56. #include <plat/panel-nokia-dsi.h>
  57. #include <plat/vram.h>
  58. #include <plat/board-nokia.h>
  59. #include <plat/omap-pm.h>
  60.  
  61. #include <linux/pvr.h>
  62. #include <linux/printk.h>
  63. #include <plat/mcspi.h>
  64. #include <plat/omap_device.h>
  65. #include <plat/ssi.h>
  66.  
  67. #include "mux.h"
  68. #include "hsmmc.h"
  69. #include "sdram-nokia.h"
  70. #include "common-board-devices.h"
  71. #include "atmel_mxt_config.h"
  72. #include "pm.h"
  73.  
  74. #include "dss.h"
  75.  
  76. #if defined(CONFIG_SND_OMAP_SOC_DFL61_TWL4030) || \
  77. defined(CONFIG_SND_OMAP_SOC_DFL61_TWL4030_MODULE)
  78. #include <plat/dfl61-audio.h>
  79. #include <linux/mfd/twl4030-audio.h>
  80. #endif
  81.  
  82. #include <media/v4l2-subdev.h>
  83. #include "../../../drivers/media/video/omap3isp/isp.h"
  84. #include "../../../drivers/media/video/omap3isp/ispreg.h"
  85. #include "../../../drivers/media/video/omap3isp/ispcsi2.h"
  86. #include <media/smiapp.h>
  87. #include <plat/control.h>
  88. #include <media/ad58xx.h>
  89. #include <media/as3645a.h> /* Senna Flash driver */
  90. #include "devices.h"
  91.  
  92. #define ATMEL_MXT_IRQ_GPIO 61
  93. #define ATMEL_MXT_RESET_GPIO 81
  94.  
  95. #define LIS302_IRQ1_GPIO 180
  96. #define LIS302_IRQ2_GPIO 181
  97. #define RM696_FM_RESET_GPIO1 179
  98. #define RM696_FM_RESET_GPIO2 178
  99. #define RM696_FMRX_IRQ_GPIO 43
  100.  
  101. #define NFC_HOST_INT_GPIO 76
  102. #define NFC_ENABLE_GPIO 77
  103. #define NFC_FW_RESET_GPIO 78
  104.  
  105. #define RM696_DAC33_RESET_GPIO 60
  106. #define RM696_DAC33_IRQ_GPIO 53
  107.  
  108. #define RM696_VIBRA_POWER_GPIO 182
  109. #define RM696_VIBRA_POWER_UP_TIME 1000 /* usecs */
  110.  
  111. #define RM696_TVOUT_EN_GPIO 40
  112. #define RM696_JACK_GPIO (OMAP_MAX_GPIO_LINES + 0)
  113.  
  114. #define RM696_LP5521_CHIP_EN_GPIO 41 //RM696
  115. #define RM680_LP5523_CHIP_EN_GPIO 41 //RM680
  116.  
  117. #define APDS990X_GPIO 83 //RM696
  118. #define BHSFH_GPIO 83 //RM680
  119.  
  120. #define RM696_BCM4751_GPS_IRQ_GPIO 95
  121. #define RM696_BCM4751_GPS_ENABLE_GPIO 94
  122. #define RM696_BCM4751_GPS_WAKEUP_GPIO 91
  123.  
  124. #define SEC_CAMERA_RESET_GPIO 97
  125.  
  126. #define RM696_PRI_SENSOR 1
  127. #define RM696_PRI_LENS 2
  128. #define RM696_SEC_SENSOR 3
  129. #define MAIN_CAMERA_XCLK ISP_XCLK_A
  130. #define SEC_CAMERA_XCLK ISP_XCLK_B
  131.  
  132. static uint32_t rm696_keymap[] = {
  133. /* row, col, event */
  134. KEY(6, 8, KEY_VOLUMEUP),
  135. KEY(7, 8, KEY_VOLUMEDOWN),
  136. };
  137.  
  138. static struct matrix_keymap_data rm696_keymap_data = {
  139. .keymap = rm696_keymap,
  140. .keymap_size = ARRAY_SIZE(rm696_keymap),
  141. };
  142.  
  143. static struct twl4030_keypad_data rm696_kp_data = {
  144. .keymap_data = &rm696_keymap_data,
  145. .rows = 8, /* Two last rows are used */
  146. .cols = 8,
  147. .rep = 1,
  148. };
  149.  
  150. /* CMT init data */
  151. static struct cmt_platform_data rm696_cmt_pdata = {
  152. .cmt_rst_ind_gpio = 34,
  153. .cmt_rst_ind_flags = IRQF_TRIGGER_RISING,
  154. };
  155.  
  156. static struct platform_device rm696_cmt_device = {
  157. .name = "cmt",
  158. .id = -1,
  159. .dev = {
  160. .platform_data = &rm696_cmt_pdata,
  161. },
  162. };
  163.  
  164. static struct eci_platform_data rm696_eci_platform_data = {
  165. #if defined(CONFIG_SND_OMAP_SOC_DFL61_TWL4030) || \
  166. defined(CONFIG_SND_OMAP_SOC_DFL61_TWL4030_MODULE)
  167. .register_hsmic_event_cb = dfl61_register_hsmic_event_cb,
  168. .jack_report = dfl61_jack_report,
  169. #endif
  170. };
  171.  
  172. static struct platform_device rm696_eci_device = {
  173. .name = "ECI_accessory",
  174. .dev = {
  175. .platform_data = &rm696_eci_platform_data,
  176. },
  177. };
  178.  
  179. /* SSI init data */
  180. static struct omap_ssi_port_config __initdata rm696_ssi_port_config[] = {
  181. [0] = {
  182. .cawake_gpio = 151,
  183. .ready_rx_gpio = 154,
  184. },
  185. };
  186.  
  187. static struct omap_ssi_board_config __initdata rm696_ssi_config = {
  188. .num_ports = ARRAY_SIZE(rm696_ssi_port_config),
  189. .port_config = rm696_ssi_port_config,
  190. };
  191.  
  192. static struct hsi_board_info __initdata rm696_ssi_cl[] = {
  193. [0] = {
  194. .name = "hsi_char",
  195. .hsi_id = 0,
  196. .port = 0,
  197. },
  198. [1] = {
  199. .name = "ssi_protocol",
  200. .hsi_id = 0,
  201. .port = 0,
  202. .tx_cfg = {
  203. .mode = HSI_MODE_FRAME,
  204. .channels = 4,
  205. .speed = 96000,
  206. .arb_mode = HSI_ARB_RR,
  207. },
  208. .rx_cfg = {
  209. .mode = HSI_MODE_FRAME,
  210. .channels = 4,
  211. },
  212. },
  213. [2] = {
  214. .name = "cmt_speech",
  215. .hsi_id = 0,
  216. .port = 0,
  217. },
  218.  
  219. };
  220.  
  221. static void __init rm696_ssi_init(void)
  222. {
  223. omap_ssi_config(&rm696_ssi_config);
  224. hsi_register_board_info(rm696_ssi_cl, ARRAY_SIZE(rm696_ssi_cl));
  225. }
  226.  
  227. /* CPU table initialization */
  228. static int __init rm696_opp_init(void)
  229. {
  230. int r = 0;
  231. struct device *mpu_dev, *iva_dev;
  232.  
  233. r = omap3_opp_init();
  234. if (IS_ERR_VALUE(r) && (r != -EEXIST)) {
  235. pr_err("opp default init failed\n");
  236. return r;
  237. }
  238.  
  239. mpu_dev = omap_device_get_by_hwmod_name("mpu");
  240. iva_dev = omap_device_get_by_hwmod_name("iva");
  241. if (IS_ERR(mpu_dev) || IS_ERR(iva_dev)) {
  242. pr_err("no mpu_dev/iva_dev error\n");
  243. return -ENODEV;
  244. }
  245.  
  246. /* Enable MPU 800MHz and lower opps */
  247. r = opp_enable(mpu_dev, 800000000);
  248. if (r)
  249. pr_err("failed to enable higher (800MHz) opp\n");
  250.  
  251. /* Enable MPU 1GHz and lower opps */
  252. r = opp_enable(mpu_dev, 1000000000);
  253. if (r)
  254. pr_err("failed to enable higher (1GHz) opp\n");
  255.  
  256. r = opp_enable(iva_dev, 660000000);
  257. if (r)
  258. pr_err("failed to enable higher (660MHz) opp on DSP\n");
  259.  
  260. r = opp_enable(iva_dev, 800000000);
  261. if (r)
  262. pr_err("failed to enable higher (800MHz) opp on DSP\n");
  263.  
  264. return 0;
  265. }
  266. device_initcall(rm696_opp_init);
  267.  
  268.  
  269. /* WL1271 SDIO/SPI */
  270. #define RM696_WL1271_POWER_GPIO 35
  271. #define RM696_WL1271_IRQ_GPIO 42
  272. #define RM696_WL1271_REF_CLOCK 2
  273.  
  274. static void rm696_wl1271_set_power(bool enable)
  275. {
  276. gpio_set_value(RM696_WL1271_POWER_GPIO, enable);
  277. }
  278.  
  279. static struct wl12xx_platform_data wl1271_pdata = {
  280. .set_power = rm696_wl1271_set_power,
  281. .board_ref_clock = RM696_WL1271_REF_CLOCK,
  282. };
  283.  
  284. static inline bool board_is_rm680(void)
  285. {
  286. return (system_rev & 0x00f0) == 0x0020;
  287. }
  288.  
  289. static bool board_has_sdio_wlan(void)
  290. {
  291. /* RM-696 - N950 using SPI */
  292. if (board_is_rm680())
  293. return false;
  294.  
  295. return system_rev > 0x0301;
  296. }
  297.  
  298. /* SPI for wl1271 */
  299. static struct omap2_mcspi_device_config wl1271_mcspi_config = {
  300. .turbo_mode = 1,
  301. };
  302.  
  303. static struct spi_board_info rm696_peripherals_spi_board_info[] = {
  304. [0] = {
  305. .modalias = "wl1271_spi",
  306. .bus_num = 4,
  307. .chip_select = 0,
  308. .max_speed_hz = 48000000,
  309. .mode = SPI_MODE_0,
  310. .controller_data = &wl1271_mcspi_config,
  311. .platform_data = &wl1271_pdata,
  312. },
  313. };
  314.  
  315. /* SDIO fixed regulator for WLAN */
  316. static struct regulator_consumer_supply rm696_vsdio_consumers[] = {
  317. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.2"),
  318. };
  319.  
  320. static struct regulator_init_data rm696_vsdio_data = {
  321. .constraints = {
  322. .valid_ops_mask = REGULATOR_CHANGE_STATUS
  323. | REGULATOR_CHANGE_MODE,
  324. },
  325. .num_consumer_supplies = ARRAY_SIZE(rm696_vsdio_consumers),
  326. .consumer_supplies = rm696_vsdio_consumers,
  327. };
  328.  
  329. static struct fixed_voltage_config rm696_vsdio_config = {
  330. .supply_name = "vwl1271",
  331. .microvolts = 1800000,
  332. .gpio = RM696_WL1271_POWER_GPIO,
  333. .startup_delay = 1000,
  334. .enable_high = 1,
  335. .enabled_at_boot = 0,
  336. .init_data = &rm696_vsdio_data,
  337. };
  338.  
  339. static struct platform_device rm696_vsdio_device = {
  340. .name = "reg-fixed-voltage",
  341. .id = 1,
  342. .dev = {
  343. .platform_data = &rm696_vsdio_config,
  344. },
  345. };
  346.  
  347.  
  348. /* Fixed regulator for internal eMMC */
  349. static struct regulator_consumer_supply rm680_vemmc_consumers[] = {
  350. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1"),
  351. };
  352.  
  353. static struct regulator_init_data rm680_vemmc = {
  354. .constraints = {
  355. .name = "rm680_vemmc",
  356. .valid_modes_mask = REGULATOR_MODE_NORMAL
  357. | REGULATOR_MODE_STANDBY,
  358. .valid_ops_mask = REGULATOR_CHANGE_STATUS
  359. | REGULATOR_CHANGE_MODE,
  360. },
  361. .num_consumer_supplies = ARRAY_SIZE(rm680_vemmc_consumers),
  362. .consumer_supplies = rm680_vemmc_consumers,
  363. };
  364.  
  365. static struct fixed_voltage_config rm680_vemmc_config = {
  366. .supply_name = "VEMMC",
  367. .microvolts = 2900000,
  368. .gpio = 157,
  369. .startup_delay = 150,
  370. .enable_high = 1,
  371. .init_data = &rm680_vemmc,
  372. };
  373.  
  374. static struct platform_device rm680_vemmc_device = {
  375. .name = "reg-fixed-voltage",
  376. .dev = {
  377. .platform_data = &rm680_vemmc_config,
  378. },
  379. };
  380.  
  381. static void __init rm680_init_wl1271(void)
  382. {
  383. int irq, ret;
  384.  
  385. if (board_has_sdio_wlan()) {
  386. pr_info("wl1271 SDIO\n");
  387. platform_device_register(&rm696_vsdio_device);
  388.  
  389. ret = gpio_request(RM696_WL1271_IRQ_GPIO, "wl1271 irq");
  390. if (ret < 0)
  391. goto sdio_err;
  392.  
  393. ret = gpio_direction_input(RM696_WL1271_IRQ_GPIO);
  394. if (ret < 0)
  395. goto sdio_err_irq;
  396.  
  397. irq = gpio_to_irq(RM696_WL1271_IRQ_GPIO);
  398. if (ret < 0)
  399. goto sdio_err_irq;
  400.  
  401. wl1271_pdata.irq = irq;
  402. wl12xx_set_platform_data(&wl1271_pdata);
  403.  
  404. /* Set high power gpio - mmc3 need to be detected.
  405. Next wl12xx driver will set this low */
  406. rm696_wl1271_set_power(true);
  407.  
  408. omap_mux_init_signal("sdmmc2_dat4.sdmmc3_dat0",
  409. OMAP_PIN_INPUT_PULLUP);
  410. omap_mux_init_signal("sdmmc2_dat5.sdmmc3_dat1",
  411. OMAP_PIN_INPUT_PULLUP);
  412. omap_mux_init_signal("sdmmc2_dat6.sdmmc3_dat2",
  413. OMAP_PIN_INPUT_PULLUP);
  414. omap_mux_init_signal("sdmmc2_dat7.sdmmc3_dat3",
  415. OMAP_PIN_INPUT_PULLUP);
  416.  
  417. return;
  418. sdio_err:
  419. gpio_free(RM696_WL1271_IRQ_GPIO);
  420. sdio_err_irq:
  421. pr_err("wl1271 sdio board initialisation failed\n");
  422. wl1271_pdata.set_power = NULL;
  423. } else {
  424. pr_info("wl1271 SPI\n");
  425.  
  426. ret = gpio_request(RM696_WL1271_POWER_GPIO, "wl1271 power");
  427. if (ret < 0)
  428. goto spi_err;
  429.  
  430. ret = gpio_direction_output(RM696_WL1271_POWER_GPIO, 0);
  431. if (ret < 0)
  432. goto spi_err_power;
  433.  
  434. ret = gpio_request(RM696_WL1271_IRQ_GPIO, "wl1271 irq");
  435. if (ret < 0)
  436. goto spi_err_power;
  437.  
  438. ret = gpio_direction_input(RM696_WL1271_IRQ_GPIO);
  439. if (ret < 0)
  440. goto spi_err_irq;
  441.  
  442. irq = gpio_to_irq(RM696_WL1271_IRQ_GPIO);
  443. if (irq < 0)
  444. goto spi_err_irq;
  445.  
  446. rm696_peripherals_spi_board_info[0].irq = irq;
  447.  
  448. spi_register_board_info(rm696_peripherals_spi_board_info,
  449. ARRAY_SIZE(rm696_peripherals_spi_board_info));
  450.  
  451. return;
  452. spi_err_irq:
  453. gpio_free(RM696_WL1271_IRQ_GPIO);
  454. spi_err_power:
  455. gpio_free(RM696_WL1271_POWER_GPIO);
  456. spi_err:
  457. pr_err("wl1271 spi board initialisation failed\n");
  458. wl1271_pdata.set_power = NULL;
  459.  
  460. }
  461. }
  462.  
  463. /* GPIO0 AvPlugDet */
  464. #define TWL_GPIOS_HIGH BIT(0)
  465. #define TWL_GPIOS_LOW (BIT(2) | BIT(6) | BIT(8) | BIT(13) | BIT(15))
  466.  
  467. static int twlgpio_setup(struct device *dev, unsigned gpio, unsigned n)
  468. {
  469. int err;
  470.  
  471. err = gpio_request(gpio + 1, "TMP303_SOH");
  472. if (err) {
  473. printk(KERN_ERR "twl4030_gpio: gpio request failed\n");
  474. goto out;
  475. }
  476.  
  477. err = gpio_direction_output(gpio + 1, 0);
  478. if (err)
  479. printk(KERN_ERR "twl4030_gpio: set gpio direction failed\n");
  480.  
  481. out:
  482. return 0;
  483. }
  484.  
  485. static int twlgpio_teardown(struct device *dev, unsigned gpio, unsigned n)
  486. {
  487. gpio_free(gpio + 1);
  488. return 0;
  489. }
  490.  
  491. /* TWL */
  492. static struct twl4030_gpio_platform_data rm680_gpio_data = {
  493. .gpio_base = OMAP_MAX_GPIO_LINES,
  494. .irq_base = TWL4030_GPIO_IRQ_BASE,
  495. .irq_end = TWL4030_GPIO_IRQ_END,
  496. .pullups = TWL_GPIOS_HIGH,
  497. .pulldowns = TWL_GPIOS_LOW,
  498. .setup = twlgpio_setup,
  499. .teardown = twlgpio_teardown,
  500. };
  501.  
  502. static struct twl4030_codec_data rm680_codec_data;
  503.  
  504. static struct twl4030_audio_data rm680_audio_data = {
  505. .audio_mclk = 38400000,
  506. .codec = &rm680_codec_data,
  507. /*FIXME: vibra*/
  508. };
  509.  
  510. static struct regulator_consumer_supply rm696_vio_consumers[] = {
  511. REGULATOR_SUPPLY("DVDD", "2-0019"), /* TLV320DAC33 */
  512. REGULATOR_SUPPLY("IOVDD", "2-0019"), /* TLV320DAC33 */
  513. REGULATOR_SUPPLY("VDDI", "display0"), /* Himalaya */
  514. REGULATOR_SUPPLY("Vdd", "2-004b"), /* Atmel mxt */
  515. REGULATOR_SUPPLY("vonenand", "omap2-onenand"), /* OneNAND flash */
  516. REGULATOR_SUPPLY("Vdd_IO", "3-001d"), /* LIS302 */
  517. REGULATOR_SUPPLY("DVdd", "3-000f"), /* AK8975 on RM696, AK8974 on RM680 */
  518. REGULATOR_SUPPLY("Vdd_IO", "3-002b"), /* PN544 */
  519. REGULATOR_SUPPLY("vmmc_aux", "mmci-omap-hs.1"),
  520. REGULATOR_SUPPLY("Vbat", "3-a1fa"), /* BCM4751_GPS */
  521. REGULATOR_SUPPLY("Vddio", "3-a1fa"), /* BCM4751_GPS */
  522. };
  523.  
  524. static struct regulator_init_data rm696_vio_data = {
  525. .constraints = {
  526. .name = "rm696_vio",
  527. .min_uV = 1800000,
  528. .max_uV = 1800000,
  529. .apply_uV = true,
  530. .valid_modes_mask = REGULATOR_MODE_NORMAL
  531. | REGULATOR_MODE_STANDBY,
  532. .valid_ops_mask = REGULATOR_CHANGE_STATUS
  533. | REGULATOR_CHANGE_MODE,
  534. },
  535. .num_consumer_supplies = ARRAY_SIZE(rm696_vio_consumers),
  536. .consumer_supplies = rm696_vio_consumers,
  537. };
  538.  
  539. static struct regulator_consumer_supply rm696_vsim_consumers[] = {
  540. REGULATOR_SUPPLY("VSim", "3-002b"), /* PN544 */
  541. };
  542.  
  543. static struct regulator_init_data rm696_vsim_data = {
  544. .constraints = {
  545. .name = "rm696_vsim",
  546. .min_uV = 1800000,
  547. .max_uV = 1800000,
  548. .apply_uV = true,
  549. .valid_modes_mask = REGULATOR_MODE_NORMAL
  550. | REGULATOR_MODE_STANDBY,
  551. .valid_ops_mask = REGULATOR_CHANGE_STATUS
  552. | REGULATOR_CHANGE_MODE,
  553. },
  554. .num_consumer_supplies = ARRAY_SIZE(rm696_vsim_consumers),
  555. .consumer_supplies = rm696_vsim_consumers,
  556. };
  557.  
  558. static struct regulator_consumer_supply rm696_vbat_consumers[] = {
  559. REGULATOR_SUPPLY("Vled", "2-0039"), /* APDS990x */
  560. REGULATOR_SUPPLY("AVdd", "2-0060"), /* TPA6140A2 */
  561. REGULATOR_SUPPLY("VBat", "3-002b"), /* PN544 */
  562. };
  563.  
  564. static struct regulator_init_data rm696_vbat_data = {
  565. .num_consumer_supplies = ARRAY_SIZE(rm696_vbat_consumers),
  566. .consumer_supplies = rm696_vbat_consumers,
  567. .constraints = {
  568. .always_on = 1,
  569. },
  570. };
  571.  
  572. static struct fixed_voltage_config rm696_vbat_config = {
  573. .supply_name = "vbat",
  574. .microvolts = 3700000,
  575. .gpio = -1,
  576. .init_data = &rm696_vbat_data,
  577. };
  578.  
  579. static struct platform_device rm696_vbat = {
  580. .name = "reg-fixed-voltage",
  581. .id = -1,
  582. .dev = {
  583. .platform_data = &rm696_vbat_config,
  584. },
  585. };
  586.  
  587. /*
  588. * According to public N9 schematics VPNL comes from battery not from
  589. * TWL MMC2
  590. */
  591. static struct regulator_consumer_supply rm696_vmmc2_consumers[] = {
  592. REGULATOR_SUPPLY("VPNL", "display0"), /* Himalaya */
  593. };
  594.  
  595. static struct regulator_init_data rm696_vmmc2_data = {
  596. .constraints = {
  597. .name = "rm696_vmmc2",
  598. .min_uV = 3000000,
  599. .max_uV = 3000000,
  600. .apply_uV = true,
  601. .valid_modes_mask = REGULATOR_MODE_NORMAL
  602. | REGULATOR_MODE_STANDBY,
  603. .valid_ops_mask = REGULATOR_CHANGE_STATUS
  604. | REGULATOR_CHANGE_MODE,
  605. },
  606. .num_consumer_supplies = ARRAY_SIZE(rm696_vmmc2_consumers),
  607. .consumer_supplies = rm696_vmmc2_consumers,
  608. };
  609.  
  610. static struct regulator_consumer_supply rm696_vaux1_consumers[] = {
  611. REGULATOR_SUPPLY("AVdd", "2-004b"), /* Atmel mxt */
  612. REGULATOR_SUPPLY("Vdd", "3-001d"), /* LIS302 */
  613. REGULATOR_SUPPLY("v28", "twl5031_aci"),
  614. REGULATOR_SUPPLY("Vdd", "2-0039"), /* APDS990x */
  615. REGULATOR_SUPPLY("AVdd", "3-000f"), /* AK8975 on RM696, AK8974 on RM680 */
  616. };
  617.  
  618. static struct regulator_init_data rm696_vaux1_data = {
  619. .constraints = {
  620. .name = "rm696_vaux1",
  621. .min_uV = 2800000,
  622. .max_uV = 2800000,
  623. .valid_modes_mask = REGULATOR_MODE_NORMAL
  624. | REGULATOR_MODE_STANDBY,
  625. .valid_ops_mask = REGULATOR_CHANGE_MODE
  626. | REGULATOR_CHANGE_STATUS,
  627. },
  628. .num_consumer_supplies = ARRAY_SIZE(rm696_vaux1_consumers),
  629. .consumer_supplies = rm696_vaux1_consumers,
  630. };
  631.  
  632. static struct regulator_consumer_supply rm696_vaux2_consumers[] = {
  633. REGULATOR_SUPPLY("VDD_CSIPHY1", "omap3isp"), /* OMAP ISP */
  634. REGULATOR_SUPPLY("VDD_CSIPHY2", "omap3isp"), /* OMAP ISP */
  635. };
  636.  
  637. static struct regulator_init_data rm696_vaux2_data = {
  638. .constraints = {
  639. .name = "rm696_vaux2",
  640. .min_uV = 1800000,
  641. .max_uV = 1800000,
  642. .valid_modes_mask = REGULATOR_MODE_NORMAL
  643. | REGULATOR_MODE_STANDBY,
  644. .valid_ops_mask = REGULATOR_CHANGE_MODE
  645. | REGULATOR_CHANGE_STATUS,
  646. },
  647. .num_consumer_supplies = ARRAY_SIZE(rm696_vaux2_consumers),
  648. .consumer_supplies = rm696_vaux2_consumers,
  649. };
  650.  
  651. static struct regulator_consumer_supply rm696_vaux3_consumers[] = {
  652. REGULATOR_SUPPLY("VANA", "2-0037"), /* Main Camera Sensor */
  653. REGULATOR_SUPPLY("VANA", "2-000e"), /* Main Camera Lens */
  654. REGULATOR_SUPPLY("VANA", "2-0010"), /* Front Camera */
  655. };
  656.  
  657. static struct regulator_init_data rm696_vaux3_data = {
  658. .constraints = {
  659. .name = "rm696_vaux3",
  660. .min_uV = 2800000,
  661. .max_uV = 2800000,
  662. .valid_modes_mask = REGULATOR_MODE_NORMAL
  663. | REGULATOR_MODE_STANDBY,
  664. .valid_ops_mask = REGULATOR_CHANGE_MODE
  665. | REGULATOR_CHANGE_STATUS,
  666. },
  667. .num_consumer_supplies = ARRAY_SIZE(rm696_vaux3_consumers),
  668. .consumer_supplies = rm696_vaux3_consumers,
  669. };
  670.  
  671. static struct regulator_consumer_supply rm696_vaux4_consumers[] = {
  672. REGULATOR_SUPPLY("AVDD", "2-0019"), /* TLV320DAC33 */
  673. };
  674.  
  675. static struct regulator_init_data rm696_vaux4_data = {
  676. .constraints = {
  677. .name = "rm696_vaux4",
  678. .min_uV = 2800000,
  679. .max_uV = 2800000,
  680. .valid_modes_mask = REGULATOR_MODE_NORMAL
  681. | REGULATOR_MODE_STANDBY,
  682. .valid_ops_mask = REGULATOR_CHANGE_MODE
  683. | REGULATOR_CHANGE_STATUS,
  684. },
  685. .num_consumer_supplies = ARRAY_SIZE(rm696_vaux4_consumers),
  686. .consumer_supplies = rm696_vaux4_consumers,
  687. };
  688.  
  689. static struct platform_device *rm680_peripherals_devices[] __initdata = {
  690. &rm696_vbat,
  691. &rm680_vemmc_device,
  692. &rm696_cmt_device,
  693. &rm696_eci_device,
  694. };
  695.  
  696.  
  697.  
  698. /* ACI */
  699. static struct regulator *rm696plug_regulator;
  700. static bool rm696plug_regulator_enabled;
  701. static int rm696_plug_resource_reserve(struct device *dev)
  702. {
  703. rm696plug_regulator = regulator_get(dev, "v28");
  704. if (IS_ERR(rm696plug_regulator)) {
  705. dev_err(dev, "Unable to get v28 regulator for plug switch");
  706. return PTR_ERR(rm696plug_regulator);
  707. }
  708.  
  709. rm696plug_regulator_enabled = 0;
  710. return 0;
  711. }
  712.  
  713. static int rm696_plug_set_state(struct device *dev, bool plugged)
  714. {
  715. int ret;
  716.  
  717. if (rm696plug_regulator_enabled == plugged)
  718. return 0;
  719.  
  720. if (plugged) {
  721. ret = regulator_enable(rm696plug_regulator);
  722. if (ret)
  723. dev_err(dev, "Failed to enable v28 regulator");
  724. else
  725. rm696plug_regulator_enabled = 1;
  726. } else {
  727. ret = regulator_disable(rm696plug_regulator);
  728. if (ret)
  729. dev_err(dev, "Failed to disable v28 regulator");
  730. else
  731. rm696plug_regulator_enabled = 0;
  732. }
  733.  
  734. return ret;
  735. }
  736.  
  737. static void rm696_plug_resource_release(void)
  738. {
  739. if (rm696plug_regulator_enabled)
  740. regulator_disable(rm696plug_regulator);
  741.  
  742. regulator_put(rm696plug_regulator);
  743. rm696plug_regulator = NULL;
  744. }
  745.  
  746. static struct twl5031_aci_platform_data rm696_aci_data = {
  747. .tvout_gpio = RM696_TVOUT_EN_GPIO,
  748. .jack_gpio = RM696_JACK_GPIO,
  749. .avplugdet_plugged = AVPLUGDET_WHEN_PLUGGED_HIGH,
  750. .hw_plug_set_state = rm696_plug_set_state,
  751. .hw_plug_resource_reserve = rm696_plug_resource_reserve,
  752. .hw_plug_resource_release = rm696_plug_resource_release,
  753. };
  754.  
  755. static struct twl4030_platform_data rm680_twl_data = {
  756. .gpio = &rm680_gpio_data,
  757. .audio = &rm680_audio_data,
  758. .aci = &rm696_aci_data,
  759. .keypad = &rm696_kp_data,
  760. /* add rest of the children here */
  761. /* LDOs */
  762. .vio = &rm696_vio_data,
  763. .vmmc2 = &rm696_vmmc2_data,
  764. .vsim = &rm696_vsim_data,
  765. .vaux1 = &rm696_vaux1_data,
  766. .vaux2 = &rm696_vaux2_data,
  767. .vaux3 = &rm696_vaux3_data,
  768. .vaux4 = &rm696_vaux4_data,
  769. };
  770.  
  771. #if defined(CONFIG_RADIO_WL1273) || defined(CONFIG_RADIO_WL1273_MODULE)
  772.  
  773. static unsigned int wl1273_fm_reset_gpio;
  774.  
  775. static int rm696_wl1273_fm_request_resources(struct i2c_client *client)
  776. {
  777. if (gpio_request(RM696_FMRX_IRQ_GPIO, "wl1273_fm irq gpio") < 0) {
  778. dev_err(&client->dev, "Request IRQ GPIO fails.\n");
  779. return -1;
  780. }
  781.  
  782. if (system_rev < 0x0501)
  783. wl1273_fm_reset_gpio = RM696_FM_RESET_GPIO1;
  784. else
  785. wl1273_fm_reset_gpio = RM696_FM_RESET_GPIO2;
  786.  
  787. if (gpio_request(wl1273_fm_reset_gpio, "wl1273_fm reset gpio") < 0) {
  788. dev_err(&client->dev, "Request for GPIO %d fails.\n",
  789. wl1273_fm_reset_gpio);
  790. return -1;
  791. }
  792.  
  793. if (gpio_direction_output(wl1273_fm_reset_gpio, 0)) {
  794. dev_err(&client->dev, "Set GPIO Direction fails.\n");
  795. return -1;
  796. }
  797.  
  798. client->irq = gpio_to_irq(RM696_FMRX_IRQ_GPIO);
  799.  
  800. return 0;
  801. }
  802.  
  803. static void rm696_wl1273_fm_free_resources(void)
  804. {
  805. gpio_free(RM696_FMRX_IRQ_GPIO);
  806. gpio_free(wl1273_fm_reset_gpio);
  807. }
  808.  
  809. static void rm696_wl1273_fm_enable(void)
  810. {
  811. gpio_set_value(wl1273_fm_reset_gpio, 1);
  812. }
  813.  
  814. static void rm696_wl1273_fm_disable(void)
  815. {
  816. gpio_set_value(wl1273_fm_reset_gpio, 0);
  817. }
  818.  
  819. static struct wl1273_fm_platform_data rm696_fm_data = {
  820. .request_resources = rm696_wl1273_fm_request_resources,
  821. .free_resources = rm696_wl1273_fm_free_resources,
  822. .enable = rm696_wl1273_fm_enable,
  823. .disable = rm696_wl1273_fm_disable,
  824. #if defined(CONFIG_SND_SOC_WL1273) || defined(CONFIG_SND_SOC_WL1273_MODULE)
  825. .children = WL1273_CODEC_CHILD | WL1273_RADIO_CHILD,
  826. #else
  827. .children = WL1273_RADIO_CHILD,
  828. #endif
  829. };
  830.  
  831. static struct platform_device rm696_wl1273_core_device = {
  832. .name = "dfl61audio-wl1273",
  833. .id = -1,
  834. .dev = {
  835. .platform_data = &rm696_fm_data,
  836. },
  837. };
  838.  
  839. static void __init rm696_wl1273_init(void)
  840. {
  841. platform_device_register(&rm696_wl1273_core_device);
  842. }
  843. #else
  844.  
  845. static void __init rm696_wl1273_init(void)
  846. {
  847. }
  848. #endif
  849.  
  850. static struct mxt_platform_data atmel_mxt_platform_data_rm696 = {
  851. .reset_gpio = ATMEL_MXT_RESET_GPIO,
  852. .int_gpio = ATMEL_MXT_IRQ_GPIO,
  853. .rlimit_min_interval_us = 7000,
  854. .rlimit_bypass_time_us = 25000,
  855. .wakeup_interval_ms = 50,
  856. .config = &atmel_mxt_pyrenees_config,
  857. };
  858.  
  859. static struct mxt_platform_data atmel_mxt_platform_data_rm680 = {
  860. .reset_gpio = ATMEL_MXT_RESET_GPIO,
  861. .int_gpio = ATMEL_MXT_IRQ_GPIO,
  862. .rlimit_min_interval_us = 7000,
  863. .rlimit_bypass_time_us = 25000,
  864. .wakeup_interval_ms = 50,
  865. .config = &atmel_mxt_himalaya_config,
  866. };
  867.  
  868. #if defined(CONFIG_SND_SOC_TLV320DAC33) || \
  869. defined(CONFIG_SND_SOC_TLV320DAC33_MODULE)
  870. static struct tlv320dac33_platform_data rm696_dac33_platform_data = {
  871. .power_gpio = RM696_DAC33_RESET_GPIO,
  872. .mode1_latency = 10000, /* 10ms */
  873. /*FIXME there is no mode7lp_latency & fallback_to_bypass_time*/
  874. /*.mode7lp_latency = 10000,*/ /* 10ms */
  875. /*.fallback_to_bypass_time = 40000,*/ /* 40ms */
  876. .auto_fifo_config = 1,
  877. .keep_bclk = 1,
  878. .burst_bclkdiv = 3,
  879. };
  880. #endif
  881.  
  882.  
  883. #if defined(CONFIG_SND_SOC_TPA6130A2) || \
  884. defined(CONFIG_SND_SOC_TPA6130A2_MODULE)
  885. /* We don't have GPIO allocated for the TPA6130A2 amplifier */
  886. static struct tpa6130a2_platform_data rm696_tpa6130a2_platform_data = {
  887. .power_gpio = -1,
  888. };
  889. #endif
  890.  
  891. #if defined(CONFIG_LEDS_LP5521) || defined(CONFIG_LEDS_LP5521_MODULE)
  892. #define RM696_LED_MAX_CURR 130 /* 13 mA */
  893. #define RM696_LED_DEF_CURR 50 /* 5.0 mA */
  894. static struct lp5521_led_config rm696_lp5521_led_config[] = {
  895. {
  896. .chan_nr = 0,
  897. .led_current = RM696_LED_DEF_CURR,
  898. .max_current = RM696_LED_MAX_CURR,
  899. },
  900. {
  901. .chan_nr = 1,
  902. .led_current = 0,
  903. },
  904. {
  905. .chan_nr = 2,
  906. .led_current = 0,
  907. }
  908. };
  909.  
  910. static int lp5521_setup(void)
  911. {
  912. int err;
  913. int gpio = RM696_LP5521_CHIP_EN_GPIO;
  914. err = gpio_request(gpio, "lp5521_enable");
  915. if (err) {
  916. printk(KERN_ERR "lp5521: gpio request failed\n");
  917. return err;
  918. }
  919. gpio_direction_output(gpio, 0);
  920. return 0;
  921. }
  922.  
  923. static void lp5521_release(void)
  924. {
  925. gpio_free(RM696_LP5521_CHIP_EN_GPIO);
  926. }
  927.  
  928. static void lp5521_enable(bool state)
  929. {
  930. gpio_set_value(RM696_LP5521_CHIP_EN_GPIO, !!state);
  931. }
  932.  
  933. static struct lp5521_platform_data rm696_lp5521_platform_data = {
  934. .led_config = rm696_lp5521_led_config,
  935. .num_channels = ARRAY_SIZE(rm696_lp5521_led_config),
  936. .clock_mode = LP5521_CLOCK_EXT,
  937. .setup_resources = lp5521_setup,
  938. .release_resources = lp5521_release,
  939. .enable = lp5521_enable,
  940. .update_config = LP5521_PWRSAVE_EN | LP5521_CP_MODE_OFF | LP5521_R_TO_BATT,
  941. };
  942. #endif
  943.  
  944. #if defined(CONFIG_SENSORS_APDS990X) || defined(CONFIG_SENSORS_APDS990X_MODULE)
  945. static int apds990x_setup(void)
  946. {
  947. int err;
  948.  
  949. err = gpio_request_one(APDS990X_GPIO, GPIOF_DIR_IN, "apds990x_irq");
  950. if (err)
  951. goto fail;
  952.  
  953. fail:
  954. return err;
  955. }
  956.  
  957. static int apds990x_release(void)
  958. {
  959. gpio_free(APDS990X_GPIO);
  960. return 0;
  961. }
  962.  
  963. static struct apds990x_platform_data rm696_apds990x_data = {
  964. .cf.ga = 168834, /* 41.2194 * 4096 */
  965. .cf.cf1 = 4096,
  966. .cf.irf1 = 7824, /* 1.9102 * 4096 */
  967. .cf.cf2 = 877, /* 0.2140 * 4096 */
  968. .cf.irf2 = 1575, /* 0.3846 * 4096 */
  969. .cf.df = 52,
  970. .pdrive = APDS_IRLED_CURR_25mA,
  971. .setup_resources = apds990x_setup,
  972. .release_resources = apds990x_release,
  973. };
  974. #endif
  975.  
  976. static struct i2c_board_info rm696_peripherals_i2c_board_info_2[] /*__initdata */= {
  977. {
  978. /* keep this first */
  979. I2C_BOARD_INFO("atmel_mxt", 0x4b),
  980. .platform_data = &atmel_mxt_platform_data_rm696,
  981. },
  982.  
  983. #if defined(CONFIG_SENSORS_APDS990X) || defined(CONFIG_SENSORS_APDS990X_MODULE)
  984. {
  985. /* keep this second */
  986. I2C_BOARD_INFO("apds990x", 0x39),
  987. .platform_data = &rm696_apds990x_data,
  988. },
  989. #endif
  990.  
  991. #if defined(CONFIG_SND_SOC_TLV320DAC33) || \
  992. defined(CONFIG_SND_SOC_TLV320DAC33_MODULE)
  993. {
  994. /*keep this third*/
  995. I2C_BOARD_INFO("tlv320dac33", 0x19),
  996. .platform_data = &rm696_dac33_platform_data,
  997. },
  998. #endif
  999.  
  1000. #if defined(CONFIG_SND_SOC_TPA6130A2) || \
  1001. defined(CONFIG_SND_SOC_TPA6130A2_MODULE)
  1002. {
  1003. I2C_BOARD_INFO("tpa6140a2", 0x60),
  1004. .platform_data = &rm696_tpa6130a2_platform_data,
  1005. },
  1006. #endif
  1007.  
  1008. #if defined(CONFIG_LEDS_LP5521) || defined(CONFIG_LEDS_LP5521_MODULE)
  1009. {
  1010. I2C_BOARD_INFO("lp5521", 0x32),
  1011. .platform_data = &rm696_lp5521_platform_data,
  1012. },
  1013. #endif
  1014.  
  1015. };
  1016.  
  1017. static struct i2c_board_info rm680_peripherals_i2c_board_info_2[] /*__initdata */= {
  1018. {
  1019. /* keep this first */
  1020. I2C_BOARD_INFO("atmel_mxt", 0x4b),
  1021. .platform_data = &atmel_mxt_platform_data_rm680,
  1022. },
  1023.  
  1024. #if defined(CONFIG_SENSORS_APDS990X) || defined(CONFIG_SENSORS_APDS990X_MODULE)
  1025. {
  1026. /* keep this second */
  1027. I2C_BOARD_INFO("apds990x", 0x39),
  1028. .platform_data = &rm696_apds990x_data,
  1029. },
  1030. #endif
  1031.  
  1032. #if defined(CONFIG_SND_SOC_TLV320DAC33) || \
  1033. defined(CONFIG_SND_SOC_TLV320DAC33_MODULE)
  1034. {
  1035. /*keep this third*/
  1036. I2C_BOARD_INFO("tlv320dac33", 0x19),
  1037. .platform_data = &rm696_dac33_platform_data,
  1038. },
  1039. #endif
  1040.  
  1041. #if defined(CONFIG_SND_SOC_TPA6130A2) || \
  1042. defined(CONFIG_SND_SOC_TPA6130A2_MODULE)
  1043. {
  1044. I2C_BOARD_INFO("tpa6140a2", 0x60),
  1045. .platform_data = &rm696_tpa6130a2_platform_data,
  1046. },
  1047. #endif
  1048.  
  1049. #if defined(CONFIG_LEDS_LP5521) || defined(CONFIG_LEDS_LP5521_MODULE)
  1050. {
  1051. I2C_BOARD_INFO("lp5521", 0x32),
  1052. .platform_data = &rm696_lp5521_platform_data,
  1053. },
  1054. #endif
  1055.  
  1056. };
  1057.  
  1058. #if defined(CONFIG_SENSORS_APDS990X) || defined(CONFIG_SENSORS_APDS990X_MODULE)
  1059. static void __init rm696_apds990x_init(void)
  1060. {
  1061. if (system_rev < 0x0300) {
  1062. rm696_apds990x_data.cf.ga = 19660; /* 0.48 / 10% * 4096 */
  1063. rm696_apds990x_data.cf.irf1 = 7781; /* 1.8996 * 4096 */
  1064. rm696_apds990x_data.cf.cf2 = 1959; /* 0.4783 * 4096 */
  1065. rm696_apds990x_data.cf.irf2 = 3669; /* 0.8957 * 4096 */
  1066. rm696_apds990x_data.pdrive = APDS_IRLED_CURR_50mA;
  1067. } else if (system_rev < 0x1500) {
  1068. rm696_apds990x_data.cf.ga = 102674; /* 25.067 * 4096 */
  1069. rm696_apds990x_data.cf.irf1 = 7578; /* 1.8502 * 4096 */
  1070. rm696_apds990x_data.cf.cf2 = 1707; /* 0.4168 * 4096 */
  1071. rm696_apds990x_data.cf.irf2 = 2975; /* 0.7264 * 4096 */
  1072. rm696_apds990x_data.pdrive = APDS_IRLED_CURR_50mA;
  1073. }
  1074.  
  1075. if (!board_is_rm680()) {
  1076. rm696_peripherals_i2c_board_info_2[1].irq = gpio_to_irq(APDS990X_GPIO);
  1077. } else {
  1078. rm680_peripherals_i2c_board_info_2[1].irq = gpio_to_irq(APDS990X_GPIO);
  1079. }
  1080. }
  1081. #else
  1082. static inline void rm696_apds990x_init(void) {}
  1083. #endif
  1084.  
  1085. #if defined(CONFIG_SENSORS_LIS3_I2C) || defined(CONFIG_SENSORS_LIS3_I2C_MODULE)
  1086. static int lis302_setup(void)
  1087. {
  1088. int err;
  1089. int irq1 = LIS302_IRQ1_GPIO;
  1090. int irq2 = LIS302_IRQ2_GPIO;
  1091.  
  1092. /* gpio for interrupt pin 1 */
  1093. err = gpio_request(irq1, "lis3lv02dl_irq1");
  1094. if (err) {
  1095. printk(KERN_ERR "lis3lv02dl: gpio request failed\n");
  1096. goto out;
  1097. }
  1098.  
  1099. /* gpio for interrupt pin 2 */
  1100. err = gpio_request(irq2, "lis3lv02dl_irq2");
  1101. if (err) {
  1102. gpio_free(irq1);
  1103. printk(KERN_ERR "lis3lv02dl: gpio request failed\n");
  1104. goto out;
  1105. }
  1106.  
  1107. gpio_direction_input(irq1);
  1108. gpio_direction_input(irq2);
  1109.  
  1110. out:
  1111. return err;
  1112. }
  1113.  
  1114. static int lis302_release(void)
  1115. {
  1116. gpio_free(LIS302_IRQ1_GPIO);
  1117. gpio_free(LIS302_IRQ2_GPIO);
  1118.  
  1119. return 0;
  1120. }
  1121.  
  1122. #define LIS3_IRQ1_USE_BOTH_EDGES 1
  1123. #define LIS3_IRQ2_USE_BOTH_EDGES 2
  1124.  
  1125. static struct lis3lv02d_platform_data rm696_lis302dl_data = {
  1126. .click_flags = LIS3_CLICK_SINGLE_X | LIS3_CLICK_SINGLE_Y |
  1127. LIS3_CLICK_SINGLE_Z,
  1128. /* Limits are 0.5g * value */
  1129. .click_thresh_x = 8,
  1130. .click_thresh_y = 8,
  1131. .click_thresh_z = 10,
  1132. /* Click must be longer than time limit */
  1133. .click_time_limit = 9,
  1134. /* Kind of debounce filter */
  1135. .click_latency = 50,
  1136.  
  1137. /* Limits for all axis. millig-value / 18 to get HW values */
  1138. .wakeup_flags = LIS3_WAKEUP_X_HI | LIS3_WAKEUP_Y_HI,
  1139. .wakeup_thresh = 8,
  1140. .wakeup_flags2 = LIS3_WAKEUP_Z_HI,
  1141. .wakeup_thresh2 = 10,
  1142.  
  1143. .hipass_ctrl = LIS3_HIPASS_CUTFF_2HZ,
  1144.  
  1145. /* Interrupt line 2 for click detection, line 1 for thresholds */
  1146. .irq_cfg = LIS3_IRQ2_CLICK | LIS3_IRQ1_FF_WU_12,
  1147.  
  1148. .irq_flags1 = LIS3_IRQ1_USE_BOTH_EDGES,
  1149. .irq_flags2 = LIS3_IRQ2_USE_BOTH_EDGES,
  1150. .duration1 = 8,
  1151. .duration2 = 8,
  1152.  
  1153. .axis_x = LIS3_DEV_X,
  1154. .axis_y = LIS3_INV_DEV_Y,
  1155. .axis_z = LIS3_INV_DEV_Z,
  1156. .setup_resources = lis302_setup,
  1157. .release_resources = lis302_release,
  1158. .st_min_limits = {-46, 3, 3},
  1159. .st_max_limits = {-3, 46, 46},
  1160. };
  1161.  
  1162. static struct lis3lv02d_platform_data rm680_lis302dl_data = {
  1163. .click_flags = LIS3_CLICK_SINGLE_X | LIS3_CLICK_SINGLE_Y |
  1164. LIS3_CLICK_SINGLE_Z,
  1165. /* Limits are 0.5g * value */
  1166. .click_thresh_x = 8,
  1167. .click_thresh_y = 8,
  1168. .click_thresh_z = 10,
  1169. /* Click must be longer than time limit */
  1170. .click_time_limit = 9,
  1171. /* Kind of debounce filter */
  1172. .click_latency = 50,
  1173.  
  1174. /* Limits for all axis. millig-value / 18 to get HW values */
  1175. .wakeup_flags = LIS3_WAKEUP_X_HI | LIS3_WAKEUP_Y_HI,
  1176. .wakeup_thresh = 8,
  1177. .wakeup_flags2 = LIS3_WAKEUP_Z_HI,
  1178. .wakeup_thresh2 = 10,
  1179.  
  1180. .hipass_ctrl = LIS3_HIPASS_CUTFF_2HZ,
  1181.  
  1182. /* Interrupt line 2 for click detection, line 1 for thresholds */
  1183. .irq_cfg = LIS3_IRQ2_CLICK | LIS3_IRQ1_FF_WU_12,
  1184.  
  1185. .irq_flags1 = LIS3_IRQ1_USE_BOTH_EDGES,
  1186. .irq_flags2 = LIS3_IRQ2_USE_BOTH_EDGES,
  1187. .duration1 = 8,
  1188. .duration2 = 8,
  1189.  
  1190. .axis_x = LIS3_INV_DEV_Y,
  1191. .axis_y = LIS3_INV_DEV_X,
  1192. .axis_z = LIS3_INV_DEV_Z,
  1193. .setup_resources = lis302_setup,
  1194. .release_resources = lis302_release,
  1195. .st_min_limits = {-46, 3, 3},
  1196. .st_max_limits = {-3, 46, 46},
  1197. };
  1198.  
  1199. #endif
  1200.  
  1201. #if defined(CONFIG_SENSORS_AK8975) || defined(CONFIG_SENSORS_AK8975_MODULE)
  1202. static struct ak8975_platform_data rm696_ak8975_data = {
  1203. .axis_x = AK8975_DEV_Z,
  1204. .axis_y = AK8975_INV_DEV_X,
  1205. .axis_z = AK8975_INV_DEV_Y,
  1206. };
  1207. #endif
  1208.  
  1209. #if defined(CONFIG_PN544_NFC) || defined(CONFIG_PN544_NFC_MODULE)
  1210. static int rm696_pn544_nfc_request_resources(struct i2c_client *client)
  1211. {
  1212. int ret;
  1213. ret = gpio_request(NFC_HOST_INT_GPIO, "NFC INT");
  1214. if (ret) {
  1215. dev_err(&client->dev, "Request NFC INT GPIO fails %d\n", ret);
  1216. return -1;
  1217. }
  1218. ret = gpio_direction_input(NFC_HOST_INT_GPIO);
  1219. if (ret) {
  1220. dev_err(&client->dev, "Set GPIO Direction fails %d\n", ret);
  1221. goto err_int;
  1222. }
  1223.  
  1224. ret = gpio_request(NFC_ENABLE_GPIO, "NFC Enable");
  1225. if (ret) {
  1226. dev_err(&client->dev,
  1227. "Request for NFC Enable GPIO fails %d\n", ret);
  1228. goto err_int;
  1229. }
  1230. ret = gpio_direction_output(NFC_ENABLE_GPIO, 0);
  1231. if (ret) {
  1232. dev_err(&client->dev, "Set GPIO Direction fails %d\n", ret);
  1233. goto err_enable;
  1234. }
  1235.  
  1236. ret = gpio_request(NFC_FW_RESET_GPIO, "NFC FW Reset");
  1237. if (ret) {
  1238. dev_err(&client->dev,
  1239. "Request for NFC FW Reset GPIO fails %d\n", ret);
  1240. goto err_enable;
  1241. }
  1242. ret = gpio_direction_output(NFC_FW_RESET_GPIO, 0);
  1243. if (ret) {
  1244. dev_err(&client->dev, "Set GPIO Direction fails %d\n", ret);
  1245. goto err_fw;
  1246. }
  1247.  
  1248. return 0;
  1249. err_fw:
  1250. gpio_free(NFC_FW_RESET_GPIO);
  1251. err_enable:
  1252. gpio_free(NFC_ENABLE_GPIO);
  1253. err_int:
  1254. gpio_free(NFC_HOST_INT_GPIO);
  1255. return -1;
  1256. }
  1257.  
  1258. static void rm696_pn544_nfc_free_resources(void)
  1259. {
  1260. gpio_free(NFC_HOST_INT_GPIO);
  1261. gpio_free(NFC_ENABLE_GPIO);
  1262. gpio_free(NFC_FW_RESET_GPIO);
  1263. }
  1264.  
  1265. static void rm696_pn544_nfc_enable(int fw)
  1266. {
  1267. gpio_set_value(NFC_FW_RESET_GPIO, fw ? 1 : 0);
  1268. msleep(PN544_GPIO4VEN_TIME);
  1269. gpio_set_value(NFC_ENABLE_GPIO, 1);
  1270. }
  1271.  
  1272. static int rm696_pn544_nfc_test(void)
  1273. {
  1274. int a, b;
  1275. rm696_pn544_nfc_enable(0);
  1276. a = gpio_get_value(NFC_FW_RESET_GPIO);
  1277. rm696_pn544_nfc_enable(1);
  1278. b = gpio_get_value(NFC_FW_RESET_GPIO);
  1279.  
  1280. return (a == 0) && (b == 1);
  1281. }
  1282.  
  1283. static void rm696_pn544_nfc_disable(void)
  1284. {
  1285. gpio_set_value(NFC_ENABLE_GPIO, 0);
  1286. }
  1287.  
  1288. static struct pn544_nfc_platform_data rm696_nfc_data = {
  1289. .request_resources = rm696_pn544_nfc_request_resources,
  1290. .free_resources = rm696_pn544_nfc_free_resources,
  1291. .enable = rm696_pn544_nfc_enable,
  1292. .test = rm696_pn544_nfc_test,
  1293. .disable = rm696_pn544_nfc_disable,
  1294. };
  1295. #endif
  1296.  
  1297. #if defined(CONFIG_BCM4751_GPS) || defined(CONFIG_BCM4751_GPS_MODULE)
  1298. static int bcm4751_gps_setup(struct i2c_client *client)
  1299. {
  1300. struct bcm4751_gps_data *data = i2c_get_clientdata(client);
  1301. int err;
  1302.  
  1303. /* GPS IRQ */
  1304. err = gpio_request(data->gpio_irq, "GPS_IRQ");
  1305. if (err) {
  1306. dev_err(&client->dev,
  1307. "Failed to request GPIO%d (HOST_REQ)\n",
  1308. data->gpio_irq);
  1309. return err;
  1310. }
  1311. err = gpio_direction_input(data->gpio_irq);
  1312. if (err) {
  1313. dev_err(&client->dev, "Failed to change direction\n");
  1314. goto clean_gpio_irq;
  1315. }
  1316.  
  1317. client->irq = gpio_to_irq(data->gpio_irq);
  1318.  
  1319. /* Request GPIO for NSHUTDOWN == GPS_ENABLE */
  1320. err = gpio_request(data->gpio_enable, "GPS Enable");
  1321. if (err < 0) {
  1322. dev_err(&client->dev,
  1323. "Failed to request GPIO%d (GPS_ENABLE)\n",
  1324. data->gpio_enable);
  1325. goto clean_gpio_irq;
  1326. }
  1327. err = gpio_direction_output(data->gpio_enable, 0);
  1328. if (err) {
  1329. dev_err(&client->dev, "Failed to change direction\n");
  1330. goto clean_gpio_en;
  1331. }
  1332.  
  1333. /* Request GPIO for GPS WAKEUP */
  1334. err = gpio_request(data->gpio_wakeup, "GPS Wakeup");
  1335. if (err < 0) {
  1336. dev_err(&client->dev,
  1337. "Failed to request GPIO%d (GPS_WAKEUP)\n",
  1338. data->gpio_wakeup);
  1339. goto clean_gpio_en;
  1340. }
  1341. err = gpio_direction_output(data->gpio_wakeup, 0);
  1342. if (err) {
  1343. dev_err(&client->dev, "Failed to change direction\n");
  1344. goto clean_gpio_wakeup;
  1345. }
  1346.  
  1347. return 0;
  1348.  
  1349. clean_gpio_wakeup:
  1350. gpio_free(data->gpio_wakeup);
  1351.  
  1352. clean_gpio_en:
  1353. gpio_free(data->gpio_enable);
  1354.  
  1355. clean_gpio_irq:
  1356. gpio_free(data->gpio_irq);
  1357.  
  1358. return err;
  1359. }
  1360.  
  1361. static void bcm4751_gps_cleanup(struct i2c_client *client)
  1362. {
  1363. struct bcm4751_gps_data *data = i2c_get_clientdata(client);
  1364.  
  1365. gpio_free(data->gpio_irq);
  1366. gpio_free(data->gpio_wakeup);
  1367. gpio_free(data->gpio_enable);
  1368. }
  1369.  
  1370. static int bcm4751_gps_show_gpio_irq(struct i2c_client *client)
  1371. {
  1372. struct bcm4751_gps_data *data = i2c_get_clientdata(client);
  1373.  
  1374. return gpio_get_value(data->gpio_irq);
  1375. }
  1376.  
  1377. static void bcm4751_gps_enable(struct i2c_client *client)
  1378. {
  1379. struct bcm4751_gps_data *data = i2c_get_clientdata(client);
  1380.  
  1381. gpio_set_value(data->gpio_enable, 1);
  1382. }
  1383.  
  1384. static void bcm4751_gps_disable(struct i2c_client *client)
  1385. {
  1386. struct bcm4751_gps_data *data = i2c_get_clientdata(client);
  1387.  
  1388. gpio_set_value(data->gpio_enable, 0);
  1389. }
  1390.  
  1391. static void bcm4751_gps_wakeup_ctrl(struct i2c_client *client, int value)
  1392. {
  1393. struct bcm4751_gps_data *data = i2c_get_clientdata(client);
  1394.  
  1395. gpio_set_value(data->gpio_wakeup, value);
  1396. }
  1397.  
  1398. static struct bcm4751_gps_platform_data rm696_bcm4751_gps_platform_data = {
  1399. .gps_gpio_irq = RM696_BCM4751_GPS_IRQ_GPIO,
  1400. .gps_gpio_enable = RM696_BCM4751_GPS_ENABLE_GPIO,
  1401. .gps_gpio_wakeup = RM696_BCM4751_GPS_WAKEUP_GPIO,
  1402. .setup = bcm4751_gps_setup,
  1403. .cleanup = bcm4751_gps_cleanup,
  1404. .enable = bcm4751_gps_enable,
  1405. .disable = bcm4751_gps_disable,
  1406. .wakeup_ctrl = bcm4751_gps_wakeup_ctrl,
  1407. .show_irq = bcm4751_gps_show_gpio_irq
  1408. };
  1409. #endif
  1410.  
  1411. static struct i2c_board_info rm696_peripherals_i2c_board_info_3[] /*__initdata */= {
  1412. #if defined(CONFIG_SENSORS_LIS3_I2C) || defined(CONFIG_SENSORS_LIS3_I2C_MODULE)
  1413. {
  1414. /* Keep this first */
  1415. I2C_BOARD_INFO("lis3lv02d", 0x1d),
  1416. .platform_data = &rm696_lis302dl_data,
  1417. },
  1418. #endif
  1419.  
  1420. #if defined(CONFIG_PN544_NFC) || defined(CONFIG_PN544_NFC_MODULE)
  1421. {
  1422. /* Keep this second */
  1423. I2C_BOARD_INFO(PN544_DRIVER_NAME, 0x2b),
  1424. .platform_data = &rm696_nfc_data,
  1425. },
  1426. #endif
  1427.  
  1428. #if defined(CONFIG_RADIO_WL1273) || defined(CONFIG_RADIO_WL1273_MODULE)
  1429. {
  1430. I2C_BOARD_INFO(WL1273_FM_DRIVER_NAME, RX71_FM_I2C_ADDR),
  1431. .platform_data = &rm696_fm_data,
  1432. },
  1433. #endif
  1434.  
  1435. #if defined(CONFIG_SENSORS_AK8975) || defined(CONFIG_SENSORS_AK8975_MODULE)
  1436. {
  1437. I2C_BOARD_INFO("ak8975", 0x0f),
  1438. .platform_data = &rm696_ak8975_data,
  1439. },
  1440. #endif
  1441.  
  1442. #if defined(CONFIG_BCM4751_GPS) || defined(CONFIG_BCM4751_GPS_MODULE)
  1443. {
  1444. I2C_BOARD_INFO("bcm4751-gps", 0x1fa),
  1445. .platform_data = &rm696_bcm4751_gps_platform_data,
  1446. .flags = I2C_CLIENT_TEN,
  1447. },
  1448. #endif
  1449.  
  1450. };
  1451.  
  1452. static struct i2c_board_info rm680_peripherals_i2c_board_info_3[] /*__initdata */= {
  1453. #if defined(CONFIG_SENSORS_LIS3_I2C) || defined(CONFIG_SENSORS_LIS3_I2C_MODULE)
  1454. {
  1455. /* Keep this first */
  1456. I2C_BOARD_INFO("lis3lv02d", 0x1d),
  1457. .platform_data = &rm680_lis302dl_data,
  1458. },
  1459. #endif
  1460.  
  1461. #if defined(CONFIG_RADIO_WL1273) || defined(CONFIG_RADIO_WL1273_MODULE)
  1462. {
  1463. I2C_BOARD_INFO(WL1273_FM_DRIVER_NAME, RX71_FM_I2C_ADDR),
  1464. .platform_data = &rm696_fm_data,
  1465. },
  1466. #endif
  1467.  
  1468. #if defined(CONFIG_SENSORS_AK8975) || defined(CONFIG_SENSORS_AK8975_MODULE)
  1469. {
  1470. I2C_BOARD_INFO("ak8975", 0x0f),
  1471. .platform_data = &rm696_ak8975_data,
  1472. },
  1473. #endif
  1474.  
  1475. #if defined(CONFIG_BCM4751_GPS) || defined(CONFIG_BCM4751_GPS_MODULE)
  1476. {
  1477. I2C_BOARD_INFO("bcm4751-gps", 0x1fa),
  1478. .platform_data = &rm696_bcm4751_gps_platform_data,
  1479. .flags = I2C_CLIENT_TEN,
  1480. },
  1481. #endif
  1482.  
  1483. };
  1484.  
  1485. static void rm696_vibra_set_power(bool enable)
  1486. {
  1487. gpio_set_value(RM696_VIBRA_POWER_GPIO, enable);
  1488. if (enable)
  1489. usleep_range(RM696_VIBRA_POWER_UP_TIME,
  1490. RM696_VIBRA_POWER_UP_TIME + 100);
  1491. }
  1492.  
  1493. static struct vibra_spi_platform_data vibra_pdata = {
  1494. .set_power = rm696_vibra_set_power,
  1495. };
  1496.  
  1497. static struct omap2_mcspi_device_config spi_vibra_mcspi_config = {
  1498. .turbo_mode = 1,
  1499. };
  1500.  
  1501. static struct spi_board_info rm696_vibra_spi_board_info = {
  1502. .modalias = "vibra_spi",
  1503. .bus_num = 2,
  1504. .chip_select = 0,
  1505. .max_speed_hz = 750000,
  1506. .mode = SPI_MODE_0,
  1507. .controller_data = &spi_vibra_mcspi_config,
  1508. .platform_data = &vibra_pdata,
  1509. };
  1510.  
  1511. static void __init rm696_init_vibra(void)
  1512. {
  1513. int ret;
  1514.  
  1515. /* Vibra has been connected to SPI since S1.1 */
  1516. if (system_rev < 0x0501)
  1517. return ;
  1518.  
  1519. ret = gpio_request(RM696_VIBRA_POWER_GPIO, "Vibra amplifier");
  1520. if (ret < 0)
  1521. goto error;
  1522.  
  1523. ret = gpio_direction_output(RM696_VIBRA_POWER_GPIO, 0);
  1524. if (ret < 0)
  1525. goto err_power;
  1526.  
  1527. spi_register_board_info(&rm696_vibra_spi_board_info, 1);
  1528. return ;
  1529.  
  1530. err_power:
  1531. gpio_free(RM696_VIBRA_POWER_GPIO);
  1532. error:
  1533. printk(KERN_ERR "SPI Vibra board initialisation failed\n");
  1534. vibra_pdata.set_power = NULL;
  1535. }
  1536.  
  1537. static void __init rm680_i2c_init(void)
  1538. {
  1539. struct twl4030_codec_data *codec_data;
  1540.  
  1541. omap3_pmic_get_config(&rm680_twl_data,
  1542. TWL_COMMON_PDATA_USB |
  1543. TWL_COMMON_PDATA_MADC |
  1544. TWL_COMMON_PDATA_BCI,
  1545. TWL_COMMON_REGULATOR_VDAC |
  1546. TWL_COMMON_REGULATOR_VPLL2);
  1547.  
  1548. codec_data = rm680_twl_data.audio->codec;
  1549. codec_data->ramp_delay_value = 2;
  1550. codec_data->offset_cncl_path = TWL4030_OFFSET_CNCL_SEL_ARX2;
  1551. codec_data->check_defaults = 0;
  1552. codec_data->reset_registers = 0;
  1553. codec_data->digimic_delay = 0;
  1554.  
  1555. #if defined(CONFIG_SENSORS_LIS3_I2C) || defined(CONFIG_SENSORS_LIS3_I2C_MODULE)
  1556. if (!board_is_rm680()) {
  1557. rm696_lis302dl_data.irq2 = gpio_to_irq(LIS302_IRQ2_GPIO);
  1558. rm696_peripherals_i2c_board_info_3[0].irq = gpio_to_irq(LIS302_IRQ1_GPIO);
  1559. } else {
  1560. rm680_lis302dl_data.irq2 = gpio_to_irq(LIS302_IRQ2_GPIO);
  1561. rm680_peripherals_i2c_board_info_3[0].irq = gpio_to_irq(LIS302_IRQ1_GPIO);
  1562. }
  1563. #endif
  1564.  
  1565. #if defined(CONFIG_PN544_NFC) || defined(CONFIG_PN544_NFC_MODULE)
  1566. if (!board_is_rm680()) {
  1567. rm696_peripherals_i2c_board_info_3[1].irq = gpio_to_irq(NFC_HOST_INT_GPIO);
  1568. }
  1569. #endif
  1570.  
  1571. omap_pmic_init(1, 2900, "twl5031", INT_34XX_SYS_NIRQ, &rm680_twl_data);
  1572. if (!board_is_rm680()) {
  1573. omap_register_i2c_bus(2, 400, rm696_peripherals_i2c_board_info_2,
  1574. ARRAY_SIZE(rm696_peripherals_i2c_board_info_2));
  1575. omap_register_i2c_bus(3, 400, rm696_peripherals_i2c_board_info_3,
  1576. ARRAY_SIZE(rm696_peripherals_i2c_board_info_3));
  1577. } else {
  1578. omap_register_i2c_bus(2, 400, rm680_peripherals_i2c_board_info_2,
  1579. ARRAY_SIZE(rm680_peripherals_i2c_board_info_2));
  1580. omap_register_i2c_bus(3, 400, rm680_peripherals_i2c_board_info_3,
  1581. ARRAY_SIZE(rm680_peripherals_i2c_board_info_3));
  1582. }
  1583. }
  1584.  
  1585. #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
  1586. defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
  1587. static struct omap_onenand_platform_data board_onenand_data[] = {
  1588. {
  1589. .cs = 0,
  1590. .gpio_irq = 65,
  1591. .flags = ONENAND_SYNC_READWRITE,
  1592. .regulator_can_sleep = 1,
  1593. .skip_initial_unlocking = 1,
  1594. }
  1595. };
  1596. #endif
  1597.  
  1598. static struct omap2_hsmmc_info mmc[] __initdata = {
  1599. /* eMMC */
  1600. {
  1601. .name = "internal",
  1602. .mmc = 2,
  1603. /* FIXME:
  1604. * Setting MMC_CAP_8_BIT_DATA here causes wl1271 to break with message:
  1605. * wl1271_sdio mmc2:0001:2 sdio write failed (-84)
  1606. */
  1607. .caps = MMC_CAP_4_BIT_DATA,
  1608. .gpio_cd = -EINVAL,
  1609. .gpio_wp = -EINVAL,
  1610. .nonremovable = true,
  1611. .power_saving = true,
  1612. .no_off = true,
  1613. .vcc_aux_disable_is_sleep = true,
  1614. /* FIXME: nomux is present in 2.6 but missing in 3.5 */
  1615. /* .nomux = 1,*/
  1616. },
  1617. /* WLAN */
  1618. {
  1619. .name = "wl1271",
  1620. .mmc = 3,
  1621. .caps = MMC_CAP_4_BIT_DATA,
  1622. .gpio_cd = -EINVAL,
  1623. .gpio_wp = -EINVAL,
  1624. .nonremovable = true,
  1625. },
  1626. { /* Terminator */ }
  1627. };
  1628.  
  1629. static struct nokia_dsi_panel_data rm696_panel_data = {
  1630. .name = "pyrenees",
  1631. .reset_gpio = 87,
  1632. .use_ext_te = true,
  1633. .ext_te_gpio = 62,
  1634. .esd_timeout = 5000,
  1635. .ulps_timeout = 500,
  1636. .partial_area = {
  1637. .offset = 0,
  1638. .height = 854,
  1639. },
  1640. .rotate = 1,
  1641. };
  1642.  
  1643. static struct nokia_dsi_panel_data rm680_panel_data = {
  1644. .name = "himalaya",
  1645. .reset_gpio = 87,
  1646. .use_ext_te = true,
  1647. .ext_te_gpio = 62,
  1648. .esd_timeout = 5000,
  1649. .ulps_timeout = 500,
  1650. .partial_area = {
  1651. .offset = 5,
  1652. .height = 854,
  1653. },
  1654. .rotate = 3,
  1655. };
  1656.  
  1657. static struct omap_dss_device rm696_dsi_display_data = {
  1658. .type = OMAP_DISPLAY_TYPE_DSI,
  1659. .name = "lcd",
  1660. .driver_name = "panel-nokia-dsi",
  1661. .phy.dsi = {
  1662. .clk_lane = 2,
  1663. .clk_pol = 0,
  1664. .data1_lane = 3,
  1665. .data1_pol = 0,
  1666. .data2_lane = 1,
  1667. .data2_pol = 0,
  1668. .ext_te = true,
  1669. .ext_te_gpio = 62,
  1670. },
  1671.  
  1672. .clocks = {
  1673. .dss = {
  1674. .fck_div = 5,
  1675. },
  1676.  
  1677. .dispc = {
  1678. /* LCK 170.88 MHz */
  1679. .lck_div = 1,
  1680. /* PCK 42.72 MHz */
  1681. .pck_div = 4,
  1682.  
  1683. .fclk_from_dsi_pll = false,
  1684. },
  1685.  
  1686. .dsi = {
  1687. /* DDR CLK 210.24 MHz */
  1688. .regn = 10,
  1689. .regm = 219,
  1690. /* DISPC FCLK 170.88 MHz */
  1691. .regm3 = 6,
  1692. /* DSI FCLK 170.88 MHz */
  1693. .regm4 = 6,
  1694.  
  1695. /* LP CLK 8.760 MHz */
  1696. .lp_clk_div = 8,
  1697.  
  1698. .fclk_from_dsi_pll = false,
  1699. },
  1700. },
  1701.  
  1702. .data = &rm696_panel_data,
  1703. };
  1704.  
  1705. static struct omap_dss_device rm680_dsi_display_data = {
  1706. .type = OMAP_DISPLAY_TYPE_DSI,
  1707. .name = "lcd",
  1708. .driver_name = "panel-nokia-dsi",
  1709. .phy.dsi = {
  1710. .clk_lane = 2,
  1711. .clk_pol = 0,
  1712. .data1_lane = 1,
  1713. .data1_pol = 0,
  1714. .data2_lane = 3,
  1715. .data2_pol = 0,
  1716. },
  1717.  
  1718. .clocks = {
  1719. .dss = {
  1720. .fck_div = 5,
  1721. },
  1722.  
  1723. .dispc = {
  1724. /* LCK 170.88 MHz */
  1725. .lck_div = 1,
  1726. /* PCK 42.72 MHz */
  1727. .pck_div = 4,
  1728.  
  1729. .fclk_from_dsi_pll = false,
  1730. },
  1731.  
  1732. .dsi = {
  1733. /* DDR CLK 256.32 MHz */
  1734. .regn = 10,
  1735. .regm = 267,
  1736. /* DISPC FCLK 170.88 MHz */
  1737. .regm3 = 6,
  1738. /* DSI FCLK 170.88 MHz */
  1739. .regm4 = 6,
  1740.  
  1741. /* LP CLK 7.767 MHz */
  1742. .lp_clk_div = 11,
  1743.  
  1744. .fclk_from_dsi_pll = false,
  1745. },
  1746. },
  1747.  
  1748. .data = &rm680_panel_data,
  1749. };
  1750.  
  1751. static int rm696_tv_enable(struct omap_dss_device *dssdev)
  1752. {
  1753. if (dssdev->reset_gpio != -1)
  1754. gpio_set_value(dssdev->reset_gpio, 1);
  1755.  
  1756. return 0;
  1757. }
  1758.  
  1759. static void rm696_tv_disable(struct omap_dss_device *dssdev)
  1760. {
  1761. if (dssdev->reset_gpio != -1)
  1762. gpio_set_value(dssdev->reset_gpio, 0);
  1763. }
  1764.  
  1765. static struct omap_dss_device rm696_tv_display_data = {
  1766. .type = OMAP_DISPLAY_TYPE_VENC,
  1767. .name = "tv",
  1768. .driver_name = "venc",
  1769. /* was 40, handled by twl5031-aci */
  1770. .reset_gpio = -1,
  1771. .phy.venc.type = OMAP_DSS_VENC_TYPE_COMPOSITE,
  1772. .platform_enable = rm696_tv_enable,
  1773. .platform_disable = rm696_tv_disable,
  1774. };
  1775.  
  1776. static struct omap_dss_device *rm696_dss_devices[] = {
  1777. &rm696_dsi_display_data,
  1778. &rm696_tv_display_data,
  1779. };
  1780.  
  1781. static struct omap_dss_device *rm680_dss_devices[] = {
  1782. &rm680_dsi_display_data,
  1783. &rm696_tv_display_data, //same as on RM696
  1784. };
  1785.  
  1786. static struct omap_dss_board_info rm696_dss_data = {
  1787. .num_devices = ARRAY_SIZE(rm696_dss_devices),
  1788. .devices = rm696_dss_devices,
  1789. .default_device = &rm696_dsi_display_data,
  1790. };
  1791.  
  1792. static struct omap_dss_board_info rm680_dss_data = {
  1793. .num_devices = ARRAY_SIZE(rm680_dss_devices),
  1794. .devices = rm680_dss_devices,
  1795. .default_device = &rm680_dsi_display_data,
  1796. };
  1797.  
  1798. struct platform_device rm696_dss_device = {
  1799. .name = "omapdss",
  1800. .id = -1,
  1801. .dev = {
  1802. .platform_data = &rm696_dss_data,
  1803. },
  1804. };
  1805.  
  1806. struct platform_device rm680_dss_device = {
  1807. .name = "omapdss",
  1808. .id = -1,
  1809. .dev = {
  1810. .platform_data = &rm680_dss_data,
  1811. },
  1812. };
  1813.  
  1814. static struct omapfb_platform_data rm696_omapfb_data = {
  1815. .mem_desc = {
  1816. .region_cnt = 1,
  1817. .region[0] = {
  1818. .format_used = true,
  1819. .format = OMAPFB_COLOR_ARGB32,
  1820. .size = PAGE_ALIGN(856 * 512 * 4 * 3),
  1821. .xres_virtual = 856,
  1822. .yres_virtual = 512 * 3,
  1823. }
  1824. }
  1825. };
  1826.  
  1827. static void rm680_bt_set_pm_limits(struct device *dev, bool set)
  1828. {
  1829. omap_pm_set_max_mpu_wakeup_lat(dev, set ? H4P_WAKEUP_LATENCY : -1);
  1830. }
  1831.  
  1832. static struct omap_bluetooth_config rm680_bt_config = {
  1833. .chip_type = BT_CHIP_TI,
  1834. .bt_wakeup_gpio = 37,
  1835. .host_wakeup_gpio = 101,
  1836. .reset_gpio = 26,
  1837. .bt_uart = 2,
  1838. .bt_sysclk = BT_SYSCLK_38_4,
  1839. .set_pm_limits = rm680_bt_set_pm_limits,
  1840. };
  1841.  
  1842. static void rm696_sgx_dev_release(struct device *pdev)
  1843. {
  1844. pr_debug("%s: (%p)", __func__, pdev);
  1845. }
  1846.  
  1847. static struct sgx_platform_data rm696_sgx_platform_data = {
  1848. .fclock_max = 200000000,
  1849. };
  1850.  
  1851. static struct platform_device rm696_sgx_device = {
  1852. .name = "pvrsrvkm",
  1853. .id = -1,
  1854. .dev = {
  1855. .platform_data = &rm696_sgx_platform_data,
  1856. .release = rm696_sgx_dev_release,
  1857. }
  1858. };
  1859.  
  1860. static int __init rm696_video_init(void)
  1861. {
  1862. int r;
  1863.  
  1864. if (board_is_rm680())
  1865. return 0;
  1866.  
  1867. omap_setup_dss_device(&rm696_dss_device);
  1868.  
  1869. rm696_dss_devices[0] = &rm696_dsi_display_data;
  1870.  
  1871. r = gpio_request(rm696_panel_data.reset_gpio, "pyrenees reset");
  1872. if (r < 0)
  1873. goto err0;
  1874.  
  1875. r = gpio_direction_output(rm696_panel_data.reset_gpio, 1);
  1876.  
  1877. rm696_dss_data.default_device = rm696_dss_devices[0];
  1878.  
  1879. /* TV */
  1880. if (rm696_tv_display_data.reset_gpio != -1) {
  1881. r = gpio_request(rm696_tv_display_data.reset_gpio,
  1882. "TV-out enable");
  1883. if (r < 0)
  1884. goto err1;
  1885.  
  1886. r = gpio_direction_output(rm696_tv_display_data.reset_gpio, 0);
  1887. if (r < 0)
  1888. goto err2;
  1889. }
  1890.  
  1891. r = platform_device_register(&rm696_dss_device);
  1892. if (r < 0)
  1893. goto err2;
  1894.  
  1895. omapfb_set_platform_data(&rm696_omapfb_data);
  1896.  
  1897. r = platform_device_register(&rm696_sgx_device);
  1898. if (r < 0)
  1899. goto err3;
  1900.  
  1901. return 0;
  1902.  
  1903. err3:
  1904. platform_device_unregister(&rm696_dss_device);
  1905. err2:
  1906. if (rm696_tv_display_data.reset_gpio != -1) {
  1907. gpio_free(rm696_tv_display_data.reset_gpio);
  1908. rm696_tv_display_data.reset_gpio = -1;
  1909. }
  1910. err1:
  1911. gpio_free(rm696_panel_data.reset_gpio);
  1912. rm696_panel_data.reset_gpio = -1;
  1913. err0:
  1914. pr_err("%s failed (%d)\n", __func__, r);
  1915.  
  1916. return r;
  1917. }
  1918.  
  1919. subsys_initcall(rm696_video_init);
  1920.  
  1921. static int __init rm680_video_init(void)
  1922. {
  1923. int r;
  1924.  
  1925. if (!board_is_rm680())
  1926. return 0;
  1927.  
  1928. if (system_rev < 0x0420) {
  1929. pr_err("RM-680 display is supported only on HWID 0420 and " \
  1930. "higher\n");
  1931. r = -ENODEV;
  1932. goto err0;
  1933. }
  1934.  
  1935. omap_setup_dss_device(&rm680_dss_device);
  1936.  
  1937. r = gpio_request(rm680_panel_data.reset_gpio, "himalaya reset");
  1938. if (r < 0)
  1939. goto err0;
  1940.  
  1941. r = gpio_direction_output(rm680_panel_data.reset_gpio, 1);
  1942.  
  1943. rm680_dss_data.default_device = rm680_dss_devices[0];
  1944.  
  1945. /* TV */
  1946. if (rm696_tv_display_data.reset_gpio != -1) { //same as on RM696
  1947. r = gpio_request(rm696_tv_display_data.reset_gpio,
  1948. "TV-out enable");
  1949. if (r < 0)
  1950. goto err1;
  1951.  
  1952. r = gpio_direction_output(rm696_tv_display_data.reset_gpio, 0);
  1953. if (r < 0)
  1954. goto err2;
  1955. }
  1956.  
  1957. r = platform_device_register(&rm680_dss_device);
  1958. if (r < 0)
  1959. goto err2;
  1960.  
  1961. omapfb_set_platform_data(&rm696_omapfb_data); // same as on RM696
  1962.  
  1963. r = platform_device_register(&rm696_sgx_device); //same as on RM696
  1964. if (r < 0)
  1965. goto err3;
  1966.  
  1967. return 0;
  1968.  
  1969. err3:
  1970. platform_device_unregister(&rm696_dss_device);
  1971. err2:
  1972. if (rm696_tv_display_data.reset_gpio != -1) {
  1973. gpio_free(rm696_tv_display_data.reset_gpio);
  1974. rm696_tv_display_data.reset_gpio = -1;
  1975. }
  1976. err1:
  1977. gpio_free(rm680_panel_data.reset_gpio);
  1978. rm680_panel_data.reset_gpio = -1;
  1979. err0:
  1980. pr_err("%s failed (%d)\n", __func__, r);
  1981.  
  1982. return r;
  1983. }
  1984.  
  1985. subsys_initcall(rm680_video_init);
  1986.  
  1987. static int __init rm696_atmel_mxt_init(void)
  1988. {
  1989. int err;
  1990.  
  1991. err = gpio_request_one(ATMEL_MXT_RESET_GPIO, GPIOF_OUT_INIT_HIGH,
  1992. "mxt_reset");
  1993. if (err)
  1994. goto err1;
  1995.  
  1996. err = gpio_request_one(ATMEL_MXT_IRQ_GPIO, GPIOF_DIR_IN, "mxt_irq");
  1997. if (err)
  1998. goto err2;
  1999.  
  2000. if (!board_is_rm680()) {
  2001. rm696_peripherals_i2c_board_info_2[0].irq = gpio_to_irq(ATMEL_MXT_IRQ_GPIO);
  2002. } else {
  2003. rm680_peripherals_i2c_board_info_2[0].irq = gpio_to_irq(ATMEL_MXT_IRQ_GPIO);
  2004. }
  2005.  
  2006. return 0;
  2007. err2:
  2008. gpio_free(ATMEL_MXT_RESET_GPIO);
  2009. err1:
  2010.  
  2011. return err;
  2012. }
  2013.  
  2014. #if defined(CONFIG_SND_OMAP_SOC_DFL61_TWL4030) || \
  2015. defined(CONFIG_SND_OMAP_SOC_DFL61_TWL4030_MODULE)
  2016. static struct dfl61audio_twl4030_platform_data rm696_twl4030_data;
  2017.  
  2018. static struct platform_device rm696_twl4030_device = {
  2019. .name = "dfl61audio-twl4030",
  2020. .id = -1,
  2021. .dev = {
  2022. .platform_data = &rm696_twl4030_data,
  2023. },
  2024. };
  2025.  
  2026. static int __init rm696_audio_init(void)
  2027. {
  2028. if (!machine_is_nokia_rm680() && !machine_is_nokia_rm696())
  2029. return -ENODEV;
  2030.  
  2031. rm696_twl4030_data.audio_config = AUDIO_CONFIG4;
  2032. rm696_twl4030_data.freq = 38400000;
  2033.  
  2034. platform_device_register(&rm696_twl4030_device);
  2035. return 0;
  2036. }
  2037. #else
  2038. static inline void __init rm696_audio_init(void)
  2039. {
  2040. }
  2041. #endif
  2042.  
  2043. #if defined(CONFIG_SND_SOC_TLV320DAC33) || \
  2044. defined(CONFIG_SND_SOC_TLV320DAC33_MODULE)
  2045.  
  2046. static struct platform_device rm696_tlv320dac33_device = {
  2047. .name = "dfl61audio-tlv320dac33",
  2048. .id = -1,
  2049. };
  2050.  
  2051. static int __init rm696_tlv320dac33_init(void)
  2052. {
  2053. int r;
  2054.  
  2055. r = gpio_request(RM696_DAC33_IRQ_GPIO, "tlv320dac33 IRQ");
  2056. if (r < 0) {
  2057. printk(KERN_ERR "Failed to request IRQ gpio "
  2058. "for tlv320dac33 chip\n");
  2059. }
  2060.  
  2061. if (!board_is_rm680()) {
  2062. rm696_peripherals_i2c_board_info_2[2].irq = gpio_to_irq(RM696_DAC33_IRQ_GPIO);
  2063. } else {
  2064. rm680_peripherals_i2c_board_info_2[2].irq = gpio_to_irq(RM696_DAC33_IRQ_GPIO);
  2065. }
  2066.  
  2067. gpio_direction_input(RM696_DAC33_IRQ_GPIO);
  2068.  
  2069. platform_device_register(&rm696_tlv320dac33_device);
  2070.  
  2071. return 0;
  2072. }
  2073. #else
  2074. static inline void __init rm696_tlv320dac33_init(void)
  2075. {
  2076. }
  2077. #endif
  2078.  
  2079. static void __init rm696_avplugdet_init(void)
  2080. {
  2081. /* Prior to S0.2, the pin was as in previous platforms */
  2082. if (system_rev < 0x0200)
  2083. rm696_aci_data.avplugdet_plugged = AVPLUGDET_WHEN_PLUGGED_LOW;
  2084. }
  2085.  
  2086. static void __init rm680_peripherals_init(void)
  2087. {
  2088. rm680_init_wl1271();
  2089.  
  2090. /*if (!board_is_rm680()) {*/
  2091. rm696_init_vibra();
  2092.  
  2093. platform_add_devices(rm680_peripherals_devices,
  2094. ARRAY_SIZE(rm680_peripherals_devices));
  2095.  
  2096. rm696_atmel_mxt_init();
  2097. rm696_apds990x_init();
  2098. rm696_avplugdet_init();
  2099. rm680_i2c_init();
  2100. gpmc_onenand_init(board_onenand_data);
  2101.  
  2102. /* FIXME: gpio_hw_reset is present in 2.6 but missing in 3.5 */
  2103. /* if (system_rev > 0x1300) {
  2104. mmc[0].hw_reset_connected = 1;
  2105. mmc[0].gpio_hw_reset = 39;
  2106. }*/
  2107. omap_hsmmc_init(mmc);
  2108. rm696_ssi_init();
  2109. omap_bt_init(&rm680_bt_config);
  2110. /*} else {
  2111.  
  2112. }*/
  2113. }
  2114.  
  2115. #ifdef CONFIG_OMAP_MUX
  2116. static struct omap_board_mux board_mux[] __initdata = {
  2117. { .reg_offset = OMAP_MUX_TERMINATOR },
  2118. };
  2119. #endif
  2120.  
  2121. static struct omap_musb_board_data rm696_musb_data = {
  2122. .interface_type = MUSB_INTERFACE_ULPI,
  2123. .mode = MUSB_PERIPHERAL,
  2124. .power = 100,
  2125. };
  2126.  
  2127. static int __init rm696_set_l3_opp(void)
  2128. {
  2129. struct device *l3_dev;
  2130. struct clk *sdrc_ck;
  2131. int r = 0;
  2132. int opp1_clk = 0, opp2_clk = 0;
  2133. u32 sdrc_rate;
  2134.  
  2135. l3_dev = omap_device_get_by_hwmod_name("l3_main");
  2136. if (IS_ERR(l3_dev)) {
  2137. pr_err("no l3_dev error\n");
  2138. return -ENODEV;
  2139. }
  2140.  
  2141. /*
  2142. * Adjust L3 OPPs according to the SDRC frequency initialized
  2143. * by the boot loader
  2144. */
  2145. sdrc_ck = clk_get(NULL, "sdrc_ick");
  2146. if (sdrc_ck) {
  2147. sdrc_rate = clk_get_rate(sdrc_ck);
  2148. switch (sdrc_rate) {
  2149. case 185000000:
  2150. opp1_clk = 92500000;
  2151. opp2_clk = 185000000;
  2152. break;
  2153. case 195200000:
  2154. opp1_clk = 97600000;
  2155. opp2_clk = 195200000;
  2156. break;
  2157. case 200000000:
  2158. pr_warning("Running device under out of "
  2159. "spec clocking on L3\n");
  2160. break;
  2161. default:
  2162. pr_warning("Booting with unknown L3 clock\n");
  2163. break;
  2164. }
  2165.  
  2166. if (opp1_clk) {
  2167. /* We need to add new rates*/
  2168. r = opp_add(l3_dev, opp1_clk, 1000000);
  2169. r |= opp_add(l3_dev, opp2_clk, 1200000);
  2170. if (r)
  2171. {
  2172. /* We din't succed in adding new rates */
  2173. pr_warning("failed to add l3 opp\n");
  2174. goto err1;
  2175. }
  2176.  
  2177. /* We now have new rates, let's enable them */
  2178. r = opp_enable(l3_dev, opp1_clk);
  2179. r |= opp_enable(l3_dev, opp2_clk);
  2180. if (r)
  2181. {
  2182. /* We didin't succed in enabling rates */
  2183. pr_warning("failed to enable l3 opp\n");
  2184. goto err2;
  2185. }
  2186.  
  2187. /* New rates are added and enabled, let's disable default ones */
  2188. opp_disable(l3_dev, 100000000);
  2189. opp_disable(l3_dev, 200000000);
  2190.  
  2191. }
  2192. clk_put(sdrc_ck);
  2193. }
  2194.  
  2195. return 0;
  2196. err2:
  2197. opp_disable(l3_dev, opp1_clk);
  2198. opp_disable(l3_dev, opp2_clk);
  2199. err1:
  2200. clk_put(sdrc_ck);
  2201.  
  2202. return r;
  2203. }
  2204.  
  2205. /*
  2206. *
  2207. * HW initialization
  2208. *
  2209. *
  2210. */
  2211. static int __init rm696_sec_camera_init(void)
  2212. {
  2213. if (gpio_request(SEC_CAMERA_RESET_GPIO, "sec_camera reset") != 0) {
  2214. printk(KERN_INFO "%s: unable to acquire secondary "
  2215. "camera reset gpio\n", __func__);
  2216. return -ENODEV;
  2217. }
  2218.  
  2219. /* XSHUTDOWN off, reset */
  2220. gpio_direction_output(SEC_CAMERA_RESET_GPIO, 0);
  2221. gpio_set_value(SEC_CAMERA_RESET_GPIO, 0);
  2222.  
  2223. return 0;
  2224. }
  2225.  
  2226. static int __init rm696_camera_hw_init(void)
  2227. {
  2228. return rm696_sec_camera_init();
  2229. }
  2230.  
  2231. /*
  2232. *
  2233. * Main Camera Module EXTCLK
  2234. * Used by the sensor and the actuator driver.
  2235. *
  2236. */
  2237. static struct camera_xclk {
  2238. u32 hz;
  2239. u32 lock;
  2240. u8 xclksel;
  2241. } cameras_xclk;
  2242.  
  2243. static DEFINE_MUTEX(lock_xclk);
  2244.  
  2245. static int rm696_update_xclk(struct v4l2_subdev *subdev, u32 hz, u32 which,
  2246. u8 xclksel)
  2247. {
  2248. struct isp_device *isp = v4l2_dev_to_isp_device(subdev->v4l2_dev);
  2249. int ret;
  2250.  
  2251. mutex_lock(&lock_xclk);
  2252.  
  2253. if (which == RM696_SEC_SENSOR) {
  2254. if (cameras_xclk.xclksel == MAIN_CAMERA_XCLK) {
  2255. ret = -EBUSY;
  2256. goto done;
  2257. }
  2258. } else {
  2259. if (cameras_xclk.xclksel == SEC_CAMERA_XCLK) {
  2260. ret = -EBUSY;
  2261. goto done;
  2262. }
  2263. }
  2264.  
  2265. if (hz) { /* Turn on */
  2266. cameras_xclk.lock |= which;
  2267. if (cameras_xclk.hz == 0) {
  2268. isp->platform_cb.set_xclk(isp, hz, xclksel);
  2269. cameras_xclk.hz = hz;
  2270. cameras_xclk.xclksel = xclksel;
  2271. }
  2272. } else { /* Turn off */
  2273. cameras_xclk.lock &= ~which;
  2274. if (cameras_xclk.lock == 0) {
  2275. isp->platform_cb.set_xclk(isp, 0, xclksel);
  2276. cameras_xclk.hz = 0;
  2277. cameras_xclk.xclksel = 0;
  2278. }
  2279. }
  2280.  
  2281. ret = cameras_xclk.hz;
  2282.  
  2283. done:
  2284. mutex_unlock(&lock_xclk);
  2285. return ret;
  2286. }
  2287.  
  2288. /*
  2289. *
  2290. * Main Camera Sensor
  2291. *
  2292. */
  2293.  
  2294. static struct isp_csiphy_lanes_cfg rm696_main_camera_csi2_lanecfg = {
  2295. .clk = {
  2296. .pol = 1,
  2297. .pos = 2,
  2298. },
  2299. .data[0] = {
  2300. .pol = 1,
  2301. .pos = 1,
  2302. },
  2303. .data[1] = {
  2304. .pol = 1,
  2305. .pos = 3,
  2306. },
  2307. };
  2308.  
  2309. /*
  2310. * THS_TERM: Programmed value = ceil(12.5 ns/DDRClk period) - 1.
  2311. * THS_SETTLE: Programmed value = ceil(90 ns/DDRClk period) + 3.
  2312. */
  2313. #define THS_TERM_D 2000000
  2314. #define THS_TERM(ddrclk_khz) \
  2315. ( \
  2316. ((25 * (ddrclk_khz)) % THS_TERM_D) ? \
  2317. ((25 * (ddrclk_khz)) / THS_TERM_D) : \
  2318. ((25 * (ddrclk_khz)) / THS_TERM_D) - 1 \
  2319. )
  2320.  
  2321. #define THS_SETTLE_D 1000000
  2322. #define THS_SETTLE(ddrclk_khz) \
  2323. ( \
  2324. ((90 * (ddrclk_khz)) % THS_SETTLE_D) ? \
  2325. ((90 * (ddrclk_khz)) / THS_SETTLE_D) + 4 : \
  2326. ((90 * (ddrclk_khz)) / THS_SETTLE_D) + 3 \
  2327. )
  2328.  
  2329. /*
  2330. * TCLK values are OK at their reset values
  2331. */
  2332. #define TCLK_TERM 0
  2333. #define TCLK_MISS 1
  2334. #define TCLK_SETTLE 14
  2335.  
  2336. static void rm696_main_camera_csi2_configure(struct v4l2_subdev *subdev,
  2337. struct smia_mode *mode)
  2338. {
  2339. struct isp_device *isp = v4l2_dev_to_isp_device(subdev->v4l2_dev);
  2340. struct isp_csiphy_dphy_cfg csi2phy;
  2341. int csi2_ddrclk_khz;
  2342.  
  2343. /*
  2344. * SCM.CONTROL_CAMERA_PHY_CTRL
  2345. * - bit[4] : 0 CSIPHY1 data sent to CSIB
  2346. * - bit [3:2] : 10 CSIPHY1 in CCP2 Data/Clock Mode
  2347. * - bit [1:0] : 00 CSIPHY2 in D-PHY Mode
  2348. */
  2349. omap_writel(0x08,
  2350. OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL);
  2351.  
  2352. csi2_ddrclk_khz = ((mode->opsys_clock / 1000) /
  2353. (2 * isp->isp_csiphy2.num_data_lanes));
  2354. csi2phy.ths_term = THS_TERM(csi2_ddrclk_khz);
  2355. csi2phy.ths_settle = THS_SETTLE(csi2_ddrclk_khz);
  2356. csi2phy.tclk_term = TCLK_TERM;
  2357. csi2phy.tclk_miss = TCLK_MISS;
  2358. csi2phy.tclk_settle = TCLK_SETTLE;
  2359.  
  2360. isp->platform_cb.csiphy_config(&isp->isp_csiphy2, &csi2phy,
  2361. &rm696_main_camera_csi2_lanecfg);
  2362. }
  2363.  
  2364. static int rm696_main_camera_set_xclk(struct v4l2_subdev *sd, int hz)
  2365. {
  2366. return rm696_update_xclk(sd, hz, RM696_PRI_SENSOR, MAIN_CAMERA_XCLK);
  2367. }
  2368.  
  2369. static struct smiapp_flash_strobe_parms rm696_main_camera_strobe_setup = {
  2370. .mode = 0x0c,
  2371. .strobe_width_high_us = 100000,
  2372. .strobe_delay = 0,
  2373. .stobe_start_point = 0,
  2374. .trigger = 0,
  2375. };
  2376.  
  2377. /*
  2378. * Lada TS samples don't have their own sensors in there yet.
  2379. * Lada TS Toshiba has Toshiba Gambino Sensor
  2380. * Lada TS Fujinon has Sony Gambino Sensor
  2381. *
  2382. * Moreover the SMIA++ registers of model_id and manufacturer_id are
  2383. * not present on the modules yet. Instead we have to use sensor model id
  2384. * and sensor manufacturer id for identification. This should hopefully
  2385. * get resolved with the ES samples.
  2386. *
  2387. * For now provide the translation to the driver from sensor idents to
  2388. * module idents
  2389. *
  2390. * Lada ES1.0 Fujinon has Fujinon Lada Sensor but the SMIA++ registers
  2391. * are still missing.
  2392. *
  2393. * Lada ES1.0 Toshiba has Toshiba Lada sensor and SMIA++ registers are
  2394. * programmed as well
  2395. */
  2396. static const struct smiapp_module_ident rm696_main_camera_idents[] = {
  2397. {
  2398. .sensor_manu_id = 0x0b,
  2399. .sensor_model_id = 0x0088,
  2400. .name = "smiapp-001",
  2401. }, /* Sony Gambino - imx088es */
  2402. {
  2403. .sensor_manu_id = 0x0c,
  2404. .sensor_model_id = 0x218e,
  2405. .name = "smiapp-002",
  2406. }, /* Toshiba Gambino - tcm8596md */
  2407. {
  2408. .sensor_manu_id = 0x0b,
  2409. .sensor_model_id = 0x0125,
  2410. .name = "smiapp-003",
  2411. }, /* Fujinon Lada - imx125 */
  2412. {
  2413. .manu_id = 0x0c,
  2414. .model_id = 0x560f,
  2415. .name = "smiapp-004",
  2416. }, /* Toshiba Lada - jt8ew9 */
  2417. };
  2418.  
  2419. static struct smiapp_module_ident rm696_main_camera;
  2420.  
  2421. static const struct smiapp_module_ident *
  2422. rm696_main_camera_identify_module(const struct smiapp_module_ident *ident_in)
  2423. {
  2424. int i;
  2425.  
  2426. for (i = 0; i < ARRAY_SIZE(rm696_main_camera_idents); i++) {
  2427. if (rm696_main_camera_idents[i].manu_id
  2428. && rm696_main_camera_idents[i].manu_id
  2429. == ident_in->manu_id
  2430. && rm696_main_camera_idents[i].model_id
  2431. == ident_in->model_id)
  2432. break;
  2433. else if (rm696_main_camera_idents[i].sensor_manu_id
  2434. == ident_in->sensor_manu_id
  2435. && rm696_main_camera_idents[i].sensor_model_id
  2436. == ident_in->sensor_model_id)
  2437. break;
  2438. }
  2439.  
  2440. if (i >= ARRAY_SIZE(rm696_main_camera_idents))
  2441. return NULL;
  2442.  
  2443. /*
  2444. * if manu_id and model_id are missing, copy over the corresponding
  2445. * sensor_manu_id and sensor_model_id to keep the smiapp driver going
  2446. */
  2447. rm696_main_camera = rm696_main_camera_idents[i];
  2448. if (!rm696_main_camera.manu_id) {
  2449. rm696_main_camera.manu_id = rm696_main_camera.sensor_manu_id;
  2450. rm696_main_camera.model_id = rm696_main_camera.sensor_model_id;
  2451. }
  2452.  
  2453. return &rm696_main_camera;
  2454. }
  2455.  
  2456. static int rm696_get_analog_gain_limits(const struct smiapp_module_ident *ident,
  2457. u32 *min, u32 *max, u32 *step)
  2458. {
  2459. if (ident->manu_id == 0x0c && ident->model_id == 0x218e) {
  2460. /* Toshiba Gambino - tcm8596md */
  2461. *min = 69; /* Below 27 gain doesn't have effect at all, */
  2462. *max = 1858; /* but ~69 is needed for full dynamic range */
  2463. *step = 1;
  2464. } else if (ident->manu_id == 0x0c && ident->model_id == 0x560f) {
  2465. /* Toshiba Lada - jt8ew9 */
  2466. *min = 59; /* Below 24 gain doesn't have effect at all, */
  2467. *max = 6000; /* but ~59 is needed for full dynamic range */
  2468. *step = 1;
  2469. } else
  2470. return -ENOSYS;
  2471.  
  2472. return 0;
  2473. }
  2474.  
  2475. static struct smiapp_platform_data rm696_main_camera_platform_data = {
  2476. .i2c_addr_dfl = SMIAPP_DFL_I2C_ADDR,
  2477. .i2c_addr_alt = SMIAPP_ALT_I2C_ADDR,
  2478. .nvm_size = 16 * 64,
  2479. .ext_clk = (9.6 * 1000 * 1000),
  2480. .identify_module = rm696_main_camera_identify_module,
  2481. .get_analog_gain_limits = rm696_get_analog_gain_limits,
  2482. .strobe_setup = &rm696_main_camera_strobe_setup,
  2483. .csi_configure = rm696_main_camera_csi2_configure,
  2484. .set_xclk = rm696_main_camera_set_xclk,
  2485. };
  2486.  
  2487. /*
  2488. *
  2489. * Main Camera Actuator Driver
  2490. *
  2491. */
  2492.  
  2493. static int rm696_lens_use_iclk(void)
  2494. {
  2495. /*
  2496. * Lada Toshiba camera modules (smiapp-004), which have an AD5817 lens
  2497. * actuator driver should use the internal 19.2 MHz clock generator for
  2498. * PWM drive mode.
  2499. */
  2500. if (rm696_main_camera.manu_id == 0xc &&
  2501. rm696_main_camera.model_id == 0x560f)
  2502. return 1;
  2503.  
  2504. return 0;
  2505. }
  2506.  
  2507. static int rm696_lens_use_protection(void)
  2508. {
  2509. /*
  2510. * Lada Toshiba camera modules (smiapp-004), which have an AD5817 lens
  2511. * actuator driver should enable over-current, low-battery and
  2512. * over-temperature protection.
  2513. */
  2514. if (rm696_main_camera.manu_id == 0xc &&
  2515. rm696_main_camera.model_id == 0x560f)
  2516. return 1;
  2517.  
  2518. return 0;
  2519. }
  2520.  
  2521. static int rm696_lens_set_xclk(struct v4l2_subdev *sd, u32 hz)
  2522. {
  2523. return rm696_update_xclk(sd, hz, RM696_PRI_LENS, MAIN_CAMERA_XCLK);
  2524. }
  2525.  
  2526. /* When no activity on EXTCLK, the AD5836 enters power-down mode */
  2527. static struct ad58xx_platform_data rm696_ad5836_platform_data = {
  2528. .ext_clk = (9.6 * 1000 * 1000),
  2529. .set_xclk = rm696_lens_set_xclk,
  2530. .use_iclk = rm696_lens_use_iclk,
  2531. .use_protection = rm696_lens_use_protection
  2532. };
  2533.  
  2534. /*
  2535. * Main Camera Flash
  2536. */
  2537.  
  2538. static void rm696_as3645a_setup_ext_strobe(int enable)
  2539. {
  2540. if (enable)
  2541. rm696_main_camera_platform_data.strobe_setup->trigger = 1;
  2542. else
  2543. rm696_main_camera_platform_data.strobe_setup->trigger = 0;
  2544. }
  2545.  
  2546. static void rm696_as3645a_set_strobe_width(u32 width_in_us)
  2547. {
  2548. rm696_main_camera_platform_data.strobe_setup->strobe_width_high_us =
  2549. width_in_us;
  2550. }
  2551.  
  2552. static struct as3645a_flash_torch_parms rm696_main_camera_flash_setup = {
  2553. .flash_min_current = 200,
  2554. .flash_max_current = 320,
  2555. .torch_min_current = 20,
  2556. .torch_max_current = 60,
  2557. .timeout_min = 100000,
  2558. .timeout_max = 150000,
  2559. };
  2560.  
  2561. static struct as3645a_platform_data rm696_as3645a_platform_data = {
  2562. .num_leds = 2,
  2563. .use_ext_flash_strobe = 1,
  2564. .setup_ext_strobe = rm696_as3645a_setup_ext_strobe,
  2565. .set_strobe_width = rm696_as3645a_set_strobe_width,
  2566. .flash_torch_limits = &rm696_main_camera_flash_setup,
  2567. };
  2568.  
  2569. /*
  2570. *
  2571. * SECONDARY CAMERA Sensor
  2572. *
  2573. */
  2574.  
  2575. #define SEC_CAMERA_XCLK ISP_XCLK_B
  2576.  
  2577. static struct isp_csiphy_lanes_cfg rm696_sec_camera_csiphy_lanecfg = {
  2578. .clk = {
  2579. .pol = 0,
  2580. .pos = 1,
  2581. },
  2582. .data[0] = {
  2583. .pol = 0,
  2584. .pos = 2,
  2585. },
  2586. };
  2587.  
  2588. static void rm696_sec_camera_configure_interface(struct v4l2_subdev *subdev,
  2589. struct smia_mode *mode)
  2590. {
  2591. struct isp_device *isp = v4l2_dev_to_isp_device(subdev->v4l2_dev);
  2592. struct isp_csiphy_dphy_cfg dummy_phy;
  2593.  
  2594. /*
  2595. * SCM.CONTROL_CAMERA_PHY_CTRL
  2596. * - bit[4] : 0 CSIPHY1 data sent to CSIB
  2597. * - bit [3:2] : 10 CSIPHY1 in CCP2 Data/Clock Mode
  2598. * - bit [1:0] : 00 CSIPHY2 in D-PHY Mode
  2599. */
  2600. omap_writel(0x08,
  2601. OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL);
  2602.  
  2603. memset(&dummy_phy, 0, sizeof(dummy_phy));
  2604. isp->platform_cb.csiphy_config(&isp->isp_csiphy1, &dummy_phy,
  2605. &rm696_sec_camera_csiphy_lanecfg);
  2606. }
  2607.  
  2608. static int rm696_sec_camera_set_xclk(struct v4l2_subdev *sd, int hz)
  2609. {
  2610. return rm696_update_xclk(sd, hz, RM696_SEC_SENSOR, SEC_CAMERA_XCLK);
  2611. }
  2612.  
  2613. static int rm696_sec_camera_set_xshutdown(struct v4l2_subdev *subdev, u8 set)
  2614. {
  2615. gpio_set_value(SEC_CAMERA_RESET_GPIO, !!set);
  2616. return 0;
  2617. }
  2618.  
  2619. static struct smiapp_platform_data rm696_sec_camera_platform_data = {
  2620. .ext_clk = (10.8 * 1000 * 1000),
  2621. .module_board_orient = SMIAPP_MODULE_BOARD_ORIENT_180,
  2622. .csi_configure = rm696_sec_camera_configure_interface,
  2623. .set_xclk = rm696_sec_camera_set_xclk,
  2624. .set_xshutdown = rm696_sec_camera_set_xshutdown,
  2625. };
  2626.  
  2627. /*
  2628. *
  2629. * Init all the modules
  2630. *
  2631. */
  2632.  
  2633. #define CAMERA_I2C_BUS_NUM 2
  2634. #define AD5836_I2C_BUS_NUM 2
  2635. #define AS3645A_I2C_BUS_NUM 2
  2636.  
  2637. static struct i2c_board_info rm696_camera_i2c_devices[] = {
  2638. {
  2639. I2C_BOARD_INFO(SMIAPP_NAME, SMIAPP_ALT_I2C_ADDR),
  2640. .platform_data = &rm696_main_camera_platform_data,
  2641. },
  2642. {
  2643. I2C_BOARD_INFO(AD58XX_NAME, AD58XX_I2C_ADDR),
  2644. .platform_data = &rm696_ad5836_platform_data,
  2645. },
  2646. {
  2647. I2C_BOARD_INFO(AS3645A_NAME, AS3645A_I2C_ADDR),
  2648. .platform_data = &rm696_as3645a_platform_data,
  2649. },
  2650. {
  2651. I2C_BOARD_INFO(SMIAPP_NAME, SMIAPP_DFL_I2C_ADDR),
  2652. .platform_data = &rm696_sec_camera_platform_data,
  2653. },
  2654. };
  2655.  
  2656. static struct isp_subdev_i2c_board_info rm696_camera_primary_subdevs[] = {
  2657. {
  2658. .board_info = &rm696_camera_i2c_devices[0],
  2659. .i2c_adapter_id = CAMERA_I2C_BUS_NUM,
  2660. },
  2661. {
  2662. .board_info = &rm696_camera_i2c_devices[1],
  2663. .i2c_adapter_id = AD5836_I2C_BUS_NUM,
  2664. },
  2665. {
  2666. .board_info = &rm696_camera_i2c_devices[2],
  2667. .i2c_adapter_id = AS3645A_I2C_BUS_NUM,
  2668. },
  2669. { NULL, 0, },
  2670. };
  2671.  
  2672. static struct isp_subdev_i2c_board_info rm696_camera_secondary_subdevs[] = {
  2673. {
  2674. .board_info = &rm696_camera_i2c_devices[3],
  2675. .i2c_adapter_id = CAMERA_I2C_BUS_NUM,
  2676. },
  2677. { NULL, 0, },
  2678. };
  2679.  
  2680. static struct isp_v4l2_subdevs_group rm696_camera_subdevs[] = {
  2681. {
  2682. .subdevs = rm696_camera_primary_subdevs,
  2683. .interface = ISP_INTERFACE_CSI2A_PHY2,
  2684. .bus = { .csi2 = {
  2685. .crc = 1,
  2686. .vpclk_div = 1,
  2687. } },
  2688. },
  2689. {
  2690. .subdevs = rm696_camera_secondary_subdevs,
  2691. .interface = ISP_INTERFACE_CCP2B_PHY1,
  2692. .bus = { .ccp2 = {
  2693. .strobe_clk_pol = 0,
  2694. .crc = 0,
  2695. .ccp2_mode = 0,
  2696. .phy_layer = 0,
  2697. .vpclk_div = 2,
  2698. } },
  2699. },
  2700. { NULL, 0, },
  2701. };
  2702.  
  2703. static struct isp_platform_data rm696_isp_platform_data = {
  2704. .subdevs = rm696_camera_subdevs,
  2705. };
  2706.  
  2707. void __init rm696_camera_init(void)
  2708. {
  2709. int rval;
  2710.  
  2711. rval = rm696_camera_hw_init();
  2712. if (rval) {
  2713. printk(KERN_WARNING "%s: unable to initialise camera\n",
  2714. __func__);
  2715. return;
  2716. }
  2717.  
  2718. if (omap3_init_camera(&rm696_isp_platform_data) < 0)
  2719. printk(KERN_WARNING
  2720. "%s: unable to register camera platform device\n",
  2721. __func__);
  2722. }
  2723.  
  2724. void __init rm680_camera_init(void)
  2725. {
  2726. //TODO
  2727. }
  2728.  
  2729. static inline void board_serial_init(void)
  2730. {
  2731. struct omap_board_data bdata;
  2732.  
  2733. bdata.flags = 0;
  2734. bdata.pads = NULL;
  2735. bdata.pads_cnt = 0;
  2736.  
  2737. bdata.id = 2; //UART3
  2738. omap_serial_init_port(&bdata, NULL);
  2739. }
  2740.  
  2741. static void __init rm680_init(void)
  2742. {
  2743. struct omap_sdrc_params *sdrc_params;
  2744.  
  2745. pr_info("RM-680/696 board, rev %04x\n", system_rev);
  2746. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  2747. board_serial_init();
  2748.  
  2749. sdrc_params = nokia_get_sdram_timings();
  2750. omap_sdrc_init(sdrc_params, sdrc_params);
  2751.  
  2752. rm696_set_l3_opp();
  2753.  
  2754. usb_musb_init(&rm696_musb_data);
  2755. rm680_peripherals_init();
  2756. if (!board_is_rm680()) {
  2757. rm696_camera_init();
  2758. } else {
  2759. rm680_camera_init();
  2760. }
  2761.  
  2762. /* Ensure SDRC pins are mux'd for self-refresh */
  2763. omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
  2764. omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
  2765.  
  2766. rm696_audio_init();
  2767. rm696_tlv320dac33_init();
  2768. rm696_wl1273_init();
  2769. }
  2770.  
  2771. static void __init rx680_reserve(void)
  2772. {
  2773. omap_vram_set_sdram_vram(PAGE_ALIGN(856 * 512 * 4 * 3) +
  2774. PAGE_ALIGN(1280 * 720 * 4 * 6), 0);
  2775. omap_reserve();
  2776. }
  2777.  
  2778. MACHINE_START(NOKIA_RM680, "Nokia RM-680 board")
  2779. .atag_offset = 0x100,
  2780. .reserve = rx680_reserve,
  2781. .map_io = omap3_map_io,
  2782. .init_early = omap3630_init_early,
  2783. .init_irq = omap3_init_irq,
  2784. .handle_irq = omap3_intc_handle_irq,
  2785. .init_machine = rm680_init,
  2786. .init_late = omap3630_init_late,
  2787. .timer = &omap3_timer,
  2788. .restart = omap_prcm_restart,
  2789. MACHINE_END
  2790.  
  2791. MACHINE_START(NOKIA_RM696, "Nokia RM-696 board")
  2792. .atag_offset = 0x100,
  2793. .reserve = rx680_reserve,
  2794. .map_io = omap3_map_io,
  2795. .init_early = omap3630_init_early,
  2796. .init_irq = omap3_init_irq,
  2797. .handle_irq = omap3_intc_handle_irq,
  2798. .init_machine = rm680_init,
  2799. .init_late = omap3630_init_late,
  2800. .timer = &omap3_timer,
  2801. .restart = omap_prcm_restart,
  2802. MACHINE_END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement