2 * Copyright (C) 2007 Google, Inc.
3 * Copyright (c) 2009-2010, Code Aurora Forum. All rights reserved.
4 * Author: Mike Lockwood <lockwood@android.com>
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
16 #ifndef __ASM_ARCH_MSM_GPIO_H
17 #define __ASM_ARCH_MSM_GPIO_H
20 * struct msm_gpio - GPIO pin description
21 * @gpio_cfg - configuration bitmap, as per gpio_tlmm_config()
22 * @label - textual label
24 * Usually, GPIO's are operated by sets.
25 * This struct accumulate all GPIO information in single source
26 * and facilitete group operations provided by msm_gpios_xxx()
34 * msm_gpios_request_enable() - request and enable set of GPIOs
36 * Request and configure set of GPIO's
37 * In case of error, all operations rolled back.
41 * @size: number of entries in @table
43 int msm_gpios_request_enable(const struct msm_gpio *table, int size);
46 * msm_gpios_disable_free() - disable and free set of GPIOs
49 * @size: number of entries in @table
51 void msm_gpios_disable_free(const struct msm_gpio *table, int size);
54 * msm_gpios_request() - request set of GPIOs
55 * In case of error, all operations rolled back.
59 * @size: number of entries in @table
61 int msm_gpios_request(const struct msm_gpio *table, int size);
64 * msm_gpios_free() - free set of GPIOs
67 * @size: number of entries in @table
69 void msm_gpios_free(const struct msm_gpio *table, int size);
72 * msm_gpios_enable() - enable set of GPIOs
73 * In case of error, all operations rolled back.
77 * @size: number of entries in @table
79 int msm_gpios_enable(const struct msm_gpio *table, int size);
82 * msm_gpios_disable() - disable set of GPIOs
85 * @size: number of entries in @table
87 void msm_gpios_disable(const struct msm_gpio *table, int size);
89 /* GPIO TLMM (Top Level Multiplexing) Definitions */
91 /* GPIO TLMM: Function -- GPIO specific */
93 /* GPIO TLMM: Direction */
99 /* GPIO TLMM: Pullup/Pulldown */
107 /* GPIO TLMM: Drive Strength */
124 #define GPIO_CFG(gpio, func, dir, pull, drvstr) \
125 ((((gpio) & 0x3FF) << 4) | \
127 (((dir) & 0x1) << 14) | \
128 (((pull) & 0x3) << 15) | \
129 (((drvstr) & 0xF) << 17))
132 * extract GPIO pin from bit-field used for gpio_tlmm_config
134 #define GPIO_PIN(gpio_cfg) (((gpio_cfg) >> 4) & 0x3ff)
135 #define GPIO_FUNC(gpio_cfg) (((gpio_cfg) >> 0) & 0xf)
136 #define GPIO_DIR(gpio_cfg) (((gpio_cfg) >> 14) & 0x1)
137 #define GPIO_PULL(gpio_cfg) (((gpio_cfg) >> 15) & 0x3)
138 #define GPIO_DRVSTR(gpio_cfg) (((gpio_cfg) >> 17) & 0xf)
140 int gpio_tlmm_config(unsigned config, unsigned disable);
142 #endif /* __ASM_ARCH_MSM_GPIO_H */