PageRenderTime 103ms CodeModel.GetById 12ms app.highlight 77ms RepoModel.GetById 1ms app.codeStats 1ms

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

https://github.com/AICP/kernel_google_msm
C | 3408 lines | 2970 code | 330 blank | 108 comment | 126 complexity | 051bd07c1991f5e7e260656d7a5d82d1 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   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/bitops.h>
  15#include <linux/platform_device.h>
  16#include <linux/gpio.h>
  17#include <linux/io.h>
  18#include <linux/irq.h>
  19#include <linux/i2c.h>
  20#include <linux/i2c/smb349.h>
  21#include <linux/i2c/sx150x.h>
  22#include <linux/slimbus/slimbus.h>
  23#include <linux/mfd/wcd9xxx/core.h>
  24#include <linux/mfd/wcd9xxx/pdata.h>
  25#include <linux/mfd/pm8xxx/misc.h>
  26#include <linux/msm_ssbi.h>
  27#include <linux/spi/spi.h>
  28#include <linux/dma-contiguous.h>
  29#include <linux/dma-mapping.h>
  30#include <linux/platform_data/qcom_crypto_device.h>
  31#include <linux/msm_ion.h>
  32#include <linux/memory.h>
  33#include <linux/memblock.h>
  34#include <linux/msm_thermal.h>
  35#include <linux/i2c/atmel_mxt_ts.h>
  36#include <linux/cyttsp-qc.h>
  37#include <linux/i2c/isa1200.h>
  38#include <linux/gpio_keys.h>
  39#include <linux/epm_adc.h>
  40#include <linux/i2c/sx150x.h>
  41#include <asm/mach-types.h>
  42#include <asm/mach/arch.h>
  43#include <asm/hardware/gic.h>
  44#include <asm/mach/mmc.h>
  45#include <linux/platform_data/qcom_wcnss_device.h>
  46
  47#include <mach/board.h>
  48#include <mach/msm_iomap.h>
  49#include <mach/ion.h>
  50#include <linux/usb/msm_hsusb.h>
  51#include <linux/usb/android.h>
  52#include <mach/socinfo.h>
  53#include <mach/msm_spi.h>
  54#include "timer.h"
  55#include "devices.h"
  56#include <mach/gpiomux.h>
  57#include <mach/rpm.h>
  58#ifdef CONFIG_ANDROID_PMEM
  59#include <linux/android_pmem.h>
  60#endif
  61#include <mach/msm_memtypes.h>
  62#include <linux/bootmem.h>
  63#include <asm/setup.h>
  64#include <mach/dma.h>
  65#include <mach/msm_dsps.h>
  66#include <mach/msm_bus_board.h>
  67#include <mach/cpuidle.h>
  68#include <mach/mdm2.h>
  69#include <linux/msm_tsens.h>
  70#include <mach/msm_xo.h>
  71#include <mach/msm_rtb.h>
  72#include <sound/cs8427.h>
  73#include <media/gpio-ir-recv.h>
  74#include <linux/fmem.h>
  75#include <mach/msm_pcie.h>
  76#include <mach/restart.h>
  77#include <mach/msm_iomap.h>
  78
  79#include "msm_watchdog.h"
  80#include "board-8064.h"
  81#include "clock.h"
  82#include "spm.h"
  83#include <mach/mpm.h>
  84#include "rpm_resources.h"
  85#include "pm.h"
  86#include "pm-boot.h"
  87#include "devices-msm8x60.h"
  88#include "smd_private.h"
  89#include "sysmon.h"
  90
  91#define MSM_PMEM_ADSP_SIZE         0x7800000
  92#define MSM_PMEM_AUDIO_SIZE        0x4CF000
  93#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
  94#define MSM_PMEM_SIZE 0x4000000 /* 64 Mbytes */
  95#else
  96#define MSM_PMEM_SIZE 0x4000000 /* 64 Mbytes */
  97#endif
  98
  99#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
 100#define HOLE_SIZE		0x20000
 101#define MSM_ION_MFC_META_SIZE  0x40000 /* 256 Kbytes */
 102#define MSM_CONTIG_MEM_SIZE  0x65000
 103#ifdef CONFIG_MSM_IOMMU
 104#define MSM_ION_MM_SIZE		0x3800000
 105#define MSM_ION_SF_SIZE		0
 106#define MSM_ION_QSECOM_SIZE	0x780000 /* (7.5MB) */
 107#define MSM_ION_HEAP_NUM	8
 108#else
 109#define MSM_ION_MM_SIZE		MSM_PMEM_ADSP_SIZE
 110#define MSM_ION_SF_SIZE		MSM_PMEM_SIZE
 111#define MSM_ION_QSECOM_SIZE	0x600000 /* (6MB) */
 112#define MSM_ION_HEAP_NUM	8
 113#endif
 114#define MSM_ION_MM_FW_SIZE	(0x200000 - HOLE_SIZE) /* (2MB - 128KB) */
 115#define MSM_ION_MFC_SIZE	(SZ_8K + MSM_ION_MFC_META_SIZE)
 116#define MSM_ION_AUDIO_SIZE	MSM_PMEM_AUDIO_SIZE
 117#else
 118#define MSM_CONTIG_MEM_SIZE  0x110C000
 119#define MSM_ION_HEAP_NUM	1
 120#endif
 121
 122#define APQ8064_FIXED_AREA_START (0xa0000000 - (MSM_ION_MM_FW_SIZE + \
 123							HOLE_SIZE))
 124#define MAX_FIXED_AREA_SIZE	0x10000000
 125#define MSM_MM_FW_SIZE		(0x200000 - HOLE_SIZE)
 126#define APQ8064_FW_START	APQ8064_FIXED_AREA_START
 127#define MSM_ION_ADSP_SIZE	SZ_8M
 128
 129#define QFPROM_RAW_FEAT_CONFIG_ROW0_MSB     (MSM_QFPROM_BASE + 0x23c)
 130#define QFPROM_RAW_OEM_CONFIG_ROW0_LSB      (MSM_QFPROM_BASE + 0x220)
 131
 132/* PCIE AXI address space */
 133#define PCIE_AXI_BAR_PHYS   0x08000000
 134#define PCIE_AXI_BAR_SIZE   SZ_128M
 135
 136/* PCIe pmic gpios */
 137#define PCIE_WAKE_N_PMIC_GPIO 12
 138#define PCIE_PWR_EN_PMIC_GPIO 13
 139#define PCIE_RST_N_PMIC_MPP 1
 140
 141#ifdef CONFIG_KERNEL_MSM_CONTIG_MEM_REGION
 142static unsigned msm_contig_mem_size = MSM_CONTIG_MEM_SIZE;
 143static int __init msm_contig_mem_size_setup(char *p)
 144{
 145	msm_contig_mem_size = memparse(p, NULL);
 146	return 0;
 147}
 148early_param("msm_contig_mem_size", msm_contig_mem_size_setup);
 149#endif
 150
 151#ifdef CONFIG_ANDROID_PMEM
 152static unsigned pmem_size = MSM_PMEM_SIZE;
 153static int __init pmem_size_setup(char *p)
 154{
 155	pmem_size = memparse(p, NULL);
 156	return 0;
 157}
 158early_param("pmem_size", pmem_size_setup);
 159
 160static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
 161
 162static int __init pmem_adsp_size_setup(char *p)
 163{
 164	pmem_adsp_size = memparse(p, NULL);
 165	return 0;
 166}
 167early_param("pmem_adsp_size", pmem_adsp_size_setup);
 168
 169static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
 170
 171static int __init pmem_audio_size_setup(char *p)
 172{
 173	pmem_audio_size = memparse(p, NULL);
 174	return 0;
 175}
 176early_param("pmem_audio_size", pmem_audio_size_setup);
 177#endif
 178
 179#ifdef CONFIG_ANDROID_PMEM
 180#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
 181static struct android_pmem_platform_data android_pmem_pdata = {
 182	.name = "pmem",
 183	.allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
 184	.cached = 1,
 185	.memory_type = MEMTYPE_EBI1,
 186};
 187
 188static struct platform_device apq8064_android_pmem_device = {
 189	.name = "android_pmem",
 190	.id = 0,
 191	.dev = {.platform_data = &android_pmem_pdata},
 192};
 193
 194static struct android_pmem_platform_data android_pmem_adsp_pdata = {
 195	.name = "pmem_adsp",
 196	.allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
 197	.cached = 0,
 198	.memory_type = MEMTYPE_EBI1,
 199};
 200static struct platform_device apq8064_android_pmem_adsp_device = {
 201	.name = "android_pmem",
 202	.id = 2,
 203	.dev = { .platform_data = &android_pmem_adsp_pdata },
 204};
 205
 206static struct android_pmem_platform_data android_pmem_audio_pdata = {
 207	.name = "pmem_audio",
 208	.allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
 209	.cached = 0,
 210	.memory_type = MEMTYPE_EBI1,
 211};
 212
 213static struct platform_device apq8064_android_pmem_audio_device = {
 214	.name = "android_pmem",
 215	.id = 4,
 216	.dev = { .platform_data = &android_pmem_audio_pdata },
 217};
 218#endif /* CONFIG_MSM_MULTIMEDIA_USE_ION */
 219#endif /* CONFIG_ANDROID_PMEM */
 220
 221struct fmem_platform_data apq8064_fmem_pdata = {
 222};
 223
 224static struct memtype_reserve apq8064_reserve_table[] __initdata = {
 225	[MEMTYPE_SMI] = {
 226	},
 227	[MEMTYPE_EBI0] = {
 228		.flags	=	MEMTYPE_FLAGS_1M_ALIGN,
 229	},
 230	[MEMTYPE_EBI1] = {
 231		.flags	=	MEMTYPE_FLAGS_1M_ALIGN,
 232	},
 233};
 234
 235static void __init reserve_rtb_memory(void)
 236{
 237#if defined(CONFIG_MSM_RTB)
 238	apq8064_reserve_table[MEMTYPE_EBI1].size += apq8064_rtb_pdata.size;
 239#endif
 240}
 241
 242
 243static void __init size_pmem_devices(void)
 244{
 245#ifdef CONFIG_ANDROID_PMEM
 246#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
 247	android_pmem_adsp_pdata.size = pmem_adsp_size;
 248	android_pmem_pdata.size = pmem_size;
 249	android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
 250#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
 251#endif /*CONFIG_ANDROID_PMEM*/
 252}
 253
 254#ifdef CONFIG_ANDROID_PMEM
 255#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
 256static void __init reserve_memory_for(struct android_pmem_platform_data *p)
 257{
 258	apq8064_reserve_table[p->memory_type].size += p->size;
 259}
 260#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
 261#endif /*CONFIG_ANDROID_PMEM*/
 262
 263static void __init reserve_pmem_memory(void)
 264{
 265#ifdef CONFIG_ANDROID_PMEM
 266#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
 267	reserve_memory_for(&android_pmem_adsp_pdata);
 268	reserve_memory_for(&android_pmem_pdata);
 269	reserve_memory_for(&android_pmem_audio_pdata);
 270#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
 271	apq8064_reserve_table[MEMTYPE_EBI1].size += msm_contig_mem_size;
 272#endif /*CONFIG_ANDROID_PMEM*/
 273}
 274
 275static int apq8064_paddr_to_memtype(unsigned int paddr)
 276{
 277	return MEMTYPE_EBI1;
 278}
 279
 280#define FMEM_ENABLED 0
 281
 282#ifdef CONFIG_ION_MSM
 283#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
 284static struct ion_cp_heap_pdata cp_mm_apq8064_ion_pdata = {
 285	.permission_type = IPT_TYPE_MM_CARVEOUT,
 286	.align = PAGE_SIZE,
 287	.reusable = FMEM_ENABLED,
 288	.mem_is_fmem = FMEM_ENABLED,
 289	.fixed_position = FIXED_MIDDLE,
 290	.is_cma = 1,
 291	.no_nonsecure_alloc = 1,
 292};
 293
 294static struct ion_cp_heap_pdata cp_mfc_apq8064_ion_pdata = {
 295	.permission_type = IPT_TYPE_MFC_SHAREDMEM,
 296	.align = PAGE_SIZE,
 297	.reusable = 0,
 298	.mem_is_fmem = FMEM_ENABLED,
 299	.fixed_position = FIXED_HIGH,
 300	.no_nonsecure_alloc = 1,
 301};
 302
 303static struct ion_co_heap_pdata co_apq8064_ion_pdata = {
 304	.adjacent_mem_id = INVALID_HEAP_ID,
 305	.align = PAGE_SIZE,
 306	.mem_is_fmem = 0,
 307};
 308
 309static struct ion_co_heap_pdata fw_co_apq8064_ion_pdata = {
 310	.adjacent_mem_id = ION_CP_MM_HEAP_ID,
 311	.align = SZ_128K,
 312	.mem_is_fmem = FMEM_ENABLED,
 313	.fixed_position = FIXED_LOW,
 314};
 315#endif
 316
 317static u64 msm_dmamask = DMA_BIT_MASK(32);
 318
 319static struct platform_device ion_mm_heap_device = {
 320	.name = "ion-mm-heap-device",
 321	.id = -1,
 322	.dev = {
 323		.dma_mask = &msm_dmamask,
 324		.coherent_dma_mask = DMA_BIT_MASK(32),
 325	}
 326};
 327
 328static struct platform_device ion_adsp_heap_device = {
 329	.name = "ion-adsp-heap-device",
 330	.id = -1,
 331	.dev = {
 332		.dma_mask = &msm_dmamask,
 333		.coherent_dma_mask = DMA_BIT_MASK(32),
 334	}
 335};
 336/**
 337 * These heaps are listed in the order they will be allocated. Due to
 338 * video hardware restrictions and content protection the FW heap has to
 339 * be allocated adjacent (below) the MM heap and the MFC heap has to be
 340 * allocated after the MM heap to ensure MFC heap is not more than 256MB
 341 * away from the base address of the FW heap.
 342 * However, the order of FW heap and MM heap doesn't matter since these
 343 * two heaps are taken care of by separate code to ensure they are adjacent
 344 * to each other.
 345 * Don't swap the order unless you know what you are doing!
 346 */
 347struct ion_platform_heap apq8064_heaps[] = {
 348		{
 349			.id	= ION_SYSTEM_HEAP_ID,
 350			.type	= ION_HEAP_TYPE_SYSTEM,
 351			.name	= ION_VMALLOC_HEAP_NAME,
 352		},
 353#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
 354		{
 355			.id	= ION_CP_MM_HEAP_ID,
 356			.type	= ION_HEAP_TYPE_CP,
 357			.name	= ION_MM_HEAP_NAME,
 358			.size	= MSM_ION_MM_SIZE,
 359			.memory_type = ION_EBI_TYPE,
 360			.extra_data = (void *) &cp_mm_apq8064_ion_pdata,
 361			.priv	= &ion_mm_heap_device.dev
 362		},
 363		{
 364			.id	= ION_MM_FIRMWARE_HEAP_ID,
 365			.type	= ION_HEAP_TYPE_CARVEOUT,
 366			.name	= ION_MM_FIRMWARE_HEAP_NAME,
 367			.size	= MSM_ION_MM_FW_SIZE,
 368			.memory_type = ION_EBI_TYPE,
 369			.extra_data = (void *) &fw_co_apq8064_ion_pdata,
 370		},
 371		{
 372			.id	= ION_CP_MFC_HEAP_ID,
 373			.type	= ION_HEAP_TYPE_CP,
 374			.name	= ION_MFC_HEAP_NAME,
 375			.size	= MSM_ION_MFC_SIZE,
 376			.memory_type = ION_EBI_TYPE,
 377			.extra_data = (void *) &cp_mfc_apq8064_ion_pdata,
 378		},
 379#ifndef CONFIG_MSM_IOMMU
 380		{
 381			.id	= ION_SF_HEAP_ID,
 382			.type	= ION_HEAP_TYPE_CARVEOUT,
 383			.name	= ION_SF_HEAP_NAME,
 384			.size	= MSM_ION_SF_SIZE,
 385			.memory_type = ION_EBI_TYPE,
 386			.extra_data = (void *) &co_apq8064_ion_pdata,
 387		},
 388#endif
 389		{
 390			.id	= ION_IOMMU_HEAP_ID,
 391			.type	= ION_HEAP_TYPE_IOMMU,
 392			.name	= ION_IOMMU_HEAP_NAME,
 393		},
 394		{
 395			.id	= ION_QSECOM_HEAP_ID,
 396			.type	= ION_HEAP_TYPE_CARVEOUT,
 397			.name	= ION_QSECOM_HEAP_NAME,
 398			.size	= MSM_ION_QSECOM_SIZE,
 399			.memory_type = ION_EBI_TYPE,
 400			.extra_data = (void *) &co_apq8064_ion_pdata,
 401		},
 402		{
 403			.id	= ION_AUDIO_HEAP_ID,
 404			.type	= ION_HEAP_TYPE_CARVEOUT,
 405			.name	= ION_AUDIO_HEAP_NAME,
 406			.size	= MSM_ION_AUDIO_SIZE,
 407			.memory_type = ION_EBI_TYPE,
 408			.extra_data = (void *) &co_apq8064_ion_pdata,
 409		},
 410		{
 411			.id     = ION_ADSP_HEAP_ID,
 412			.type   = ION_HEAP_TYPE_DMA,
 413			.name   = ION_ADSP_HEAP_NAME,
 414			.size   = MSM_ION_ADSP_SIZE,
 415			.memory_type = ION_EBI_TYPE,
 416			.extra_data = (void *) &co_apq8064_ion_pdata,
 417			.priv = &ion_adsp_heap_device.dev,
 418		},
 419#endif
 420};
 421
 422static struct ion_platform_data apq8064_ion_pdata = {
 423	.nr = MSM_ION_HEAP_NUM,
 424	.heaps = apq8064_heaps,
 425};
 426
 427static struct platform_device apq8064_ion_dev = {
 428	.name = "ion-msm",
 429	.id = 1,
 430	.dev = { .platform_data = &apq8064_ion_pdata },
 431};
 432#endif
 433
 434static struct platform_device apq8064_fmem_device = {
 435	.name = "fmem",
 436	.id = 1,
 437	.dev = { .platform_data = &apq8064_fmem_pdata },
 438};
 439
 440static void __init reserve_mem_for_ion(enum ion_memory_types mem_type,
 441				      unsigned long size)
 442{
 443	apq8064_reserve_table[mem_type].size += size;
 444}
 445
 446static void __init apq8064_reserve_fixed_area(unsigned long fixed_area_size)
 447{
 448#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
 449	int ret;
 450
 451	if (fixed_area_size > MAX_FIXED_AREA_SIZE)
 452		panic("fixed area size is larger than %dM\n",
 453			MAX_FIXED_AREA_SIZE >> 20);
 454
 455	reserve_info->fixed_area_size = fixed_area_size;
 456	reserve_info->fixed_area_start = APQ8064_FW_START;
 457
 458	ret = memblock_remove(reserve_info->fixed_area_start,
 459		reserve_info->fixed_area_size);
 460	BUG_ON(ret);
 461#endif
 462}
 463
 464/**
 465 * Reserve memory for ION and calculate amount of reusable memory for fmem.
 466 * We only reserve memory for heaps that are not reusable. However, we only
 467 * support one reusable heap at the moment so we ignore the reusable flag for
 468 * other than the first heap with reusable flag set. Also handle special case
 469 * for video heaps (MM,FW, and MFC). Video requires heaps MM and MFC to be
 470 * at a higher address than FW in addition to not more than 256MB away from the
 471 * base address of the firmware. This means that if MM is reusable the other
 472 * two heaps must be allocated in the same region as FW. This is handled by the
 473 * mem_is_fmem flag in the platform data. In addition the MM heap must be
 474 * adjacent to the FW heap for content protection purposes.
 475 */
 476static void __init reserve_ion_memory(void)
 477{
 478#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
 479	unsigned int i;
 480	unsigned int ret;
 481	unsigned int fixed_size = 0;
 482	unsigned int fixed_low_size, fixed_middle_size, fixed_high_size;
 483	unsigned long fixed_low_start, fixed_middle_start, fixed_high_start;
 484	unsigned long cma_alignment;
 485	unsigned int low_use_cma = 0;
 486	unsigned int middle_use_cma = 0;
 487	unsigned int high_use_cma = 0;
 488
 489
 490	fixed_low_size = 0;
 491	fixed_middle_size = 0;
 492	fixed_high_size = 0;
 493
 494	cma_alignment = PAGE_SIZE << max(MAX_ORDER, pageblock_order);
 495
 496	for (i = 0; i < apq8064_ion_pdata.nr; ++i) {
 497		struct ion_platform_heap *heap =
 498			&(apq8064_ion_pdata.heaps[i]);
 499		int use_cma = 0;
 500
 501
 502		if (heap->extra_data) {
 503			int fixed_position = NOT_FIXED;
 504
 505			switch ((int)heap->type) {
 506			case ION_HEAP_TYPE_CP:
 507				if (((struct ion_cp_heap_pdata *)
 508					heap->extra_data)->is_cma) {
 509					heap->size = ALIGN(heap->size,
 510						cma_alignment);
 511					use_cma = 1;
 512				}
 513				fixed_position = ((struct ion_cp_heap_pdata *)
 514					heap->extra_data)->fixed_position;
 515				break;
 516			case ION_HEAP_TYPE_DMA:
 517				use_cma = 1;
 518				/* Purposely fall through here */
 519			case ION_HEAP_TYPE_CARVEOUT:
 520				fixed_position = ((struct ion_co_heap_pdata *)
 521					heap->extra_data)->fixed_position;
 522				break;
 523			default:
 524				break;
 525			}
 526
 527			if (fixed_position != NOT_FIXED)
 528				fixed_size += heap->size;
 529			else
 530				reserve_mem_for_ion(MEMTYPE_EBI1, heap->size);
 531
 532			if (fixed_position == FIXED_LOW) {
 533				fixed_low_size += heap->size;
 534				low_use_cma = use_cma;
 535			} else if (fixed_position == FIXED_MIDDLE) {
 536				fixed_middle_size += heap->size;
 537				middle_use_cma = use_cma;
 538			} else if (fixed_position == FIXED_HIGH) {
 539				fixed_high_size += heap->size;
 540				high_use_cma = use_cma;
 541			} else if (use_cma) {
 542				/*
 543				 * Heaps that use CMA but are not part of the
 544				 * fixed set. Create wherever.
 545				 */
 546				dma_declare_contiguous(
 547					heap->priv,
 548					heap->size,
 549					0,
 550					0xb0000000);
 551
 552			}
 553		}
 554	}
 555
 556	if (!fixed_size)
 557		return;
 558
 559	/*
 560	 * Given the setup for the fixed area, we can't round up all sizes.
 561	 * Some sizes must be set up exactly and aligned correctly. Incorrect
 562	 * alignments are considered a configuration issue
 563	 */
 564
 565	fixed_low_start = APQ8064_FIXED_AREA_START;
 566	if (low_use_cma) {
 567		BUG_ON(!IS_ALIGNED(fixed_low_size + HOLE_SIZE, cma_alignment));
 568		BUG_ON(!IS_ALIGNED(fixed_low_start, cma_alignment));
 569	} else {
 570		BUG_ON(!IS_ALIGNED(fixed_low_size + HOLE_SIZE, SECTION_SIZE));
 571		ret = memblock_remove(fixed_low_start,
 572				      fixed_low_size + HOLE_SIZE);
 573		BUG_ON(ret);
 574	}
 575
 576	fixed_middle_start = fixed_low_start + fixed_low_size + HOLE_SIZE;
 577	if (middle_use_cma) {
 578		BUG_ON(!IS_ALIGNED(fixed_middle_start, cma_alignment));
 579		BUG_ON(!IS_ALIGNED(fixed_middle_size, cma_alignment));
 580	} else {
 581		BUG_ON(!IS_ALIGNED(fixed_middle_size, SECTION_SIZE));
 582		ret = memblock_remove(fixed_middle_start, fixed_middle_size);
 583		BUG_ON(ret);
 584	}
 585
 586	fixed_high_start = fixed_middle_start + fixed_middle_size;
 587	if (high_use_cma) {
 588		fixed_high_size = ALIGN(fixed_high_size, cma_alignment);
 589		BUG_ON(!IS_ALIGNED(fixed_high_start, cma_alignment));
 590	} else {
 591		/* This is the end of the fixed area so it's okay to round up */
 592		fixed_high_size = ALIGN(fixed_high_size, SECTION_SIZE);
 593		ret = memblock_remove(fixed_high_start, fixed_high_size);
 594		BUG_ON(ret);
 595	}
 596
 597	for (i = 0; i < apq8064_ion_pdata.nr; ++i) {
 598		struct ion_platform_heap *heap = &(apq8064_ion_pdata.heaps[i]);
 599
 600		if (heap->extra_data) {
 601			int fixed_position = NOT_FIXED;
 602			struct ion_cp_heap_pdata *pdata = NULL;
 603
 604			switch ((int) heap->type) {
 605			case ION_HEAP_TYPE_CP:
 606				pdata =
 607				(struct ion_cp_heap_pdata *)heap->extra_data;
 608				fixed_position = pdata->fixed_position;
 609				break;
 610			case ION_HEAP_TYPE_CARVEOUT:
 611			case ION_HEAP_TYPE_DMA:
 612				fixed_position = ((struct ion_co_heap_pdata *)
 613					heap->extra_data)->fixed_position;
 614				break;
 615			default:
 616				break;
 617			}
 618
 619			switch (fixed_position) {
 620			case FIXED_LOW:
 621				heap->base = fixed_low_start;
 622				break;
 623			case FIXED_MIDDLE:
 624				heap->base = fixed_middle_start;
 625				if (middle_use_cma) {
 626					ret = dma_declare_contiguous(
 627						heap->priv,
 628						heap->size,
 629						fixed_middle_start,
 630						0xa0000000);
 631					WARN_ON(ret);
 632				}
 633				pdata->secure_base = fixed_middle_start
 634								- HOLE_SIZE;
 635				pdata->secure_size = HOLE_SIZE + heap->size;
 636				break;
 637			case FIXED_HIGH:
 638				heap->base = fixed_high_start;
 639				break;
 640			default:
 641				break;
 642			}
 643		}
 644	}
 645#endif
 646}
 647
 648static void __init reserve_mdp_memory(void)
 649{
 650	apq8064_mdp_writeback(apq8064_reserve_table);
 651}
 652
 653static void __init reserve_cache_dump_memory(void)
 654{
 655#ifdef CONFIG_MSM_CACHE_DUMP
 656	unsigned int total;
 657
 658	total = apq8064_cache_dump_pdata.l1_size +
 659		apq8064_cache_dump_pdata.l2_size;
 660	apq8064_reserve_table[MEMTYPE_EBI1].size += total;
 661#endif
 662}
 663
 664static void __init reserve_mpdcvs_memory(void)
 665{
 666	apq8064_reserve_table[MEMTYPE_EBI1].size += SZ_32K;
 667}
 668
 669static void __init apq8064_calculate_reserve_sizes(void)
 670{
 671	size_pmem_devices();
 672	reserve_pmem_memory();
 673	reserve_ion_memory();
 674	reserve_mdp_memory();
 675	reserve_rtb_memory();
 676	reserve_cache_dump_memory();
 677	reserve_mpdcvs_memory();
 678}
 679
 680static struct reserve_info apq8064_reserve_info __initdata = {
 681	.memtype_reserve_table = apq8064_reserve_table,
 682	.calculate_reserve_sizes = apq8064_calculate_reserve_sizes,
 683	.reserve_fixed_area = apq8064_reserve_fixed_area,
 684	.paddr_to_memtype = apq8064_paddr_to_memtype,
 685};
 686
 687static int apq8064_memory_bank_size(void)
 688{
 689	return 1<<29;
 690}
 691
 692static void __init locate_unstable_memory(void)
 693{
 694	struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
 695	unsigned long bank_size;
 696	unsigned long low, high;
 697
 698	bank_size = apq8064_memory_bank_size();
 699	low = meminfo.bank[0].start;
 700	high = mb->start + mb->size;
 701
 702	/* Check if 32 bit overflow occured */
 703	if (high < mb->start)
 704		high = -PAGE_SIZE;
 705
 706	low &= ~(bank_size - 1);
 707
 708	if (high - low <= bank_size)
 709		goto no_dmm;
 710
 711#ifdef CONFIG_ENABLE_DMM
 712	apq8064_reserve_info.low_unstable_address = mb->start -
 713					MIN_MEMORY_BLOCK_SIZE + mb->size;
 714	apq8064_reserve_info.max_unstable_size = MIN_MEMORY_BLOCK_SIZE;
 715
 716	apq8064_reserve_info.bank_size = bank_size;
 717	pr_info("low unstable address %lx max size %lx bank size %lx\n",
 718		apq8064_reserve_info.low_unstable_address,
 719		apq8064_reserve_info.max_unstable_size,
 720		apq8064_reserve_info.bank_size);
 721	return;
 722#endif
 723no_dmm:
 724	apq8064_reserve_info.low_unstable_address = high;
 725	apq8064_reserve_info.max_unstable_size = 0;
 726}
 727
 728static int apq8064_change_memory_power(u64 start, u64 size,
 729	int change_type)
 730{
 731	return soc_change_memory_power(start, size, change_type);
 732}
 733
 734static char prim_panel_name[PANEL_NAME_MAX_LEN];
 735static char ext_panel_name[PANEL_NAME_MAX_LEN];
 736
 737static int ext_resolution;
 738
 739static int __init prim_display_setup(char *param)
 740{
 741	if (strnlen(param, PANEL_NAME_MAX_LEN))
 742		strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
 743	return 0;
 744}
 745early_param("prim_display", prim_display_setup);
 746
 747static int __init ext_display_setup(char *param)
 748{
 749	if (strnlen(param, PANEL_NAME_MAX_LEN))
 750		strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
 751	return 0;
 752}
 753early_param("ext_display", ext_display_setup);
 754
 755static int __init hdmi_resulution_setup(char *param)
 756{
 757	int ret;
 758	ret = kstrtoint(param, 10, &ext_resolution);
 759	return ret;
 760}
 761early_param("ext_resolution", hdmi_resulution_setup);
 762
 763static void __init apq8064_reserve(void)
 764{
 765	apq8064_set_display_params(prim_panel_name, ext_panel_name,
 766		ext_resolution);
 767	msm_reserve();
 768}
 769
 770static void __init place_movable_zone(void)
 771{
 772#ifdef CONFIG_ENABLE_DMM
 773	movable_reserved_start = apq8064_reserve_info.low_unstable_address;
 774	movable_reserved_size = apq8064_reserve_info.max_unstable_size;
 775	pr_info("movable zone start %lx size %lx\n",
 776		movable_reserved_start, movable_reserved_size);
 777#endif
 778}
 779
 780static void __init apq8064_early_reserve(void)
 781{
 782	reserve_info = &apq8064_reserve_info;
 783	locate_unstable_memory();
 784	place_movable_zone();
 785
 786}
 787#ifdef CONFIG_USB_EHCI_MSM_HSIC
 788/* Bandwidth requests (zero) if no vote placed */
 789static struct msm_bus_vectors hsic_init_vectors[] = {
 790	{
 791		.src = MSM_BUS_MASTER_SPS,
 792		.dst = MSM_BUS_SLAVE_SPS,
 793		.ab = 0,
 794		.ib = 0,
 795	},
 796};
 797
 798/* Bus bandwidth requests in Bytes/sec */
 799static struct msm_bus_vectors hsic_max_vectors[] = {
 800	{
 801		.src = MSM_BUS_MASTER_SPS,
 802		.dst = MSM_BUS_SLAVE_SPS,
 803		.ab = 0,
 804		.ib = 256000000, /*vote for 32Mhz dfab clk rate*/
 805	},
 806};
 807
 808static struct msm_bus_paths hsic_bus_scale_usecases[] = {
 809	{
 810		ARRAY_SIZE(hsic_init_vectors),
 811		hsic_init_vectors,
 812	},
 813	{
 814		ARRAY_SIZE(hsic_max_vectors),
 815		hsic_max_vectors,
 816	},
 817};
 818
 819static struct msm_bus_scale_pdata hsic_bus_scale_pdata = {
 820	hsic_bus_scale_usecases,
 821	ARRAY_SIZE(hsic_bus_scale_usecases),
 822	.name = "hsic",
 823};
 824
 825static struct msm_hsic_host_platform_data msm_hsic_pdata = {
 826	.strobe			= 88,
 827	.data			= 89,
 828	.bus_scale_table	= &hsic_bus_scale_pdata,
 829};
 830#else
 831static struct msm_hsic_host_platform_data msm_hsic_pdata;
 832#endif
 833
 834#define PID_MAGIC_ID		0x71432909
 835#define SERIAL_NUM_MAGIC_ID	0x61945374
 836#define SERIAL_NUMBER_LENGTH	127
 837#define DLOAD_USB_BASE_ADD	0x2A03F0C8
 838
 839struct magic_num_struct {
 840	uint32_t pid;
 841	uint32_t serial_num;
 842};
 843
 844struct dload_struct {
 845	uint32_t	reserved1;
 846	uint32_t	reserved2;
 847	uint32_t	reserved3;
 848	uint16_t	reserved4;
 849	uint16_t	pid;
 850	char		serial_number[SERIAL_NUMBER_LENGTH];
 851	uint16_t	reserved5;
 852	struct magic_num_struct magic_struct;
 853};
 854
 855static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
 856{
 857	struct dload_struct __iomem *dload = 0;
 858
 859	dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
 860	if (!dload) {
 861		pr_err("%s: cannot remap I/O memory region: %08x\n",
 862					__func__, DLOAD_USB_BASE_ADD);
 863		return -ENXIO;
 864	}
 865
 866	pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
 867				__func__, dload, pid, snum);
 868	/* update pid */
 869	dload->magic_struct.pid = PID_MAGIC_ID;
 870	dload->pid = pid;
 871
 872	/* update serial number */
 873	dload->magic_struct.serial_num = 0;
 874	if (!snum) {
 875		memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
 876		goto out;
 877	}
 878
 879	dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
 880	strlcpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
 881out:
 882	iounmap(dload);
 883	return 0;
 884}
 885
 886static struct android_usb_platform_data android_usb_pdata = {
 887	.update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
 888};
 889
 890static struct platform_device android_usb_device = {
 891	.name	= "android_usb",
 892	.id	= -1,
 893	.dev	= {
 894		.platform_data = &android_usb_pdata,
 895	},
 896};
 897
 898/* Bandwidth requests (zero) if no vote placed */
 899static struct msm_bus_vectors usb_init_vectors[] = {
 900	{
 901		.src = MSM_BUS_MASTER_SPS,
 902		.dst = MSM_BUS_SLAVE_EBI_CH0,
 903		.ab = 0,
 904		.ib = 0,
 905	},
 906};
 907
 908/* Bus bandwidth requests in Bytes/sec */
 909static struct msm_bus_vectors usb_max_vectors[] = {
 910	{
 911		.src = MSM_BUS_MASTER_SPS,
 912		.dst = MSM_BUS_SLAVE_EBI_CH0,
 913		.ab = 60000000,		/* At least 480Mbps on bus. */
 914		.ib = 960000000,	/* MAX bursts rate */
 915	},
 916};
 917
 918static struct msm_bus_paths usb_bus_scale_usecases[] = {
 919	{
 920		ARRAY_SIZE(usb_init_vectors),
 921		usb_init_vectors,
 922	},
 923	{
 924		ARRAY_SIZE(usb_max_vectors),
 925		usb_max_vectors,
 926	},
 927};
 928
 929static struct msm_bus_scale_pdata usb_bus_scale_pdata = {
 930	usb_bus_scale_usecases,
 931	ARRAY_SIZE(usb_bus_scale_usecases),
 932	.name = "usb",
 933};
 934
 935static int phy_init_seq[] = {
 936	0x38, 0x81, /* update DC voltage level */
 937	0x24, 0x82, /* set pre-emphasis and rise/fall time */
 938	-1
 939};
 940
 941#define PMIC_GPIO_DP		27    /* PMIC GPIO for D+ change */
 942#define PMIC_GPIO_DP_IRQ	PM8921_GPIO_IRQ(PM8921_IRQ_BASE, PMIC_GPIO_DP)
 943#define MSM_MPM_PIN_USB1_OTGSESSVLD	40
 944
 945static struct msm_otg_platform_data msm_otg_pdata = {
 946	.mode			= USB_OTG,
 947	.otg_control		= OTG_PMIC_CONTROL,
 948	.phy_type		= SNPS_28NM_INTEGRATED_PHY,
 949	.pmic_id_irq		= PM8921_USB_ID_IN_IRQ(PM8921_IRQ_BASE),
 950	.power_budget		= 750,
 951	.bus_scale_table	= &usb_bus_scale_pdata,
 952	.phy_init_seq		= phy_init_seq,
 953	.mpm_otgsessvld_int	= MSM_MPM_PIN_USB1_OTGSESSVLD,
 954};
 955
 956static struct msm_usb_host_platform_data msm_ehci_host_pdata3 = {
 957	.power_budget = 500,
 958};
 959
 960#ifdef CONFIG_USB_EHCI_MSM_HOST4
 961static struct msm_usb_host_platform_data msm_ehci_host_pdata4;
 962#endif
 963
 964static void __init apq8064_ehci_host_init(void)
 965{
 966	if (machine_is_apq8064_liquid() || machine_is_mpq8064_cdp() ||
 967		machine_is_mpq8064_hrd() || machine_is_mpq8064_dtv()) {
 968		if (machine_is_apq8064_liquid())
 969			msm_ehci_host_pdata3.dock_connect_irq =
 970					PM8921_MPP_IRQ(PM8921_IRQ_BASE, 9);
 971		else
 972			msm_ehci_host_pdata3.pmic_gpio_dp_irq =
 973							PMIC_GPIO_DP_IRQ;
 974
 975		apq8064_device_ehci_host3.dev.platform_data =
 976				&msm_ehci_host_pdata3;
 977		platform_device_register(&apq8064_device_ehci_host3);
 978
 979#ifdef CONFIG_USB_EHCI_MSM_HOST4
 980		apq8064_device_ehci_host4.dev.platform_data =
 981				&msm_ehci_host_pdata4;
 982		platform_device_register(&apq8064_device_ehci_host4);
 983#endif
 984	}
 985}
 986
 987static struct smb349_platform_data smb349_data __initdata = {
 988	.en_n_gpio		= PM8921_GPIO_PM_TO_SYS(37),
 989	.chg_susp_gpio		= PM8921_GPIO_PM_TO_SYS(30),
 990	.chg_current_ma		= 2200,
 991};
 992
 993static struct i2c_board_info smb349_charger_i2c_info[] __initdata = {
 994	{
 995		I2C_BOARD_INFO(SMB349_NAME, 0x1B),
 996		.platform_data	= &smb349_data,
 997	},
 998};
 999
