Stepan Moskovchenko | 5ea3c31 | 2012-01-31 18:19:40 -0800 | [diff] [blame^] | 1 | /* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved. |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 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 | |
| 14 | #include <linux/init.h> |
| 15 | #include <linux/ioport.h> |
| 16 | #include <linux/platform_device.h> |
| 17 | #include <linux/bootmem.h> |
| 18 | #include <asm/mach-types.h> |
| 19 | #include <asm/mach/mmc.h> |
| 20 | #include <mach/msm_bus_board.h> |
| 21 | #include <mach/board.h> |
| 22 | #include <mach/gpio.h> |
| 23 | #include <mach/gpiomux.h> |
| 24 | #include "devices.h" |
| 25 | #include "board-8064.h" |
| 26 | |
| 27 | #if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE) |
| 28 | static struct gpiomux_setting gpio_eth_config = { |
| 29 | .pull = GPIOMUX_PULL_NONE, |
| 30 | .drv = GPIOMUX_DRV_8MA, |
| 31 | .func = GPIOMUX_FUNC_GPIO, |
| 32 | }; |
| 33 | |
| 34 | /* The SPI configurations apply to GSBI 5*/ |
| 35 | static struct gpiomux_setting gpio_spi_config = { |
| 36 | .func = GPIOMUX_FUNC_2, |
| 37 | .drv = GPIOMUX_DRV_8MA, |
| 38 | .pull = GPIOMUX_PULL_NONE, |
| 39 | }; |
| 40 | |
| 41 | /* The SPI configurations apply to GSBI 5 chip select 2*/ |
| 42 | static struct gpiomux_setting gpio_spi_cs2_config = { |
| 43 | .func = GPIOMUX_FUNC_3, |
| 44 | .drv = GPIOMUX_DRV_8MA, |
| 45 | .pull = GPIOMUX_PULL_NONE, |
| 46 | }; |
| 47 | |
| 48 | struct msm_gpiomux_config apq8064_ethernet_configs[] = { |
| 49 | { |
| 50 | .gpio = 43, |
| 51 | .settings = { |
| 52 | [GPIOMUX_SUSPENDED] = &gpio_eth_config, |
| 53 | [GPIOMUX_ACTIVE] = &gpio_eth_config, |
| 54 | } |
| 55 | }, |
| 56 | }; |
| 57 | #endif |
| 58 | |
Swaminathan Sathappan | cef966d | 2011-12-15 17:27:04 -0800 | [diff] [blame] | 59 | static struct gpiomux_setting cdc_mclk = { |
| 60 | .func = GPIOMUX_FUNC_1, |
| 61 | .drv = GPIOMUX_DRV_8MA, |
| 62 | .pull = GPIOMUX_PULL_NONE, |
| 63 | }; |
| 64 | |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 65 | static struct gpiomux_setting audio_auxpcm[] = { |
| 66 | /* Suspended state */ |
| 67 | { |
| 68 | .func = GPIOMUX_FUNC_GPIO, |
| 69 | .drv = GPIOMUX_DRV_2MA, |
| 70 | .pull = GPIOMUX_PULL_NONE, |
| 71 | }, |
| 72 | /* Active state */ |
| 73 | { |
| 74 | .func = GPIOMUX_FUNC_1, |
| 75 | .drv = GPIOMUX_DRV_2MA, |
| 76 | .pull = GPIOMUX_PULL_NONE, |
| 77 | }, |
| 78 | }; |
| 79 | |
Swaminathan Sathappan | cef966d | 2011-12-15 17:27:04 -0800 | [diff] [blame] | 80 | static struct gpiomux_setting slimbus = { |
| 81 | .func = GPIOMUX_FUNC_1, |
| 82 | .drv = GPIOMUX_DRV_8MA, |
| 83 | .pull = GPIOMUX_PULL_KEEPER, |
| 84 | }; |
| 85 | |
Stepan Moskovchenko | 5ea3c31 | 2012-01-31 18:19:40 -0800 | [diff] [blame^] | 86 | static struct gpiomux_setting gsbi1_uart_config = { |
| 87 | .func = GPIOMUX_FUNC_1, |
| 88 | .drv = GPIOMUX_DRV_16MA, |
| 89 | .pull = GPIOMUX_PULL_NONE, |
| 90 | }; |
| 91 | |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 92 | static struct msm_gpiomux_config apq8064_gsbi_configs[] __initdata = { |
Stepan Moskovchenko | 5ea3c31 | 2012-01-31 18:19:40 -0800 | [diff] [blame^] | 93 | { |
| 94 | .gpio = 18, /* GSBI1 UART TX */ |
| 95 | .settings = { |
| 96 | [GPIOMUX_SUSPENDED] = &gsbi1_uart_config, |
| 97 | }, |
| 98 | }, |
| 99 | { |
| 100 | .gpio = 19, /* GSBI1 UART RX */ |
| 101 | .settings = { |
| 102 | [GPIOMUX_SUSPENDED] = &gsbi1_uart_config, |
| 103 | }, |
| 104 | }, |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 105 | #if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE) |
| 106 | { |
| 107 | .gpio = 51, /* GSBI5 QUP SPI_DATA_MOSI */ |
| 108 | .settings = { |
| 109 | [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| 110 | }, |
| 111 | }, |
| 112 | { |
| 113 | .gpio = 52, /* GSBI5 QUP SPI_DATA_MISO */ |
| 114 | .settings = { |
| 115 | [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| 116 | }, |
| 117 | }, |
| 118 | { |
| 119 | .gpio = 31, /* GSBI5 QUP SPI_CS2_N */ |
| 120 | .settings = { |
| 121 | [GPIOMUX_SUSPENDED] = &gpio_spi_cs2_config, |
| 122 | }, |
| 123 | }, |
| 124 | { |
| 125 | .gpio = 54, /* GSBI5 QUP SPI_CLK */ |
| 126 | .settings = { |
| 127 | [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| 128 | }, |
| 129 | }, |
| 130 | #endif |
| 131 | }; |
| 132 | |
Swaminathan Sathappan | cef966d | 2011-12-15 17:27:04 -0800 | [diff] [blame] | 133 | static struct msm_gpiomux_config apq8064_slimbus_config[] __initdata = { |
| 134 | { |
| 135 | .gpio = 40, /* slimbus clk */ |
| 136 | .settings = { |
| 137 | [GPIOMUX_SUSPENDED] = &slimbus, |
| 138 | }, |
| 139 | }, |
| 140 | { |
| 141 | .gpio = 41, /* slimbus data */ |
| 142 | .settings = { |
| 143 | [GPIOMUX_SUSPENDED] = &slimbus, |
| 144 | }, |
| 145 | }, |
| 146 | }; |
| 147 | |
| 148 | static struct msm_gpiomux_config apq8064_audio_codec_configs[] __initdata = { |
| 149 | { |
| 150 | .gpio = 39, |
| 151 | .settings = { |
| 152 | [GPIOMUX_SUSPENDED] = &cdc_mclk, |
| 153 | }, |
| 154 | }, |
| 155 | }; |
| 156 | |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 157 | static struct msm_gpiomux_config apq8064_audio_auxpcm_configs[] __initdata = { |
| 158 | { |
| 159 | .gpio = 43, |
| 160 | .settings = { |
| 161 | [GPIOMUX_SUSPENDED] = &audio_auxpcm[0], |
| 162 | [GPIOMUX_ACTIVE] = &audio_auxpcm[1], |
| 163 | }, |
| 164 | }, |
| 165 | { |
| 166 | .gpio = 44, |
| 167 | .settings = { |
| 168 | [GPIOMUX_SUSPENDED] = &audio_auxpcm[0], |
| 169 | [GPIOMUX_ACTIVE] = &audio_auxpcm[1], |
| 170 | }, |
| 171 | }, |
| 172 | { |
| 173 | .gpio = 45, |
| 174 | .settings = { |
| 175 | [GPIOMUX_SUSPENDED] = &audio_auxpcm[0], |
| 176 | [GPIOMUX_ACTIVE] = &audio_auxpcm[1], |
| 177 | }, |
| 178 | }, |
| 179 | { |
| 180 | .gpio = 46, |
| 181 | .settings = { |
| 182 | [GPIOMUX_SUSPENDED] = &audio_auxpcm[0], |
| 183 | [GPIOMUX_ACTIVE] = &audio_auxpcm[1], |
| 184 | }, |
| 185 | }, |
| 186 | }; |
| 187 | |
| 188 | void __init apq8064_init_gpiomux(void) |
| 189 | { |
| 190 | int rc; |
| 191 | |
| 192 | rc = msm_gpiomux_init(NR_GPIO_IRQS); |
| 193 | if (rc) { |
| 194 | pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc); |
| 195 | return; |
| 196 | } |
| 197 | |
| 198 | #if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE) |
| 199 | msm_gpiomux_install(apq8064_ethernet_configs, |
| 200 | ARRAY_SIZE(apq8064_ethernet_configs)); |
| 201 | #endif |
| 202 | |
| 203 | msm_gpiomux_install(apq8064_gsbi_configs, |
| 204 | ARRAY_SIZE(apq8064_gsbi_configs)); |
| 205 | |
Swaminathan Sathappan | cef966d | 2011-12-15 17:27:04 -0800 | [diff] [blame] | 206 | msm_gpiomux_install(apq8064_slimbus_config, |
| 207 | ARRAY_SIZE(apq8064_slimbus_config)); |
| 208 | |
| 209 | msm_gpiomux_install(apq8064_audio_codec_configs, |
| 210 | ARRAY_SIZE(apq8064_audio_codec_configs)); |
| 211 | |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 212 | msm_gpiomux_install(apq8064_audio_auxpcm_configs, |
| 213 | ARRAY_SIZE(apq8064_audio_auxpcm_configs)); |
| 214 | } |