PageRenderTime 110ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 1ms

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

https://github.com/AICP/kernel_google_msm
C | 3041 lines | 2623 code | 296 blank | 122 comment | 97 complexity | c59f087fba96513c83752eb1769bb677 MD5 | raw file
Possible License(s): GPL-2.0
  1. /* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/io.h>
  16. #include <linux/irq.h>
  17. #include <linux/i2c.h>
  18. #include <linux/i2c/sx150x.h>
  19. #include <linux/i2c/isl9519.h>
  20. #include <linux/gpio.h>
  21. #include <linux/msm_ssbi.h>
  22. #include <linux/regulator/msm-gpio-regulator.h>
  23. #include <linux/mfd/pm8xxx/pm8921.h>
  24. #include <linux/mfd/pm8xxx/pm8xxx-adc.h>
  25. #include <linux/regulator/consumer.h>
  26. #include <linux/spi/spi.h>
  27. #include <linux/slimbus/slimbus.h>
  28. #include <linux/bootmem.h>
  29. #ifdef CONFIG_ANDROID_PMEM
  30. #include <linux/android_pmem.h>
  31. #endif
  32. #include <linux/dma-contiguous.h>
  33. #include <linux/dma-mapping.h>
  34. #include <linux/platform_data/qcom_crypto_device.h>
  35. #include <linux/platform_data/qcom_wcnss_device.h>
  36. #include <linux/leds.h>
  37. #include <linux/leds-pm8xxx.h>
  38. #include <linux/i2c/atmel_mxt_ts.h>
  39. #include <linux/msm_tsens.h>
  40. #include <linux/ks8851.h>
  41. #include <linux/i2c/isa1200.h>
  42. #include <linux/gpio_keys.h>
  43. #include <linux/memory.h>
  44. #include <linux/memblock.h>
  45. #include <linux/msm_thermal.h>
  46. #include <linux/slimbus/slimbus.h>
  47. #include <linux/mfd/wcd9xxx/core.h>
  48. #include <linux/mfd/wcd9xxx/pdata.h>
  49. #ifdef CONFIG_STM_LIS3DH
  50. #include <linux/input/lis3dh.h>
  51. #endif
  52. #include <asm/mach-types.h>
  53. #include <asm/mach/arch.h>
  54. #include <asm/setup.h>
  55. #include <asm/hardware/gic.h>
  56. #include <asm/mach/mmc.h>
  57. #include <mach/board.h>
  58. #include <mach/msm_iomap.h>
  59. #include <mach/msm_spi.h>
  60. #ifdef CONFIG_USB_MSM_OTG_72K
  61. #include <mach/msm_hsusb.h>
  62. #else
  63. #include <linux/usb/msm_hsusb.h>
  64. #endif
  65. #include <linux/usb/android.h>
  66. #include <mach/usbdiag.h>
  67. #include <mach/socinfo.h>
  68. #include <mach/rpm.h>
  69. #include <mach/gpiomux.h>
  70. #include <mach/msm_bus_board.h>
  71. #include <mach/msm_memtypes.h>
  72. #include <mach/dma.h>
  73. #include <mach/msm_xo.h>
  74. #include <mach/restart.h>
  75. #include <linux/msm_ion.h>
  76. #include <mach/ion.h>
  77. #include <mach/mdm2.h>
  78. #include <mach/msm_rtb.h>
  79. #include <linux/fmem.h>
  80. #include <mach/msm_cache_dump.h>
  81. #include <mach/kgsl.h>
  82. #ifdef CONFIG_INPUT_MPU3050
  83. #include <linux/input/mpu3050.h>
  84. #endif
  85. #include "timer.h"
  86. #include "devices.h"
  87. #include "devices-msm8x60.h"
  88. #include "spm.h"
  89. #include "pm.h"
  90. #include <mach/cpuidle.h>
  91. #include "rpm_resources.h"
  92. #include <mach/mpm.h>
  93. #include "clock.h"
  94. #include "smd_private.h"
  95. #include "pm-boot.h"
  96. #include "msm_watchdog.h"
  97. #include "board-8930.h"
  98. #include "acpuclock-krait.h"
  99. static struct platform_device msm_fm_platform_init = {
  100. .name = "iris_fm",
  101. .id = -1,
  102. };
  103. #define KS8851_RST_GPIO 89
  104. #define KS8851_IRQ_GPIO 90
  105. #define HAP_SHIFT_LVL_OE_GPIO 47
  106. #define HDMI_MHL_MUX_GPIO 73
  107. #define MHL_GPIO_INT 72
  108. #define MHL_GPIO_RESET 71
  109. #define MHL_GPIO_PWR_EN 5
  110. #if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
  111. struct sx150x_platform_data msm8930_sx150x_data[] = {
  112. [SX150X_CAM] = {
  113. .gpio_base = GPIO_CAM_EXPANDER_BASE,
  114. .oscio_is_gpo = false,
  115. .io_pullup_ena = 0x0,
  116. .io_pulldn_ena = 0xc0,
  117. .io_open_drain_ena = 0x0,
  118. .irq_summary = -1,
  119. },
  120. };
  121. #endif
  122. #define MSM_PMEM_ADSP_SIZE 0x7800000
  123. #define MSM_PMEM_AUDIO_SIZE 0x4CF000
  124. #ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
  125. #define MSM_PMEM_SIZE 0x4000000 /* 64 Mbytes */
  126. #else
  127. #define MSM_PMEM_SIZE 0x2800000 /* 40 Mbytes */
  128. #endif
  129. #define MSM_LIQUID_PMEM_SIZE 0x4000000 /* 64 Mbytes */
  130. #ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
  131. #define HOLE_SIZE 0x20000
  132. #define MSM_CONTIG_MEM_SIZE 0x65000
  133. #ifdef CONFIG_MSM_IOMMU
  134. #define MSM_ION_MM_SIZE 0x3800000 /* Need to be multiple of 64K */
  135. #define MSM_ION_SF_SIZE 0x0
  136. #define MSM_ION_QSECOM_SIZE 0x780000 /* (7.5MB) */
  137. #define MSM_ION_HEAP_NUM 8
  138. #else
  139. #define MSM_ION_SF_SIZE MSM_PMEM_SIZE
  140. #define MSM_ION_MM_SIZE MSM_PMEM_ADSP_SIZE
  141. #define MSM_ION_QSECOM_SIZE 0x600000 /* (6MB) */
  142. #define MSM_ION_HEAP_NUM 8
  143. #endif
  144. #define MSM_ION_MM_FW_SIZE (0x200000 - HOLE_SIZE) /* 2MB - 128Kb */
  145. #define MSM_ION_MFC_SIZE SZ_8K
  146. #define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE
  147. #define MSM_LIQUID_ION_MM_SIZE (MSM_ION_MM_SIZE + 0x600000)
  148. #define MSM_LIQUID_ION_SF_SIZE MSM_LIQUID_PMEM_SIZE
  149. #define MSM_HDMI_PRIM_ION_SF_SIZE MSM_HDMI_PRIM_PMEM_SIZE
  150. #define MSM_MM_FW_SIZE (0x200000 - HOLE_SIZE) /*2MB -128Kb */
  151. #define MSM8930_FIXED_AREA_START (0xa0000000 - (MSM_ION_MM_FW_SIZE + \
  152. HOLE_SIZE))
  153. #define MAX_FIXED_AREA_SIZE 0x10000000
  154. #define MSM8930_FW_START MSM8930_FIXED_AREA_START
  155. #define MSM_ION_ADSP_SIZE SZ_8M
  156. #else
  157. #define MSM_CONTIG_MEM_SIZE 0x110C000
  158. #define MSM_ION_HEAP_NUM 1
  159. #endif
  160. #ifdef CONFIG_KERNEL_MSM_CONTIG_MEM_REGION
  161. static unsigned msm_contig_mem_size = MSM_CONTIG_MEM_SIZE;
  162. static int __init msm_contig_mem_size_setup(char *p)
  163. {
  164. msm_contig_mem_size = memparse(p, NULL);
  165. return 0;
  166. }
  167. early_param("msm_contig_mem_size", msm_contig_mem_size_setup);
  168. #endif
  169. #ifdef CONFIG_ANDROID_PMEM
  170. static unsigned pmem_size = MSM_PMEM_SIZE;
  171. static int __init pmem_size_setup(char *p)
  172. {
  173. pmem_size = memparse(p, NULL);
  174. return 0;
  175. }
  176. early_param("pmem_size", pmem_size_setup);
  177. static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
  178. static int __init pmem_adsp_size_setup(char *p)
  179. {
  180. pmem_adsp_size = memparse(p, NULL);
  181. return 0;
  182. }
  183. early_param("pmem_adsp_size", pmem_adsp_size_setup);
  184. static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
  185. static int __init pmem_audio_size_setup(char *p)
  186. {
  187. pmem_audio_size = memparse(p, NULL);
  188. return 0;
  189. }
  190. early_param("pmem_audio_size", pmem_audio_size_setup);
  191. #endif
  192. #ifdef CONFIG_ANDROID_PMEM
  193. #ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
  194. static struct android_pmem_platform_data android_pmem_pdata = {
  195. .name = "pmem",
  196. .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
  197. .cached = 1,
  198. .memory_type = MEMTYPE_EBI1,
  199. };
  200. static struct platform_device msm8930_android_pmem_device = {
  201. .name = "android_pmem",
  202. .id = 0,
  203. .dev = {.platform_data = &android_pmem_pdata},
  204. };
  205. static struct android_pmem_platform_data android_pmem_adsp_pdata = {
  206. .name = "pmem_adsp",
  207. .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
  208. .cached = 0,
  209. .memory_type = MEMTYPE_EBI1,
  210. };
  211. static struct platform_device msm8930_android_pmem_adsp_device = {
  212. .name = "android_pmem",
  213. .id = 2,
  214. .dev = { .platform_data = &android_pmem_adsp_pdata },
  215. };
  216. static struct android_pmem_platform_data android_pmem_audio_pdata = {
  217. .name = "pmem_audio",
  218. .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
  219. .cached = 0,
  220. .memory_type = MEMTYPE_EBI1,
  221. };
  222. static struct platform_device msm8930_android_pmem_audio_device = {
  223. .name = "android_pmem",
  224. .id = 4,
  225. .dev = { .platform_data = &android_pmem_audio_pdata },
  226. };
  227. #endif /* CONFIG_MSM_MULTIMEDIA_USE_ION */
  228. #endif /* CONFIG_ANDROID_PMEM */
  229. struct fmem_platform_data msm8930_fmem_pdata = {
  230. };
  231. #define DSP_RAM_BASE_8960 0x8da00000
  232. #define DSP_RAM_SIZE_8960 0x1800000
  233. static int dspcrashd_pdata_8960 = 0xDEADDEAD;
  234. static struct resource resources_dspcrashd_8960[] = {
  235. {
  236. .name = "msm_dspcrashd",
  237. .start = DSP_RAM_BASE_8960,
  238. .end = DSP_RAM_BASE_8960 + DSP_RAM_SIZE_8960,
  239. .flags = IORESOURCE_DMA,
  240. },
  241. };
  242. static struct platform_device msm_device_dspcrashd_8960 = {
  243. .name = "msm_dspcrashd",
  244. .num_resources = ARRAY_SIZE(resources_dspcrashd_8960),
  245. .resource = resources_dspcrashd_8960,
  246. .dev = { .platform_data = &dspcrashd_pdata_8960 },
  247. };
  248. static struct memtype_reserve msm8930_reserve_table[] __initdata = {
  249. [MEMTYPE_SMI] = {
  250. },
  251. [MEMTYPE_EBI0] = {
  252. .flags = MEMTYPE_FLAGS_1M_ALIGN,
  253. },
  254. [MEMTYPE_EBI1] = {
  255. .flags = MEMTYPE_FLAGS_1M_ALIGN,
  256. },
  257. };
  258. static void __init reserve_rtb_memory(void)
  259. {
  260. #if defined(CONFIG_MSM_RTB)
  261. msm8930_reserve_table[MEMTYPE_EBI1].size += msm8930_rtb_pdata.size;
  262. #endif
  263. }
  264. static void __init size_pmem_devices(void)
  265. {
  266. #ifdef CONFIG_ANDROID_PMEM
  267. #ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
  268. android_pmem_adsp_pdata.size = pmem_adsp_size;
  269. android_pmem_pdata.size = pmem_size;
  270. android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
  271. #endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
  272. #endif /*CONFIG_ANDROID_PMEM*/
  273. }
  274. #ifdef CONFIG_ANDROID_PMEM
  275. #ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
  276. static void __init reserve_memory_for(struct android_pmem_platform_data *p)
  277. {
  278. msm8930_reserve_table[p->memory_type].size += p->size;
  279. }
  280. #endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
  281. #endif /*CONFIG_ANDROID_PMEM*/
  282. static void __init reserve_pmem_memory(void)
  283. {
  284. #ifdef CONFIG_ANDROID_PMEM
  285. #ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
  286. reserve_memory_for(&android_pmem_adsp_pdata);
  287. reserve_memory_for(&android_pmem_pdata);
  288. reserve_memory_for(&android_pmem_audio_pdata);
  289. #endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
  290. msm8930_reserve_table[MEMTYPE_EBI1].size += msm_contig_mem_size;
  291. #endif /*CONFIG_ANDROID_PMEM*/
  292. }
  293. static int msm8930_paddr_to_memtype(unsigned int paddr)
  294. {
  295. return MEMTYPE_EBI1;
  296. }
  297. #define FMEM_ENABLED 0
  298. #ifdef CONFIG_ION_MSM
  299. #ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
  300. static struct ion_cp_heap_pdata cp_mm_msm8930_ion_pdata = {
  301. .permission_type = IPT_TYPE_MM_CARVEOUT,
  302. .align = PAGE_SIZE,
  303. .reusable = FMEM_ENABLED,
  304. .mem_is_fmem = FMEM_ENABLED,
  305. .fixed_position = FIXED_MIDDLE,
  306. .is_cma = 1,
  307. .no_nonsecure_alloc = 1,
  308. };
  309. static struct ion_cp_heap_pdata cp_mfc_msm8930_ion_pdata = {
  310. .permission_type = IPT_TYPE_MFC_SHAREDMEM,
  311. .align = PAGE_SIZE,
  312. .reusable = 0,
  313. .mem_is_fmem = FMEM_ENABLED,
  314. .fixed_position = FIXED_HIGH,
  315. .no_nonsecure_alloc = 1,
  316. };
  317. static struct ion_co_heap_pdata co_msm8930_ion_pdata = {
  318. .adjacent_mem_id = INVALID_HEAP_ID,
  319. .align = PAGE_SIZE,
  320. .mem_is_fmem = 0,
  321. };
  322. static struct ion_co_heap_pdata fw_co_msm8930_ion_pdata = {
  323. .adjacent_mem_id = ION_CP_MM_HEAP_ID,
  324. .align = SZ_128K,
  325. .mem_is_fmem = FMEM_ENABLED,
  326. .fixed_position = FIXED_LOW,
  327. };
  328. #endif
  329. static u64 msm_dmamask = DMA_BIT_MASK(32);
  330. static struct platform_device ion_mm_heap_device = {
  331. .name = "ion-mm-heap-device",
  332. .id = -1,
  333. .dev = {
  334. .dma_mask = &msm_dmamask,
  335. .coherent_dma_mask = DMA_BIT_MASK(32),
  336. }
  337. };
  338. static struct platform_device ion_adsp_heap_device = {
  339. .name = "ion-adsp-heap-device",
  340. .id = -1,
  341. .dev = {
  342. .dma_mask = &msm_dmamask,
  343. .coherent_dma_mask = DMA_BIT_MASK(32),
  344. }
  345. };
  346. /**
  347. * These heaps are listed in the order they will be allocated. Due to
  348. * video hardware restrictions and content protection the FW heap has to
  349. * be allocated adjacent (below) the MM heap and the MFC heap has to be
  350. * allocated after the MM heap to ensure MFC heap is not more than 256MB
  351. * away from the base address of the FW heap.
  352. * However, the order of FW heap and MM heap doesn't matter since these
  353. * two heaps are taken care of by separate code to ensure they are adjacent
  354. * to each other.
  355. * Don't swap the order unless you know what you are doing!
  356. */
  357. struct ion_platform_heap msm8930_heaps[] = {
  358. {
  359. .id = ION_SYSTEM_HEAP_ID,
  360. .type = ION_HEAP_TYPE_SYSTEM,
  361. .name = ION_VMALLOC_HEAP_NAME,
  362. },
  363. #ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
  364. {
  365. .id = ION_CP_MM_HEAP_ID,
  366. .type = ION_HEAP_TYPE_CP,
  367. .name = ION_MM_HEAP_NAME,
  368. .size = MSM_ION_MM_SIZE,
  369. .memory_type = ION_EBI_TYPE,
  370. .extra_data = (void *) &cp_mm_msm8930_ion_pdata,
  371. .priv = &ion_mm_heap_device.dev
  372. },
  373. {
  374. .id = ION_MM_FIRMWARE_HEAP_ID,
  375. .type = ION_HEAP_TYPE_CARVEOUT,
  376. .name = ION_MM_FIRMWARE_HEAP_NAME,
  377. .size = MSM_ION_MM_FW_SIZE,
  378. .memory_type = ION_EBI_TYPE,
  379. .extra_data = (void *) &fw_co_msm8930_ion_pdata,
  380. },
  381. {
  382. .id = ION_CP_MFC_HEAP_ID,
  383. .type = ION_HEAP_TYPE_CP,
  384. .name = ION_MFC_HEAP_NAME,
  385. .size = MSM_ION_MFC_SIZE,
  386. .memory_type = ION_EBI_TYPE,
  387. .extra_data = (void *) &cp_mfc_msm8930_ion_pdata,
  388. },
  389. #ifndef CONFIG_MSM_IOMMU
  390. {
  391. .id = ION_SF_HEAP_ID,
  392. .type = ION_HEAP_TYPE_CARVEOUT,
  393. .name = ION_SF_HEAP_NAME,
  394. .size = MSM_ION_SF_SIZE,
  395. .memory_type = ION_EBI_TYPE,
  396. .extra_data = (void *) &co_msm8930_ion_pdata,
  397. },
  398. #endif
  399. {
  400. .id = ION_IOMMU_HEAP_ID,
  401. .type = ION_HEAP_TYPE_IOMMU,
  402. .name = ION_IOMMU_HEAP_NAME,
  403. },
  404. {
  405. .id = ION_QSECOM_HEAP_ID,
  406. .type = ION_HEAP_TYPE_CARVEOUT,
  407. .name = ION_QSECOM_HEAP_NAME,
  408. .size = MSM_ION_QSECOM_SIZE,
  409. .memory_type = ION_EBI_TYPE,
  410. .extra_data = (void *) &co_msm8930_ion_pdata,
  411. },
  412. {
  413. .id = ION_AUDIO_HEAP_ID,
  414. .type = ION_HEAP_TYPE_CARVEOUT,
  415. .name = ION_AUDIO_HEAP_NAME,
  416. .size = MSM_ION_AUDIO_SIZE,
  417. .memory_type = ION_EBI_TYPE,
  418. .extra_data = (void *) &co_msm8930_ion_pdata,
  419. },
  420. {
  421. .id = ION_ADSP_HEAP_ID,
  422. .type = ION_HEAP_TYPE_DMA,
  423. .name = ION_ADSP_HEAP_NAME,
  424. .size = MSM_ION_ADSP_SIZE,
  425. .memory_type = ION_EBI_TYPE,
  426. .extra_data = (void *) &co_msm8930_ion_pdata,
  427. .priv = &ion_adsp_heap_device.dev,
  428. },
  429. #endif
  430. };
  431. static struct ion_platform_data msm8930_ion_pdata = {
  432. .nr = MSM_ION_HEAP_NUM,
  433. .heaps = msm8930_heaps,
  434. };
  435. static struct platform_device msm8930_ion_dev = {
  436. .name = "ion-msm",
  437. .id = 1,
  438. .dev = { .platform_data = &msm8930_ion_pdata },
  439. };
  440. #endif
  441. struct platform_device msm8930_fmem_device = {
  442. .name = "fmem",
  443. .id = 1,
  444. .dev = { .platform_data = &msm8930_fmem_pdata },
  445. };
  446. static void __init reserve_mem_for_ion(enum ion_memory_types mem_type,
  447. unsigned long size)
  448. {
  449. msm8930_reserve_table[mem_type].size += size;
  450. }
  451. static void __init msm8930_reserve_fixed_area(unsigned long fixed_area_size)
  452. {
  453. #if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
  454. int ret;
  455. if (fixed_area_size > MAX_FIXED_AREA_SIZE)
  456. panic("fixed area size is larger than %dM\n",
  457. MAX_FIXED_AREA_SIZE >> 20);
  458. reserve_info->fixed_area_size = fixed_area_size;
  459. reserve_info->fixed_area_start = MSM8930_FW_START;
  460. ret = memblock_remove(reserve_info->fixed_area_start,
  461. reserve_info->fixed_area_size);
  462. BUG_ON(ret);
  463. #endif
  464. }
  465. /**
  466. * Reserve memory for ION and calculate amount of reusable memory for fmem.
  467. * We only reserve memory for heaps that are not reusable. However, we only
  468. * support one reusable heap at the moment so we ignore the reusable flag for
  469. * other than the first heap with reusable flag set. Also handle special case
  470. * for video heaps (MM,FW, and MFC). Video requires heaps MM and MFC to be
  471. * at a higher address than FW in addition to not more than 256MB away from the
  472. * base address of the firmware. This means that if MM is reusable the other
  473. * two heaps must be allocated in the same region as FW. This is handled by the
  474. * mem_is_fmem flag in the platform data. In addition the MM heap must be
  475. * adjacent to the FW heap for content protection purposes.
  476. */
  477. static void __init reserve_ion_memory(void)
  478. {
  479. #if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
  480. unsigned int i;
  481. int ret;
  482. unsigned int fixed_size = 0;
  483. unsigned int fixed_low_size, fixed_middle_size, fixed_high_size;
  484. unsigned long fixed_low_start, fixed_middle_start, fixed_high_start;
  485. unsigned long cma_alignment;
  486. unsigned int low_use_cma = 0;
  487. unsigned int middle_use_cma = 0;
  488. unsigned int high_use_cma = 0;
  489. fixed_low_size = 0;
  490. fixed_middle_size = 0;
  491. fixed_high_size = 0;
  492. cma_alignment = PAGE_SIZE << max(MAX_ORDER, pageblock_order);
  493. for (i = 0; i < msm8930_ion_pdata.nr; ++i) {
  494. struct ion_platform_heap *heap =
  495. &(msm8930_ion_pdata.heaps[i]);
  496. int use_cma = 0;
  497. if (heap->extra_data) {
  498. int fixed_position = NOT_FIXED;
  499. switch ((int) heap->type) {
  500. case ION_HEAP_TYPE_CP:
  501. if (((struct ion_cp_heap_pdata *)
  502. heap->extra_data)->is_cma) {
  503. heap->size = ALIGN(heap->size,
  504. cma_alignment);
  505. use_cma = 1;
  506. }
  507. fixed_position = ((struct ion_cp_heap_pdata *)
  508. heap->extra_data)->fixed_position;
  509. break;
  510. case ION_HEAP_TYPE_DMA:
  511. use_cma = 1;
  512. /* Purposely fall through here */
  513. case ION_HEAP_TYPE_CARVEOUT:
  514. fixed_position = ((struct ion_co_heap_pdata *)
  515. heap->extra_data)->fixed_position;
  516. break;
  517. default:
  518. break;
  519. }
  520. if (fixed_position != NOT_FIXED)
  521. fixed_size += heap->size;
  522. else
  523. reserve_mem_for_ion(MEMTYPE_EBI1, heap->size);
  524. if (fixed_position == FIXED_LOW) {
  525. fixed_low_size += heap->size;
  526. low_use_cma = use_cma;
  527. } else if (fixed_position == FIXED_MIDDLE) {
  528. fixed_middle_size += heap->size;
  529. middle_use_cma = use_cma;
  530. } else if (fixed_position == FIXED_HIGH) {
  531. fixed_high_size += heap->size;
  532. high_use_cma = use_cma;
  533. } else if (use_cma) {
  534. /*
  535. * Heaps that use CMA but are not part of the
  536. * fixed set. Create wherever.
  537. */
  538. dma_declare_contiguous(
  539. heap->priv,
  540. heap->size,
  541. 0,
  542. 0xb0000000);
  543. }
  544. }
  545. }
  546. if (!fixed_size)
  547. return;
  548. /*
  549. * Given the setup for the fixed area, we can't round up all sizes.
  550. * Some sizes must be set up exactly and aligned correctly. Incorrect
  551. * alignments are considered a configuration issue
  552. */
  553. fixed_low_start = MSM8930_FIXED_AREA_START;
  554. if (low_use_cma) {
  555. BUG_ON(!IS_ALIGNED(fixed_low_size + HOLE_SIZE, cma_alignment));
  556. BUG_ON(!IS_ALIGNED(fixed_low_start, cma_alignment));
  557. } else {
  558. BUG_ON(!IS_ALIGNED(fixed_low_size + HOLE_SIZE, SECTION_SIZE));
  559. ret = memblock_remove(fixed_low_start,
  560. fixed_low_size + HOLE_SIZE);
  561. BUG_ON(ret);
  562. }
  563. fixed_middle_start = fixed_low_start + fixed_low_size + HOLE_SIZE;
  564. if (middle_use_cma) {
  565. BUG_ON(!IS_ALIGNED(fixed_middle_start, cma_alignment));
  566. BUG_ON(!IS_ALIGNED(fixed_middle_size, cma_alignment));
  567. } else {
  568. BUG_ON(!IS_ALIGNED(fixed_middle_size, SECTION_SIZE));
  569. ret = memblock_remove(fixed_middle_start, fixed_middle_size);
  570. BUG_ON(ret);
  571. }
  572. fixed_high_start = fixed_middle_start + fixed_middle_size;
  573. if (high_use_cma) {
  574. fixed_high_size = ALIGN(fixed_high_size, cma_alignment);
  575. BUG_ON(!IS_ALIGNED(fixed_high_start, cma_alignment));
  576. } else {
  577. /* This is the end of the fixed area so it's okay to round up */
  578. fixed_high_size = ALIGN(fixed_high_size, SECTION_SIZE);
  579. ret = memblock_remove(fixed_high_start, fixed_high_size);
  580. BUG_ON(ret);
  581. }
  582. for (i = 0; i < msm8930_ion_pdata.nr; ++i) {
  583. struct ion_platform_heap *heap = &(msm8930_ion_pdata.heaps[i]);
  584. if (heap->extra_data) {
  585. int fixed_position = NOT_FIXED;
  586. struct ion_cp_heap_pdata *pdata = NULL;
  587. switch ((int) heap->type) {
  588. case ION_HEAP_TYPE_CP:
  589. pdata =
  590. (struct ion_cp_heap_pdata *)heap->extra_data;
  591. fixed_position = pdata->fixed_position;
  592. break;
  593. case ION_HEAP_TYPE_DMA:
  594. case ION_HEAP_TYPE_CARVEOUT:
  595. fixed_position = ((struct ion_co_heap_pdata *)
  596. heap->extra_data)->fixed_position;
  597. break;
  598. default:
  599. break;
  600. }
  601. switch (fixed_position) {
  602. case FIXED_LOW:
  603. heap->base = fixed_low_start;
  604. break;
  605. case FIXED_MIDDLE:
  606. heap->base = fixed_middle_start;
  607. if (middle_use_cma)
  608. dma_declare_contiguous(
  609. &ion_mm_heap_device.dev,
  610. heap->size,
  611. fixed_middle_start,
  612. 0xa0000000);
  613. pdata->secure_base = fixed_middle_start
  614. - HOLE_SIZE;
  615. pdata->secure_size = HOLE_SIZE + heap->size;
  616. break;
  617. case FIXED_HIGH:
  618. heap->base = fixed_high_start;
  619. break;
  620. default:
  621. break;
  622. }
  623. }
  624. }
  625. #endif
  626. }
  627. static void __init reserve_mdp_memory(void)
  628. {
  629. msm8930_mdp_writeback(msm8930_reserve_table);
  630. }
  631. #ifdef CONFIG_MSM_CACHE_DUMP
  632. static void __init reserve_cache_dump_memory(void)
  633. {
  634. unsigned int total;
  635. total = msm8930_cache_dump_pdata.l1_size +
  636. msm8930_cache_dump_pdata.l2_size;
  637. msm8930_reserve_table[MEMTYPE_EBI1].size += total;
  638. }
  639. #else
  640. static void __init reserve_cache_dump_memory(void) { }
  641. #endif
  642. static void __init msm8930_calculate_reserve_sizes(void)
  643. {
  644. size_pmem_devices();
  645. reserve_pmem_memory();
  646. reserve_ion_memory();
  647. reserve_mdp_memory();
  648. reserve_rtb_memory();
  649. reserve_cache_dump_memory();
  650. }
  651. static struct reserve_info msm8930_reserve_info __initdata = {
  652. .memtype_reserve_table = msm8930_reserve_table,
  653. .calculate_reserve_sizes = msm8930_calculate_reserve_sizes,
  654. .reserve_fixed_area = msm8930_reserve_fixed_area,
  655. .paddr_to_memtype = msm8930_paddr_to_memtype,
  656. };
  657. static int msm8930_memory_bank_size(void)
  658. {
  659. return 1<<29;
  660. }
  661. static void __init locate_unstable_memory(void)
  662. {
  663. struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
  664. unsigned long bank_size;
  665. unsigned long low, high;
  666. bank_size = msm8930_memory_bank_size();
  667. low = meminfo.bank[0].start;
  668. high = mb->start + mb->size;
  669. /* Check if 32 bit overflow occured */
  670. if (high < mb->start)
  671. high -= PAGE_SIZE;
  672. if (high < MAX_FIXED_AREA_SIZE + MSM8930_FIXED_AREA_START)
  673. panic("fixed area extends beyond end of memory\n");
  674. low &= ~(bank_size - 1);
  675. if (high - low <= bank_size)
  676. goto no_dmm;
  677. msm8930_reserve_info.bank_size = bank_size;
  678. #ifdef CONFIG_ENABLE_DMM
  679. msm8930_reserve_info.low_unstable_address = mb->start -
  680. MIN_MEMORY_BLOCK_SIZE + mb->size;
  681. msm8930_reserve_info.max_unstable_size = MIN_MEMORY_BLOCK_SIZE;
  682. pr_info("low unstable address %lx max size %lx bank size %lx\n",
  683. msm8930_reserve_info.low_unstable_address,
  684. msm8930_reserve_info.max_unstable_size,
  685. msm8930_reserve_info.bank_size);
  686. return;
  687. #endif
  688. no_dmm:
  689. msm8930_reserve_info.low_unstable_address = high;
  690. msm8930_reserve_info.max_unstable_size = 0;
  691. }
  692. static void __init place_movable_zone(void)
  693. {
  694. #ifdef CONFIG_ENABLE_DMM
  695. movable_reserved_start = msm8930_reserve_info.low_unstable_address;
  696. movable_reserved_size = msm8930_reserve_info.max_unstable_size;
  697. pr_info("movable zone start %lx size %lx\n",
  698. movable_reserved_start, movable_reserved_size);
  699. #endif
  700. }
  701. static void __init msm8930_early_memory(void)
  702. {
  703. reserve_info = &msm8930_reserve_info;
  704. locate_unstable_memory();
  705. place_movable_zone();
  706. }
  707. static void __init msm8930_reserve(void)
  708. {
  709. msm_reserve();
  710. }
  711. static int msm8930_change_memory_power(u64 start, u64 size,
  712. int change_type)
  713. {
  714. return soc_change_memory_power(start, size, change_type);
  715. }
  716. static void __init msm8930_allocate_memory_regions(void)
  717. {
  718. msm8930_allocate_fb_region();
  719. }
  720. #ifdef CONFIG_WCD9304_CODEC
  721. #define SITAR_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS + NR_PM8921_IRQS)
  722. /* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
  723. * 4 micbiases are used to power various analog and digital
  724. * microphones operating at 1800 mV. Technically, all micbiases
  725. * can source from single cfilter since all microphones operate
  726. * at the same voltage level. The arrangement below is to make
  727. * sure all cfilters are exercised. LDO_H regulator ouput level
  728. * does not need to be as high as 2.85V. It is choosen for
  729. * microphone sensitivity purpose.
  730. */
  731. static struct wcd9xxx_pdata sitar_platform_data = {
  732. .slimbus_slave_device = {
  733. .name = "sitar-slave",
  734. .e_addr = {0, 0, 0x00, 0, 0x17, 2},
  735. },
  736. .irq = MSM_GPIO_TO_INT(62),
  737. .irq_base = SITAR_INTERRUPT_BASE,
  738. .num_irqs = NR_WCD9XXX_IRQS,
  739. .reset_gpio = 42,
  740. .micbias = {
  741. .ldoh_v = SITAR_LDOH_2P85_V,
  742. .cfilt1_mv = 1800,
  743. .cfilt2_mv = 1800,
  744. .bias1_cfilt_sel = SITAR_CFILT1_SEL,
  745. .bias2_cfilt_sel = SITAR_CFILT2_SEL,
  746. .bias1_cap_mode = MICBIAS_EXT_BYP_CAP,
  747. .bias2_cap_mode = MICBIAS_NO_EXT_BYP_CAP,
  748. },
  749. .regulator = {
  750. {
  751. .name = "CDC_VDD_CP",
  752. .min_uV = 1800000,
  753. .max_uV = 2200000,
  754. .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
  755. },
  756. {
  757. .name = "CDC_VDDA_RX",
  758. .min_uV = 1800000,
  759. .max_uV = 1800000,
  760. .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
  761. },
  762. {
  763. .name = "CDC_VDDA_TX",
  764. .min_uV = 1800000,
  765. .max_uV = 1800000,
  766. .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
  767. },
  768. {
  769. .name = "VDDIO_CDC",
  770. .min_uV = 1800000,
  771. .max_uV = 1800000,
  772. .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
  773. },
  774. {
  775. .name = "VDDD_CDC_D",
  776. .min_uV = 1200000,
  777. .max_uV = 1250000,
  778. .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
  779. },
  780. {
  781. .name = "CDC_VDDA_A_1P2V",
  782. .min_uV = 1200000,
  783. .max_uV = 1250000,
  784. .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
  785. },
  786. },
  787. };
  788. static struct slim_device msm_slim_sitar = {
  789. .name = "sitar-slim",
  790. .e_addr = {0, 1, 0x00, 0, 0x17, 2},
  791. .dev = {
  792. .platform_data = &sitar_platform_data,
  793. },
  794. };
  795. static struct wcd9xxx_pdata sitar1p1_platform_data = {
  796. .slimbus_slave_device = {
  797. .name = "sitar-slave",
  798. .e_addr = {0, 0, 0x70, 0, 0x17, 2},
  799. },
  800. .irq = MSM_GPIO_TO_INT(62),
  801. .irq_base = SITAR_INTERRUPT_BASE,
  802. .num_irqs = NR_WCD9XXX_IRQS,
  803. .reset_gpio = 42,
  804. .micbias = {
  805. .ldoh_v = SITAR_LDOH_2P85_V,
  806. .cfilt1_mv = 1800,
  807. .cfilt2_mv = 1800,
  808. .bias1_cfilt_sel = SITAR_CFILT1_SEL,
  809. .bias2_cfilt_sel = SITAR_CFILT2_SEL,
  810. .bias1_cap_mode = MICBIAS_EXT_BYP_CAP,
  811. .bias2_cap_mode = MICBIAS_NO_EXT_BYP_CAP,
  812. },
  813. .regulator = {
  814. {
  815. .name = "CDC_VDD_CP",
  816. .min_uV = 1800000,
  817. .max_uV = 2200000,
  818. .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
  819. },
  820. {
  821. .name = "CDC_VDDA_RX",
  822. .min_uV = 1800000,
  823. .max_uV = 1800000,
  824. .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
  825. },
  826. {
  827. .name = "CDC_VDDA_TX",
  828. .min_uV = 1800000,
  829. .max_uV = 1800000,
  830. .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
  831. },
  832. {
  833. .name = "VDDIO_CDC",
  834. .min_uV = 1800000,
  835. .max_uV = 1800000,
  836. .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
  837. },
  838. {
  839. .name = "VDDD_CDC_D",
  840. .min_uV = 1200000,
  841. .max_uV = 1250000,
  842. .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
  843. },
  844. {
  845. .name = "CDC_VDDA_A_1P2V",
  846. .min_uV = 1200000,
  847. .max_uV = 1250000,
  848. .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
  849. },
  850. },
  851. };
  852. static struct slim_device msm_slim_sitar1p1 = {
  853. .name = "sitar1p1-slim",
  854. .e_addr = {0, 1, 0x70, 0, 0x17, 2},
  855. .dev = {
  856. .platform_data = &sitar1p1_platform_data,
  857. },
  858. };
  859. #endif
  860. static struct slim_boardinfo msm_slim_devices[] = {
  861. #ifdef CONFIG_WCD9304_CODEC
  862. {
  863. .bus_num = 1,
  864. .slim_slave = &msm_slim_sitar,
  865. },
  866. {
  867. .bus_num = 1,
  868. .slim_slave = &msm_slim_sitar1p1,
  869. },
  870. #endif
  871. /* add more slimbus slaves as needed */
  872. };
  873. #define MSM_WCNSS_PHYS 0x03000000
  874. #define MSM_WCNSS_SIZE 0x280000
  875. static struct resource resources_wcnss_wlan[] = {
  876. {
  877. .start = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
  878. .end = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
  879. .name = "wcnss_wlanrx_irq",
  880. .flags = IORESOURCE_IRQ,
  881. },
  882. {
  883. .start = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
  884. .end = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
  885. .name = "wcnss_wlantx_irq",
  886. .flags = IORESOURCE_IRQ,
  887. },
  888. {
  889. .start = MSM_WCNSS_PHYS,
  890. .end = MSM_WCNSS_PHYS + MSM_WCNSS_SIZE - 1,
  891. .name = "wcnss_mmio",
  892. .flags = IORESOURCE_MEM,
  893. },
  894. {
  895. .start = 84,
  896. .end = 88,
  897. .name = "wcnss_gpios_5wire",
  898. .flags = IORESOURCE_IO,
  899. },
  900. };
  901. static struct qcom_wcnss_opts qcom_wcnss_pdata = {
  902. .has_48mhz_xo = 1,
  903. };
  904. static struct platform_device msm_device_wcnss_wlan = {
  905. .name = "wcnss_wlan",
  906. .id = 0,
  907. .num_resources = ARRAY_SIZE(resources_wcnss_wlan),
  908. .resource = resources_wcnss_wlan,
  909. .dev = {.platform_data = &qcom_wcnss_pdata},
  910. };
  911. #ifdef CONFIG_QSEECOM
  912. /* qseecom bus scaling */
  913. static struct msm_bus_vectors qseecom_clks_init_vectors[] = {
  914. {
  915. .src = MSM_BUS_MASTER_SPS,
  916. .dst = MSM_BUS_SLAVE_EBI_CH0,
  917. .ib = 0,
  918. .ab = 0,
  919. },
  920. {
  921. .src = MSM_BUS_MASTER_SPS,
  922. .dst = MSM_BUS_SLAVE_SPS,
  923. .ib = 0,
  924. .ab = 0,
  925. },
  926. {
  927. .src = MSM_BUS_MASTER_SPDM,
  928. .dst = MSM_BUS_SLAVE_SPDM,
  929. .ib = 0,
  930. .ab = 0,
  931. },
  932. };
  933. static struct msm_bus_vectors qseecom_enable_dfab_vectors[] = {
  934. {
  935. .src = MSM_BUS_MASTER_SPS,
  936. .dst = MSM_BUS_SLAVE_EBI_CH0,
  937. .ib = (492 * 8) * 1000000UL,
  938. .ab = (492 * 8) * 100000UL,
  939. },
  940. {
  941. .src = MSM_BUS_MASTER_SPS,
  942. .dst = MSM_BUS_SLAVE_SPS,
  943. .ib = (492 * 8) * 1000000UL,
  944. .ab = (492 * 8) * 100000UL,
  945. },
  946. {
  947. .src = MSM_BUS_MASTER_SPDM,
  948. .dst = MSM_BUS_SLAVE_SPDM,
  949. .ib = 0,
  950. .ab = 0,
  951. },
  952. };
  953. static struct msm_bus_vectors qseecom_enable_sfpb_vectors[] = {
  954. {
  955. .src = MSM_BUS_MASTER_SPS,
  956. .dst = MSM_BUS_SLAVE_EBI_CH0,
  957. .ib = 0,
  958. .ab = 0,
  959. },
  960. {
  961. .src = MSM_BUS_MASTER_SPS,
  962. .dst = MSM_BUS_SLAVE_SPS,
  963. .ib = 0,
  964. .ab = 0,
  965. },
  966. {
  967. .src = MSM_BUS_MASTER_SPDM,
  968. .dst = MSM_BUS_SLAVE_SPDM,
  969. .ib = (64 * 8) * 1000000UL,
  970. .ab = (64 * 8) * 100000UL,
  971. },
  972. };
  973. static struct msm_bus_vectors qseecom_enable_dfab_sfpb_vectors[] = {
  974. {
  975. .src = MSM_BUS_MASTER_SPS,
  976. .dst = MSM_BUS_SLAVE_EBI_CH0,
  977. .ib = (492 * 8) * 1000000UL,
  978. .ab = (492 * 8) * 100000UL,
  979. },
  980. {
  981. .src = MSM_BUS_MASTER_SPS,
  982. .dst = MSM_BUS_SLAVE_SPS,
  983. .ib = (492 * 8) * 1000000UL,
  984. .ab = (492 * 8) * 100000UL,
  985. },
  986. {
  987. .src = MSM_BUS_MASTER_SPDM,
  988. .dst = MSM_BUS_SLAVE_SPDM,
  989. .ib = (64 * 8) * 1000000UL,
  990. .ab = (64 * 8) * 100000UL,
  991. },
  992. };
  993. static struct msm_bus_paths qseecom_hw_bus_scale_usecases[] = {
  994. {
  995. ARRAY_SIZE(qseecom_clks_init_vectors),
  996. qseecom_clks_init_vectors,
  997. },
  998. {
  999. ARRAY_SIZE(qseecom_enable_dfab_vectors),
  1000. qseecom_enable_sfpb_vectors,
  1001. },
  1002. {
  1003. ARRAY_SIZE(qseecom_enable_sfpb_vectors),
  1004. qseecom_enable_sfpb_vectors,
  1005. },
  1006. {
  1007. ARRAY_SIZE(qseecom_enable_dfab_sfpb_vectors),
  1008. qseecom_enable_dfab_sfpb_vectors,
  1009. },
  1010. };
  1011. static struct msm_bus_scale_pdata qseecom_bus_pdata = {
  1012. qseecom_hw_bus_scale_usecases,
  1013. ARRAY_SIZE(qseecom_hw_bus_scale_usecases),
  1014. .name = "qsee",
  1015. };
  1016. static struct platform_device qseecom_device = {
  1017. .name = "qseecom",
  1018. .id = 0,
  1019. .dev = {
  1020. .platform_data = &qseecom_bus_pdata,
  1021. },
  1022. };
  1023. #endif
  1024. #if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
  1025. defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
  1026. defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
  1027. defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
  1028. #define QCE_SIZE 0x10000
  1029. #define QCE_0_BASE 0x18500000
  1030. #define QCE_HW_KEY_SUPPORT 0
  1031. #define QCE_SHA_HMAC_SUPPORT 1
  1032. #define QCE_SHARE_CE_RESOURCE 1
  1033. #define QCE_CE_SHARED 0
  1034. /* Begin Bus scaling definitions */
  1035. static struct msm_bus_vectors crypto_hw_init_vectors[] = {
  1036. {
  1037. .src = MSM_BUS_MASTER_ADM_PORT0,
  1038. .dst = MSM_BUS_SLAVE_EBI_CH0,
  1039. .ab = 0,
  1040. .ib = 0,
  1041. },
  1042. {
  1043. .src = MSM_BUS_MASTER_ADM_PORT1,
  1044. .dst = MSM_BUS_SLAVE_GSBI1_UART,
  1045. .ab = 0,
  1046. .ib = 0,
  1047. },
  1048. };
  1049. static struct msm_bus_vectors crypto_hw_active_vectors[] = {
  1050. {
  1051. .src = MSM_BUS_MASTER_ADM_PORT0,
  1052. .dst = MSM_BUS_SLAVE_EBI_CH0,
  1053. .ab = 70000000UL,
  1054. .ib = 70000000UL,
  1055. },
  1056. {
  1057. .src = MSM_BUS_MASTER_ADM_PORT1,
  1058. .dst = MSM_BUS_SLAVE_GSBI1_UART,
  1059. .ab = 2480000000UL,
  1060. .ib = 2480000000UL,
  1061. },
  1062. };
  1063. static struct msm_bus_paths crypto_hw_bus_scale_usecases[] = {
  1064. {
  1065. ARRAY_SIZE(crypto_hw_init_vectors),
  1066. crypto_hw_init_vectors,
  1067. },
  1068. {
  1069. ARRAY_SIZE(crypto_hw_active_vectors),
  1070. crypto_hw_active_vectors,
  1071. },
  1072. };
  1073. static struct msm_bus_scale_pdata crypto_hw_bus_scale_pdata = {
  1074. crypto_hw_bus_scale_usecases,
  1075. ARRAY_SIZE(crypto_hw_bus_scale_usecases),
  1076. .name = "cryptohw",
  1077. };
  1078. /* End Bus Scaling Definitions*/
  1079. static struct resource qcrypto_resources[] = {
  1080. [0] = {
  1081. .start = QCE_0_BASE,
  1082. .end = QCE_0_BASE + QCE_SIZE - 1,
  1083. .flags = IORESOURCE_MEM,
  1084. },
  1085. [1] = {
  1086. .name = "crypto_channels",
  1087. .start = DMOV_CE_IN_CHAN,
  1088. .end = DMOV_CE_OUT_CHAN,
  1089. .flags = IORESOURCE_DMA,
  1090. },
  1091. [2] = {
  1092. .name = "crypto_crci_in",
  1093. .start = DMOV_CE_IN_CRCI,
  1094. .end = DMOV_CE_IN_CRCI,
  1095. .flags = IORESOURCE_DMA,
  1096. },
  1097. [3] = {
  1098. .name = "crypto_crci_out",
  1099. .start = DMOV_CE_OUT_CRCI,
  1100. .end = DMOV_CE_OUT_CRCI,
  1101. .flags = IORESOURCE_DMA,
  1102. },
  1103. };
  1104. static struct resource qcedev_resources[] = {
  1105. [0] = {
  1106. .start = QCE_0_BASE,
  1107. .end = QCE_0_BASE + QCE_SIZE - 1,
  1108. .flags = IORESOURCE_MEM,
  1109. },
  1110. [1] = {
  1111. .name = "crypto_channels",
  1112. .start = DMOV_CE_IN_CHAN,
  1113. .end = DMOV_CE_OUT_CHAN,
  1114. .flags = IORESOURCE_DMA,
  1115. },
  1116. [2] = {
  1117. .name = "crypto_crci_in",
  1118. .start = DMOV_CE_IN_CRCI,
  1119. .end = DMOV_CE_IN_CRCI,
  1120. .flags = IORESOURCE_DMA,
  1121. },
  1122. [3] = {
  1123. .name = "crypto_crci_out",
  1124. .start = DMOV_CE_OUT_CRCI,
  1125. .end = DMOV_CE_OUT_CRCI,
  1126. .flags = IORESOURCE_DMA,
  1127. },
  1128. };
  1129. #endif
  1130. #if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
  1131. defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
  1132. static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
  1133. .ce_shared = QCE_CE_SHARED,
  1134. .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
  1135. .hw_key_support = QCE_HW_KEY_SUPPORT,
  1136. .sha_hmac = QCE_SHA_HMAC_SUPPORT,
  1137. .bus_scale_table = &crypto_hw_bus_scale_pdata,
  1138. };
  1139. static struct platform_device qcrypto_device = {
  1140. .name = "qcrypto",
  1141. .id = 0,
  1142. .num_resources = ARRAY_SIZE(qcrypto_resources),
  1143. .resource = qcrypto_resources,
  1144. .dev = {
  1145. .coherent_dma_mask = DMA_BIT_MASK(32),
  1146. .platform_data = &qcrypto_ce_hw_suppport,
  1147. },
  1148. };
  1149. #endif
  1150. #if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
  1151. defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
  1152. static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
  1153. .ce_shared = QCE_CE_SHARED,
  1154. .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
  1155. .hw_key_support = QCE_HW_KEY_SUPPORT,
  1156. .sha_hmac = QCE_SHA_HMAC_SUPPORT,
  1157. .bus_scale_table = &crypto_hw_bus_scale_pdata,
  1158. };
  1159. static struct platform_device qcedev_device = {
  1160. .name = "qce",
  1161. .id = 0,
  1162. .num_resources = ARRAY_SIZE(qcedev_resources),
  1163. .resource = qcedev_resources,
  1164. .dev = {
  1165. .coherent_dma_mask = DMA_BIT_MASK(32),
  1166. .platform_data = &qcedev_ce_hw_suppport,
  1167. },
  1168. };
  1169. #endif
  1170. #define MDM2AP_ERRFATAL 70
  1171. #define AP2MDM_ERRFATAL 95
  1172. #define MDM2AP_STATUS 69
  1173. #define AP2MDM_STATUS 94
  1174. #define AP2MDM_PMIC_RESET_N 80
  1175. #define AP2MDM_KPDPWR_N 81
  1176. static struct resource mdm_resources[] = {
  1177. {
  1178. .start = MDM2AP_ERRFATAL,
  1179. .end = MDM2AP_ERRFATAL,
  1180. .name = "MDM2AP_ERRFATAL",
  1181. .flags = IORESOURCE_IO,
  1182. },
  1183. {
  1184. .start = AP2MDM_ERRFATAL,
  1185. .end = AP2MDM_ERRFATAL,
  1186. .name = "AP2MDM_ERRFATAL",
  1187. .flags = IORESOURCE_IO,
  1188. },
  1189. {
  1190. .start = MDM2AP_STATUS,
  1191. .end = MDM2AP_STATUS,
  1192. .name = "MDM2AP_STATUS",
  1193. .flags = IORESOURCE_IO,
  1194. },
  1195. {
  1196. .start = AP2MDM_STATUS,
  1197. .end = AP2MDM_STATUS,
  1198. .name = "AP2MDM_STATUS",
  1199. .flags = IORESOURCE_IO,
  1200. },
  1201. {
  1202. .start = AP2MDM_PMIC_RESET_N,
  1203. .end = AP2MDM_PMIC_RESET_N,
  1204. .name = "AP2MDM_PMIC_RESET_N",
  1205. .flags = IORESOURCE_IO,
  1206. },
  1207. {
  1208. .start = AP2MDM_KPDPWR_N,
  1209. .end = AP2MDM_KPDPWR_N,
  1210. .name = "AP2MDM_KPDPWR_N",
  1211. .flags = IORESOURCE_IO,
  1212. },
  1213. };
  1214. static struct mdm_platform_data mdm_platform_data = {
  1215. .mdm_version = "2.5",
  1216. };
  1217. static struct platform_device mdm_device = {
  1218. .name = "mdm2_modem",
  1219. .id = -1,
  1220. .num_resources = ARRAY_SIZE(mdm_resources),
  1221. .resource = mdm_resources,
  1222. .dev = {
  1223. .platform_data = &mdm_platform_data,
  1224. },
  1225. };
  1226. static struct platform_device *mdm_devices[] __initdata = {
  1227. &mdm_device,
  1228. };
  1229. #ifdef CONFIG_MSM_MPM
  1230. static uint16_t msm_mpm_irqs_m2a[MSM_MPM_NR_MPM_IRQS] __initdata = {
  1231. [1] = MSM_GPIO_TO_INT(46),
  1232. [2] = MSM_GPIO_TO_INT(150),
  1233. [4] = MSM_GPIO_TO_INT(103),
  1234. [5] = MSM_GPIO_TO_INT(104),
  1235. [6] = MSM_GPIO_TO_INT(105),
  1236. [7] = MSM_GPIO_TO_INT(106),
  1237. [8] = MSM_GPIO_TO_INT(107),
  1238. [9] = MSM_GPIO_TO_INT(7),
  1239. [10] = MSM_GPIO_TO_INT(11),
  1240. [11] = MSM_GPIO_TO_INT(15),
  1241. [12] = MSM_GPIO_TO_INT(19),
  1242. [13] = MSM_GPIO_TO_INT(23),
  1243. [14] = MSM_GPIO_TO_INT(27),
  1244. [15] = MSM_GPIO_TO_INT(31),
  1245. [16] = MSM_GPIO_TO_INT(35),
  1246. [19] = MSM_GPIO_TO_INT(90),
  1247. [20] = MSM_GPIO_TO_INT(92),
  1248. [23] = MSM_GPIO_TO_INT(85),
  1249. [24] = MSM_GPIO_TO_INT(83),
  1250. [25] = USB1_HS_IRQ,
  1251. [26] = MSM_GPIO_TO_INT(6),
  1252. [27] = HDMI_IRQ,
  1253. [29] = MSM_GPIO_TO_INT(10),
  1254. [30] = MSM_GPIO_TO_INT(102),
  1255. [31] = MSM_GPIO_TO_INT(81),
  1256. [32] = MSM_GPIO_TO_INT(78),
  1257. [33] = MSM_GPIO_TO_INT(94),
  1258. [34] = MSM_GPIO_TO_INT(72),
  1259. [35] = MSM_GPIO_TO_INT(39),
  1260. [36] = MSM_GPIO_TO_INT(43),
  1261. [37] = MSM_GPIO_TO_INT(61),
  1262. [38] = MSM_GPIO_TO_INT(50),
  1263. [39] = MSM_GPIO_TO_INT(42),
  1264. [41] = MSM_GPIO_TO_INT(62),
  1265. [42] = MSM_GPIO_TO_INT(8),
  1266. [43] = MSM_GPIO_TO_INT(33),
  1267. [44] = MSM_GPIO_TO_INT(70),
  1268. [45] = MSM_GPIO_TO_INT(69),
  1269. [46] = MSM_GPIO_TO_INT(67),
  1270. [47] = MSM_GPIO_TO_INT(65),
  1271. [48] = MSM_GPIO_TO_INT(55),
  1272. [49] = MSM_GPIO_TO_INT(74),
  1273. [50] = MSM_GPIO_TO_INT(98),
  1274. [51] = MSM_GPIO_TO_INT(49),
  1275. [52] = MSM_GPIO_TO_INT(40),
  1276. [53] = MSM_GPIO_TO_INT(37),
  1277. [54] = MSM_GPIO_TO_INT(24),
  1278. [55] = MSM_GPIO_TO_INT(14),
  1279. };
  1280. static uint16_t msm_mpm_bypassed_apps_irqs[] __initdata = {
  1281. TLMM_MSM_SUMMARY_IRQ,
  1282. RPM_APCC_CPU0_GP_HIGH_IRQ,
  1283. RPM_APCC_CPU0_GP_MEDIUM_IRQ,
  1284. RPM_APCC_CPU0_GP_LOW_IRQ,
  1285. RPM_APCC_CPU0_WAKE_UP_IRQ,
  1286. RPM_APCC_CPU1_GP_HIGH_IRQ,
  1287. RPM_APCC_CPU1_GP_MEDIUM_IRQ,
  1288. RPM_APCC_CPU1_GP_LOW_IRQ,
  1289. RPM_APCC_CPU1_WAKE_UP_IRQ,
  1290. MSS_TO_APPS_IRQ_0,
  1291. MSS_TO_APPS_IRQ_1,
  1292. MSS_TO_APPS_IRQ_2,
  1293. MSS_TO_APPS_IRQ_3,
  1294. MSS_TO_APPS_IRQ_4,
  1295. MSS_TO_APPS_IRQ_5,
  1296. MSS_TO_APPS_IRQ_6,
  1297. MSS_TO_APPS_IRQ_7,
  1298. MSS_TO_APPS_IRQ_8,
  1299. MSS_TO_APPS_IRQ_9,
  1300. LPASS_SCSS_GP_LOW_IRQ,
  1301. LPASS_SCSS_GP_MEDIUM_IRQ,
  1302. LPASS_SCSS_GP_HIGH_IRQ,
  1303. SPS_MTI_30,
  1304. SPS_MTI_31,
  1305. RIVA_APSS_SPARE_IRQ,
  1306. RIVA_APPS_WLAN_SMSM_IRQ,
  1307. RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
  1308. RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
  1309. };
  1310. struct msm_mpm_device_data msm8930_mpm_dev_data __initdata = {
  1311. .irqs_m2a = msm_mpm_irqs_m2a,
  1312. .irqs_m2a_size = ARRAY_SIZE(msm_mpm_irqs_m2a),
  1313. .bypassed_apps_irqs = msm_mpm_bypassed_apps_irqs,
  1314. .bypassed_apps_irqs_size = ARRAY_SIZE(msm_mpm_bypassed_apps_irqs),
  1315. .mpm_request_reg_base = MSM_RPM_BASE + 0x9d8,
  1316. .mpm_status_reg_base = MSM_RPM_BASE + 0xdf8,
  1317. .mpm_apps_ipc_reg = MSM_APCS_GCC_BASE + 0x008,
  1318. .mpm_apps_ipc_val = BIT(1),
  1319. .mpm_ipc_irq = RPM_APCC_CPU0_GP_MEDIUM_IRQ,
  1320. };
  1321. #endif
  1322. #define MSM_SHARED_RAM_PHYS 0x80000000
  1323. static void __init msm8930_map_io(void)
  1324. {
  1325. msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
  1326. msm_map_msm8930_io();
  1327. if (socinfo_init() < 0)
  1328. pr_err("socinfo_init() failed!\n");
  1329. }
  1330. static void __init msm8930_init_irq(void)
  1331. {
  1332. struct msm_mpm_device_data *data = NULL;
  1333. #ifdef CONFIG_MSM_MPM
  1334. data = &msm8930_mpm_dev_data;
  1335. #endif
  1336. msm_mpm_irq_extn_init(data);
  1337. gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
  1338. (void *)MSM_QGIC_CPU_BASE);
  1339. }
  1340. static void __init msm8930_init_buses(void)
  1341. {
  1342. #ifdef CONFIG_MSM_BUS_SCALING
  1343. msm_bus_rpm_set_mt_mask();
  1344. msm_bus_8930_apps_fabric_pdata.rpm_enabled = 1;
  1345. msm_bus_8930_sys_fabric_pdata.rpm_enabled = 1;
  1346. msm_bus_8930_mm_fabric_pdata.rpm_enabled = 1;
  1347. msm_bus_8930_apps_fabric.dev.platform_data =
  1348. &msm_bus_8930_apps_fabric_pdata;
  1349. msm_bus_8930_sys_fabric.dev.platform_data =
  1350. &msm_bus_8930_sys_fabric_pdata;
  1351. msm_bus_8930_mm_fabric.dev.platform_data =
  1352. &msm_bus_8930_mm_fabric_pdata;
  1353. msm_bus_8930_sys_fpb.dev.platform_data = &msm_bus_8930_sys_fpb_pdata;
  1354. msm_bus_8930_cpss_fpb.dev.platform_data = &msm_bus_8930_cpss_fpb_pdata;
  1355. #endif
  1356. }
  1357. static struct msm_spi_platform_data msm8960_qup_spi_gsbi1_pdata = {
  1358. .max_clock_speed = 15060000,
  1359. };
  1360. #ifdef CONFIG_USB_MSM_OTG_72K
  1361. static struct msm_otg_platform_data msm_otg_pdata;
  1362. #else
  1363. static int enable_usb_host_mode;
  1364. static int __init usb_host_mode_with_pm8917(char *param)
  1365. {
  1366. int ret;
  1367. ret = kstrtoint(param, 10, &enable_usb_host_mode);
  1368. return ret;
  1369. }
  1370. early_param("usb_host_mode_pm8917", usb_host_mode_with_pm8917);
  1371. #ifdef CONFIG_MSM_BUS_SCALING
  1372. /* Bandwidth requests (zero) if no vote placed */
  1373. static struct msm_bus_vectors usb_init_vectors[] = {
  1374. {
  1375. .src = MSM_BUS_MASTER_SPS,
  1376. .dst = MSM_BUS_SLAVE_EBI_CH0,
  1377. .ab = 0,
  1378. .ib = 0,
  1379. },
  1380. };
  1381. /* Bus bandwidth requests in Bytes/sec */
  1382. static struct msm_bus_vectors usb_max_vectors[] = {
  1383. {
  1384. .src = MSM_BUS_MASTER_SPS,
  1385. .dst = MSM_BUS_SLAVE_EBI_CH0,
  1386. .ab = 60000000, /* At least 480Mbps on bus. */
  1387. .ib = 960000000, /* MAX bursts rate */
  1388. },
  1389. };
  1390. static struct msm_bus_paths usb_bus_scale_usecases[] = {
  1391. {
  1392. ARRAY_SIZE(usb_init_vectors),
  1393. usb_init_vectors,
  1394. },
  1395. {
  1396. ARRAY_SIZE(usb_max_vectors),
  1397. usb_max_vectors,
  1398. },
  1399. };
  1400. static struct msm_bus_scale_pdata usb_bus_scale_pdata = {
  1401. usb_bus_scale_usecases,
  1402. ARRAY_SIZE(usb_bus_scale_usecases),
  1403. .name = "usb",
  1404. };
  1405. #endif
  1406. static int hsusb_phy_init_seq[] = {
  1407. 0x44, 0x80, /* set VBUS valid threshold
  1408. and disconnect valid threshold */
  1409. 0x38, 0x81, /* update DC voltage level */
  1410. 0x24, 0x82, /* set preemphasis and rise/fall time */
  1411. 0x13, 0x83, /* set source impedance adjusment */
  1412. -1};
  1413. #define MSM_MPM_PIN_USB1_OTGSESSVLD 40
  1414. static struct msm_otg_platform_data msm_otg_pdata = {
  1415. .mode = USB_OTG,
  1416. .otg_control = OTG_PMIC_CONTROL,
  1417. .phy_type = SNPS_28NM_INTEGRATED_PHY,
  1418. .power_budget = 750,
  1419. #ifdef CONFIG_MSM_BUS_SCALING
  1420. .bus_scale_table = &usb_bus_scale_pdata,
  1421. #endif
  1422. #ifdef CONFIG_FB_MSM_HDMI_MHL_8334
  1423. .mhl_dev_name = "sii8334",
  1424. #endif
  1425. .mpm_otgsessvld_int = MSM_MPM_PIN_USB1_OTGSESSVLD,
  1426. };
  1427. #endif
  1428. #define PID_MAGIC_ID 0x71432909
  1429. #define SERIAL_NUM_MAGIC_ID 0x61945374
  1430. #define SERIAL_NUMBER_LENGTH 127
  1431. #define DLOAD_USB_BASE_ADD 0x2A03F0C8
  1432. struct magic_num_struct {
  1433. uint32_t pid;
  1434. uint32_t serial_num;
  1435. };
  1436. struct dload_struct {
  1437. uint32_t reserved1;
  1438. uint32_t reserved2;
  1439. uint32_t reserved3;
  1440. uint16_t reserved4;
  1441. uint16_t pid;
  1442. char serial_number[SERIAL_NUMBER_LENGTH];
  1443. uint16_t reserved5;
  1444. struct magic_num_struct magic_struct;
  1445. };
  1446. static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
  1447. {
  1448. struct dload_struct __iomem *dload = 0;
  1449. dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
  1450. if (!dload) {
  1451. pr_err("%s: cannot remap I/O memory region: %08x\n",
  1452. __func__, DLOAD_USB_BASE_ADD);
  1453. return -ENXIO;
  1454. }
  1455. pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
  1456. __func__, dload, pid, snum);
  1457. /* update pid */
  1458. dload->magic_struct.pid = PID_MAGIC_ID;
  1459. dload->pid = pid;
  1460. /* update serial number */
  1461. dload->magic_struct.serial_num = 0;
  1462. if (!snum) {
  1463. memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
  1464. goto out;
  1465. }
  1466. dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
  1467. strlcpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
  1468. out:
  1469. iounmap(dload);
  1470. return 0;
  1471. }
  1472. static struct android_usb_platform_data android_usb_pdata = {
  1473. .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
  1474. };
  1475. static struct platform_device android_usb_device = {
  1476. .name = "android_usb",
  1477. .id = -1,
  1478. .dev = {
  1479. .platform_data = &android_usb_pdata,
  1480. },
  1481. };
  1482. static uint8_t spm_wfi_cmd_sequence[] __initdata = {
  1483. 0x03, 0x0f,
  1484. };
  1485. static uint8_t spm_retention_cmd_sequence[] __initdata = {
  1486. 0x00, 0x05, 0x03, 0x0D,
  1487. 0x0B, 0x00, 0x0f,
  1488. };
  1489. static uint8_t spm_power_collapse_without_rpm[] __initdata = {
  1490. 0x00, 0x24, 0x54, 0x10,
  1491. 0x09, 0x03, 0x01,
  1492. 0x10, 0x54, 0x30, 0x0C,
  1493. 0x24, 0x30, 0x0f,
  1494. };
  1495. static uint8_t spm_power_collapse_with_rpm[] __initdata = {
  1496. 0x00, 0x24, 0x54, 0x10,
  1497. 0x09, 0x07, 0x01, 0x0B,
  1498. 0x10, 0x54, 0x30, 0x0C,
  1499. 0x24, 0x30, 0x0f,
  1500. };
  1501. static struct msm_spm_seq_entry msm_spm_boot_cpu_seq_list[] __initdata = {
  1502. [0] = {
  1503. .mode = MSM_SPM_MODE_CLOCK_GATING,
  1504. .notify_rpm = false,
  1505. .cmd = spm_wfi_cmd_sequence,
  1506. },
  1507. [1] = {
  1508. .mode = MSM_SPM_MODE_POWER_RETENTION,
  1509. .notify_rpm = false,
  1510. .cmd = spm_retention_cmd_sequence,
  1511. },
  1512. [2] = {
  1513. .mode = MSM_SPM_MODE_POWER_COLLAPSE,
  1514. .notify_rpm = false,
  1515. .cmd = spm_power_collapse_without_rpm,
  1516. },
  1517. [3] = {
  1518. .mode = MSM_SPM_MODE_POWER_COLLAPSE,
  1519. .notify_rpm = true,
  1520. .cmd = spm_power_collapse_with_rpm,
  1521. },
  1522. };
  1523. static struct msm_spm_seq_entry msm_spm_nonboot_cpu_seq_list[] __initdata = {
  1524. [0] = {
  1525. .mode = MSM_SPM_MODE_CLOCK_GATING,
  1526. .notify_rpm = false,
  1527. .cmd = spm_wfi_cmd_sequence,
  1528. },
  1529. [1] = {
  1530. .mode = MSM_SPM_MODE_POWER_COLLAPSE,
  1531. .notify_rpm = false,
  1532. .cmd = spm_power_collapse_without_rpm,
  1533. },
  1534. [2] = {
  1535. .mode = MSM_SPM_MODE_POWER_COLLAPSE,
  1536. .notify_rpm = true,
  1537. .cmd = spm_power_collapse_with_rpm,
  1538. },
  1539. };
  1540. static struct msm_spm_platform_data msm_spm_data[] __initdata = {
  1541. [0] = {
  1542. .reg_base_addr = MSM_SAW0_BASE,
  1543. .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
  1544. #if defined(CONFIG_MSM_AVS_HW)
  1545. .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
  1546. .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
  1547. #endif
  1548. .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
  1549. .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x03020004,
  1550. .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0084009C,
  1551. .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A4001C,
  1552. .vctl_timeout_us = 50,
  1553. .num_modes = ARRAY_SIZE(msm_spm_boot_cpu_seq_list),
  1554. .modes = msm_spm_boot_cpu_seq_list,
  1555. },
  1556. [1] = {
  1557. .reg_base_addr = MSM_SAW1_BASE,
  1558. .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
  1559. #if defined(CONFIG_MSM_AVS_HW)
  1560. .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
  1561. .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
  1562. #endif
  1563. .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
  1564. .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
  1565. .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
  1566. .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
  1567. .vctl_timeout_us = 50,
  1568. .num_modes = ARRAY_SIZE(msm_spm_nonboot_cpu_seq_list),
  1569. .modes = msm_spm_nonboot_cpu_seq_list,
  1570. },
  1571. };
  1572. static uint8_t l2_spm_wfi_cmd_sequence[] __initdata = {
  1573. 0x00, 0x20, 0x03, 0x20,
  1574. 0x00, 0x0f,
  1575. };
  1576. static uint8_t l2_spm_gdhs_cmd_sequence[] __initdata = {
  1577. 0x00, 0x20, 0x34, 0x64,
  1578. 0x48, 0x07, 0x48, 0x20,
  1579. 0x50, 0x64, 0x04, 0x34,
  1580. 0x50, 0x0f,
  1581. };
  1582. static uint8_t l2_spm_power_off_cmd_sequence[] __initdata = {
  1583. 0x00, 0x10, 0x34, 0x64,
  1584. 0x48, 0x07, 0x48, 0x10,
  1585. 0x50, 0x64, 0x04, 0x34,
  1586. 0x50, 0x0F,
  1587. };
  1588. static struct msm_spm_seq_entry msm_spm_l2_seq_list[] __initdata = {
  1589. [0] = {
  1590. .mode = MSM_SPM_L2_MODE_RETENTION,
  1591. .notify_rpm = false,
  1592. .cmd = l2_spm_wfi_cmd_sequence,
  1593. },
  1594. [1] = {
  1595. .mode = MSM_SPM_L2_MODE_GDHS,
  1596. .notify_rpm = true,
  1597. .cmd = l2_spm_gdhs_cmd_sequence,
  1598. },
  1599. [2] = {
  1600. .mode = MSM_SPM_L2_MODE_POWER_COLLAPSE,
  1601. .notify_rpm = true,
  1602. .cmd = l2_spm_power_off_cmd_sequence,
  1603. },
  1604. };
  1605. static struct msm_spm_platform_data msm_spm_l2_data[] __initdata = {
  1606. [0] = {
  1607. .reg_base_addr = MSM_SAW_L2_BASE,
  1608. .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x00,
  1609. .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
  1610. .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x00A000AE,
  1611. .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A00020,
  1612. .modes = msm_spm_l2_seq_list,
  1613. .num_modes = ARRAY_SIZE(msm_spm_l2_seq_list),
  1614. },
  1615. };
  1616. #define ISA1200_HAP_EN_GPIO 77
  1617. #define ISA1200_HAP_LEN_GPIO 78
  1618. #define ISA1200_HAP_CLK_PM8038 PM8038_GPIO_PM_TO_SYS(7)
  1619. #define ISA1200_HAP_CLK_PM8917 PM8917_GPIO_PM_TO_SYS(38)
  1620. static int isa1200_power(int on)
  1621. {
  1622. unsigned int gpio = ISA1200_HAP_CLK_PM8038;
  1623. enum pm8xxx_aux_clk_id clk_id = CLK_MP3_1;
  1624. int rc = 0;
  1625. if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917) {
  1626. gpio = ISA1200_HAP_CLK_PM8917;
  1627. clk_id = CLK_MP3_2;
  1628. }
  1629. gpio_set_value_cansleep(gpio, !!on);
  1630. if (on)
  1631. rc = pm8xxx_aux_clk_control(clk_id, XO_DIV_1, true);
  1632. else
  1633. rc = pm8xxx_aux_clk_control(clk_id, XO_DIV_NONE, true);
  1634. if (rc) {
  1635. pr_err("%s: unable to write aux clock register(%d)\n",
  1636. __func__, rc);
  1637. }
  1638. return rc;
  1639. }
  1640. static int isa1200_dev_setup(bool enable)
  1641. {
  1642. unsigned int gpio = ISA1200_HAP_CLK_PM8038;
  1643. int rc = 0;
  1644. if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917)
  1645. gpio = ISA1200_HAP_CLK_PM8917;
  1646. if (!enable)
  1647. goto fail_gpio_dir;
  1648. rc = gpio_request(gpio, "haptics_clk");
  1649. if (rc) {
  1650. pr_err("%s: gpio_request for %d gpio failed rc(%d)\n",
  1651. __func__, gpio, rc);
  1652. goto fail_gpio_req;
  1653. }
  1654. rc = gpio_direction_output(gpio, 0);
  1655. if (rc) {
  1656. pr_err("%s: gpio_direction_output failed for %d gpio rc(%d)\n",
  1657. __func__, gpio, rc);
  1658. goto fail_gpio_dir;
  1659. }
  1660. return 0;
  1661. fail_gpio_dir:
  1662. gpio_free(gpio);
  1663. fail_gpio_req:
  1664. return rc;
  1665. }
  1666. static struct isa1200_regulator isa1200_reg_data[] = {
  1667. {
  1668. .name = "vddp",
  1669. .min_uV = ISA_I2C_VTG_MIN_UV,
  1670. .max_uV = ISA_I2C_VTG_MAX_UV,
  1671. .load_uA = ISA_I2C_CURR_UA,
  1672. },
  1673. {
  1674. .name = "vcc_i2c",
  1675. .min_uV = ISA_I2C_VTG_MIN_UV,
  1676. .max_uV = ISA_I2C_VTG_MAX_UV,
  1677. .load_uA = ISA_I2C_CURR_UA,
  1678. },
  1679. };
  1680. static struct isa1200_platform_data isa1200_1_pdata = {
  1681. .name = "vibrator",
  1682. .dev_setup = isa1200_dev_setup,
  1683. .power_on = isa1200_power,
  1684. .hap_en_gpio = ISA1200_HAP_EN_GPIO,
  1685. .hap_len_gpio = ISA1200_HAP_LEN_GPIO,
  1686. .max_timeout = 15000,
  1687. .mode_ctrl = PWM_GEN_MODE,
  1688. .pwm_fd = {
  1689. .pwm_div = 256,
  1690. },
  1691. .is_erm = false,
  1692. .smart_en = true,
  1693. .ext_clk_en = true,
  1694. .chip_en = 1,
  1695. .regulator_info = isa1200_reg_data,
  1696. .num_regulators = ARRAY_SIZE(isa1200_reg_data),
  1697. };
  1698. static struct i2c_board_info msm_isa1200_board_info[] __initdata = {
  1699. {
  1700. I2C_BOARD_INFO("isa1200_1", 0x90>>1),
  1701. .platform_data = &isa1200_1_pdata,
  1702. },
  1703. };
  1704. #define MXT_TS_GPIO_IRQ 11
  1705. #define MXT_TS_RESET_GPIO 52
  1706. static const u8 mxt_config_data_8930_v1[] = {
  1707. /* T6 Object */
  1708. 0, 0, 0, 0, 0, 0,
  1709. /* T38 Object */
  1710. 15, 3, 0, 15, 12, 11, 0, 0,
  1711. /* T7 Object */
  1712. 32, 16, 50,
  1713. /* T8 Object */
  1714. 30, 0, 5, 1, 0, 0, 8, 8, 0, 0,
  1715. /* T9 Object */
  1716. 131, 0, 0, 19, 11, 0, 16, 43, 2, 3,
  1717. 10, 7, 2, 0, 4, 5, 35, 10, 43, 4,
  1718. 54, 2, 15, 32, 38, 38, 143, 40, 143, 80,
  1719. 7, 9, 50, 50, 2,
  1720. /* T15 Object */
  1721. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  1722. 0,
  1723. /* T18 Object */
  1724. 0, 0,
  1725. /* T19 Object */
  1726. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  1727. 0, 0, 0, 0, 0, 0,
  1728. /* T23 Object */
  1729. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  1730. 0, 0, 0, 0, 0,
  1731. /* T25 Object */
  1732. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  1733. 0, 0, 0, 0,
  1734. /* T40 Object */
  1735. 0, 0, 0, 0, 0,
  1736. /* T42 Object */
  1737. 0, 0, 0, 0, 0, 0, 0, 0,
  1738. /* T46 Object */
  1739. 0, 3, 8, 16, 0, 0, 1, 0, 0,
  1740. /* T47 Object */
  1741. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  1742. /* T48 Object */
  1743. 0, 0, 8, 0, 0, 0, 0, 0, 0, 0,
  1744. 0, 0, 0, 0, 0, 0, 0, 100, 4, 64,
  1745. 0, 0, 5, 42, 0, 0, 0, 0, 0, 0,
  1746. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  1747. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  1748. 0, 0, 0, 0,
  1749. };
  1750. static const u8 mxt_config_data_8930_v2[] = {
  1751. /* T6 Object */
  1752. 0, 0, 0, 0, 0, 0,
  1753. /* T38 Object */
  1754. 15, 4, 0, 9, 7, 12, 0, 0,
  1755. /* T7 Object */
  1756. 32, 16, 50,
  1757. /* T8 Object */
  1758. 30, 0, 5, 10, 0, 0, 10, 10, 0, 0,
  1759. /* T9 Object */
  1760. 131, 0, 0, 19, 11, 0, 16, 50, 1, 3,
  1761. 12, 7, 2, 0, 4, 5, 2, 10, 43, 4,
  1762. 54, 2, -25, 29, 38, 18, 143, 40, 207, 80,
  1763. 17, 5, 50, 50, 0,
  1764. /* T18 Object */
  1765. 0, 0,
  1766. /* T19 Object */
  1767. 0, 0, 0, 0, 0, 0,
  1768. /* T25 Object */
  1769. 0, 0, 0, 0, 0, 0,
  1770. /* T42 Object */
  1771. 3, 60, 20, 20, 150, 0, 0, 0,
  1772. /* T46 Object */
  1773. 0, 3, 28, 28, 0, 0, 1, 0, 0,
  1774. /* T47 Object */
  1775. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  1776. /* T48 Object */
  1777. 1, 3, 82, 0, 0, 0, 0, 0, 0, 0,
  1778. 16, 30, 0, 6, 6, 0, 0, 124, 4, 100,
  1779. 0, 0, 0, 5, 0, 42, 0, 1, 0, 40,
  1780. 52, 20, 0, 0, 0, 50, 1, 5, 2, 1,
  1781. 4, 5, 3, -25, 29, 38, 18, 143, 40, 207,
  1782. 80, 10, 5, 2,
  1783. /* T55 Object */
  1784. 0, 0, 0, 0,
  1785. };
  1786. static ssize_t mxt224e_vkeys_show(struct kobject *kobj,
  1787. struct kobj_attribute *attr, char *buf)
  1788. {
  1789. return snprintf(buf, 200,
  1790. __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":57:1030:90:90"
  1791. ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":206:1030:90:90"
  1792. ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":366:1030:90:90"
  1793. ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":503:1030:90:90"
  1794. "\n");
  1795. }
  1796. static struct kobj_attribute mxt224e_vkeys_attr = {
  1797. .attr = {
  1798. .mode = S_IRUGO,
  1799. },
  1800. .show = &mxt224e_vkeys_show,
  1801. };
  1802. static struct attribute *mxt224e_properties_attrs[] = {
  1803. &mxt224e_vkeys_attr.attr,
  1804. NULL
  1805. };
  1806. static struct attribute_group mxt224e_properties_attr_group = {
  1807. .attrs = mxt224e_properties_attrs,
  1808. };
  1809. static void mxt_init_vkeys_8930(void)
  1810. {
  1811. int rc = 0;
  1812. static struct kobject *mxt224e_properties_kobj;
  1813. mxt224e_vkeys_attr.attr.name = "virtualkeys.atmel_mxt_ts";
  1814. mxt224e_properties_kobj = kobject_create_and_add("board_properties",
  1815. NULL);
  1816. if (mxt224e_properties_kobj)
  1817. rc = sysfs_create_group(mxt224e_properties_kobj,
  1818. &mxt224e_properties_attr_group);
  1819. if (!mxt224e_properties_kobj || rc)
  1820. pr_err("%s: failed to create board_properties\n",
  1821. __func__);
  1822. return;
  1823. }
  1824. static struct mxt_config_info mxt_config_array[] = {
  1825. {
  1826. .config = mxt_config_data_8930_v1,
  1827. .config_length = ARRAY_SIZE(mxt_config_data_8930_v1),
  1828. .family_id = 0x81,
  1829. .variant_id = 0x01,
  1830. .version = 0x10,
  1831. .build = 0xAA,
  1832. .bootldr_id = MXT_BOOTLOADER_ID_224E,
  1833. .fw_name = "atmel_8930_fluid_v2_0_AB.hex",
  1834. },
  1835. {
  1836. .config = mxt_config_data_8930_v2,
  1837. .config_length = ARRAY_SIZE(mxt_config_data_8930_v2),
  1838. .family_id = 0x81,
  1839. .variant_id = 0x15,
  1840. .version = 0x11,
  1841. .build = 0xAA,
  1842. .bootldr_id = MXT_BOOTLOADER_ID_224E,
  1843. .fw_name = "atmel_8930_fluid_v2_0_AB.hex",
  1844. },
  1845. {
  1846. .config = mxt_config_data_8930_v2,
  1847. .config_length = ARRAY_SIZE(mxt_config_data_8930_v2),
  1848. .family_id = 0x81,
  1849. .variant_id = 0x01,
  1850. .version = 0x20,
  1851. .build = 0xAB,
  1852. .bootldr_id = MXT_BOOTLOADER_ID_224E,
  1853. },
  1854. };
  1855. static struct mxt_platform_data mxt_platform_data_8930 = {
  1856. .config_array = mxt_config_array,
  1857. .config_array_size = ARRAY_SIZE(mxt_config_array),
  1858. .panel_minx = 0,
  1859. .panel_maxx = 566,
  1860. .panel_miny = 0,
  1861. .panel_maxy = 1067,
  1862. .disp_minx = 0,
  1863. .disp_maxx = 540,
  1864. .disp_miny = 0,
  1865. .disp_maxy = 960,
  1866. .irqflags = IRQF_TRIGGER_FALLING,
  1867. #ifdef MSM8930_PHASE_2
  1868. .digital_pwr_regulator = true,
  1869. #endif
  1870. .i2c_pull_up = true,
  1871. .reset_gpio = MXT_TS_RESET_GPIO,
  1872. .irq_gpio = MXT_TS_GPIO_IRQ,
  1873. };
  1874. static struct i2c_board_info mxt_device_info_8930[] __initdata = {
  1875. {
  1876. I2C_BOARD_INFO("atmel_mxt_ts", 0x4a),
  1877. .platform_data = &mxt_platform_data_8930,
  1878. .irq = MSM_GPIO_TO_INT(MXT_TS_GPIO_IRQ),
  1879. },
  1880. };
  1881. #define MHL_POWER_GPIO_PM8038 PM8038_GPIO_PM_TO_SYS(MHL_GPIO_PWR_EN)
  1882. #define MHL_POWER_GPIO_PM8917 PM8917_GPIO_PM_TO_SYS(25)
  1883. static struct msm_mhl_platform_data mhl_platform_data = {
  1884. .irq = MSM_GPIO_TO_INT(MHL_GPIO_INT),
  1885. .gpio_mhl_int = MHL_GPIO_INT,
  1886. .gpio_mhl_reset = MHL_GPIO_RESET,
  1887. .gpio_mhl_power = MHL_POWER_GPIO_PM8038,
  1888. .gpio_hdmi_mhl_mux = HDMI_MHL_MUX_GPIO,
  1889. };
  1890. static struct i2c_board_info sii_device_info[] __initdata = {
  1891. {
  1892. /*
  1893. * keeps SI 8334 as the default
  1894. * MHL TX
  1895. */
  1896. I2C_BOARD_INFO("sii8334", 0x39),
  1897. .platform_data = &mhl_platform_data,
  1898. .flags = I2C_CLIENT_WAKE,
  1899. },
  1900. };
  1901. #ifdef MSM8930_PHASE_2
  1902. #define GPIO_VOLUME_UP_PM8038 PM8038_GPIO_PM_TO_SYS(3)
  1903. #define GPIO_VOLUME_DOWN_PM8038 PM8038_GPIO_PM_TO_SYS(8)
  1904. #define GPIO_CAMERA_SNAPSHOT_PM8038 PM8038_GPIO_PM_TO_SYS(10)
  1905. #define GPIO_CAMERA_FOCUS_PM8038 PM8038_GPIO_PM_TO_SYS(11)
  1906. #define GPIO_VOLUME_UP_PM8917 PM8917_GPIO_PM_TO_SYS(27)
  1907. #define GPIO_VOLUME_DOWN_PM8917 PM8917_GPIO_PM_TO_SYS(28)
  1908. #define GPIO_CAMERA_SNAPSHOT_PM8917 PM8917_GPIO_PM_TO_SYS(36)
  1909. #define GPIO_CAMERA_FOCUS_PM8917 PM8917_GPIO_PM_TO_SYS(37)
  1910. static struct gpio_keys_button keys_8930_pm8038[] = {
  1911. {
  1912. .code = KEY_VOLUMEUP,
  1913. .type = EV_KEY,
  1914. .desc = "volume_up",
  1915. .gpio = GPIO_VOLUME_UP_PM8038,
  1916. .wakeup = 1,
  1917. .active_low = 1,
  1918. .debounce_interval = 15,
  1919. },
  1920. {
  1921. .code = KEY_VOLUMEDOWN,
  1922. .type = EV_KEY,
  1923. .desc = "volume_down",
  1924. .gpio = GPIO_VOLUME_DOWN_PM8038,
  1925. .wakeup = 1,
  1926. .active_low = 1,
  1927. .debounce_interval = 15,
  1928. },
  1929. {
  1930. .code = KEY_CAMERA_FOCUS,
  1931. .type = EV_KEY,
  1932. .desc = "camera_focus",
  1933. .gpio = GPIO_CAMERA_FOCUS_PM8038,
  1934. .wakeup = 1,
  1935. .active_low = 1,
  1936. .debounce_interval = 15,
  1937. },
  1938. {
  1939. .code = KEY_CAMERA_SNAPSHOT,
  1940. .type = EV_KEY,
  1941. .desc = "camera_snapshot",
  1942. .gpio = GPIO_CAMERA_SNAPSHOT_PM8038,
  1943. .wakeup = 1,
  1944. .active_low = 1,
  1945. .debounce_interval = 15,
  1946. },
  1947. };
  1948. static struct gpio_keys_button keys_8930_pm8917[] = {
  1949. {
  1950. .code = KEY_VOLUMEUP,
  1951. .type = EV_KEY,
  1952. .desc = "volume_up",
  1953. .gpio = GPIO_VOLUME_UP_PM8917,
  1954. .wakeup = 1,
  1955. .active_low = 1,
  1956. .debounce_interval = 15,
  1957. },
  1958. {
  1959. .code = KEY_VOLUMEDOWN,
  1960. .type = EV_KEY,
  1961. .desc = "volume_down",
  1962. .gpio = GPIO_VOLUME_DOWN_PM8917,
  1963. .wakeup = 1,
  1964. .active_low = 1,
  1965. .debounce_interval = 15,
  1966. },
  1967. {
  1968. .code = KEY_CAMERA_FOCUS,
  1969. .type = EV_KEY,
  1970. .desc = "camera_focus",
  1971. .gpio = GPIO_CAMERA_FOCUS_PM8917,
  1972. .wakeup = 1,
  1973. .active_low = 1,
  1974. .debounce_interval = 15,
  1975. },
  1976. {
  1977. .code = KEY_CAMERA_SNAPSHOT,
  1978. .type = EV_KEY,
  1979. .desc = "camera_snapshot",
  1980. .gpio = GPIO_CAMERA_SNAPSHOT_PM8917,
  1981. .wakeup = 1,
  1982. .active_low = 1,
  1983. .debounce_interval = 15,
  1984. },
  1985. };
  1986. /* Add GPIO keys for 8930 */
  1987. static struct gpio_keys_platform_data gpio_keys_8930_pdata = {
  1988. .buttons = keys_8930_pm8038,
  1989. .nbuttons = ARRAY_SIZE(keys_8930_pm8038),
  1990. };
  1991. static struct platform_device gpio_keys_8930 = {
  1992. .name = "gpio-keys",
  1993. .id = -1,
  1994. .dev = {
  1995. .platform_data = &gpio_keys_8930_pdata,
  1996. },
  1997. };
  1998. #endif /* MSM8930_PHASE_2 */
  1999. static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi4_pdata = {
  2000. .clk_freq = 100000,
  2001. .src_clk_rate = 24000000,
  2002. };
  2003. static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi3_pdata = {
  2004. .clk_freq = 100000,
  2005. .src_clk_rate = 24000000,
  2006. };
  2007. static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi9_pdata = {
  2008. .clk_freq = 100000,
  2009. .src_clk_rate = 24000000,
  2010. };
  2011. static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi10_pdata = {
  2012. .clk_freq = 100000,
  2013. .src_clk_rate = 24000000,
  2014. };
  2015. static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi12_pdata = {
  2016. .clk_freq = 100000,
  2017. .src_clk_rate = 24000000,
  2018. };
  2019. static struct ks8851_pdata spi_eth_pdata = {
  2020. .irq_gpio = KS8851_IRQ_GPIO,
  2021. .rst_gpio = KS8851_RST_GPIO,
  2022. };
  2023. static struct spi_board_info spi_board_info[] __initdata = {
  2024. {
  2025. .modalias = "ks8851",
  2026. .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
  2027. .max_speed_hz = 19200000,
  2028. .bus_num = 0,
  2029. .chip_select = 0,
  2030. .mode = SPI_MODE_0,
  2031. .platform_data = &spi_eth_pdata
  2032. },
  2033. {
  2034. .modalias = "dsi_novatek_3d_panel_spi",
  2035. .max_speed_hz = 10800000,
  2036. .bus_num = 0,
  2037. .chip_select = 1,
  2038. .mode = SPI_MODE_0,
  2039. },
  2040. };
  2041. static struct platform_device msm_device_saw_core0 = {
  2042. .name = "saw-regulator",
  2043. .id = 0,
  2044. .dev = {
  2045. .platform_data = &msm8930_pm8038_saw_regulator_core0_pdata,
  2046. },
  2047. };
  2048. static struct platform_device msm_device_saw_core1 = {
  2049. .name = "saw-regulator",
  2050. .id = 1,
  2051. .dev = {
  2052. .platform_data = &msm8930_pm8038_saw_regulator_core1_pdata,
  2053. },
  2054. };
  2055. static struct tsens_platform_data msm_tsens_pdata = {
  2056. .tsens_factor = 1000,
  2057. .hw_type = APQ_8064,
  2058. .tsens_num_sensor = 10,
  2059. .slope = {1132, 1135, 1137, 1135, 1157,
  2060. 1142, 1124, 1153, 1175, 1166},
  2061. };
  2062. static struct platform_device msm_tsens_device = {
  2063. .name = "tsens8960-tm",
  2064. .id = -1,
  2065. };
  2066. static struct msm_thermal_data msm_thermal_pdata = {
  2067. .sensor_id = 9,
  2068. .poll_ms = 250,
  2069. .limit_temp_degC = 60,
  2070. .temp_hysteresis_degC = 10,
  2071. .freq_step = 2,
  2072. };
  2073. #ifdef CONFIG_MSM_FAKE_BATTERY
  2074. static struct platform_device fish_battery_device = {
  2075. .name = "fish_battery",
  2076. };
  2077. #endif
  2078. #ifndef MSM8930_PHASE_2
  2079. /* 8930 Phase 1 */
  2080. static struct platform_device msm8930_device_ext_5v_vreg __devinitdata = {
  2081. .name = GPIO_REGULATOR_DEV_NAME,
  2082. .id = PM8921_MPP_PM_TO_SYS(7),
  2083. .dev = {
  2084. .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
  2085. },
  2086. };
  2087. static struct platform_device msm8930_device_ext_l2_vreg __devinitdata = {
  2088. .name = GPIO_REGULATOR_DEV_NAME,
  2089. .id = 91,
  2090. .dev = {
  2091. .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_L2],
  2092. },
  2093. };
  2094. #else
  2095. /* 8930 Phase 2 */
  2096. static struct platform_device msm8930_device_ext_5v_vreg __devinitdata = {
  2097. .name = GPIO_REGULATOR_DEV_NAME,
  2098. .id = 63,
  2099. .dev = {
  2100. .platform_data = &msm8930_pm8038_gpio_regulator_pdata[
  2101. MSM8930_GPIO_VREG_ID_EXT_5V],
  2102. },
  2103. };
  2104. static struct platform_device msm8930_device_ext_otg_sw_vreg __devinitdata = {
  2105. .name = GPIO_REGULATOR_DEV_NAME,
  2106. .id = 97,
  2107. .dev = {
  2108. .platform_data = &msm8930_pm8038_gpio_regulator_pdata[
  2109. MSM8930_GPIO_VREG_ID_EXT_OTG_SW],
  2110. },
  2111. };
  2112. #endif
  2113. static struct platform_device msm8930_device_rpm_regulator __devinitdata = {
  2114. .name = "rpm-regulator",
  2115. .id = -1,
  2116. .dev = {
  2117. #ifndef MSM8930_PHASE_2
  2118. .platform_data = &msm_rpm_regulator_pdata,
  2119. #else
  2120. .platform_data = &msm8930_pm8038_rpm_regulator_pdata,
  2121. #endif
  2122. },
  2123. };
  2124. static struct platform_device *early_common_devices[] __initdata = {
  2125. &msm8960_device_dmov,
  2126. &msm_device_smd,
  2127. &msm8960_device_uart_gsbi5,
  2128. &msm_device_uart_dm6,
  2129. &msm_device_saw_core0,
  2130. &msm_device_saw_core1,
  2131. };
  2132. /* ext_5v and ext_otg_sw are present when using PM8038 */
  2133. static struct platform_device *pmic_pm8038_devices[] __initdata = {
  2134. &msm8930_device_ext_5v_vreg,
  2135. #ifndef MSM8930_PHASE_2
  2136. &msm8930_device_ext_l2_vreg,
  2137. #endif
  2138. &msm8960_device_ssbi_pmic,
  2139. #ifdef MSM8930_PHASE_2
  2140. &msm8930_device_ext_otg_sw_vreg,
  2141. #endif
  2142. };
  2143. /* ext_5v and ext_otg_sw are not present when using PM8917 */
  2144. static struct platform_device *pmic_pm8917_devices[] __initdata = {
  2145. &msm8960_device_ssbi_pmic,
  2146. };
  2147. static struct platform_device *common_devices[] __initdata = {
  2148. &msm_8960_q6_lpass,
  2149. &msm_8960_q6_mss_fw,
  2150. &msm_8960_q6_mss_sw,
  2151. &msm_8960_riva,
  2152. &msm_pil_tzapps,
  2153. &msm_pil_vidc,
  2154. &msm8960_device_qup_spi_gsbi1,
  2155. &msm8960_device_qup_i2c_gsbi3,
  2156. &msm8960_device_qup_i2c_gsbi4,
  2157. &msm8960_device_qup_i2c_gsbi9,
  2158. &msm8960_device_qup_i2c_gsbi10,
  2159. &msm8960_device_qup_i2c_gsbi12,
  2160. &msm_slim_ctrl,
  2161. &msm_device_wcnss_wlan,
  2162. #if defined(CONFIG_QSEECOM)
  2163. &qseecom_device,
  2164. #endif
  2165. #if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
  2166. defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
  2167. &qcrypto_device,
  2168. #endif
  2169. #if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
  2170. defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
  2171. &qcedev_device,
  2172. #endif
  2173. #ifdef CONFIG_MSM_ROTATOR
  2174. &msm_rotator_device,
  2175. #endif
  2176. &msm_device_sps,
  2177. #ifdef CONFIG_MSM_FAKE_BATTERY
  2178. &fish_battery_device,
  2179. #endif
  2180. #ifdef CONFIG_ANDROID_PMEM
  2181. #ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
  2182. &msm8930_android_pmem_device,
  2183. &msm8930_android_pmem_adsp_device,
  2184. &msm8930_android_pmem_audio_device,
  2185. #endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
  2186. #endif /*CONFIG_ANDROID_PMEM*/
  2187. &msm8930_fmem_device,
  2188. &msm_device_bam_dmux,
  2189. &msm_fm_platform_init,
  2190. #ifdef CONFIG_HW_RANDOM_MSM
  2191. &msm_device_rng,
  2192. #endif
  2193. &msm8930_rpm_device,
  2194. &msm8930_rpm_log_device,
  2195. &msm8930_rpm_rbcpr_device,
  2196. &msm8930_rpm_stat_device,
  2197. &msm8930_rpm_master_stat_device,
  2198. #ifdef CONFIG_ION_MSM
  2199. &msm8930_ion_dev,
  2200. #endif
  2201. &msm_device_tz_log,
  2202. &coresight_tpiu_device,
  2203. &coresight_etb_device,
  2204. &coresight_funnel_device,
  2205. &coresight_etm0_device,
  2206. &coresight_etm1_device,
  2207. &msm_device_dspcrashd_8960,
  2208. &msm8960_device_watchdog,
  2209. #ifdef MSM8930_PHASE_2
  2210. &gpio_keys_8930,
  2211. #endif
  2212. &msm8930_rtb_device,
  2213. &msm_bus_8930_apps_fabric,
  2214. &msm_bus_8930_sys_fabric,
  2215. &msm_bus_8930_mm_fabric,
  2216. &msm_bus_8930_sys_fpb,
  2217. &msm_bus_8930_cpss_fpb,
  2218. &msm8960_device_cache_erp,
  2219. &msm8930_iommu_domain_device,
  2220. &msm_tsens_device,
  2221. &msm8930_cache_dump_device,
  2222. &msm8930_pc_cntr,
  2223. };
  2224. static struct platform_device *cdp_devices[] __initdata = {
  2225. &msm8960_device_otg,
  2226. &msm8960_device_gadget_peripheral,
  2227. &msm_device_hsusb_host,
  2228. &android_usb_device,
  2229. &msm_pcm,
  2230. &msm_pcm_routing,
  2231. &msm_cpudai0,
  2232. &msm_cpudai1,
  2233. &msm_cpudai_hdmi_rx,
  2234. &msm_cpudai_bt_rx,
  2235. &msm_cpudai_bt_tx,
  2236. &msm_cpudai_fm_rx,
  2237. &msm_cpudai_fm_tx,
  2238. &msm_cpudai_auxpcm_rx,
  2239. &msm_cpudai_auxpcm_tx,
  2240. &msm_cpu_fe,
  2241. &msm_stub_codec,
  2242. #ifdef CONFIG_MSM_GEMINI
  2243. &msm8960_gemini_device,
  2244. #endif
  2245. &msm_voice,
  2246. &msm_voip,
  2247. &msm_lpa_pcm,
  2248. &msm_cpudai_afe_01_rx,
  2249. &msm_cpudai_afe_01_tx,
  2250. &msm_cpudai_afe_02_rx,
  2251. &msm_cpudai_afe_02_tx,
  2252. &msm_pcm_afe,
  2253. &msm_compr_dsp,
  2254. &msm_cpudai_incall_music_rx,
  2255. &msm_cpudai_incall_record_rx,
  2256. &msm_cpudai_incall_record_tx,
  2257. &msm_pcm_hostless,
  2258. &msm_multi_ch_pcm,
  2259. &msm_lowlatency_pcm,
  2260. };
  2261. static void __init msm8930_i2c_init(void)
  2262. {
  2263. msm8960_device_qup_i2c_gsbi4.dev.platform_data =
  2264. &msm8960_i2c_qup_gsbi4_pdata;
  2265. msm8960_device_qup_i2c_gsbi3.dev.platform_data =
  2266. &msm8960_i2c_qup_gsbi3_pdata;
  2267. msm8960_device_qup_i2c_gsbi9.dev.platform_data =
  2268. &msm8960_i2c_qup_gsbi9_pdata;
  2269. msm8960_device_qup_i2c_gsbi10.dev.platform_data =
  2270. &msm8960_i2c_qup_gsbi10_pdata;
  2271. msm8960_device_qup_i2c_gsbi12.dev.platform_data =
  2272. &msm8960_i2c_qup_gsbi12_pdata;
  2273. }
  2274. static struct msm_rpmrs_level msm_rpmrs_levels[] __initdata = {
  2275. {
  2276. MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
  2277. MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
  2278. true,
  2279. 1, 784, 180000, 100,
  2280. },
  2281. {
  2282. MSM_PM_SLEEP_MODE_RETENTION,
  2283. MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
  2284. true,
  2285. 415, 715, 340827, 475,
  2286. },
  2287. {
  2288. MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
  2289. MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
  2290. true,
  2291. 1300, 228, 1200000, 2000,
  2292. },
  2293. {
  2294. MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
  2295. MSM_RPMRS_LIMITS(ON, GDHS, MAX, ACTIVE),
  2296. false,
  2297. 2000, 138, 1208400, 3200,
  2298. },
  2299. {
  2300. MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
  2301. MSM_RPMRS_LIMITS(ON, HSFS_OPEN, ACTIVE, RET_HIGH),
  2302. false,
  2303. 6000, 119, 1850300, 9000,
  2304. },
  2305. {
  2306. MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
  2307. MSM_RPMRS_LIMITS(OFF, GDHS, MAX, ACTIVE),
  2308. false,
  2309. 9200, 68, 2839200, 16400,
  2310. },
  2311. {
  2312. MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
  2313. MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
  2314. false,
  2315. 10300, 63, 3128000, 18200,
  2316. },
  2317. {
  2318. MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
  2319. MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
  2320. false,
  2321. 18000, 10, 4602600, 27000,
  2322. },
  2323. {
  2324. MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
  2325. MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
  2326. false,
  2327. 20000, 2, 5752000, 32000,
  2328. },
  2329. };
  2330. static struct msm_rpmrs_platform_data msm_rpmrs_data __initdata = {
  2331. .levels = &msm_rpmrs_levels[0],
  2332. .num_levels = ARRAY_SIZE(msm_rpmrs_levels),
  2333. .vdd_mem_levels = {
  2334. [MSM_RPMRS_VDD_MEM_RET_LOW] = 750000,
  2335. [MSM_RPMRS_VDD_MEM_RET_HIGH] = 750000,
  2336. [MSM_RPMRS_VDD_MEM_ACTIVE] = 1050000,
  2337. [MSM_RPMRS_VDD_MEM_MAX] = 1150000,
  2338. },
  2339. .vdd_dig_levels = {
  2340. [MSM_RPMRS_VDD_DIG_RET_LOW] = 0,
  2341. [MSM_RPMRS_VDD_DIG_RET_HIGH] = 0,
  2342. [MSM_RPMRS_VDD_DIG_ACTIVE] = 1,
  2343. [MSM_RPMRS_VDD_DIG_MAX] = 3,
  2344. },
  2345. .vdd_mask = 0x7FFFFF,
  2346. .rpmrs_target_id = {
  2347. [MSM_RPMRS_ID_PXO_CLK] = MSM_RPM_ID_PXO_CLK,
  2348. [MSM_RPMRS_ID_L2_CACHE_CTL] = MSM_RPM_ID_LAST,
  2349. [MSM_RPMRS_ID_VDD_DIG_0] = MSM_RPM_ID_VOLTAGE_CORNER,
  2350. [MSM_RPMRS_ID_VDD_DIG_1] = MSM_RPM_ID_LAST,
  2351. [MSM_RPMRS_ID_VDD_MEM_0] = MSM_RPM_ID_PM8038_L24_0,
  2352. [MSM_RPMRS_ID_VDD_MEM_1] = MSM_RPM_ID_PM8038_L24_1,
  2353. [MSM_RPMRS_ID_RPM_CTL] = MSM_RPM_ID_RPM_CTL,
  2354. },
  2355. };
  2356. static struct msm_rpmrs_platform_data msm_rpmrs_data_pm8917 __initdata = {
  2357. .levels = &msm_rpmrs_levels[0],
  2358. .num_levels = ARRAY_SIZE(msm_rpmrs_levels),
  2359. .vdd_mem_levels = {
  2360. [MSM_RPMRS_VDD_MEM_RET_LOW] = 750000,
  2361. [MSM_RPMRS_VDD_MEM_RET_HIGH] = 750000,
  2362. [MSM_RPMRS_VDD_MEM_ACTIVE] = 1050000,
  2363. [MSM_RPMRS_VDD_MEM_MAX] = 1150000,
  2364. },
  2365. .vdd_dig_levels = {
  2366. [MSM_RPMRS_VDD_DIG_RET_LOW] = 0,
  2367. [MSM_RPMRS_VDD_DIG_RET_HIGH] = 0,
  2368. [MSM_RPMRS_VDD_DIG_ACTIVE] = 1,
  2369. [MSM_RPMRS_VDD_DIG_MAX] = 3,
  2370. },
  2371. .vdd_mask = 0x7FFFFF,
  2372. .rpmrs_target_id = {
  2373. [MSM_RPMRS_ID_PXO_CLK] = MSM_RPM_ID_PXO_CLK,
  2374. [MSM_RPMRS_ID_L2_CACHE_CTL] = MSM_RPM_ID_LAST,
  2375. [MSM_RPMRS_ID_VDD_DIG_0] = MSM_RPM_ID_VOLTAGE_CORNER,
  2376. [MSM_RPMRS_ID_VDD_DIG_1] = MSM_RPM_ID_LAST,
  2377. [MSM_RPMRS_ID_VDD_MEM_0] = MSM_RPM_ID_PM8917_L24_0,
  2378. [MSM_RPMRS_ID_VDD_MEM_1] = MSM_RPM_ID_PM8917_L24_1,
  2379. [MSM_RPMRS_ID_RPM_CTL] = MSM_RPM_ID_RPM_CTL,
  2380. },
  2381. };
  2382. static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
  2383. .mode = MSM_PM_BOOT_CONFIG_TZ,
  2384. };
  2385. #ifdef CONFIG_I2C
  2386. #define I2C_SURF 1
  2387. #define I2C_FFA (1 << 1)
  2388. #define I2C_RUMI (1 << 2)
  2389. #define I2C_SIM (1 << 3)
  2390. #define I2C_FLUID (1 << 4)
  2391. #define I2C_LIQUID (1 << 5)
  2392. struct i2c_registry {
  2393. u8 machs;
  2394. int bus;
  2395. struct i2c_board_info *info;
  2396. int len;
  2397. };
  2398. #ifdef CONFIG_INPUT_MPU3050
  2399. #define MPU3050_INT_GPIO 69
  2400. static struct mpu3050_gyro_platform_data mpu3050_gyro = {
  2401. .gpio_int = MPU3050_INT_GPIO,
  2402. };
  2403. static struct i2c_board_info __initdata mpu3050_i2c_boardinfo[] = {
  2404. {
  2405. I2C_BOARD_INFO("mpu3050", 0x68),
  2406. .irq = MSM_GPIO_TO_INT(MPU3050_INT_GPIO),
  2407. .platform_data = &mpu3050_gyro,
  2408. },
  2409. };
  2410. #endif
  2411. #ifdef CONFIG_ISL9519_CHARGER
  2412. static struct isl_platform_data isl_data __initdata = {
  2413. .valid_n_gpio = 0, /* Not required when notify-by-pmic */
  2414. .chg_detection_config = NULL, /* Not required when notify-by-pmic */
  2415. .max_system_voltage = 4200,
  2416. .min_system_voltage = 3200,
  2417. .chgcurrent = 1000, /* 1900, */
  2418. .term_current = 400, /* Need fine tuning */
  2419. .input_current = 2048,
  2420. };
  2421. static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
  2422. {
  2423. I2C_BOARD_INFO("isl9519q", 0x9),
  2424. .irq = 0, /* Not required when notify-by-pmic */
  2425. .platform_data = &isl_data,
  2426. },
  2427. };
  2428. #endif /* CONFIG_ISL9519_CHARGER */
  2429. #ifdef CONFIG_STM_LIS3DH
  2430. static struct lis3dh_acc_platform_data lis3dh_accel = {
  2431. .poll_interval = 200,
  2432. .min_interval = 10,
  2433. .g_range = LIS3DH_ACC_G_2G,
  2434. .axis_map_x = 1,
  2435. .axis_map_y = 0,
  2436. .axis_map_z = 2,
  2437. .negate_x = 0,
  2438. .negate_y = 0,
  2439. .negate_z = 1,
  2440. .init = NULL,
  2441. .exit = NULL,
  2442. .gpio_int1 = -EINVAL,
  2443. .gpio_int2 = -EINVAL,
  2444. };
  2445. static struct i2c_board_info __initdata lis3dh_i2c_boardinfo[] = {
  2446. {
  2447. I2C_BOARD_INFO(LIS3DH_ACC_DEV_NAME, 0x18),
  2448. .platform_data = &lis3dh_accel,
  2449. },
  2450. };
  2451. #endif /* CONFIG_STM_LIS3DH */
  2452. #ifdef CONFIG_BMP18X_I2C
  2453. static struct i2c_board_info __initdata bmp18x_i2c_boardinfo[] = {
  2454. {
  2455. I2C_BOARD_INFO("bmp18x", 0x77),
  2456. },
  2457. };
  2458. #endif
  2459. static struct i2c_registry msm8960_i2c_devices[] __initdata = {
  2460. #ifdef CONFIG_ISL9519_CHARGER
  2461. {
  2462. I2C_LIQUID,
  2463. MSM_8930_GSBI10_QUP_I2C_BUS_ID,
  2464. isl_charger_i2c_info,
  2465. ARRAY_SIZE(isl_charger_i2c_info),
  2466. },
  2467. #endif /* CONFIG_ISL9519_CHARGER */
  2468. #ifdef CONFIG_INPUT_MPU3050
  2469. {
  2470. I2C_FFA | I2C_FLUID,
  2471. MSM_8930_GSBI12_QUP_I2C_BUS_ID,
  2472. mpu3050_i2c_boardinfo,
  2473. ARRAY_SIZE(mpu3050_i2c_boardinfo),
  2474. },
  2475. #endif
  2476. {
  2477. I2C_SURF | I2C_FFA | I2C_FLUID,
  2478. MSM_8930_GSBI9_QUP_I2C_BUS_ID,
  2479. msm_isa1200_board_info,
  2480. ARRAY_SIZE(msm_isa1200_board_info),
  2481. },
  2482. {
  2483. I2C_SURF | I2C_FFA | I2C_FLUID,
  2484. MSM_8930_GSBI3_QUP_I2C_BUS_ID,
  2485. mxt_device_info_8930,
  2486. ARRAY_SIZE(mxt_device_info_8930),
  2487. },
  2488. {
  2489. I2C_SURF | I2C_FFA | I2C_LIQUID | I2C_FLUID,
  2490. MSM_8930_GSBI9_QUP_I2C_BUS_ID,
  2491. sii_device_info,
  2492. ARRAY_SIZE(sii_device_info),
  2493. },
  2494. #ifdef CONFIG_STM_LIS3DH
  2495. {
  2496. I2C_FFA | I2C_FLUID,
  2497. MSM_8930_GSBI12_QUP_I2C_BUS_ID,
  2498. lis3dh_i2c_boardinfo,
  2499. ARRAY_SIZE(lis3dh_i2c_boardinfo),
  2500. },
  2501. #endif
  2502. #ifdef CONFIG_BMP18X_I2C
  2503. {
  2504. I2C_FFA | I2C_FLUID,
  2505. MSM_8930_GSBI12_QUP_I2C_BUS_ID,
  2506. bmp18x_i2c_boardinfo,
  2507. ARRAY_SIZE(bmp18x_i2c_boardinfo),
  2508. },
  2509. #endif
  2510. };
  2511. #endif /* CONFIG_I2C */
  2512. static void __init register_i2c_devices(void)
  2513. {
  2514. #ifdef CONFIG_I2C
  2515. u8 mach_mask = 0;
  2516. int i;
  2517. #ifdef CONFIG_MSM_CAMERA
  2518. struct i2c_registry msm8930_camera_i2c_devices = {
  2519. I2C_SURF | I2C_FFA | I2C_FLUID | I2C_LIQUID | I2C_RUMI,
  2520. MSM_8930_GSBI4_QUP_I2C_BUS_ID,
  2521. msm8930_camera_board_info.board_info,
  2522. msm8930_camera_board_info.num_i2c_board_info,
  2523. };
  2524. #endif
  2525. /* Build the matching 'supported_machs' bitmask */
  2526. if (machine_is_msm8930_cdp() || machine_is_msm8627_cdp())
  2527. mach_mask = I2C_SURF;
  2528. else if (machine_is_msm8930_fluid())
  2529. mach_mask = I2C_FLUID;
  2530. else if (machine_is_msm8930_mtp() || machine_is_msm8627_mtp())
  2531. mach_mask = I2C_FFA;
  2532. else
  2533. pr_err("unmatched machine ID in register_i2c_devices\n");
  2534. /* Run the array and install devices as appropriate */
  2535. for (i = 0; i < ARRAY_SIZE(msm8960_i2c_devices); ++i) {
  2536. if (msm8960_i2c_devices[i].machs & mach_mask)
  2537. i2c_register_board_info(msm8960_i2c_devices[i].bus,
  2538. msm8960_i2c_devices[i].info,
  2539. msm8960_i2c_devices[i].len);
  2540. }
  2541. #ifdef CONFIG_MSM_CAMERA
  2542. if (msm8930_camera_i2c_devices.machs & mach_mask)
  2543. i2c_register_board_info(msm8930_camera_i2c_devices.bus,
  2544. msm8930_camera_i2c_devices.info,
  2545. msm8930_camera_i2c_devices.len);
  2546. #endif
  2547. #endif
  2548. }
  2549. /* Modify platform data values to match requirements for PM8917. */
  2550. static void __init msm8930_pm8917_pdata_fixup(void)
  2551. {
  2552. struct acpuclk_platform_data *pdata;
  2553. mhl_platform_data.gpio_mhl_power = MHL_POWER_GPIO_PM8917;
  2554. gpio_keys_8930_pdata.buttons = keys_8930_pm8917;
  2555. gpio_keys_8930_pdata.nbuttons = ARRAY_SIZE(keys_8930_pm8917);
  2556. msm_device_saw_core0.dev.platform_data
  2557. = &msm8930_pm8038_saw_regulator_core0_pdata;
  2558. msm_device_saw_core1.dev.platform_data
  2559. = &msm8930_pm8038_saw_regulator_core1_pdata;
  2560. msm8930_device_rpm_regulator.dev.platform_data
  2561. = &msm8930_pm8917_rpm_regulator_pdata;
  2562. pdata = msm8930_device_acpuclk.dev.platform_data;
  2563. pdata->uses_pm8917 = true;
  2564. pdata = msm8930ab_device_acpuclk.dev.platform_data;
  2565. pdata->uses_pm8917 = true;
  2566. }
  2567. static void __init msm8930_cdp_init(void)
  2568. {
  2569. if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917)
  2570. msm8930_pm8917_pdata_fixup();
  2571. if (meminfo_init(SYS_MEMORY, SZ_256M) < 0)
  2572. pr_err("meminfo_init() failed!\n");
  2573. platform_device_register(&msm_gpio_device);
  2574. msm_tsens_early_init(&msm_tsens_pdata);
  2575. msm_thermal_init(&msm_thermal_pdata);
  2576. if (socinfo_get_pmic_model() != PMIC_MODEL_PM8917) {
  2577. BUG_ON(msm_rpm_init(&msm8930_rpm_data));
  2578. BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
  2579. } else {
  2580. BUG_ON(msm_rpm_init(&msm8930_rpm_data_pm8917));
  2581. BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data_pm8917));
  2582. }
  2583. regulator_suppress_info_printing();
  2584. if (msm_xo_init())
  2585. pr_err("Failed to initialize XO votes\n");
  2586. platform_device_register(&msm8930_device_rpm_regulator);
  2587. if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917)
  2588. msm_clock_init(&msm8930_pm8917_clock_init_data);
  2589. else
  2590. msm_clock_init(&msm8930_clock_init_data);
  2591. if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917) {
  2592. /*
  2593. * By default, set USB mode as USB Peripheral only due to
  2594. * hardware rework requirement for USB Host Mode.
  2595. * Provide pmic_id_irq number only if host mode is enable
  2596. * by user assuming that hardware rework is available.
  2597. */
  2598. if (enable_usb_host_mode) {
  2599. /* MPP01 IRQ number */
  2600. msm_otg_pdata.pmic_id_irq =
  2601. PM8921_MPP_IRQ(PM8917_IRQ_BASE, 1);
  2602. } else {
  2603. pr_err("Enabling USB Peripheral Only mode.\n");
  2604. msm_otg_pdata.mode = USB_PERIPHERAL;
  2605. }
  2606. } else {
  2607. msm_otg_pdata.pmic_id_irq =
  2608. PM8038_USB_ID_IN_IRQ(PM8038_IRQ_BASE);
  2609. }
  2610. msm_otg_pdata.phy_init_seq = hsusb_phy_init_seq;
  2611. msm8960_device_otg.dev.platform_data = &msm_otg_pdata;
  2612. android_usb_pdata.swfi_latency =
  2613. msm_rpmrs_levels[0].latency_us;
  2614. msm8930_init_gpiomux();
  2615. msm8960_device_qup_spi_gsbi1.dev.platform_data =
  2616. &msm8960_qup_spi_gsbi1_pdata;
  2617. spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
  2618. /*
  2619. * TODO: When physical 8930/PM8038 hardware becomes
  2620. * available, remove this block or add the config
  2621. * option.
  2622. */
  2623. #ifndef MSM8930_PHASE_2
  2624. msm8960_init_pmic();
  2625. #else
  2626. msm8930_init_pmic();
  2627. #endif
  2628. msm8930_i2c_init();
  2629. msm8930_init_gpu();
  2630. msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
  2631. msm_spm_l2_init(msm_spm_l2_data);
  2632. msm8930_init_buses();
  2633. if (cpu_is_msm8627()) {
  2634. platform_add_devices(msm8627_footswitch,
  2635. msm8627_num_footswitch);
  2636. } else {
  2637. if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917)
  2638. platform_add_devices(msm8930_pm8917_footswitch,
  2639. msm8930_pm8917_num_footswitch);
  2640. else
  2641. platform_add_devices(msm8930_footswitch,
  2642. msm8930_num_footswitch);
  2643. }
  2644. if (cpu_is_msm8627())
  2645. platform_device_register(&msm8627_device_acpuclk);
  2646. else if (cpu_is_msm8930())
  2647. platform_device_register(&msm8930_device_acpuclk);
  2648. else if (cpu_is_msm8930aa())
  2649. platform_device_register(&msm8930aa_device_acpuclk);
  2650. else if (cpu_is_msm8930ab())
  2651. platform_device_register(&msm8930ab_device_acpuclk);
  2652. platform_add_devices(early_common_devices,
  2653. ARRAY_SIZE(early_common_devices));
  2654. if (socinfo_get_pmic_model() != PMIC_MODEL_PM8917)
  2655. platform_add_devices(pmic_pm8038_devices,
  2656. ARRAY_SIZE(pmic_pm8038_devices));
  2657. else
  2658. platform_add_devices(pmic_pm8917_devices,
  2659. ARRAY_SIZE(pmic_pm8917_devices));
  2660. platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
  2661. msm8930_add_vidc_device();
  2662. /*
  2663. * TODO: When physical 8930/PM8038 hardware becomes
  2664. * available, remove this block or add the config
  2665. * option.
  2666. */
  2667. #ifndef MSM8930_PHASE_2
  2668. msm8960_pm8921_gpio_mpp_init();
  2669. #else
  2670. if (socinfo_get_pmic_model() != PMIC_MODEL_PM8917)
  2671. msm8930_pm8038_gpio_mpp_init();
  2672. else
  2673. msm8930_pm8917_gpio_mpp_init();
  2674. #endif
  2675. platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
  2676. #ifdef CONFIG_MSM_CAMERA
  2677. msm8930_init_cam();
  2678. #endif
  2679. msm8930_init_mmc();
  2680. mxt_init_vkeys_8930();
  2681. register_i2c_devices();
  2682. msm8930_init_fb();
  2683. slim_register_board_info(msm_slim_devices,
  2684. ARRAY_SIZE(msm_slim_devices));
  2685. change_memory_power = &msm8930_change_memory_power;
  2686. BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
  2687. msm_pm_set_tz_retention_flag(1);
  2688. if (PLATFORM_IS_CHARM25())
  2689. platform_add_devices(mdm_devices, ARRAY_SIZE(mdm_devices));
  2690. }
  2691. MACHINE_START(MSM8930_CDP, "QCT MSM8930 CDP")
  2692. .map_io = msm8930_map_io,
  2693. .reserve = msm8930_reserve,
  2694. .init_irq = msm8930_init_irq,
  2695. .handle_irq = gic_handle_irq,
  2696. .timer = &msm_timer,
  2697. .init_machine = msm8930_cdp_init,
  2698. .init_early = msm8930_allocate_memory_regions,
  2699. .init_very_early = msm8930_early_memory,
  2700. .restart = msm_restart,
  2701. MACHINE_END
  2702. MACHINE_START(MSM8930_MTP, "QCT MSM8930 MTP")
  2703. .map_io = msm8930_map_io,
  2704. .reserve = msm8930_reserve,
  2705. .init_irq = msm8930_init_irq,
  2706. .handle_irq = gic_handle_irq,
  2707. .timer = &msm_timer,
  2708. .init_machine = msm8930_cdp_init,
  2709. .init_early = msm8930_allocate_memory_regions,
  2710. .init_very_early = msm8930_early_memory,
  2711. .restart = msm_restart,
  2712. MACHINE_END
  2713. MACHINE_START(MSM8930_FLUID, "QCT MSM8930 FLUID")
  2714. .map_io = msm8930_map_io,
  2715. .reserve = msm8930_reserve,
  2716. .init_irq = msm8930_init_irq,
  2717. .handle_irq = gic_handle_irq,
  2718. .timer = &msm_timer,
  2719. .init_machine = msm8930_cdp_init,
  2720. .init_early = msm8930_allocate_memory_regions,
  2721. .init_very_early = msm8930_early_memory,
  2722. .restart = msm_restart,
  2723. MACHINE_END
  2724. MACHINE_START(MSM8627_CDP, "QCT MSM8627 CDP")
  2725. .map_io = msm8930_map_io,
  2726. .reserve = msm8930_reserve,
  2727. .init_irq = msm8930_init_irq,
  2728. .handle_irq = gic_handle_irq,
  2729. .timer = &msm_timer,
  2730. .init_machine = msm8930_cdp_init,
  2731. .init_early = msm8930_allocate_memory_regions,
  2732. .init_very_early = msm8930_early_memory,
  2733. .restart = msm_restart,
  2734. MACHINE_END
  2735. MACHINE_START(MSM8627_MTP, "QCT MSM8627 MTP")
  2736. .map_io = msm8930_map_io,
  2737. .reserve = msm8930_reserve,
  2738. .init_irq = msm8930_init_irq,
  2739. .handle_irq = gic_handle_irq,
  2740. .timer = &msm_timer,
  2741. .init_machine = msm8930_cdp_init,
  2742. .init_early = msm8930_allocate_memory_regions,
  2743. .init_very_early = msm8930_early_memory,
  2744. .restart = msm_restart,
  2745. MACHINE_END