1000struct sx150x_platform_data apq8064_sx150x_data[] = {
1001	[SX150X_EPM] = {
1002		.gpio_base	= GPIO_EPM_EXPANDER_BASE,
1003		.oscio_is_gpo	= false,
1004		.io_pullup_ena	= 0x0,
1005		.io_pulldn_ena	= 0x0,
1006		.io_open_drain_ena = 0x0,
1007		.io_polarity	= 0,
1008		.irq_summary	= -1,
1009	},
1010};
1011
1012static struct epm_chan_properties ads_adc_channel_data[] = {
1013	{10, 100}, {1000, 1}, {10, 100}, {1000, 1},
1014	{10, 100}, {1000, 1}, {10, 100}, {1000, 1},
1015	{10, 100}, {20, 100}, {500, 100}, {5, 100},
1016	{1000, 1}, {200, 100}, {50, 100}, {10, 100},
1017	{510, 100}, {50, 100}, {20, 100}, {100, 100},
1018	{510, 100}, {20, 100}, {50, 100}, {200, 100},
1019	{10, 100}, {20, 100}, {1000, 1}, {10, 100},
1020	{200, 100}, {510, 100}, {1000, 100}, {200, 100},
1021};
1022
1023static struct epm_adc_platform_data epm_adc_pdata = {
1024	.channel		= ads_adc_channel_data,
1025	.bus_id	= 0x0,
1026	.epm_i2c_board_info = {
1027		.type	= "sx1509q",
1028		.addr = 0x3e,
1029		.platform_data = &apq8064_sx150x_data[SX150X_EPM],
1030	},
1031	.gpio_expander_base_addr = GPIO_EPM_EXPANDER_BASE,
1032};
1033
1034static struct platform_device epm_adc_device = {
1035	.name   = "epm_adc",
1036	.id = -1,
1037	.dev = {
1038		.platform_data = &epm_adc_pdata,
1039	},
1040};
1041
1042static void __init apq8064_epm_adc_init(void)
1043{
1044	epm_adc_pdata.num_channels = 32;
1045	epm_adc_pdata.num_adc = 2;
1046	epm_adc_pdata.chan_per_adc = 16;
1047	epm_adc_pdata.chan_per_mux = 8;
1048};
1049
1050/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
1051 * 4 micbiases are used to power various analog and digital
1052 * microphones operating at 1800 mV. Technically, all micbiases
1053 * can source from single cfilter since all microphones operate
1054 * at the same voltage level. The arrangement below is to make
1055 * sure all cfilters are exercised. LDO_H regulator ouput level
1056 * does not need to be as high as 2.85V. It is choosen for
1057 * microphone sensitivity purpose.
1058 */
1059static struct wcd9xxx_pdata apq8064_tabla_platform_data = {
1060	.slimbus_slave_device = {
1061		.name = "tabla-slave",
1062		.e_addr = {0, 0, 0x10, 0, 0x17, 2},
1063	},
1064	.irq = MSM_GPIO_TO_INT(42),
1065	.irq_base = TABLA_INTERRUPT_BASE,
1066	.num_irqs = NR_WCD9XXX_IRQS,
1067	.reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
1068	.micbias = {
1069		.ldoh_v = TABLA_LDOH_2P85_V,
1070		.cfilt1_mv = 1800,
1071		.cfilt2_mv = 2700,
1072		.cfilt3_mv = 1800,
1073		.bias1_cfilt_sel = TABLA_CFILT1_SEL,
1074		.bias2_cfilt_sel = TABLA_CFILT2_SEL,
1075		.bias3_cfilt_sel = TABLA_CFILT3_SEL,
1076		.bias4_cfilt_sel = TABLA_CFILT3_SEL,
1077	},
1078	.regulator = {
1079	{
1080		.name = "CDC_VDD_CP",
1081		.min_uV = 1800000,
1082		.max_uV = 1800000,
1083		.optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
1084	},
1085	{
1086		.name = "CDC_VDDA_RX",
1087		.min_uV = 1800000,
1088		.max_uV = 1800000,
1089		.optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
1090	},
1091	{
1092		.name = "CDC_VDDA_TX",
1093		.min_uV = 1800000,
1094		.max_uV = 1800000,
1095		.optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
1096	},
1097	{
1098		.name = "VDDIO_CDC",
1099		.min_uV = 1800000,
1100		.max_uV = 1800000,
1101		.optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
1102	},
1103	{
1104		.name = "VDDD_CDC_D",
1105		.min_uV = 1225000,
1106		.max_uV = 1250000,
1107		.optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
1108	},
1109	{
1110		.name = "CDC_VDDA_A_1P2V",
1111		.min_uV = 1225000,
1112		.max_uV = 1250000,
1113		.optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
1114	},
1115	},
1116};
1117
1118static struct slim_device apq8064_slim_tabla = {
1119	.name = "tabla-slim",
1120	.e_addr = {0, 1, 0x10, 0, 0x17, 2},
1121	.dev = {
1122		.platform_data = &apq8064_tabla_platform_data,
1123	},
1124};
1125
1126static struct wcd9xxx_pdata apq8064_tabla20_platform_data = {
1127	.slimbus_slave_device = {
1128		.name = "tabla-slave",
1129		.e_addr = {0, 0, 0x60, 0, 0x17, 2},
1130	},
1131	.irq = MSM_GPIO_TO_INT(42),
1132	.irq_base = TABLA_INTERRUPT_BASE,
1133	.num_irqs = NR_WCD9XXX_IRQS,
1134	.reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
1135	.micbias = {
1136		.ldoh_v = TABLA_LDOH_2P85_V,
1137		.cfilt1_mv = 1800,
1138		.cfilt2_mv = 2700,
1139		.cfilt3_mv = 1800,
1140		.bias1_cfilt_sel = TABLA_CFILT1_SEL,
1141		.bias2_cfilt_sel = TABLA_CFILT2_SEL,
1142		.bias3_cfilt_sel = TABLA_CFILT3_SEL,
1143		.bias4_cfilt_sel = TABLA_CFILT3_SEL,
1144	},
1145	.regulator = {
1146	{
1147		.name = "CDC_VDD_CP",
1148		.min_uV = 1800000,
1149		.max_uV = 1800000,
1150		.optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
1151	},
1152	{
1153		.name = "CDC_VDDA_RX",
1154		.min_uV = 1800000,
1155		.max_uV = 1800000,
1156		.optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
1157	},
1158	{
1159		.name = "CDC_VDDA_TX",
1160		.min_uV = 1800000,
1161		.max_uV = 1800000,
1162		.optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
1163	},
1164	{
1165		.name = "VDDIO_CDC",
1166		.min_uV = 1800000,
1167		.max_uV = 1800000,
1168		.optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
1169	},
1170	{
1171		.name = "VDDD_CDC_D",
1172		.min_uV = 1225000,
1173		.max_uV = 1250000,
1174		.optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
1175	},
1176	{
1177		.name = "CDC_VDDA_A_1P2V",
1178		.min_uV = 1225000,
1179		.max_uV = 1250000,
1180		.optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
1181	},
1182	},
1183};
1184
1185static struct slim_device apq8064_slim_tabla20 = {
1186	.name = "tabla2x-slim",
1187	.e_addr = {0, 1, 0x60, 0, 0x17, 2},
1188	.dev = {
1189		.platform_data = &apq8064_tabla20_platform_data,
1190	},
1191};
1192
1193/* enable the level shifter for cs8427 to make sure the I2C
1194 * clock is running at 100KHz and voltage levels are at 3.3
1195 * and 5 volts
1196 */
1197static int enable_100KHz_ls(int enable)
1198{
1199	int ret = 0;
1200	if (enable) {
1201		ret = gpio_request(SX150X_GPIO(1, 10),
1202					"cs8427_100KHZ_ENABLE");
1203		if (ret) {
1204			pr_err("%s: Failed to request gpio %d\n", __func__,
1205				SX150X_GPIO(1, 10));
1206			return ret;
1207		}
1208		gpio_direction_output(SX150X_GPIO(1, 10), 1);
1209	} else {
1210		gpio_direction_output(SX150X_GPIO(1, 10), 0);
1211		gpio_free(SX150X_GPIO(1, 10));
1212	}
1213	return ret;
1214}
1215
1216static struct cs8427_platform_data cs8427_i2c_platform_data = {
1217	.irq = SX150X_GPIO(1, 4),
1218	.reset_gpio = SX150X_GPIO(1, 6),
1219	.enable = enable_100KHz_ls,
1220};
1221
1222static struct i2c_board_info cs8427_device_info[] __initdata = {
1223	{
1224		I2C_BOARD_INFO("cs8427", CS8427_ADDR4),
1225		.platform_data = &cs8427_i2c_platform_data,
1226	},
1227};
1228
1229#define HAP_SHIFT_LVL_OE_GPIO		PM8921_MPP_PM_TO_SYS(8)
1230#define ISA1200_HAP_EN_GPIO		PM8921_GPIO_PM_TO_SYS(33)
1231#define ISA1200_HAP_LEN_GPIO		PM8921_GPIO_PM_TO_SYS(20)
1232#define ISA1200_HAP_CLK_PM8921		PM8921_GPIO_PM_TO_SYS(44)
1233#define ISA1200_HAP_CLK_PM8917		PM8921_GPIO_PM_TO_SYS(38)
1234
1235static int isa1200_clk_enable(bool on)
1236{
1237	unsigned int gpio = ISA1200_HAP_CLK_PM8921;
1238	int rc = 0;
1239
1240	if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917)
1241		gpio = ISA1200_HAP_CLK_PM8917;
1242
1243	gpio_set_value_cansleep(gpio, on);
1244
1245	if (on) {
1246		rc = pm8xxx_aux_clk_control(CLK_MP3_2, XO_DIV_1, true);
1247		if (rc) {
1248			pr_err("%s: unable to write aux clock register(%d)\n",
1249				__func__, rc);
1250			goto err_gpio_dis;
1251		}
1252	} else {
1253		rc = pm8xxx_aux_clk_control(CLK_MP3_2, XO_DIV_NONE, true);
1254		if (rc)
1255			pr_err("%s: unable to write aux clock register(%d)\n",
1256				__func__, rc);
1257	}
1258
1259	return rc;
1260
1261err_gpio_dis:
1262	gpio_set_value_cansleep(gpio, !on);
1263	return rc;
1264}
1265
1266static int isa1200_dev_setup(bool enable)
1267{
1268	unsigned int gpio = ISA1200_HAP_CLK_PM8921;
1269	int rc = 0;
1270
1271	if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917)
1272		gpio = ISA1200_HAP_CLK_PM8917;
1273
1274	if (!enable)
1275		goto free_gpio;
1276
1277	rc = gpio_request(gpio, "haptics_clk");
1278	if (rc) {
1279		pr_err("%s: unable to request gpio %d config(%d)\n",
1280			__func__, gpio, rc);
1281		return rc;
1282	}
1283
1284	rc = gpio_direction_output(gpio, 0);
1285	if (rc) {
1286		pr_err("%s: unable to set direction\n", __func__);
1287		goto free_gpio;
1288	}
1289
1290	return 0;
1291
1292free_gpio:
1293	gpio_free(gpio);
1294	return rc;
1295}
1296
1297static struct isa1200_regulator isa1200_reg_data[] = {
1298	{
1299		.name = "vddp",
1300		.min_uV = ISA_I2C_VTG_MIN_UV,
1301		.max_uV = ISA_I2C_VTG_MAX_UV,
1302		.load_uA = ISA_I2C_CURR_UA,
1303	},
1304};
1305
1306static struct isa1200_platform_data isa1200_1_pdata = {
1307	.name = "vibrator",
1308	.dev_setup = isa1200_dev_setup,
1309	.clk_enable = isa1200_clk_enable,
1310	.need_pwm_clk = true,
1311	.hap_en_gpio = ISA1200_HAP_EN_GPIO,
1312	.hap_len_gpio = ISA1200_HAP_LEN_GPIO,
1313	.max_timeout = 15000,
1314	.mode_ctrl = PWM_GEN_MODE,
1315	.pwm_fd = {
1316		.pwm_div = 256,
1317	},
1318	.is_erm = false,
1319	.smart_en = true,
1320	.ext_clk_en = true,
1321	.chip_en = 1,
1322	.regulator_info = isa1200_reg_data,
1323	.num_regulators = ARRAY_SIZE(isa1200_reg_data),
1324};
1325
1326static struct i2c_board_info isa1200_board_info[] __initdata = {
1327	{
1328		I2C_BOARD_INFO("isa1200_1", 0x90>>1),
1329		.platform_data = &isa1200_1_pdata,
1330	},
1331};
1332/* configuration data for mxt1386e using V2.1 firmware */
1333static const u8 mxt1386e_config_data_v2_1[] = {
1334	/* T6 Object */
1335	0, 0, 0, 0, 0, 0,
1336	/* T38 Object */
1337	14, 3, 0, 5, 7, 12, 0, 0, 0, 0,
1338	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1339	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1340	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1341	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1342	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1343	0, 0, 0, 0,
1344	/* T7 Object */
1345	32, 10, 50,
1346	/* T8 Object */
1347	25, 0, 20, 20, 0, 0, 0, 0, 0, 0,
1348	/* T9 Object */
1349	139, 0, 0, 26, 42, 0, 32, 80, 2, 5,
1350	0, 5, 5, 79, 10, 30, 10, 10, 255, 2,
1351	85, 5, 0, 5, 9, 5, 12, 35, 70, 40,
1352	20, 5, 0, 0, 0,
1353	/* T18 Object */
1354	0, 0,
1355	/* T24 Object */
1356	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1357	0, 0, 0, 0, 0, 0, 0, 0, 0,
1358	/* T25 Object */
1359	1, 0, 60, 115, 156, 99,
1360	/* T27 Object */
1361	0, 0, 0, 0, 0, 0, 0,
1362	/* T40 Object */
1363	0, 0, 0, 0, 0,
1364	/* T42 Object */
1365	0, 0, 255, 0, 255, 0, 0, 0, 0, 0,
1366	/* T43 Object */
1367	0, 0, 0, 0, 0, 0, 0, 64, 0, 8,
1368	16,
1369	/* T46 Object */
1370	68, 0, 16, 16, 0, 0, 0, 0, 0,
1371	/* T47 Object */
1372	0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
1373	/* T48 Object */
1374	1, 64, 64, 0, 0, 0, 0, 0, 0, 0,
1375	32, 40, 0, 10, 10, 0, 0, 100, 10, 90,
1376	0, 0, 0, 0, 0, 0, 0, 10, 1, 10,
1377	52, 10, 12, 0, 33, 0, 1, 0, 0, 0,
1378	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1379	0, 0, 0, 0,
1380	/* T56 Object */
1381	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1382	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1383	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1384	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1385	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1386	0,
1387};
1388
1389#define MXT_TS_GPIO_IRQ			6
1390#define MXT_TS_PWR_EN_GPIO		PM8921_GPIO_PM_TO_SYS(23)
1391#define MXT_TS_RESET_GPIO		33
1392
1393static struct mxt_config_info mxt_config_array[] = {
1394	{
1395		.config		= mxt1386e_config_data_v2_1,
1396		.config_length	= ARRAY_SIZE(mxt1386e_config_data_v2_1),
1397		.family_id	= 0xA0,
1398		.variant_id	= 0x7,
1399		.version	= 0x21,
1400		.build		= 0xAA,
1401		.bootldr_id	= MXT_BOOTLOADER_ID_1386E,
1402		.fw_name	= "atmel_8064_liquid_v2_2_AA.hex",
1403	},
1404	{
1405		/* The config data for V2.2.AA is the same as for V2.1.AA */
1406		.config		= mxt1386e_config_data_v2_1,
1407		.config_length	= ARRAY_SIZE(mxt1386e_config_data_v2_1),
1408		.family_id	= 0xA0,
1409		.variant_id	= 0x7,
1410		.version	= 0x22,
1411		.build		= 0xAA,
1412		.bootldr_id	= MXT_BOOTLOADER_ID_1386E,
1413	},
1414};
1415
1416static struct mxt_platform_data mxt_platform_data = {
1417	.config_array		= mxt_config_array,
1418	.config_array_size	= ARRAY_SIZE(mxt_config_array),
1419	.panel_minx		= 0,
1420	.panel_maxx		= 1365,
1421	.panel_miny		= 0,
1422	.panel_maxy		= 767,
1423	.disp_minx		= 0,
1424	.disp_maxx		= 1365,
1425	.disp_miny		= 0,
1426	.disp_maxy		= 767,
1427	.irqflags		= IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
1428	.i2c_pull_up		= true,
1429	.reset_gpio		= MXT_TS_RESET_GPIO,
1430	.irq_gpio		= MXT_TS_GPIO_IRQ,
1431};
1432
1433static struct i2c_board_info mxt_device_info[] __initdata = {
1434	{
1435		I2C_BOARD_INFO("atmel_mxt_ts", 0x5b),
1436		.platform_data = &mxt_platform_data,
1437		.irq = MSM_GPIO_TO_INT(MXT_TS_GPIO_IRQ),
1438	},
1439};
1440#define CYTTSP_TS_GPIO_IRQ		6
1441#define CYTTSP_TS_GPIO_SLEEP		33
1442#define CYTTSP_TS_GPIO_SLEEP_ALT	12
1443
1444static ssize_t tma340_vkeys_show(struct kobject *kobj,
1445			struct kobj_attribute *attr, char *buf)
1446{
1447	return snprintf(buf, 200,
1448	__stringify(EV_KEY) ":" __stringify(KEY_BACK) ":73:1120:97:97"
1449	":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":230:1120:97:97"
1450	":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":389:1120:97:97"
1451	":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":544:1120:97:97"
1452	"\n");
1453}
1454
1455static struct kobj_attribute tma340_vkeys_attr = {
1456	.attr = {
1457		.mode = S_IRUGO,
1458	},
1459	.show = &tma340_vkeys_show,
1460};
1461
1462static struct attribute *tma340_properties_attrs[] = {
1463	&tma340_vkeys_attr.attr,
1464	NULL
1465};
1466
1467static struct attribute_group tma340_properties_attr_group = {
1468	.attrs = tma340_properties_attrs,
1469};
1470
1471static int cyttsp_platform_init(struct i2c_client *client)
1472{
1473	int rc = 0;
1474	static struct kobject *tma340_properties_kobj;
1475
1476	tma340_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
1477	tma340_properties_kobj = kobject_create_and_add("board_properties",
1478								NULL);
1479	if (tma340_properties_kobj)
1480		rc = sysfs_create_group(tma340_properties_kobj,
1481					&tma340_properties_attr_group);
1482	if (!tma340_properties_kobj || rc)
1483		pr_err("%s: failed to create board_properties\n",
1484				__func__);
1485
1486	return 0;
1487}
1488
1489static struct cyttsp_regulator cyttsp_regulator_data[] = {
1490	{
1491		.name = "vdd",
1492		.min_uV = CY_TMA300_VTG_MIN_UV,
1493		.max_uV = CY_TMA300_VTG_MAX_UV,
1494		.hpm_load_uA = CY_TMA300_CURR_24HZ_UA,
1495		.lpm_load_uA = CY_TMA300_CURR_24HZ_UA,
1496	},
1497	{
1498		.name = "vcc_i2c",
1499		.min_uV = CY_I2C_VTG_MIN_UV,
1500		.max_uV = CY_I2C_VTG_MAX_UV,
1501		.hpm_load_uA = CY_I2C_CURR_UA,
1502		.lpm_load_uA = CY_I2C_CURR_UA,
1503	},
1504};
1505
1506static struct cyttsp_platform_data cyttsp_pdata = {
1507	.panel_maxx = 634,
1508	.panel_maxy = 1166,
1509	.disp_minx = 18,
1510	.disp_maxx = 617,
1511	.disp_miny = 18,
1512	.disp_maxy = 1041,
1513	.flags = 0x01,
1514	.gen = CY_GEN3,
1515	.use_st = CY_USE_ST,
1516	.use_mt = CY_USE_MT,
1517	.use_hndshk = CY_SEND_HNDSHK,
1518	.use_trk_id = CY_USE_TRACKING_ID,
1519	.use_sleep = CY_USE_DEEP_SLEEP_SEL,
1520	.use_gestures = CY_USE_GESTURES,
1521	.fw_fname = "cyttsp_8064_mtp.hex",
1522	/* change act_intrvl to customize the Active power state
1523	 * scanning/processing refresh interval for Operating mode
1524	 */
1525	.act_intrvl = CY_ACT_INTRVL_DFLT,
1526	/* change tch_tmout to customize the touch timeout for the
1527	 * Active power state for Operating mode
1528	 */
1529	.tch_tmout = CY_TCH_TMOUT_DFLT,
1530	/* change lp_intrvl to customize the Low Power power state
1531	 * scanning/processing refresh interval for Operating mode
1532	 */
1533	.lp_intrvl = CY_LP_INTRVL_DFLT,
1534	.sleep_gpio = CYTTSP_TS_GPIO_SLEEP,
1535	.resout_gpio = -1,
1536	.irq_gpio = CYTTSP_TS_GPIO_IRQ,
1537	.regulator_info = cyttsp_regulator_data,
1538	.num_regulators = ARRAY_SIZE(cyttsp_regulator_data),
1539	.init = cyttsp_platform_init,
1540	.correct_fw_ver = 17,
1541};
1542
1543static struct i2c_board_info cyttsp_info[] __initdata = {
1544	{
1545		I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
1546		.platform_data = &cyttsp_pdata,
1547		.irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
1548	},
1549};
1550
1551#define MSM_WCNSS_PHYS	0x03000000
1552#define MSM_WCNSS_SIZE	0x280000
1553
1554static struct resource resources_wcnss_wlan[] = {
1555	{
1556		.start	= RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1557		.end	= RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1558		.name	= "wcnss_wlanrx_irq",
1559		.flags	= IORESOURCE_IRQ,
1560	},
1561	{
1562		.start	= RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1563		.end	= RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1564		.name	= "wcnss_wlantx_irq",
1565		.flags	= IORESOURCE_IRQ,
1566	},
1567	{
1568		.start	= MSM_WCNSS_PHYS,
1569		.end	= MSM_WCNSS_PHYS + MSM_WCNSS_SIZE - 1,
1570		.name	= "wcnss_mmio",
1571		.flags	= IORESOURCE_MEM,
1572	},
1573	{
1574		.start	= 64,
1575		.end	= 68,
1576		.name	= "wcnss_gpios_5wire",
1577		.flags	= IORESOURCE_IO,
1578	},
1579};
1580
1581static struct qcom_wcnss_opts qcom_wcnss_pdata = {
1582	.has_48mhz_xo	= 1,
1583};
1584
1585static struct platform_device msm_device_wcnss_wlan = {
1586	.name		= "wcnss_wlan",
1587	.id		= 0,
1588	.num_resources	= ARRAY_SIZE(resources_wcnss_wlan),
1589	.resource	= resources_wcnss_wlan,
1590	.dev		= {.platform_data = &qcom_wcnss_pdata},
1591};
1592
1593static struct platform_device msm_device_iris_fm __devinitdata = {
1594	.name = "iris_fm",
1595	.id   = -1,
1596};
1597
1598#ifdef CONFIG_QSEECOM
1599/* qseecom bus scaling */
1600static struct msm_bus_vectors qseecom_clks_init_vectors[] = {
1601	{
1602		.src = MSM_BUS_MASTER_ADM_PORT0,
1603		.dst = MSM_BUS_SLAVE_EBI_CH0,
1604		.ab = 0,
1605		.ib = 0,
1606	},
1607	{
1608		.src = MSM_BUS_MASTER_ADM_PORT1,
1609		.dst = MSM_BUS_SLAVE_GSBI1_UART,
1610		.ab = 0,
1611		.ib = 0,
1612	},
1613	{
1614		.src = MSM_BUS_MASTER_SPDM,
1615		.dst = MSM_BUS_SLAVE_SPDM,
1616		.ib = 0,
1617		.ab = 0,
1618	},
1619};
1620
1621static struct msm_bus_vectors qseecom_enable_dfab_vectors[] = {
1622	{
1623		.src = MSM_BUS_MASTER_ADM_PORT0,
1624		.dst = MSM_BUS_SLAVE_EBI_CH0,
1625		.ab = 70000000UL,
1626		.ib = 70000000UL,
1627	},
1628	{
1629		.src = MSM_BUS_MASTER_ADM_PORT1,
1630		.dst = MSM_BUS_SLAVE_GSBI1_UART,
1631		.ab = 2480000000UL,
1632		.ib = 2480000000UL,
1633	},
1634	{
1635		.src = MSM_BUS_MASTER_SPDM,
1636		.dst = MSM_BUS_SLAVE_SPDM,
1637		.ib = 0,
1638		.ab = 0,
1639	},
1640};
1641
1642static struct msm_bus_vectors qseecom_enable_sfpb_vectors[] = {
1643	{
1644		.src = MSM_BUS_MASTER_ADM_PORT0,
1645		.dst = MSM_BUS_SLAVE_EBI_CH0,
1646		.ab = 0,
1647		.ib = 0,
1648	},
1649	{
1650		.src = MSM_BUS_MASTER_ADM_PORT1,
1651		.dst = MSM_BUS_SLAVE_GSBI1_UART,
1652		.ab = 0,
1653		.ib = 0,
1654	},
1655	{
1656		.src = MSM_BUS_MASTER_SPDM,
1657		.dst = MSM_BUS_SLAVE_SPDM,
1658		.ib = (64 * 8) * 1000000UL,
1659		.ab = (64 * 8) *  100000UL,
1660	},
1661};
1662
1663static struct msm_bus_vectors qseecom_enable_dfab_sfpb_vectors[] = {
1664	{
1665		.src = MSM_BUS_MASTER_ADM_PORT0,
1666		.dst = MSM_BUS_SLAVE_EBI_CH0,
1667		.ab = 70000000UL,
1668		.ib = 70000000UL,
1669	},
1670	{
1671		.src = MSM_BUS_MASTER_ADM_PORT1,
1672		.dst = MSM_BUS_SLAVE_GSBI1_UART,
1673		.ab = 2480000000UL,
1674		.ib = 2480000000UL,
1675	},
1676	{
1677		.src = MSM_BUS_MASTER_SPDM,
1678		.dst = MSM_BUS_SLAVE_SPDM,
1679		.ib = (64 * 8) * 1000000UL,
1680		.ab = (64 * 8) *  100000UL,
1681	},
1682};
1683
1684static struct msm_bus_paths qseecom_hw_bus_scale_usecases[] = {
1685	{
1686		ARRAY_SIZE(qseecom_clks_init_vectors),
1687		qseecom_clks_init_vectors,
1688	},
1689	{
1690		ARRAY_SIZE(qseecom_enable_dfab_vectors),
1691		qseecom_enable_dfab_vectors,
1692	},
1693	{
1694		ARRAY_SIZE(qseecom_enable_sfpb_vectors),
1695		qseecom_enable_sfpb_vectors,
1696	},
1697	{
1698		ARRAY_SIZE(qseecom_enable_dfab_sfpb_vectors),
1699		qseecom_enable_dfab_sfpb_vectors,
1700	},
1701};
1702
1703static struct msm_bus_scale_pdata qseecom_bus_pdata = {
1704	qseecom_hw_bus_scale_usecases,
1705	ARRAY_SIZE(qseecom_hw_bus_scale_usecases),
1706	.name = "qsee",
1707};
1708
1709static struct platform_device qseecom_device = {
1710	.name		= "qseecom",
1711	.id		= 0,
1712	.dev		= {
1713		.platform_data = &qseecom_bus_pdata,
1714	},
1715};
1716#endif
1717
1718#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1719		defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
1720		defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1721		defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1722
1723#define QCE_SIZE		0x10000
1724#define QCE_0_BASE		0x11000000
1725
1726#define QCE_HW_KEY_SUPPORT	0
1727#define QCE_SHA_HMAC_SUPPORT	1
1728#define QCE_SHARE_CE_RESOURCE	3
1729#define QCE_CE_SHARED		0
1730
1731static struct resource qcrypto_resources[] = {
1732	[0] = {
1733		.start = QCE_0_BASE,
1734		.end = QCE_0_BASE + QCE_SIZE - 1,
1735		.flags = IORESOURCE_MEM,
1736	},
1737	[1] = {
1738		.name = "crypto_channels",
1739		.start = DMOV8064_CE_IN_CHAN,
1740		.end = DMOV8064_CE_OUT_CHAN,
1741		.flags = IORESOURCE_DMA,
1742	},
1743	[2] = {
1744		.name = "crypto_crci_in",
1745		.start = DMOV8064_CE_IN_CRCI,
1746		.end = DMOV8064_CE_IN_CRCI,
1747		.flags = IORESOURCE_DMA,
1748	},
1749	[3] = {
1750		.name = "crypto_crci_out",
1751		.start = DMOV8064_CE_OUT_CRCI,
1752		.end = DMOV8064_CE_OUT_CRCI,
1753		.flags = IORESOURCE_DMA,
1754	},
1755};
1756
1757static struct resource qcedev_resources[] = {
1758	[0] = {
1759		.start = QCE_0_BASE,
1760		.end = QCE_0_BASE + QCE_SIZE - 1,
1761		.flags = IORESOURCE_MEM,
1762	},
1763	[1] = {
1764		.name = "crypto_channels",
1765		.start = DMOV8064_CE_IN_CHAN,
1766		.end = DMOV8064_CE_OUT_CHAN,
1767		.flags = IORESOURCE_DMA,
1768	},
1769	[2] = {
1770		.name = "crypto_crci_in",
1771		.start = DMOV8064_CE_IN_CRCI,
1772		.end = DMOV8064_CE_IN_CRCI,
1773		.flags = IORESOURCE_DMA,
1774	},
1775	[3] = {
1776		.name = "crypto_crci_out",
1777		.start = DMOV8064_CE_OUT_CRCI,
1778		.end = DMOV8064_CE_OUT_CRCI,
1779		.flags = IORESOURCE_DMA,
1780	},
1781};
1782
1783#endif
1784
1785#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1786		defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
1787
1788static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
1789	.ce_shared = QCE_CE_SHARED,
1790	.shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1791	.hw_key_support = QCE_HW_KEY_SUPPORT,
1792	.sha_hmac = QCE_SHA_HMAC_SUPPORT,
1793	.bus_scale_table = NULL,
1794};
1795
1796static struct platform_device qcrypto_device = {
1797	.name		= "qcrypto",
1798	.id		= 0,
1799	.num_resources	= ARRAY_SIZE(qcrypto_resources),
1800	.resource	= qcrypto_resources,
1801	.dev		= {
1802		.coherent_dma_mask = DMA_BIT_MASK(32),
1803		.platform_data = &qcrypto_ce_hw_suppport,
1804	},
1805};
1806#endif
1807
1808#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1809		defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1810
1811static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
1812	.ce_shared = QCE_CE_SHARED,
1813	.shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1814	.hw_key_support = QCE_HW_KEY_SUPPORT,
1815	.sha_hmac = QCE_SHA_HMAC_SUPPORT,
1816	.bus_scale_table = NULL,
1817};
1818
1819static struct platform_device qcedev_device = {
1820	.name		= "qce",
1821	.id		= 0,
1822	.num_resources	= ARRAY_SIZE(qcedev_resources),
1823	.resource	= qcedev_resources,
1824	.dev		= {
1825		.coherent_dma_mask = DMA_BIT_MASK(32),
1826		.platform_data = &qcedev_ce_hw_suppport,
1827	},
1828};
1829#endif
1830
1831static struct mdm_vddmin_resource mdm_vddmin_rscs = {
1832	.rpm_id = MSM_RPM_ID_VDDMIN_GPIO,
1833	.ap2mdm_vddmin_gpio = 30,
1834	.modes  = 0x03,
1835	.drive_strength = 8,
1836	.mdm2ap_vddmin_gpio = 80,
1837};
1838
1839static struct gpiomux_setting mdm2ap_status_gpio_run_cfg = {
1840	.func = GPIOMUX_FUNC_GPIO,
1841	.drv = GPIOMUX_DRV_8MA,
1842	.pull = GPIOMUX_PULL_NONE,
1843};
1844
1845static struct mdm_platform_data mdm_platform_data = {
1846	.mdm_version = "3.0",
1847	.ramdump_delay_ms = 2000,
1848	.early_power_on = 1,
1849	.sfr_query = 1,
1850	.vddmin_resource = &mdm_vddmin_rscs,
1851	.peripheral_platform_device = &apq8064_device_hsic_host,
1852	.ramdump_timeout_ms = 120000,
1853	.mdm2ap_status_gpio_run_cfg = &mdm2ap_status_gpio_run_cfg,
1854	.sysmon_subsys_id_valid = 1,
1855	.sysmon_subsys_id = SYSMON_SS_EXT_MODEM,
1856};
1857
1858static struct mdm_platform_data amdm_platform_data = {
1859	.mdm_version = "3.0",
1860	.ramdump_delay_ms = 2000,
1861	.early_power_on = 1,
1862	.sfr_query = 1,
1863	.send_shdn = 1,
1864	.vddmin_resource = &mdm_vddmin_rscs,
1865	.peripheral_platform_device = &apq8064_device_hsic_host,
1866	.ramdump_timeout_ms = 120000,
1867	.mdm2ap_status_gpio_run_cfg = &mdm2ap_status_gpio_run_cfg,
1868	.sysmon_subsys_id_valid = 1,
1869	.sysmon_subsys_id = SYSMON_SS_EXT_MODEM,
1870	.no_a2m_errfatal_on_ssr = 1,
1871};
1872
1873static struct mdm_vddmin_resource bmdm_vddmin_rscs = {
1874	.rpm_id = MSM_RPM_ID_VDDMIN_GPIO,
1875	.ap2mdm_vddmin_gpio = 30,
1876	.modes  = 0x03,
1877	.drive_strength = 8,
1878	.mdm2ap_vddmin_gpio = 64,
1879};
1880
1881static struct mdm_platform_data bmdm_platform_data = {
1882	.mdm_version = "3.0",
1883	.ramdump_delay_ms = 2000,
1884	.sfr_query = 1,
1885	.send_shdn = 1,
1886	.vddmin_resource = &bmdm_vddmin_rscs,
1887	.peripheral_platform_device = &apq8064_device_ehci_host3,
1888	.ramdump_timeout_ms = 120000,
1889	.mdm2ap_status_gpio_run_cfg = &mdm2ap_status_gpio_run_cfg,
1890	.sysmon_subsys_id_valid = 1,
1891	.sysmon_subsys_id = SYSMON_SS_EXT_MODEM2,
1892	.no_a2m_errfatal_on_ssr = 1,
1893};
1894
1895static struct tsens_platform_data apq_tsens_pdata  = {
1896		.tsens_factor		= 1000,
1897		.hw_type		= APQ_8064,
1898		.tsens_num_sensor	= 11,
1899		.slope = {1176, 1176, 1154, 1176, 1111,
1900			1132, 1132, 1199, 1132, 1199, 1132},
1901};
1902
1903static struct platform_device msm_tsens_device = {
1904	.name   = "tsens8960-tm",
1905	.id = -1,
1906};
1907
1908static struct msm_thermal_data msm_thermal_pdata = {
1909	.sensor_id = 7,
1910	.poll_ms = 250,
1911	.limit_temp_degC = 60,
1912	.temp_hysteresis_degC = 10,
1913	.freq_step = 2,
1914};
1915
1916#define MSM_SHARED_RAM_PHYS 0x80000000
1917static void __init apq8064_map_io(void)
1918{
1919	msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
1920	msm_map_apq8064_io();
1921	if (socinfo_init() < 0)
1922		pr_err("socinfo_init() failed!\n");
1923}
1924
1925static void __init apq8064_init_irq(void)
1926{
1927	struct msm_mpm_device_data *data = NULL;
1928
1929#ifdef CONFIG_MSM_MPM
1930	data = &apq8064_mpm_dev_data;
1931#endif
1932
1933	msm_mpm_irq_extn_init(data);
1934	gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
1935						(void *)MSM_QGIC_CPU_BASE);
1936}
1937
1938static struct platform_device msm8064_device_saw_regulator_core0 = {
1939	.name	= "saw-regulator",
1940	.id	= 0,
1941	.dev	= {
1942		.platform_data = &msm8064_saw_regulator_pdata_8921_s5,
1943	},
1944};
1945
1946static struct platform_device msm8064_device_saw_regulator_core1 = {
1947	.name	= "saw-regulator",
1948	.id	= 1,
1949	.dev	= {
1950		.platform_data = &msm8064_saw_regulator_pdata_8921_s6,
1951	},
1952};
1953
1954static struct platform_device msm8064_device_saw_regulator_core2 = {
1955	.name	= "saw-regulator",
1956	.id	= 2,
1957	.dev	= {
1958		.platform_data = &msm8064_saw_regulator_pdata_8821_s0,
1959	},
1960};
1961
1962static struct platform_device msm8064_device_saw_regulator_core3 = {
1963	.name	= "saw-regulator",
1964	.id	= 3,
1965	.dev	= {
1966		.platform_data = &msm8064_saw_regulator_pdata_8821_s1,
1967
1968	},
1969};
1970
1971static struct msm_rpmrs_level msm_rpmrs_levels[] = {
1972	{
1973		MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
1974		MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
1975		true,
1976		1, 784, 180000, 100,
1977	},
1978
1979	{
1980		MSM_PM_SLEEP_MODE_RETENTION,
1981		MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
1982		true,
1983		415, 715, 340827, 475,
1984	},
1985
1986	{
1987		MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
1988		MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
1989		true,
1990		1300, 228, 1200000, 2000

Large files files are truncated, but you can click here to view the full file