board-qsd8x50.c 5.2 KB
Newer Older
1
/* Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 */
17
#include <linux/gpio.h>
18 19 20 21
#include <linux/kernel.h>
#include <linux/irq.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
22
#include <linux/usb/msm_hsusb.h>
23
#include <linux/err.h>
S
Stephen Boyd 已提交
24
#include <linux/clkdev.h>
25 26 27 28 29 30 31

#include <asm/mach-types.h>
#include <asm/mach/arch.h>
#include <asm/io.h>
#include <asm/setup.h>

#include <mach/board.h>
32 33
#include <mach/irqs.h>
#include <mach/sirc.h>
34
#include <mach/vreg.h>
35
#include <linux/platform_data/mmc-msm_sdcc.h>
36 37

#include "devices.h"
38
#include "common.h"
39

40 41
static const resource_size_t qsd8x50_surf_smc91x_base __initconst = 0x70000300;
static const unsigned        qsd8x50_surf_smc91x_gpio __initconst = 156;
G
Gregory Bean 已提交
42 43 44 45 46

/* Leave smc91x resources empty here, as we'll fill them in
 * at run-time: they vary from board to board, and the true
 * configuration won't be known until boot.
 */
47
static struct resource smc91x_resources[] = {
G
Gregory Bean 已提交
48 49 50 51 52 53 54 55
	[0] = {
		.flags = IORESOURCE_MEM,
	},
	[1] = {
		.flags = IORESOURCE_IRQ,
	},
};

56
static struct platform_device smc91x_device = {
G
Gregory Bean 已提交
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
	.name           = "smc91x",
	.id             = 0,
	.num_resources  = ARRAY_SIZE(smc91x_resources),
	.resource       = smc91x_resources,
};

static int __init msm_init_smc91x(void)
{
	if (machine_is_qsd8x50_surf()) {
		smc91x_resources[0].start = qsd8x50_surf_smc91x_base;
		smc91x_resources[0].end   = qsd8x50_surf_smc91x_base + 0xff;
		smc91x_resources[1].start =
			gpio_to_irq(qsd8x50_surf_smc91x_gpio);
		smc91x_resources[1].end   =
			gpio_to_irq(qsd8x50_surf_smc91x_gpio);
		platform_device_register(&smc91x_device);
	}

	return 0;
}
module_init(msm_init_smc91x);

79 80 81 82 83 84 85 86 87 88 89 90
static int hsusb_phy_init_seq[] = {
	0x08, 0x31,	/* Increase HS Driver Amplitude */
	0x20, 0x32,	/* Enable and set Pre-Emphasis Depth to 10% */
	-1
};

static struct msm_otg_platform_data msm_otg_pdata = {
	.phy_init_seq		= hsusb_phy_init_seq,
	.mode                   = USB_PERIPHERAL,
	.otg_control		= OTG_PHY_CONTROL,
};

91
static struct platform_device *devices[] __initdata = {
92
	&msm_device_uart3,
93
	&msm_device_smd,
94 95 96
	&msm_device_otg,
	&msm_device_hsusb,
	&msm_device_hsusb_host,
97 98
};

99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
static struct msm_mmc_gpio sdc1_gpio_cfg[] = {
	{51, "sdc1_dat_3"},
	{52, "sdc1_dat_2"},
	{53, "sdc1_dat_1"},
	{54, "sdc1_dat_0"},
	{55, "sdc1_cmd"},
	{56, "sdc1_clk"}
};

static struct vreg *vreg_mmc;
static unsigned long vreg_sts;

static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
{
	int rc = 0;
	struct platform_device *pdev;

	pdev = container_of(dv, struct platform_device, dev);

	if (vdd == 0) {
		if (!vreg_sts)
			return 0;

		clear_bit(pdev->id, &vreg_sts);

		if (!vreg_sts) {
			rc = vreg_disable(vreg_mmc);
			if (rc)
				pr_err("vreg_mmc disable failed for slot "
						"%d: %d\n", pdev->id, rc);
		}
		return 0;
	}

	if (!vreg_sts) {
		rc = vreg_set_level(vreg_mmc, 2900);
		if (rc)
			pr_err("vreg_mmc set level failed for slot %d: %d\n",
					pdev->id, rc);
		rc = vreg_enable(vreg_mmc);
		if (rc)
			pr_err("vreg_mmc enable failed for slot %d: %d\n",
					pdev->id, rc);
	}
	set_bit(pdev->id, &vreg_sts);
	return 0;
}

static struct msm_mmc_gpio_data sdc1_gpio = {
	.gpio = sdc1_gpio_cfg,
	.size = ARRAY_SIZE(sdc1_gpio_cfg),
};

static struct msm_mmc_platform_data qsd8x50_sdc1_data = {
	.ocr_mask	= MMC_VDD_27_28 | MMC_VDD_28_29,
	.translate_vdd	= msm_sdcc_setup_power,
	.gpio_data = &sdc1_gpio,
};

static void __init qsd8x50_init_mmc(void)
{
160
	vreg_mmc = vreg_get(NULL, "gp5");
161 162 163 164 165 166 167 168 169 170

	if (IS_ERR(vreg_mmc)) {
		pr_err("vreg get for vreg_mmc failed (%ld)\n",
				PTR_ERR(vreg_mmc));
		return;
	}

	msm_add_sdcc(1, &qsd8x50_sdc1_data, 0, 0);
}

171
static void __init qsd8x50_map_io(void)
172
{
173 174
	msm_map_qsd8x50_io();
	msm_clock_init(msm_clocks_8x50, msm_num_clocks_8x50);
175 176
}

177
static void __init qsd8x50_init_irq(void)
178
{
179 180
	msm_init_irq();
	msm_init_sirc();
181 182 183 184
}

static void __init qsd8x50_init(void)
{
185 186 187
	msm_device_otg.dev.platform_data = &msm_otg_pdata;
	msm_device_hsusb.dev.parent = &msm_device_otg.dev;
	msm_device_hsusb_host.dev.parent = &msm_device_otg.dev;
188
	platform_add_devices(devices, ARRAY_SIZE(devices));
189
	qsd8x50_init_mmc();
190 191
}

192 193 194 195 196
static void __init qsd8x50_init_late(void)
{
	smd_debugfs_init();
}

197
MACHINE_START(QSD8X50_SURF, "QCT QSD8X50 SURF")
198
	.atag_offset = 0x100,
199 200 201
	.map_io = qsd8x50_map_io,
	.init_irq = qsd8x50_init_irq,
	.init_machine = qsd8x50_init,
202
	.init_late = qsd8x50_init_late,
203
	.timer = &qsd8x50_timer,
204 205
MACHINE_END

206
MACHINE_START(QSD8X50A_ST1_5, "QCT QSD8X50A ST1.5")
207
	.atag_offset = 0x100,
208 209 210
	.map_io = qsd8x50_map_io,
	.init_irq = qsd8x50_init_irq,
	.init_machine = qsd8x50_init,
211
	.init_late = qsd8x50_init_late,
212
	.timer = &qsd8x50_timer,
213
MACHINE_END