blob: 6bfdee8c10b58c06469c5e5032c0cb98185baaa9 [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>
22
23#include <mach/board.h>
24#include <mach/msm_iomap.h>
25#include <linux/usb/msm_hsusb.h>
26#include <linux/usb/android.h>
27#include <mach/socinfo.h>
Harini Jayaramanc4c58692011-07-19 14:50:10 -060028#include <mach/msm_spi.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070029#include "timer.h"
30#include "devices.h"
Joel King4ebccc62011-07-22 09:43:22 -070031#include <mach/gpio.h>
32#include <mach/gpiomux.h>
33
Jay Chokshiea67c622011-07-29 17:12:26 -070034#include "board-apq8064.h"
35
Joel King4ebccc62011-07-22 09:43:22 -070036static int __init gpiomux_init(void)
37{
38 int rc;
39
40 rc = msm_gpiomux_init(NR_GPIO_IRQS);
41 if (rc) {
42 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
43 return rc;
44 }
45 return 0;
46}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070047
48static void __init apq8064_map_io(void)
49{
50 msm_map_apq8064_io();
51}
52
53static void __init apq8064_init_irq(void)
54{
55 unsigned int i;
56 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
57 (void *)MSM_QGIC_CPU_BASE);
58
59 /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
60 writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
61
62 writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET);
63 mb();
64
65 /*
66 * FIXME: Not installing AVS_SVICINT and AVS_SVICINTSWDONE yet
67 * as they are configured as level, which does not play nice with
68 * handle_percpu_irq.
69 */
70 for (i = GIC_PPI_START; i < GIC_SPI_START; i++) {
71 if (i != AVS_SVICINT && i != AVS_SVICINTSWDONE)
72 irq_set_handler(i, handle_percpu_irq);
73 }
74}
75
76static struct platform_device *common_devices[] __initdata = {
Stepan Moskovchenkodf13d342011-08-03 19:01:25 -070077 &apq8064_device_dmov,
Harini Jayaramanc4c58692011-07-19 14:50:10 -060078 &apq8064_device_uart_gsbi3,
Kenneth Heitke748593a2011-07-15 15:45:11 -060079 &apq8064_device_qup_i2c_gsbi4,
Harini Jayaramanc4c58692011-07-19 14:50:10 -060080 &apq8064_device_qup_spi_gsbi5,
Kenneth Heitke36920d32011-07-20 16:44:30 -060081 &apq8064_device_ssbi_pmic1,
82 &apq8064_device_ssbi_pmic2,
Harini Jayaramanc4c58692011-07-19 14:50:10 -060083};
84
85static struct msm_spi_platform_data apq8064_qup_spi_gsbi5_pdata = {
86 .max_clock_speed = 26000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070087};
88
89static struct msm_otg_platform_data msm_otg_pdata = {
90 .mode = USB_PERIPHERAL,
91 .otg_control = OTG_PHY_CONTROL,
92 .phy_type = SNPS_28NM_INTEGRATED_PHY,
93 .pclk_src_name = "dfab_usb_hs_clk",
94};
95
Jay Chokshiea67c622011-07-29 17:12:26 -070096static struct pm8921_platform_data pm8921_platform_data __devinitdata = {
97 .regulator_pdatas = msm8064_pm8921_regulator_pdata,
98};
99
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700100static struct msm_ssbi_platform_data apq8064_ssbi_pm8921_pdata __devinitdata = {
101 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
102 .slave = {
Jay Chokshiea67c622011-07-29 17:12:26 -0700103 .name = "pm8921-core",
104 .platform_data = &pm8921_platform_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700105 },
106};
107
108static struct msm_ssbi_platform_data apq8064_ssbi_pm8821_pdata __devinitdata = {
109 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
110 .slave = {
Jay Chokshiea67c622011-07-29 17:12:26 -0700111 .name = "pm8821-core",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700112 },
113};
114
Kenneth Heitke748593a2011-07-15 15:45:11 -0600115static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi4_pdata = {
116 .clk_freq = 100000,
117 .src_clk_rate = 24000000,
118 .clk = "gsbi_qup_clk",
119 .pclk = "gsbi_pclk",
120};
121
122static void __init apq8064_i2c_init(void)
123{
124 apq8064_device_qup_i2c_gsbi4.dev.platform_data =
125 &apq8064_i2c_qup_gsbi4_pdata;
126}
127
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700128static void __init apq8064_common_init(void)
129{
130 if (socinfo_init() < 0)
131 pr_err("socinfo_init() failed!\n");
Stephen Boydbb600ae2011-08-02 20:11:40 -0700132 msm_clock_init(&apq8064_dummy_clock_init_data);
Joel King4ebccc62011-07-22 09:43:22 -0700133 gpiomux_init();
Kenneth Heitke748593a2011-07-15 15:45:11 -0600134 apq8064_i2c_init();
Kenneth Heitke36920d32011-07-20 16:44:30 -0600135
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600136 apq8064_device_qup_spi_gsbi5.dev.platform_data =
137 &apq8064_qup_spi_gsbi5_pdata;
Kenneth Heitke36920d32011-07-20 16:44:30 -0600138 apq8064_device_ssbi_pmic1.dev.platform_data =
Jay Chokshiea67c622011-07-29 17:12:26 -0700139 &apq8064_ssbi_pm8921_pdata;
Kenneth Heitke36920d32011-07-20 16:44:30 -0600140 apq8064_device_ssbi_pmic2.dev.platform_data =
141 &apq8064_ssbi_pm8821_pdata;
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -0700142 apq8064_device_otg.dev.platform_data = &msm_otg_pdata;
143 apq8064_device_gadget_peripheral.dev.parent = &apq8064_device_otg.dev;
Jay Chokshiea67c622011-07-29 17:12:26 -0700144 pm8921_platform_data.num_regulators =
145 msm8064_pm8921_regulator_pdata_len;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700146 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
147}
148
149static void __init apq8064_sim_init(void)
150{
151 apq8064_common_init();
152}
153
154MACHINE_START(APQ8064_SIM, "QCT APQ8064 SIMULATOR")
155 .map_io = apq8064_map_io,
156 .init_irq = apq8064_init_irq,
157 .timer = &msm_timer,
158 .init_machine = apq8064_sim_init,
159MACHINE_END
160