blob: 5f933bc507838e10cb408e5088b06b706d1894b7 [file] [log] [blame]
Sahitya Tummala8b4d95f2011-01-18 11:22:50 +05301/* Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
Daniel Walkera32d2fe2010-02-25 11:38:39 -08002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
Russell King2f8163b2011-07-26 10:53:52 +010017#include <linux/gpio.h>
Daniel Walkera32d2fe2010-02-25 11:38:39 -080018#include <linux/kernel.h>
19#include <linux/irq.h>
Daniel Walkera32d2fe2010-02-25 11:38:39 -080020#include <linux/platform_device.h>
Daniel Walkera32d2fe2010-02-25 11:38:39 -080021#include <linux/delay.h>
Pavankumar Kondeti7032d512010-12-08 13:37:07 +053022#include <linux/usb/msm_hsusb.h>
Sahitya Tummala8b4d95f2011-01-18 11:22:50 +053023#include <linux/err.h>
Stephen Boydbd323442011-02-23 09:37:42 -080024#include <linux/clkdev.h>
Daniel Walkera32d2fe2010-02-25 11:38:39 -080025
26#include <asm/mach-types.h>
27#include <asm/mach/arch.h>
28#include <asm/io.h>
29#include <asm/setup.h>
30
Daniel Walkerd1c0d432010-05-05 07:17:31 -070031#include <mach/irqs.h>
32#include <mach/sirc.h>
Sahitya Tummala8b4d95f2011-01-18 11:22:50 +053033#include <mach/vreg.h>
Arnd Bergmann1ef21f62012-08-24 15:14:41 +020034#include <linux/platform_data/mmc-msm_sdcc.h>
Daniel Walkera32d2fe2010-02-25 11:38:39 -080035
36#include "devices.h"
Stephen Boyd4312a7e2012-09-05 12:28:52 -070037#include "common.h"
Daniel Walkera32d2fe2010-02-25 11:38:39 -080038
Andi Kleenbcad6dc2012-10-04 17:11:28 -070039static const resource_size_t qsd8x50_surf_smc91x_base __initconst = 0x70000300;
40static const unsigned qsd8x50_surf_smc91x_gpio __initconst = 156;
Gregory Bean5d73c532010-09-29 13:46:45 -070041
42/* Leave smc91x resources empty here, as we'll fill them in
43 * at run-time: they vary from board to board, and the true
44 * configuration won't be known until boot.
45 */
Stephen Boyd7c63ded2010-12-20 15:00:17 -080046static struct resource smc91x_resources[] = {
Gregory Bean5d73c532010-09-29 13:46:45 -070047 [0] = {
48 .flags = IORESOURCE_MEM,
49 },
50 [1] = {
51 .flags = IORESOURCE_IRQ,
52 },
53};
54
Stephen Boyd7c63ded2010-12-20 15:00:17 -080055static struct platform_device smc91x_device = {
Gregory Bean5d73c532010-09-29 13:46:45 -070056 .name = "smc91x",
57 .id = 0,
58 .num_resources = ARRAY_SIZE(smc91x_resources),
59 .resource = smc91x_resources,
60};
61
62static int __init msm_init_smc91x(void)
63{
64 if (machine_is_qsd8x50_surf()) {
65 smc91x_resources[0].start = qsd8x50_surf_smc91x_base;
66 smc91x_resources[0].end = qsd8x50_surf_smc91x_base + 0xff;
67 smc91x_resources[1].start =
68 gpio_to_irq(qsd8x50_surf_smc91x_gpio);
69 smc91x_resources[1].end =
70 gpio_to_irq(qsd8x50_surf_smc91x_gpio);
71 platform_device_register(&smc91x_device);
72 }
73
74 return 0;
75}
76module_init(msm_init_smc91x);
77
Pavankumar Kondeti7032d512010-12-08 13:37:07 +053078static int hsusb_phy_init_seq[] = {
79 0x08, 0x31, /* Increase HS Driver Amplitude */
80 0x20, 0x32, /* Enable and set Pre-Emphasis Depth to 10% */
81 -1
82};
83
84static struct msm_otg_platform_data msm_otg_pdata = {
85 .phy_init_seq = hsusb_phy_init_seq,
86 .mode = USB_PERIPHERAL,
87 .otg_control = OTG_PHY_CONTROL,
88};
89
Daniel Walkera32d2fe2010-02-25 11:38:39 -080090static struct platform_device *devices[] __initdata = {
Stephen Boyd421faca2013-06-17 10:43:18 -070091 &msm_clock_8x50,
Stephen Boyd7bce6962013-03-04 15:08:27 -080092 &msm_device_gpio_8x50,
Daniel Walkerd1c0d432010-05-05 07:17:31 -070093 &msm_device_uart3,
Niranjana Vishwanathapura88b52272010-10-06 13:52:11 -070094 &msm_device_smd,
Pavankumar Kondeti7032d512010-12-08 13:37:07 +053095 &msm_device_otg,
96 &msm_device_hsusb,
97 &msm_device_hsusb_host,
Daniel Walkera32d2fe2010-02-25 11:38:39 -080098};
99
Sahitya Tummala8b4d95f2011-01-18 11:22:50 +0530100static struct msm_mmc_gpio sdc1_gpio_cfg[] = {
101 {51, "sdc1_dat_3"},
102 {52, "sdc1_dat_2"},
103 {53, "sdc1_dat_1"},
104 {54, "sdc1_dat_0"},
105 {55, "sdc1_cmd"},
106 {56, "sdc1_clk"}
107};
108
109static struct vreg *vreg_mmc;
110static unsigned long vreg_sts;
111
112static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
113{
114 int rc = 0;
115 struct platform_device *pdev;
116
117 pdev = container_of(dv, struct platform_device, dev);
118
119 if (vdd == 0) {
120 if (!vreg_sts)
121 return 0;
122
123 clear_bit(pdev->id, &vreg_sts);
124
125 if (!vreg_sts) {
126 rc = vreg_disable(vreg_mmc);
127 if (rc)
128 pr_err("vreg_mmc disable failed for slot "
129 "%d: %d\n", pdev->id, rc);
130 }
131 return 0;
132 }
133
134 if (!vreg_sts) {
135 rc = vreg_set_level(vreg_mmc, 2900);
136 if (rc)
137 pr_err("vreg_mmc set level failed for slot %d: %d\n",
138 pdev->id, rc);
139 rc = vreg_enable(vreg_mmc);
140 if (rc)
141 pr_err("vreg_mmc enable failed for slot %d: %d\n",
142 pdev->id, rc);
143 }
144 set_bit(pdev->id, &vreg_sts);
145 return 0;
146}
147
148static struct msm_mmc_gpio_data sdc1_gpio = {
149 .gpio = sdc1_gpio_cfg,
150 .size = ARRAY_SIZE(sdc1_gpio_cfg),
151};
152
153static struct msm_mmc_platform_data qsd8x50_sdc1_data = {
154 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
155 .translate_vdd = msm_sdcc_setup_power,
156 .gpio_data = &sdc1_gpio,
157};
158
159static void __init qsd8x50_init_mmc(void)
160{
David Brown62f09882011-03-29 11:48:45 -0700161 vreg_mmc = vreg_get(NULL, "gp5");
Sahitya Tummala8b4d95f2011-01-18 11:22:50 +0530162
163 if (IS_ERR(vreg_mmc)) {
164 pr_err("vreg get for vreg_mmc failed (%ld)\n",
165 PTR_ERR(vreg_mmc));
166 return;
167 }
168
169 msm_add_sdcc(1, &qsd8x50_sdc1_data, 0, 0);
170}
171
Daniel Walkera32d2fe2010-02-25 11:38:39 -0800172static void __init qsd8x50_map_io(void)
173{
Daniel Walkera32d2fe2010-02-25 11:38:39 -0800174 msm_map_qsd8x50_io();
Daniel Walkera32d2fe2010-02-25 11:38:39 -0800175}
176
Daniel Walkerd1c0d432010-05-05 07:17:31 -0700177static void __init qsd8x50_init_irq(void)
178{
179 msm_init_irq();
180 msm_init_sirc();
181}
182
183static void __init qsd8x50_init(void)
184{
Pavankumar Kondeti7032d512010-12-08 13:37:07 +0530185 msm_device_otg.dev.platform_data = &msm_otg_pdata;
186 msm_device_hsusb.dev.parent = &msm_device_otg.dev;
187 msm_device_hsusb_host.dev.parent = &msm_device_otg.dev;
Daniel Walkerd1c0d432010-05-05 07:17:31 -0700188 platform_add_devices(devices, ARRAY_SIZE(devices));
Sahitya Tummala8b4d95f2011-01-18 11:22:50 +0530189 qsd8x50_init_mmc();
Daniel Walkerd1c0d432010-05-05 07:17:31 -0700190}
191
Shawn Guoc633c532012-05-02 15:53:20 +0800192static void __init qsd8x50_init_late(void)
193{
194 smd_debugfs_init();
195}
196
Daniel Walkera32d2fe2010-02-25 11:38:39 -0800197MACHINE_START(QSD8X50_SURF, "QCT QSD8X50 SURF")
Nicolas Pitref631dd42011-07-05 22:38:14 -0400198 .atag_offset = 0x100,
Daniel Walkera32d2fe2010-02-25 11:38:39 -0800199 .map_io = qsd8x50_map_io,
200 .init_irq = qsd8x50_init_irq,
201 .init_machine = qsd8x50_init,
Shawn Guoc633c532012-05-02 15:53:20 +0800202 .init_late = qsd8x50_init_late,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700203 .init_time = qsd8x50_timer_init,
Daniel Walkera32d2fe2010-02-25 11:38:39 -0800204MACHINE_END
205
Daniel Walkerd1c0d432010-05-05 07:17:31 -0700206MACHINE_START(QSD8X50A_ST1_5, "QCT QSD8X50A ST1.5")
Nicolas Pitref631dd42011-07-05 22:38:14 -0400207 .atag_offset = 0x100,
Daniel Walkera32d2fe2010-02-25 11:38:39 -0800208 .map_io = qsd8x50_map_io,
209 .init_irq = qsd8x50_init_irq,
210 .init_machine = qsd8x50_init,
Shawn Guoc633c532012-05-02 15:53:20 +0800211 .init_late = qsd8x50_init_late,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700212 .init_time = qsd8x50_timer_init,
Daniel Walkera32d2fe2010-02-25 11:38:39 -0800213MACHINE_END