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