| /* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved. |
| * |
| * This program is free software; you can redistribute it and/or modify |
| * it under the terms of the GNU General Public License version 2 and |
| * only version 2 as published by the Free Software Foundation. |
| * |
| * This program is distributed in the hope that it will be useful, |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| * GNU General Public License for more details. |
| * |
| */ |
| |
| #include <linux/init.h> |
| #include <linux/ioport.h> |
| #include <linux/platform_device.h> |
| #include <linux/bootmem.h> |
| #include <asm/mach-types.h> |
| #include <asm/mach/mmc.h> |
| #include <mach/msm_bus_board.h> |
| #include <mach/board.h> |
| #include <mach/gpio.h> |
| #include <mach/gpiomux.h> |
| #include <mach/socinfo.h> |
| #include "devices.h" |
| #include "board-8064.h" |
| |
| #if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE) |
| static struct gpiomux_setting gpio_eth_config = { |
| .pull = GPIOMUX_PULL_NONE, |
| .drv = GPIOMUX_DRV_8MA, |
| .func = GPIOMUX_FUNC_GPIO, |
| }; |
| |
| /* The SPI configurations apply to GSBI 5*/ |
| static struct gpiomux_setting gpio_spi_config = { |
| .func = GPIOMUX_FUNC_2, |
| .drv = GPIOMUX_DRV_12MA, |
| .pull = GPIOMUX_PULL_NONE, |
| }; |
| |
| /* The SPI configurations apply to GSBI 5 chip select 2*/ |
| static struct gpiomux_setting gpio_spi_cs2_config = { |
| .func = GPIOMUX_FUNC_3, |
| .drv = GPIOMUX_DRV_12MA, |
| .pull = GPIOMUX_PULL_NONE, |
| }; |
| |
| /* Chip selects for SPI clients */ |
| static struct gpiomux_setting gpio_spi_cs_config = { |
| .func = GPIOMUX_FUNC_GPIO, |
| .drv = GPIOMUX_DRV_12MA, |
| .pull = GPIOMUX_PULL_UP, |
| }; |
| |
| struct msm_gpiomux_config apq8064_ethernet_configs[] = { |
| { |
| .gpio = 43, |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &gpio_eth_config, |
| [GPIOMUX_ACTIVE] = &gpio_eth_config, |
| } |
| }, |
| }; |
| #endif |
| |
| static struct gpiomux_setting cdc_mclk = { |
| .func = GPIOMUX_FUNC_1, |
| .drv = GPIOMUX_DRV_8MA, |
| .pull = GPIOMUX_PULL_NONE, |
| }; |
| |
| static struct gpiomux_setting audio_auxpcm[] = { |
| /* Suspended state */ |
| { |
| .func = GPIOMUX_FUNC_GPIO, |
| .drv = GPIOMUX_DRV_2MA, |
| .pull = GPIOMUX_PULL_NONE, |
| }, |
| /* Active state */ |
| { |
| .func = GPIOMUX_FUNC_1, |
| .drv = GPIOMUX_DRV_2MA, |
| .pull = GPIOMUX_PULL_NONE, |
| }, |
| }; |
| |
| static struct gpiomux_setting slimbus = { |
| .func = GPIOMUX_FUNC_1, |
| .drv = GPIOMUX_DRV_8MA, |
| .pull = GPIOMUX_PULL_KEEPER, |
| }; |
| |
| static struct gpiomux_setting gsbi1_uart_config = { |
| .func = GPIOMUX_FUNC_1, |
| .drv = GPIOMUX_DRV_16MA, |
| .pull = GPIOMUX_PULL_NONE, |
| }; |
| |
| static struct gpiomux_setting ext_regulator_config = { |
| .func = GPIOMUX_FUNC_GPIO, |
| .drv = GPIOMUX_DRV_8MA, |
| .pull = GPIOMUX_PULL_NONE, |
| .dir = GPIOMUX_OUT_LOW, |
| }; |
| |
| static struct gpiomux_setting gsbi7_func1_cfg = { |
| .func = GPIOMUX_FUNC_1, |
| .drv = GPIOMUX_DRV_8MA, |
| .pull = GPIOMUX_PULL_NONE, |
| }; |
| |
| static struct gpiomux_setting gsbi7_func2_cfg = { |
| .func = GPIOMUX_FUNC_2, |
| .drv = GPIOMUX_DRV_8MA, |
| .pull = GPIOMUX_PULL_NONE, |
| }; |
| |
| #ifdef CONFIG_USB_EHCI_MSM_HSIC |
| static struct gpiomux_setting hsic_act_cfg = { |
| .func = GPIOMUX_FUNC_1, |
| .drv = GPIOMUX_DRV_8MA, |
| .pull = GPIOMUX_PULL_NONE, |
| }; |
| |
| static struct gpiomux_setting hsic_sus_cfg = { |
| .func = GPIOMUX_FUNC_GPIO, |
| .drv = GPIOMUX_DRV_2MA, |
| .pull = GPIOMUX_PULL_DOWN, |
| .dir = GPIOMUX_OUT_LOW, |
| }; |
| |
| static struct msm_gpiomux_config apq8064_hsic_configs[] = { |
| { |
| .gpio = 88, /*HSIC_STROBE */ |
| .settings = { |
| [GPIOMUX_ACTIVE] = &hsic_act_cfg, |
| [GPIOMUX_SUSPENDED] = &hsic_sus_cfg, |
| }, |
| }, |
| { |
| .gpio = 89, /* HSIC_DATA */ |
| .settings = { |
| [GPIOMUX_ACTIVE] = &hsic_act_cfg, |
| [GPIOMUX_SUSPENDED] = &hsic_sus_cfg, |
| }, |
| }, |
| }; |
| #endif |
| |
| static struct msm_gpiomux_config apq8064_gsbi_configs[] __initdata = { |
| { |
| .gpio = 18, /* GSBI1 UART TX */ |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &gsbi1_uart_config, |
| }, |
| }, |
| { |
| .gpio = 19, /* GSBI1 UART RX */ |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &gsbi1_uart_config, |
| }, |
| }, |
| #if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE) |
| { |
| .gpio = 51, /* GSBI5 QUP SPI_DATA_MOSI */ |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| }, |
| }, |
| { |
| .gpio = 52, /* GSBI5 QUP SPI_DATA_MISO */ |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| }, |
| }, |
| { |
| .gpio = 53, /* Funny CS0 */ |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| }, |
| }, |
| { |
| .gpio = 31, /* GSBI5 QUP SPI_CS2_N */ |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &gpio_spi_cs2_config, |
| }, |
| }, |
| { |
| .gpio = 54, /* GSBI5 QUP SPI_CLK */ |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| }, |
| }, |
| #endif |
| { |
| .gpio = 30, /* FP CS */ |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config, |
| }, |
| }, |
| { |
| .gpio = 32, /* EPM CS */ |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config, |
| }, |
| }, |
| { |
| .gpio = 53, /* NOR CS */ |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config, |
| }, |
| }, |
| { |
| .gpio = 82, /* GSBI7 UART2 TX */ |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &gsbi7_func2_cfg, |
| }, |
| }, |
| { |
| .gpio = 83, /* GSBI7 UART2 RX */ |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &gsbi7_func1_cfg, |
| }, |
| }, |
| }; |
| |
| static struct msm_gpiomux_config apq8064_slimbus_config[] __initdata = { |
| { |
| .gpio = 40, /* slimbus clk */ |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &slimbus, |
| }, |
| }, |
| { |
| .gpio = 41, /* slimbus data */ |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &slimbus, |
| }, |
| }, |
| }; |
| |
| static struct msm_gpiomux_config apq8064_audio_codec_configs[] __initdata = { |
| { |
| .gpio = 39, |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &cdc_mclk, |
| }, |
| }, |
| }; |
| |
| static struct msm_gpiomux_config apq8064_audio_auxpcm_configs[] __initdata = { |
| { |
| .gpio = 43, |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &audio_auxpcm[0], |
| [GPIOMUX_ACTIVE] = &audio_auxpcm[1], |
| }, |
| }, |
| { |
| .gpio = 44, |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &audio_auxpcm[0], |
| [GPIOMUX_ACTIVE] = &audio_auxpcm[1], |
| }, |
| }, |
| { |
| .gpio = 45, |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &audio_auxpcm[0], |
| [GPIOMUX_ACTIVE] = &audio_auxpcm[1], |
| }, |
| }, |
| { |
| .gpio = 46, |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &audio_auxpcm[0], |
| [GPIOMUX_ACTIVE] = &audio_auxpcm[1], |
| }, |
| }, |
| }; |
| |
| /* External 3.3 V regulator enable */ |
| static struct msm_gpiomux_config apq8064_ext_regulator_configs[] __initdata = { |
| { |
| .gpio = APQ8064_EXT_3P3V_REG_EN_GPIO, |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &ext_regulator_config, |
| }, |
| }, |
| }; |
| |
| static struct gpiomux_setting ap2mdm_cfg = { |
| .func = GPIOMUX_FUNC_GPIO, |
| .drv = GPIOMUX_DRV_8MA, |
| .pull = GPIOMUX_PULL_DOWN, |
| }; |
| |
| static struct gpiomux_setting mdm2ap_status_cfg = { |
| .func = GPIOMUX_FUNC_GPIO, |
| .drv = GPIOMUX_DRV_8MA, |
| .pull = GPIOMUX_PULL_NONE, |
| }; |
| |
| static struct gpiomux_setting mdm2ap_errfatal_cfg = { |
| .func = GPIOMUX_FUNC_GPIO, |
| .drv = GPIOMUX_DRV_16MA, |
| .pull = GPIOMUX_PULL_DOWN, |
| }; |
| |
| static struct gpiomux_setting ap2mdm_pon_reset_n_cfg = { |
| .func = GPIOMUX_FUNC_GPIO, |
| .drv = GPIOMUX_DRV_8MA, |
| .pull = GPIOMUX_PULL_DOWN, |
| }; |
| |
| static struct msm_gpiomux_config mdm_configs[] __initdata = { |
| /* AP2MDM_STATUS */ |
| { |
| .gpio = 48, |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &ap2mdm_cfg, |
| } |
| }, |
| /* MDM2AP_STATUS */ |
| { |
| .gpio = 49, |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &mdm2ap_status_cfg, |
| } |
| }, |
| /* MDM2AP_ERRFATAL */ |
| { |
| .gpio = 19, |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &mdm2ap_errfatal_cfg, |
| } |
| }, |
| /* AP2MDM_ERRFATAL */ |
| { |
| .gpio = 18, |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &ap2mdm_cfg, |
| } |
| }, |
| /* AP2MDM_PON_RESET_N */ |
| { |
| .gpio = 27, |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &ap2mdm_pon_reset_n_cfg, |
| } |
| } |
| }; |
| |
| void __init apq8064_init_gpiomux(void) |
| { |
| int rc; |
| |
| rc = msm_gpiomux_init(NR_GPIO_IRQS); |
| if (rc) { |
| pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc); |
| return; |
| } |
| |
| #if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE) |
| msm_gpiomux_install(apq8064_ethernet_configs, |
| ARRAY_SIZE(apq8064_ethernet_configs)); |
| #endif |
| |
| msm_gpiomux_install(apq8064_gsbi_configs, |
| ARRAY_SIZE(apq8064_gsbi_configs)); |
| |
| msm_gpiomux_install(apq8064_slimbus_config, |
| ARRAY_SIZE(apq8064_slimbus_config)); |
| |
| msm_gpiomux_install(apq8064_audio_codec_configs, |
| ARRAY_SIZE(apq8064_audio_codec_configs)); |
| |
| msm_gpiomux_install(apq8064_audio_auxpcm_configs, |
| ARRAY_SIZE(apq8064_audio_auxpcm_configs)); |
| |
| msm_gpiomux_install(apq8064_ext_regulator_configs, |
| ARRAY_SIZE(apq8064_ext_regulator_configs)); |
| |
| if (machine_is_apq8064_mtp()) |
| msm_gpiomux_install(mdm_configs, |
| ARRAY_SIZE(mdm_configs)); |
| |
| #ifdef CONFIG_USB_EHCI_MSM_HSIC |
| msm_gpiomux_install(apq8064_hsic_configs, |
| ARRAY_SIZE(apq8064_hsic_configs)); |
| #endif |
| } |