Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -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> |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 15 | #include <linux/i2c.h> |
Kenneth Heitke | af3d3cf | 2011-09-08 11:45:31 -0700 | [diff] [blame] | 16 | #include <linux/msm_ssbi.h> |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 17 | #include <asm/mach-types.h> |
| 18 | #include <asm/mach/arch.h> |
| 19 | #include <mach/board.h> |
| 20 | #include <mach/msm_iomap.h> |
| 21 | #include <mach/gpio.h> |
| 22 | #include <mach/gpiomux.h> |
Harini Jayaraman | 738c931 | 2011-09-08 15:22:38 -0600 | [diff] [blame] | 23 | #include <mach/msm_spi.h> |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 24 | #include "timer.h" |
| 25 | #include "devices.h" |
David Collins | fb88c43 | 2011-08-25 15:12:47 -0700 | [diff] [blame] | 26 | #include "board-9615.h" |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 27 | |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 28 | static struct platform_device *common_devices[] = { |
| 29 | &msm9615_device_uart_gsbi4, |
Kenneth Heitke | af3d3cf | 2011-09-08 11:45:31 -0700 | [diff] [blame] | 30 | &msm9615_device_ssbi_pmic1, |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 31 | &msm9615_device_qup_i2c_gsbi5, |
Harini Jayaraman | 738c931 | 2011-09-08 15:22:38 -0600 | [diff] [blame] | 32 | &msm9615_device_qup_spi_gsbi3, |
Yan He | 092b727 | 2011-09-21 15:25:03 -0700 | [diff] [blame^] | 33 | &msm_device_sps, |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 34 | }; |
| 35 | |
David Collins | fb88c43 | 2011-08-25 15:12:47 -0700 | [diff] [blame] | 36 | static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata __devinitdata = { |
| 37 | .irq_base = PM8018_IRQ_BASE, |
| 38 | .devirq = MSM_GPIO_TO_INT(87), |
| 39 | .irq_trigger_flag = IRQF_TRIGGER_LOW, |
| 40 | }; |
| 41 | |
| 42 | static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata __devinitdata = { |
| 43 | .gpio_base = PM8018_GPIO_PM_TO_SYS(1), |
| 44 | }; |
| 45 | |
| 46 | static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata __devinitdata = { |
| 47 | .mpp_base = PM8018_MPP_PM_TO_SYS(1), |
| 48 | }; |
| 49 | |
| 50 | static struct pm8xxx_rtc_platform_data pm8xxx_rtc_pdata __devinitdata = { |
| 51 | .rtc_write_enable = false, |
| 52 | }; |
| 53 | |
| 54 | static struct pm8xxx_pwrkey_platform_data pm8xxx_pwrkey_pdata = { |
| 55 | .pull_up = 1, |
| 56 | .kpd_trigger_delay_us = 970, |
| 57 | .wakeup = 1, |
| 58 | }; |
| 59 | |
| 60 | static struct pm8xxx_misc_platform_data pm8xxx_misc_pdata = { |
| 61 | .priority = 0, |
| 62 | }; |
| 63 | |
| 64 | static struct pm8018_platform_data pm8018_platform_data __devinitdata = { |
| 65 | .irq_pdata = &pm8xxx_irq_pdata, |
| 66 | .gpio_pdata = &pm8xxx_gpio_pdata, |
| 67 | .mpp_pdata = &pm8xxx_mpp_pdata, |
| 68 | .rtc_pdata = &pm8xxx_rtc_pdata, |
| 69 | .pwrkey_pdata = &pm8xxx_pwrkey_pdata, |
| 70 | .misc_pdata = &pm8xxx_misc_pdata, |
David Collins | 00b31e6 | 2011-08-31 20:00:10 -0700 | [diff] [blame] | 71 | .regulator_pdatas = msm_pm8018_regulator_pdata, |
David Collins | fb88c43 | 2011-08-25 15:12:47 -0700 | [diff] [blame] | 72 | }; |
| 73 | |
Kenneth Heitke | af3d3cf | 2011-09-08 11:45:31 -0700 | [diff] [blame] | 74 | static struct msm_ssbi_platform_data msm9615_ssbi_pm8018_pdata __devinitdata = { |
| 75 | .controller_type = MSM_SBI_CTRL_PMIC_ARBITER, |
| 76 | .slave = { |
David Collins | fb88c43 | 2011-08-25 15:12:47 -0700 | [diff] [blame] | 77 | .name = PM8018_CORE_DEV_NAME, |
| 78 | .platform_data = &pm8018_platform_data, |
Kenneth Heitke | af3d3cf | 2011-09-08 11:45:31 -0700 | [diff] [blame] | 79 | }, |
| 80 | }; |
| 81 | |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 82 | static struct gpiomux_setting gsbi4 = { |
| 83 | .func = GPIOMUX_FUNC_1, |
| 84 | .drv = GPIOMUX_DRV_8MA, |
| 85 | .pull = GPIOMUX_PULL_NONE, |
| 86 | }; |
| 87 | |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 88 | static struct gpiomux_setting gsbi5 = { |
| 89 | .func = GPIOMUX_FUNC_1, |
| 90 | .drv = GPIOMUX_DRV_8MA, |
| 91 | .pull = GPIOMUX_PULL_NONE, |
| 92 | }; |
| 93 | |
Harini Jayaraman | 738c931 | 2011-09-08 15:22:38 -0600 | [diff] [blame] | 94 | static struct gpiomux_setting gsbi3 = { |
| 95 | .func = GPIOMUX_FUNC_1, |
| 96 | .drv = GPIOMUX_DRV_8MA, |
| 97 | .pull = GPIOMUX_PULL_NONE, |
| 98 | }; |
| 99 | |
| 100 | static struct gpiomux_setting gsbi3_cs1_config = { |
| 101 | .func = GPIOMUX_FUNC_4, |
| 102 | .drv = GPIOMUX_DRV_8MA, |
| 103 | .pull = GPIOMUX_PULL_NONE, |
| 104 | }; |
| 105 | |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 106 | struct msm_gpiomux_config msm9615_gsbi_configs[] __initdata = { |
| 107 | { |
Harini Jayaraman | 738c931 | 2011-09-08 15:22:38 -0600 | [diff] [blame] | 108 | .gpio = 8, /* GSBI3 QUP SPI_CLK */ |
| 109 | .settings = { |
| 110 | [GPIOMUX_SUSPENDED] = &gsbi3, |
| 111 | }, |
| 112 | }, |
| 113 | { |
| 114 | .gpio = 9, /* GSBI3 QUP SPI_CS_N */ |
| 115 | .settings = { |
| 116 | [GPIOMUX_SUSPENDED] = &gsbi3, |
| 117 | }, |
| 118 | }, |
| 119 | { |
| 120 | .gpio = 10, /* GSBI3 QUP SPI_DATA_MISO */ |
| 121 | .settings = { |
| 122 | [GPIOMUX_SUSPENDED] = &gsbi3, |
| 123 | }, |
| 124 | }, |
| 125 | { |
| 126 | .gpio = 11, /* GSBI3 QUP SPI_DATA_MOSI */ |
| 127 | .settings = { |
| 128 | [GPIOMUX_SUSPENDED] = &gsbi3, |
| 129 | }, |
| 130 | }, |
| 131 | { |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 132 | .gpio = 12, /* GSBI4 UART */ |
| 133 | .settings = { |
| 134 | [GPIOMUX_SUSPENDED] = &gsbi4, |
| 135 | }, |
| 136 | }, |
| 137 | { |
| 138 | .gpio = 13, /* GSBI4 UART */ |
| 139 | .settings = { |
| 140 | [GPIOMUX_SUSPENDED] = &gsbi4, |
| 141 | }, |
| 142 | }, |
| 143 | { |
| 144 | .gpio = 14, /* GSBI4 UART */ |
| 145 | .settings = { |
| 146 | [GPIOMUX_SUSPENDED] = &gsbi4, |
| 147 | }, |
| 148 | }, |
| 149 | { |
| 150 | .gpio = 15, /* GSBI4 UART */ |
| 151 | .settings = { |
| 152 | [GPIOMUX_SUSPENDED] = &gsbi4, |
| 153 | }, |
| 154 | }, |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 155 | { |
| 156 | .gpio = 16, /* GSBI5 I2C QUP SCL */ |
| 157 | .settings = { |
| 158 | [GPIOMUX_SUSPENDED] = &gsbi5, |
| 159 | }, |
| 160 | }, |
| 161 | { |
| 162 | .gpio = 17, /* GSBI5 I2C QUP SDA */ |
| 163 | .settings = { |
| 164 | [GPIOMUX_SUSPENDED] = &gsbi5, |
| 165 | }, |
| 166 | }, |
Harini Jayaraman | 738c931 | 2011-09-08 15:22:38 -0600 | [diff] [blame] | 167 | { |
| 168 | /* GPIO 19 can be used for I2C/UART on GSBI5 */ |
| 169 | .gpio = 19, /* GSBI3 QUP SPI_CS_1 */ |
| 170 | .settings = { |
| 171 | [GPIOMUX_SUSPENDED] = &gsbi3_cs1_config, |
| 172 | }, |
| 173 | }, |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 174 | }; |
| 175 | |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 176 | static int __init gpiomux_init(void) |
| 177 | { |
| 178 | int rc; |
| 179 | |
| 180 | rc = msm_gpiomux_init(NR_GPIO_IRQS); |
| 181 | if (rc) { |
| 182 | pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc); |
| 183 | return rc; |
| 184 | } |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 185 | msm_gpiomux_install(msm9615_gsbi_configs, |
| 186 | ARRAY_SIZE(msm9615_gsbi_configs)); |
| 187 | |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 188 | return 0; |
| 189 | } |
| 190 | |
Harini Jayaraman | 738c931 | 2011-09-08 15:22:38 -0600 | [diff] [blame] | 191 | static struct msm_spi_platform_data msm9615_qup_spi_gsbi3_pdata = { |
| 192 | .max_clock_speed = 24000000, |
| 193 | }; |
| 194 | |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 195 | static struct msm_i2c_platform_data msm9615_i2c_qup_gsbi5_pdata = { |
| 196 | .clk_freq = 100000, |
| 197 | .src_clk_rate = 24000000, |
| 198 | }; |
| 199 | |
| 200 | static void __init msm9615_i2c_init(void) |
| 201 | { |
| 202 | msm9615_device_qup_i2c_gsbi5.dev.platform_data = |
| 203 | &msm9615_i2c_qup_gsbi5_pdata; |
| 204 | } |
| 205 | |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 206 | static void __init msm9615_common_init(void) |
| 207 | { |
| 208 | msm9615_device_init(); |
| 209 | gpiomux_init(); |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 210 | msm9615_i2c_init(); |
David Collins | 00b31e6 | 2011-08-31 20:00:10 -0700 | [diff] [blame] | 211 | regulator_suppress_info_printing(); |
Harini Jayaraman | 738c931 | 2011-09-08 15:22:38 -0600 | [diff] [blame] | 212 | msm9615_device_qup_spi_gsbi3.dev.platform_data = |
| 213 | &msm9615_qup_spi_gsbi3_pdata; |
Kenneth Heitke | af3d3cf | 2011-09-08 11:45:31 -0700 | [diff] [blame] | 214 | msm9615_device_ssbi_pmic1.dev.platform_data = |
| 215 | &msm9615_ssbi_pm8018_pdata; |
David Collins | 00b31e6 | 2011-08-31 20:00:10 -0700 | [diff] [blame] | 216 | pm8018_platform_data.num_regulators = msm_pm8018_regulator_pdata_len; |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 217 | platform_add_devices(common_devices, ARRAY_SIZE(common_devices)); |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | static void __init msm9615_cdp_init(void) |
| 221 | { |
| 222 | msm9615_common_init(); |
| 223 | } |
| 224 | |
| 225 | static void __init msm9615_mtp_init(void) |
| 226 | { |
| 227 | msm9615_common_init(); |
| 228 | } |
| 229 | |
| 230 | MACHINE_START(MSM9615_CDP, "QCT MSM9615 CDP") |
| 231 | .map_io = msm9615_map_io, |
| 232 | .init_irq = msm9615_init_irq, |
| 233 | .timer = &msm_timer, |
| 234 | .init_machine = msm9615_cdp_init, |
| 235 | MACHINE_END |
| 236 | |
| 237 | MACHINE_START(MSM9615_MTP, "QCT MSM9615 MTP") |
| 238 | .map_io = msm9615_map_io, |
| 239 | .init_irq = msm9615_init_irq, |
| 240 | .timer = &msm_timer, |
| 241 | .init_machine = msm9615_mtp_init, |
| 242 | MACHINE_END |