/arch/arm/mach-msm/board-halibut.c

https://bitbucket.org/sammyz/iscream_thunderc-2.6.35-rebase · C · 482 lines · 412 code · 53 blank · 17 comment · 2 complexity · 6a7324eb00415da45b343de3eb5d04b0 MD5 · raw file

  1. /* linux/arch/arm/mach-msm/board-halibut.c
  2. *
  3. * Copyright (C) 2007 Google, Inc.
  4. * Author: Brian Swetland <swetland@google.com>
  5. *
  6. * This software is licensed under the terms of the GNU General Public
  7. * License version 2, as published by the Free Software Foundation, and
  8. * may be copied, distributed, and modified under those terms.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. */
  16. #include <linux/kernel.h>
  17. #include <linux/init.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/input.h>
  20. #include <linux/io.h>
  21. #include <linux/delay.h>
  22. #include <linux/bootmem.h>
  23. #include <mach/hardware.h>
  24. #include <mach/irqs.h>
  25. #include <mach/gpio.h>
  26. #include <asm/mach-types.h>
  27. #include <asm/mach/arch.h>
  28. #include <asm/mach/map.h>
  29. #include <asm/mach/flash.h>
  30. #include <asm/setup.h>
  31. #include <mach/irqs.h>
  32. #include <mach/board.h>
  33. #include <mach/msm_iomap.h>
  34. #include <mach/msm_hsusb.h>
  35. #include <mach/camera.h>
  36. #include <linux/mtd/nand.h>
  37. #include <linux/mtd/partitions.h>
  38. #include <linux/i2c.h>
  39. #include <linux/android_pmem.h>
  40. #include <linux/usb/android_composite.h>
  41. #include "devices.h"
  42. #include "board-halibut.h"
  43. #include "proc_comm.h"
  44. static struct resource smc91x_resources[] = {
  45. [0] = {
  46. .start = 0x9C004300,
  47. .end = 0x9C004400,
  48. .flags = IORESOURCE_MEM,
  49. },
  50. [1] = {
  51. .start = MSM_GPIO_TO_INT(49),
  52. .end = MSM_GPIO_TO_INT(49),
  53. .flags = IORESOURCE_IRQ,
  54. },
  55. };
  56. static struct platform_device smc91x_device = {
  57. .name = "smc91x",
  58. .id = 0,
  59. .num_resources = ARRAY_SIZE(smc91x_resources),
  60. .resource = smc91x_resources,
  61. };
  62. static struct i2c_board_info i2c_devices[] = {
  63. #ifdef CONFIG_MT9D112
  64. {
  65. I2C_BOARD_INFO("mt9d112", 0x78 >> 1),
  66. },
  67. #endif
  68. #ifdef CONFIG_S5K3E2FX
  69. {
  70. I2C_BOARD_INFO("s5k3e2fx", 0x20 >> 1),
  71. },
  72. #endif
  73. #ifdef CONFIG_MT9P012
  74. {
  75. I2C_BOARD_INFO("mt9p012", 0x6C >> 1),
  76. },
  77. #endif
  78. #if defined(CONFIG_MT9T013) || defined(CONFIG_SENSORS_MT9T013)
  79. {
  80. I2C_BOARD_INFO("mt9t013", 0x6C), // 0x78>>1
  81. },
  82. #endif
  83. };
  84. #ifdef CONFIG_MSM_CAMERA
  85. static uint32_t camera_off_gpio_table[] = {
  86. /* parallel CAMERA interfaces */
  87. PCOM_GPIO_CFG(0, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT0 */
  88. PCOM_GPIO_CFG(1, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT1 */
  89. PCOM_GPIO_CFG(2, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT2 */
  90. PCOM_GPIO_CFG(3, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT3 */
  91. PCOM_GPIO_CFG(4, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT4 */
  92. PCOM_GPIO_CFG(5, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT5 */
  93. PCOM_GPIO_CFG(6, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT6 */
  94. PCOM_GPIO_CFG(7, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT7 */
  95. PCOM_GPIO_CFG(8, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT8 */
  96. PCOM_GPIO_CFG(9, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT9 */
  97. PCOM_GPIO_CFG(10, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT10 */
  98. PCOM_GPIO_CFG(11, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT11 */
  99. PCOM_GPIO_CFG(12, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* PCLK */
  100. PCOM_GPIO_CFG(13, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* HSYNC_IN */
  101. PCOM_GPIO_CFG(14, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* VSYNC_IN */
  102. PCOM_GPIO_CFG(15, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA), /* MCLK */
  103. };
  104. static uint32_t camera_on_gpio_table[] = {
  105. /* parallel CAMERA interfaces */
  106. PCOM_GPIO_CFG(0, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT0 */
  107. PCOM_GPIO_CFG(1, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT1 */
  108. PCOM_GPIO_CFG(2, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT2 */
  109. PCOM_GPIO_CFG(3, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT3 */
  110. PCOM_GPIO_CFG(4, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT4 */
  111. PCOM_GPIO_CFG(5, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT5 */
  112. PCOM_GPIO_CFG(6, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT6 */
  113. PCOM_GPIO_CFG(7, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT7 */
  114. PCOM_GPIO_CFG(8, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT8 */
  115. PCOM_GPIO_CFG(9, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT9 */
  116. PCOM_GPIO_CFG(10, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT10 */
  117. PCOM_GPIO_CFG(11, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT11 */
  118. PCOM_GPIO_CFG(12, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_16MA), /* PCLK */
  119. PCOM_GPIO_CFG(13, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* HSYNC_IN */
  120. PCOM_GPIO_CFG(14, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* VSYNC_IN */
  121. PCOM_GPIO_CFG(15, 1, GPIO_OUTPUT, GPIO_PULL_DOWN, GPIO_16MA), /* MCLK */
  122. };
  123. static void config_gpio_table(uint32_t *table, int len)
  124. {
  125. int n;
  126. unsigned id;
  127. for (n = 0; n < len; n++) {
  128. id = table[n];
  129. msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &id, 0);
  130. }
  131. }
  132. static void config_camera_on_gpios(void)
  133. {
  134. config_gpio_table(camera_on_gpio_table,
  135. ARRAY_SIZE(camera_on_gpio_table));
  136. }
  137. static void config_camera_off_gpios(void)
  138. {
  139. config_gpio_table(camera_off_gpio_table,
  140. ARRAY_SIZE(camera_off_gpio_table));
  141. }
  142. static struct msm_camera_device_platform_data msm_camera_device_data = {
  143. .camera_gpio_on = config_camera_on_gpios,
  144. .camera_gpio_off = config_camera_off_gpios,
  145. .ioext.mdcphy = MSM_MDC_PHYS,
  146. .ioext.mdcsz = MSM_MDC_SIZE,
  147. .ioext.appphy = MSM_CLK_CTL_PHYS,
  148. .ioext.appsz = MSM_CLK_CTL_SIZE,
  149. };
  150. #ifdef CONFIG_MT9D112
  151. static struct msm_camera_sensor_info msm_camera_sensor_mt9d112_data = {
  152. .sensor_name = "mt9d112",
  153. .sensor_reset = 89,
  154. .sensor_pwd = 85,
  155. .vcm_pwd = 0,
  156. .pdata = &msm_camera_device_data,
  157. };
  158. static struct platform_device msm_camera_sensor_mt9d112 = {
  159. .name = "msm_camera_mt9d112",
  160. .dev = {
  161. .platform_data = &msm_camera_sensor_mt9d112_data,
  162. },
  163. };
  164. #endif
  165. #ifdef CONFIG_S5K3E2FX
  166. static struct msm_camera_sensor_info msm_camera_sensor_s5k3e2fx_data = {
  167. .sensor_name = "s5k3e2fx",
  168. .sensor_reset = 89,
  169. .sensor_pwd = 85,
  170. .vcm_pwd = 0,
  171. .pdata = &msm_camera_device_data,
  172. };
  173. static struct platform_device msm_camera_sensor_s5k3e2fx = {
  174. .name = "msm_camera_s5k3e2fx",
  175. .dev = {
  176. .platform_data = &msm_camera_sensor_s5k3e2fx_data,
  177. },
  178. };
  179. #endif
  180. #ifdef CONFIG_MT9P012
  181. static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_data = {
  182. .sensor_name = "mt9p012",
  183. .sensor_reset = 89,
  184. .sensor_pwd = 85,
  185. .vcm_pwd = 88,
  186. .pdata = &msm_camera_device_data,
  187. };
  188. static struct platform_device msm_camera_sensor_mt9p012 = {
  189. .name = "msm_camera_mt9p012",
  190. .dev = {
  191. .platform_data = &msm_camera_sensor_mt9p012_data,
  192. },
  193. };
  194. #endif
  195. #ifdef CONFIG_MT9T013
  196. static struct msm_camera_sensor_info msm_camera_sensor_mt9t013_data = {
  197. .sensor_name = "mt9t013",
  198. .sensor_reset = 89,
  199. .sensor_pwd = 85,
  200. .vcm_pwd = 0,
  201. .pdata = &msm_camera_device_data,
  202. };
  203. static struct platform_device msm_camera_sensor_mt9t013 = {
  204. .name = "msm_camera_mt9t013",
  205. .dev = {
  206. .platform_data = &msm_camera_sensor_mt9t013_data,
  207. },
  208. };
  209. #endif
  210. #endif /*CONFIG_MSM_CAMERA*/
  211. #define SND(desc, num) { .name = #desc, .id = num }
  212. static struct snd_endpoint snd_endpoints_list[] = {
  213. SND(HANDSET, 0),
  214. SND(HEADSET, 2),
  215. SND(SPEAKER, 6),
  216. SND(BT, 12),
  217. SND(CURRENT, 25),
  218. };
  219. #undef SND
  220. static struct msm_snd_endpoints halibut_snd_endpoints = {
  221. .endpoints = snd_endpoints_list,
  222. .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint)
  223. };
  224. static struct platform_device halibut_snd = {
  225. .name = "msm_snd",
  226. .id = -1,
  227. .dev = {
  228. .platform_data = &halibut_snd_endpoints
  229. },
  230. };
  231. static struct android_pmem_platform_data android_pmem_pdata = {
  232. .name = "pmem",
  233. .start = MSM_PMEM_MDP_BASE,
  234. .size = MSM_PMEM_MDP_SIZE,
  235. .no_allocator = 0,
  236. .cached = 1,
  237. };
  238. static struct android_pmem_platform_data android_pmem_camera_pdata = {
  239. .name = "pmem_camera",
  240. .start = MSM_PMEM_CAMERA_BASE,
  241. .size = MSM_PMEM_CAMERA_SIZE,
  242. .no_allocator = 1,
  243. .cached = 1,
  244. };
  245. static struct android_pmem_platform_data android_pmem_adsp_pdata = {
  246. .name = "pmem_adsp",
  247. .start = MSM_PMEM_ADSP_BASE,
  248. .size = MSM_PMEM_ADSP_SIZE,
  249. .no_allocator = 0,
  250. .cached = 0,
  251. };
  252. static struct android_pmem_platform_data android_pmem_gpu0_pdata = {
  253. .name = "pmem_gpu0",
  254. .start = MSM_PMEM_GPU0_BASE,
  255. .size = MSM_PMEM_GPU0_SIZE,
  256. .no_allocator = 1,
  257. .cached = 0,
  258. };
  259. static struct android_pmem_platform_data android_pmem_gpu1_pdata = {
  260. .name = "pmem_gpu1",
  261. .start = MSM_PMEM_GPU1_BASE,
  262. .size = MSM_PMEM_GPU1_SIZE,
  263. .no_allocator = 1,
  264. .cached = 0,
  265. };
  266. static struct platform_device android_pmem_device = {
  267. .name = "android_pmem",
  268. .id = 0,
  269. .dev = { .platform_data = &android_pmem_pdata },
  270. };
  271. static struct platform_device android_pmem_adsp_device = {
  272. .name = "android_pmem",
  273. .id = 1,
  274. .dev = { .platform_data = &android_pmem_adsp_pdata },
  275. };
  276. static struct platform_device android_pmem_gpu0_device = {
  277. .name = "android_pmem",
  278. .id = 2,
  279. .dev = { .platform_data = &android_pmem_gpu0_pdata },
  280. };
  281. static struct platform_device android_pmem_gpu1_device = {
  282. .name = "android_pmem",
  283. .id = 3,
  284. .dev = { .platform_data = &android_pmem_gpu1_pdata },
  285. };
  286. static struct platform_device android_pmem_camera_device = {
  287. .name = "android_pmem",
  288. .id = 4,
  289. .dev = { .platform_data = &android_pmem_camera_pdata },
  290. };
  291. static int halibut_phy_init_seq[] = { 0x1D, 0x0D, 0x1D, 0x10, -1 };
  292. static struct msm_hsusb_platform_data msm_hsusb_pdata = {
  293. .phy_init_seq = halibut_phy_init_seq,
  294. };
  295. static struct usb_mass_storage_platform_data mass_storage_pdata = {
  296. .nluns = 1,
  297. .vendor = "Qualcomm",
  298. .product = "Halibut",
  299. .release = 0x0100,
  300. };
  301. static struct platform_device usb_mass_storage_device = {
  302. .name = "usb_mass_storage",
  303. .id = -1,
  304. .dev = {
  305. .platform_data = &mass_storage_pdata,
  306. },
  307. };
  308. static char *usb_functions[] = { "usb_mass_storage" };
  309. static char *usb_functions_adb[] = { "usb_mass_storage", "adb" };
  310. static struct android_usb_product usb_products[] = {
  311. {
  312. .product_id = 0x0c01,
  313. .num_functions = ARRAY_SIZE(usb_functions),
  314. .functions = usb_functions,
  315. },
  316. {
  317. .product_id = 0x0c02,
  318. .num_functions = ARRAY_SIZE(usb_functions_adb),
  319. .functions = usb_functions_adb,
  320. },
  321. };
  322. static struct android_usb_platform_data android_usb_pdata = {
  323. .vendor_id = 0x18d1,
  324. .product_id = 0x0c01,
  325. .version = 0x0100,
  326. .serial_number = "42",
  327. .product_name = "Halibutdroid",
  328. .manufacturer_name = "Qualcomm",
  329. .num_products = ARRAY_SIZE(usb_products),
  330. .products = usb_products,
  331. .num_functions = ARRAY_SIZE(usb_functions_adb),
  332. .functions = usb_functions_adb,
  333. };
  334. static struct platform_device android_usb_device = {
  335. .name = "android_usb",
  336. .id = -1,
  337. .dev = {
  338. .platform_data = &android_usb_pdata,
  339. },
  340. };
  341. static struct platform_device fish_battery_device = {
  342. .name = "fish_battery",
  343. };
  344. static struct platform_device *devices[] __initdata = {
  345. #if !defined(CONFIG_MSM_SERIAL_DEBUGGER)
  346. &msm_device_uart3,
  347. #endif
  348. &msm_device_smd,
  349. &msm_device_nand,
  350. &msm_device_hsusb,
  351. &usb_mass_storage_device,
  352. &android_usb_device,
  353. &msm_device_i2c,
  354. &smc91x_device,
  355. &halibut_snd,
  356. #ifdef CONFIG_MT9T013
  357. &msm_camera_sensor_mt9t013,
  358. #endif
  359. #ifdef CONFIG_MT9D112
  360. &msm_camera_sensor_mt9d112,
  361. #endif
  362. #ifdef CONFIG_S5K3E2FX
  363. &msm_camera_sensor_s5k3e2fx,
  364. #endif
  365. #ifdef CONFIG_MT9P012
  366. &msm_camera_sensor_mt9p012,
  367. #endif
  368. &android_pmem_device,
  369. &android_pmem_adsp_device,
  370. &android_pmem_gpu0_device,
  371. &android_pmem_gpu1_device,
  372. &android_pmem_camera_device,
  373. &fish_battery_device,
  374. };
  375. extern struct sys_timer msm_timer;
  376. static void __init halibut_init_irq(void)
  377. {
  378. msm_init_irq();
  379. }
  380. static struct msm_acpu_clock_platform_data halibut_clock_data = {
  381. .acpu_switch_time_us = 50,
  382. .max_speed_delta_khz = 256000,
  383. .vdd_switch_time_us = 62,
  384. .power_collapse_khz = 19200000,
  385. .wait_for_irq_khz = 128000000,
  386. };
  387. extern void msm_serial_debug_init(unsigned int base, int irq,
  388. struct device *clk_device, int signal_irq);
  389. static void __init halibut_init(void)
  390. {
  391. #if defined(CONFIG_MSM_SERIAL_DEBUGGER)
  392. msm_serial_debug_init(MSM_UART3_PHYS, INT_UART3,
  393. &msm_device_uart3.dev, 1);
  394. #endif
  395. msm_device_hsusb.dev.platform_data = &msm_hsusb_pdata;
  396. msm_acpu_clock_init(&halibut_clock_data);
  397. #ifdef CONFIG_MSM_CAMERA
  398. config_camera_off_gpios(); /* might not be necessary */
  399. #endif
  400. i2c_register_board_info(0, i2c_devices, ARRAY_SIZE(i2c_devices));
  401. platform_add_devices(devices, ARRAY_SIZE(devices));
  402. i2c_register_board_info(0, i2c_devices, ARRAY_SIZE(i2c_devices));
  403. msm_hsusb_set_vbus_state(1);
  404. }
  405. static void __init halibut_fixup(struct machine_desc *desc, struct tag *tags,
  406. char **cmdline, struct meminfo *mi)
  407. {
  408. mi->nr_banks = 1;
  409. mi->bank[0].start = PHYS_OFFSET;
  410. mi->bank[0].node = PHYS_TO_NID(PHYS_OFFSET);
  411. mi->bank[0].size = (101*1024*1024);
  412. }
  413. static void __init halibut_map_io(void)
  414. {
  415. msm_map_common_io();
  416. msm_clock_init(msm_clocks_7x01a, msm_num_clocks_7x01a);
  417. }
  418. MACHINE_START(HALIBUT, "Halibut Board (QCT SURF7200A)")
  419. #ifdef CONFIG_MSM_DEBUG_UART
  420. .phys_io = MSM_DEBUG_UART_PHYS,
  421. .io_pg_offst = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
  422. #endif
  423. .boot_params = 0x10000100,
  424. .fixup = halibut_fixup,
  425. .map_io = halibut_map_io,
  426. .init_irq = halibut_init_irq,
  427. .init_machine = halibut_init,
  428. .timer = &msm_timer,
  429. MACHINE_END