environmentalTemperatureAnalysis.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. {