| /* Copyright (c) 2013, The Linux Foundation. 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 <mach/board.h> |
| #include <mach/gpio.h> |
| #include <mach/gpiomux.h> |
| |
| #define KS8851_IRQ_GPIO 75 |
| |
| static struct gpiomux_setting gpio_uart_config = { |
| .func = GPIOMUX_FUNC_2, |
| .drv = GPIOMUX_DRV_16MA, |
| .pull = GPIOMUX_PULL_NONE, |
| .dir = GPIOMUX_OUT_HIGH, |
| }; |
| |
| static struct gpiomux_setting gpio_i2c_config = { |
| .func = GPIOMUX_FUNC_3, |
| .drv = GPIOMUX_DRV_2MA, |
| .pull = GPIOMUX_PULL_NONE, |
| }; |
| |
| static struct gpiomux_setting gpio_i2c_act_config = { |
| .func = GPIOMUX_FUNC_3, |
| .drv = GPIOMUX_DRV_2MA, |
| .pull = GPIOMUX_PULL_UP, |
| }; |
| |
| static struct gpiomux_setting gpio_touch_int_act_config = { |
| .func = GPIOMUX_FUNC_GPIO, |
| .drv = GPIOMUX_DRV_8MA, |
| .pull = GPIOMUX_PULL_UP, |
| }; |
| |
| static struct gpiomux_setting gpio_touch_int_sus_config = { |
| .func = GPIOMUX_FUNC_GPIO, |
| .drv = GPIOMUX_DRV_2MA, |
| .pull = GPIOMUX_PULL_DOWN, |
| }; |
| |
| static struct gpiomux_setting gpio_touch_reset_act_config = { |
| .func = GPIOMUX_FUNC_GPIO, |
| .drv = GPIOMUX_DRV_6MA, |
| .pull = GPIOMUX_PULL_UP, |
| }; |
| |
| static struct gpiomux_setting gpio_touch_reset_sus_config = { |
| .func = GPIOMUX_FUNC_GPIO, |
| .drv = GPIOMUX_DRV_2MA, |
| .pull = GPIOMUX_PULL_DOWN, |
| }; |
| |
| static struct gpiomux_setting wcnss_5wire_suspend_cfg = { |
| .func = GPIOMUX_FUNC_GPIO, |
| .drv = GPIOMUX_DRV_2MA, |
| .pull = GPIOMUX_PULL_UP, |
| }; |
| |
| static struct gpiomux_setting wcnss_5wire_active_cfg = { |
| .func = GPIOMUX_FUNC_1, |
| .drv = GPIOMUX_DRV_6MA, |
| .pull = GPIOMUX_PULL_DOWN, |
| }; |
| |
| #if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE) |
| static struct gpiomux_setting gpio_spi_config = { |
| .func = GPIOMUX_FUNC_1, |
| .drv = GPIOMUX_DRV_12MA, |
| .pull = GPIOMUX_PULL_NONE, |
| }; |
| |
| static struct gpiomux_setting gpio_spi_cs1_config = { |
| .func = GPIOMUX_FUNC_GPIO, |
| .drv = GPIOMUX_DRV_6MA, |
| .pull = GPIOMUX_PULL_UP, |
| }; |
| |
| static struct gpiomux_setting gpio_spi_cs2_config = { |
| .func = GPIOMUX_FUNC_4, |
| .drv = GPIOMUX_DRV_6MA, |
| .pull = GPIOMUX_PULL_DOWN, |
| }; |
| |
| static struct gpiomux_setting gpio_eth_config = { |
| .pull = GPIOMUX_PULL_UP, |
| .drv = GPIOMUX_DRV_2MA, |
| .func = GPIOMUX_FUNC_GPIO, |
| }; |
| |
| static struct msm_gpiomux_config msm_eth_configs[] = { |
| { |
| .gpio = KS8851_IRQ_GPIO, |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &gpio_eth_config, |
| } |
| }, |
| }; |
| #endif |
| |
| static struct msm_gpiomux_config wcnss_5wire_interface[] = { |
| { |
| .gpio = 36, |
| .settings = { |
| [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg, |
| [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg, |
| }, |
| }, |
| { |
| .gpio = 37, |
| .settings = { |
| [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg, |
| [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg, |
| }, |
| }, |
| { |
| .gpio = 38, |
| .settings = { |
| [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg, |
| [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg, |
| }, |
| }, |
| { |
| .gpio = 39, |
| .settings = { |
| [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg, |
| [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg, |
| }, |
| }, |
| { |
| .gpio = 40, |
| .settings = { |
| [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg, |
| [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg, |
| }, |
| }, |
| }; |
| |
| static struct msm_gpiomux_config msm_blsp_configs[] __initdata = { |
| { |
| .gpio = 0, /* BLSP1 QUP1 SPI_DATA_MOSI */ |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| }, |
| }, |
| { |
| .gpio = 1, /* BLSP1 QUP1 SPI_DATA_MISO */ |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| }, |
| }, |
| { |
| .gpio = 3, /* BLSP1 QUP SPI_CLK */ |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| }, |
| }, |
| { |
| .gpio = 6, /* BLSP1 QUP2 I2C_SDA */ |
| .settings = { |
| [GPIOMUX_ACTIVE] = &gpio_i2c_act_config, |
| [GPIOMUX_SUSPENDED] = &gpio_i2c_config, |
| }, |
| }, |
| { |
| .gpio = 7, /* BLSP1 QUP2 I2C_SCL */ |
| .settings = { |
| [GPIOMUX_ACTIVE] = &gpio_i2c_act_config, |
| [GPIOMUX_SUSPENDED] = &gpio_i2c_config, |
| }, |
| }, |
| { |
| .gpio = 8, /* BLSP1 QUP SPI_CS1_N */ |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &gpio_spi_cs1_config, |
| }, |
| }, |
| { |
| .gpio = 9, /* BLSP1 QUP SPI_CS2A_N */ |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &gpio_spi_cs2_config, |
| }, |
| }, |
| { |
| .gpio = 4, /* BLSP2 UART TX */ |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &gpio_uart_config, |
| }, |
| }, |
| { |
| .gpio = 5, /* BLSP2 UART RX */ |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &gpio_uart_config, |
| }, |
| }, |
| { |
| .gpio = 55, /* BLSP2 QUP1 I2C_SDA */ |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &gpio_i2c_config, |
| }, |
| }, |
| { |
| .gpio = 56, /* BLSP2 QUP1 I2C_SCL */ |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &gpio_i2c_config, |
| }, |
| }, |
| { /* NFC */ |
| .gpio = 87, /* BLSP2 QUP2 I2C_DAT */ |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &gpio_i2c_config, |
| }, |
| }, |
| { /* NFC */ |
| .gpio = 88, /* BLSP2 QUP2 I2C_CLK */ |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &gpio_i2c_config, |
| }, |
| }, |
| }; |
| |
| static struct gpiomux_setting lcd_en_act_cfg = { |
| .func = GPIOMUX_FUNC_GPIO, |
| .drv = GPIOMUX_DRV_8MA, |
| .pull = GPIOMUX_PULL_NONE, |
| .dir = GPIOMUX_OUT_HIGH, |
| }; |
| |
| static struct gpiomux_setting lcd_en_sus_cfg = { |
| .func = GPIOMUX_FUNC_GPIO, |
| .drv = GPIOMUX_DRV_2MA, |
| .pull = GPIOMUX_PULL_DOWN, |
| }; |
| |
| static struct msm_gpiomux_config msm_lcd_configs[] __initdata = { |
| { |
| .gpio = 102, /* BKLT ENABLE */ |
| .settings = { |
| [GPIOMUX_ACTIVE] = &lcd_en_act_cfg, |
| [GPIOMUX_SUSPENDED] = &lcd_en_sus_cfg, |
| }, |
| }, |
| { |
| .gpio = 82, /* DISPLAY ENABLE */ |
| .settings = { |
| [GPIOMUX_ACTIVE] = &lcd_en_act_cfg, |
| [GPIOMUX_SUSPENDED] = &lcd_en_sus_cfg, |
| }, |
| }, |
| }; |
| |
| static struct gpiomux_setting auxpcm_act_cfg = { |
| .func = GPIOMUX_FUNC_1, |
| .drv = GPIOMUX_DRV_8MA, |
| .pull = GPIOMUX_PULL_NONE, |
| }; |
| |
| static struct gpiomux_setting auxpcm_sus_cfg = { |
| .func = GPIOMUX_FUNC_1, |
| .drv = GPIOMUX_DRV_2MA, |
| .pull = GPIOMUX_PULL_DOWN, |
| }; |
| |
| /* Primary AUXPCM port sharing GPIO lines with Primary MI2S */ |
| static struct msm_gpiomux_config samarium_pri_pri_auxpcm_cfg[] __initdata = { |
| { |
| .gpio = 65, |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &auxpcm_sus_cfg, |
| [GPIOMUX_ACTIVE] = &auxpcm_act_cfg, |
| }, |
| }, |
| { |
| .gpio = 66, |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &auxpcm_sus_cfg, |
| [GPIOMUX_ACTIVE] = &auxpcm_act_cfg, |
| }, |
| }, |
| { |
| .gpio = 67, |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &auxpcm_sus_cfg, |
| [GPIOMUX_ACTIVE] = &auxpcm_act_cfg, |
| }, |
| }, |
| { |
| .gpio = 68, |
| .settings = { |
| [GPIOMUX_SUSPENDED] = &auxpcm_sus_cfg, |
| [GPIOMUX_ACTIVE] = &auxpcm_act_cfg, |
| }, |
| }, |
| }; |
| static struct msm_gpiomux_config msm_touch_configs[] __initdata = { |
| { |
| .gpio = 14, /* TOUCH INT GPIO */ |
| .settings = { |
| [GPIOMUX_ACTIVE] = &gpio_touch_int_act_config, |
| [GPIOMUX_SUSPENDED] = &gpio_touch_int_sus_config, |
| }, |
| }, |
| { |
| .gpio = 13, /* TOUCH RESET GPIO */ |
| .settings = { |
| [GPIOMUX_ACTIVE] = &gpio_touch_reset_act_config, |
| [GPIOMUX_SUSPENDED] = &gpio_touch_reset_sus_config, |
| }, |
| }, |
| }; |
| |
| static struct gpiomux_setting sd_card_det_active_config = { |
| .func = GPIOMUX_FUNC_GPIO, |
| .drv = GPIOMUX_DRV_2MA, |
| .pull = GPIOMUX_PULL_NONE, |
| .dir = GPIOMUX_IN, |
| }; |
| |
| static struct gpiomux_setting sd_card_det_suspend_config = { |
| .func = GPIOMUX_FUNC_GPIO, |
| .drv = GPIOMUX_DRV_2MA, |
| .pull = GPIOMUX_PULL_UP, |
| .dir = GPIOMUX_IN, |
| }; |
| |
| static struct msm_gpiomux_config sd_card_det[] __initdata = { |
| { |
| .gpio = 62, |
| .settings = { |
| [GPIOMUX_ACTIVE] = &sd_card_det_active_config, |
| [GPIOMUX_SUSPENDED] = &sd_card_det_suspend_config, |
| }, |
| }, |
| }; |
| |
| void __init msmsamarium_init_gpiomux(void) |
| { |
| int rc; |
| |
| rc = msm_gpiomux_init_dt(); |
| if (rc) { |
| pr_err("%s failed %d\n", __func__, rc); |
| return; |
| } |
| |
| #if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE) |
| msm_gpiomux_install(msm_eth_configs, ARRAY_SIZE(msm_eth_configs)); |
| #endif |
| msm_gpiomux_install(msm_blsp_configs, ARRAY_SIZE(msm_blsp_configs)); |
| msm_gpiomux_install(msm_lcd_configs, ARRAY_SIZE(msm_lcd_configs)); |
| msm_gpiomux_install(samarium_pri_pri_auxpcm_cfg, |
| ARRAY_SIZE(samarium_pri_pri_auxpcm_cfg)); |
| msm_gpiomux_install(msm_touch_configs, ARRAY_SIZE(msm_touch_configs)); |
| msm_gpiomux_install(sd_card_det, ARRAY_SIZE(sd_card_det)); |
| msm_gpiomux_install(wcnss_5wire_interface, |
| ARRAY_SIZE(wcnss_5wire_interface)); |
| } |