calculationStandardDeviation.c 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. /* linux/arch/arm/mach-s3c64xx/mach-crag6410.c
  2. *
  3. * Copyright 2011 Wolfson Microelectronics plc
  4. * Mark Brown <broonie@opensource.wolfsonmicro.com>
  5. *
  6. * Copyright 2011 Simtec Electronics
  7. * Ben Dooks <ben@simtec.co.uk>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/list.h>
  15. #include <linux/serial_core.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/fb.h>
  18. #include <linux/io.h>
  19. #include <linux/init.h>
  20. #include <linux/gpio.h>
  21. #include <linux/leds.h>
  22. #include <linux/delay.h>
  23. #include <linux/mmc/host.h>
  24. #include <linux/regulator/machine.h>
  25. #include <linux/regulator/fixed.h>
  26. #include <linux/pwm_backlight.h>
  27. #include <linux/dm9000.h>
  28. #include <linux/gpio_keys.h>
  29. #include <linux/basic_mmio_gpio.h>
  30. #include <linux/spi/spi.h>
  31. #include <linux/i2c/pca953x.h>
  32. #include <linux/platform_data/s3c-hsotg.h>
  33. #include <video/platform_lcd.h>
  34. #include <linux/mfd/wm831x/core.h>
  35. #include <linux/mfd/wm831x/pdata.h>
  36. #include <linux/mfd/wm831x/irq.h>
  37. #include <linux/mfd/wm831x/gpio.h>
  38. #include <sound/wm1250-ev1.h>
  39. #include <asm/hardware/vic.h>
  40. #include <asm/mach/arch.h>
  41. #include <asm/mach-types.h>
  42. #include <video/samsung_fimd.h>
  43. #include <mach/hardware.h>
  44. #include <mach/map.h>
  45. #include <mach/regs-sys.h>
  46. #include <mach/regs-gpio.h>
  47. #include <mach/regs-modem.h>
  48. #include <mach/crag6410.h>
  49. #include <mach/regs-gpio-memport.h>
  50. #include <plat/regs-serial.h>
  51. #include <plat/fb.h>
  52. #include <plat/sdhci.h>
  53. #include <plat/gpio-cfg.h>
  54. #include <linux/platform_data/spi-s3c64xx.h>
  55. #include <plat/keypad.h>
  56. #include <plat/clock.h>
  57. #include <plat/devs.h>
  58. #include <plat/cpu.h>
  59. #include <plat/adc.h>
  60. #include <linux/platform_data/i2c-s3c2410.h>
  61. #include <plat/pm.h>
  62. #include "common.h"
  63. /* serial port setup */
  64. #define UCON (S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK)
  65. #define ULCON (S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB)
  66. #define UFCON (S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE)
  67. static struct s3c2410_uartcfg crag6410_uartcfgs[] __initdata = {
  68. [0] = {
  69. .hwport = 0,
  70. .flags = 0,
  71. .ucon = UCON,
  72. .ulcon = ULCON,
  73. .ufcon = UFCON,
  74. },
  75. [1] = {
  76. .hwport = 1,
  77. .flags = 0,
  78. .ucon = UCON,
  79. .ulcon = ULCON,
  80. .ufcon = UFCON,
  81. },
  82. [2] = {
  83. .hwport = 2,
  84. .flags = 0,
  85. .ucon = UCON,
  86. .ulcon = ULCON,
  87. .ufcon = UFCON,
  88. },
  89. [3] = {
  90. .hwport = 3,
  91. .flags = 0,
  92. .ucon = UCON,
  93. .ulcon = ULCON,
  94. .ufcon = UFCON,
  95. },
  96. };
  97. static struct platform_pwm_backlight_data crag6410_backlight_data = {
  98. .pwm_id = 0,
  99. .max_brightness = 1000,
  100. .dft_brightness = 600,
  101. .pwm_period_ns = 100000, /* about 1kHz */
  102. };
  103. static struct platform_device crag6410_backlight_device = {
  104. .name = "pwm-backlight",
  105. .id = -1,
  106. .dev = {
  107. .parent = &s3c_device_timer[0].dev,
  108. .platform_data = &crag6410_backlight_data,
  109. },
  110. };
  111. static void crag6410_lcd_power_set(struct plat_lcd_data *pd, unsigned int power)
  112. {
  113. pr_debug("%s: setting power %d\n", __func__, power);
  114. if (power) {
  115. gpio_set_value(S3C64XX_GPB(0), 1);
  116. msleep(1);
  117. s3c_gpio_cfgpin(S3C64XX_GPF(14), S3C_GPIO_SFN(2));
  118. } else {
  119. gpio_direction_output(S3C64XX_GPF(14), 0);
  120. gpio_set_value(S3C64XX_GPB(0), 0);
  121. }
  122. }
  123. static struct platform_device crag6410_lcd_powerdev = {
  124. .name = "platform-lcd",
  125. .id = -1,
  126. .dev.parent = &s3c_device_fb.dev,
  127. .dev.platform_data = &(struct plat_lcd_data) {
  128. .set_power = crag6410_lcd_power_set,
  129. },
  130. };
  131. /* 640x480 URT */
  132. static struct s3c_fb_pd_win crag6410_fb_win0 = {
  133. .max_bpp = 32,
  134. .default_bpp = 16,
  135. .xres = 640,
  136. .yres = 480,
  137. .virtual_y = 480 * 2,
  138. .virtual_x = 640,
  139. };
  140. static struct fb_videomode crag6410_lcd_timing = {
  141. .left_margin = 150,
  142. .right_margin = 80,
  143. .upper_margin = 40,
  144. .lower_margin = 5,
  145. .hsync_len = 40,
  146. .vsync_len = 5,
  147. .xres = 640,
  148. .yres = 480,
  149. };
  150. /* 405566 clocks per frame => 60Hz refresh requires 24333960Hz clock */
  151. static struct s3c_fb_platdata crag6410_lcd_pdata = {
  152. .setup_gpio = s3c64xx_fb_gpio_setup_24bpp,
  153. .vtiming = &crag6410_lcd_timing,
  154. .win[0] = &crag6410_fb_win0,
  155. .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
  156. .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
  157. };
  158. /* 2x6 keypad */
  159. static uint32_t crag6410_keymap[] = {
  160. /* KEY(row, col, keycode) */
  161. KEY(0, 0, KEY_VOLUMEUP),
  162. KEY(0, 1, KEY_HOME),
  163. KEY(0, 2, KEY_VOLUMEDOWN),
  164. KEY(0, 3, KEY_HELP),
  165. KEY(0, 4, KEY_MENU),
  166. KEY(0, 5, KEY_MEDIA),
  167. KEY(1, 0, 232),
  168. KEY(1, 1, KEY_DOWN),
  169. KEY(1, 2, KEY_LEFT),
  170. KEY(1, 3, KEY_UP),
  171. KEY(1, 4, KEY_RIGHT),
  172. KEY(1, 5, KEY_CAMERA),
  173. };
  174. static struct matrix_keymap_data crag6410_keymap_data = {
  175. .keymap = crag6410_keymap,
  176. .keymap_size = ARRAY_SIZE(crag6410_keymap),
  177. };
  178. static struct samsung_keypad_platdata crag6410_keypad_data = {
  179. .keymap_data = &crag6410_keymap_data,
  180. .rows = 2,
  181. .cols = 6,
  182. };
  183. static struct gpio_keys_button crag6410_gpio_keys[] = {
  184. [0] = {
  185. .code = KEY_SUSPEND,
  186. .gpio = S3C64XX_GPL(10), /* EINT 18 */
  187. .type = EV_KEY,
  188. .wakeup = 1,
  189. .active_low = 1,
  190. },
  191. [1] = {
  192. .code = SW_FRONT_PROXIMITY,
  193. .gpio = S3C64XX_GPN(11), /* EINT 11 */
  194. .type = EV_SW,
  195. },
  196. };
  197. static struct gpio_keys_platform_data crag6410_gpio_keydata = {
  198. .buttons = crag6410_gpio_keys,
  199. .nbuttons = ARRAY_SIZE(crag6410_gpio_keys),
  200. };
  201. static struct platform_device crag6410_gpio_keydev = {
  202. .name = "gpio-keys",
  203. .id = 0,
  204. .dev.platform_data = &crag6410_gpio_keydata,
  205. };
  206. static struct resource crag6410_dm9k_resource[] = {
  207. [0] = DEFINE_RES_MEM(S3C64XX_PA_XM0CSN5, 2),
  208. [1] = DEFINE_RES_MEM(S3C64XX_PA_XM0CSN5 + (1 << 8), 2),
  209. [2] = DEFINE_RES_NAMED(S3C_EINT(17), 1, NULL, IORESOURCE_IRQ \
  210. | IORESOURCE_IRQ_HIGHLEVEL),
  211. };
  212. static struct dm9000_plat_data mini6410_dm9k_pdata = {
  213. .flags = DM9000_PLATF_16BITONLY,
  214. };
  215. static struct platform_device crag6410_dm9k_device = {
  216. .name = "dm9000",
  217. .id = -1,
  218. .num_resources = ARRAY_SIZE(crag6410_dm9k_resource),
  219. .resource = crag6410_dm9k_resource,
  220. .dev.platform_data = &mini6410_dm9k_pdata,
  221. };
  222. static struct resource crag6410_mmgpio_resource[] = {
  223. [0] = DEFINE_RES_MEM_NAMED(S3C64XX_PA_XM0CSN4, 1, "dat"),
  224. };
  225. static struct platform_device crag6410_mmgpio = {
  226. .name = "basic-mmio-gpio",
  227. .id = -1,
  228. .resource = crag6410_mmgpio_resource,
  229. .num_resources = ARRAY_SIZE(crag6410_mmgpio_resource),
  230. .dev.platform_data = &(struct bgpio_pdata) {
  231. .base = MMGPIO_GPIO_BASE,
  232. },
  233. };
  234. static struct platform_device speyside_device = {
  235. .name = "speyside",
  236. .id = -1,
  237. };
  238. static struct platform_device lowland_device = {
  239. .name = "lowland",
  240. .id = -1,
  241. };
  242. static struct platform_device tobermory_device = {
  243. .name = "tobermory",
  244. .id = -1,
  245. };
  246. static struct platform_device littlemill_device = {
  247. .name = "littlemill",
  248. .id = -1,
  249. };
  250. static struct platform_device bells_wm2200_device = {
  251. .name = "bells",
  252. .id = 0,
  253. };
  254. static struct platform_device bells_wm5102_device = {
  255. .name = "bells",
  256. .id = 1,
  257. };
  258. static struct platform_device bells_wm5110_device = {
  259. .name = "bells",
  260. .id = 2,
  261. };
  262. static struct regulator_consumer_supply wallvdd_consumers[] = {
  263. REGULATOR_SUPPLY("SPKVDD", "1-001a"),
  264. REGULATOR_SUPPLY("SPKVDD1", "1-001a"),
  265. REGULATOR_SUPPLY("SPKVDD2", "1-001a"),
  266. REGULATOR_SUPPLY("SPKVDDL", "1-001a"),
  267. REGULATOR_SUPPLY("SPKVDDR", "1-001a"),
  268. REGULATOR_SUPPLY("SPKVDDL", "spi0.1"),
  269. REGULATOR_SUPPLY("SPKVDDR", "spi0.1"),
  270. REGULATOR_SUPPLY("SPKVDDL", "wm5102-codec"),
  271. REGULATOR_SUPPLY("SPKVDDR", "wm5102-codec"),
  272. REGULATOR_SUPPLY("SPKVDDL", "wm5110-codec"),
  273. REGULATOR_SUPPLY("SPKVDDR", "wm5110-codec"),
  274. REGULATOR_SUPPLY("DC1VDD", "0-0034"),
  275. REGULATOR_SUPPLY("DC2VDD", "0-0034"),
  276. REGULATOR_SUPPLY("DC3VDD", "0-0034"),
  277. REGULATOR_SUPPLY("LDO1VDD", "0-0034"),
  278. REGULATOR_SUPPLY("LDO2VDD", "0-0034"),
  279. REGULATOR_SUPPLY("LDO4VDD", "0-0034"),
  280. REGULATOR_SUPPLY("LDO5VDD", "0-0034"),
  281. REGULATOR_SUPPLY("LDO6VDD", "0-0034"),
  282. REGULATOR_SUPPLY("LDO7VDD", "0-0034"),
  283. REGULATOR_SUPPLY("LDO8VDD", "0-0034"),
  284. REGULATOR_SUPPLY("LDO9VDD", "0-0034"),
  285. REGULATOR_SUPPLY("LDO10VDD", "0-0034"),
  286. REGULATOR_SUPPLY("LDO11VDD", "0-0034"),
  287. REGULATOR_SUPPLY("DC1VDD", "1-0034"),
  288. REGULATOR_SUPPLY("DC2VDD", "1-0034"),
  289. REGULATOR_SUPPLY("DC3VDD", "1-0034"),
  290. REGULATOR_SUPPLY("LDO1VDD", "1-0034"),
  291. REGULATOR_SUPPLY("LDO2VDD", "1-0034"),
  292. REGULATOR_SUPPLY("LDO4VDD", "1-0034"),
  293. REGULATOR_SUPPLY("LDO5VDD", "1-0034"),
  294. REGULATOR_SUPPLY("LDO6VDD", "1-0034"),
  295. REGULATOR_SUPPLY("LDO7VDD", "1-0034"),
  296. REGULATOR_SUPPLY("LDO8VDD", "1-0034"),