jznomoney

Untitled

Mar 23rd, 2011
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.80 KB | None | 0 0
  1. /* linux/arch/arm/mach-msm/devices.c
  2. *
  3. * Copyright (C) 2008 Google, Inc.
  4. * Copyright (C) 2007-2009 HTC Corporation.
  5. * Author: Thomas Tsai <[email protected]>
  6. *
  7. * This software is licensed under the terms of the GNU General Public
  8. * License version 2, as published by the Free Software Foundation, and
  9. * may be copied, distributed, and modified under those terms.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. */
  16.  
  17. #include <linux/kernel.h>
  18. #include <linux/platform_device.h>
  19.  
  20. #include <linux/dma-mapping.h>
  21. #include <mach/msm_iomap.h>
  22. #include <mach/dma.h>
  23. #include "gpio_chip.h"
  24. #include "devices.h"
  25. #include <mach/board.h>
  26. #include <mach/board_htc.h>
  27. #include <mach/msm_hsusb.h>
  28. #include <linux/usb/android_composite.h>
  29.  
  30. #include <asm/mach/flash.h>
  31. #include <asm/setup.h>
  32. #include <linux/mtd/nand.h>
  33. #include <linux/mtd/partitions.h>
  34. #include <linux/delay.h>
  35. #include <linux/android_pmem.h>
  36. #include <mach/msm_rpcrouter.h>
  37. #include <mach/msm_iomap.h>
  38. #include <asm/mach/mmc.h>
  39. #include <linux/msm_kgsl.h>
  40. #include <mach/dal_axi.h>
  41. #include "proc_comm.h"
  42.  
  43. #ifndef CONFIG_ARCH_MSM7X30
  44. struct platform_device *devices[] __initdata = {
  45. &msm_device_nand,
  46. &msm_device_smd,
  47. /* &msm_device_i2c, */
  48. };
  49.  
  50. void __init msm_add_devices(void)
  51. {
  52. platform_add_devices(devices, ARRAY_SIZE(devices));
  53. }
  54. #endif
  55.  
  56. static struct android_pmem_platform_data pmem_pdata = {
  57. .name = "pmem",
  58. .no_allocator = 1,
  59. .cached = 1,
  60. };
  61.  
  62. static struct android_pmem_platform_data pmem_adsp_pdata = {
  63. .name = "pmem_adsp",
  64. .no_allocator = 0,
  65. #if defined(CONFIG_ARCH_MSM7227)
  66. .cached = 1,
  67. #else
  68. .cached = 0,
  69. #endif
  70. };
  71.  
  72. static struct android_pmem_platform_data pmem_camera_pdata = {
  73. .name = "pmem_camera",
  74. .no_allocator = 0,
  75. .cached = 0,
  76. };
  77.  
  78. static struct platform_device pmem_device = {
  79. .name = "android_pmem",
  80. .id = 0,
  81. .dev = { .platform_data = &pmem_pdata },
  82. };
  83.  
  84. static struct platform_device pmem_adsp_device = {
  85. .name = "android_pmem",
  86. .id = 1,
  87. .dev = { .platform_data = &pmem_adsp_pdata },
  88. };
  89.  
  90. static struct platform_device pmem_camera_device = {
  91. .name = "android_pmem",
  92. .id = 4,
  93. .dev = { .platform_data = &pmem_camera_pdata },
  94. };
  95.  
  96. static struct resource ram_console_resource[] = {
  97. {
  98. .flags = IORESOURCE_MEM,
  99. }
  100. };
  101.  
  102. static struct platform_device ram_console_device = {
  103. .name = "ram_console",
  104. .id = -1,
  105. .num_resources = ARRAY_SIZE(ram_console_resource),
  106. .resource = ram_console_resource,
  107. };
  108.  
  109. #ifdef CONFIG_MSM_CAMERA_7X30
  110. static struct resource msm_vpe_resources[] = {
  111. {
  112. .start = 0xAD200000,
  113. .end = 0xAD200000 + SZ_1M - 1,
  114. .flags = IORESOURCE_MEM,
  115. },
  116. {
  117. .start = INT_VPE,
  118. .end = INT_VPE,
  119. .flags = IORESOURCE_IRQ,
  120. },
  121. };
  122.  
  123. static struct platform_device msm_vpe_device = {
  124. .name = "msm_vpe",
  125. .id = 0,
  126. .num_resources = ARRAY_SIZE(msm_vpe_resources),
  127. .resource = msm_vpe_resources,
  128. };
  129. #endif
  130.  
  131. #if defined(CONFIG_MSM_HW3D)
  132. static struct resource resources_hw3d[] = {
  133. {
  134. .start = 0xA0000000,
  135. .end = 0xA00fffff,
  136. .flags = IORESOURCE_MEM,
  137. .name = "regs",
  138. },
  139. {
  140. .flags = IORESOURCE_MEM,
  141. .name = "smi",
  142. },
  143. {
  144. .flags = IORESOURCE_MEM,
  145. .name = "ebi",
  146. },
  147. {
  148. .start = INT_GRAPHICS,
  149. .end = INT_GRAPHICS,
  150. .flags = IORESOURCE_IRQ,
  151. .name = "gfx",
  152. },
  153. };
  154.  
  155. static struct platform_device hw3d_device = {
  156. .name = "msm_hw3d",
  157. .id = 0,
  158. .num_resources = ARRAY_SIZE(resources_hw3d),
  159. .resource = resources_hw3d,
  160. };
  161. #endif
  162.  
  163. #if defined(CONFIG_GPU_MSM_KGSL)
  164. static struct resource msm_kgsl_resources[] = {
  165. {
  166. .name = "kgsl_reg_memory",
  167. .start = MSM_GPU_REG_PHYS,
  168. .end = MSM_GPU_REG_PHYS + MSM_GPU_REG_SIZE - 1,
  169. .flags = IORESOURCE_MEM,
  170. },
  171. {
  172. .name = "kgsl_phys_memory",
  173. .flags = IORESOURCE_MEM,
  174. },
  175. {
  176. #ifdef CONFIG_ARCH_MSM7X30
  177. .name = "kgsl_yamato_irq",
  178. .start = INT_GRP_3D,
  179. .end = INT_GRP_3D,
  180. #else
  181. .start = INT_GRAPHICS,
  182. .end = INT_GRAPHICS,
  183. #endif
  184. .flags = IORESOURCE_IRQ,
  185. },
  186. #ifdef CONFIG_ARCH_MSM7X30
  187. {
  188. .name = "kgsl_2d0_reg_memory",
  189. .start = MSM_GPU_2D_REG_PHYS, /* Z180 base address */
  190. .end = MSM_GPU_2D_REG_PHYS + MSM_GPU_2D_REG_SIZE - 1,
  191. .flags = IORESOURCE_MEM,
  192. },
  193. {
  194. .name = "kgsl_2d0_irq",
  195. .start = INT_GRP_2D,
  196. .end = INT_GRP_2D,
  197. .flags = IORESOURCE_IRQ,
  198. },
  199. #endif
  200. };
  201.  
  202. #ifdef CONFIG_ARCH_MSM7X30
  203. static struct kgsl_platform_data kgsl_pdata = {
  204. #ifdef CONFIG_MSM_NPA_SYSTEM_BUS
  205. /* NPA Flow IDs */
  206. .high_axi_3d = MSM_AXI_FLOW_3D_GPU_HIGH,
  207. .high_axi_2d = MSM_AXI_FLOW_2D_GPU_HIGH,
  208. #else
  209. /* AXI rates in KHz */
  210. .high_axi_3d = 192000,
  211. .high_axi_2d = 192000,
  212. #endif
  213. .max_grp2d_freq = 0,
  214. .min_grp2d_freq = 0,
  215. .set_grp2d_async = NULL, /* HW workaround, run Z180 SYNC @ 192 MHZ */
  216. .max_grp3d_freq = 245760000,
  217. .min_grp3d_freq = 192000000,
  218. .set_grp3d_async = set_grp3d_async,
  219. .imem_clk_name = "imem_clk",
  220. .grp3d_clk_name = "grp_clk",
  221. .grp2d0_clk_name = "grp_2d_clk",
  222. };
  223. #endif
  224.  
  225. static struct platform_device msm_kgsl_device = {
  226. .name = "kgsl",
  227. .id = -1,
  228. .resource = msm_kgsl_resources,
  229. .num_resources = ARRAY_SIZE(msm_kgsl_resources),
  230. #ifdef CONFIG_ARCH_MSM7X30
  231. .dev = {
  232. .platform_data = &kgsl_pdata,
  233. },
  234. #endif
  235. };
  236.  
  237. #if !defined(CONFIG_ARCH_MSM7X30)
  238. #define PWR_RAIL_GRP_CLK 8
  239. static int kgsl_power_rail_mode(int follow_clk)
  240. {
  241. int mode = follow_clk ? 0 : 1;
  242. int rail_id = PWR_RAIL_GRP_CLK;
  243.  
  244. return msm_proc_comm(PCOM_CLKCTL_RPC_RAIL_CONTROL, &rail_id, &mode);
  245. }
  246.  
  247. static int kgsl_power(bool on)
  248. {
  249. int cmd;
  250. int rail_id = PWR_RAIL_GRP_CLK;
  251.  
  252. cmd = on ? PCOM_CLKCTL_RPC_RAIL_ENABLE : PCOM_CLKCTL_RPC_RAIL_DISABLE;
  253. return msm_proc_comm(cmd, &rail_id, NULL);
  254. }
  255. #endif
  256.  
  257. #endif
  258.  
  259. void __init msm_add_mem_devices(struct msm_pmem_setting *setting)
  260. {
  261. if (setting->pmem_size) {
  262. pmem_pdata.start = setting->pmem_start;
  263. pmem_pdata.size = setting->pmem_size;
  264. platform_device_register(&pmem_device);
  265. }
  266.  
  267. if (setting->pmem_adsp_size) {
  268. pmem_adsp_pdata.start = setting->pmem_adsp_start;
  269. pmem_adsp_pdata.size = setting->pmem_adsp_size;
  270. platform_device_register(&pmem_adsp_device);
  271. }
  272.  
  273. #if defined(CONFIG_MSM_HW3D)
  274. if (setting->pmem_gpu0_size && setting->pmem_gpu1_size) {
  275. struct resource *res;
  276.  
  277. res = platform_get_resource_byname(&hw3d_device, IORESOURCE_MEM,
  278. "smi");
  279. res->start = setting->pmem_gpu0_start;
  280. res->end = res->start + setting->pmem_gpu0_size - 1;
  281.  
  282. res = platform_get_resource_byname(&hw3d_device, IORESOURCE_MEM,
  283. "ebi");
  284. res->start = setting->pmem_gpu1_start;
  285. res->end = res->start + setting->pmem_gpu1_size - 1;
  286. platform_device_register(&hw3d_device);
  287. }
  288. #endif
  289.  
  290. if (setting->pmem_camera_size) {
  291. pmem_camera_pdata.start = setting->pmem_camera_start;
  292. pmem_camera_pdata.size = setting->pmem_camera_size;
  293. platform_device_register(&pmem_camera_device);
  294. }
  295.  
  296. if (setting->ram_console_size) {
  297. ram_console_resource[0].start = setting->ram_console_start;
  298. ram_console_resource[0].end = setting->ram_console_start
  299. + setting->ram_console_size - 1;
  300. platform_device_register(&ram_console_device);
  301. }
  302.  
  303. #if defined(CONFIG_GPU_MSM_KGSL)
  304. if (setting->kgsl_size) {
  305. msm_kgsl_resources[1].start = setting->kgsl_start;
  306. msm_kgsl_resources[1].end = setting->kgsl_start
  307. + setting->kgsl_size - 1;
  308. /* due to 7x30 gpu hw bug, we have to apply clk
  309. * first then power on gpu, thus we move power on
  310. * into kgsl driver
  311. */
  312. #if !defined(CONFIG_ARCH_MSM7X30)
  313. kgsl_power_rail_mode(0);
  314. kgsl_power(true);
  315. #endif
  316. platform_device_register(&msm_kgsl_device);
  317. }
  318. #endif
  319.  
  320. #ifdef CONFIG_MSM_CAMERA_7X30
  321. platform_device_register(&msm_vpe_device);
  322. #endif
  323. }
  324.  
  325. #define PM_LIBPROG 0x30000061
  326. #if (CONFIG_MSM_AMSS_VERSION == 6220) || (CONFIG_MSM_AMSS_VERSION == 6225)
  327. #define PM_LIBVERS 0xfb837d0b
  328. #else
  329. #define PM_LIBVERS 0x10001
  330. #endif
  331.  
  332. #if 1
  333. static struct platform_device *msm_serial_devices[] __initdata = {
  334. &msm_device_uart1,
  335. &msm_device_uart2,
  336. &msm_device_uart3,
  337. #ifdef CONFIG_SERIAL_MSM_HS
  338. &msm_device_uart_dm1,
  339. &msm_device_uart_dm2,
  340. #endif
  341. };
  342.  
  343. int __init msm_add_serial_devices(unsigned num)
  344. {
  345. if (num > MSM_SERIAL_NUM)
  346. return -EINVAL;
  347.  
  348. return platform_device_register(msm_serial_devices[num]);
  349. }
  350. #endif
  351.  
  352. #define ATAG_SMI 0x4d534D71
  353. /* setup calls mach->fixup, then parse_tags, parse_cmdline
  354. * We need to setup meminfo in mach->fixup, so this function
  355. * will need to traverse each tag to find smi tag.
  356. */
  357. int __init parse_tag_smi(const struct tag *tags)
  358. {
  359. int smi_sz = 0, find = 0;
  360. struct tag *t = (struct tag *)tags;
  361.  
  362. for (; t->hdr.size; t = tag_next(t)) {
  363. if (t->hdr.tag == ATAG_SMI) {
  364. printk(KERN_DEBUG "find the smi tag\n");
  365. find = 1;
  366. break;
  367. }
  368. }
  369. if (!find)
  370. return -1;
  371.  
  372. printk(KERN_DEBUG "parse_tag_smi: smi size = %d\n", t->u.mem.size);
  373. smi_sz = t->u.mem.size;
  374. return smi_sz;
  375. }
  376. __tagtable(ATAG_SMI, parse_tag_smi);
  377.  
  378.  
  379. #define ATAG_HWID 0x4d534D72
  380. int __init parse_tag_hwid(const struct tag *tags)
  381. {
  382. int hwid = 0, find = 0;
  383. struct tag *t = (struct tag *)tags;
  384.  
  385. for (; t->hdr.size; t = tag_next(t)) {
  386. if (t->hdr.tag == ATAG_HWID) {
  387. printk(KERN_DEBUG "find the hwid tag\n");
  388. find = 1;
  389. break;
  390. }
  391. }
  392.  
  393. if (find)
  394. hwid = t->u.revision.rev;
  395. printk(KERN_DEBUG "parse_tag_hwid: hwid = 0x%x\n", hwid);
  396. return hwid;
  397. }
  398. __tagtable(ATAG_HWID, parse_tag_hwid);
  399.  
  400. static char *keycap_tag = NULL;
  401. static int __init board_keycaps_tag(char *get_keypads)
  402. {
  403. if(strlen(get_keypads))
  404. keycap_tag = get_keypads;
  405. else
  406. keycap_tag = NULL;
  407. return 1;
  408. }
  409. __setup("androidboot.keycaps=", board_keycaps_tag);
  410.  
  411. void board_get_keycaps_tag(char **ret_data)
  412. {
  413. *ret_data = keycap_tag;
  414. }
  415. EXPORT_SYMBOL(board_get_keycaps_tag);
  416.  
  417. static char *cid_tag = NULL;
  418. static int __init board_set_cid_tag(char *get_hboot_cid)
  419. {
  420. if(strlen(get_hboot_cid))
  421. cid_tag = get_hboot_cid;
  422. else
  423. cid_tag = NULL;
  424. return 1;
  425. }
  426. __setup("androidboot.cid=", board_set_cid_tag);
  427.  
  428. void board_get_cid_tag(char **ret_data)
  429. {
  430. *ret_data = cid_tag;
  431. }
  432. EXPORT_SYMBOL(board_get_cid_tag);
  433.  
  434. static char *carrier_tag = NULL;
  435. static int __init board_set_carrier_tag(char *get_hboot_carrier)
  436. {
  437. if(strlen(get_hboot_carrier))
  438. carrier_tag = get_hboot_carrier;
  439. else
  440. carrier_tag = NULL;
  441. return 1;
  442. }
  443. __setup("androidboot.carrier=", board_set_carrier_tag);
  444.  
  445. void board_get_carrier_tag(char **ret_data)
  446. {
  447. *ret_data = carrier_tag;
  448. }
  449. EXPORT_SYMBOL(board_get_carrier_tag);
  450.  
  451. /* G-Sensor calibration value */
  452. #define ATAG_GS 0x5441001d
  453.  
  454. unsigned int gs_kvalue;
  455. EXPORT_SYMBOL(gs_kvalue);
  456.  
  457. static int __init parse_tag_gs_calibration(const struct tag *tag)
  458. {
  459. gs_kvalue = tag->u.revision.rev;
  460. printk(KERN_DEBUG "%s: gs_kvalue = 0x%x\n", __func__, gs_kvalue);
  461. return 0;
  462. }
  463.  
  464. __tagtable(ATAG_GS, parse_tag_gs_calibration);
  465.  
  466. /* Proximity sensor calibration values */
  467. #define ATAG_PS 0x5441001c
  468.  
  469. unsigned int ps_kparam1;
  470. EXPORT_SYMBOL(ps_kparam1);
  471.  
  472. unsigned int ps_kparam2;
  473. EXPORT_SYMBOL(ps_kparam2);
  474.  
  475. static int __init parse_tag_ps_calibration(const struct tag *tag)
  476. {
  477. ps_kparam1 = tag->u.serialnr.low;
  478. ps_kparam2 = tag->u.serialnr.high;
  479.  
  480. printk(KERN_DEBUG "%s: ps_kparam1 = 0x%x, ps_kparam2 = 0x%x\n",
  481. __func__, ps_kparam1, ps_kparam2);
  482.  
  483. return 0;
  484. }
  485.  
  486. __tagtable(ATAG_PS, parse_tag_ps_calibration);
  487.  
  488. unsigned int als_kadc;
  489. EXPORT_SYMBOL(als_kadc);
  490.  
  491. static int __init parse_tag_als_calibration(const struct tag *tag)
  492. {
  493. als_kadc = tag->u.als_kadc.kadc;
  494.  
  495. return 0;
  496. }
  497.  
  498. __tagtable(ATAG_ALS, parse_tag_als_calibration);
Advertisement
Add Comment
Please, Sign In to add comment