--- zzzz-none-000/linux-3.10.107/arch/arm/mach-msm/gpiomux-v1.c 2017-06-27 09:49:32.000000000 +0000 +++ vr9-7490-729/linux-3.10.107/arch/arm/mach-msm/gpiomux-v1.c 2021-11-10 11:53:52.000000000 +0000 @@ -1,4 +1,4 @@ -/* Copyright (c) 2010, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2010-2011 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 @@ -8,23 +8,37 @@ * 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. */ +#include #include -#include "gpiomux.h" -#include "proc_comm.h" +#include +#include +#include +#include "gpio.h" -void __msm_gpiomux_write(unsigned gpio, gpiomux_config_t val) +void __msm_gpiomux_write(unsigned gpio, struct gpiomux_setting val) { - unsigned tlmm_config = (val & ~GPIOMUX_CTL_MASK) | - ((gpio & 0x3ff) << 4); + unsigned tlmm_config; unsigned tlmm_disable = 0; + void __iomem *out_reg; + unsigned offset; + uint32_t bits; int rc; + tlmm_config = (val.drv << 17) | + (val.pull << 15) | + ((gpio & 0x3ff) << 4) | + val.func; + if (val.func == GPIOMUX_FUNC_GPIO) { + tlmm_config |= (val.dir > GPIOMUX_IN ? BIT(14) : 0); + msm_gpio_find_out(gpio, &out_reg, &offset); + bits = __raw_readl(out_reg); + if (val.dir == GPIOMUX_OUT_HIGH) + __raw_writel(bits | BIT(offset), out_reg); + else + __raw_writel(bits & ~BIT(offset), out_reg); + } + mb(); rc = msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &tlmm_config, &tlmm_disable); if (rc)