blob: 8eb92a470b712dcae88d46273330c470c5be6372 [file] [log] [blame]
Daniel Walker2682fd32010-02-24 15:47:58 -08001/*
2 * Copyright (C) 2007 Google, Inc.
Sravan Kumar Ambapuramb22cf4d2012-01-02 21:45:04 +05303 * Copyright (c) 2008-2012, Code Aurora Forum. All rights reserved.
Daniel Walker2682fd32010-02-24 15:47:58 -08004 * Author: Brian Swetland <swetland@google.com>
5 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16
17#include <linux/kernel.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070018#include <linux/gpio.h>
Daniel Walker2682fd32010-02-24 15:47:58 -080019#include <linux/init.h>
20#include <linux/platform_device.h>
21#include <linux/input.h>
22#include <linux/io.h>
23#include <linux/delay.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070024#include <linux/bootmem.h>
Daniel Walker2682fd32010-02-24 15:47:58 -080025#include <linux/power_supply.h>
26
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070027#include <mach/msm_memtypes.h>
Daniel Walker2682fd32010-02-24 15:47:58 -080028#include <mach/hardware.h>
29#include <asm/mach-types.h>
30#include <asm/mach/arch.h>
31#include <asm/mach/map.h>
32#include <asm/mach/flash.h>
33#include <asm/setup.h>
34#ifdef CONFIG_CACHE_L2X0
35#include <asm/hardware/cache-l2x0.h>
36#endif
37
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070038#include <asm/mach/mmc.h>
Daniel Walker2682fd32010-02-24 15:47:58 -080039#include <mach/vreg.h>
40#include <mach/mpp.h>
Daniel Walker2682fd32010-02-24 15:47:58 -080041#include <mach/board.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070042#include <mach/pmic.h>
Daniel Walker2682fd32010-02-24 15:47:58 -080043#include <mach/msm_iomap.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070044#include <mach/msm_rpcrouter.h>
45#include <mach/msm_hsusb.h>
46#include <mach/rpc_hsusb.h>
47#include <mach/rpc_pmapp.h>
48#include <mach/msm_serial_hs.h>
49#include <mach/memory.h>
50#include <mach/msm_battery.h>
51#include <mach/rpc_server_handset.h>
52#include <mach/msm_tsif.h>
53#include <mach/socinfo.h>
Daniel Walker2682fd32010-02-24 15:47:58 -080054
55#include <linux/mtd/nand.h>
56#include <linux/mtd/partitions.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070057#include <linux/i2c.h>
58#include <linux/android_pmem.h>
59#include <mach/camera.h>
Daniel Walker2682fd32010-02-24 15:47:58 -080060
Manu Gautam99ed3912011-10-13 18:00:55 +053061#ifdef CONFIG_USB_G_ANDROID
62#include <linux/usb/android.h>
63#include <mach/usbdiag.h>
64#endif
65
Pankaj Kumar75c86fd2011-10-01 18:51:09 +053066#include "board-msm7627-regulator.h"
Daniel Walker2682fd32010-02-24 15:47:58 -080067#include "devices.h"
Daniel Walker2682fd32010-02-24 15:47:58 -080068#include "clock.h"
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070069#include "acpuclock.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070070#include "msm-keypad-devices.h"
Matt Wagantall7cca4642012-02-01 16:43:24 -080071#include "pm.h"
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -060072#include "pm-boot.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070073
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070074#ifdef CONFIG_ARCH_MSM7X25
75#define MSM_PMEM_MDP_SIZE 0xb21000
76#define MSM_PMEM_ADSP_SIZE 0x97b000
77#define MSM_PMEM_AUDIO_SIZE 0x121000
78#define MSM_FB_SIZE 0x200000
79#define PMEM_KERNEL_EBI1_SIZE 0x64000
80#endif
81
82#ifdef CONFIG_ARCH_MSM7X27
83#define MSM_PMEM_MDP_SIZE 0x1B76000
84#define MSM_PMEM_ADSP_SIZE 0xC8A000
85#define MSM_PMEM_AUDIO_SIZE 0x5B000
86
87#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
88#define MSM_FB_SIZE 0x233000
89#else
90#define MSM_FB_SIZE 0x177000
91#endif
92
93#define PMEM_KERNEL_EBI1_SIZE 0x1C000
94#endif
Daniel Walker2682fd32010-02-24 15:47:58 -080095
96static struct resource smc91x_resources[] = {
97 [0] = {
98 .start = 0x9C004300,
99 .end = 0x9C0043ff,
100 .flags = IORESOURCE_MEM,
101 },
102 [1] = {
103 .start = MSM_GPIO_TO_INT(132),
104 .end = MSM_GPIO_TO_INT(132),
105 .flags = IORESOURCE_IRQ,
106 },
107};
108
Manu Gautam99ed3912011-10-13 18:00:55 +0530109static struct platform_device smc91x_device = {
110 .name = "smc91x",
111 .id = 0,
112 .num_resources = ARRAY_SIZE(smc91x_resources),
113 .resource = smc91x_resources,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700114};
115
Manu Gautam99ed3912011-10-13 18:00:55 +0530116#ifdef CONFIG_USB_G_ANDROID
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700117static struct android_usb_platform_data android_usb_pdata = {
Manu Gautam99ed3912011-10-13 18:00:55 +0530118 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700119};
120
121static struct platform_device android_usb_device = {
122 .name = "android_usb",
123 .id = -1,
124 .dev = {
125 .platform_data = &android_usb_pdata,
126 },
127};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700128#endif
129
130#ifdef CONFIG_USB_EHCI_MSM_72K
131static void msm_hsusb_vbus_power(unsigned phy_info, int on)
132{
133 if (on)
134 msm_hsusb_vbus_powerup();
135 else
136 msm_hsusb_vbus_shutdown();
137}
138
139static struct msm_usb_host_platform_data msm_usb_host_pdata = {
140 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_65NM),
141};
142
143static void __init msm7x2x_init_host(void)
144{
145 if (machine_is_msm7x25_ffa() || machine_is_msm7x27_ffa())
146 return;
147
148 msm_add_host(0, &msm_usb_host_pdata);
149}
150#endif
151
152#ifdef CONFIG_USB_MSM_OTG_72K
153static int hsusb_rpc_connect(int connect)
154{
155 if (connect)
156 return msm_hsusb_rpc_connect();
157 else
158 return msm_hsusb_rpc_close();
159}
160#endif
161
162#ifdef CONFIG_USB_MSM_OTG_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700163static int msm_hsusb_ldo_init(int init)
164{
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530165 static struct regulator *reg_hsusb;
166 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700167 if (init) {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530168 reg_hsusb = regulator_get(NULL, "usb");
169 if (IS_ERR(reg_hsusb)) {
170 rc = PTR_ERR(reg_hsusb);
171 pr_err("%s: could not get regulator: %d\n",
172 __func__, rc);
173 goto out;
174 }
175
176 rc = regulator_set_voltage(reg_hsusb, 3300000, 3300000);
177 if (rc < 0) {
178 pr_err("%s: could not set voltage: %d\n",
179 __func__, rc);
180 goto usb_reg_fail;
181 }
182
183 rc = regulator_enable(reg_hsusb);
184 if (rc < 0) {
185 pr_err("%s: could not enable regulator: %d\n",
186 __func__, rc);
187 goto usb_reg_fail;
188 }
189
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700190 /*
191 * PHY 3.3V analog domain(VDDA33) is powered up by
192 * an always enabled power supply (LP5900TL-3.3).
193 * USB VREG default source is VBUS line. Turning
194 * on USB VREG has a side effect on the USB suspend
195 * current. Hence USB VREG is explicitly turned
196 * off here.
197 */
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530198
199 rc = regulator_disable(reg_hsusb);
200 if (rc < 0) {
201 pr_err("%s: could not disable regulator: %d\n",
202 __func__, rc);
203 goto usb_reg_fail;
204 }
205
206 regulator_put(reg_hsusb);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700207 }
208
209 return 0;
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530210usb_reg_fail:
211 regulator_put(reg_hsusb);
212out:
213 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700214}
215
216static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
217{
218 int ret;
219
220 if (init) {
221 ret = msm_pm_app_rpc_init(callback);
222 } else {
223 msm_pm_app_rpc_deinit(callback);
224 ret = 0;
225 }
226 return ret;
227}
228
229static int msm_otg_rpc_phy_reset(void __iomem *regs)
230{
231 return msm_hsusb_phy_reset();
232}
233
234static struct msm_otg_platform_data msm_otg_pdata = {
235 .rpc_connect = hsusb_rpc_connect,
236 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
237 .chg_vbus_draw = hsusb_chg_vbus_draw,
238 .chg_connected = hsusb_chg_connected,
239 .chg_init = hsusb_chg_init,
240#ifdef CONFIG_USB_EHCI_MSM_72K
241 .vbus_power = msm_hsusb_vbus_power,
242#endif
243 .ldo_init = msm_hsusb_ldo_init,
244 .pclk_required_during_lpm = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700245};
246
247#ifdef CONFIG_USB_GADGET
248static struct msm_hsusb_gadget_platform_data msm_gadget_pdata;
249#endif
250#endif
251
252#define SND(desc, num) { .name = #desc, .id = num }
253static struct snd_endpoint snd_endpoints_list[] = {
254 SND(HANDSET, 0),
255 SND(MONO_HEADSET, 2),
256 SND(HEADSET, 3),
257 SND(SPEAKER, 6),
258 SND(TTY_HEADSET, 8),
259 SND(TTY_VCO, 9),
260 SND(TTY_HCO, 10),
261 SND(BT, 12),
262 SND(IN_S_SADC_OUT_HANDSET, 16),
263 SND(IN_S_SADC_OUT_SPEAKER_PHONE, 25),
264 SND(CURRENT, 27),
265};
266#undef SND
267
268static struct msm_snd_endpoints msm_device_snd_endpoints = {
269 .endpoints = snd_endpoints_list,
270 .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint)
271};
272
273static struct platform_device msm_device_snd = {
274 .name = "msm_snd",
275 .id = -1,
276 .dev = {
277 .platform_data = &msm_device_snd_endpoints
278 },
279};
280
281#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
282 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
283 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
284 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
285 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
286 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
287#ifdef CONFIG_ARCH_MSM7X25
288#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_WAV)|(1<<MSM_ADSP_CODEC_ADPCM)| \
289 (1<<MSM_ADSP_CODEC_YADPCM)|(1<<MSM_ADSP_CODEC_QCELP)| \
290 (1<<MSM_ADSP_CODEC_MP3))
291#define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_WAV)|(1<<MSM_ADSP_CODEC_ADPCM)| \
292 (1<<MSM_ADSP_CODEC_YADPCM)|(1<<MSM_ADSP_CODEC_QCELP)| \
293 (1<<MSM_ADSP_CODEC_MP3))
294#define DEC3_FORMAT 0
295#define DEC4_FORMAT 0
296#else
297#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
298 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
299 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
300 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
301 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
302 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
303#define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
304 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
305 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
306 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
307 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
308 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
309#define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
310 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
311 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
312 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
313 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
314 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
315#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
316#endif
317
318static unsigned int dec_concurrency_table[] = {
319 /* Audio LP */
320 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DMA)), 0,
321 0, 0, 0,
322
323 /* Concurrency 1 */
324 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
325 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
326 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
327 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
328 (DEC4_FORMAT),
329
330 /* Concurrency 2 */
331 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
332 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
333 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
334 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
335 (DEC4_FORMAT),
336
337 /* Concurrency 3 */
338 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
339 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
340 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
341 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
342 (DEC4_FORMAT),
343
344 /* Concurrency 4 */
345 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
346 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
347 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
348 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
349 (DEC4_FORMAT),
350
351 /* Concurrency 5 */
352 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
353 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
354 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
355 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
356 (DEC4_FORMAT),
357
358 /* Concurrency 6 */
359 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
360 0, 0, 0, 0,
361
362 /* Concurrency 7 */
363 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
364 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
365 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
366 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
367 (DEC4_FORMAT),
368};
369
370#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
371 .module_queueid = queueid, .module_decid = decid, \
372 .nr_codec_support = nr_codec}
373
374static struct msm_adspdec_info dec_info_list[] = {
375 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
376#ifdef CONFIG_ARCH_MSM7X25
377 DEC_INFO("AUDPLAY1TASK", 14, 1, 5), /* AudPlay1BitStreamCtrlQueue */
378 DEC_INFO("AUDPLAY2TASK", 15, 2, 5), /* AudPlay2BitStreamCtrlQueue */
379 DEC_INFO("AUDPLAY3TASK", 16, 3, 0), /* AudPlay3BitStreamCtrlQueue */
380 DEC_INFO("AUDPLAY4TASK", 17, 4, 0), /* AudPlay4BitStreamCtrlQueue */
381#else
382 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
383 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
384 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
385 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
386#endif
387};
388
389static struct msm_adspdec_database msm_device_adspdec_database = {
390 .num_dec = ARRAY_SIZE(dec_info_list),
391 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
392 ARRAY_SIZE(dec_info_list)),
393 .dec_concurrency_table = dec_concurrency_table,
394 .dec_info_list = dec_info_list,
395};
396
397static struct platform_device msm_device_adspdec = {
398 .name = "msm_adspdec",
399 .id = -1,
400 .dev = {
401 .platform_data = &msm_device_adspdec_database
402 },
403};
404
405static struct android_pmem_platform_data android_pmem_pdata = {
406 .name = "pmem",
407 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
408 .cached = 1,
409 .memory_type = MEMTYPE_EBI1,
410};
411
412static struct android_pmem_platform_data android_pmem_adsp_pdata = {
413 .name = "pmem_adsp",
414 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
415 .cached = 0,
416 .memory_type = MEMTYPE_EBI1,
417};
418
419static struct android_pmem_platform_data android_pmem_audio_pdata = {
420 .name = "pmem_audio",
421 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
422 .cached = 0,
423 .memory_type = MEMTYPE_EBI1,
424};
425
426static struct platform_device android_pmem_device = {
427 .name = "android_pmem",
428 .id = 0,
429 .dev = { .platform_data = &android_pmem_pdata },
430};
431
432static struct platform_device android_pmem_adsp_device = {
433 .name = "android_pmem",
434 .id = 1,
435 .dev = { .platform_data = &android_pmem_adsp_pdata },
436};
437
438static struct platform_device android_pmem_audio_device = {
439 .name = "android_pmem",
440 .id = 2,
441 .dev = { .platform_data = &android_pmem_audio_pdata },
442};
443
444static struct msm_handset_platform_data hs_platform_data = {
445 .hs_name = "7k_handset",
446 .pwr_key_delay_ms = 500, /* 0 will disable end key */
447};
448
449static struct platform_device hs_device = {
450 .name = "msm-handset",
451 .id = -1,
452 .dev = {
453 .platform_data = &hs_platform_data,
454 },
455};
456
457/* TSIF begin */
458#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
459
460#define TSIF_B_SYNC GPIO_CFG(87, 5, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
461#define TSIF_B_DATA GPIO_CFG(86, 3, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
462#define TSIF_B_EN GPIO_CFG(85, 3, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
463#define TSIF_B_CLK GPIO_CFG(84, 4, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
464
465static const struct msm_gpio tsif_gpios[] = {
466 { .gpio_cfg = TSIF_B_CLK, .label = "tsif_clk", },
467 { .gpio_cfg = TSIF_B_EN, .label = "tsif_en", },
468 { .gpio_cfg = TSIF_B_DATA, .label = "tsif_data", },
469 { .gpio_cfg = TSIF_B_SYNC, .label = "tsif_sync", },
470};
471
472static struct msm_tsif_platform_data tsif_platform_data = {
473 .num_gpios = ARRAY_SIZE(tsif_gpios),
474 .gpios = tsif_gpios,
Matt Wagantall640e5fd2011-08-17 16:08:53 -0700475 .tsif_clk = "core_clk",
476 .tsif_pclk = "iface_clk",
477 .tsif_ref_clk = "ref_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700478};
479#endif /* defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) */
480/* TSIF end */
481
482#define LCDC_CONFIG_PROC 21
483#define LCDC_UN_CONFIG_PROC 22
484#define LCDC_API_PROG 0x30000066
485#define LCDC_API_VERS 0x00010001
486
487#define GPIO_OUT_132 132
488#define GPIO_OUT_131 131
489#define GPIO_OUT_103 103
490#define GPIO_OUT_102 102
491#define GPIO_OUT_88 88
492
493static struct msm_rpc_endpoint *lcdc_ep;
494
495static int msm_fb_lcdc_config(int on)
496{
497 int rc = 0;
498 struct rpc_request_hdr hdr;
499
500 if (on)
501 pr_info("lcdc config\n");
502 else
503 pr_info("lcdc un-config\n");
504
505 lcdc_ep = msm_rpc_connect_compatible(LCDC_API_PROG, LCDC_API_VERS, 0);
506 if (IS_ERR(lcdc_ep)) {
507 printk(KERN_ERR "%s: msm_rpc_connect failed! rc = %ld\n",
508 __func__, PTR_ERR(lcdc_ep));
509 return -EINVAL;
510 }
511
512 rc = msm_rpc_call(lcdc_ep,
513 (on) ? LCDC_CONFIG_PROC : LCDC_UN_CONFIG_PROC,
514 &hdr, sizeof(hdr),
515 5 * HZ);
516 if (rc)
517 printk(KERN_ERR
518 "%s: msm_rpc_call failed! rc = %d\n", __func__, rc);
519
520 msm_rpc_close(lcdc_ep);
521 return rc;
522}
523
524static int gpio_array_num[] = {
525 GPIO_OUT_132, /* spi_clk */
526 GPIO_OUT_131, /* spi_cs */
527 GPIO_OUT_103, /* spi_sdi */
528 GPIO_OUT_102, /* spi_sdoi */
529 GPIO_OUT_88
530 };
531
532static void lcdc_gordon_gpio_init(void)
533{
534 if (gpio_request(GPIO_OUT_132, "spi_clk"))
535 pr_err("failed to request gpio spi_clk\n");
536 if (gpio_request(GPIO_OUT_131, "spi_cs"))
537 pr_err("failed to request gpio spi_cs\n");
538 if (gpio_request(GPIO_OUT_103, "spi_sdi"))
539 pr_err("failed to request gpio spi_sdi\n");
540 if (gpio_request(GPIO_OUT_102, "spi_sdoi"))
541 pr_err("failed to request gpio spi_sdoi\n");
542 if (gpio_request(GPIO_OUT_88, "gpio_dac"))
543 pr_err("failed to request gpio_dac\n");
544}
545
546static uint32_t lcdc_gpio_table[] = {
547 GPIO_CFG(GPIO_OUT_132, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
548 GPIO_CFG(GPIO_OUT_131, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
549 GPIO_CFG(GPIO_OUT_103, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
550 GPIO_CFG(GPIO_OUT_102, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
551 GPIO_CFG(GPIO_OUT_88, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
552};
553
554static void config_lcdc_gpio_table(uint32_t *table, int len, unsigned enable)
555{
556 int n, rc;
557 for (n = 0; n < len; n++) {
558 rc = gpio_tlmm_config(table[n],
559 enable ? GPIO_CFG_ENABLE : GPIO_CFG_DISABLE);
560 if (rc) {
561 printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n",
562 __func__, table[n], rc);
563 break;
564 }
565 }
566}
567
568static void lcdc_gordon_config_gpios(int enable)
569{
570 config_lcdc_gpio_table(lcdc_gpio_table,
571 ARRAY_SIZE(lcdc_gpio_table), enable);
572}
573
574static char *msm_fb_lcdc_vreg[] = {
575 "gp5"
576};
577
578static int msm_fb_lcdc_power_save(int on)
579{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700580 int i, rc = 0;
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530581 static struct regulator *vreg[ARRAY_SIZE(msm_fb_lcdc_vreg)];
582
583 if (on) {
584 for (i = 0; i < ARRAY_SIZE(msm_fb_lcdc_vreg); i++) {
585 vreg[i] = regulator_get(NULL, msm_fb_lcdc_vreg[i]);
586 if (IS_ERR(vreg[i])) {
587 rc = PTR_ERR(vreg[i]);
588 pr_err("%s: could get not regulator: %d\n",
589 __func__, rc);
590 goto reg_get_fail;
591 }
592
593 rc = regulator_set_voltage(vreg[i], 2850000, 3000000);
594 if (rc < 0) {
595 pr_err("%s: could not set voltage: %d\n",
596 __func__, rc);
597 goto reg_get_fail;
598 }
599 }
600 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700601
602 for (i = 0; i < ARRAY_SIZE(msm_fb_lcdc_vreg); i++) {
603 if (on) {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530604 rc = regulator_enable(vreg[i]);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700605 if (rc) {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530606 pr_err("%s: could not enable regulator %s:"
607 "%d\n", __func__,
608 msm_fb_lcdc_vreg[i], rc);
609 goto vreg_lcdc_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700610 }
611 } else {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530612 rc = regulator_disable(vreg[i]);
613 if (rc) {
614 pr_err("%s: could not disable regulator %s:"
615 "%d\n", __func__,
616 msm_fb_lcdc_vreg[i], rc);
617
618 regulator_put(vreg[i]);
619 goto vreg_lcdc_fail;
620
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700621 }
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530622
623 regulator_put(vreg[i]);
624 rc = gpio_tlmm_config(GPIO_CFG(GPIO_OUT_88, 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700625 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
626 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530627 if (rc)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700628 printk(KERN_ERR "gpio_tlmm_config failed\n");
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530629
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700630 gpio_set_value(88, 0);
631 mdelay(15);
632 gpio_set_value(88, 1);
633 mdelay(15);
634 }
635 }
636
637 return rc;
638
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530639reg_get_fail:
640 for (; i > 0; i--)
641 regulator_put(vreg[i - 1]);
642 return rc;
643
644vreg_lcdc_fail:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700645 if (on) {
646 for (; i > 0; i--)
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530647 regulator_disable(vreg[i - 1]);
648 } else {
649 for (; i > 0; i--)
650 regulator_enable(vreg[i - 1]);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700651 }
652
653 return rc;
654}
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530655
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700656static struct lcdc_platform_data lcdc_pdata = {
657 .lcdc_gpio_config = msm_fb_lcdc_config,
658 .lcdc_power_save = msm_fb_lcdc_power_save,
659};
660
661static struct msm_panel_common_pdata lcdc_gordon_panel_data = {
662 .panel_config_gpio = lcdc_gordon_config_gpios,
663 .gpio_num = gpio_array_num,
664};
665
666static struct platform_device lcdc_gordon_panel_device = {
667 .name = "lcdc_gordon_vga",
668 .id = 0,
669 .dev = {
670 .platform_data = &lcdc_gordon_panel_data,
671 }
672};
673
674static struct resource msm_fb_resources[] = {
675 {
676 .flags = IORESOURCE_DMA,
677 }
678};
679
680static int msm_fb_detect_panel(const char *name)
681{
682 int ret = -EPERM;
683
684 if (machine_is_msm7x25_ffa() || machine_is_msm7x27_ffa()) {
685 if (!strcmp(name, "lcdc_gordon_vga"))
686 ret = 0;
687 else
688 ret = -ENODEV;
689 }
690
691 return ret;
692}
693
694static struct msm_fb_platform_data msm_fb_pdata = {
695 .detect_client = msm_fb_detect_panel,
696 .mddi_prescan = 1,
697};
698
699static struct platform_device msm_fb_device = {
700 .name = "msm_fb",
701 .id = 0,
702 .num_resources = ARRAY_SIZE(msm_fb_resources),
703 .resource = msm_fb_resources,
704 .dev = {
705 .platform_data = &msm_fb_pdata,
706 }
707};
708
709#ifdef CONFIG_BT
710static struct platform_device msm_bt_power_device = {
711 .name = "bt_power",
712};
713
714enum {
715 BT_WAKE,
716 BT_RFR,
717 BT_CTS,
718 BT_RX,
719 BT_TX,
720 BT_PCM_DOUT,
721 BT_PCM_DIN,
722 BT_PCM_SYNC,
723 BT_PCM_CLK,
724 BT_HOST_WAKE,
725};
726
727static unsigned bt_config_power_on[] = {
728 GPIO_CFG(42, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* WAKE */
729 GPIO_CFG(43, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* RFR */
730 GPIO_CFG(44, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* CTS */
731 GPIO_CFG(45, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* Rx */
732 GPIO_CFG(46, 3, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* Tx */
733 GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DOUT */
734 GPIO_CFG(69, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DIN */
735 GPIO_CFG(70, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_SYNC */
736 GPIO_CFG(71, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_CLK */
737 GPIO_CFG(83, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* HOST_WAKE */
738};
739static unsigned bt_config_power_off[] = {
740 GPIO_CFG(42, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* WAKE */
741 GPIO_CFG(43, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* RFR */
742 GPIO_CFG(44, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* CTS */
743 GPIO_CFG(45, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* Rx */
744 GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* Tx */
745 GPIO_CFG(68, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCM_DOUT */
746 GPIO_CFG(69, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCM_DIN */
747 GPIO_CFG(70, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCM_SYNC */
748 GPIO_CFG(71, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCM_CLK */
749 GPIO_CFG(83, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HOST_WAKE */
750};
751
752static int bluetooth_power(int on)
753{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700754 int pin, rc;
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530755 static struct regulator *vreg_bt;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700756
757 printk(KERN_DEBUG "%s\n", __func__);
758
759 /* do not have vreg bt defined, gp6 is the same */
760 /* vreg_get parameter 1 (struct device *) is ignored */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700761
762 if (on) {
763 for (pin = 0; pin < ARRAY_SIZE(bt_config_power_on); pin++) {
764 rc = gpio_tlmm_config(bt_config_power_on[pin],
765 GPIO_CFG_ENABLE);
766 if (rc) {
767 printk(KERN_ERR
768 "%s: gpio_tlmm_config(%#x)=%d\n",
769 __func__, bt_config_power_on[pin], rc);
770 return -EIO;
771 }
772 }
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530773 vreg_bt = regulator_get(NULL, "gp6");
774
775 if (IS_ERR(vreg_bt)) {
776 rc = PTR_ERR(vreg_bt);
777 pr_err("%s: could get not regulator: %d\n",
778 __func__, rc);
779 goto out;
780 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700781
782 /* units of mV, steps of 50 mV */
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530783 rc = regulator_set_voltage(vreg_bt, 2600000, 2600000);
784 if (rc < 0) {
785 pr_err("%s: could not set voltage: %d\n", __func__, rc);
786 goto bt_vreg_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700787 }
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530788 rc = regulator_enable(vreg_bt);
789 if (rc < 0) {
790 pr_err("%s: could not enable regulator: %d\n",
791 __func__, rc);
792 goto bt_vreg_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700793 }
794 } else {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530795 rc = regulator_disable(vreg_bt);
796 if (rc < 0) {
797 pr_err("%s: could not disable regulator: %d\n",
798 __func__, rc);
799 goto bt_vreg_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700800 }
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530801 regulator_put(vreg_bt);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700802 for (pin = 0; pin < ARRAY_SIZE(bt_config_power_off); pin++) {
803 rc = gpio_tlmm_config(bt_config_power_off[pin],
804 GPIO_CFG_ENABLE);
805 if (rc) {
806 printk(KERN_ERR
807 "%s: gpio_tlmm_config(%#x)=%d\n",
808 __func__, bt_config_power_off[pin], rc);
809 return -EIO;
810 }
811 }
812 }
813 return 0;
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530814
815bt_vreg_fail:
816 regulator_put(vreg_bt);
817out:
818 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700819}
820
821static void __init bt_power_init(void)
822{
823 msm_bt_power_device.dev.platform_data = &bluetooth_power;
824}
825#else
826#define bt_power_init(x) do {} while (0)
827#endif
828
829static struct platform_device msm_device_pmic_leds = {
830 .name = "pmic-leds",
831 .id = -1,
832};
833
834static struct resource bluesleep_resources[] = {
835 {
836 .name = "gpio_host_wake",
837 .start = 83,
838 .end = 83,
839 .flags = IORESOURCE_IO,
840 },
841 {
842 .name = "gpio_ext_wake",
843 .start = 42,
844 .end = 42,
845 .flags = IORESOURCE_IO,
846 },
847 {
848 .name = "host_wake",
849 .start = MSM_GPIO_TO_INT(83),
850 .end = MSM_GPIO_TO_INT(83),
851 .flags = IORESOURCE_IRQ,
852 },
853};
854
855static struct platform_device msm_bluesleep_device = {
856 .name = "bluesleep",
857 .id = -1,
858 .num_resources = ARRAY_SIZE(bluesleep_resources),
859 .resource = bluesleep_resources,
860};
861
862static struct i2c_board_info i2c_devices[] = {
863#ifdef CONFIG_MT9D112
864 {
865 I2C_BOARD_INFO("mt9d112", 0x78 >> 1),
866 },
867#endif
868#ifdef CONFIG_S5K3E2FX
869 {
870 I2C_BOARD_INFO("s5k3e2fx", 0x20 >> 1),
871 },
872#endif
873#ifdef CONFIG_MT9P012
874 {
875 I2C_BOARD_INFO("mt9p012", 0x6C >> 1),
876 },
877#endif
878#ifdef CONFIG_MT9P012_KM
879 {
880 I2C_BOARD_INFO("mt9p012_km", 0x6C >> 2),
881 },
882#endif
883#if defined(CONFIG_MT9T013) || defined(CONFIG_SENSORS_MT9T013)
884 {
885 I2C_BOARD_INFO("mt9t013", 0x6C),
886 },
887#endif
888#ifdef CONFIG_VB6801
889 {
890 I2C_BOARD_INFO("vb6801", 0x20),
891 },
892#endif
893};
894
895#ifdef CONFIG_MSM_CAMERA
896static uint32_t camera_off_gpio_table[] = {
897 /* parallel CAMERA interfaces */
898 GPIO_CFG(0, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT0 */
899 GPIO_CFG(1, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT1 */
900 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */
901 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */
902 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */
903 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */
904 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */
905 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */
906 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */
907 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */
908 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */
909 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */
910 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCLK */
911 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */
912 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */
913 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* MCLK */
914};
915
916static uint32_t camera_on_gpio_table[] = {
917 /* parallel CAMERA interfaces */
918 GPIO_CFG(0, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT0 */
919 GPIO_CFG(1, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT1 */
920 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */
921 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */
922 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */
923 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */
924 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */
925 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */
926 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */
927 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */
928 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */
929 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */
930 GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_16MA), /* PCLK */
931 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */
932 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */
933 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_16MA), /* MCLK */
934 };
935
936static void config_gpio_table(uint32_t *table, int len)
937{
938 int n, rc;
939 for (n = 0; n < len; n++) {
940 rc = gpio_tlmm_config(table[n], GPIO_CFG_ENABLE);
941 if (rc) {
942 printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n",
943 __func__, table[n], rc);
944 break;
945 }
946 }
947}
948
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700949static void msm_camera_vreg_config(int vreg_en)
950{
951 int rc;
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530952 static struct regulator *vreg_gp2;
953 static struct regulator *vreg_gp3;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700954
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530955 if (vreg_gp2 == NULL && vreg_gp3 == NULL) {
956 vreg_gp2 = regulator_get(NULL, "gp2");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700957 if (IS_ERR(vreg_gp2)) {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530958 rc = PTR_ERR(vreg_gp2);
959 pr_err("%s: could not get regulator: %d\n",
960 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700961 return;
962 }
963
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530964 rc = regulator_set_voltage(vreg_gp2, 1800000, 1800000);
965 if (rc < 0) {
966 pr_err("%s: could not set voltage: %d\n",
967 __func__, rc);
968 goto cam_vreg_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700969 }
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530970
971 vreg_gp3 = regulator_get(NULL, "gp3");
972 if (IS_ERR(vreg_gp3)) {
973 rc = PTR_ERR(vreg_gp3);
974 pr_err("%s: could not get regulator: %d\n",
975 __func__, rc);
976 goto cam_vreg_fail;
977 }
978
979 rc = regulator_set_voltage(vreg_gp3, 2850000, 2850000);
980 if (rc < 0) {
981 pr_err("%s: could not set voltage: %d\n", __func__, rc);
982 goto cam_vreg2_fail;
983 }
984
985 return;
986
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700987 }
988
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530989 if (vreg_gp2 == NULL || vreg_gp3 == NULL) {
990 pr_err("Camera Regulators are not initialized\n");
991 return;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700992 }
993
994 if (vreg_en) {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530995 rc = regulator_enable(vreg_gp2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700996 if (rc) {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530997 pr_err("%s: could not enable regulator: %d\n",
998 __func__, rc);
999 goto cam_vreg2_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001000 }
1001
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301002 rc = regulator_enable(vreg_gp3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001003 if (rc) {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301004 pr_err("%s: could not enable regulator: %d\n",
1005 __func__, rc);
1006 goto vreg_gp3_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001007 }
1008 } else {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301009 rc = regulator_disable(vreg_gp2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001010 if (rc) {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301011 pr_err("%s: could not disable regulator: %d\n",
1012 __func__, rc);
1013 return;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001014 }
1015
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301016 rc = regulator_disable(vreg_gp3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001017 if (rc) {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301018 pr_err("%s: could not disable regulator: %d\n",
1019 __func__, rc);
1020 goto cam_vreg2_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001021 }
1022 }
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301023
1024 return;
1025
1026vreg_gp3_fail:
1027 if (vreg_en)
1028 regulator_disable(vreg_gp2);
1029
1030cam_vreg2_fail:
1031 regulator_put(vreg_gp3);
1032cam_vreg_fail:
1033 regulator_put(vreg_gp2);
1034 vreg_gp3 = NULL;
1035 vreg_gp2 = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001036}
1037
1038static int config_camera_on_gpios(void)
1039{
1040 int vreg_en = 1;
1041
1042 if (machine_is_msm7x25_ffa() ||
1043 machine_is_msm7x27_ffa())
1044 msm_camera_vreg_config(vreg_en);
1045
1046 config_gpio_table(camera_on_gpio_table,
1047 ARRAY_SIZE(camera_on_gpio_table));
1048 return 0;
1049}
1050
1051static void config_camera_off_gpios(void)
1052{
1053 int vreg_en = 0;
1054
1055 if (machine_is_msm7x25_ffa() ||
1056 machine_is_msm7x27_ffa())
1057 msm_camera_vreg_config(vreg_en);
1058
1059 config_gpio_table(camera_off_gpio_table,
1060 ARRAY_SIZE(camera_off_gpio_table));
1061}
1062
1063static struct msm_camera_device_platform_data msm_camera_device_data = {
1064 .camera_gpio_on = config_camera_on_gpios,
1065 .camera_gpio_off = config_camera_off_gpios,
Taniya Das13b811a2011-12-09 18:33:45 +05301066 .ioext.mdcphy = MSM7XXX_MDC_PHYS,
1067 .ioext.mdcsz = MSM7XXX_MDC_SIZE,
1068 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
1069 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001070};
1071
1072int pmic_set_flash_led_current(enum pmic8058_leds id, unsigned mA)
1073{
1074 int rc;
1075 rc = pmic_flash_led_set_current(mA);
1076 return rc;
1077}
1078
1079static struct msm_camera_sensor_flash_src msm_flash_src = {
1080 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PMIC,
1081 ._fsrc.pmic_src.num_of_src = 1,
1082 ._fsrc.pmic_src.low_current = 30,
1083 ._fsrc.pmic_src.high_current = 100,
1084 ._fsrc.pmic_src.led_src_1 = 0,
1085 ._fsrc.pmic_src.led_src_2 = 0,
1086 ._fsrc.pmic_src.pmic_set_current = pmic_set_flash_led_current,
1087};
1088
1089#ifdef CONFIG_MT9D112
1090static struct msm_camera_sensor_flash_data flash_mt9d112 = {
1091 .flash_type = MSM_CAMERA_FLASH_LED,
1092 .flash_src = &msm_flash_src
1093};
1094
1095static struct msm_camera_sensor_info msm_camera_sensor_mt9d112_data = {
1096 .sensor_name = "mt9d112",
1097 .sensor_reset = 89,
1098 .sensor_pwd = 85,
1099 .vcm_pwd = 0,
1100 .vcm_enable = 0,
1101 .pdata = &msm_camera_device_data,
1102 .flash_data = &flash_mt9d112
1103};
1104
1105static struct platform_device msm_camera_sensor_mt9d112 = {
1106 .name = "msm_camera_mt9d112",
1107 .dev = {
1108 .platform_data = &msm_camera_sensor_mt9d112_data,
1109 },
1110};
1111#endif
1112
1113#ifdef CONFIG_S5K3E2FX
1114static struct msm_camera_sensor_flash_data flash_s5k3e2fx = {
1115 .flash_type = MSM_CAMERA_FLASH_LED,
1116 .flash_src = &msm_flash_src
1117};
1118
1119static struct msm_camera_sensor_info msm_camera_sensor_s5k3e2fx_data = {
1120 .sensor_name = "s5k3e2fx",
1121 .sensor_reset = 89,
1122 .sensor_pwd = 85,
1123 .vcm_pwd = 0,
1124 .vcm_enable = 0,
1125 .pdata = &msm_camera_device_data,
1126 .flash_data = &flash_s5k3e2fx
1127};
1128
1129static struct platform_device msm_camera_sensor_s5k3e2fx = {
1130 .name = "msm_camera_s5k3e2fx",
1131 .dev = {
1132 .platform_data = &msm_camera_sensor_s5k3e2fx_data,
1133 },
1134};
1135#endif
1136
1137#ifdef CONFIG_MT9P012
1138static struct msm_camera_sensor_flash_data flash_mt9p012 = {
1139 .flash_type = MSM_CAMERA_FLASH_LED,
1140 .flash_src = &msm_flash_src
1141};
1142
1143static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_data = {
1144 .sensor_name = "mt9p012",
1145 .sensor_reset = 89,
1146 .sensor_pwd = 85,
1147 .vcm_pwd = 88,
1148 .vcm_enable = 0,
1149 .pdata = &msm_camera_device_data,
1150 .flash_data = &flash_mt9p012
1151};
1152
1153static struct platform_device msm_camera_sensor_mt9p012 = {
1154 .name = "msm_camera_mt9p012",
1155 .dev = {
1156 .platform_data = &msm_camera_sensor_mt9p012_data,
1157 },
1158};
1159#endif
1160
1161#ifdef CONFIG_MT9P012_KM
1162static struct msm_camera_sensor_flash_data flash_mt9p012_km = {
1163 .flash_type = MSM_CAMERA_FLASH_LED,
1164 .flash_src = &msm_flash_src
1165};
1166
1167static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_km_data = {
1168 .sensor_name = "mt9p012_km",
1169 .sensor_reset = 89,
1170 .sensor_pwd = 85,
1171 .vcm_pwd = 88,
1172 .vcm_enable = 0,
1173 .pdata = &msm_camera_device_data,
1174 .flash_data = &flash_mt9p012_km
1175};
1176
1177static struct platform_device msm_camera_sensor_mt9p012_km = {
1178 .name = "msm_camera_mt9p012_km",
1179 .dev = {
1180 .platform_data = &msm_camera_sensor_mt9p012_km_data,
1181 },
1182};
1183#endif
1184
1185#ifdef CONFIG_MT9T013
1186static struct msm_camera_sensor_flash_data flash_mt9t013 = {
1187 .flash_type = MSM_CAMERA_FLASH_LED,
1188 .flash_src = &msm_flash_src
1189};
1190
1191static struct msm_camera_sensor_info msm_camera_sensor_mt9t013_data = {
1192 .sensor_name = "mt9t013",
1193 .sensor_reset = 89,
1194 .sensor_pwd = 85,
1195 .vcm_pwd = 0,
1196 .vcm_enable = 0,
1197 .pdata = &msm_camera_device_data,
1198 .flash_data = &flash_mt9t013
1199};
1200
1201static struct platform_device msm_camera_sensor_mt9t013 = {
1202 .name = "msm_camera_mt9t013",
1203 .dev = {
1204 .platform_data = &msm_camera_sensor_mt9t013_data,
1205 },
1206};
1207#endif
1208
1209#ifdef CONFIG_VB6801
1210static struct msm_camera_sensor_flash_data flash_vb6801 = {
1211 .flash_type = MSM_CAMERA_FLASH_LED,
1212 .flash_src = &msm_flash_src
1213};
1214
1215static struct msm_camera_sensor_info msm_camera_sensor_vb6801_data = {
1216 .sensor_name = "vb6801",
1217 .sensor_reset = 89,
1218 .sensor_pwd = 88,
1219 .vcm_pwd = 0,
1220 .vcm_enable = 0,
1221 .pdata = &msm_camera_device_data,
1222 .flash_data = &flash_vb6801
1223};
1224
1225static struct platform_device msm_camera_sensor_vb6801 = {
1226 .name = "msm_camera_vb6801",
1227 .dev = {
1228 .platform_data = &msm_camera_sensor_vb6801_data,
1229 },
1230};
1231#endif
1232#endif
1233
1234static u32 msm_calculate_batt_capacity(u32 current_voltage);
1235
1236static struct msm_psy_batt_pdata msm_psy_batt_data = {
1237 .voltage_min_design = 2800,
1238 .voltage_max_design = 4300,
1239 .avail_chg_sources = AC_CHG | USB_CHG ,
1240 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
1241 .calculate_capacity = &msm_calculate_batt_capacity,
1242};
1243
1244static u32 msm_calculate_batt_capacity(u32 current_voltage)
1245{
1246 u32 low_voltage = msm_psy_batt_data.voltage_min_design;
1247 u32 high_voltage = msm_psy_batt_data.voltage_max_design;
1248
1249 return (current_voltage - low_voltage) * 100
1250 / (high_voltage - low_voltage);
1251}
1252
1253static struct platform_device msm_batt_device = {
1254 .name = "msm-battery",
1255 .id = -1,
1256 .dev.platform_data = &msm_psy_batt_data,
1257};
1258
1259
Daniel Walker2682fd32010-02-24 15:47:58 -08001260static struct platform_device *devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001261 &asoc_msm_pcm,
1262 &asoc_msm_dai0,
1263 &asoc_msm_dai1,
1264
Daniel Walker2682fd32010-02-24 15:47:58 -08001265 &msm_device_smd,
1266 &msm_device_dmov,
1267 &msm_device_nand,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001268
1269#ifdef CONFIG_USB_MSM_OTG_72K
1270 &msm_device_otg,
1271#ifdef CONFIG_USB_GADGET
1272 &msm_device_gadget_peripheral,
1273#endif
1274#endif
1275
Manu Gautam99ed3912011-10-13 18:00:55 +05301276#ifdef CONFIG_USB_G_ANDROID
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001277 &android_usb_device,
1278#endif
Manu Gautam99ed3912011-10-13 18:00:55 +05301279
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001280 &msm_device_i2c,
Daniel Walker2682fd32010-02-24 15:47:58 -08001281 &smc91x_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001282 &msm_device_tssc,
1283 &android_pmem_device,
1284 &android_pmem_adsp_device,
1285 &android_pmem_audio_device,
1286 &msm_fb_device,
1287 &lcdc_gordon_panel_device,
1288 &msm_device_uart_dm1,
1289#ifdef CONFIG_BT
1290 &msm_bt_power_device,
1291#endif
1292 &msm_device_pmic_leds,
1293 &msm_device_snd,
1294 &msm_device_adspdec,
1295#ifdef CONFIG_MT9T013
1296 &msm_camera_sensor_mt9t013,
1297#endif
1298#ifdef CONFIG_MT9D112
1299 &msm_camera_sensor_mt9d112,
1300#endif
1301#ifdef CONFIG_S5K3E2FX
1302 &msm_camera_sensor_s5k3e2fx,
1303#endif
1304#ifdef CONFIG_MT9P012
1305 &msm_camera_sensor_mt9p012,
1306#endif
1307#ifdef CONFIG_MT9P012_KM
1308 &msm_camera_sensor_mt9p012_km,
1309#endif
1310#ifdef CONFIG_VB6801
1311 &msm_camera_sensor_vb6801,
1312#endif
1313 &msm_bluesleep_device,
1314#ifdef CONFIG_ARCH_MSM7X27
1315 &msm_kgsl_3d0,
1316#endif
1317#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
1318 &msm_device_tsif,
1319#endif
1320 &hs_device,
1321 &msm_batt_device,
Daniel Walker2682fd32010-02-24 15:47:58 -08001322};
1323
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001324static struct msm_panel_common_pdata mdp_pdata = {
1325 .gpio = 97,
Ravishangar Kalyanam07ef7882011-08-09 15:50:48 -07001326 .mdp_rev = MDP_REV_30,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001327};
1328
1329static void __init msm_fb_add_devices(void)
1330{
1331 msm_fb_register_device("mdp", &mdp_pdata);
1332 msm_fb_register_device("pmdh", 0);
1333 msm_fb_register_device("lcdc", &lcdc_pdata);
1334}
1335
Daniel Walker2682fd32010-02-24 15:47:58 -08001336extern struct sys_timer msm_timer;
1337
1338static void __init msm7x2x_init_irq(void)
1339{
1340 msm_init_irq();
1341}
1342
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001343void msm_serial_debug_init(unsigned int base, int irq,
1344 struct device *clk_device, int signal_irq);
1345
1346#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
1347 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
1348 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
1349 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT))
1350
1351static unsigned long vreg_sts, gpio_sts;
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301352static struct regulator *vreg_mmc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001353static unsigned mpp_mmc = 2;
1354
1355struct sdcc_gpio {
1356 struct msm_gpio *cfg_data;
1357 uint32_t size;
1358 struct msm_gpio *sleep_cfg_data;
1359};
1360
1361static struct msm_gpio sdc1_cfg_data[] = {
1362 {GPIO_CFG(51, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_3"},
1363 {GPIO_CFG(52, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_2"},
1364 {GPIO_CFG(53, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_1"},
1365 {GPIO_CFG(54, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_0"},
1366 {GPIO_CFG(55, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_cmd"},
1367 {GPIO_CFG(56, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "sdc1_clk"},
1368};
1369
1370static struct msm_gpio sdc2_cfg_data[] = {
1371 {GPIO_CFG(62, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "sdc2_clk"},
1372 {GPIO_CFG(63, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_cmd"},
1373 {GPIO_CFG(64, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_3"},
1374 {GPIO_CFG(65, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_2"},
1375 {GPIO_CFG(66, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_1"},
1376 {GPIO_CFG(67, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_0"},
1377};
1378
1379static struct msm_gpio sdc2_sleep_cfg_data[] = {
1380 {GPIO_CFG(62, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "sdc2_clk"},
1381 {GPIO_CFG(63, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "sdc2_cmd"},
1382 {GPIO_CFG(64, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "sdc2_dat_3"},
1383 {GPIO_CFG(65, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "sdc2_dat_2"},
1384 {GPIO_CFG(66, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "sdc2_dat_1"},
1385 {GPIO_CFG(67, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "sdc2_dat_0"},
1386};
1387static struct msm_gpio sdc3_cfg_data[] = {
1388 {GPIO_CFG(88, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "sdc3_clk"},
1389 {GPIO_CFG(89, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_cmd"},
1390 {GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_3"},
1391 {GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_2"},
1392 {GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_1"},
1393 {GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_0"},
1394};
1395
1396static struct msm_gpio sdc4_cfg_data[] = {
1397 {GPIO_CFG(19, 3, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_3"},
1398 {GPIO_CFG(20, 3, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_2"},
1399 {GPIO_CFG(21, 4, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_1"},
1400 {GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_cmd"},
1401 {GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_0"},
1402 {GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "sdc4_clk"},
1403};
1404
1405static struct sdcc_gpio sdcc_cfg_data[] = {
1406 {
1407 .cfg_data = sdc1_cfg_data,
1408 .size = ARRAY_SIZE(sdc1_cfg_data),
1409 .sleep_cfg_data = NULL,
1410 },
1411 {
1412 .cfg_data = sdc2_cfg_data,
1413 .size = ARRAY_SIZE(sdc2_cfg_data),
1414 .sleep_cfg_data = sdc2_sleep_cfg_data,
1415 },
1416 {
1417 .cfg_data = sdc3_cfg_data,
1418 .size = ARRAY_SIZE(sdc3_cfg_data),
1419 .sleep_cfg_data = NULL,
1420 },
1421 {
1422 .cfg_data = sdc4_cfg_data,
1423 .size = ARRAY_SIZE(sdc4_cfg_data),
1424 .sleep_cfg_data = NULL,
1425 },
1426};
1427
1428static void msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
1429{
1430 int rc = 0;
1431 struct sdcc_gpio *curr;
1432
1433 curr = &sdcc_cfg_data[dev_id - 1];
1434 if (!(test_bit(dev_id, &gpio_sts)^enable))
1435 return;
1436
1437 if (enable) {
1438 set_bit(dev_id, &gpio_sts);
1439 rc = msm_gpios_request_enable(curr->cfg_data, curr->size);
1440 if (rc)
1441 printk(KERN_ERR "%s: Failed to turn on GPIOs for slot %d\n",
1442 __func__, dev_id);
1443 } else {
1444 clear_bit(dev_id, &gpio_sts);
1445 if (curr->sleep_cfg_data) {
1446 msm_gpios_enable(curr->sleep_cfg_data, curr->size);
1447 msm_gpios_free(curr->sleep_cfg_data, curr->size);
1448 return;
1449 }
1450 msm_gpios_disable_free(curr->cfg_data, curr->size);
1451 }
1452}
1453
1454static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
1455{
1456 int rc = 0;
1457 struct platform_device *pdev;
1458
1459 pdev = container_of(dv, struct platform_device, dev);
1460 msm_sdcc_setup_gpio(pdev->id, !!vdd);
1461
1462 if (vdd == 0) {
1463 if (!vreg_sts)
1464 return 0;
1465
1466 clear_bit(pdev->id, &vreg_sts);
1467
1468 if (!vreg_sts) {
1469 if (machine_is_msm7x25_ffa() ||
1470 machine_is_msm7x27_ffa()) {
1471 rc = mpp_config_digital_out(mpp_mmc,
1472 MPP_CFG(MPP_DLOGIC_LVL_MSMP,
1473 MPP_DLOGIC_OUT_CTRL_LOW));
1474 } else
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301475 rc = regulator_disable(vreg_mmc);
1476 if (rc) {
1477 pr_err("%s: return val: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001478 __func__, rc);
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301479 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001480 }
1481 return 0;
1482 }
1483
1484 if (!vreg_sts) {
1485 if (machine_is_msm7x25_ffa() || machine_is_msm7x27_ffa()) {
1486 rc = mpp_config_digital_out(mpp_mmc,
1487 MPP_CFG(MPP_DLOGIC_LVL_MSMP,
1488 MPP_DLOGIC_OUT_CTRL_HIGH));
1489 } else {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301490 rc = regulator_set_voltage(vreg_mmc, 2850000, 2850000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001491 if (!rc)
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301492 rc = regulator_enable(vreg_mmc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001493 }
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301494 if (rc) {
1495 pr_err("%s: return val: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001496 __func__, rc);
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301497 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001498 }
1499 set_bit(pdev->id, &vreg_sts);
1500 return 0;
1501}
1502
1503#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
1504static struct mmc_platform_data msm7x2x_sdc1_data = {
1505 .ocr_mask = MMC_VDD_28_29,
1506 .translate_vdd = msm_sdcc_setup_power,
1507 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
1508 .msmsdcc_fmin = 144000,
1509 .msmsdcc_fmid = 24576000,
1510 .msmsdcc_fmax = 49152000,
1511 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001512};
1513#endif
1514
1515#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
1516static struct mmc_platform_data msm7x2x_sdc2_data = {
1517 .ocr_mask = MMC_VDD_28_29,
1518 .translate_vdd = msm_sdcc_setup_power,
1519 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
1520#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
1521 .sdiowakeup_irq = MSM_GPIO_TO_INT(66),
1522#endif
1523 .msmsdcc_fmin = 144000,
1524 .msmsdcc_fmid = 24576000,
1525 .msmsdcc_fmax = 49152000,
1526 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001527};
1528#endif
1529
1530#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
1531static struct mmc_platform_data msm7x2x_sdc3_data = {
1532 .ocr_mask = MMC_VDD_28_29,
1533 .translate_vdd = msm_sdcc_setup_power,
1534 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
1535 .msmsdcc_fmin = 144000,
1536 .msmsdcc_fmid = 24576000,
1537 .msmsdcc_fmax = 49152000,
1538 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001539};
1540#endif
1541
1542#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
1543static struct mmc_platform_data msm7x2x_sdc4_data = {
1544 .ocr_mask = MMC_VDD_28_29,
1545 .translate_vdd = msm_sdcc_setup_power,
1546 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
1547 .msmsdcc_fmin = 144000,
1548 .msmsdcc_fmid = 24576000,
1549 .msmsdcc_fmax = 49152000,
1550 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001551};
1552#endif
1553
1554static void __init msm7x2x_init_mmc(void)
1555{
1556 if (!machine_is_msm7x25_ffa() && !machine_is_msm7x27_ffa()) {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301557 vreg_mmc = regulator_get(NULL, "mmc");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001558 if (IS_ERR(vreg_mmc)) {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301559 pr_err("%s: could not get regulator: %ld\n",
1560 __func__, PTR_ERR(vreg_mmc));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001561 }
1562 }
1563
1564#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
1565 msm_add_sdcc(1, &msm7x2x_sdc1_data);
1566#endif
1567
1568 if (machine_is_msm7x25_surf() || machine_is_msm7x27_surf() ||
1569 machine_is_msm7x27_ffa()) {
1570#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
1571 msm_sdcc_setup_gpio(2, 1);
1572 msm_add_sdcc(2, &msm7x2x_sdc2_data);
1573#endif
1574 }
1575
1576 if (machine_is_msm7x25_surf() || machine_is_msm7x27_surf()) {
1577#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
1578 msm_add_sdcc(3, &msm7x2x_sdc3_data);
1579#endif
1580#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
1581 msm_add_sdcc(4, &msm7x2x_sdc4_data);
1582#endif
1583 }
1584}
1585#else
1586#define msm7x2x_init_mmc() do {} while (0)
1587#endif
1588
1589
1590static struct msm_pm_platform_data msm7x25_pm_data[MSM_PM_SLEEP_MODE_NR] = {
1591 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE].latency = 16000,
1592
1593 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN].latency = 12000,
1594
1595 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency = 2000,
1596};
1597
1598static struct msm_pm_platform_data msm7x27_pm_data[MSM_PM_SLEEP_MODE_NR] = {
1599 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = {
1600 .idle_supported = 1,
1601 .suspend_supported = 1,
1602 .idle_enabled = 1,
1603 .suspend_enabled = 1,
1604 .latency = 16000,
1605 .residency = 20000,
1606 },
1607
1608 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] = {
1609 .idle_supported = 1,
1610 .suspend_supported = 1,
1611 .idle_enabled = 1,
1612 .suspend_enabled = 1,
1613 .latency = 12000,
1614 .residency = 20000,
1615 },
1616
1617 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT] = {
1618 .idle_supported = 1,
1619 .suspend_supported = 1,
1620 .idle_enabled = 1,
1621 .suspend_enabled = 1,
1622 .latency = 2000,
1623 .residency = 0,
1624 },
1625};
1626
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06001627static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
Sravan Kumar Ambapuramb22cf4d2012-01-02 21:45:04 +05301628 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_PHYS,
1629 .p_addr = 0,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06001630};
1631
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001632static void
1633msm_i2c_gpio_config(int iface, int config_type)
1634{
1635 int gpio_scl;
1636 int gpio_sda;
1637 if (iface) {
1638 gpio_scl = 95;
1639 gpio_sda = 96;
1640 } else {
1641 gpio_scl = 60;
1642 gpio_sda = 61;
1643 }
1644 if (config_type) {
1645 gpio_tlmm_config(GPIO_CFG(gpio_scl, 1, GPIO_CFG_INPUT,
1646 GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE);
1647 gpio_tlmm_config(GPIO_CFG(gpio_sda, 1, GPIO_CFG_INPUT,
1648 GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE);
1649 } else {
1650 gpio_tlmm_config(GPIO_CFG(gpio_scl, 0, GPIO_CFG_OUTPUT,
1651 GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE);
1652 gpio_tlmm_config(GPIO_CFG(gpio_sda, 0, GPIO_CFG_OUTPUT,
1653 GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE);
1654 }
1655}
1656
1657static struct msm_i2c_platform_data msm_i2c_pdata = {
1658 .clk_freq = 100000,
1659 .rmutex = 0,
1660 .pri_clk = 60,
1661 .pri_dat = 61,
1662 .aux_clk = 95,
1663 .aux_dat = 96,
1664 .msm_i2c_config_gpio = msm_i2c_gpio_config,
1665};
Pankaj Kumar75c86fd2011-10-01 18:51:09 +05301666static struct platform_device msm_proccomm_regulator_dev = {
1667 .name = PROCCOMM_REGULATOR_DEV_NAME,
1668 .id = -1,
1669 .dev = {
1670 .platform_data = &msm7627_proccomm_regulator_data
1671 }
1672};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001673
Pankaj Kumar75c86fd2011-10-01 18:51:09 +05301674static void __init msm7627_init_regulators(void)
1675{
1676 int rc = platform_device_register(&msm_proccomm_regulator_dev);
1677 if (rc)
1678 pr_err("%s: could not register regulator device: %d\n",
1679 __func__, rc);
1680}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001681static void __init msm_device_i2c_init(void)
1682{
1683 if (gpio_request(60, "i2c_pri_clk"))
1684 pr_err("failed to request gpio i2c_pri_clk\n");
1685 if (gpio_request(61, "i2c_pri_dat"))
1686 pr_err("failed to request gpio i2c_pri_dat\n");
1687 if (gpio_request(95, "i2c_sec_clk"))
1688 pr_err("failed to request gpio i2c_sec_clk\n");
1689 if (gpio_request(96, "i2c_sec_dat"))
1690 pr_err("failed to request gpio i2c_sec_dat\n");
1691
1692 if (cpu_is_msm7x27())
1693 msm_i2c_pdata.pm_lat =
1694 msm7x27_pm_data[MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN]
1695 .latency;
1696 else
1697 msm_i2c_pdata.pm_lat =
1698 msm7x25_pm_data[MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN]
1699 .latency;
1700
1701 msm_device_i2c.dev.platform_data = &msm_i2c_pdata;
1702}
1703
1704static void usb_mpp_init(void)
1705{
1706 unsigned rc;
1707 unsigned mpp_usb = 7;
1708
1709 if (machine_is_msm7x25_ffa() || machine_is_msm7x27_ffa()) {
1710 rc = mpp_config_digital_out(mpp_usb,
1711 MPP_CFG(MPP_DLOGIC_LVL_VDD,
1712 MPP_DLOGIC_OUT_CTRL_HIGH));
1713 if (rc)
1714 pr_err("%s: configuring mpp pin"
1715 "to enable 3.3V LDO failed\n", __func__);
1716 }
1717}
1718
1719static void msm7x27_wlan_init(void)
1720{
1721 int rc = 0;
1722 /* TBD: if (machine_is_msm7x27_ffa_with_wcn1312()) */
1723 if (machine_is_msm7x27_ffa()) {
1724 rc = mpp_config_digital_out(3, MPP_CFG(MPP_DLOGIC_LVL_MSMP,
1725 MPP_DLOGIC_OUT_CTRL_LOW));
1726 if (rc)
1727 printk(KERN_ERR "%s: return val: %d \n",
1728 __func__, rc);
1729 }
1730}
1731
Daniel Walker2682fd32010-02-24 15:47:58 -08001732static void __init msm7x2x_init(void)
1733{
Daniel Walker2682fd32010-02-24 15:47:58 -08001734
Pankaj Kumar75c86fd2011-10-01 18:51:09 +05301735 msm7627_init_regulators();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001736#ifdef CONFIG_ARCH_MSM7X25
1737 msm_clock_init(msm_clocks_7x25, msm_num_clocks_7x25);
1738#elif defined(CONFIG_ARCH_MSM7X27)
Stephen Boydbb600ae2011-08-02 20:11:40 -07001739 msm_clock_init(&msm7x27_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001740#endif
1741
1742#if defined(CONFIG_SMC91X)
Daniel Walker2682fd32010-02-24 15:47:58 -08001743 if (machine_is_msm7x25_ffa() || machine_is_msm7x27_ffa()) {
1744 smc91x_resources[0].start = 0x98000300;
1745 smc91x_resources[0].end = 0x980003ff;
1746 smc91x_resources[1].start = MSM_GPIO_TO_INT(85);
1747 smc91x_resources[1].end = MSM_GPIO_TO_INT(85);
1748 if (gpio_tlmm_config(GPIO_CFG(85, 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001749 GPIO_CFG_INPUT,
1750 GPIO_CFG_PULL_DOWN,
1751 GPIO_CFG_2MA),
1752 GPIO_CFG_ENABLE)) {
Daniel Walker2682fd32010-02-24 15:47:58 -08001753 printk(KERN_ERR
1754 "%s: Err: Config GPIO-85 INT\n",
1755 __func__);
1756 }
1757 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001758#endif
Pankaj Kumar6e66f372011-12-05 14:41:58 +05301759 acpuclk_init(&acpuclk_7x27_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001760
1761 usb_mpp_init();
1762
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001763
1764#ifdef CONFIG_USB_MSM_OTG_72K
1765 msm_device_otg.dev.platform_data = &msm_otg_pdata;
1766 if (machine_is_msm7x25_surf() || machine_is_msm7x25_ffa()) {
1767 msm_otg_pdata.pemp_level =
1768 PRE_EMPHASIS_WITH_20_PERCENT;
1769 msm_otg_pdata.drv_ampl = HS_DRV_AMPLITUDE_5_PERCENT;
1770 msm_otg_pdata.cdr_autoreset = CDR_AUTO_RESET_ENABLE;
1771 msm_otg_pdata.phy_reset = msm_otg_rpc_phy_reset;
1772 }
1773 if (machine_is_msm7x27_surf() || machine_is_msm7x27_ffa()) {
1774 msm_otg_pdata.pemp_level =
1775 PRE_EMPHASIS_WITH_10_PERCENT;
1776 msm_otg_pdata.drv_ampl = HS_DRV_AMPLITUDE_5_PERCENT;
1777 msm_otg_pdata.cdr_autoreset = CDR_AUTO_RESET_DISABLE;
1778 msm_otg_pdata.phy_reset_sig_inverted = 1;
1779 }
1780
1781#ifdef CONFIG_USB_GADGET
1782 msm_otg_pdata.swfi_latency =
1783 msm7x27_pm_data
1784 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
1785 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
1786 msm_gadget_pdata.is_phy_status_timer_on = 1;
1787#endif
1788#endif
1789#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
1790 msm_device_tsif.dev.platform_data = &tsif_platform_data;
1791#endif
1792 platform_add_devices(msm_footswitch_devices,
1793 msm_num_footswitch_devices);
Daniel Walker2682fd32010-02-24 15:47:58 -08001794 platform_add_devices(devices, ARRAY_SIZE(devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001795#ifdef CONFIG_MSM_CAMERA
1796 config_camera_off_gpios(); /* might not be necessary */
1797#endif
1798 msm_device_i2c_init();
1799 i2c_register_board_info(0, i2c_devices, ARRAY_SIZE(i2c_devices));
1800
1801#ifdef CONFIG_SURF_FFA_GPIO_KEYPAD
1802 if (machine_is_msm7x25_ffa() || machine_is_msm7x27_ffa())
1803 platform_device_register(&keypad_device_7k_ffa);
1804 else
1805 platform_device_register(&keypad_device_surf);
1806#endif
1807 lcdc_gordon_gpio_init();
1808 msm_fb_add_devices();
1809#ifdef CONFIG_USB_EHCI_MSM_72K
1810 msm7x2x_init_host();
1811#endif
1812 msm7x2x_init_mmc();
1813 bt_power_init();
1814
1815 if (cpu_is_msm7x27())
1816 msm_pm_set_platform_data(msm7x27_pm_data,
1817 ARRAY_SIZE(msm7x27_pm_data));
1818 else
1819 msm_pm_set_platform_data(msm7x25_pm_data,
1820 ARRAY_SIZE(msm7x25_pm_data));
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -06001821
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06001822 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
1823
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001824 msm7x27_wlan_init();
1825}
1826
1827static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE;
1828static int __init pmem_kernel_ebi1_size_setup(char *p)
1829{
1830 pmem_kernel_ebi1_size = memparse(p, NULL);
1831 return 0;
1832}
1833early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
1834
1835static unsigned pmem_mdp_size = MSM_PMEM_MDP_SIZE;
1836static int __init pmem_mdp_size_setup(char *p)
1837{
1838 pmem_mdp_size = memparse(p, NULL);
1839 return 0;
1840}
1841early_param("pmem_mdp_size", pmem_mdp_size_setup);
1842
1843static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
1844static int __init pmem_adsp_size_setup(char *p)
1845{
1846 pmem_adsp_size = memparse(p, NULL);
1847 return 0;
1848}
1849early_param("pmem_adsp_size", pmem_adsp_size_setup);
1850
1851static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
1852static int __init pmem_audio_size_setup(char *p)
1853{
1854 pmem_audio_size = memparse(p, NULL);
1855 return 0;
1856}
1857early_param("pmem_audio_size", pmem_audio_size_setup);
1858
1859static unsigned fb_size = MSM_FB_SIZE;
1860static int __init fb_size_setup(char *p)
1861{
1862 fb_size = memparse(p, NULL);
1863 return 0;
1864}
1865early_param("fb_size", fb_size_setup);
1866
1867static void __init msm_msm7x2x_allocate_memory_regions(void)
1868{
1869 void *addr;
1870 unsigned long size;
1871
1872 size = fb_size ? : MSM_FB_SIZE;
1873 addr = alloc_bootmem_align(size, 0x1000);
1874 msm_fb_resources[0].start = __pa(addr);
1875 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
1876 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
1877 size, addr, __pa(addr));
1878}
1879
1880static struct memtype_reserve msm7x27_reserve_table[] __initdata = {
1881 [MEMTYPE_SMI] = {
1882 },
1883 [MEMTYPE_EBI0] = {
1884 .flags = MEMTYPE_FLAGS_1M_ALIGN,
1885 },
1886 [MEMTYPE_EBI1] = {
1887 .flags = MEMTYPE_FLAGS_1M_ALIGN,
1888 },
1889};
1890
1891static void __init size_pmem_devices(void)
1892{
1893#ifdef CONFIG_ANDROID_PMEM
1894 android_pmem_adsp_pdata.size = pmem_adsp_size;
1895 android_pmem_pdata.size = pmem_mdp_size;
1896 android_pmem_audio_pdata.size = pmem_audio_size;
1897#endif
1898}
1899
1900static void __init reserve_memory_for(struct android_pmem_platform_data *p)
1901{
1902 msm7x27_reserve_table[p->memory_type].size += p->size;
1903}
1904
1905static void __init reserve_pmem_memory(void)
1906{
1907#ifdef CONFIG_ANDROID_PMEM
1908 reserve_memory_for(&android_pmem_adsp_pdata);
1909 reserve_memory_for(&android_pmem_pdata);
1910 reserve_memory_for(&android_pmem_audio_pdata);
1911 msm7x27_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
1912#endif
1913}
1914
1915static void __init msm7x27_calculate_reserve_sizes(void)
1916{
1917 size_pmem_devices();
1918 reserve_pmem_memory();
1919}
1920
1921static int msm7x27_paddr_to_memtype(unsigned int paddr)
1922{
1923 return MEMTYPE_EBI1;
1924}
1925
1926static struct reserve_info msm7x27_reserve_info __initdata = {
1927 .memtype_reserve_table = msm7x27_reserve_table,
1928 .calculate_reserve_sizes = msm7x27_calculate_reserve_sizes,
1929 .paddr_to_memtype = msm7x27_paddr_to_memtype,
1930};
1931
1932static void __init msm7x27_reserve(void)
1933{
1934 reserve_info = &msm7x27_reserve_info;
1935 msm_reserve();
1936}
1937
1938static void __init msm7x27_init_early(void)
1939{
1940 msm_msm7x2x_allocate_memory_regions();
Daniel Walker2682fd32010-02-24 15:47:58 -08001941}
1942
1943static void __init msm7x2x_map_io(void)
1944{
1945 msm_map_common_io();
Daniel Walker2682fd32010-02-24 15:47:58 -08001946
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001947 if (socinfo_init() < 0)
1948 BUG();
Daniel Walker2682fd32010-02-24 15:47:58 -08001949
1950#ifdef CONFIG_CACHE_L2X0
1951 if (machine_is_msm7x27_surf() || machine_is_msm7x27_ffa()) {
1952 /* 7x27 has 256KB L2 cache:
1953 64Kb/Way and 4-Way Associativity;
Daniel Walker2682fd32010-02-24 15:47:58 -08001954 evmon/parity/share disabled. */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001955 if ((SOCINFO_VERSION_MAJOR(socinfo_get_version()) > 1)
1956 || ((SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 1)
1957 && (SOCINFO_VERSION_MINOR(socinfo_get_version()) >= 3)))
1958 /* R/W latency: 4 cycles; */
1959 l2x0_init(MSM_L2CC_BASE, 0x0006801B, 0xfe000000);
1960 else
1961 /* R/W latency: 3 cycles; */
1962 l2x0_init(MSM_L2CC_BASE, 0x00068012, 0xfe000000);
Daniel Walker2682fd32010-02-24 15:47:58 -08001963 }
1964#endif
1965}
1966
1967MACHINE_START(MSM7X27_SURF, "QCT MSM7x27 SURF")
Russell Kingb75c1782011-01-04 19:03:16 +00001968 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker2682fd32010-02-24 15:47:58 -08001969 .map_io = msm7x2x_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001970 .reserve = msm7x27_reserve,
Daniel Walker2682fd32010-02-24 15:47:58 -08001971 .init_irq = msm7x2x_init_irq,
1972 .init_machine = msm7x2x_init,
1973 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001974 .init_early = msm7x27_init_early,
Taniya Dasbe561a02011-10-12 09:53:11 +05301975 .handle_irq = vic_handle_irq,
Daniel Walker2682fd32010-02-24 15:47:58 -08001976MACHINE_END
1977
1978MACHINE_START(MSM7X27_FFA, "QCT MSM7x27 FFA")
Russell Kingb75c1782011-01-04 19:03:16 +00001979 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker2682fd32010-02-24 15:47:58 -08001980 .map_io = msm7x2x_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001981 .reserve = msm7x27_reserve,
Daniel Walker2682fd32010-02-24 15:47:58 -08001982 .init_irq = msm7x2x_init_irq,
1983 .init_machine = msm7x2x_init,
1984 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001985 .init_early = msm7x27_init_early,
Taniya Dasbe561a02011-10-12 09:53:11 +05301986 .handle_irq = vic_handle_irq,
Daniel Walker2682fd32010-02-24 15:47:58 -08001987MACHINE_END
1988
1989MACHINE_START(MSM7X25_SURF, "QCT MSM7x25 SURF")
Russell Kingb75c1782011-01-04 19:03:16 +00001990 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker2682fd32010-02-24 15:47:58 -08001991 .map_io = msm7x2x_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001992 .reserve = msm7x27_reserve,
Daniel Walker2682fd32010-02-24 15:47:58 -08001993 .init_irq = msm7x2x_init_irq,
1994 .init_machine = msm7x2x_init,
1995 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001996 .init_early = msm7x27_init_early,
Taniya Dasbe561a02011-10-12 09:53:11 +05301997 .handle_irq = vic_handle_irq,
Daniel Walker2682fd32010-02-24 15:47:58 -08001998MACHINE_END
1999
2000MACHINE_START(MSM7X25_FFA, "QCT MSM7x25 FFA")
Russell Kingb75c1782011-01-04 19:03:16 +00002001 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker2682fd32010-02-24 15:47:58 -08002002 .map_io = msm7x2x_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002003 .reserve = msm7x27_reserve,
Daniel Walker2682fd32010-02-24 15:47:58 -08002004 .init_irq = msm7x2x_init_irq,
2005 .init_machine = msm7x2x_init,
2006 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002007 .init_early = msm7x27_init_early,
Taniya Dasbe561a02011-10-12 09:53:11 +05302008 .handle_irq = vic_handle_irq,
Daniel Walker2682fd32010-02-24 15:47:58 -08002009MACHINE_END