blob: f292c4d6b3b3716e4cff31371fc690545d1d7830 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
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 */
13#include <linux/kernel.h>
14#include <linux/platform_device.h>
15#include <linux/io.h>
16#include <linux/irq.h>
Kenneth Heitke748593a2011-07-15 15:45:11 -060017#include <linux/i2c.h>
Kenneth Heitke36920d32011-07-20 16:44:30 -060018#include <linux/msm_ssbi.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070019#include <asm/mach-types.h>
20#include <asm/mach/arch.h>
21#include <asm/hardware/gic.h>
Sahitya Tummala3586ed92011-08-03 09:13:23 +053022#include <asm/mach/mmc.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070023
24#include <mach/board.h>
25#include <mach/msm_iomap.h>
26#include <linux/usb/msm_hsusb.h>
27#include <linux/usb/android.h>
28#include <mach/socinfo.h>
Harini Jayaramanc4c58692011-07-19 14:50:10 -060029#include <mach/msm_spi.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070030#include "timer.h"
31#include "devices.h"
Joel King4ebccc62011-07-22 09:43:22 -070032#include <mach/gpio.h>
33#include <mach/gpiomux.h>
34
Jay Chokshiea67c622011-07-29 17:12:26 -070035#include "board-apq8064.h"
36
Joel King4ebccc62011-07-22 09:43:22 -070037static int __init gpiomux_init(void)
38{
39 int rc;
40
41 rc = msm_gpiomux_init(NR_GPIO_IRQS);
42 if (rc) {
43 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
44 return rc;
45 }
46 return 0;
47}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070048
Sahitya Tummala3586ed92011-08-03 09:13:23 +053049#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
50static unsigned int sdc1_sup_clk_rates[] = {
51 400000, 24000000, 48000000, 96000000
52};
53
54static struct mmc_platform_data sdc1_data = {
55 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
56 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
57 .sup_clk_table = sdc1_sup_clk_rates,
58 .sup_clk_cnt = ARRAY_SIZE(sdc1_sup_clk_rates),
59};
60static struct mmc_platform_data *apq8064_sdc1_pdata = &sdc1_data;
61#else
62static struct mmc_platform_data *apq8064_sdc1_pdata;
63#endif
64
65#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
66static unsigned int sdc3_sup_clk_rates[] = {
67 400000, 24000000, 48000000, 96000000
68};
69
70static struct mmc_platform_data sdc3_data = {
71 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
72 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
73 .sup_clk_table = sdc3_sup_clk_rates,
74 .sup_clk_cnt = ARRAY_SIZE(sdc3_sup_clk_rates),
75};
76static struct mmc_platform_data *apq8064_sdc3_pdata = &sdc3_data;
77#else
78static struct mmc_platform_data *apq8064_sdc3_pdata;
79#endif
80
81static void __init apq8064_init_mmc(void)
82{
83 apq8064_add_sdcc(1, apq8064_sdc1_pdata);
84 apq8064_add_sdcc(3, apq8064_sdc3_pdata);
85}
86
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070087static void __init apq8064_map_io(void)
88{
89 msm_map_apq8064_io();
90}
91
92static void __init apq8064_init_irq(void)
93{
94 unsigned int i;
95 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
96 (void *)MSM_QGIC_CPU_BASE);
97
98 /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
99 writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
100
101 writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET);
102 mb();
103
104 /*
105 * FIXME: Not installing AVS_SVICINT and AVS_SVICINTSWDONE yet
106 * as they are configured as level, which does not play nice with
107 * handle_percpu_irq.
108 */
109 for (i = GIC_PPI_START; i < GIC_SPI_START; i++) {
110 if (i != AVS_SVICINT && i != AVS_SVICINTSWDONE)
111 irq_set_handler(i, handle_percpu_irq);
112 }
113}
114
115static struct platform_device *common_devices[] __initdata = {
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600116 &apq8064_device_uart_gsbi3,
Kenneth Heitke748593a2011-07-15 15:45:11 -0600117 &apq8064_device_qup_i2c_gsbi4,
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600118 &apq8064_device_qup_spi_gsbi5,
Kenneth Heitke36920d32011-07-20 16:44:30 -0600119 &apq8064_device_ssbi_pmic1,
120 &apq8064_device_ssbi_pmic2,
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600121};
122
Joel King4e7ad222011-08-17 15:47:38 -0700123static struct platform_device *sim_devices[] __initdata = {
124 &apq8064_device_dmov,
125};
126
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600127static struct msm_spi_platform_data apq8064_qup_spi_gsbi5_pdata = {
128 .max_clock_speed = 26000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700129};
130
131static struct msm_otg_platform_data msm_otg_pdata = {
132 .mode = USB_PERIPHERAL,
133 .otg_control = OTG_PHY_CONTROL,
134 .phy_type = SNPS_28NM_INTEGRATED_PHY,
135 .pclk_src_name = "dfab_usb_hs_clk",
136};
137
Jay Chokshiea67c622011-07-29 17:12:26 -0700138static struct pm8921_platform_data pm8921_platform_data __devinitdata = {
139 .regulator_pdatas = msm8064_pm8921_regulator_pdata,
140};
141
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700142static struct msm_ssbi_platform_data apq8064_ssbi_pm8921_pdata __devinitdata = {
143 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
144 .slave = {
Jay Chokshiea67c622011-07-29 17:12:26 -0700145 .name = "pm8921-core",
146 .platform_data = &pm8921_platform_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700147 },
148};
149
150static struct msm_ssbi_platform_data apq8064_ssbi_pm8821_pdata __devinitdata = {
151 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
152 .slave = {
Jay Chokshiea67c622011-07-29 17:12:26 -0700153 .name = "pm8821-core",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700154 },
155};
156
Kenneth Heitke748593a2011-07-15 15:45:11 -0600157static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi4_pdata = {
158 .clk_freq = 100000,
159 .src_clk_rate = 24000000,
160 .clk = "gsbi_qup_clk",
161 .pclk = "gsbi_pclk",
162};
163
164static void __init apq8064_i2c_init(void)
165{
166 apq8064_device_qup_i2c_gsbi4.dev.platform_data =
167 &apq8064_i2c_qup_gsbi4_pdata;
168}
169
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700170static void __init apq8064_common_init(void)
171{
172 if (socinfo_init() < 0)
173 pr_err("socinfo_init() failed!\n");
Stephen Boydbb600ae2011-08-02 20:11:40 -0700174 msm_clock_init(&apq8064_dummy_clock_init_data);
Joel King4ebccc62011-07-22 09:43:22 -0700175 gpiomux_init();
Kenneth Heitke748593a2011-07-15 15:45:11 -0600176 apq8064_i2c_init();
Kenneth Heitke36920d32011-07-20 16:44:30 -0600177
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600178 apq8064_device_qup_spi_gsbi5.dev.platform_data =
179 &apq8064_qup_spi_gsbi5_pdata;
Kenneth Heitke36920d32011-07-20 16:44:30 -0600180 apq8064_device_ssbi_pmic1.dev.platform_data =
Jay Chokshiea67c622011-07-29 17:12:26 -0700181 &apq8064_ssbi_pm8921_pdata;
Kenneth Heitke36920d32011-07-20 16:44:30 -0600182 apq8064_device_ssbi_pmic2.dev.platform_data =
183 &apq8064_ssbi_pm8821_pdata;
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -0700184 apq8064_device_otg.dev.platform_data = &msm_otg_pdata;
185 apq8064_device_gadget_peripheral.dev.parent = &apq8064_device_otg.dev;
Jay Chokshiea67c622011-07-29 17:12:26 -0700186 pm8921_platform_data.num_regulators =
187 msm8064_pm8921_regulator_pdata_len;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700188 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530189 apq8064_init_mmc();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700190}
191
192static void __init apq8064_sim_init(void)
193{
194 apq8064_common_init();
Joel King4e7ad222011-08-17 15:47:38 -0700195 platform_add_devices(sim_devices, ARRAY_SIZE(sim_devices));
196}
197
198static void __init apq8064_rumi3_init(void)
199{
200 apq8064_common_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700201}
202
203MACHINE_START(APQ8064_SIM, "QCT APQ8064 SIMULATOR")
204 .map_io = apq8064_map_io,
205 .init_irq = apq8064_init_irq,
206 .timer = &msm_timer,
207 .init_machine = apq8064_sim_init,
208MACHINE_END
209
Joel King4e7ad222011-08-17 15:47:38 -0700210MACHINE_START(APQ8064_RUMI3, "QCT APQ8064 RUMI3")
211 .map_io = apq8064_map_io,
212 .init_irq = apq8064_init_irq,
213 .timer = &msm_timer,
214 .init_machine = apq8064_rumi3_init,
215MACHINE_END
216