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