environmentalTemperatureAnalysis.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. /*
  2. * CompuLab CM-T35/CM-T3730 modules support
  3. *
  4. * Copyright (C) 2009-2011 CompuLab, Ltd.
  5. * Authors: Mike Rapoport <mike@compulab.co.il>
  6. * Igor Grinberg <grinberg@compulab.co.il>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * version 2 as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. */
  18. #include <linux/kernel.h>
  19. #include <linux/init.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/input.h>
  22. #include <linux/input/matrix_keypad.h>
  23. #include <linux/delay.h>
  24. #include <linux/gpio.h>
  25. #include <linux/platform_data/gpio-omap.h>
  26. #include <linux/i2c/at24.h>
  27. #include <linux/i2c/twl.h>
  28. #include <linux/regulator/fixed.h>
  29. #include <linux/regulator/machine.h>
  30. #include <linux/mmc/host.h>
  31. #include <linux/spi/spi.h>
  32. #include <linux/spi/tdo24m.h>
  33. #include <asm/mach-types.h>
  34. #include <asm/mach/arch.h>
  35. #include <asm/mach/map.h>
  36. #include <linux/platform_data/mtd-nand-omap2.h>
  37. #include <video/omapdss.h>
  38. #include <video/omap-panel-generic-dpi.h>
  39. #include <video/omap-panel-tfp410.h>
  40. #include <linux/platform_data/spi-omap2-mcspi.h>
  41. #include "common.h"
  42. #include "mux.h"
  43. #include "sdram-micron-mt46h32m32lf-6.h"
  44. #include "hsmmc.h"
  45. #include "common-board-devices.h"
  46. #include "gpmc.h"
  47. #include "gpmc-nand.h"
  48. #define CM_T35_GPIO_PENDOWN 57
  49. #define SB_T35_USB_HUB_RESET_GPIO 167
  50. #define CM_T35_SMSC911X_CS 5
  51. #define CM_T35_SMSC911X_GPIO 163
  52. #define SB_T35_SMSC911X_CS 4
  53. #define SB_T35_SMSC911X_GPIO 65
  54. #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
  55. #include <linux/smsc911x.h>
  56. #include "gpmc-smsc911x.h"
  57. static struct omap_smsc911x_platform_data cm_t35_smsc911x_cfg = {
  58. .id = 0,
  59. .cs = CM_T35_SMSC911X_CS,
  60. .gpio_irq = CM_T35_SMSC911X_GPIO,
  61. .gpio_reset = -EINVAL,
  62. .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
  63. };
  64. static struct omap_smsc911x_platform_data sb_t35_smsc911x_cfg = {
  65. .id = 1,
  66. .cs = SB_T35_SMSC911X_CS,
  67. .gpio_irq = SB_T35_SMSC911X_GPIO,
  68. .gpio_reset = -EINVAL,
  69. .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
  70. };
  71. static struct regulator_consumer_supply cm_t35_smsc911x_supplies[] = {
  72. REGULATOR_SUPPLY("vddvario", "smsc911x.0"),
  73. REGULATOR_SUPPLY("vdd33a", "smsc911x.0"),
  74. };
  75. static struct regulator_consumer_supply sb_t35_smsc911x_supplies[] = {
  76. REGULATOR_SUPPLY("vddvario", "smsc911x.1"),
  77. REGULATOR_SUPPLY("vdd33a", "smsc911x.1"),
  78. };
  79. static void __init cm_t35_init_ethernet(void)
  80. {
  81. regulator_register_fixed(0, cm_t35_smsc911x_supplies,
  82. ARRAY_SIZE(cm_t35_smsc911x_supplies));
  83. regulator_register_fixed(1, sb_t35_smsc911x_supplies,
  84. ARRAY_SIZE(sb_t35_smsc911x_supplies));
  85. gpmc_smsc911x_init(&cm_t35_smsc911x_cfg);
  86. gpmc_smsc911x_init(&sb_t35_smsc911x_cfg);
  87. }
  88. #else
  89. static inline void __init cm_t35_init_ethernet(void) { return; }
  90. #endif
  91. #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
  92. #include <linux/leds.h>
  93. static struct gpio_led cm_t35_leds[] = {
  94. [0] = {
  95. .gpio = 186,
  96. .name = "cm-t35:green",
  97. .default_trigger = "heartbeat",
  98. .active_low = 0,
  99. },
  100. };
  101. static struct gpio_led_platform_data cm_t35_led_pdata = {
  102. .num_leds = ARRAY_SIZE(cm_t35_leds),
  103. .leds = cm_t35_leds,
  104. };
  105. static struct platform_device cm_t35_led_device = {
  106. .name = "leds-gpio",
  107. .id = -1,
  108. .dev = {
  109. .platform_data = &cm_t35_led_pdata,
  110. },
  111. };
  112. static void __init cm_t35_init_led(void)
  113. {
  114. platform_device_register(&cm_t35_led_device);
  115. }
  116. #else
  117. static inline void cm_t35_init_led(void) {}
  118. #endif
  119. #if defined(CONFIG_MTD_NAND_OMAP2) || defined(CONFIG_MTD_NAND_OMAP2_MODULE)
  120. #include <linux/mtd/mtd.h>
  121. #include <linux/mtd/nand.h>
  122. #include <linux/mtd/partitions.h>
  123. static struct mtd_partition cm_t35_nand_partitions[] = {
  124. {
  125. .name = "xloader",
  126. .offset = 0, /* Offset = 0x00000 */
  127. .size = 4 * NAND_BLOCK_SIZE,
  128. .mask_flags = MTD_WRITEABLE
  129. },
  130. {
  131. .name = "uboot",
  132. .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
  133. .size = 15 * NAND_BLOCK_SIZE,
  134. },
  135. {
  136. .name = "uboot environment",
  137. .offset = MTDPART_OFS_APPEND, /* Offset = 0x260000 */
  138. .size = 2 * NAND_BLOCK_SIZE,
  139. },
  140. {
  141. .name = "linux",
  142. .offset = MTDPART_OFS_APPEND, /* Offset = 0x2A0000 */
  143. .size = 32 * NAND_BLOCK_SIZE,
  144. },
  145. {
  146. .name = "rootfs",
  147. .offset = MTDPART_OFS_APPEND, /* Offset = 0x6A0000 */
  148. .size = MTDPART_SIZ_FULL,
  149. },
  150. };
  151. static struct omap_nand_platform_data cm_t35_nand_data = {
  152. .parts = cm_t35_nand_partitions,
  153. .nr_parts = ARRAY_SIZE(cm_t35_nand_partitions),
  154. .cs = 0,
  155. };
  156. static void __init cm_t35_init_nand(void)
  157. {
  158. if (gpmc_nand_init(&cm_t35_nand_data, NULL) < 0)
  159. pr_err("CM-T35: Unable to register NAND device\n");
  160. }
  161. #else
  162. static inline void cm_t35_init_nand(void) {}
  163. #endif
  164. #define CM_T35_LCD_EN_GPIO 157
  165. #define CM_T35_LCD_BL_GPIO 58
  166. #define CM_T35_DVI_EN_GPIO 54
  167. static int lcd_enabled;
  168. static int dvi_enabled;
  169. static int cm_t35_panel_enable_lcd(struct omap_dss_device *dssdev)
  170. {
  171. if (dvi_enabled) {
  172. printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
  173. return -EINVAL;
  174. }
  175. gpio_set_value(CM_T35_LCD_EN_GPIO, 1);
  176. gpio_set_value(CM_T35_LCD_BL_GPIO, 1);
  177. lcd_enabled = 1;
  178. return 0;
  179. }
  180. static void cm_t35_panel_disable_lcd(struct omap_dss_device *dssdev)
  181. {
  182. lcd_enabled = 0;
  183. gpio_set_value(CM_T35_LCD_BL_GPIO, 0);
  184. gpio_set_value(CM_T35_LCD_EN_GPIO, 0);
  185. }
  186. static int cm_t35_panel_enable_tv(struct omap_dss_device *dssdev)
  187. {
  188. return 0;
  189. }
  190. static void cm_t35_panel_disable_tv(struct omap_dss_device *dssdev)
  191. {
  192. }
  193. static struct panel_generic_dpi_data lcd_panel = {
  194. .name = "toppoly_tdo35s",
  195. .platform_enable = cm_t35_panel_enable_lcd,
  196. .platform_disable = cm_t35_panel_disable_lcd,
  197. };
  198. static struct omap_dss_device cm_t35_lcd_device = {
  199. .name = "lcd",
  200. .type = OMAP_DISPLAY_TYPE_DPI,
  201. .driver_name = "generic_dpi_panel",
  202. .data = &lcd_panel,
  203. .phy.dpi.data_lines = 18,
  204. };
  205. static struct tfp410_platform_data dvi_panel = {
  206. .power_down_gpio = CM_T35_DVI_EN_GPIO,
  207. .i2c_bus_num = -1,
  208. };
  209. static struct omap_dss_device cm_t35_dvi_device = {
  210. .name = "dvi",
  211. .type = OMAP_DISPLAY_TYPE_DPI,
  212. .driver_name = "tfp410",
  213. .data = &dvi_panel,
  214. .phy.dpi.data_lines = 24,
  215. };
  216. static struct omap_dss_device cm_t35_tv_device = {
  217. .name = "tv",
  218. .driver_name = "venc",
  219. .type = OMAP_DISPLAY_TYPE_VENC,
  220. .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
  221. .platform_enable = cm_t35_panel_enable_tv,
  222. .platform_disable = cm_t35_panel_disable_tv,
  223. };
  224. static struct omap_dss_device *cm_t35_dss_devices[] = {
  225. &cm_t35_lcd_device,
  226. &cm_t35_dvi_device,
  227. &cm_t35_tv_device,
  228. };
  229. static struct omap_dss_board_info cm_t35_dss_data = {
  230. .num_devices = ARRAY_SIZE(cm_t35_dss_devices),
  231. .devices = cm_t35_dss_devices,
  232. .default_device = &cm_t35_dvi_device,
  233. };
  234. static struct omap2_mcspi_device_config tdo24m_mcspi_config = {
  235. .turbo_mode = 0,
  236. };
  237. static struct tdo24m_platform_data tdo24m_config = {
  238. .model = TDO35S,
  239. };
  240. static struct spi_board_info cm_t35_lcd_spi_board_info[] __initdata = {
  241. {
  242. .modalias = "tdo24m",
  243. .bus_num = 4,
  244. .chip_select = 0,
  245. .max_speed_hz = 1000000,
  246. .controller_data = &tdo24m_mcspi_config,
  247. .platform_data = &tdo24m_config,
  248. },
  249. };
  250. static struct gpio cm_t35_dss_gpios[] __initdata = {
  251. { CM_T35_LCD_EN_GPIO, GPIOF_OUT_INIT_LOW, "lcd enable" },
  252. { CM_T35_LCD_BL_GPIO, GPIOF_OUT_INIT_LOW, "lcd bl enable" },
  253. };
  254. static void __init cm_t35_init_display(void)
  255. {
  256. int err;
  257. spi_register_board_info(cm_t35_lcd_spi_board_info,
  258. ARRAY_SIZE(cm_t35_lcd_spi_board_info));
  259. err = gpio_request_array(cm_t35_dss_gpios,
  260. ARRAY_SIZE(cm_t35_dss_gpios));
  261. if (err) {
  262. pr_err("CM-T35: failed to request DSS control GPIOs\n");
  263. return;
  264. }
  265. gpio_export(CM_T35_LCD_EN_GPIO, 0);
  266. gpio_export(CM_T35_LCD_BL_GPIO, 0);
  267. msleep(50);
  268. gpio_set_value(CM_T35_LCD_EN_GPIO, 1);
  269. err = omap_display_init(&cm_t35_dss_data);
  270. if (err) {
  271. pr_err("CM-T35: failed to register DSS device\n");
  272. gpio_free_array(cm_t35_dss_gpios, ARRAY_SIZE(cm_t35_dss_gpios));
  273. }
  274. }
  275. static struct regulator_consumer_supply cm_t35_vmmc1_supply[] = {
  276. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
  277. };
  278. static struct regulator_consumer_supply cm_t35_vsim_supply[] = {
  279. REGULATOR_SUPPLY("vmmc_aux", "omap_hsmmc.0"),
  280. };
  281. static struct regulator_consumer_supply cm_t35_vio_supplies[] = {
  282. REGULATOR_SUPPLY("vcc", "spi1.0"),
  283. REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
  284. REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi1"),
  285. };
  286. /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
  287. static struct regulator_init_data cm_t35_vmmc1 = {
  288. .constraints = {
  289. .min_uV = 1850000,
  290. .max_uV = 3150000,
  291. .valid_modes_mask = REGULATOR_MODE_NORMAL
  292. | REGULATOR_MODE_STANDBY,
  293. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  294. | REGULATOR_CHANGE_MODE
  295. | REGULATOR_CHANGE_STATUS,
  296. },
  297. .num_consumer_supplies = ARRAY_SIZE(cm_t35_vmmc1_supply),
  298. .consumer_supplies = cm_t35_vmmc1_supply,
  299. };
  300. /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
  301. static struct regulator_init_data cm_t35_vsim = {
  302. .constraints = {
  303. .min_uV = 1800000,
  304. .max_uV = 3000000,
  305. .valid_modes_mask = REGULATOR_MODE_NORMAL
  306. | REGULATOR_MODE_STANDBY,
  307. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  308. | REGULATOR_CHANGE_MODE
  309. | REGULATOR_CHANGE_STATUS,
  310. },
  311. .num_consumer_supplies = ARRAY_SIZE(cm_t35_vsim_supply),
  312. .consumer_supplies = cm_t35_vsim_supply,
  313. };
  314. static struct regulator_init_data cm_t35_vio = {
  315. .constraints = {
  316. .min_uV = 1800000,
  317. .max_uV = 1800000,
  318. .apply_uV = true,
  319. .valid_modes_mask = REGULATOR_MODE_NORMAL
  320. | REGULATOR_MODE_STANDBY,
  321. .valid_ops_mask = REGULATOR_CHANGE_MODE,
  322. },
  323. .num_consumer_supplies = ARRAY_SIZE(cm_t35_vio_supplies),
  324. .consumer_supplies = cm_t35_vio_supplies,
  325. };
  326. static uint32_t cm_t35_keymap[] = {
  327. KEY(0, 0, KEY_A), KEY(0, 1, KEY_B), KEY(0, 2, KEY_LEFT),
  328. KEY(1, 0, KEY_UP), KEY(1, 1, KEY_ENTER), KEY(1, 2, KEY_DOWN),
  329. KEY(2, 0, KEY_RIGHT), KEY(2, 1, KEY_C), KEY(2, 2, KEY_D),
  330. };
  331. static struct matrix_keymap_data cm_t35_keymap_data = {
  332. .keymap = cm_t35_keymap,
  333. .keymap_size = ARRAY_SIZE(cm_t35_keymap),
  334. };
  335. static struct twl4030_keypad_data cm_t35_kp_data = {
  336. .keymap_data = &cm_t35_keymap_data,
  337. .rows = 3,
  338. .cols = 3,
  339. .rep = 1,
  340. };
  341. static struct omap2_hsmmc_info mmc[] = {
  342. {
  343. .mmc = 1,
  344. .caps = MMC_CAP_4_BIT_DATA,
  345. .gpio_cd = -EINVAL,
  346. .gpio_wp = -EINVAL,
  347. .deferred = true,
  348. },
  349. {
  350. .mmc = 2,
  351. .caps = MMC_CAP_4_BIT_DATA,
  352. .transceiver = 1,
  353. .gpio_cd = -EINVAL,
  354. .gpio_wp = -EINVAL,
  355. .ocr_mask = 0x00100000, /* 3.3V */
  356. },
  357. {} /* Terminator */
  358. };
  359. static struct usbhs_omap_board_data usbhs_bdata __initdata = {
  360. .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
  361. .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
  362. .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
  363. .phy_reset = true,
  364. .reset_gpio_port[0] = OMAP_MAX_GPIO_LINES + 6,
  365. .reset_gpio_port[1] = OMAP_MAX_GPIO_LINES + 7,
  366. .reset_gpio_port[2] = -EINVAL
  367. };
  368. static void __init cm_t35_init_usbh(void)
  369. {
  370. int err;
  371. err = gpio_request_one(SB_T35_USB_HUB_RESET_GPIO,
  372. GPIOF_OUT_INIT_LOW, "usb hub rst");
  373. if (err) {
  374. pr_err("SB-T35: usb hub rst gpio request failed: %d\n", err);
  375. } else {
  376. udelay(10);
  377. gpio_set_value(SB_T35_USB_HUB_RESET_GPIO, 1);
  378. msleep(1);
  379. }
  380. usbhs_init(&usbhs_bdata);
  381. }
  382. static int cm_t35_twl_gpio_setup(struct device *dev, unsigned gpio,
  383. unsigned ngpio)
  384. {
  385. int wlan_rst = gpio + 2;
  386. if (gpio_request_one(wlan_rst, GPIOF_OUT_INIT_HIGH, "WLAN RST") == 0) {
  387. gpio_export(wlan_rst, 0);
  388. udelay(10);
  389. gpio_set_value_cansleep(wlan_rst, 0);
  390. udelay(10);
  391. gpio_set_value_cansleep(wlan_rst, 1);
  392. } else {
  393. pr_err("CM-T35: could not obtain gpio for WiFi reset\n");
  394. }
  395. /* gpio + 0 is "mmc0_cd" (input/IRQ) */
  396. mmc[0].gpio_cd = gpio + 0;
  397. omap_hsmmc_late_init(mmc);
  398. return 0;
  399. }
  400. static struct twl4030_gpio_platform_data cm_t35_gpio_data = {
  401. .setup = cm_t35_twl_gpio_setup,
  402. };
  403. static struct twl4030_power_data cm_t35_power_data = {
  404. .use_poweroff = true,
  405. };
  406. static struct twl4030_platform_data cm_t35_twldata = {
  407. /* platform_data for children goes here */
  408. .keypad = &cm_t35_kp_data,
  409. .gpio = &cm_t35_gpio_data,
  410. .vmmc1 = &cm_t35_vmmc1,
  411. .vsim = &cm_t35_vsim,
  412. .vio = &cm_t35_vio,
  413. .power = &cm_t35_power_data,
  414. };
  415. #if defined(CONFIG_VIDEO_OMAP3) || defined(CONFIG_VIDEO_OMAP3_MODULE)
  416. #include <media/omap3isp.h>
  417. #include "devices.h"
  418. static struct i2c_board_info cm_t35_isp_i2c_boardinfo[] = {
  419. {
  420. I2C_BOARD_INFO("mt9t001", 0x5d),
  421. },
  422. {
  423. I2C_BOARD_INFO("tvp5150", 0x5c),
  424. },
  425. };
  426. static struct isp_subdev_i2c_board_info cm_t35_isp_primary_subdevs[] = {
  427. {
  428. .board_info = &cm_t35_isp_i2c_boardinfo[0],
  429. .i2c_adapter_id = 3,
  430. },
  431. { NULL, 0, },
  432. };
  433. static struct isp_subdev_i2c_board_info cm_t35_isp_secondary_subdevs[] = {
  434. {
  435. .board_info = &cm_t35_isp_i2c_boardinfo[1],
  436. .i2c_adapter_id = 3,
  437. },
  438. { NULL, 0, },
  439. };
  440. static struct isp_v4l2_subdevs_group cm_t35_isp_subdevs[] = {
  441. {
  442. .subdevs = cm_t35_isp_primary_subdevs,
  443. .interface = ISP_INTERFACE_PARALLEL,
  444. .bus = {
  445. .parallel = {
  446. .clk_pol = 1,
  447. },
  448. },
  449. },
  450. {
  451. .subdevs = cm_t35_isp_secondary_subdevs,
  452. .interface = ISP_INTERFACE_PARALLEL,
  453. .bus = {
  454. .parallel = {
  455. .clk_pol = 0,
  456. },
  457. },
  458. },
  459. { NULL, 0, },
  460. };
  461. static struct isp_platform_data cm_t35_isp_pdata = {
  462. .subdevs = cm_t35_isp_subdevs,
  463. };
  464. static void __init cm_t35_init_camera(void)
  465. {
  466. if (omap3_init_camera(&cm_t35_isp_pdata) < 0)