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" |
| 26 | |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 27 | static struct platform_device *common_devices[] = { |
| 28 | &msm9615_device_uart_gsbi4, |
Kenneth Heitke | af3d3cf | 2011-09-08 11:45:31 -0700 | [diff] [blame^] | 29 | &msm9615_device_ssbi_pmic1, |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 30 | &msm9615_device_qup_i2c_gsbi5, |
Harini Jayaraman | 738c931 | 2011-09-08 15:22:38 -0600 | [diff] [blame] | 31 | &msm9615_device_qup_spi_gsbi3, |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 32 | }; |
| 33 | |
Kenneth Heitke | af3d3cf | 2011-09-08 11:45:31 -0700 | [diff] [blame^] | 34 | static struct msm_ssbi_platform_data msm9615_ssbi_pm8018_pdata __devinitdata = { |
| 35 | .controller_type = MSM_SBI_CTRL_PMIC_ARBITER, |
| 36 | .slave = { |
| 37 | .name = "pm8018-core", |
| 38 | }, |
| 39 | }; |
| 40 | |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 41 | static struct gpiomux_setting gsbi4 = { |
| 42 | .func = GPIOMUX_FUNC_1, |
| 43 | .drv = GPIOMUX_DRV_8MA, |
| 44 | .pull = GPIOMUX_PULL_NONE, |
| 45 | }; |
| 46 | |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 47 | static struct gpiomux_setting gsbi5 = { |
| 48 | .func = GPIOMUX_FUNC_1, |
| 49 | .drv = GPIOMUX_DRV_8MA, |
| 50 | .pull = GPIOMUX_PULL_NONE, |
| 51 | }; |
| 52 | |
Harini Jayaraman | 738c931 | 2011-09-08 15:22:38 -0600 | [diff] [blame] | 53 | static struct gpiomux_setting gsbi3 = { |
| 54 | .func = GPIOMUX_FUNC_1, |
| 55 | .drv = GPIOMUX_DRV_8MA, |
| 56 | .pull = GPIOMUX_PULL_NONE, |
| 57 | }; |
| 58 | |
| 59 | static struct gpiomux_setting gsbi3_cs1_config = { |
| 60 | .func = GPIOMUX_FUNC_4, |
| 61 | .drv = GPIOMUX_DRV_8MA, |
| 62 | .pull = GPIOMUX_PULL_NONE, |
| 63 | }; |
| 64 | |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 65 | struct msm_gpiomux_config msm9615_gsbi_configs[] __initdata = { |
| 66 | { |
Harini Jayaraman | 738c931 | 2011-09-08 15:22:38 -0600 | [diff] [blame] | 67 | .gpio = 8, /* GSBI3 QUP SPI_CLK */ |
| 68 | .settings = { |
| 69 | [GPIOMUX_SUSPENDED] = &gsbi3, |
| 70 | }, |
| 71 | }, |
| 72 | { |
| 73 | .gpio = 9, /* GSBI3 QUP SPI_CS_N */ |
| 74 | .settings = { |
| 75 | [GPIOMUX_SUSPENDED] = &gsbi3, |
| 76 | }, |
| 77 | }, |
| 78 | { |
| 79 | .gpio = 10, /* GSBI3 QUP SPI_DATA_MISO */ |
| 80 | .settings = { |
| 81 | [GPIOMUX_SUSPENDED] = &gsbi3, |
| 82 | }, |
| 83 | }, |
| 84 | { |
| 85 | .gpio = 11, /* GSBI3 QUP SPI_DATA_MOSI */ |
| 86 | .settings = { |
| 87 | [GPIOMUX_SUSPENDED] = &gsbi3, |
| 88 | }, |
| 89 | }, |
| 90 | { |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 91 | .gpio = 12, /* GSBI4 UART */ |
| 92 | .settings = { |
| 93 | [GPIOMUX_SUSPENDED] = &gsbi4, |
| 94 | }, |
| 95 | }, |
| 96 | { |
| 97 | .gpio = 13, /* GSBI4 UART */ |
| 98 | .settings = { |
| 99 | [GPIOMUX_SUSPENDED] = &gsbi4, |
| 100 | }, |
| 101 | }, |
| 102 | { |
| 103 | .gpio = 14, /* GSBI4 UART */ |
| 104 | .settings = { |
| 105 | [GPIOMUX_SUSPENDED] = &gsbi4, |
| 106 | }, |
| 107 | }, |
| 108 | { |
| 109 | .gpio = 15, /* GSBI4 UART */ |
| 110 | .settings = { |
| 111 | [GPIOMUX_SUSPENDED] = &gsbi4, |
| 112 | }, |
| 113 | }, |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 114 | { |
| 115 | .gpio = 16, /* GSBI5 I2C QUP SCL */ |
| 116 | .settings = { |
| 117 | [GPIOMUX_SUSPENDED] = &gsbi5, |
| 118 | }, |
| 119 | }, |
| 120 | { |
| 121 | .gpio = 17, /* GSBI5 I2C QUP SDA */ |
| 122 | .settings = { |
| 123 | [GPIOMUX_SUSPENDED] = &gsbi5, |
| 124 | }, |
| 125 | }, |
Harini Jayaraman | 738c931 | 2011-09-08 15:22:38 -0600 | [diff] [blame] | 126 | { |
| 127 | /* GPIO 19 can be used for I2C/UART on GSBI5 */ |
| 128 | .gpio = 19, /* GSBI3 QUP SPI_CS_1 */ |
| 129 | .settings = { |
| 130 | [GPIOMUX_SUSPENDED] = &gsbi3_cs1_config, |
| 131 | }, |
| 132 | }, |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 133 | }; |
| 134 | |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 135 | static int __init gpiomux_init(void) |
| 136 | { |
| 137 | int rc; |
| 138 | |
| 139 | rc = msm_gpiomux_init(NR_GPIO_IRQS); |
| 140 | if (rc) { |
| 141 | pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc); |
| 142 | return rc; |
| 143 | } |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 144 | msm_gpiomux_install(msm9615_gsbi_configs, |
| 145 | ARRAY_SIZE(msm9615_gsbi_configs)); |
| 146 | |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 147 | return 0; |
| 148 | } |
| 149 | |
Harini Jayaraman | 738c931 | 2011-09-08 15:22:38 -0600 | [diff] [blame] | 150 | static struct msm_spi_platform_data msm9615_qup_spi_gsbi3_pdata = { |
| 151 | .max_clock_speed = 24000000, |
| 152 | }; |
| 153 | |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 154 | static struct msm_i2c_platform_data msm9615_i2c_qup_gsbi5_pdata = { |
| 155 | .clk_freq = 100000, |
| 156 | .src_clk_rate = 24000000, |
| 157 | }; |
| 158 | |
| 159 | static void __init msm9615_i2c_init(void) |
| 160 | { |
| 161 | msm9615_device_qup_i2c_gsbi5.dev.platform_data = |
| 162 | &msm9615_i2c_qup_gsbi5_pdata; |
| 163 | } |
| 164 | |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 165 | static void __init msm9615_common_init(void) |
| 166 | { |
| 167 | msm9615_device_init(); |
| 168 | gpiomux_init(); |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 169 | msm9615_i2c_init(); |
Harini Jayaraman | 738c931 | 2011-09-08 15:22:38 -0600 | [diff] [blame] | 170 | msm9615_device_qup_spi_gsbi3.dev.platform_data = |
| 171 | &msm9615_qup_spi_gsbi3_pdata; |
Kenneth Heitke | af3d3cf | 2011-09-08 11:45:31 -0700 | [diff] [blame^] | 172 | msm9615_device_ssbi_pmic1.dev.platform_data = |
| 173 | &msm9615_ssbi_pm8018_pdata; |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 174 | platform_add_devices(common_devices, ARRAY_SIZE(common_devices)); |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | static void __init msm9615_cdp_init(void) |
| 178 | { |
| 179 | msm9615_common_init(); |
| 180 | } |
| 181 | |
| 182 | static void __init msm9615_mtp_init(void) |
| 183 | { |
| 184 | msm9615_common_init(); |
| 185 | } |
| 186 | |
| 187 | MACHINE_START(MSM9615_CDP, "QCT MSM9615 CDP") |
| 188 | .map_io = msm9615_map_io, |
| 189 | .init_irq = msm9615_init_irq, |
| 190 | .timer = &msm_timer, |
| 191 | .init_machine = msm9615_cdp_init, |
| 192 | MACHINE_END |
| 193 | |
| 194 | MACHINE_START(MSM9615_MTP, "QCT MSM9615 MTP") |
| 195 | .map_io = msm9615_map_io, |
| 196 | .init_irq = msm9615_init_irq, |
| 197 | .timer = &msm_timer, |
| 198 | .init_machine = msm9615_mtp_init, |
| 199 | MACHINE_END |