Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1 | /* 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 Heitke | 36920d3 | 2011-07-20 16:44:30 -0600 | [diff] [blame^] | 17 | #include <linux/msm_ssbi.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 18 | #include <asm/mach-types.h> |
| 19 | #include <asm/mach/arch.h> |
| 20 | #include <asm/hardware/gic.h> |
| 21 | |
| 22 | #include <mach/board.h> |
| 23 | #include <mach/msm_iomap.h> |
| 24 | #include <linux/usb/msm_hsusb.h> |
| 25 | #include <linux/usb/android.h> |
| 26 | #include <mach/socinfo.h> |
Harini Jayaraman | c4c5869 | 2011-07-19 14:50:10 -0600 | [diff] [blame] | 27 | #include <mach/msm_spi.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 28 | #include "timer.h" |
| 29 | #include "devices.h" |
Joel King | 4ebccc6 | 2011-07-22 09:43:22 -0700 | [diff] [blame] | 30 | #include <mach/gpio.h> |
| 31 | #include <mach/gpiomux.h> |
| 32 | |
| 33 | static int __init gpiomux_init(void) |
| 34 | { |
| 35 | int rc; |
| 36 | |
| 37 | rc = msm_gpiomux_init(NR_GPIO_IRQS); |
| 38 | if (rc) { |
| 39 | pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc); |
| 40 | return rc; |
| 41 | } |
| 42 | return 0; |
| 43 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 44 | |
| 45 | static void __init apq8064_map_io(void) |
| 46 | { |
| 47 | msm_map_apq8064_io(); |
| 48 | } |
| 49 | |
| 50 | static void __init apq8064_init_irq(void) |
| 51 | { |
| 52 | unsigned int i; |
| 53 | gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE, |
| 54 | (void *)MSM_QGIC_CPU_BASE); |
| 55 | |
| 56 | /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */ |
| 57 | writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4); |
| 58 | |
| 59 | writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET); |
| 60 | mb(); |
| 61 | |
| 62 | /* |
| 63 | * FIXME: Not installing AVS_SVICINT and AVS_SVICINTSWDONE yet |
| 64 | * as they are configured as level, which does not play nice with |
| 65 | * handle_percpu_irq. |
| 66 | */ |
| 67 | for (i = GIC_PPI_START; i < GIC_SPI_START; i++) { |
| 68 | if (i != AVS_SVICINT && i != AVS_SVICINTSWDONE) |
| 69 | irq_set_handler(i, handle_percpu_irq); |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | static struct platform_device *common_devices[] __initdata = { |
Joel King | 0581896d | 2011-07-19 16:43:28 -0700 | [diff] [blame] | 74 | &msm_device_dmov, |
Harini Jayaraman | c4c5869 | 2011-07-19 14:50:10 -0600 | [diff] [blame] | 75 | &apq8064_device_uart_gsbi3, |
| 76 | &apq8064_device_qup_spi_gsbi5, |
Kenneth Heitke | 36920d3 | 2011-07-20 16:44:30 -0600 | [diff] [blame^] | 77 | &apq8064_device_ssbi_pmic1, |
| 78 | &apq8064_device_ssbi_pmic2, |
Harini Jayaraman | c4c5869 | 2011-07-19 14:50:10 -0600 | [diff] [blame] | 79 | }; |
| 80 | |
| 81 | static struct msm_spi_platform_data apq8064_qup_spi_gsbi5_pdata = { |
| 82 | .max_clock_speed = 26000000, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | static struct msm_otg_platform_data msm_otg_pdata = { |
| 86 | .mode = USB_PERIPHERAL, |
| 87 | .otg_control = OTG_PHY_CONTROL, |
| 88 | .phy_type = SNPS_28NM_INTEGRATED_PHY, |
| 89 | .pclk_src_name = "dfab_usb_hs_clk", |
| 90 | }; |
| 91 | |
| 92 | static struct msm_ssbi_platform_data apq8064_ssbi_pm8921_pdata __devinitdata = { |
| 93 | .controller_type = MSM_SBI_CTRL_PMIC_ARBITER, |
| 94 | .slave = { |
| 95 | .name = "pm8921-core", |
| 96 | }, |
| 97 | }; |
| 98 | |
| 99 | static struct msm_ssbi_platform_data apq8064_ssbi_pm8821_pdata __devinitdata = { |
| 100 | .controller_type = MSM_SBI_CTRL_PMIC_ARBITER, |
| 101 | .slave = { |
| 102 | .name = "pm8821-core", |
| 103 | }, |
| 104 | }; |
| 105 | |
| 106 | static void __init apq8064_common_init(void) |
| 107 | { |
| 108 | if (socinfo_init() < 0) |
| 109 | pr_err("socinfo_init() failed!\n"); |
| 110 | msm_clock_init(msm_clocks_8064_dummy, msm_num_clocks_8064_dummy); |
Joel King | 4ebccc6 | 2011-07-22 09:43:22 -0700 | [diff] [blame] | 111 | gpiomux_init(); |
Kenneth Heitke | 36920d3 | 2011-07-20 16:44:30 -0600 | [diff] [blame^] | 112 | |
Harini Jayaraman | c4c5869 | 2011-07-19 14:50:10 -0600 | [diff] [blame] | 113 | apq8064_device_qup_spi_gsbi5.dev.platform_data = |
| 114 | &apq8064_qup_spi_gsbi5_pdata; |
Kenneth Heitke | 36920d3 | 2011-07-20 16:44:30 -0600 | [diff] [blame^] | 115 | apq8064_device_ssbi_pmic1.dev.platform_data = |
| 116 | &apq8064_ssbi_pm8921_pdata; |
| 117 | apq8064_device_ssbi_pmic2.dev.platform_data = |
| 118 | &apq8064_ssbi_pm8821_pdata; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 119 | platform_add_devices(common_devices, ARRAY_SIZE(common_devices)); |
| 120 | } |
| 121 | |
| 122 | static void __init apq8064_sim_init(void) |
| 123 | { |
| 124 | apq8064_common_init(); |
| 125 | } |
| 126 | |
| 127 | MACHINE_START(APQ8064_SIM, "QCT APQ8064 SIMULATOR") |
| 128 | .map_io = apq8064_map_io, |
| 129 | .init_irq = apq8064_init_irq, |
| 130 | .timer = &msm_timer, |
| 131 | .init_machine = apq8064_sim_init, |
| 132 | MACHINE_END |
| 133 | |