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