Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [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 | |
| 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 | |
| 59 | static struct gpiomux_setting audio_auxpcm[] = { |
| 60 | /* Suspended state */ |
| 61 | { |
| 62 | .func = GPIOMUX_FUNC_GPIO, |
| 63 | .drv = GPIOMUX_DRV_2MA, |
| 64 | .pull = GPIOMUX_PULL_NONE, |
| 65 | }, |
| 66 | /* Active state */ |
| 67 | { |
| 68 | .func = GPIOMUX_FUNC_1, |
| 69 | .drv = GPIOMUX_DRV_2MA, |
| 70 | .pull = GPIOMUX_PULL_NONE, |
| 71 | }, |
| 72 | }; |
| 73 | |
| 74 | static struct msm_gpiomux_config apq8064_gsbi_configs[] __initdata = { |
| 75 | #if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE) |
| 76 | { |
| 77 | .gpio = 51, /* GSBI5 QUP SPI_DATA_MOSI */ |
| 78 | .settings = { |
| 79 | [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| 80 | }, |
| 81 | }, |
| 82 | { |
| 83 | .gpio = 52, /* GSBI5 QUP SPI_DATA_MISO */ |
| 84 | .settings = { |
| 85 | [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| 86 | }, |
| 87 | }, |
| 88 | { |
| 89 | .gpio = 31, /* GSBI5 QUP SPI_CS2_N */ |
| 90 | .settings = { |
| 91 | [GPIOMUX_SUSPENDED] = &gpio_spi_cs2_config, |
| 92 | }, |
| 93 | }, |
| 94 | { |
| 95 | .gpio = 54, /* GSBI5 QUP SPI_CLK */ |
| 96 | .settings = { |
| 97 | [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| 98 | }, |
| 99 | }, |
| 100 | #endif |
| 101 | }; |
| 102 | |
| 103 | static struct msm_gpiomux_config apq8064_audio_auxpcm_configs[] __initdata = { |
| 104 | { |
| 105 | .gpio = 43, |
| 106 | .settings = { |
| 107 | [GPIOMUX_SUSPENDED] = &audio_auxpcm[0], |
| 108 | [GPIOMUX_ACTIVE] = &audio_auxpcm[1], |
| 109 | }, |
| 110 | }, |
| 111 | { |
| 112 | .gpio = 44, |
| 113 | .settings = { |
| 114 | [GPIOMUX_SUSPENDED] = &audio_auxpcm[0], |
| 115 | [GPIOMUX_ACTIVE] = &audio_auxpcm[1], |
| 116 | }, |
| 117 | }, |
| 118 | { |
| 119 | .gpio = 45, |
| 120 | .settings = { |
| 121 | [GPIOMUX_SUSPENDED] = &audio_auxpcm[0], |
| 122 | [GPIOMUX_ACTIVE] = &audio_auxpcm[1], |
| 123 | }, |
| 124 | }, |
| 125 | { |
| 126 | .gpio = 46, |
| 127 | .settings = { |
| 128 | [GPIOMUX_SUSPENDED] = &audio_auxpcm[0], |
| 129 | [GPIOMUX_ACTIVE] = &audio_auxpcm[1], |
| 130 | }, |
| 131 | }, |
| 132 | }; |
| 133 | |
| 134 | void __init apq8064_init_gpiomux(void) |
| 135 | { |
| 136 | int rc; |
| 137 | |
| 138 | rc = msm_gpiomux_init(NR_GPIO_IRQS); |
| 139 | if (rc) { |
| 140 | pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc); |
| 141 | return; |
| 142 | } |
| 143 | |
| 144 | #if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE) |
| 145 | msm_gpiomux_install(apq8064_ethernet_configs, |
| 146 | ARRAY_SIZE(apq8064_ethernet_configs)); |
| 147 | #endif |
| 148 | |
| 149 | msm_gpiomux_install(apq8064_gsbi_configs, |
| 150 | ARRAY_SIZE(apq8064_gsbi_configs)); |
| 151 | |
| 152 | msm_gpiomux_install(apq8064_audio_auxpcm_configs, |
| 153 | ARRAY_SIZE(apq8064_audio_auxpcm_configs)); |
| 154 | } |