linux/arch/arm/mach-msm/gpiomux.h
<<
>>
Prefs
   1/* Copyright (c) 2010, 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 * You should have received a copy of the GNU General Public License
  13 * along with this program; if not, write to the Free Software
  14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15 * 02110-1301, USA.
  16 */
  17#ifndef __ARCH_ARM_MACH_MSM_GPIOMUX_H
  18#define __ARCH_ARM_MACH_MSM_GPIOMUX_H
  19
  20#include <linux/bitops.h>
  21#include <linux/errno.h>
  22
  23#if defined(CONFIG_MSM_V2_TLMM)
  24#include "gpiomux-v2.h"
  25#else
  26#include "gpiomux-v1.h"
  27#endif
  28
  29/**
  30 * struct msm_gpiomux_config: gpiomux settings for one gpio line.
  31 *
  32 * A complete gpiomux config is the bitwise-or of a drive-strength,
  33 * function, and pull.  For functions other than GPIO, the OE
  34 * is hard-wired according to the function.  For GPIO mode,
  35 * OE is controlled by gpiolib.
  36 *
  37 * Available settings differ by target; see the gpiomux header
  38 * specific to your target arch for available configurations.
  39 *
  40 * @active: The configuration to be installed when the line is
  41 * active, or its reference count is > 0.
  42 * @suspended: The configuration to be installed when the line
  43 * is suspended, or its reference count is 0.
  44 * @ref: The reference count of the line.  For internal use of
  45 * the gpiomux framework only.
  46 */
  47struct msm_gpiomux_config {
  48        gpiomux_config_t active;
  49        gpiomux_config_t suspended;
  50        unsigned         ref;
  51};
  52
  53/**
  54 * @GPIOMUX_VALID:      If set, the config field contains 'good data'.
  55 *                      The absence of this bit will prevent the gpiomux
  56 *                      system from applying the configuration under all
  57 *                      circumstances.
  58 */
  59enum {
  60        GPIOMUX_VALID    = BIT(sizeof(gpiomux_config_t) * BITS_PER_BYTE - 1),
  61        GPIOMUX_CTL_MASK = GPIOMUX_VALID,
  62};
  63
  64#ifdef CONFIG_MSM_GPIOMUX
  65
  66/* Each architecture must provide its own instance of this table.
  67 * To avoid having gpiomux manage any given gpio, one or both of
  68 * the entries can avoid setting GPIOMUX_VALID - the absence
  69 * of that flag will prevent the configuration from being applied
  70 * during state transitions.
  71 */
  72extern struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS];
  73
  74/* Increment a gpio's reference count, possibly activating the line. */
  75int __must_check msm_gpiomux_get(unsigned gpio);
  76
  77/* Decrement a gpio's reference count, possibly suspending the line. */
  78int msm_gpiomux_put(unsigned gpio);
  79
  80/* Install a new configuration to the gpio line.  To avoid overwriting
  81 * a configuration, leave the VALID bit out.
  82 */
  83int msm_gpiomux_write(unsigned gpio,
  84                      gpiomux_config_t active,
  85                      gpiomux_config_t suspended);
  86
  87/* Architecture-internal function for use by the framework only.
  88 * This function can assume the following:
  89 * - the gpio value has passed a bounds-check
  90 * - the gpiomux spinlock has been obtained
  91 *
  92 * This function is not for public consumption.  External users
  93 * should use msm_gpiomux_write.
  94 */
  95void __msm_gpiomux_write(unsigned gpio, gpiomux_config_t val);
  96#else
  97static inline int __must_check msm_gpiomux_get(unsigned gpio)
  98{
  99        return -ENOSYS;
 100}
 101
 102static inline int msm_gpiomux_put(unsigned gpio)
 103{
 104        return -ENOSYS;
 105}
 106
 107static inline int msm_gpiomux_write(unsigned gpio,
 108                                    gpiomux_config_t active,
 109                                    gpiomux_config_t suspended)
 110{
 111        return -ENOSYS;
 112}
 113#endif
 114#endif
 115