blob: e41fe72d2484c36c9b275fc62c7779801e9ff3c7 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/*
2 * Copyright (C) 2007 Google, Inc.
3 * Copyright (c) 2009-2010, Code Aurora Forum. All rights reserved.
4 * Author: Mike Lockwood <lockwood@android.com>
5 *
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.
9 *
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.
14 *
15 */
16#ifndef __ASM_ARCH_MSM_GPIO_TLMM_V1_H
17#define __ASM_ARCH_MSM_GPIO_TLMM_V1_H
18
19/* GPIO TLMM (Top Level Multiplexing) Definitions */
20
21/* GPIO TLMM: Function -- GPIO specific */
22
23/* GPIO TLMM: Direction */
24enum {
25 GPIO_CFG_INPUT,
26 GPIO_CFG_OUTPUT,
27};
28
29/* GPIO TLMM: Pullup/Pulldown */
30enum {
31 GPIO_CFG_NO_PULL,
32 GPIO_CFG_PULL_DOWN,
33 GPIO_CFG_KEEPER,
34 GPIO_CFG_PULL_UP,
35};
36
37/* GPIO TLMM: Drive Strength */
38enum {
39 GPIO_CFG_2MA,
40 GPIO_CFG_4MA,
41 GPIO_CFG_6MA,
42 GPIO_CFG_8MA,
43 GPIO_CFG_10MA,
44 GPIO_CFG_12MA,
45 GPIO_CFG_14MA,
46 GPIO_CFG_16MA,
47};
48
49enum {
50 GPIO_CFG_ENABLE,
51 GPIO_CFG_DISABLE,
52};
53
54#define GPIO_CFG(gpio, func, dir, pull, drvstr) \
55 ((((gpio) & 0x3FF) << 4) | \
56 ((func) & 0xf) | \
57 (((dir) & 0x1) << 14) | \
58 (((pull) & 0x3) << 15) | \
59 (((drvstr) & 0xF) << 17))
60
61/**
62 * extract GPIO pin from bit-field used for gpio_tlmm_config
63 */
64#define GPIO_PIN(gpio_cfg) (((gpio_cfg) >> 4) & 0x3ff)
65#define GPIO_FUNC(gpio_cfg) (((gpio_cfg) >> 0) & 0xf)
66#define GPIO_DIR(gpio_cfg) (((gpio_cfg) >> 14) & 0x1)
67#define GPIO_PULL(gpio_cfg) (((gpio_cfg) >> 15) & 0x3)
68#define GPIO_DRVSTR(gpio_cfg) (((gpio_cfg) >> 17) & 0xf)
69
70int gpio_tlmm_config(unsigned config, unsigned disable);
71
72#endif