1 /* Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
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.
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.
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
17 #include <linux/gpio.h>
18 #include <linux/kernel.h>
19 #include <linux/irq.h>
20 #include <linux/platform_device.h>
21 #include <linux/delay.h>
22 #include <linux/usb/msm_hsusb.h>
23 #include <linux/err.h>
24 #include <linux/clkdev.h>
25 #include <linux/smc91x.h>
27 #include <asm/mach-types.h>
28 #include <asm/mach/arch.h>
30 #include <asm/setup.h>
32 #include <mach/irqs.h>
33 #include <mach/sirc.h>
34 #include <mach/vreg.h>
36 #include <linux/platform_data/mmc-msm_sdcc.h>
41 static const resource_size_t qsd8x50_surf_smc91x_base __initconst = 0x70000300;
42 static const unsigned qsd8x50_surf_smc91x_gpio __initconst = 156;
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.
48 static struct resource smc91x_resources[] = {
50 .flags = IORESOURCE_MEM,
53 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
57 static struct smc91x_platdata smc91x_platdata = {
58 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
61 static struct platform_device smc91x_device = {
64 .num_resources = ARRAY_SIZE(smc91x_resources),
65 .resource = smc91x_resources,
66 .dev.platform_data = &smc91x_platdata,
69 static int __init msm_init_smc91x(void)
71 if (machine_is_qsd8x50_surf()) {
72 smc91x_resources[0].start = qsd8x50_surf_smc91x_base;
73 smc91x_resources[0].end = qsd8x50_surf_smc91x_base + 0xff;
74 smc91x_resources[1].start =
75 gpio_to_irq(qsd8x50_surf_smc91x_gpio);
76 smc91x_resources[1].end =
77 gpio_to_irq(qsd8x50_surf_smc91x_gpio);
78 platform_device_register(&smc91x_device);
83 module_init(msm_init_smc91x);
85 static int hsusb_phy_init_seq[] = {
86 0x08, 0x31, /* Increase HS Driver Amplitude */
87 0x20, 0x32, /* Enable and set Pre-Emphasis Depth to 10% */
91 static int hsusb_link_clk_reset(struct clk *link_clk, bool assert)
96 ret = clk_reset(link_clk, CLK_RESET_ASSERT);
98 pr_err("usb hs_clk assert failed\n");
100 ret = clk_reset(link_clk, CLK_RESET_DEASSERT);
102 pr_err("usb hs_clk deassert failed\n");
107 static int hsusb_phy_clk_reset(struct clk *phy_clk)
111 ret = clk_reset(phy_clk, CLK_RESET_ASSERT);
113 pr_err("usb phy clk assert failed\n");
116 usleep_range(10000, 12000);
117 ret = clk_reset(phy_clk, CLK_RESET_DEASSERT);
119 pr_err("usb phy clk deassert failed\n");
123 static struct msm_otg_platform_data msm_otg_pdata = {
124 .phy_init_seq = hsusb_phy_init_seq,
125 .mode = USB_DR_MODE_PERIPHERAL,
126 .otg_control = OTG_PHY_CONTROL,
127 .link_clk_reset = hsusb_link_clk_reset,
128 .phy_clk_reset = hsusb_phy_clk_reset,
131 static struct platform_device *devices[] __initdata = {
133 &msm_device_gpio_8x50,
138 &msm_device_hsusb_host,
141 static struct msm_mmc_gpio sdc1_gpio_cfg[] = {
150 static struct vreg *vreg_mmc;
151 static unsigned long vreg_sts;
153 static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
156 struct platform_device *pdev;
158 pdev = container_of(dv, struct platform_device, dev);
164 clear_bit(pdev->id, &vreg_sts);
167 rc = vreg_disable(vreg_mmc);
169 pr_err("vreg_mmc disable failed for slot "
170 "%d: %d\n", pdev->id, rc);
176 rc = vreg_set_level(vreg_mmc, 2900);
178 pr_err("vreg_mmc set level failed for slot %d: %d\n",
180 rc = vreg_enable(vreg_mmc);
182 pr_err("vreg_mmc enable failed for slot %d: %d\n",
185 set_bit(pdev->id, &vreg_sts);
189 static struct msm_mmc_gpio_data sdc1_gpio = {
190 .gpio = sdc1_gpio_cfg,
191 .size = ARRAY_SIZE(sdc1_gpio_cfg),
194 static struct msm_mmc_platform_data qsd8x50_sdc1_data = {
195 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
196 .translate_vdd = msm_sdcc_setup_power,
197 .gpio_data = &sdc1_gpio,
200 static void __init qsd8x50_init_mmc(void)
202 vreg_mmc = vreg_get(NULL, "gp5");
204 if (IS_ERR(vreg_mmc)) {
205 pr_err("vreg get for vreg_mmc failed (%ld)\n",
210 msm_add_sdcc(1, &qsd8x50_sdc1_data, 0, 0);
213 static void __init qsd8x50_map_io(void)
215 msm_map_qsd8x50_io();
218 static void __init qsd8x50_init_irq(void)
224 static void __init qsd8x50_init(void)
226 msm_device_otg.dev.platform_data = &msm_otg_pdata;
227 msm_device_hsusb.dev.parent = &msm_device_otg.dev;
228 msm_device_hsusb_host.dev.parent = &msm_device_otg.dev;
229 platform_add_devices(devices, ARRAY_SIZE(devices));
233 static void __init qsd8x50_init_late(void)
238 MACHINE_START(QSD8X50_SURF, "QCT QSD8X50 SURF")
239 .atag_offset = 0x100,
240 .map_io = qsd8x50_map_io,
241 .init_irq = qsd8x50_init_irq,
242 .init_machine = qsd8x50_init,
243 .init_late = qsd8x50_init_late,
244 .init_time = qsd8x50_timer_init,
247 MACHINE_START(QSD8X50A_ST1_5, "QCT QSD8X50A ST1.5")
248 .atag_offset = 0x100,
249 .map_io = qsd8x50_map_io,
250 .init_irq = qsd8x50_init_irq,
251 .init_machine = qsd8x50_init,
252 .init_late = qsd8x50_init_late,
253 .init_time = qsd8x50_timer_init,