diff options
author | Gregory Bean <gbean@codeaurora.org> | 2010-08-28 13:05:44 -0400 |
---|---|---|
committer | Daniel Walker <dwalker@codeaurora.org> | 2010-10-06 12:01:15 -0400 |
commit | 1963a2afc81afe6d85e7a12538b74a9919d958ae (patch) | |
tree | f1486399cfce632819509cb86639d3106d539805 /arch/arm/mach-msm/gpiomux.h | |
parent | 846afbd1fe015e082c89d56dd42c484d896ef58e (diff) |
msm: add gpiomux api for gpio multiplex & configuration.
Add the 'gpiomux' api, which addresses the following shortcomings
of existing tlmm api:
- gpio power-collapse, which is managed by a peripheral processor on
other targets, must be managed by the application processor on the 8x60.
- The enable/disable flag of the legacy gpio_tlmm_config api
is not applicable on the 8x60, and causes confusion.
- The gpio 'direction' bits are meaningless for all func_sel
configurations except for generic-gpio mode (func_sel 0), in which
case the gpio_direction_* functions should be used. Having these
bits in the tlmm api leads to confusion and misuse of the gpiolib
api, and they have been removed in gpiomux.
- The functional api of the legacy system ran contrary to the typical
use-case, which is a single massive configuration at boot. Rather
than forcing hundreds of 'config' function calls, the new api
allows data to be configured with a single table.
gpiomux_get and gpiomux_put are meant to be called automatically
when gpio_request and gpio_free are called, giving automatic
gpiomux/tlmm control to those drivers/lines with simple
power profiles - in the simplest cases, an entry in the gpiomux table
and the correct usage of gpiolib is all that is required to get proper
gpio power control.
Signed-off-by: Gregory Bean <gbean@codeaurora.org>
Signed-off-by: Daniel Walker <dwalker@codeaurora.org>
Diffstat (limited to 'arch/arm/mach-msm/gpiomux.h')
-rw-r--r-- | arch/arm/mach-msm/gpiomux.h | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/arch/arm/mach-msm/gpiomux.h b/arch/arm/mach-msm/gpiomux.h new file mode 100644 index 000000000000..bb0acf0c9644 --- /dev/null +++ b/arch/arm/mach-msm/gpiomux.h | |||
@@ -0,0 +1,94 @@ | |||
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 | |||
22 | #if defined(CONFIG_MSM_V2_TLMM) | ||
23 | #include "gpiomux-v2.h" | ||
24 | #else | ||
25 | #include "gpiomux-v1.h" | ||
26 | #endif | ||
27 | |||
28 | /** | ||
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 OE | ||
33 | * 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 header | ||
37 | * specific to your target arch for available configurations. | ||
38 | * | ||
39 | * @active: The configuration to be installed when the line is | ||
40 | * active, or its reference count is > 0. | ||
41 | * @suspended: The configuration to be installed when the line | ||
42 | * is suspended, or its reference count is 0. | ||
43 | * @ref: The reference count of the line. For internal use of | ||
44 | * the gpiomux framework only. | ||
45 | */ | ||
46 | struct msm_gpiomux_config { | ||
47 | gpiomux_config_t active; | ||
48 | gpiomux_config_t suspended; | ||
49 | unsigned ref; | ||
50 | }; | ||
51 | |||
52 | /** | ||
53 | * @GPIOMUX_VALID: If set, the config field contains 'good data'. | ||
54 | * The absence of this bit will prevent the gpiomux | ||
55 | * system from applying the configuration under all | ||
56 | * circumstances. | ||
57 | */ | ||
58 | enum { | ||
59 | GPIOMUX_VALID = BIT(sizeof(gpiomux_config_t) * BITS_PER_BYTE - 1), | ||
60 | GPIOMUX_CTL_MASK = GPIOMUX_VALID, | ||
61 | }; | ||
62 | |||
63 | /* Each architecture must provide its own instance of this table. | ||
64 | * To avoid having gpiomux manage any given gpio, one or both of | ||
65 | * the entries can avoid setting GPIOMUX_VALID - the absence | ||
66 | * of that flag will prevent the configuration from being applied | ||
67 | * during state transitions. | ||
68 | */ | ||
69 | extern struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS]; | ||
70 | |||
71 | /* Increment a gpio's reference count, possibly activating the line. */ | ||
72 | int __must_check msm_gpiomux_get(unsigned gpio); | ||
73 | |||
74 | /* Decrement a gpio's reference count, possibly suspending the line. */ | ||
75 | int msm_gpiomux_put(unsigned gpio); | ||
76 | |||
77 | /* Install a new configuration to the gpio line. To avoid overwriting | ||
78 | * a configuration, leave the VALID bit out. | ||
79 | */ | ||
80 | int msm_gpiomux_write(unsigned gpio, | ||
81 | gpiomux_config_t active, | ||
82 | gpiomux_config_t suspended); | ||
83 | |||
84 | /* Architecture-internal function for use by the framework only. | ||
85 | * This function can assume the following: | ||
86 | * - the gpio value has passed a bounds-check | ||
87 | * - the gpiomux spinlock has been obtained | ||
88 | * | ||
89 | * This function is not for public consumption. External users | ||
90 | * should use msm_gpiomux_write. | ||
91 | */ | ||
92 | void __msm_gpiomux_write(unsigned gpio, gpiomux_config_t val); | ||
93 | |||
94 | #endif | ||