blob: ef1bf2de7c583484f65e39f3531c216de6109cd7 [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
Daniel Walker2682fd32010-02-24 15:47:58 -080066#include "devices.h"
Daniel Walker2682fd32010-02-24 15:47:58 -080067#include "clock.h"
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070068#include "acpuclock.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070069#include "msm-keypad-devices.h"
70#include "pm.h"
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -060071#include "pm-boot.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070072
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070073#ifdef CONFIG_ARCH_MSM7X25
74#define MSM_PMEM_MDP_SIZE 0xb21000
75#define MSM_PMEM_ADSP_SIZE 0x97b000
76#define MSM_PMEM_AUDIO_SIZE 0x121000
77#define MSM_FB_SIZE 0x200000
78#define PMEM_KERNEL_EBI1_SIZE 0x64000
79#endif
80
81#ifdef CONFIG_ARCH_MSM7X27
82#define MSM_PMEM_MDP_SIZE 0x1B76000
83#define MSM_PMEM_ADSP_SIZE 0xC8A000
84#define MSM_PMEM_AUDIO_SIZE 0x5B000
85
86#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
87#define MSM_FB_SIZE 0x233000
88#else
89#define MSM_FB_SIZE 0x177000
90#endif
91
92#define PMEM_KERNEL_EBI1_SIZE 0x1C000
93#endif
Daniel Walker2682fd32010-02-24 15:47:58 -080094
95static struct resource smc91x_resources[] = {
96 [0] = {
97 .start = 0x9C004300,
98 .end = 0x9C0043ff,
99 .flags = IORESOURCE_MEM,
100 },
101 [1] = {
102 .start = MSM_GPIO_TO_INT(132),
103 .end = MSM_GPIO_TO_INT(132),
104 .flags = IORESOURCE_IRQ,
105 },
106};
107
Manu Gautam99ed3912011-10-13 18:00:55 +0530108static struct platform_device smc91x_device = {
109 .name = "smc91x",
110 .id = 0,
111 .num_resources = ARRAY_SIZE(smc91x_resources),
112 .resource = smc91x_resources,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700113};
114
Manu Gautam99ed3912011-10-13 18:00:55 +0530115#ifdef CONFIG_USB_G_ANDROID
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700116static struct android_usb_platform_data android_usb_pdata = {
Manu Gautam99ed3912011-10-13 18:00:55 +0530117 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700118};
119
120static struct platform_device android_usb_device = {
121 .name = "android_usb",
122 .id = -1,
123 .dev = {
124 .platform_data = &android_usb_pdata,
125 },
126};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700127#endif
128
129#ifdef CONFIG_USB_EHCI_MSM_72K
130static void msm_hsusb_vbus_power(unsigned phy_info, int on)
131{
132 if (on)
133 msm_hsusb_vbus_powerup();
134 else
135 msm_hsusb_vbus_shutdown();
136}
137
138static struct msm_usb_host_platform_data msm_usb_host_pdata = {
139 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_65NM),
140};
141
142static void __init msm7x2x_init_host(void)
143{
144 if (machine_is_msm7x25_ffa() || machine_is_msm7x27_ffa())
145 return;
146
147 msm_add_host(0, &msm_usb_host_pdata);
148}
149#endif
150
151#ifdef CONFIG_USB_MSM_OTG_72K
152static int hsusb_rpc_connect(int connect)
153{
154 if (connect)
155 return msm_hsusb_rpc_connect();
156 else
157 return msm_hsusb_rpc_close();
158}
159#endif
160
161#ifdef CONFIG_USB_MSM_OTG_72K
162struct vreg *vreg_3p3;
163static int msm_hsusb_ldo_init(int init)
164{
165 if (init) {
166 /*
167 * PHY 3.3V analog domain(VDDA33) is powered up by
168 * an always enabled power supply (LP5900TL-3.3).
169 * USB VREG default source is VBUS line. Turning
170 * on USB VREG has a side effect on the USB suspend
171 * current. Hence USB VREG is explicitly turned
172 * off here.
173 */
174 vreg_3p3 = vreg_get(NULL, "usb");
175 if (IS_ERR(vreg_3p3))
176 return PTR_ERR(vreg_3p3);
177 vreg_enable(vreg_3p3);
178 vreg_disable(vreg_3p3);
179 vreg_put(vreg_3p3);
180 }
181
182 return 0;
183}
184
185static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
186{
187 int ret;
188
189 if (init) {
190 ret = msm_pm_app_rpc_init(callback);
191 } else {
192 msm_pm_app_rpc_deinit(callback);
193 ret = 0;
194 }
195 return ret;
196}
197
198static int msm_otg_rpc_phy_reset(void __iomem *regs)
199{
200 return msm_hsusb_phy_reset();
201}
202
203static struct msm_otg_platform_data msm_otg_pdata = {
204 .rpc_connect = hsusb_rpc_connect,
205 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
206 .chg_vbus_draw = hsusb_chg_vbus_draw,
207 .chg_connected = hsusb_chg_connected,
208 .chg_init = hsusb_chg_init,
209#ifdef CONFIG_USB_EHCI_MSM_72K
210 .vbus_power = msm_hsusb_vbus_power,
211#endif
212 .ldo_init = msm_hsusb_ldo_init,
213 .pclk_required_during_lpm = 1,
214 .pclk_src_name = "ebi1_usb_clk",
215};
216
217#ifdef CONFIG_USB_GADGET
218static struct msm_hsusb_gadget_platform_data msm_gadget_pdata;
219#endif
220#endif
221
222#define SND(desc, num) { .name = #desc, .id = num }
223static struct snd_endpoint snd_endpoints_list[] = {
224 SND(HANDSET, 0),
225 SND(MONO_HEADSET, 2),
226 SND(HEADSET, 3),
227 SND(SPEAKER, 6),
228 SND(TTY_HEADSET, 8),
229 SND(TTY_VCO, 9),
230 SND(TTY_HCO, 10),
231 SND(BT, 12),
232 SND(IN_S_SADC_OUT_HANDSET, 16),
233 SND(IN_S_SADC_OUT_SPEAKER_PHONE, 25),
234 SND(CURRENT, 27),
235};
236#undef SND
237
238static struct msm_snd_endpoints msm_device_snd_endpoints = {
239 .endpoints = snd_endpoints_list,
240 .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint)
241};
242
243static struct platform_device msm_device_snd = {
244 .name = "msm_snd",
245 .id = -1,
246 .dev = {
247 .platform_data = &msm_device_snd_endpoints
248 },
249};
250
251#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
252 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
253 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
254 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
255 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
256 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
257#ifdef CONFIG_ARCH_MSM7X25
258#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_WAV)|(1<<MSM_ADSP_CODEC_ADPCM)| \
259 (1<<MSM_ADSP_CODEC_YADPCM)|(1<<MSM_ADSP_CODEC_QCELP)| \
260 (1<<MSM_ADSP_CODEC_MP3))
261#define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_WAV)|(1<<MSM_ADSP_CODEC_ADPCM)| \
262 (1<<MSM_ADSP_CODEC_YADPCM)|(1<<MSM_ADSP_CODEC_QCELP)| \
263 (1<<MSM_ADSP_CODEC_MP3))
264#define DEC3_FORMAT 0
265#define DEC4_FORMAT 0
266#else
267#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
268 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
269 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
270 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
271 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
272 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
273#define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
274 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
275 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
276 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
277 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
278 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
279#define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
280 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
281 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
282 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
283 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
284 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
285#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
286#endif
287
288static unsigned int dec_concurrency_table[] = {
289 /* Audio LP */
290 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DMA)), 0,
291 0, 0, 0,
292
293 /* Concurrency 1 */
294 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
295 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
296 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
297 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
298 (DEC4_FORMAT),
299
300 /* Concurrency 2 */
301 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
302 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
303 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
304 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
305 (DEC4_FORMAT),
306
307 /* Concurrency 3 */
308 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
309 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
310 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
311 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
312 (DEC4_FORMAT),
313
314 /* Concurrency 4 */
315 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
316 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
317 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
318 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
319 (DEC4_FORMAT),
320
321 /* Concurrency 5 */
322 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
323 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
324 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
325 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
326 (DEC4_FORMAT),
327
328 /* Concurrency 6 */
329 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
330 0, 0, 0, 0,
331
332 /* Concurrency 7 */
333 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
334 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
335 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
336 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
337 (DEC4_FORMAT),
338};
339
340#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
341 .module_queueid = queueid, .module_decid = decid, \
342 .nr_codec_support = nr_codec}
343
344static struct msm_adspdec_info dec_info_list[] = {
345 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
346#ifdef CONFIG_ARCH_MSM7X25
347 DEC_INFO("AUDPLAY1TASK", 14, 1, 5), /* AudPlay1BitStreamCtrlQueue */
348 DEC_INFO("AUDPLAY2TASK", 15, 2, 5), /* AudPlay2BitStreamCtrlQueue */
349 DEC_INFO("AUDPLAY3TASK", 16, 3, 0), /* AudPlay3BitStreamCtrlQueue */
350 DEC_INFO("AUDPLAY4TASK", 17, 4, 0), /* AudPlay4BitStreamCtrlQueue */
351#else
352 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
353 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
354 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
355 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
356#endif
357};
358
359static struct msm_adspdec_database msm_device_adspdec_database = {
360 .num_dec = ARRAY_SIZE(dec_info_list),
361 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
362 ARRAY_SIZE(dec_info_list)),
363 .dec_concurrency_table = dec_concurrency_table,
364 .dec_info_list = dec_info_list,
365};
366
367static struct platform_device msm_device_adspdec = {
368 .name = "msm_adspdec",
369 .id = -1,
370 .dev = {
371 .platform_data = &msm_device_adspdec_database
372 },
373};
374
375static struct android_pmem_platform_data android_pmem_pdata = {
376 .name = "pmem",
377 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
378 .cached = 1,
379 .memory_type = MEMTYPE_EBI1,
380};
381
382static struct android_pmem_platform_data android_pmem_adsp_pdata = {
383 .name = "pmem_adsp",
384 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
385 .cached = 0,
386 .memory_type = MEMTYPE_EBI1,
387};
388
389static struct android_pmem_platform_data android_pmem_audio_pdata = {
390 .name = "pmem_audio",
391 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
392 .cached = 0,
393 .memory_type = MEMTYPE_EBI1,
394};
395
396static struct platform_device android_pmem_device = {
397 .name = "android_pmem",
398 .id = 0,
399 .dev = { .platform_data = &android_pmem_pdata },
400};
401
402static struct platform_device android_pmem_adsp_device = {
403 .name = "android_pmem",
404 .id = 1,
405 .dev = { .platform_data = &android_pmem_adsp_pdata },
406};
407
408static struct platform_device android_pmem_audio_device = {
409 .name = "android_pmem",
410 .id = 2,
411 .dev = { .platform_data = &android_pmem_audio_pdata },
412};
413
414static struct msm_handset_platform_data hs_platform_data = {
415 .hs_name = "7k_handset",
416 .pwr_key_delay_ms = 500, /* 0 will disable end key */
417};
418
419static struct platform_device hs_device = {
420 .name = "msm-handset",
421 .id = -1,
422 .dev = {
423 .platform_data = &hs_platform_data,
424 },
425};
426
427/* TSIF begin */
428#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
429
430#define TSIF_B_SYNC GPIO_CFG(87, 5, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
431#define TSIF_B_DATA GPIO_CFG(86, 3, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
432#define TSIF_B_EN GPIO_CFG(85, 3, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
433#define TSIF_B_CLK GPIO_CFG(84, 4, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
434
435static const struct msm_gpio tsif_gpios[] = {
436 { .gpio_cfg = TSIF_B_CLK, .label = "tsif_clk", },
437 { .gpio_cfg = TSIF_B_EN, .label = "tsif_en", },
438 { .gpio_cfg = TSIF_B_DATA, .label = "tsif_data", },
439 { .gpio_cfg = TSIF_B_SYNC, .label = "tsif_sync", },
440};
441
442static struct msm_tsif_platform_data tsif_platform_data = {
443 .num_gpios = ARRAY_SIZE(tsif_gpios),
444 .gpios = tsif_gpios,
Matt Wagantall640e5fd2011-08-17 16:08:53 -0700445 .tsif_clk = "core_clk",
446 .tsif_pclk = "iface_clk",
447 .tsif_ref_clk = "ref_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700448};
449#endif /* defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) */
450/* TSIF end */
451
452#define LCDC_CONFIG_PROC 21
453#define LCDC_UN_CONFIG_PROC 22
454#define LCDC_API_PROG 0x30000066
455#define LCDC_API_VERS 0x00010001
456
457#define GPIO_OUT_132 132
458#define GPIO_OUT_131 131
459#define GPIO_OUT_103 103
460#define GPIO_OUT_102 102
461#define GPIO_OUT_88 88
462
463static struct msm_rpc_endpoint *lcdc_ep;
464
465static int msm_fb_lcdc_config(int on)
466{
467 int rc = 0;
468 struct rpc_request_hdr hdr;
469
470 if (on)
471 pr_info("lcdc config\n");
472 else
473 pr_info("lcdc un-config\n");
474
475 lcdc_ep = msm_rpc_connect_compatible(LCDC_API_PROG, LCDC_API_VERS, 0);
476 if (IS_ERR(lcdc_ep)) {
477 printk(KERN_ERR "%s: msm_rpc_connect failed! rc = %ld\n",
478 __func__, PTR_ERR(lcdc_ep));
479 return -EINVAL;
480 }
481
482 rc = msm_rpc_call(lcdc_ep,
483 (on) ? LCDC_CONFIG_PROC : LCDC_UN_CONFIG_PROC,
484 &hdr, sizeof(hdr),
485 5 * HZ);
486 if (rc)
487 printk(KERN_ERR
488 "%s: msm_rpc_call failed! rc = %d\n", __func__, rc);
489
490 msm_rpc_close(lcdc_ep);
491 return rc;
492}
493
494static int gpio_array_num[] = {
495 GPIO_OUT_132, /* spi_clk */
496 GPIO_OUT_131, /* spi_cs */
497 GPIO_OUT_103, /* spi_sdi */
498 GPIO_OUT_102, /* spi_sdoi */
499 GPIO_OUT_88
500 };
501
502static void lcdc_gordon_gpio_init(void)
503{
504 if (gpio_request(GPIO_OUT_132, "spi_clk"))
505 pr_err("failed to request gpio spi_clk\n");
506 if (gpio_request(GPIO_OUT_131, "spi_cs"))
507 pr_err("failed to request gpio spi_cs\n");
508 if (gpio_request(GPIO_OUT_103, "spi_sdi"))
509 pr_err("failed to request gpio spi_sdi\n");
510 if (gpio_request(GPIO_OUT_102, "spi_sdoi"))
511 pr_err("failed to request gpio spi_sdoi\n");
512 if (gpio_request(GPIO_OUT_88, "gpio_dac"))
513 pr_err("failed to request gpio_dac\n");
514}
515
516static uint32_t lcdc_gpio_table[] = {
517 GPIO_CFG(GPIO_OUT_132, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
518 GPIO_CFG(GPIO_OUT_131, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
519 GPIO_CFG(GPIO_OUT_103, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
520 GPIO_CFG(GPIO_OUT_102, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
521 GPIO_CFG(GPIO_OUT_88, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
522};
523
524static void config_lcdc_gpio_table(uint32_t *table, int len, unsigned enable)
525{
526 int n, rc;
527 for (n = 0; n < len; n++) {
528 rc = gpio_tlmm_config(table[n],
529 enable ? GPIO_CFG_ENABLE : GPIO_CFG_DISABLE);
530 if (rc) {
531 printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n",
532 __func__, table[n], rc);
533 break;
534 }
535 }
536}
537
538static void lcdc_gordon_config_gpios(int enable)
539{
540 config_lcdc_gpio_table(lcdc_gpio_table,
541 ARRAY_SIZE(lcdc_gpio_table), enable);
542}
543
544static char *msm_fb_lcdc_vreg[] = {
545 "gp5"
546};
547
548static int msm_fb_lcdc_power_save(int on)
549{
550 struct vreg *vreg[ARRAY_SIZE(msm_fb_lcdc_vreg)];
551 int i, rc = 0;
552
553 for (i = 0; i < ARRAY_SIZE(msm_fb_lcdc_vreg); i++) {
554 if (on) {
555 vreg[i] = vreg_get(0, msm_fb_lcdc_vreg[i]);
556 rc = vreg_enable(vreg[i]);
557 if (rc) {
558 printk(KERN_ERR "vreg_enable: %s vreg"
559 "operation failed \n",
560 msm_fb_lcdc_vreg[i]);
561 goto bail;
562 }
563 } else {
564 int tmp;
565 vreg[i] = vreg_get(0, msm_fb_lcdc_vreg[i]);
566 tmp = vreg_disable(vreg[i]);
567 if (tmp) {
568 printk(KERN_ERR "vreg_disable: %s vreg "
569 "operation failed \n",
570 msm_fb_lcdc_vreg[i]);
571 if (!rc)
572 rc = tmp;
573 }
574 tmp = gpio_tlmm_config(GPIO_CFG(GPIO_OUT_88, 0,
575 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
576 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
577 if (tmp) {
578 printk(KERN_ERR "gpio_tlmm_config failed\n");
579 if (!rc)
580 rc = tmp;
581 }
582 gpio_set_value(88, 0);
583 mdelay(15);
584 gpio_set_value(88, 1);
585 mdelay(15);
586 }
587 }
588
589 return rc;
590
591bail:
592 if (on) {
593 for (; i > 0; i--)
594 vreg_disable(vreg[i - 1]);
595 }
596
597 return rc;
598}
599static struct lcdc_platform_data lcdc_pdata = {
600 .lcdc_gpio_config = msm_fb_lcdc_config,
601 .lcdc_power_save = msm_fb_lcdc_power_save,
602};
603
604static struct msm_panel_common_pdata lcdc_gordon_panel_data = {
605 .panel_config_gpio = lcdc_gordon_config_gpios,
606 .gpio_num = gpio_array_num,
607};
608
609static struct platform_device lcdc_gordon_panel_device = {
610 .name = "lcdc_gordon_vga",
611 .id = 0,
612 .dev = {
613 .platform_data = &lcdc_gordon_panel_data,
614 }
615};
616
617static struct resource msm_fb_resources[] = {
618 {
619 .flags = IORESOURCE_DMA,
620 }
621};
622
623static int msm_fb_detect_panel(const char *name)
624{
625 int ret = -EPERM;
626
627 if (machine_is_msm7x25_ffa() || machine_is_msm7x27_ffa()) {
628 if (!strcmp(name, "lcdc_gordon_vga"))
629 ret = 0;
630 else
631 ret = -ENODEV;
632 }
633
634 return ret;
635}
636
637static struct msm_fb_platform_data msm_fb_pdata = {
638 .detect_client = msm_fb_detect_panel,
639 .mddi_prescan = 1,
640};
641
642static struct platform_device msm_fb_device = {
643 .name = "msm_fb",
644 .id = 0,
645 .num_resources = ARRAY_SIZE(msm_fb_resources),
646 .resource = msm_fb_resources,
647 .dev = {
648 .platform_data = &msm_fb_pdata,
649 }
650};
651
652#ifdef CONFIG_BT
653static struct platform_device msm_bt_power_device = {
654 .name = "bt_power",
655};
656
657enum {
658 BT_WAKE,
659 BT_RFR,
660 BT_CTS,
661 BT_RX,
662 BT_TX,
663 BT_PCM_DOUT,
664 BT_PCM_DIN,
665 BT_PCM_SYNC,
666 BT_PCM_CLK,
667 BT_HOST_WAKE,
668};
669
670static unsigned bt_config_power_on[] = {
671 GPIO_CFG(42, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* WAKE */
672 GPIO_CFG(43, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* RFR */
673 GPIO_CFG(44, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* CTS */
674 GPIO_CFG(45, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* Rx */
675 GPIO_CFG(46, 3, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* Tx */
676 GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DOUT */
677 GPIO_CFG(69, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DIN */
678 GPIO_CFG(70, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_SYNC */
679 GPIO_CFG(71, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_CLK */
680 GPIO_CFG(83, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* HOST_WAKE */
681};
682static unsigned bt_config_power_off[] = {
683 GPIO_CFG(42, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* WAKE */
684 GPIO_CFG(43, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* RFR */
685 GPIO_CFG(44, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* CTS */
686 GPIO_CFG(45, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* Rx */
687 GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* Tx */
688 GPIO_CFG(68, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCM_DOUT */
689 GPIO_CFG(69, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCM_DIN */
690 GPIO_CFG(70, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCM_SYNC */
691 GPIO_CFG(71, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCM_CLK */
692 GPIO_CFG(83, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HOST_WAKE */
693};
694
695static int bluetooth_power(int on)
696{
697 struct vreg *vreg_bt;
698 int pin, rc;
699
700 printk(KERN_DEBUG "%s\n", __func__);
701
702 /* do not have vreg bt defined, gp6 is the same */
703 /* vreg_get parameter 1 (struct device *) is ignored */
704 vreg_bt = vreg_get(NULL, "gp6");
705
706 if (IS_ERR(vreg_bt)) {
707 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
708 __func__, PTR_ERR(vreg_bt));
709 return PTR_ERR(vreg_bt);
710 }
711
712 if (on) {
713 for (pin = 0; pin < ARRAY_SIZE(bt_config_power_on); pin++) {
714 rc = gpio_tlmm_config(bt_config_power_on[pin],
715 GPIO_CFG_ENABLE);
716 if (rc) {
717 printk(KERN_ERR
718 "%s: gpio_tlmm_config(%#x)=%d\n",
719 __func__, bt_config_power_on[pin], rc);
720 return -EIO;
721 }
722 }
723
724 /* units of mV, steps of 50 mV */
725 rc = vreg_set_level(vreg_bt, 2600);
726 if (rc) {
727 printk(KERN_ERR "%s: vreg set level failed (%d)\n",
728 __func__, rc);
729 return -EIO;
730 }
731 rc = vreg_enable(vreg_bt);
732 if (rc) {
733 printk(KERN_ERR "%s: vreg enable failed (%d)\n",
734 __func__, rc);
735 return -EIO;
736 }
737 } else {
738 rc = vreg_disable(vreg_bt);
739 if (rc) {
740 printk(KERN_ERR "%s: vreg disable failed (%d)\n",
741 __func__, rc);
742 return -EIO;
743 }
744 for (pin = 0; pin < ARRAY_SIZE(bt_config_power_off); pin++) {
745 rc = gpio_tlmm_config(bt_config_power_off[pin],
746 GPIO_CFG_ENABLE);
747 if (rc) {
748 printk(KERN_ERR
749 "%s: gpio_tlmm_config(%#x)=%d\n",
750 __func__, bt_config_power_off[pin], rc);
751 return -EIO;
752 }
753 }
754 }
755 return 0;
756}
757
758static void __init bt_power_init(void)
759{
760 msm_bt_power_device.dev.platform_data = &bluetooth_power;
761}
762#else
763#define bt_power_init(x) do {} while (0)
764#endif
765
766static struct platform_device msm_device_pmic_leds = {
767 .name = "pmic-leds",
768 .id = -1,
769};
770
771static struct resource bluesleep_resources[] = {
772 {
773 .name = "gpio_host_wake",
774 .start = 83,
775 .end = 83,
776 .flags = IORESOURCE_IO,
777 },
778 {
779 .name = "gpio_ext_wake",
780 .start = 42,
781 .end = 42,
782 .flags = IORESOURCE_IO,
783 },
784 {
785 .name = "host_wake",
786 .start = MSM_GPIO_TO_INT(83),
787 .end = MSM_GPIO_TO_INT(83),
788 .flags = IORESOURCE_IRQ,
789 },
790};
791
792static struct platform_device msm_bluesleep_device = {
793 .name = "bluesleep",
794 .id = -1,
795 .num_resources = ARRAY_SIZE(bluesleep_resources),
796 .resource = bluesleep_resources,
797};
798
799static struct i2c_board_info i2c_devices[] = {
800#ifdef CONFIG_MT9D112
801 {
802 I2C_BOARD_INFO("mt9d112", 0x78 >> 1),
803 },
804#endif
805#ifdef CONFIG_S5K3E2FX
806 {
807 I2C_BOARD_INFO("s5k3e2fx", 0x20 >> 1),
808 },
809#endif
810#ifdef CONFIG_MT9P012
811 {
812 I2C_BOARD_INFO("mt9p012", 0x6C >> 1),
813 },
814#endif
815#ifdef CONFIG_MT9P012_KM
816 {
817 I2C_BOARD_INFO("mt9p012_km", 0x6C >> 2),
818 },
819#endif
820#if defined(CONFIG_MT9T013) || defined(CONFIG_SENSORS_MT9T013)
821 {
822 I2C_BOARD_INFO("mt9t013", 0x6C),
823 },
824#endif
825#ifdef CONFIG_VB6801
826 {
827 I2C_BOARD_INFO("vb6801", 0x20),
828 },
829#endif
830};
831
832#ifdef CONFIG_MSM_CAMERA
833static uint32_t camera_off_gpio_table[] = {
834 /* parallel CAMERA interfaces */
835 GPIO_CFG(0, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT0 */
836 GPIO_CFG(1, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT1 */
837 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */
838 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */
839 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */
840 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */
841 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */
842 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */
843 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */
844 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */
845 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */
846 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */
847 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCLK */
848 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */
849 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */
850 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* MCLK */
851};
852
853static uint32_t camera_on_gpio_table[] = {
854 /* parallel CAMERA interfaces */
855 GPIO_CFG(0, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT0 */
856 GPIO_CFG(1, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT1 */
857 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */
858 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */
859 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */
860 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */
861 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */
862 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */
863 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */
864 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */
865 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */
866 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */
867 GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_16MA), /* PCLK */
868 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */
869 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */
870 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_16MA), /* MCLK */
871 };
872
873static void config_gpio_table(uint32_t *table, int len)
874{
875 int n, rc;
876 for (n = 0; n < len; n++) {
877 rc = gpio_tlmm_config(table[n], GPIO_CFG_ENABLE);
878 if (rc) {
879 printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n",
880 __func__, table[n], rc);
881 break;
882 }
883 }
884}
885
886static struct vreg *vreg_gp2;
887static struct vreg *vreg_gp3;
888
889static void msm_camera_vreg_config(int vreg_en)
890{
891 int rc;
892
893 if (vreg_gp2 == NULL) {
894 vreg_gp2 = vreg_get(NULL, "gp2");
895 if (IS_ERR(vreg_gp2)) {
896 printk(KERN_ERR "%s: vreg_get(%s) failed (%ld)\n",
897 __func__, "gp2", PTR_ERR(vreg_gp2));
898 return;
899 }
900
901 rc = vreg_set_level(vreg_gp2, 1800);
902 if (rc) {
903 printk(KERN_ERR "%s: GP2 set_level failed (%d)\n",
904 __func__, rc);
905 }
906 }
907
908 if (vreg_gp3 == NULL) {
909 vreg_gp3 = vreg_get(NULL, "gp3");
910 if (IS_ERR(vreg_gp3)) {
911 printk(KERN_ERR "%s: vreg_get(%s) failed (%ld)\n",
912 __func__, "gp3", PTR_ERR(vreg_gp3));
913 return;
914 }
915
916 rc = vreg_set_level(vreg_gp3, 2850);
917 if (rc) {
918 printk(KERN_ERR "%s: GP3 set level failed (%d)\n",
919 __func__, rc);
920 }
921 }
922
923 if (vreg_en) {
924 rc = vreg_enable(vreg_gp2);
925 if (rc) {
926 printk(KERN_ERR "%s: GP2 enable failed (%d)\n",
927 __func__, rc);
928 }
929
930 rc = vreg_enable(vreg_gp3);
931 if (rc) {
932 printk(KERN_ERR "%s: GP3 enable failed (%d)\n",
933 __func__, rc);
934 }
935 } else {
936 rc = vreg_disable(vreg_gp2);
937 if (rc) {
938 printk(KERN_ERR "%s: GP2 disable failed (%d)\n",
939 __func__, rc);
940 }
941
942 rc = vreg_disable(vreg_gp3);
943 if (rc) {
944 printk(KERN_ERR "%s: GP3 disable failed (%d)\n",
945 __func__, rc);
946 }
947 }
948}
949
950static int config_camera_on_gpios(void)
951{
952 int vreg_en = 1;
953
954 if (machine_is_msm7x25_ffa() ||
955 machine_is_msm7x27_ffa())
956 msm_camera_vreg_config(vreg_en);
957
958 config_gpio_table(camera_on_gpio_table,
959 ARRAY_SIZE(camera_on_gpio_table));
960 return 0;
961}
962
963static void config_camera_off_gpios(void)
964{
965 int vreg_en = 0;
966
967 if (machine_is_msm7x25_ffa() ||
968 machine_is_msm7x27_ffa())
969 msm_camera_vreg_config(vreg_en);
970
971 config_gpio_table(camera_off_gpio_table,
972 ARRAY_SIZE(camera_off_gpio_table));
973}
974
975static struct msm_camera_device_platform_data msm_camera_device_data = {
976 .camera_gpio_on = config_camera_on_gpios,
977 .camera_gpio_off = config_camera_off_gpios,
978 .ioext.mdcphy = MSM_MDC_PHYS,
979 .ioext.mdcsz = MSM_MDC_SIZE,
980 .ioext.appphy = MSM_CLK_CTL_PHYS,
981 .ioext.appsz = MSM_CLK_CTL_SIZE,
982};
983
984int pmic_set_flash_led_current(enum pmic8058_leds id, unsigned mA)
985{
986 int rc;
987 rc = pmic_flash_led_set_current(mA);
988 return rc;
989}
990
991static struct msm_camera_sensor_flash_src msm_flash_src = {
992 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PMIC,
993 ._fsrc.pmic_src.num_of_src = 1,
994 ._fsrc.pmic_src.low_current = 30,
995 ._fsrc.pmic_src.high_current = 100,
996 ._fsrc.pmic_src.led_src_1 = 0,
997 ._fsrc.pmic_src.led_src_2 = 0,
998 ._fsrc.pmic_src.pmic_set_current = pmic_set_flash_led_current,
999};
1000
1001#ifdef CONFIG_MT9D112
1002static struct msm_camera_sensor_flash_data flash_mt9d112 = {
1003 .flash_type = MSM_CAMERA_FLASH_LED,
1004 .flash_src = &msm_flash_src
1005};
1006
1007static struct msm_camera_sensor_info msm_camera_sensor_mt9d112_data = {
1008 .sensor_name = "mt9d112",
1009 .sensor_reset = 89,
1010 .sensor_pwd = 85,
1011 .vcm_pwd = 0,
1012 .vcm_enable = 0,
1013 .pdata = &msm_camera_device_data,
1014 .flash_data = &flash_mt9d112
1015};
1016
1017static struct platform_device msm_camera_sensor_mt9d112 = {
1018 .name = "msm_camera_mt9d112",
1019 .dev = {
1020 .platform_data = &msm_camera_sensor_mt9d112_data,
1021 },
1022};
1023#endif
1024
1025#ifdef CONFIG_S5K3E2FX
1026static struct msm_camera_sensor_flash_data flash_s5k3e2fx = {
1027 .flash_type = MSM_CAMERA_FLASH_LED,
1028 .flash_src = &msm_flash_src
1029};
1030
1031static struct msm_camera_sensor_info msm_camera_sensor_s5k3e2fx_data = {
1032 .sensor_name = "s5k3e2fx",
1033 .sensor_reset = 89,
1034 .sensor_pwd = 85,
1035 .vcm_pwd = 0,
1036 .vcm_enable = 0,
1037 .pdata = &msm_camera_device_data,
1038 .flash_data = &flash_s5k3e2fx
1039};
1040
1041static struct platform_device msm_camera_sensor_s5k3e2fx = {
1042 .name = "msm_camera_s5k3e2fx",
1043 .dev = {
1044 .platform_data = &msm_camera_sensor_s5k3e2fx_data,
1045 },
1046};
1047#endif
1048
1049#ifdef CONFIG_MT9P012
1050static struct msm_camera_sensor_flash_data flash_mt9p012 = {
1051 .flash_type = MSM_CAMERA_FLASH_LED,
1052 .flash_src = &msm_flash_src
1053};
1054
1055static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_data = {
1056 .sensor_name = "mt9p012",
1057 .sensor_reset = 89,
1058 .sensor_pwd = 85,
1059 .vcm_pwd = 88,
1060 .vcm_enable = 0,
1061 .pdata = &msm_camera_device_data,
1062 .flash_data = &flash_mt9p012
1063};
1064
1065static struct platform_device msm_camera_sensor_mt9p012 = {
1066 .name = "msm_camera_mt9p012",
1067 .dev = {
1068 .platform_data = &msm_camera_sensor_mt9p012_data,
1069 },
1070};
1071#endif
1072
1073#ifdef CONFIG_MT9P012_KM
1074static struct msm_camera_sensor_flash_data flash_mt9p012_km = {
1075 .flash_type = MSM_CAMERA_FLASH_LED,
1076 .flash_src = &msm_flash_src
1077};
1078
1079static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_km_data = {
1080 .sensor_name = "mt9p012_km",
1081 .sensor_reset = 89,
1082 .sensor_pwd = 85,
1083 .vcm_pwd = 88,
1084 .vcm_enable = 0,
1085 .pdata = &msm_camera_device_data,
1086 .flash_data = &flash_mt9p012_km
1087};
1088
1089static struct platform_device msm_camera_sensor_mt9p012_km = {
1090 .name = "msm_camera_mt9p012_km",
1091 .dev = {
1092 .platform_data = &msm_camera_sensor_mt9p012_km_data,
1093 },
1094};
1095#endif
1096
1097#ifdef CONFIG_MT9T013
1098static struct msm_camera_sensor_flash_data flash_mt9t013 = {
1099 .flash_type = MSM_CAMERA_FLASH_LED,
1100 .flash_src = &msm_flash_src
1101};
1102
1103static struct msm_camera_sensor_info msm_camera_sensor_mt9t013_data = {
1104 .sensor_name = "mt9t013",
1105 .sensor_reset = 89,
1106 .sensor_pwd = 85,
1107 .vcm_pwd = 0,
1108 .vcm_enable = 0,
1109 .pdata = &msm_camera_device_data,
1110 .flash_data = &flash_mt9t013
1111};
1112
1113static struct platform_device msm_camera_sensor_mt9t013 = {
1114 .name = "msm_camera_mt9t013",
1115 .dev = {
1116 .platform_data = &msm_camera_sensor_mt9t013_data,
1117 },
1118};
1119#endif
1120
1121#ifdef CONFIG_VB6801
1122static struct msm_camera_sensor_flash_data flash_vb6801 = {
1123 .flash_type = MSM_CAMERA_FLASH_LED,
1124 .flash_src = &msm_flash_src
1125};
1126
1127static struct msm_camera_sensor_info msm_camera_sensor_vb6801_data = {
1128 .sensor_name = "vb6801",
1129 .sensor_reset = 89,
1130 .sensor_pwd = 88,
1131 .vcm_pwd = 0,
1132 .vcm_enable = 0,
1133 .pdata = &msm_camera_device_data,
1134 .flash_data = &flash_vb6801
1135};
1136
1137static struct platform_device msm_camera_sensor_vb6801 = {
1138 .name = "msm_camera_vb6801",
1139 .dev = {
1140 .platform_data = &msm_camera_sensor_vb6801_data,
1141 },
1142};
1143#endif
1144#endif
1145
1146static u32 msm_calculate_batt_capacity(u32 current_voltage);
1147
1148static struct msm_psy_batt_pdata msm_psy_batt_data = {
1149 .voltage_min_design = 2800,
1150 .voltage_max_design = 4300,
1151 .avail_chg_sources = AC_CHG | USB_CHG ,
1152 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
1153 .calculate_capacity = &msm_calculate_batt_capacity,
1154};
1155
1156static u32 msm_calculate_batt_capacity(u32 current_voltage)
1157{
1158 u32 low_voltage = msm_psy_batt_data.voltage_min_design;
1159 u32 high_voltage = msm_psy_batt_data.voltage_max_design;
1160
1161 return (current_voltage - low_voltage) * 100
1162 / (high_voltage - low_voltage);
1163}
1164
1165static struct platform_device msm_batt_device = {
1166 .name = "msm-battery",
1167 .id = -1,
1168 .dev.platform_data = &msm_psy_batt_data,
1169};
1170
1171
Daniel Walker2682fd32010-02-24 15:47:58 -08001172static struct platform_device *devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001173 &asoc_msm_pcm,
1174 &asoc_msm_dai0,
1175 &asoc_msm_dai1,
1176
Daniel Walker2682fd32010-02-24 15:47:58 -08001177 &msm_device_smd,
1178 &msm_device_dmov,
1179 &msm_device_nand,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001180
1181#ifdef CONFIG_USB_MSM_OTG_72K
1182 &msm_device_otg,
1183#ifdef CONFIG_USB_GADGET
1184 &msm_device_gadget_peripheral,
1185#endif
1186#endif
1187
Manu Gautam99ed3912011-10-13 18:00:55 +05301188#ifdef CONFIG_USB_G_ANDROID
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001189 &android_usb_device,
1190#endif
Manu Gautam99ed3912011-10-13 18:00:55 +05301191
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001192 &msm_device_i2c,
Daniel Walker2682fd32010-02-24 15:47:58 -08001193 &smc91x_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001194 &msm_device_tssc,
1195 &android_pmem_device,
1196 &android_pmem_adsp_device,
1197 &android_pmem_audio_device,
1198 &msm_fb_device,
1199 &lcdc_gordon_panel_device,
1200 &msm_device_uart_dm1,
1201#ifdef CONFIG_BT
1202 &msm_bt_power_device,
1203#endif
1204 &msm_device_pmic_leds,
1205 &msm_device_snd,
1206 &msm_device_adspdec,
1207#ifdef CONFIG_MT9T013
1208 &msm_camera_sensor_mt9t013,
1209#endif
1210#ifdef CONFIG_MT9D112
1211 &msm_camera_sensor_mt9d112,
1212#endif
1213#ifdef CONFIG_S5K3E2FX
1214 &msm_camera_sensor_s5k3e2fx,
1215#endif
1216#ifdef CONFIG_MT9P012
1217 &msm_camera_sensor_mt9p012,
1218#endif
1219#ifdef CONFIG_MT9P012_KM
1220 &msm_camera_sensor_mt9p012_km,
1221#endif
1222#ifdef CONFIG_VB6801
1223 &msm_camera_sensor_vb6801,
1224#endif
1225 &msm_bluesleep_device,
1226#ifdef CONFIG_ARCH_MSM7X27
1227 &msm_kgsl_3d0,
1228#endif
1229#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
1230 &msm_device_tsif,
1231#endif
1232 &hs_device,
1233 &msm_batt_device,
Daniel Walker2682fd32010-02-24 15:47:58 -08001234};
1235
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001236static struct msm_panel_common_pdata mdp_pdata = {
1237 .gpio = 97,
Ravishangar Kalyanam07ef7882011-08-09 15:50:48 -07001238 .mdp_rev = MDP_REV_30,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001239};
1240
1241static void __init msm_fb_add_devices(void)
1242{
1243 msm_fb_register_device("mdp", &mdp_pdata);
1244 msm_fb_register_device("pmdh", 0);
1245 msm_fb_register_device("lcdc", &lcdc_pdata);
1246}
1247
Daniel Walker2682fd32010-02-24 15:47:58 -08001248extern struct sys_timer msm_timer;
1249
1250static void __init msm7x2x_init_irq(void)
1251{
1252 msm_init_irq();
1253}
1254
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001255void msm_serial_debug_init(unsigned int base, int irq,
1256 struct device *clk_device, int signal_irq);
1257
1258#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
1259 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
1260 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
1261 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT))
1262
1263static unsigned long vreg_sts, gpio_sts;
1264static struct vreg *vreg_mmc;
1265static unsigned mpp_mmc = 2;
1266
1267struct sdcc_gpio {
1268 struct msm_gpio *cfg_data;
1269 uint32_t size;
1270 struct msm_gpio *sleep_cfg_data;
1271};
1272
1273static struct msm_gpio sdc1_cfg_data[] = {
1274 {GPIO_CFG(51, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_3"},
1275 {GPIO_CFG(52, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_2"},
1276 {GPIO_CFG(53, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_1"},
1277 {GPIO_CFG(54, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_0"},
1278 {GPIO_CFG(55, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_cmd"},
1279 {GPIO_CFG(56, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "sdc1_clk"},
1280};
1281
1282static struct msm_gpio sdc2_cfg_data[] = {
1283 {GPIO_CFG(62, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "sdc2_clk"},
1284 {GPIO_CFG(63, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_cmd"},
1285 {GPIO_CFG(64, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_3"},
1286 {GPIO_CFG(65, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_2"},
1287 {GPIO_CFG(66, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_1"},
1288 {GPIO_CFG(67, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_0"},
1289};
1290
1291static struct msm_gpio sdc2_sleep_cfg_data[] = {
1292 {GPIO_CFG(62, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "sdc2_clk"},
1293 {GPIO_CFG(63, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "sdc2_cmd"},
1294 {GPIO_CFG(64, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "sdc2_dat_3"},
1295 {GPIO_CFG(65, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "sdc2_dat_2"},
1296 {GPIO_CFG(66, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "sdc2_dat_1"},
1297 {GPIO_CFG(67, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "sdc2_dat_0"},
1298};
1299static struct msm_gpio sdc3_cfg_data[] = {
1300 {GPIO_CFG(88, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "sdc3_clk"},
1301 {GPIO_CFG(89, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_cmd"},
1302 {GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_3"},
1303 {GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_2"},
1304 {GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_1"},
1305 {GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_0"},
1306};
1307
1308static struct msm_gpio sdc4_cfg_data[] = {
1309 {GPIO_CFG(19, 3, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_3"},
1310 {GPIO_CFG(20, 3, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_2"},
1311 {GPIO_CFG(21, 4, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_1"},
1312 {GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_cmd"},
1313 {GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_0"},
1314 {GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "sdc4_clk"},
1315};
1316
1317static struct sdcc_gpio sdcc_cfg_data[] = {
1318 {
1319 .cfg_data = sdc1_cfg_data,
1320 .size = ARRAY_SIZE(sdc1_cfg_data),
1321 .sleep_cfg_data = NULL,
1322 },
1323 {
1324 .cfg_data = sdc2_cfg_data,
1325 .size = ARRAY_SIZE(sdc2_cfg_data),
1326 .sleep_cfg_data = sdc2_sleep_cfg_data,
1327 },
1328 {
1329 .cfg_data = sdc3_cfg_data,
1330 .size = ARRAY_SIZE(sdc3_cfg_data),
1331 .sleep_cfg_data = NULL,
1332 },
1333 {
1334 .cfg_data = sdc4_cfg_data,
1335 .size = ARRAY_SIZE(sdc4_cfg_data),
1336 .sleep_cfg_data = NULL,
1337 },
1338};
1339
1340static void msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
1341{
1342 int rc = 0;
1343 struct sdcc_gpio *curr;
1344
1345 curr = &sdcc_cfg_data[dev_id - 1];
1346 if (!(test_bit(dev_id, &gpio_sts)^enable))
1347 return;
1348
1349 if (enable) {
1350 set_bit(dev_id, &gpio_sts);
1351 rc = msm_gpios_request_enable(curr->cfg_data, curr->size);
1352 if (rc)
1353 printk(KERN_ERR "%s: Failed to turn on GPIOs for slot %d\n",
1354 __func__, dev_id);
1355 } else {
1356 clear_bit(dev_id, &gpio_sts);
1357 if (curr->sleep_cfg_data) {
1358 msm_gpios_enable(curr->sleep_cfg_data, curr->size);
1359 msm_gpios_free(curr->sleep_cfg_data, curr->size);
1360 return;
1361 }
1362 msm_gpios_disable_free(curr->cfg_data, curr->size);
1363 }
1364}
1365
1366static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
1367{
1368 int rc = 0;
1369 struct platform_device *pdev;
1370
1371 pdev = container_of(dv, struct platform_device, dev);
1372 msm_sdcc_setup_gpio(pdev->id, !!vdd);
1373
1374 if (vdd == 0) {
1375 if (!vreg_sts)
1376 return 0;
1377
1378 clear_bit(pdev->id, &vreg_sts);
1379
1380 if (!vreg_sts) {
1381 if (machine_is_msm7x25_ffa() ||
1382 machine_is_msm7x27_ffa()) {
1383 rc = mpp_config_digital_out(mpp_mmc,
1384 MPP_CFG(MPP_DLOGIC_LVL_MSMP,
1385 MPP_DLOGIC_OUT_CTRL_LOW));
1386 } else
1387 rc = vreg_disable(vreg_mmc);
1388 if (rc)
1389 printk(KERN_ERR "%s: return val: %d \n",
1390 __func__, rc);
1391 }
1392 return 0;
1393 }
1394
1395 if (!vreg_sts) {
1396 if (machine_is_msm7x25_ffa() || machine_is_msm7x27_ffa()) {
1397 rc = mpp_config_digital_out(mpp_mmc,
1398 MPP_CFG(MPP_DLOGIC_LVL_MSMP,
1399 MPP_DLOGIC_OUT_CTRL_HIGH));
1400 } else {
1401 rc = vreg_set_level(vreg_mmc, 2850);
1402 if (!rc)
1403 rc = vreg_enable(vreg_mmc);
1404 }
1405 if (rc)
1406 printk(KERN_ERR "%s: return val: %d \n",
1407 __func__, rc);
1408 }
1409 set_bit(pdev->id, &vreg_sts);
1410 return 0;
1411}
1412
1413#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
1414static struct mmc_platform_data msm7x2x_sdc1_data = {
1415 .ocr_mask = MMC_VDD_28_29,
1416 .translate_vdd = msm_sdcc_setup_power,
1417 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
1418 .msmsdcc_fmin = 144000,
1419 .msmsdcc_fmid = 24576000,
1420 .msmsdcc_fmax = 49152000,
1421 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001422};
1423#endif
1424
1425#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
1426static struct mmc_platform_data msm7x2x_sdc2_data = {
1427 .ocr_mask = MMC_VDD_28_29,
1428 .translate_vdd = msm_sdcc_setup_power,
1429 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
1430#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
1431 .sdiowakeup_irq = MSM_GPIO_TO_INT(66),
1432#endif
1433 .msmsdcc_fmin = 144000,
1434 .msmsdcc_fmid = 24576000,
1435 .msmsdcc_fmax = 49152000,
1436 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001437};
1438#endif
1439
1440#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
1441static struct mmc_platform_data msm7x2x_sdc3_data = {
1442 .ocr_mask = MMC_VDD_28_29,
1443 .translate_vdd = msm_sdcc_setup_power,
1444 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
1445 .msmsdcc_fmin = 144000,
1446 .msmsdcc_fmid = 24576000,
1447 .msmsdcc_fmax = 49152000,
1448 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001449};
1450#endif
1451
1452#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
1453static struct mmc_platform_data msm7x2x_sdc4_data = {
1454 .ocr_mask = MMC_VDD_28_29,
1455 .translate_vdd = msm_sdcc_setup_power,
1456 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
1457 .msmsdcc_fmin = 144000,
1458 .msmsdcc_fmid = 24576000,
1459 .msmsdcc_fmax = 49152000,
1460 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001461};
1462#endif
1463
1464static void __init msm7x2x_init_mmc(void)
1465{
1466 if (!machine_is_msm7x25_ffa() && !machine_is_msm7x27_ffa()) {
1467 vreg_mmc = vreg_get(NULL, "mmc");
1468 if (IS_ERR(vreg_mmc)) {
1469 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
1470 __func__, PTR_ERR(vreg_mmc));
1471 return;
1472 }
1473 }
1474
1475#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
1476 msm_add_sdcc(1, &msm7x2x_sdc1_data);
1477#endif
1478
1479 if (machine_is_msm7x25_surf() || machine_is_msm7x27_surf() ||
1480 machine_is_msm7x27_ffa()) {
1481#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
1482 msm_sdcc_setup_gpio(2, 1);
1483 msm_add_sdcc(2, &msm7x2x_sdc2_data);
1484#endif
1485 }
1486
1487 if (machine_is_msm7x25_surf() || machine_is_msm7x27_surf()) {
1488#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
1489 msm_add_sdcc(3, &msm7x2x_sdc3_data);
1490#endif
1491#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
1492 msm_add_sdcc(4, &msm7x2x_sdc4_data);
1493#endif
1494 }
1495}
1496#else
1497#define msm7x2x_init_mmc() do {} while (0)
1498#endif
1499
1500
1501static struct msm_pm_platform_data msm7x25_pm_data[MSM_PM_SLEEP_MODE_NR] = {
1502 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE].latency = 16000,
1503
1504 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN].latency = 12000,
1505
1506 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency = 2000,
1507};
1508
1509static struct msm_pm_platform_data msm7x27_pm_data[MSM_PM_SLEEP_MODE_NR] = {
1510 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = {
1511 .idle_supported = 1,
1512 .suspend_supported = 1,
1513 .idle_enabled = 1,
1514 .suspend_enabled = 1,
1515 .latency = 16000,
1516 .residency = 20000,
1517 },
1518
1519 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] = {
1520 .idle_supported = 1,
1521 .suspend_supported = 1,
1522 .idle_enabled = 1,
1523 .suspend_enabled = 1,
1524 .latency = 12000,
1525 .residency = 20000,
1526 },
1527
1528 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT] = {
1529 .idle_supported = 1,
1530 .suspend_supported = 1,
1531 .idle_enabled = 1,
1532 .suspend_enabled = 1,
1533 .latency = 2000,
1534 .residency = 0,
1535 },
1536};
1537
1538static void
1539msm_i2c_gpio_config(int iface, int config_type)
1540{
1541 int gpio_scl;
1542 int gpio_sda;
1543 if (iface) {
1544 gpio_scl = 95;
1545 gpio_sda = 96;
1546 } else {
1547 gpio_scl = 60;
1548 gpio_sda = 61;
1549 }
1550 if (config_type) {
1551 gpio_tlmm_config(GPIO_CFG(gpio_scl, 1, GPIO_CFG_INPUT,
1552 GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE);
1553 gpio_tlmm_config(GPIO_CFG(gpio_sda, 1, GPIO_CFG_INPUT,
1554 GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE);
1555 } else {
1556 gpio_tlmm_config(GPIO_CFG(gpio_scl, 0, GPIO_CFG_OUTPUT,
1557 GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE);
1558 gpio_tlmm_config(GPIO_CFG(gpio_sda, 0, GPIO_CFG_OUTPUT,
1559 GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE);
1560 }
1561}
1562
1563static struct msm_i2c_platform_data msm_i2c_pdata = {
1564 .clk_freq = 100000,
1565 .rmutex = 0,
1566 .pri_clk = 60,
1567 .pri_dat = 61,
1568 .aux_clk = 95,
1569 .aux_dat = 96,
1570 .msm_i2c_config_gpio = msm_i2c_gpio_config,
1571};
1572
1573static void __init msm_device_i2c_init(void)
1574{
1575 if (gpio_request(60, "i2c_pri_clk"))
1576 pr_err("failed to request gpio i2c_pri_clk\n");
1577 if (gpio_request(61, "i2c_pri_dat"))
1578 pr_err("failed to request gpio i2c_pri_dat\n");
1579 if (gpio_request(95, "i2c_sec_clk"))
1580 pr_err("failed to request gpio i2c_sec_clk\n");
1581 if (gpio_request(96, "i2c_sec_dat"))
1582 pr_err("failed to request gpio i2c_sec_dat\n");
1583
1584 if (cpu_is_msm7x27())
1585 msm_i2c_pdata.pm_lat =
1586 msm7x27_pm_data[MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN]
1587 .latency;
1588 else
1589 msm_i2c_pdata.pm_lat =
1590 msm7x25_pm_data[MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN]
1591 .latency;
1592
1593 msm_device_i2c.dev.platform_data = &msm_i2c_pdata;
1594}
1595
1596static void usb_mpp_init(void)
1597{
1598 unsigned rc;
1599 unsigned mpp_usb = 7;
1600
1601 if (machine_is_msm7x25_ffa() || machine_is_msm7x27_ffa()) {
1602 rc = mpp_config_digital_out(mpp_usb,
1603 MPP_CFG(MPP_DLOGIC_LVL_VDD,
1604 MPP_DLOGIC_OUT_CTRL_HIGH));
1605 if (rc)
1606 pr_err("%s: configuring mpp pin"
1607 "to enable 3.3V LDO failed\n", __func__);
1608 }
1609}
1610
1611static void msm7x27_wlan_init(void)
1612{
1613 int rc = 0;
1614 /* TBD: if (machine_is_msm7x27_ffa_with_wcn1312()) */
1615 if (machine_is_msm7x27_ffa()) {
1616 rc = mpp_config_digital_out(3, MPP_CFG(MPP_DLOGIC_LVL_MSMP,
1617 MPP_DLOGIC_OUT_CTRL_LOW));
1618 if (rc)
1619 printk(KERN_ERR "%s: return val: %d \n",
1620 __func__, rc);
1621 }
1622}
1623
Daniel Walker2682fd32010-02-24 15:47:58 -08001624static void __init msm7x2x_init(void)
1625{
Daniel Walker2682fd32010-02-24 15:47:58 -08001626
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001627#ifdef CONFIG_ARCH_MSM7X25
1628 msm_clock_init(msm_clocks_7x25, msm_num_clocks_7x25);
1629#elif defined(CONFIG_ARCH_MSM7X27)
Stephen Boydbb600ae2011-08-02 20:11:40 -07001630 msm_clock_init(&msm7x27_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001631#endif
1632
1633#if defined(CONFIG_SMC91X)
Daniel Walker2682fd32010-02-24 15:47:58 -08001634 if (machine_is_msm7x25_ffa() || machine_is_msm7x27_ffa()) {
1635 smc91x_resources[0].start = 0x98000300;
1636 smc91x_resources[0].end = 0x980003ff;
1637 smc91x_resources[1].start = MSM_GPIO_TO_INT(85);
1638 smc91x_resources[1].end = MSM_GPIO_TO_INT(85);
1639 if (gpio_tlmm_config(GPIO_CFG(85, 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001640 GPIO_CFG_INPUT,
1641 GPIO_CFG_PULL_DOWN,
1642 GPIO_CFG_2MA),
1643 GPIO_CFG_ENABLE)) {
Daniel Walker2682fd32010-02-24 15:47:58 -08001644 printk(KERN_ERR
1645 "%s: Err: Config GPIO-85 INT\n",
1646 __func__);
1647 }
1648 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001649#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001650 if (cpu_is_msm7x27())
Matt Wagantallec57f062011-08-16 23:54:46 -07001651 acpuclk_init(&acpuclk_7x27_soc_data);
1652 else
1653 acpuclk_init(&acpuclk_7201_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001654
1655 usb_mpp_init();
1656
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001657
1658#ifdef CONFIG_USB_MSM_OTG_72K
1659 msm_device_otg.dev.platform_data = &msm_otg_pdata;
1660 if (machine_is_msm7x25_surf() || machine_is_msm7x25_ffa()) {
1661 msm_otg_pdata.pemp_level =
1662 PRE_EMPHASIS_WITH_20_PERCENT;
1663 msm_otg_pdata.drv_ampl = HS_DRV_AMPLITUDE_5_PERCENT;
1664 msm_otg_pdata.cdr_autoreset = CDR_AUTO_RESET_ENABLE;
1665 msm_otg_pdata.phy_reset = msm_otg_rpc_phy_reset;
1666 }
1667 if (machine_is_msm7x27_surf() || machine_is_msm7x27_ffa()) {
1668 msm_otg_pdata.pemp_level =
1669 PRE_EMPHASIS_WITH_10_PERCENT;
1670 msm_otg_pdata.drv_ampl = HS_DRV_AMPLITUDE_5_PERCENT;
1671 msm_otg_pdata.cdr_autoreset = CDR_AUTO_RESET_DISABLE;
1672 msm_otg_pdata.phy_reset_sig_inverted = 1;
1673 }
1674
1675#ifdef CONFIG_USB_GADGET
1676 msm_otg_pdata.swfi_latency =
1677 msm7x27_pm_data
1678 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
1679 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
1680 msm_gadget_pdata.is_phy_status_timer_on = 1;
1681#endif
1682#endif
1683#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
1684 msm_device_tsif.dev.platform_data = &tsif_platform_data;
1685#endif
1686 platform_add_devices(msm_footswitch_devices,
1687 msm_num_footswitch_devices);
Daniel Walker2682fd32010-02-24 15:47:58 -08001688 platform_add_devices(devices, ARRAY_SIZE(devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001689#ifdef CONFIG_MSM_CAMERA
1690 config_camera_off_gpios(); /* might not be necessary */
1691#endif
1692 msm_device_i2c_init();
1693 i2c_register_board_info(0, i2c_devices, ARRAY_SIZE(i2c_devices));
1694
1695#ifdef CONFIG_SURF_FFA_GPIO_KEYPAD
1696 if (machine_is_msm7x25_ffa() || machine_is_msm7x27_ffa())
1697 platform_device_register(&keypad_device_7k_ffa);
1698 else
1699 platform_device_register(&keypad_device_surf);
1700#endif
1701 lcdc_gordon_gpio_init();
1702 msm_fb_add_devices();
1703#ifdef CONFIG_USB_EHCI_MSM_72K
1704 msm7x2x_init_host();
1705#endif
1706 msm7x2x_init_mmc();
1707 bt_power_init();
1708
1709 if (cpu_is_msm7x27())
1710 msm_pm_set_platform_data(msm7x27_pm_data,
1711 ARRAY_SIZE(msm7x27_pm_data));
1712 else
1713 msm_pm_set_platform_data(msm7x25_pm_data,
1714 ARRAY_SIZE(msm7x25_pm_data));
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -06001715
1716 BUG_ON(msm_pm_boot_init(MSM_PM_BOOT_CONFIG_RESET_VECTOR,
1717 ioremap(0, PAGE_SIZE)));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001718 msm7x27_wlan_init();
1719}
1720
1721static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE;
1722static int __init pmem_kernel_ebi1_size_setup(char *p)
1723{
1724 pmem_kernel_ebi1_size = memparse(p, NULL);
1725 return 0;
1726}
1727early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
1728
1729static unsigned pmem_mdp_size = MSM_PMEM_MDP_SIZE;
1730static int __init pmem_mdp_size_setup(char *p)
1731{
1732 pmem_mdp_size = memparse(p, NULL);
1733 return 0;
1734}
1735early_param("pmem_mdp_size", pmem_mdp_size_setup);
1736
1737static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
1738static int __init pmem_adsp_size_setup(char *p)
1739{
1740 pmem_adsp_size = memparse(p, NULL);
1741 return 0;
1742}
1743early_param("pmem_adsp_size", pmem_adsp_size_setup);
1744
1745static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
1746static int __init pmem_audio_size_setup(char *p)
1747{
1748 pmem_audio_size = memparse(p, NULL);
1749 return 0;
1750}
1751early_param("pmem_audio_size", pmem_audio_size_setup);
1752
1753static unsigned fb_size = MSM_FB_SIZE;
1754static int __init fb_size_setup(char *p)
1755{
1756 fb_size = memparse(p, NULL);
1757 return 0;
1758}
1759early_param("fb_size", fb_size_setup);
1760
1761static void __init msm_msm7x2x_allocate_memory_regions(void)
1762{
1763 void *addr;
1764 unsigned long size;
1765
1766 size = fb_size ? : MSM_FB_SIZE;
1767 addr = alloc_bootmem_align(size, 0x1000);
1768 msm_fb_resources[0].start = __pa(addr);
1769 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
1770 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
1771 size, addr, __pa(addr));
1772}
1773
1774static struct memtype_reserve msm7x27_reserve_table[] __initdata = {
1775 [MEMTYPE_SMI] = {
1776 },
1777 [MEMTYPE_EBI0] = {
1778 .flags = MEMTYPE_FLAGS_1M_ALIGN,
1779 },
1780 [MEMTYPE_EBI1] = {
1781 .flags = MEMTYPE_FLAGS_1M_ALIGN,
1782 },
1783};
1784
1785static void __init size_pmem_devices(void)
1786{
1787#ifdef CONFIG_ANDROID_PMEM
1788 android_pmem_adsp_pdata.size = pmem_adsp_size;
1789 android_pmem_pdata.size = pmem_mdp_size;
1790 android_pmem_audio_pdata.size = pmem_audio_size;
1791#endif
1792}
1793
1794static void __init reserve_memory_for(struct android_pmem_platform_data *p)
1795{
1796 msm7x27_reserve_table[p->memory_type].size += p->size;
1797}
1798
1799static void __init reserve_pmem_memory(void)
1800{
1801#ifdef CONFIG_ANDROID_PMEM
1802 reserve_memory_for(&android_pmem_adsp_pdata);
1803 reserve_memory_for(&android_pmem_pdata);
1804 reserve_memory_for(&android_pmem_audio_pdata);
1805 msm7x27_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
1806#endif
1807}
1808
1809static void __init msm7x27_calculate_reserve_sizes(void)
1810{
1811 size_pmem_devices();
1812 reserve_pmem_memory();
1813}
1814
1815static int msm7x27_paddr_to_memtype(unsigned int paddr)
1816{
1817 return MEMTYPE_EBI1;
1818}
1819
1820static struct reserve_info msm7x27_reserve_info __initdata = {
1821 .memtype_reserve_table = msm7x27_reserve_table,
1822 .calculate_reserve_sizes = msm7x27_calculate_reserve_sizes,
1823 .paddr_to_memtype = msm7x27_paddr_to_memtype,
1824};
1825
1826static void __init msm7x27_reserve(void)
1827{
1828 reserve_info = &msm7x27_reserve_info;
1829 msm_reserve();
1830}
1831
1832static void __init msm7x27_init_early(void)
1833{
1834 msm_msm7x2x_allocate_memory_regions();
Daniel Walker2682fd32010-02-24 15:47:58 -08001835}
1836
1837static void __init msm7x2x_map_io(void)
1838{
1839 msm_map_common_io();
Daniel Walker2682fd32010-02-24 15:47:58 -08001840
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001841 if (socinfo_init() < 0)
1842 BUG();
Daniel Walker2682fd32010-02-24 15:47:58 -08001843
1844#ifdef CONFIG_CACHE_L2X0
1845 if (machine_is_msm7x27_surf() || machine_is_msm7x27_ffa()) {
1846 /* 7x27 has 256KB L2 cache:
1847 64Kb/Way and 4-Way Associativity;
Daniel Walker2682fd32010-02-24 15:47:58 -08001848 evmon/parity/share disabled. */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001849 if ((SOCINFO_VERSION_MAJOR(socinfo_get_version()) > 1)
1850 || ((SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 1)
1851 && (SOCINFO_VERSION_MINOR(socinfo_get_version()) >= 3)))
1852 /* R/W latency: 4 cycles; */
1853 l2x0_init(MSM_L2CC_BASE, 0x0006801B, 0xfe000000);
1854 else
1855 /* R/W latency: 3 cycles; */
1856 l2x0_init(MSM_L2CC_BASE, 0x00068012, 0xfe000000);
Daniel Walker2682fd32010-02-24 15:47:58 -08001857 }
1858#endif
1859}
1860
1861MACHINE_START(MSM7X27_SURF, "QCT MSM7x27 SURF")
Russell Kingb75c1782011-01-04 19:03:16 +00001862 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker2682fd32010-02-24 15:47:58 -08001863 .map_io = msm7x2x_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001864 .reserve = msm7x27_reserve,
Daniel Walker2682fd32010-02-24 15:47:58 -08001865 .init_irq = msm7x2x_init_irq,
1866 .init_machine = msm7x2x_init,
1867 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001868 .init_early = msm7x27_init_early,
Taniya Dasbe561a02011-10-12 09:53:11 +05301869 .handle_irq = vic_handle_irq,
Daniel Walker2682fd32010-02-24 15:47:58 -08001870MACHINE_END
1871
1872MACHINE_START(MSM7X27_FFA, "QCT MSM7x27 FFA")
Russell Kingb75c1782011-01-04 19:03:16 +00001873 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker2682fd32010-02-24 15:47:58 -08001874 .map_io = msm7x2x_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001875 .reserve = msm7x27_reserve,
Daniel Walker2682fd32010-02-24 15:47:58 -08001876 .init_irq = msm7x2x_init_irq,
1877 .init_machine = msm7x2x_init,
1878 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001879 .init_early = msm7x27_init_early,
Taniya Dasbe561a02011-10-12 09:53:11 +05301880 .handle_irq = vic_handle_irq,
Daniel Walker2682fd32010-02-24 15:47:58 -08001881MACHINE_END
1882
1883MACHINE_START(MSM7X25_SURF, "QCT MSM7x25 SURF")
Russell Kingb75c1782011-01-04 19:03:16 +00001884 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker2682fd32010-02-24 15:47:58 -08001885 .map_io = msm7x2x_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001886 .reserve = msm7x27_reserve,
Daniel Walker2682fd32010-02-24 15:47:58 -08001887 .init_irq = msm7x2x_init_irq,
1888 .init_machine = msm7x2x_init,
1889 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001890 .init_early = msm7x27_init_early,
Taniya Dasbe561a02011-10-12 09:53:11 +05301891 .handle_irq = vic_handle_irq,
Daniel Walker2682fd32010-02-24 15:47:58 -08001892MACHINE_END
1893
1894MACHINE_START(MSM7X25_FFA, "QCT MSM7x25 FFA")
Russell Kingb75c1782011-01-04 19:03:16 +00001895 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker2682fd32010-02-24 15:47:58 -08001896 .map_io = msm7x2x_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001897 .reserve = msm7x27_reserve,
Daniel Walker2682fd32010-02-24 15:47:58 -08001898 .init_irq = msm7x2x_init_irq,
1899 .init_machine = msm7x2x_init,
1900 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001901 .init_early = msm7x27_init_early,
Taniya Dasbe561a02011-10-12 09:53:11 +05301902 .handle_irq = vic_handle_irq,
Daniel Walker2682fd32010-02-24 15:47:58 -08001903MACHINE_END