rtuHydrantCorrelationCalculation.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. /*
  2. * linux/arch/arm/mach-pxa/z2.c
  3. *
  4. * Support for the Zipit Z2 Handheld device.
  5. *
  6. * Copyright (C) 2009-2010 Marek Vasut <marek.vasut@gmail.com>
  7. *
  8. * Based on research and code by: Ken McGuire
  9. * Based on mainstone.c as modified for the Zipit Z2.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. */
  15. #include <linux/platform_device.h>
  16. #include <linux/mtd/mtd.h>
  17. #include <linux/mtd/partitions.h>
  18. #include <linux/pwm_backlight.h>
  19. #include <linux/z2_battery.h>
  20. #include <linux/dma-mapping.h>
  21. #include <linux/spi/spi.h>
  22. #include <linux/spi/pxa2xx_spi.h>
  23. #include <linux/spi/libertas_spi.h>
  24. #include <linux/spi/lms283gf05.h>
  25. #include <linux/power_supply.h>
  26. #include <linux/mtd/physmap.h>
  27. #include <linux/gpio.h>
  28. #include <linux/gpio_keys.h>
  29. #include <linux/delay.h>
  30. #include <linux/regulator/machine.h>
  31. #include <linux/i2c/pxa-i2c.h>
  32. #include <asm/mach-types.h>
  33. #include <asm/mach/arch.h>
  34. #include <mach/pxa27x.h>
  35. #include <mach/mfp-pxa27x.h>
  36. #include <mach/z2.h>
  37. #include <linux/platform_data/video-pxafb.h>
  38. #include <linux/platform_data/mmc-pxamci.h>
  39. #include <linux/platform_data/keypad-pxa27x.h>
  40. #include <mach/pm.h>
  41. #include "generic.h"
  42. #include "devices.h"
  43. /******************************************************************************
  44. * Pin configuration
  45. ******************************************************************************/
  46. static unsigned long z2_pin_config[] = {
  47. /* LCD - 16bpp Active TFT */
  48. GPIO58_LCD_LDD_0,
  49. GPIO59_LCD_LDD_1,
  50. GPIO60_LCD_LDD_2,
  51. GPIO61_LCD_LDD_3,
  52. GPIO62_LCD_LDD_4,
  53. GPIO63_LCD_LDD_5,
  54. GPIO64_LCD_LDD_6,
  55. GPIO65_LCD_LDD_7,
  56. GPIO66_LCD_LDD_8,
  57. GPIO67_LCD_LDD_9,
  58. GPIO68_LCD_LDD_10,
  59. GPIO69_LCD_LDD_11,
  60. GPIO70_LCD_LDD_12,
  61. GPIO71_LCD_LDD_13,
  62. GPIO72_LCD_LDD_14,
  63. GPIO73_LCD_LDD_15,
  64. GPIO74_LCD_FCLK,
  65. GPIO75_LCD_LCLK,
  66. GPIO76_LCD_PCLK,
  67. GPIO77_LCD_BIAS,
  68. GPIO19_GPIO, /* LCD reset */
  69. GPIO88_GPIO, /* LCD chipselect */
  70. /* PWM */
  71. GPIO115_PWM1_OUT, /* Keypad Backlight */
  72. GPIO11_PWM2_OUT, /* LCD Backlight */
  73. /* MMC */
  74. GPIO32_MMC_CLK,
  75. GPIO112_MMC_CMD,
  76. GPIO92_MMC_DAT_0,
  77. GPIO109_MMC_DAT_1,
  78. GPIO110_MMC_DAT_2,
  79. GPIO111_MMC_DAT_3,
  80. GPIO96_GPIO, /* SD detect */
  81. /* STUART */
  82. GPIO46_STUART_RXD,
  83. GPIO47_STUART_TXD,
  84. /* Keypad */
  85. GPIO100_KP_MKIN_0,
  86. GPIO101_KP_MKIN_1,
  87. GPIO102_KP_MKIN_2,
  88. GPIO34_KP_MKIN_3,
  89. GPIO38_KP_MKIN_4,
  90. GPIO16_KP_MKIN_5,
  91. GPIO17_KP_MKIN_6,
  92. GPIO103_KP_MKOUT_0,
  93. GPIO104_KP_MKOUT_1,
  94. GPIO105_KP_MKOUT_2,
  95. GPIO106_KP_MKOUT_3,
  96. GPIO107_KP_MKOUT_4,
  97. GPIO108_KP_MKOUT_5,
  98. GPIO35_KP_MKOUT_6,
  99. GPIO41_KP_MKOUT_7,
  100. /* I2C */
  101. GPIO117_I2C_SCL,
  102. GPIO118_I2C_SDA,
  103. /* SSP1 */
  104. GPIO23_SSP1_SCLK, /* SSP1_SCK */
  105. GPIO25_SSP1_TXD, /* SSP1_TXD */
  106. GPIO26_SSP1_RXD, /* SSP1_RXD */
  107. /* SSP2 */
  108. GPIO22_SSP2_SCLK, /* SSP2_SCK */
  109. GPIO13_SSP2_TXD, /* SSP2_TXD */
  110. GPIO40_SSP2_RXD, /* SSP2_RXD */
  111. /* LEDs */
  112. GPIO10_GPIO, /* WiFi LED */
  113. GPIO83_GPIO, /* Charging LED */
  114. GPIO85_GPIO, /* Charged LED */
  115. /* I2S */
  116. GPIO28_I2S_BITCLK_OUT,
  117. GPIO29_I2S_SDATA_IN,
  118. GPIO30_I2S_SDATA_OUT,
  119. GPIO31_I2S_SYNC,
  120. GPIO113_I2S_SYSCLK,
  121. /* MISC */
  122. GPIO0_GPIO, /* AC power detect */
  123. GPIO1_GPIO, /* Power button */
  124. GPIO37_GPIO, /* Headphone detect */
  125. GPIO98_GPIO, /* Lid switch */
  126. GPIO14_GPIO, /* WiFi Power */
  127. GPIO24_GPIO, /* WiFi CS */
  128. GPIO36_GPIO, /* WiFi IRQ */
  129. GPIO88_GPIO, /* LCD CS */
  130. };
  131. /******************************************************************************
  132. * NOR Flash
  133. ******************************************************************************/
  134. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  135. static struct resource z2_flash_resource = {
  136. .start = PXA_CS0_PHYS,
  137. .end = PXA_CS0_PHYS + SZ_8M - 1,
  138. .flags = IORESOURCE_MEM,
  139. };
  140. static struct mtd_partition z2_flash_parts[] = {
  141. {
  142. .name = "U-Boot Bootloader",
  143. .offset = 0x0,
  144. .size = 0x40000,
  145. }, {
  146. .name = "U-Boot Environment",
  147. .offset = 0x40000,
  148. .size = 0x20000,
  149. }, {
  150. .name = "Flash",
  151. .offset = 0x60000,
  152. .size = MTDPART_SIZ_FULL,
  153. },
  154. };
  155. static struct physmap_flash_data z2_flash_data = {
  156. .width = 2,
  157. .parts = z2_flash_parts,
  158. .nr_parts = ARRAY_SIZE(z2_flash_parts),
  159. };
  160. static struct platform_device z2_flash = {
  161. .name = "physmap-flash",
  162. .id = -1,
  163. .resource = &z2_flash_resource,
  164. .num_resources = 1,
  165. .dev = {
  166. .platform_data = &z2_flash_data,
  167. },
  168. };
  169. static void __init z2_nor_init(void)
  170. {
  171. platform_device_register(&z2_flash);
  172. }
  173. #else
  174. static inline void z2_nor_init(void) {}
  175. #endif
  176. /******************************************************************************
  177. * Backlight
  178. ******************************************************************************/
  179. #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
  180. static struct platform_pwm_backlight_data z2_backlight_data[] = {
  181. [0] = {
  182. /* Keypad Backlight */
  183. .pwm_id = 1,
  184. .max_brightness = 1023,
  185. .dft_brightness = 0,
  186. .pwm_period_ns = 1260320,
  187. },
  188. [1] = {
  189. /* LCD Backlight */
  190. .pwm_id = 2,
  191. .max_brightness = 1023,
  192. .dft_brightness = 512,
  193. .pwm_period_ns = 1260320,
  194. },
  195. };
  196. static struct platform_device z2_backlight_devices[2] = {
  197. {
  198. .name = "pwm-backlight",
  199. .id = 0,
  200. .dev = {
  201. .platform_data = &z2_backlight_data[1],
  202. },
  203. },
  204. {
  205. .name = "pwm-backlight",
  206. .id = 1,
  207. .dev = {
  208. .platform_data = &z2_backlight_data[0],
  209. },
  210. },
  211. };
  212. static void __init z2_pwm_init(void)
  213. {
  214. platform_device_register(&z2_backlight_devices[0]);
  215. platform_device_register(&z2_backlight_devices[1]);
  216. }
  217. #else
  218. static inline void z2_pwm_init(void) {}
  219. #endif
  220. /******************************************************************************
  221. * Framebuffer
  222. ******************************************************************************/
  223. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  224. static struct pxafb_mode_info z2_lcd_modes[] = {
  225. {
  226. .pixclock = 192000,
  227. .xres = 240,
  228. .yres = 320,
  229. .bpp = 16,
  230. .left_margin = 4,
  231. .right_margin = 8,
  232. .upper_margin = 4,
  233. .lower_margin = 8,
  234. .hsync_len = 4,
  235. .vsync_len = 4,
  236. },
  237. };
  238. static struct pxafb_mach_info z2_lcd_screen = {
  239. .modes = z2_lcd_modes,
  240. .num_modes = ARRAY_SIZE(z2_lcd_modes),
  241. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_BIAS_ACTIVE_LOW |
  242. LCD_ALTERNATE_MAPPING,
  243. };
  244. static void __init z2_lcd_init(void)
  245. {
  246. pxa_set_fb_info(NULL, &z2_lcd_screen);
  247. }
  248. #else
  249. static inline void z2_lcd_init(void) {}
  250. #endif
  251. /******************************************************************************
  252. * SD/MMC card controller
  253. ******************************************************************************/
  254. #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
  255. static struct pxamci_platform_data z2_mci_platform_data = {
  256. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  257. .gpio_card_detect = GPIO96_ZIPITZ2_SD_DETECT,
  258. .gpio_power = -1,
  259. .gpio_card_ro = -1,
  260. .detect_delay_ms = 200,
  261. };
  262. static void __init z2_mmc_init(void)
  263. {
  264. pxa_set_mci_info(&z2_mci_platform_data);
  265. }
  266. #else
  267. static inline void z2_mmc_init(void) {}
  268. #endif
  269. /******************************************************************************
  270. * LEDs
  271. ******************************************************************************/
  272. #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
  273. struct gpio_led z2_gpio_leds[] = {
  274. {
  275. .name = "z2:green:wifi",
  276. .default_trigger = "none",
  277. .gpio = GPIO10_ZIPITZ2_LED_WIFI,
  278. .active_low = 1,
  279. }, {