/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.1*2* This program is free software; you can redistribute it and/or modify3* it under the terms of the GNU General Public License version 2 and4* only version 2 as published by the Free Software Foundation.5*6* This program is distributed in the hope that it will be useful,7* but WITHOUT ANY WARRANTY; without even the implied warranty of8* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9* GNU General Public License for more details.10*11* You should have received a copy of the GNU General Public License12* along with this program; if not, write to the Free Software13* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA14* 02110-1301, USA.15*/16#ifndef __ARCH_ARM_MACH_MSM_GPIOMUX_H17#define __ARCH_ARM_MACH_MSM_GPIOMUX_H1819#include <linux/bitops.h>20#include <linux/errno.h>2122#if defined(CONFIG_MSM_V2_TLMM)23#include "gpiomux-v2.h"24#else25#include "gpiomux-v1.h"26#endif2728/**29* struct msm_gpiomux_config: gpiomux settings for one gpio line.30*31* A complete gpiomux config is the bitwise-or of a drive-strength,32* function, and pull. For functions other than GPIO, the OE33* is hard-wired according to the function. For GPIO mode,34* OE is controlled by gpiolib.35*36* Available settings differ by target; see the gpiomux header37* specific to your target arch for available configurations.38*39* @active: The configuration to be installed when the line is40* active, or its reference count is > 0.41* @suspended: The configuration to be installed when the line42* is suspended, or its reference count is 0.43* @ref: The reference count of the line. For internal use of44* the gpiomux framework only.45*/46struct msm_gpiomux_config {47gpiomux_config_t active;48gpiomux_config_t suspended;49unsigned ref;50};5152/**53* @GPIOMUX_VALID: If set, the config field contains 'good data'.54* The absence of this bit will prevent the gpiomux55* system from applying the configuration under all56* circumstances.57*/58enum {59GPIOMUX_VALID = BIT(sizeof(gpiomux_config_t) * BITS_PER_BYTE - 1),60GPIOMUX_CTL_MASK = GPIOMUX_VALID,61};6263#ifdef CONFIG_MSM_GPIOMUX6465/* Each architecture must provide its own instance of this table.66* To avoid having gpiomux manage any given gpio, one or both of67* the entries can avoid setting GPIOMUX_VALID - the absence68* of that flag will prevent the configuration from being applied69* during state transitions.70*/71extern struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS];7273/* Increment a gpio's reference count, possibly activating the line. */74int __must_check msm_gpiomux_get(unsigned gpio);7576/* Decrement a gpio's reference count, possibly suspending the line. */77int msm_gpiomux_put(unsigned gpio);7879/* Install a new configuration to the gpio line. To avoid overwriting80* a configuration, leave the VALID bit out.81*/82int msm_gpiomux_write(unsigned gpio,83gpiomux_config_t active,84gpiomux_config_t suspended);8586/* Architecture-internal function for use by the framework only.87* This function can assume the following:88* - the gpio value has passed a bounds-check89* - the gpiomux spinlock has been obtained90*91* This function is not for public consumption. External users92* should use msm_gpiomux_write.93*/94void __msm_gpiomux_write(unsigned gpio, gpiomux_config_t val);95#else96static inline int __must_check msm_gpiomux_get(unsigned gpio)97{98return -ENOSYS;99}100101static inline int msm_gpiomux_put(unsigned gpio)102{103return -ENOSYS;104}105106static inline int msm_gpiomux_write(unsigned gpio,107gpiomux_config_t active,108gpiomux_config_t suspended)109{110return -ENOSYS;111}112#endif113#endif114115116