blob: a09485ac7591b2064512b757e5daa34a4c207be8 [file] [log] [blame]
Daniel Walker2682fd32010-02-24 15:47:58 -08001/*
2 * Copyright (C) 2007 Google, Inc.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003 * Copyright (c) 2008-2011, 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"
71#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,
245 .pclk_src_name = "ebi1_usb_clk",
246};
247
248#ifdef CONFIG_USB_GADGET
249static struct msm_hsusb_gadget_platform_data msm_gadget_pdata;
250#endif
251#endif
252
253#define SND(desc, num) { .name = #desc, .id = num }
254static struct snd_endpoint snd_endpoints_list[] = {
255 SND(HANDSET, 0),
256 SND(MONO_HEADSET, 2),
257 SND(HEADSET, 3),
258 SND(SPEAKER, 6),
259 SND(TTY_HEADSET, 8),
260 SND(TTY_VCO, 9),
261 SND(TTY_HCO, 10),
262 SND(BT, 12),
263 SND(IN_S_SADC_OUT_HANDSET, 16),
264 SND(IN_S_SADC_OUT_SPEAKER_PHONE, 25),
265 SND(CURRENT, 27),
266};
267#undef SND
268
269static struct msm_snd_endpoints msm_device_snd_endpoints = {
270 .endpoints = snd_endpoints_list,
271 .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint)
272};
273
274static struct platform_device msm_device_snd = {
275 .name = "msm_snd",
276 .id = -1,
277 .dev = {
278 .platform_data = &msm_device_snd_endpoints
279 },
280};
281
282#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
283 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
284 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
285 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
286 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
287 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
288#ifdef CONFIG_ARCH_MSM7X25
289#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_WAV)|(1<<MSM_ADSP_CODEC_ADPCM)| \
290 (1<<MSM_ADSP_CODEC_YADPCM)|(1<<MSM_ADSP_CODEC_QCELP)| \
291 (1<<MSM_ADSP_CODEC_MP3))
292#define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_WAV)|(1<<MSM_ADSP_CODEC_ADPCM)| \
293 (1<<MSM_ADSP_CODEC_YADPCM)|(1<<MSM_ADSP_CODEC_QCELP)| \
294 (1<<MSM_ADSP_CODEC_MP3))
295#define DEC3_FORMAT 0
296#define DEC4_FORMAT 0
297#else
298#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
299 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
300 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
301 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
302 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
303 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
304#define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
305 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
306 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
307 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
308 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
309 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
310#define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
311 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
312 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
313 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
314 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
315 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
316#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
317#endif
318
319static unsigned int dec_concurrency_table[] = {
320 /* Audio LP */
321 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DMA)), 0,
322 0, 0, 0,
323
324 /* Concurrency 1 */
325 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
326 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
327 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
328 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
329 (DEC4_FORMAT),
330
331 /* Concurrency 2 */
332 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
333 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
334 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
335 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
336 (DEC4_FORMAT),
337
338 /* Concurrency 3 */
339 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
340 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
341 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
342 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
343 (DEC4_FORMAT),
344
345 /* Concurrency 4 */
346 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
347 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
348 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
349 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
350 (DEC4_FORMAT),
351
352 /* Concurrency 5 */
353 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
354 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
355 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
356 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
357 (DEC4_FORMAT),
358
359 /* Concurrency 6 */
360 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
361 0, 0, 0, 0,
362
363 /* Concurrency 7 */
364 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
365 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
366 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
367 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
368 (DEC4_FORMAT),
369};
370
371#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
372 .module_queueid = queueid, .module_decid = decid, \
373 .nr_codec_support = nr_codec}
374
375static struct msm_adspdec_info dec_info_list[] = {
376 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
377#ifdef CONFIG_ARCH_MSM7X25
378 DEC_INFO("AUDPLAY1TASK", 14, 1, 5), /* AudPlay1BitStreamCtrlQueue */
379 DEC_INFO("AUDPLAY2TASK", 15, 2, 5), /* AudPlay2BitStreamCtrlQueue */
380 DEC_INFO("AUDPLAY3TASK", 16, 3, 0), /* AudPlay3BitStreamCtrlQueue */
381 DEC_INFO("AUDPLAY4TASK", 17, 4, 0), /* AudPlay4BitStreamCtrlQueue */
382#else
383 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
384 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
385 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
386 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
387#endif
388};
389
390static struct msm_adspdec_database msm_device_adspdec_database = {
391 .num_dec = ARRAY_SIZE(dec_info_list),
392 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
393 ARRAY_SIZE(dec_info_list)),
394 .dec_concurrency_table = dec_concurrency_table,
395 .dec_info_list = dec_info_list,
396};
397
398static struct platform_device msm_device_adspdec = {
399 .name = "msm_adspdec",
400 .id = -1,
401 .dev = {
402 .platform_data = &msm_device_adspdec_database
403 },
404};
405
406static struct android_pmem_platform_data android_pmem_pdata = {
407 .name = "pmem",
408 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
409 .cached = 1,
410 .memory_type = MEMTYPE_EBI1,
411};
412
413static struct android_pmem_platform_data android_pmem_adsp_pdata = {
414 .name = "pmem_adsp",
415 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
416 .cached = 0,
417 .memory_type = MEMTYPE_EBI1,
418};
419
420static struct android_pmem_platform_data android_pmem_audio_pdata = {
421 .name = "pmem_audio",
422 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
423 .cached = 0,
424 .memory_type = MEMTYPE_EBI1,
425};
426
427static struct platform_device android_pmem_device = {
428 .name = "android_pmem",
429 .id = 0,
430 .dev = { .platform_data = &android_pmem_pdata },
431};
432
433static struct platform_device android_pmem_adsp_device = {
434 .name = "android_pmem",
435 .id = 1,
436 .dev = { .platform_data = &android_pmem_adsp_pdata },
437};
438
439static struct platform_device android_pmem_audio_device = {
440 .name = "android_pmem",
441 .id = 2,
442 .dev = { .platform_data = &android_pmem_audio_pdata },
443};
444
445static struct msm_handset_platform_data hs_platform_data = {
446 .hs_name = "7k_handset",
447 .pwr_key_delay_ms = 500, /* 0 will disable end key */
448};
449
450static struct platform_device hs_device = {
451 .name = "msm-handset",
452 .id = -1,
453 .dev = {
454 .platform_data = &hs_platform_data,
455 },
456};
457
458/* TSIF begin */
459#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
460
461#define TSIF_B_SYNC GPIO_CFG(87, 5, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
462#define TSIF_B_DATA GPIO_CFG(86, 3, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
463#define TSIF_B_EN GPIO_CFG(85, 3, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
464#define TSIF_B_CLK GPIO_CFG(84, 4, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
465
466static const struct msm_gpio tsif_gpios[] = {
467 { .gpio_cfg = TSIF_B_CLK, .label = "tsif_clk", },
468 { .gpio_cfg = TSIF_B_EN, .label = "tsif_en", },
469 { .gpio_cfg = TSIF_B_DATA, .label = "tsif_data", },
470 { .gpio_cfg = TSIF_B_SYNC, .label = "tsif_sync", },
471};
472
473static struct msm_tsif_platform_data tsif_platform_data = {
474 .num_gpios = ARRAY_SIZE(tsif_gpios),
475 .gpios = tsif_gpios,
Matt Wagantall640e5fd2011-08-17 16:08:53 -0700476 .tsif_clk = "core_clk",
477 .tsif_pclk = "iface_clk",
478 .tsif_ref_clk = "ref_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700479};
480#endif /* defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) */
481/* TSIF end */
482
483#define LCDC_CONFIG_PROC 21
484#define LCDC_UN_CONFIG_PROC 22
485#define LCDC_API_PROG 0x30000066
486#define LCDC_API_VERS 0x00010001
487
488#define GPIO_OUT_132 132
489#define GPIO_OUT_131 131
490#define GPIO_OUT_103 103
491#define GPIO_OUT_102 102
492#define GPIO_OUT_88 88
493
494static struct msm_rpc_endpoint *lcdc_ep;
495
496static int msm_fb_lcdc_config(int on)
497{
498 int rc = 0;
499 struct rpc_request_hdr hdr;
500
501 if (on)
502 pr_info("lcdc config\n");
503 else
504 pr_info("lcdc un-config\n");
505
506 lcdc_ep = msm_rpc_connect_compatible(LCDC_API_PROG, LCDC_API_VERS, 0);
507 if (IS_ERR(lcdc_ep)) {
508 printk(KERN_ERR "%s: msm_rpc_connect failed! rc = %ld\n",
509 __func__, PTR_ERR(lcdc_ep));
510 return -EINVAL;
511 }
512
513 rc = msm_rpc_call(lcdc_ep,
514 (on) ? LCDC_CONFIG_PROC : LCDC_UN_CONFIG_PROC,
515 &hdr, sizeof(hdr),
516 5 * HZ);
517 if (rc)
518 printk(KERN_ERR
519 "%s: msm_rpc_call failed! rc = %d\n", __func__, rc);
520
521 msm_rpc_close(lcdc_ep);
522 return rc;
523}
524
525static int gpio_array_num[] = {
526 GPIO_OUT_132, /* spi_clk */
527 GPIO_OUT_131, /* spi_cs */
528 GPIO_OUT_103, /* spi_sdi */
529 GPIO_OUT_102, /* spi_sdoi */
530 GPIO_OUT_88
531 };
532
533static void lcdc_gordon_gpio_init(void)
534{
535 if (gpio_request(GPIO_OUT_132, "spi_clk"))
536 pr_err("failed to request gpio spi_clk\n");
537 if (gpio_request(GPIO_OUT_131, "spi_cs"))
538 pr_err("failed to request gpio spi_cs\n");
539 if (gpio_request(GPIO_OUT_103, "spi_sdi"))
540 pr_err("failed to request gpio spi_sdi\n");
541 if (gpio_request(GPIO_OUT_102, "spi_sdoi"))
542 pr_err("failed to request gpio spi_sdoi\n");
543 if (gpio_request(GPIO_OUT_88, "gpio_dac"))
544 pr_err("failed to request gpio_dac\n");
545}
546
547static uint32_t lcdc_gpio_table[] = {
548 GPIO_CFG(GPIO_OUT_132, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
549 GPIO_CFG(GPIO_OUT_131, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
550 GPIO_CFG(GPIO_OUT_103, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
551 GPIO_CFG(GPIO_OUT_102, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
552 GPIO_CFG(GPIO_OUT_88, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
553};
554
555static void config_lcdc_gpio_table(uint32_t *table, int len, unsigned enable)
556{
557 int n, rc;
558 for (n = 0; n < len; n++) {
559 rc = gpio_tlmm_config(table[n],
560 enable ? GPIO_CFG_ENABLE : GPIO_CFG_DISABLE);
561 if (rc) {
562 printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n",
563 __func__, table[n], rc);
564 break;
565 }
566 }
567}
568
569static void lcdc_gordon_config_gpios(int enable)
570{
571 config_lcdc_gpio_table(lcdc_gpio_table,
572 ARRAY_SIZE(lcdc_gpio_table), enable);
573}
574
575static char *msm_fb_lcdc_vreg[] = {
576 "gp5"
577};
578
579static int msm_fb_lcdc_power_save(int on)
580{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700581 int i, rc = 0;
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530582 static struct regulator *vreg[ARRAY_SIZE(msm_fb_lcdc_vreg)];
583
584 if (on) {
585 for (i = 0; i < ARRAY_SIZE(msm_fb_lcdc_vreg); i++) {
586 vreg[i] = regulator_get(NULL, msm_fb_lcdc_vreg[i]);
587 if (IS_ERR(vreg[i])) {
588 rc = PTR_ERR(vreg[i]);
589 pr_err("%s: could get not regulator: %d\n",
590 __func__, rc);
591 goto reg_get_fail;
592 }
593
594 rc = regulator_set_voltage(vreg[i], 2850000, 3000000);
595 if (rc < 0) {
596 pr_err("%s: could not set voltage: %d\n",
597 __func__, rc);
598 goto reg_get_fail;
599 }
600 }
601 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700602
603 for (i = 0; i < ARRAY_SIZE(msm_fb_lcdc_vreg); i++) {
604 if (on) {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530605 rc = regulator_enable(vreg[i]);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700606 if (rc) {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530607 pr_err("%s: could not enable regulator %s:"
608 "%d\n", __func__,
609 msm_fb_lcdc_vreg[i], rc);
610 goto vreg_lcdc_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700611 }
612 } else {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530613 rc = regulator_disable(vreg[i]);
614 if (rc) {
615 pr_err("%s: could not disable regulator %s:"
616 "%d\n", __func__,
617 msm_fb_lcdc_vreg[i], rc);
618
619 regulator_put(vreg[i]);
620 goto vreg_lcdc_fail;
621
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700622 }
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530623
624 regulator_put(vreg[i]);
625 rc = gpio_tlmm_config(GPIO_CFG(GPIO_OUT_88, 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700626 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
627 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530628 if (rc)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700629 printk(KERN_ERR "gpio_tlmm_config failed\n");
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530630
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700631 gpio_set_value(88, 0);
632 mdelay(15);
633 gpio_set_value(88, 1);
634 mdelay(15);
635 }
636 }
637
638 return rc;
639
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530640reg_get_fail:
641 for (; i > 0; i--)
642 regulator_put(vreg[i - 1]);
643 return rc;
644
645vreg_lcdc_fail:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700646 if (on) {
647 for (; i > 0; i--)
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530648 regulator_disable(vreg[i - 1]);
649 } else {
650 for (; i > 0; i--)
651 regulator_enable(vreg[i - 1]);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700652 }
653
654 return rc;
655}
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530656
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700657static struct lcdc_platform_data lcdc_pdata = {
658 .lcdc_gpio_config = msm_fb_lcdc_config,
659 .lcdc_power_save = msm_fb_lcdc_power_save,
660};
661
662static struct msm_panel_common_pdata lcdc_gordon_panel_data = {
663 .panel_config_gpio = lcdc_gordon_config_gpios,
664 .gpio_num = gpio_array_num,
665};
666
667static struct platform_device lcdc_gordon_panel_device = {
668 .name = "lcdc_gordon_vga",
669 .id = 0,
670 .dev = {
671 .platform_data = &lcdc_gordon_panel_data,
672 }
673};
674
675static struct resource msm_fb_resources[] = {
676 {
677 .flags = IORESOURCE_DMA,
678 }
679};
680
681static int msm_fb_detect_panel(const char *name)
682{
683 int ret = -EPERM;
684
685 if (machine_is_msm7x25_ffa() || machine_is_msm7x27_ffa()) {
686 if (!strcmp(name, "lcdc_gordon_vga"))
687 ret = 0;
688 else
689 ret = -ENODEV;
690 }
691
692 return ret;
693}
694
695static struct msm_fb_platform_data msm_fb_pdata = {
696 .detect_client = msm_fb_detect_panel,
697 .mddi_prescan = 1,
698};
699
700static struct platform_device msm_fb_device = {
701 .name = "msm_fb",
702 .id = 0,
703 .num_resources = ARRAY_SIZE(msm_fb_resources),
704 .resource = msm_fb_resources,
705 .dev = {
706 .platform_data = &msm_fb_pdata,
707 }
708};
709
710#ifdef CONFIG_BT
711static struct platform_device msm_bt_power_device = {
712 .name = "bt_power",
713};
714
715enum {
716 BT_WAKE,
717 BT_RFR,
718 BT_CTS,
719 BT_RX,
720 BT_TX,
721 BT_PCM_DOUT,
722 BT_PCM_DIN,
723 BT_PCM_SYNC,
724 BT_PCM_CLK,
725 BT_HOST_WAKE,
726};
727
728static unsigned bt_config_power_on[] = {
729 GPIO_CFG(42, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* WAKE */
730 GPIO_CFG(43, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* RFR */
731 GPIO_CFG(44, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* CTS */
732 GPIO_CFG(45, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* Rx */
733 GPIO_CFG(46, 3, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* Tx */
734 GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DOUT */
735 GPIO_CFG(69, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DIN */
736 GPIO_CFG(70, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_SYNC */
737 GPIO_CFG(71, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_CLK */
738 GPIO_CFG(83, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* HOST_WAKE */
739};
740static unsigned bt_config_power_off[] = {
741 GPIO_CFG(42, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* WAKE */
742 GPIO_CFG(43, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* RFR */
743 GPIO_CFG(44, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* CTS */
744 GPIO_CFG(45, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* Rx */
745 GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* Tx */
746 GPIO_CFG(68, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCM_DOUT */
747 GPIO_CFG(69, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCM_DIN */
748 GPIO_CFG(70, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCM_SYNC */
749 GPIO_CFG(71, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCM_CLK */
750 GPIO_CFG(83, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HOST_WAKE */
751};
752
753static int bluetooth_power(int on)
754{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700755 int pin, rc;
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530756 static struct regulator *vreg_bt;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700757
758 printk(KERN_DEBUG "%s\n", __func__);
759
760 /* do not have vreg bt defined, gp6 is the same */
761 /* vreg_get parameter 1 (struct device *) is ignored */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700762
763 if (on) {
764 for (pin = 0; pin < ARRAY_SIZE(bt_config_power_on); pin++) {
765 rc = gpio_tlmm_config(bt_config_power_on[pin],
766 GPIO_CFG_ENABLE);
767 if (rc) {
768 printk(KERN_ERR
769 "%s: gpio_tlmm_config(%#x)=%d\n",
770 __func__, bt_config_power_on[pin], rc);
771 return -EIO;
772 }
773 }
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530774 vreg_bt = regulator_get(NULL, "gp6");
775
776 if (IS_ERR(vreg_bt)) {
777 rc = PTR_ERR(vreg_bt);
778 pr_err("%s: could get not regulator: %d\n",
779 __func__, rc);
780 goto out;
781 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700782
783 /* units of mV, steps of 50 mV */
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530784 rc = regulator_set_voltage(vreg_bt, 2600000, 2600000);
785 if (rc < 0) {
786 pr_err("%s: could not set voltage: %d\n", __func__, rc);
787 goto bt_vreg_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700788 }
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530789 rc = regulator_enable(vreg_bt);
790 if (rc < 0) {
791 pr_err("%s: could not enable regulator: %d\n",
792 __func__, rc);
793 goto bt_vreg_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700794 }
795 } else {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530796 rc = regulator_disable(vreg_bt);
797 if (rc < 0) {
798 pr_err("%s: could not disable regulator: %d\n",
799 __func__, rc);
800 goto bt_vreg_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700801 }
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530802 regulator_put(vreg_bt);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700803 for (pin = 0; pin < ARRAY_SIZE(bt_config_power_off); pin++) {
804 rc = gpio_tlmm_config(bt_config_power_off[pin],
805 GPIO_CFG_ENABLE);
806 if (rc) {
807 printk(KERN_ERR
808 "%s: gpio_tlmm_config(%#x)=%d\n",
809 __func__, bt_config_power_off[pin], rc);
810 return -EIO;
811 }
812 }
813 }
814 return 0;
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530815
816bt_vreg_fail:
817 regulator_put(vreg_bt);
818out:
819 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700820}
821
822static void __init bt_power_init(void)
823{
824 msm_bt_power_device.dev.platform_data = &bluetooth_power;
825}
826#else
827#define bt_power_init(x) do {} while (0)
828#endif
829
830static struct platform_device msm_device_pmic_leds = {
831 .name = "pmic-leds",
832 .id = -1,
833};
834
835static struct resource bluesleep_resources[] = {
836 {
837 .name = "gpio_host_wake",
838 .start = 83,
839 .end = 83,
840 .flags = IORESOURCE_IO,
841 },
842 {
843 .name = "gpio_ext_wake",
844 .start = 42,
845 .end = 42,
846 .flags = IORESOURCE_IO,
847 },
848 {
849 .name = "host_wake",
850 .start = MSM_GPIO_TO_INT(83),
851 .end = MSM_GPIO_TO_INT(83),
852 .flags = IORESOURCE_IRQ,
853 },
854};
855
856static struct platform_device msm_bluesleep_device = {
857 .name = "bluesleep",
858 .id = -1,
859 .num_resources = ARRAY_SIZE(bluesleep_resources),
860 .resource = bluesleep_resources,
861};
862
863static struct i2c_board_info i2c_devices[] = {
864#ifdef CONFIG_MT9D112
865 {
866 I2C_BOARD_INFO("mt9d112", 0x78 >> 1),
867 },
868#endif
869#ifdef CONFIG_S5K3E2FX
870 {
871 I2C_BOARD_INFO("s5k3e2fx", 0x20 >> 1),
872 },
873#endif
874#ifdef CONFIG_MT9P012
875 {
876 I2C_BOARD_INFO("mt9p012", 0x6C >> 1),
877 },
878#endif
879#ifdef CONFIG_MT9P012_KM
880 {
881 I2C_BOARD_INFO("mt9p012_km", 0x6C >> 2),
882 },
883#endif
884#if defined(CONFIG_MT9T013) || defined(CONFIG_SENSORS_MT9T013)
885 {
886 I2C_BOARD_INFO("mt9t013", 0x6C),
887 },
888#endif
889#ifdef CONFIG_VB6801
890 {
891 I2C_BOARD_INFO("vb6801", 0x20),
892 },
893#endif
894};
895
896#ifdef CONFIG_MSM_CAMERA
897static uint32_t camera_off_gpio_table[] = {
898 /* parallel CAMERA interfaces */
899 GPIO_CFG(0, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT0 */
900 GPIO_CFG(1, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT1 */
901 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */
902 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */
903 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */
904 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */
905 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */
906 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */
907 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */
908 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */
909 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */
910 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */
911 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCLK */
912 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */
913 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */
914 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* MCLK */
915};
916
917static uint32_t camera_on_gpio_table[] = {
918 /* parallel CAMERA interfaces */
919 GPIO_CFG(0, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT0 */
920 GPIO_CFG(1, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT1 */
921 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */
922 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */
923 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */
924 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */
925 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */
926 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */
927 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */
928 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */
929 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */
930 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */
931 GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_16MA), /* PCLK */
932 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */
933 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */
934 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_16MA), /* MCLK */
935 };
936
937static void config_gpio_table(uint32_t *table, int len)
938{
939 int n, rc;
940 for (n = 0; n < len; n++) {
941 rc = gpio_tlmm_config(table[n], GPIO_CFG_ENABLE);
942 if (rc) {
943 printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n",
944 __func__, table[n], rc);
945 break;
946 }
947 }
948}
949
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700950static void msm_camera_vreg_config(int vreg_en)
951{
952 int rc;
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530953 static struct regulator *vreg_gp2;
954 static struct regulator *vreg_gp3;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700955
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530956 if (vreg_gp2 == NULL && vreg_gp3 == NULL) {
957 vreg_gp2 = regulator_get(NULL, "gp2");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700958 if (IS_ERR(vreg_gp2)) {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530959 rc = PTR_ERR(vreg_gp2);
960 pr_err("%s: could not get regulator: %d\n",
961 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700962 return;
963 }
964
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530965 rc = regulator_set_voltage(vreg_gp2, 1800000, 1800000);
966 if (rc < 0) {
967 pr_err("%s: could not set voltage: %d\n",
968 __func__, rc);
969 goto cam_vreg_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700970 }
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530971
972 vreg_gp3 = regulator_get(NULL, "gp3");
973 if (IS_ERR(vreg_gp3)) {
974 rc = PTR_ERR(vreg_gp3);
975 pr_err("%s: could not get regulator: %d\n",
976 __func__, rc);
977 goto cam_vreg_fail;
978 }
979
980 rc = regulator_set_voltage(vreg_gp3, 2850000, 2850000);
981 if (rc < 0) {
982 pr_err("%s: could not set voltage: %d\n", __func__, rc);
983 goto cam_vreg2_fail;
984 }
985
986 return;
987
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700988 }
989
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530990 if (vreg_gp2 == NULL || vreg_gp3 == NULL) {
991 pr_err("Camera Regulators are not initialized\n");
992 return;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700993 }
994
995 if (vreg_en) {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530996 rc = regulator_enable(vreg_gp2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700997 if (rc) {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +0530998 pr_err("%s: could not enable regulator: %d\n",
999 __func__, rc);
1000 goto cam_vreg2_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001001 }
1002
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301003 rc = regulator_enable(vreg_gp3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001004 if (rc) {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301005 pr_err("%s: could not enable regulator: %d\n",
1006 __func__, rc);
1007 goto vreg_gp3_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001008 }
1009 } else {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301010 rc = regulator_disable(vreg_gp2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001011 if (rc) {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301012 pr_err("%s: could not disable regulator: %d\n",
1013 __func__, rc);
1014 return;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001015 }
1016
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301017 rc = regulator_disable(vreg_gp3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001018 if (rc) {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301019 pr_err("%s: could not disable regulator: %d\n",
1020 __func__, rc);
1021 goto cam_vreg2_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001022 }
1023 }
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301024
1025 return;
1026
1027vreg_gp3_fail:
1028 if (vreg_en)
1029 regulator_disable(vreg_gp2);
1030
1031cam_vreg2_fail:
1032 regulator_put(vreg_gp3);
1033cam_vreg_fail:
1034 regulator_put(vreg_gp2);
1035 vreg_gp3 = NULL;
1036 vreg_gp2 = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001037}
1038
1039static int config_camera_on_gpios(void)
1040{
1041 int vreg_en = 1;
1042
1043 if (machine_is_msm7x25_ffa() ||
1044 machine_is_msm7x27_ffa())
1045 msm_camera_vreg_config(vreg_en);
1046
1047 config_gpio_table(camera_on_gpio_table,
1048 ARRAY_SIZE(camera_on_gpio_table));
1049 return 0;
1050}
1051
1052static void config_camera_off_gpios(void)
1053{
1054 int vreg_en = 0;
1055
1056 if (machine_is_msm7x25_ffa() ||
1057 machine_is_msm7x27_ffa())
1058 msm_camera_vreg_config(vreg_en);
1059
1060 config_gpio_table(camera_off_gpio_table,
1061 ARRAY_SIZE(camera_off_gpio_table));
1062}
1063
1064static struct msm_camera_device_platform_data msm_camera_device_data = {
1065 .camera_gpio_on = config_camera_on_gpios,
1066 .camera_gpio_off = config_camera_off_gpios,
1067 .ioext.mdcphy = MSM_MDC_PHYS,
1068 .ioext.mdcsz = MSM_MDC_SIZE,
1069 .ioext.appphy = MSM_CLK_CTL_PHYS,
1070 .ioext.appsz = MSM_CLK_CTL_SIZE,
1071};
1072
1073int pmic_set_flash_led_current(enum pmic8058_leds id, unsigned mA)
1074{
1075 int rc;
1076 rc = pmic_flash_led_set_current(mA);
1077 return rc;
1078}
1079
1080static struct msm_camera_sensor_flash_src msm_flash_src = {
1081 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PMIC,
1082 ._fsrc.pmic_src.num_of_src = 1,
1083 ._fsrc.pmic_src.low_current = 30,
1084 ._fsrc.pmic_src.high_current = 100,
1085 ._fsrc.pmic_src.led_src_1 = 0,
1086 ._fsrc.pmic_src.led_src_2 = 0,
1087 ._fsrc.pmic_src.pmic_set_current = pmic_set_flash_led_current,
1088};
1089
1090#ifdef CONFIG_MT9D112
1091static struct msm_camera_sensor_flash_data flash_mt9d112 = {
1092 .flash_type = MSM_CAMERA_FLASH_LED,
1093 .flash_src = &msm_flash_src
1094};
1095
1096static struct msm_camera_sensor_info msm_camera_sensor_mt9d112_data = {
1097 .sensor_name = "mt9d112",
1098 .sensor_reset = 89,
1099 .sensor_pwd = 85,
1100 .vcm_pwd = 0,
1101 .vcm_enable = 0,
1102 .pdata = &msm_camera_device_data,
1103 .flash_data = &flash_mt9d112
1104};
1105
1106static struct platform_device msm_camera_sensor_mt9d112 = {
1107 .name = "msm_camera_mt9d112",
1108 .dev = {
1109 .platform_data = &msm_camera_sensor_mt9d112_data,
1110 },
1111};
1112#endif
1113
1114#ifdef CONFIG_S5K3E2FX
1115static struct msm_camera_sensor_flash_data flash_s5k3e2fx = {
1116 .flash_type = MSM_CAMERA_FLASH_LED,
1117 .flash_src = &msm_flash_src
1118};
1119
1120static struct msm_camera_sensor_info msm_camera_sensor_s5k3e2fx_data = {
1121 .sensor_name = "s5k3e2fx",
1122 .sensor_reset = 89,
1123 .sensor_pwd = 85,
1124 .vcm_pwd = 0,
1125 .vcm_enable = 0,
1126 .pdata = &msm_camera_device_data,
1127 .flash_data = &flash_s5k3e2fx
1128};
1129
1130static struct platform_device msm_camera_sensor_s5k3e2fx = {
1131 .name = "msm_camera_s5k3e2fx",
1132 .dev = {
1133 .platform_data = &msm_camera_sensor_s5k3e2fx_data,
1134 },
1135};
1136#endif
1137
1138#ifdef CONFIG_MT9P012
1139static struct msm_camera_sensor_flash_data flash_mt9p012 = {
1140 .flash_type = MSM_CAMERA_FLASH_LED,
1141 .flash_src = &msm_flash_src
1142};
1143
1144static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_data = {
1145 .sensor_name = "mt9p012",
1146 .sensor_reset = 89,
1147 .sensor_pwd = 85,
1148 .vcm_pwd = 88,
1149 .vcm_enable = 0,
1150 .pdata = &msm_camera_device_data,
1151 .flash_data = &flash_mt9p012
1152};
1153
1154static struct platform_device msm_camera_sensor_mt9p012 = {
1155 .name = "msm_camera_mt9p012",
1156 .dev = {
1157 .platform_data = &msm_camera_sensor_mt9p012_data,
1158 },
1159};
1160#endif
1161
1162#ifdef CONFIG_MT9P012_KM
1163static struct msm_camera_sensor_flash_data flash_mt9p012_km = {
1164 .flash_type = MSM_CAMERA_FLASH_LED,
1165 .flash_src = &msm_flash_src
1166};
1167
1168static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_km_data = {
1169 .sensor_name = "mt9p012_km",
1170 .sensor_reset = 89,
1171 .sensor_pwd = 85,
1172 .vcm_pwd = 88,
1173 .vcm_enable = 0,
1174 .pdata = &msm_camera_device_data,
1175 .flash_data = &flash_mt9p012_km
1176};
1177
1178static struct platform_device msm_camera_sensor_mt9p012_km = {
1179 .name = "msm_camera_mt9p012_km",
1180 .dev = {
1181 .platform_data = &msm_camera_sensor_mt9p012_km_data,
1182 },
1183};
1184#endif
1185
1186#ifdef CONFIG_MT9T013
1187static struct msm_camera_sensor_flash_data flash_mt9t013 = {
1188 .flash_type = MSM_CAMERA_FLASH_LED,
1189 .flash_src = &msm_flash_src
1190};
1191
1192static struct msm_camera_sensor_info msm_camera_sensor_mt9t013_data = {
1193 .sensor_name = "mt9t013",
1194 .sensor_reset = 89,
1195 .sensor_pwd = 85,
1196 .vcm_pwd = 0,
1197 .vcm_enable = 0,
1198 .pdata = &msm_camera_device_data,
1199 .flash_data = &flash_mt9t013
1200};
1201
1202static struct platform_device msm_camera_sensor_mt9t013 = {
1203 .name = "msm_camera_mt9t013",
1204 .dev = {
1205 .platform_data = &msm_camera_sensor_mt9t013_data,
1206 },
1207};
1208#endif
1209
1210#ifdef CONFIG_VB6801
1211static struct msm_camera_sensor_flash_data flash_vb6801 = {
1212 .flash_type = MSM_CAMERA_FLASH_LED,
1213 .flash_src = &msm_flash_src
1214};
1215
1216static struct msm_camera_sensor_info msm_camera_sensor_vb6801_data = {
1217 .sensor_name = "vb6801",
1218 .sensor_reset = 89,
1219 .sensor_pwd = 88,
1220 .vcm_pwd = 0,
1221 .vcm_enable = 0,
1222 .pdata = &msm_camera_device_data,
1223 .flash_data = &flash_vb6801
1224};
1225
1226static struct platform_device msm_camera_sensor_vb6801 = {
1227 .name = "msm_camera_vb6801",
1228 .dev = {
1229 .platform_data = &msm_camera_sensor_vb6801_data,
1230 },
1231};
1232#endif
1233#endif
1234
1235static u32 msm_calculate_batt_capacity(u32 current_voltage);
1236
1237static struct msm_psy_batt_pdata msm_psy_batt_data = {
1238 .voltage_min_design = 2800,
1239 .voltage_max_design = 4300,
1240 .avail_chg_sources = AC_CHG | USB_CHG ,
1241 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
1242 .calculate_capacity = &msm_calculate_batt_capacity,
1243};
1244
1245static u32 msm_calculate_batt_capacity(u32 current_voltage)
1246{
1247 u32 low_voltage = msm_psy_batt_data.voltage_min_design;
1248 u32 high_voltage = msm_psy_batt_data.voltage_max_design;
1249
1250 return (current_voltage - low_voltage) * 100
1251 / (high_voltage - low_voltage);
1252}
1253
1254static struct platform_device msm_batt_device = {
1255 .name = "msm-battery",
1256 .id = -1,
1257 .dev.platform_data = &msm_psy_batt_data,
1258};
1259
1260
Daniel Walker2682fd32010-02-24 15:47:58 -08001261static struct platform_device *devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001262 &asoc_msm_pcm,
1263 &asoc_msm_dai0,
1264 &asoc_msm_dai1,
1265
Daniel Walker2682fd32010-02-24 15:47:58 -08001266 &msm_device_smd,
1267 &msm_device_dmov,
1268 &msm_device_nand,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001269
1270#ifdef CONFIG_USB_MSM_OTG_72K
1271 &msm_device_otg,
1272#ifdef CONFIG_USB_GADGET
1273 &msm_device_gadget_peripheral,
1274#endif
1275#endif
1276
Manu Gautam99ed3912011-10-13 18:00:55 +05301277#ifdef CONFIG_USB_G_ANDROID
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001278 &android_usb_device,
1279#endif
Manu Gautam99ed3912011-10-13 18:00:55 +05301280
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001281 &msm_device_i2c,
Daniel Walker2682fd32010-02-24 15:47:58 -08001282 &smc91x_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001283 &msm_device_tssc,
1284 &android_pmem_device,
1285 &android_pmem_adsp_device,
1286 &android_pmem_audio_device,
1287 &msm_fb_device,
1288 &lcdc_gordon_panel_device,
1289 &msm_device_uart_dm1,
1290#ifdef CONFIG_BT
1291 &msm_bt_power_device,
1292#endif
1293 &msm_device_pmic_leds,
1294 &msm_device_snd,
1295 &msm_device_adspdec,
1296#ifdef CONFIG_MT9T013
1297 &msm_camera_sensor_mt9t013,
1298#endif
1299#ifdef CONFIG_MT9D112
1300 &msm_camera_sensor_mt9d112,
1301#endif
1302#ifdef CONFIG_S5K3E2FX
1303 &msm_camera_sensor_s5k3e2fx,
1304#endif
1305#ifdef CONFIG_MT9P012
1306 &msm_camera_sensor_mt9p012,
1307#endif
1308#ifdef CONFIG_MT9P012_KM
1309 &msm_camera_sensor_mt9p012_km,
1310#endif
1311#ifdef CONFIG_VB6801
1312 &msm_camera_sensor_vb6801,
1313#endif
1314 &msm_bluesleep_device,
1315#ifdef CONFIG_ARCH_MSM7X27
1316 &msm_kgsl_3d0,
1317#endif
1318#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
1319 &msm_device_tsif,
1320#endif
1321 &hs_device,
1322 &msm_batt_device,
Daniel Walker2682fd32010-02-24 15:47:58 -08001323};
1324
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001325static struct msm_panel_common_pdata mdp_pdata = {
1326 .gpio = 97,
Ravishangar Kalyanam07ef7882011-08-09 15:50:48 -07001327 .mdp_rev = MDP_REV_30,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001328};
1329
1330static void __init msm_fb_add_devices(void)
1331{
1332 msm_fb_register_device("mdp", &mdp_pdata);
1333 msm_fb_register_device("pmdh", 0);
1334 msm_fb_register_device("lcdc", &lcdc_pdata);
1335}
1336
Daniel Walker2682fd32010-02-24 15:47:58 -08001337extern struct sys_timer msm_timer;
1338
1339static void __init msm7x2x_init_irq(void)
1340{
1341 msm_init_irq();
1342}
1343
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001344void msm_serial_debug_init(unsigned int base, int irq,
1345 struct device *clk_device, int signal_irq);
1346
1347#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
1348 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
1349 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
1350 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT))
1351
1352static unsigned long vreg_sts, gpio_sts;
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301353static struct regulator *vreg_mmc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001354static unsigned mpp_mmc = 2;
1355
1356struct sdcc_gpio {
1357 struct msm_gpio *cfg_data;
1358 uint32_t size;
1359 struct msm_gpio *sleep_cfg_data;
1360};
1361
1362static struct msm_gpio sdc1_cfg_data[] = {
1363 {GPIO_CFG(51, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_3"},
1364 {GPIO_CFG(52, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_2"},
1365 {GPIO_CFG(53, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_1"},
1366 {GPIO_CFG(54, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_0"},
1367 {GPIO_CFG(55, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_cmd"},
1368 {GPIO_CFG(56, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "sdc1_clk"},
1369};
1370
1371static struct msm_gpio sdc2_cfg_data[] = {
1372 {GPIO_CFG(62, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "sdc2_clk"},
1373 {GPIO_CFG(63, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_cmd"},
1374 {GPIO_CFG(64, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_3"},
1375 {GPIO_CFG(65, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_2"},
1376 {GPIO_CFG(66, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_1"},
1377 {GPIO_CFG(67, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_0"},
1378};
1379
1380static struct msm_gpio sdc2_sleep_cfg_data[] = {
1381 {GPIO_CFG(62, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "sdc2_clk"},
1382 {GPIO_CFG(63, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "sdc2_cmd"},
1383 {GPIO_CFG(64, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "sdc2_dat_3"},
1384 {GPIO_CFG(65, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "sdc2_dat_2"},
1385 {GPIO_CFG(66, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "sdc2_dat_1"},
1386 {GPIO_CFG(67, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "sdc2_dat_0"},
1387};
1388static struct msm_gpio sdc3_cfg_data[] = {
1389 {GPIO_CFG(88, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "sdc3_clk"},
1390 {GPIO_CFG(89, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_cmd"},
1391 {GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_3"},
1392 {GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_2"},
1393 {GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_1"},
1394 {GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_0"},
1395};
1396
1397static struct msm_gpio sdc4_cfg_data[] = {
1398 {GPIO_CFG(19, 3, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_3"},
1399 {GPIO_CFG(20, 3, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_2"},
1400 {GPIO_CFG(21, 4, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_1"},
1401 {GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_cmd"},
1402 {GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_0"},
1403 {GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "sdc4_clk"},
1404};
1405
1406static struct sdcc_gpio sdcc_cfg_data[] = {
1407 {
1408 .cfg_data = sdc1_cfg_data,
1409 .size = ARRAY_SIZE(sdc1_cfg_data),
1410 .sleep_cfg_data = NULL,
1411 },
1412 {
1413 .cfg_data = sdc2_cfg_data,
1414 .size = ARRAY_SIZE(sdc2_cfg_data),
1415 .sleep_cfg_data = sdc2_sleep_cfg_data,
1416 },
1417 {
1418 .cfg_data = sdc3_cfg_data,
1419 .size = ARRAY_SIZE(sdc3_cfg_data),
1420 .sleep_cfg_data = NULL,
1421 },
1422 {
1423 .cfg_data = sdc4_cfg_data,
1424 .size = ARRAY_SIZE(sdc4_cfg_data),
1425 .sleep_cfg_data = NULL,
1426 },
1427};
1428
1429static void msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
1430{
1431 int rc = 0;
1432 struct sdcc_gpio *curr;
1433
1434 curr = &sdcc_cfg_data[dev_id - 1];
1435 if (!(test_bit(dev_id, &gpio_sts)^enable))
1436 return;
1437
1438 if (enable) {
1439 set_bit(dev_id, &gpio_sts);
1440 rc = msm_gpios_request_enable(curr->cfg_data, curr->size);
1441 if (rc)
1442 printk(KERN_ERR "%s: Failed to turn on GPIOs for slot %d\n",
1443 __func__, dev_id);
1444 } else {
1445 clear_bit(dev_id, &gpio_sts);
1446 if (curr->sleep_cfg_data) {
1447 msm_gpios_enable(curr->sleep_cfg_data, curr->size);
1448 msm_gpios_free(curr->sleep_cfg_data, curr->size);
1449 return;
1450 }
1451 msm_gpios_disable_free(curr->cfg_data, curr->size);
1452 }
1453}
1454
1455static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
1456{
1457 int rc = 0;
1458 struct platform_device *pdev;
1459
1460 pdev = container_of(dv, struct platform_device, dev);
1461 msm_sdcc_setup_gpio(pdev->id, !!vdd);
1462
1463 if (vdd == 0) {
1464 if (!vreg_sts)
1465 return 0;
1466
1467 clear_bit(pdev->id, &vreg_sts);
1468
1469 if (!vreg_sts) {
1470 if (machine_is_msm7x25_ffa() ||
1471 machine_is_msm7x27_ffa()) {
1472 rc = mpp_config_digital_out(mpp_mmc,
1473 MPP_CFG(MPP_DLOGIC_LVL_MSMP,
1474 MPP_DLOGIC_OUT_CTRL_LOW));
1475 } else
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301476 rc = regulator_disable(vreg_mmc);
1477 if (rc) {
1478 pr_err("%s: return val: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001479 __func__, rc);
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301480 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001481 }
1482 return 0;
1483 }
1484
1485 if (!vreg_sts) {
1486 if (machine_is_msm7x25_ffa() || machine_is_msm7x27_ffa()) {
1487 rc = mpp_config_digital_out(mpp_mmc,
1488 MPP_CFG(MPP_DLOGIC_LVL_MSMP,
1489 MPP_DLOGIC_OUT_CTRL_HIGH));
1490 } else {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301491 rc = regulator_set_voltage(vreg_mmc, 2850000, 2850000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001492 if (!rc)
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301493 rc = regulator_enable(vreg_mmc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001494 }
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301495 if (rc) {
1496 pr_err("%s: return val: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001497 __func__, rc);
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301498 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001499 }
1500 set_bit(pdev->id, &vreg_sts);
1501 return 0;
1502}
1503
1504#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
1505static struct mmc_platform_data msm7x2x_sdc1_data = {
1506 .ocr_mask = MMC_VDD_28_29,
1507 .translate_vdd = msm_sdcc_setup_power,
1508 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
1509 .msmsdcc_fmin = 144000,
1510 .msmsdcc_fmid = 24576000,
1511 .msmsdcc_fmax = 49152000,
1512 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001513};
1514#endif
1515
1516#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
1517static struct mmc_platform_data msm7x2x_sdc2_data = {
1518 .ocr_mask = MMC_VDD_28_29,
1519 .translate_vdd = msm_sdcc_setup_power,
1520 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
1521#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
1522 .sdiowakeup_irq = MSM_GPIO_TO_INT(66),
1523#endif
1524 .msmsdcc_fmin = 144000,
1525 .msmsdcc_fmid = 24576000,
1526 .msmsdcc_fmax = 49152000,
1527 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001528};
1529#endif
1530
1531#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
1532static struct mmc_platform_data msm7x2x_sdc3_data = {
1533 .ocr_mask = MMC_VDD_28_29,
1534 .translate_vdd = msm_sdcc_setup_power,
1535 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
1536 .msmsdcc_fmin = 144000,
1537 .msmsdcc_fmid = 24576000,
1538 .msmsdcc_fmax = 49152000,
1539 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001540};
1541#endif
1542
1543#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
1544static struct mmc_platform_data msm7x2x_sdc4_data = {
1545 .ocr_mask = MMC_VDD_28_29,
1546 .translate_vdd = msm_sdcc_setup_power,
1547 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
1548 .msmsdcc_fmin = 144000,
1549 .msmsdcc_fmid = 24576000,
1550 .msmsdcc_fmax = 49152000,
1551 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001552};
1553#endif
1554
1555static void __init msm7x2x_init_mmc(void)
1556{
1557 if (!machine_is_msm7x25_ffa() && !machine_is_msm7x27_ffa()) {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301558 vreg_mmc = regulator_get(NULL, "mmc");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001559 if (IS_ERR(vreg_mmc)) {
Pankaj Kumar0f77ca82011-10-03 10:20:30 +05301560 pr_err("%s: could not get regulator: %ld\n",
1561 __func__, PTR_ERR(vreg_mmc));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001562 }
1563 }
1564
1565#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
1566 msm_add_sdcc(1, &msm7x2x_sdc1_data);
1567#endif
1568
1569 if (machine_is_msm7x25_surf() || machine_is_msm7x27_surf() ||
1570 machine_is_msm7x27_ffa()) {
1571#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
1572 msm_sdcc_setup_gpio(2, 1);
1573 msm_add_sdcc(2, &msm7x2x_sdc2_data);
1574#endif
1575 }
1576
1577 if (machine_is_msm7x25_surf() || machine_is_msm7x27_surf()) {
1578#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
1579 msm_add_sdcc(3, &msm7x2x_sdc3_data);
1580#endif
1581#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
1582 msm_add_sdcc(4, &msm7x2x_sdc4_data);
1583#endif
1584 }
1585}
1586#else
1587#define msm7x2x_init_mmc() do {} while (0)
1588#endif
1589
1590
1591static struct msm_pm_platform_data msm7x25_pm_data[MSM_PM_SLEEP_MODE_NR] = {
1592 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE].latency = 16000,
1593
1594 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN].latency = 12000,
1595
1596 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency = 2000,
1597};
1598
1599static struct msm_pm_platform_data msm7x27_pm_data[MSM_PM_SLEEP_MODE_NR] = {
1600 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = {
1601 .idle_supported = 1,
1602 .suspend_supported = 1,
1603 .idle_enabled = 1,
1604 .suspend_enabled = 1,
1605 .latency = 16000,
1606 .residency = 20000,
1607 },
1608
1609 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] = {
1610 .idle_supported = 1,
1611 .suspend_supported = 1,
1612 .idle_enabled = 1,
1613 .suspend_enabled = 1,
1614 .latency = 12000,
1615 .residency = 20000,
1616 },
1617
1618 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT] = {
1619 .idle_supported = 1,
1620 .suspend_supported = 1,
1621 .idle_enabled = 1,
1622 .suspend_enabled = 1,
1623 .latency = 2000,
1624 .residency = 0,
1625 },
1626};
1627
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06001628static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
1629 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_VIRT,
1630 .v_addr = (uint32_t *)PAGE_OFFSET,
1631};
1632
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001633static void
1634msm_i2c_gpio_config(int iface, int config_type)
1635{
1636 int gpio_scl;
1637 int gpio_sda;
1638 if (iface) {
1639 gpio_scl = 95;
1640 gpio_sda = 96;
1641 } else {
1642 gpio_scl = 60;
1643 gpio_sda = 61;
1644 }
1645 if (config_type) {
1646 gpio_tlmm_config(GPIO_CFG(gpio_scl, 1, GPIO_CFG_INPUT,
1647 GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE);
1648 gpio_tlmm_config(GPIO_CFG(gpio_sda, 1, GPIO_CFG_INPUT,
1649 GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE);
1650 } else {
1651 gpio_tlmm_config(GPIO_CFG(gpio_scl, 0, GPIO_CFG_OUTPUT,
1652 GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE);
1653 gpio_tlmm_config(GPIO_CFG(gpio_sda, 0, GPIO_CFG_OUTPUT,
1654 GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE);
1655 }
1656}
1657
1658static struct msm_i2c_platform_data msm_i2c_pdata = {
1659 .clk_freq = 100000,
1660 .rmutex = 0,
1661 .pri_clk = 60,
1662 .pri_dat = 61,
1663 .aux_clk = 95,
1664 .aux_dat = 96,
1665 .msm_i2c_config_gpio = msm_i2c_gpio_config,
1666};
Pankaj Kumar75c86fd2011-10-01 18:51:09 +05301667static struct platform_device msm_proccomm_regulator_dev = {
1668 .name = PROCCOMM_REGULATOR_DEV_NAME,
1669 .id = -1,
1670 .dev = {
1671 .platform_data = &msm7627_proccomm_regulator_data
1672 }
1673};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001674
Pankaj Kumar75c86fd2011-10-01 18:51:09 +05301675static void __init msm7627_init_regulators(void)
1676{
1677 int rc = platform_device_register(&msm_proccomm_regulator_dev);
1678 if (rc)
1679 pr_err("%s: could not register regulator device: %d\n",
1680 __func__, rc);
1681}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001682static void __init msm_device_i2c_init(void)
1683{
1684 if (gpio_request(60, "i2c_pri_clk"))
1685 pr_err("failed to request gpio i2c_pri_clk\n");
1686 if (gpio_request(61, "i2c_pri_dat"))
1687 pr_err("failed to request gpio i2c_pri_dat\n");
1688 if (gpio_request(95, "i2c_sec_clk"))
1689 pr_err("failed to request gpio i2c_sec_clk\n");
1690 if (gpio_request(96, "i2c_sec_dat"))
1691 pr_err("failed to request gpio i2c_sec_dat\n");
1692
1693 if (cpu_is_msm7x27())
1694 msm_i2c_pdata.pm_lat =
1695 msm7x27_pm_data[MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN]
1696 .latency;
1697 else
1698 msm_i2c_pdata.pm_lat =
1699 msm7x25_pm_data[MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN]
1700 .latency;
1701
1702 msm_device_i2c.dev.platform_data = &msm_i2c_pdata;
1703}
1704
1705static void usb_mpp_init(void)
1706{
1707 unsigned rc;
1708 unsigned mpp_usb = 7;
1709
1710 if (machine_is_msm7x25_ffa() || machine_is_msm7x27_ffa()) {
1711 rc = mpp_config_digital_out(mpp_usb,
1712 MPP_CFG(MPP_DLOGIC_LVL_VDD,
1713 MPP_DLOGIC_OUT_CTRL_HIGH));
1714 if (rc)
1715 pr_err("%s: configuring mpp pin"
1716 "to enable 3.3V LDO failed\n", __func__);
1717 }
1718}
1719
1720static void msm7x27_wlan_init(void)
1721{
1722 int rc = 0;
1723 /* TBD: if (machine_is_msm7x27_ffa_with_wcn1312()) */
1724 if (machine_is_msm7x27_ffa()) {
1725 rc = mpp_config_digital_out(3, MPP_CFG(MPP_DLOGIC_LVL_MSMP,
1726 MPP_DLOGIC_OUT_CTRL_LOW));
1727 if (rc)
1728 printk(KERN_ERR "%s: return val: %d \n",
1729 __func__, rc);
1730 }
1731}
1732
Daniel Walker2682fd32010-02-24 15:47:58 -08001733static void __init msm7x2x_init(void)
1734{
Daniel Walker2682fd32010-02-24 15:47:58 -08001735
Pankaj Kumar75c86fd2011-10-01 18:51:09 +05301736 msm7627_init_regulators();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001737#ifdef CONFIG_ARCH_MSM7X25
1738 msm_clock_init(msm_clocks_7x25, msm_num_clocks_7x25);
1739#elif defined(CONFIG_ARCH_MSM7X27)
Stephen Boydbb600ae2011-08-02 20:11:40 -07001740 msm_clock_init(&msm7x27_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001741#endif
1742
1743#if defined(CONFIG_SMC91X)
Daniel Walker2682fd32010-02-24 15:47:58 -08001744 if (machine_is_msm7x25_ffa() || machine_is_msm7x27_ffa()) {
1745 smc91x_resources[0].start = 0x98000300;
1746 smc91x_resources[0].end = 0x980003ff;
1747 smc91x_resources[1].start = MSM_GPIO_TO_INT(85);
1748 smc91x_resources[1].end = MSM_GPIO_TO_INT(85);
1749 if (gpio_tlmm_config(GPIO_CFG(85, 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001750 GPIO_CFG_INPUT,
1751 GPIO_CFG_PULL_DOWN,
1752 GPIO_CFG_2MA),
1753 GPIO_CFG_ENABLE)) {
Daniel Walker2682fd32010-02-24 15:47:58 -08001754 printk(KERN_ERR
1755 "%s: Err: Config GPIO-85 INT\n",
1756 __func__);
1757 }
1758 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001759#endif
Pankaj Kumar6e66f372011-12-05 14:41:58 +05301760 acpuclk_init(&acpuclk_7x27_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001761
1762 usb_mpp_init();
1763
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001764
1765#ifdef CONFIG_USB_MSM_OTG_72K
1766 msm_device_otg.dev.platform_data = &msm_otg_pdata;
1767 if (machine_is_msm7x25_surf() || machine_is_msm7x25_ffa()) {
1768 msm_otg_pdata.pemp_level =
1769 PRE_EMPHASIS_WITH_20_PERCENT;
1770 msm_otg_pdata.drv_ampl = HS_DRV_AMPLITUDE_5_PERCENT;
1771 msm_otg_pdata.cdr_autoreset = CDR_AUTO_RESET_ENABLE;
1772 msm_otg_pdata.phy_reset = msm_otg_rpc_phy_reset;
1773 }
1774 if (machine_is_msm7x27_surf() || machine_is_msm7x27_ffa()) {
1775 msm_otg_pdata.pemp_level =
1776 PRE_EMPHASIS_WITH_10_PERCENT;
1777 msm_otg_pdata.drv_ampl = HS_DRV_AMPLITUDE_5_PERCENT;
1778 msm_otg_pdata.cdr_autoreset = CDR_AUTO_RESET_DISABLE;
1779 msm_otg_pdata.phy_reset_sig_inverted = 1;
1780 }
1781
1782#ifdef CONFIG_USB_GADGET
1783 msm_otg_pdata.swfi_latency =
1784 msm7x27_pm_data
1785 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
1786 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
1787 msm_gadget_pdata.is_phy_status_timer_on = 1;
1788#endif
1789#endif
1790#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
1791 msm_device_tsif.dev.platform_data = &tsif_platform_data;
1792#endif
1793 platform_add_devices(msm_footswitch_devices,
1794 msm_num_footswitch_devices);
Daniel Walker2682fd32010-02-24 15:47:58 -08001795 platform_add_devices(devices, ARRAY_SIZE(devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001796#ifdef CONFIG_MSM_CAMERA
1797 config_camera_off_gpios(); /* might not be necessary */
1798#endif
1799 msm_device_i2c_init();
1800 i2c_register_board_info(0, i2c_devices, ARRAY_SIZE(i2c_devices));
1801
1802#ifdef CONFIG_SURF_FFA_GPIO_KEYPAD
1803 if (machine_is_msm7x25_ffa() || machine_is_msm7x27_ffa())
1804 platform_device_register(&keypad_device_7k_ffa);
1805 else
1806 platform_device_register(&keypad_device_surf);
1807#endif
1808 lcdc_gordon_gpio_init();
1809 msm_fb_add_devices();
1810#ifdef CONFIG_USB_EHCI_MSM_72K
1811 msm7x2x_init_host();
1812#endif
1813 msm7x2x_init_mmc();
1814 bt_power_init();
1815
1816 if (cpu_is_msm7x27())
1817 msm_pm_set_platform_data(msm7x27_pm_data,
1818 ARRAY_SIZE(msm7x27_pm_data));
1819 else
1820 msm_pm_set_platform_data(msm7x25_pm_data,
1821 ARRAY_SIZE(msm7x25_pm_data));
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -06001822
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06001823 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
1824
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001825 msm7x27_wlan_init();
1826}
1827
1828static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE;
1829static int __init pmem_kernel_ebi1_size_setup(char *p)
1830{
1831 pmem_kernel_ebi1_size = memparse(p, NULL);
1832 return 0;
1833}
1834early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
1835
1836static unsigned pmem_mdp_size = MSM_PMEM_MDP_SIZE;
1837static int __init pmem_mdp_size_setup(char *p)
1838{
1839 pmem_mdp_size = memparse(p, NULL);
1840 return 0;
1841}
1842early_param("pmem_mdp_size", pmem_mdp_size_setup);
1843
1844static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
1845static int __init pmem_adsp_size_setup(char *p)
1846{
1847 pmem_adsp_size = memparse(p, NULL);
1848 return 0;
1849}
1850early_param("pmem_adsp_size", pmem_adsp_size_setup);
1851
1852static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
1853static int __init pmem_audio_size_setup(char *p)
1854{
1855 pmem_audio_size = memparse(p, NULL);
1856 return 0;
1857}
1858early_param("pmem_audio_size", pmem_audio_size_setup);
1859
1860static unsigned fb_size = MSM_FB_SIZE;
1861static int __init fb_size_setup(char *p)
1862{
1863 fb_size = memparse(p, NULL);
1864 return 0;
1865}
1866early_param("fb_size", fb_size_setup);
1867
1868static void __init msm_msm7x2x_allocate_memory_regions(void)
1869{
1870 void *addr;
1871 unsigned long size;
1872
1873 size = fb_size ? : MSM_FB_SIZE;
1874 addr = alloc_bootmem_align(size, 0x1000);
1875 msm_fb_resources[0].start = __pa(addr);
1876 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
1877 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
1878 size, addr, __pa(addr));
1879}
1880
1881static struct memtype_reserve msm7x27_reserve_table[] __initdata = {
1882 [MEMTYPE_SMI] = {
1883 },
1884 [MEMTYPE_EBI0] = {
1885 .flags = MEMTYPE_FLAGS_1M_ALIGN,
1886 },
1887 [MEMTYPE_EBI1] = {
1888 .flags = MEMTYPE_FLAGS_1M_ALIGN,
1889 },
1890};
1891
1892static void __init size_pmem_devices(void)
1893{
1894#ifdef CONFIG_ANDROID_PMEM
1895 android_pmem_adsp_pdata.size = pmem_adsp_size;
1896 android_pmem_pdata.size = pmem_mdp_size;
1897 android_pmem_audio_pdata.size = pmem_audio_size;
1898#endif
1899}
1900
1901static void __init reserve_memory_for(struct android_pmem_platform_data *p)
1902{
1903 msm7x27_reserve_table[p->memory_type].size += p->size;
1904}
1905
1906static void __init reserve_pmem_memory(void)
1907{
1908#ifdef CONFIG_ANDROID_PMEM
1909 reserve_memory_for(&android_pmem_adsp_pdata);
1910 reserve_memory_for(&android_pmem_pdata);
1911 reserve_memory_for(&android_pmem_audio_pdata);
1912 msm7x27_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
1913#endif
1914}
1915
1916static void __init msm7x27_calculate_reserve_sizes(void)
1917{
1918 size_pmem_devices();
1919 reserve_pmem_memory();
1920}
1921
1922static int msm7x27_paddr_to_memtype(unsigned int paddr)
1923{
1924 return MEMTYPE_EBI1;
1925}
1926
1927static struct reserve_info msm7x27_reserve_info __initdata = {
1928 .memtype_reserve_table = msm7x27_reserve_table,
1929 .calculate_reserve_sizes = msm7x27_calculate_reserve_sizes,
1930 .paddr_to_memtype = msm7x27_paddr_to_memtype,
1931};
1932
1933static void __init msm7x27_reserve(void)
1934{
1935 reserve_info = &msm7x27_reserve_info;
1936 msm_reserve();
1937}
1938
1939static void __init msm7x27_init_early(void)
1940{
1941 msm_msm7x2x_allocate_memory_regions();
Daniel Walker2682fd32010-02-24 15:47:58 -08001942}
1943
1944static void __init msm7x2x_map_io(void)
1945{
1946 msm_map_common_io();
Daniel Walker2682fd32010-02-24 15:47:58 -08001947
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001948 if (socinfo_init() < 0)
1949 BUG();
Daniel Walker2682fd32010-02-24 15:47:58 -08001950
1951#ifdef CONFIG_CACHE_L2X0
1952 if (machine_is_msm7x27_surf() || machine_is_msm7x27_ffa()) {
1953 /* 7x27 has 256KB L2 cache:
1954 64Kb/Way and 4-Way Associativity;
Daniel Walker2682fd32010-02-24 15:47:58 -08001955 evmon/parity/share disabled. */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001956 if ((SOCINFO_VERSION_MAJOR(socinfo_get_version()) > 1)
1957 || ((SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 1)
1958 && (SOCINFO_VERSION_MINOR(socinfo_get_version()) >= 3)))
1959 /* R/W latency: 4 cycles; */
1960 l2x0_init(MSM_L2CC_BASE, 0x0006801B, 0xfe000000);
1961 else
1962 /* R/W latency: 3 cycles; */
1963 l2x0_init(MSM_L2CC_BASE, 0x00068012, 0xfe000000);
Daniel Walker2682fd32010-02-24 15:47:58 -08001964 }
1965#endif
1966}
1967
1968MACHINE_START(MSM7X27_SURF, "QCT MSM7x27 SURF")
Russell Kingb75c1782011-01-04 19:03:16 +00001969 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker2682fd32010-02-24 15:47:58 -08001970 .map_io = msm7x2x_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001971 .reserve = msm7x27_reserve,
Daniel Walker2682fd32010-02-24 15:47:58 -08001972 .init_irq = msm7x2x_init_irq,
1973 .init_machine = msm7x2x_init,
1974 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001975 .init_early = msm7x27_init_early,
Taniya Dasbe561a02011-10-12 09:53:11 +05301976 .handle_irq = vic_handle_irq,
Daniel Walker2682fd32010-02-24 15:47:58 -08001977MACHINE_END
1978
1979MACHINE_START(MSM7X27_FFA, "QCT MSM7x27 FFA")
Russell Kingb75c1782011-01-04 19:03:16 +00001980 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker2682fd32010-02-24 15:47:58 -08001981 .map_io = msm7x2x_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001982 .reserve = msm7x27_reserve,
Daniel Walker2682fd32010-02-24 15:47:58 -08001983 .init_irq = msm7x2x_init_irq,
1984 .init_machine = msm7x2x_init,
1985 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001986 .init_early = msm7x27_init_early,
Taniya Dasbe561a02011-10-12 09:53:11 +05301987 .handle_irq = vic_handle_irq,
Daniel Walker2682fd32010-02-24 15:47:58 -08001988MACHINE_END
1989
1990MACHINE_START(MSM7X25_SURF, "QCT MSM7x25 SURF")
Russell Kingb75c1782011-01-04 19:03:16 +00001991 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker2682fd32010-02-24 15:47:58 -08001992 .map_io = msm7x2x_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001993 .reserve = msm7x27_reserve,
Daniel Walker2682fd32010-02-24 15:47:58 -08001994 .init_irq = msm7x2x_init_irq,
1995 .init_machine = msm7x2x_init,
1996 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001997 .init_early = msm7x27_init_early,
Taniya Dasbe561a02011-10-12 09:53:11 +05301998 .handle_irq = vic_handle_irq,
Daniel Walker2682fd32010-02-24 15:47:58 -08001999MACHINE_END
2000
2001MACHINE_START(MSM7X25_FFA, "QCT MSM7x25 FFA")
Russell Kingb75c1782011-01-04 19:03:16 +00002002 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker2682fd32010-02-24 15:47:58 -08002003 .map_io = msm7x2x_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002004 .reserve = msm7x27_reserve,
Daniel Walker2682fd32010-02-24 15:47:58 -08002005 .init_irq = msm7x2x_init_irq,
2006 .init_machine = msm7x2x_init,
2007 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002008 .init_early = msm7x27_init_early,
Taniya Dasbe561a02011-10-12 09:53:11 +05302009 .handle_irq = vic_handle_irq,
Daniel Walker2682fd32010-02-24 15:47:58 -08002010MACHINE_END