ARM: msm: move platform_data definitions
[deliverable/linux.git] / arch / arm / mach-msm / board-qsd8x50.c
CommitLineData
8b4d95fc 1/* Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
a32d2feb
DW
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * 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 */
2f8163ba 17#include <linux/gpio.h>
a32d2feb
DW
18#include <linux/kernel.h>
19#include <linux/irq.h>
a32d2feb 20#include <linux/platform_device.h>
a32d2feb 21#include <linux/delay.h>
7032d512 22#include <linux/usb/msm_hsusb.h>
8b4d95fc 23#include <linux/err.h>
bd32344a 24#include <linux/clkdev.h>
a32d2feb
DW
25
26#include <asm/mach-types.h>
27#include <asm/mach/arch.h>
28#include <asm/io.h>
29#include <asm/setup.h>
30
a32d2feb 31#include <mach/board.h>
d1c0d43d
DW
32#include <mach/irqs.h>
33#include <mach/sirc.h>
8b4d95fc 34#include <mach/vreg.h>
1ef21f63 35#include <linux/platform_data/mmc-msm_sdcc.h>
a32d2feb
DW
36
37#include "devices.h"
a32d2feb 38
d1c0d43d 39extern struct sys_timer msm_timer;
a32d2feb 40
5d73c53b
GB
41static const resource_size_t qsd8x50_surf_smc91x_base __initdata = 0x70000300;
42static const unsigned qsd8x50_surf_smc91x_gpio __initdata = 156;
43
44/* Leave smc91x resources empty here, as we'll fill them in
45 * at run-time: they vary from board to board, and the true
46 * configuration won't be known until boot.
47 */
7c63dedc 48static struct resource smc91x_resources[] = {
5d73c53b
GB
49 [0] = {
50 .flags = IORESOURCE_MEM,
51 },
52 [1] = {
53 .flags = IORESOURCE_IRQ,
54 },
55};
56
7c63dedc 57static struct platform_device smc91x_device = {
5d73c53b
GB
58 .name = "smc91x",
59 .id = 0,
60 .num_resources = ARRAY_SIZE(smc91x_resources),
61 .resource = smc91x_resources,
62};
63
64static int __init msm_init_smc91x(void)
65{
66 if (machine_is_qsd8x50_surf()) {
67 smc91x_resources[0].start = qsd8x50_surf_smc91x_base;
68 smc91x_resources[0].end = qsd8x50_surf_smc91x_base + 0xff;
69 smc91x_resources[1].start =
70 gpio_to_irq(qsd8x50_surf_smc91x_gpio);
71 smc91x_resources[1].end =
72 gpio_to_irq(qsd8x50_surf_smc91x_gpio);
73 platform_device_register(&smc91x_device);
74 }
75
76 return 0;
77}
78module_init(msm_init_smc91x);
79
7032d512
PK
80static int hsusb_phy_init_seq[] = {
81 0x08, 0x31, /* Increase HS Driver Amplitude */
82 0x20, 0x32, /* Enable and set Pre-Emphasis Depth to 10% */
83 -1
84};
85
86static struct msm_otg_platform_data msm_otg_pdata = {
87 .phy_init_seq = hsusb_phy_init_seq,
88 .mode = USB_PERIPHERAL,
89 .otg_control = OTG_PHY_CONTROL,
90};
91
a32d2feb 92static struct platform_device *devices[] __initdata = {
d1c0d43d 93 &msm_device_uart3,
88b52277 94 &msm_device_smd,
7032d512
PK
95 &msm_device_otg,
96 &msm_device_hsusb,
97 &msm_device_hsusb_host,
a32d2feb
DW
98};
99
8b4d95fc
ST
100static 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{
62f0988e 161 vreg_mmc = vreg_get(NULL, "gp5");
8b4d95fc
ST
162
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
d1c0d43d 172static void __init qsd8x50_map_io(void)
a32d2feb 173{
d1c0d43d
DW
174 msm_map_qsd8x50_io();
175 msm_clock_init(msm_clocks_8x50, msm_num_clocks_8x50);
a32d2feb
DW
176}
177
d1c0d43d 178static void __init qsd8x50_init_irq(void)
a32d2feb 179{
d1c0d43d
DW
180 msm_init_irq();
181 msm_init_sirc();
a32d2feb
DW
182}
183
184static void __init qsd8x50_init(void)
185{
7032d512
PK
186 msm_device_otg.dev.platform_data = &msm_otg_pdata;
187 msm_device_hsusb.dev.parent = &msm_device_otg.dev;
188 msm_device_hsusb_host.dev.parent = &msm_device_otg.dev;
a32d2feb 189 platform_add_devices(devices, ARRAY_SIZE(devices));
8b4d95fc 190 qsd8x50_init_mmc();
a32d2feb
DW
191}
192
c633c531
SG
193static void __init qsd8x50_init_late(void)
194{
195 smd_debugfs_init();
196}
197
a32d2feb 198MACHINE_START(QSD8X50_SURF, "QCT QSD8X50 SURF")
f631dd41 199 .atag_offset = 0x100,
a32d2feb
DW
200 .map_io = qsd8x50_map_io,
201 .init_irq = qsd8x50_init_irq,
202 .init_machine = qsd8x50_init,
c633c531 203 .init_late = qsd8x50_init_late,
a32d2feb
DW
204 .timer = &msm_timer,
205MACHINE_END
206
d1c0d43d 207MACHINE_START(QSD8X50A_ST1_5, "QCT QSD8X50A ST1.5")
f631dd41 208 .atag_offset = 0x100,
a32d2feb
DW
209 .map_io = qsd8x50_map_io,
210 .init_irq = qsd8x50_init_irq,
211 .init_machine = qsd8x50_init,
c633c531 212 .init_late = qsd8x50_init_late,
a32d2feb
DW
213 .timer = &msm_timer,
214MACHINE_END
This page took 0.139463 seconds and 5 git commands to generate.