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 | |
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')
-rw-r--r-- | arch/arm/mach-msm/Kconfig | 2 | ||||
-rw-r--r-- | arch/arm/mach-msm/Makefile | 3 | ||||
-rw-r--r-- | arch/arm/mach-msm/gpiomux-7x30.c | 19 | ||||
-rw-r--r-- | arch/arm/mach-msm/gpiomux-8x50.c | 19 | ||||
-rw-r--r-- | arch/arm/mach-msm/gpiomux-8x60.c | 19 | ||||
-rw-r--r-- | arch/arm/mach-msm/gpiomux-v1.c | 33 | ||||
-rw-r--r-- | arch/arm/mach-msm/gpiomux-v1.h | 67 | ||||
-rw-r--r-- | arch/arm/mach-msm/gpiomux-v2.c | 25 | ||||
-rw-r--r-- | arch/arm/mach-msm/gpiomux-v2.h | 61 | ||||
-rw-r--r-- | arch/arm/mach-msm/gpiomux.c | 96 | ||||
-rw-r--r-- | arch/arm/mach-msm/gpiomux.h | 94 | ||||
-rw-r--r-- | arch/arm/mach-msm/include/mach/msm_iomap-8x60.h | 42 | ||||
-rw-r--r-- | arch/arm/mach-msm/include/mach/msm_iomap.h | 2 |
13 files changed, 482 insertions, 0 deletions
diff --git a/arch/arm/mach-msm/Kconfig b/arch/arm/mach-msm/Kconfig index 47264a76eeb3..4e79580af628 100644 --- a/arch/arm/mach-msm/Kconfig +++ b/arch/arm/mach-msm/Kconfig | |||
@@ -106,4 +106,6 @@ config MSM_SMD_PKG3 | |||
106 | config MSM_SMD | 106 | config MSM_SMD |
107 | bool | 107 | bool |
108 | 108 | ||
109 | config MSM_V2_TLMM | ||
110 | bool | ||
109 | endif | 111 | endif |
diff --git a/arch/arm/mach-msm/Makefile b/arch/arm/mach-msm/Makefile index 704610648a25..78424e3f3802 100644 --- a/arch/arm/mach-msm/Makefile +++ b/arch/arm/mach-msm/Makefile | |||
@@ -20,3 +20,6 @@ obj-$(CONFIG_MACH_HALIBUT) += board-halibut.o devices-msm7x00.o | |||
20 | obj-$(CONFIG_ARCH_MSM7X30) += board-msm7x30.o devices-msm7x30.o | 20 | obj-$(CONFIG_ARCH_MSM7X30) += board-msm7x30.o devices-msm7x30.o |
21 | obj-$(CONFIG_ARCH_QSD8X50) += board-qsd8x50.o devices-qsd8x50.o | 21 | obj-$(CONFIG_ARCH_QSD8X50) += board-qsd8x50.o devices-qsd8x50.o |
22 | 22 | ||
23 | obj-$(CONFIG_ARCH_MSM7X30) += gpiomux-7x30.o gpiomux-v1.o gpiomux.o | ||
24 | obj-$(CONFIG_ARCH_QSD8X50) += gpiomux-8x50.o gpiomux-v1.o gpiomux.o | ||
25 | obj-$(CONFIG_ARCH_MSM8X60) += gpiomux-8x60.o gpiomux-v2.o gpiomux.o | ||
diff --git a/arch/arm/mach-msm/gpiomux-7x30.c b/arch/arm/mach-msm/gpiomux-7x30.c new file mode 100644 index 000000000000..7b380b31bd0e --- /dev/null +++ b/arch/arm/mach-msm/gpiomux-7x30.c | |||
@@ -0,0 +1,19 @@ | |||
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 | #include "gpiomux.h" | ||
18 | |||
19 | struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS] = {}; | ||
diff --git a/arch/arm/mach-msm/gpiomux-8x50.c b/arch/arm/mach-msm/gpiomux-8x50.c new file mode 100644 index 000000000000..7b380b31bd0e --- /dev/null +++ b/arch/arm/mach-msm/gpiomux-8x50.c | |||
@@ -0,0 +1,19 @@ | |||
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 | #include "gpiomux.h" | ||
18 | |||
19 | struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS] = {}; | ||
diff --git a/arch/arm/mach-msm/gpiomux-8x60.c b/arch/arm/mach-msm/gpiomux-8x60.c new file mode 100644 index 000000000000..7b380b31bd0e --- /dev/null +++ b/arch/arm/mach-msm/gpiomux-8x60.c | |||
@@ -0,0 +1,19 @@ | |||
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 | #include "gpiomux.h" | ||
18 | |||
19 | struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS] = {}; | ||
diff --git a/arch/arm/mach-msm/gpiomux-v1.c b/arch/arm/mach-msm/gpiomux-v1.c new file mode 100644 index 000000000000..27de2abd7144 --- /dev/null +++ b/arch/arm/mach-msm/gpiomux-v1.c | |||
@@ -0,0 +1,33 @@ | |||
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 | #include <linux/kernel.h> | ||
18 | #include "gpiomux.h" | ||
19 | #include "proc_comm.h" | ||
20 | |||
21 | void __msm_gpiomux_write(unsigned gpio, gpiomux_config_t val) | ||
22 | { | ||
23 | unsigned tlmm_config = (val & ~GPIOMUX_CTL_MASK) | | ||
24 | ((gpio & 0x3ff) << 4); | ||
25 | unsigned tlmm_disable = 0; | ||
26 | int rc; | ||
27 | |||
28 | rc = msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, | ||
29 | &tlmm_config, &tlmm_disable); | ||
30 | if (rc) | ||
31 | pr_err("%s: unexpected proc_comm failure %d: %08x %08x\n", | ||
32 | __func__, rc, tlmm_config, tlmm_disable); | ||
33 | } | ||
diff --git a/arch/arm/mach-msm/gpiomux-v1.h b/arch/arm/mach-msm/gpiomux-v1.h new file mode 100644 index 000000000000..71d86feba450 --- /dev/null +++ b/arch/arm/mach-msm/gpiomux-v1.h | |||
@@ -0,0 +1,67 @@ | |||
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_V1_H | ||
18 | #define __ARCH_ARM_MACH_MSM_GPIOMUX_V1_H | ||
19 | |||
20 | #if defined(CONFIG_ARCH_MSM7X30) | ||
21 | #define GPIOMUX_NGPIOS 182 | ||
22 | #elif defined(CONFIG_ARCH_QSD8X50) | ||
23 | #define GPIOMUX_NGPIOS 165 | ||
24 | #else | ||
25 | #define GPIOMUX_NGPIOS 133 | ||
26 | #endif | ||
27 | |||
28 | typedef u32 gpiomux_config_t; | ||
29 | |||
30 | enum { | ||
31 | GPIOMUX_DRV_2MA = 0UL << 17, | ||
32 | GPIOMUX_DRV_4MA = 1UL << 17, | ||
33 | GPIOMUX_DRV_6MA = 2UL << 17, | ||
34 | GPIOMUX_DRV_8MA = 3UL << 17, | ||
35 | GPIOMUX_DRV_10MA = 4UL << 17, | ||
36 | GPIOMUX_DRV_12MA = 5UL << 17, | ||
37 | GPIOMUX_DRV_14MA = 6UL << 17, | ||
38 | GPIOMUX_DRV_16MA = 7UL << 17, | ||
39 | }; | ||
40 | |||
41 | enum { | ||
42 | GPIOMUX_FUNC_GPIO = 0UL, | ||
43 | GPIOMUX_FUNC_1 = 1UL, | ||
44 | GPIOMUX_FUNC_2 = 2UL, | ||
45 | GPIOMUX_FUNC_3 = 3UL, | ||
46 | GPIOMUX_FUNC_4 = 4UL, | ||
47 | GPIOMUX_FUNC_5 = 5UL, | ||
48 | GPIOMUX_FUNC_6 = 6UL, | ||
49 | GPIOMUX_FUNC_7 = 7UL, | ||
50 | GPIOMUX_FUNC_8 = 8UL, | ||
51 | GPIOMUX_FUNC_9 = 9UL, | ||
52 | GPIOMUX_FUNC_A = 10UL, | ||
53 | GPIOMUX_FUNC_B = 11UL, | ||
54 | GPIOMUX_FUNC_C = 12UL, | ||
55 | GPIOMUX_FUNC_D = 13UL, | ||
56 | GPIOMUX_FUNC_E = 14UL, | ||
57 | GPIOMUX_FUNC_F = 15UL, | ||
58 | }; | ||
59 | |||
60 | enum { | ||
61 | GPIOMUX_PULL_NONE = 0UL << 15, | ||
62 | GPIOMUX_PULL_DOWN = 1UL << 15, | ||
63 | GPIOMUX_PULL_KEEPER = 2UL << 15, | ||
64 | GPIOMUX_PULL_UP = 3UL << 15, | ||
65 | }; | ||
66 | |||
67 | #endif | ||
diff --git a/arch/arm/mach-msm/gpiomux-v2.c b/arch/arm/mach-msm/gpiomux-v2.c new file mode 100644 index 000000000000..273396d2b127 --- /dev/null +++ b/arch/arm/mach-msm/gpiomux-v2.c | |||
@@ -0,0 +1,25 @@ | |||
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 | #include <linux/io.h> | ||
18 | #include <mach/msm_iomap.h> | ||
19 | #include "gpiomux.h" | ||
20 | |||
21 | void __msm_gpiomux_write(unsigned gpio, gpiomux_config_t val) | ||
22 | { | ||
23 | writel(val & ~GPIOMUX_CTL_MASK, | ||
24 | MSM_TLMM_BASE + 0x1000 + (0x10 * gpio)); | ||
25 | } | ||
diff --git a/arch/arm/mach-msm/gpiomux-v2.h b/arch/arm/mach-msm/gpiomux-v2.h new file mode 100644 index 000000000000..3bf10e7f0381 --- /dev/null +++ b/arch/arm/mach-msm/gpiomux-v2.h | |||
@@ -0,0 +1,61 @@ | |||
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_V2_H | ||
18 | #define __ARCH_ARM_MACH_MSM_GPIOMUX_V2_H | ||
19 | |||
20 | #define GPIOMUX_NGPIOS 173 | ||
21 | |||
22 | typedef u16 gpiomux_config_t; | ||
23 | |||
24 | enum { | ||
25 | GPIOMUX_DRV_2MA = 0UL << 6, | ||
26 | GPIOMUX_DRV_4MA = 1UL << 6, | ||
27 | GPIOMUX_DRV_6MA = 2UL << 6, | ||
28 | GPIOMUX_DRV_8MA = 3UL << 6, | ||
29 | GPIOMUX_DRV_10MA = 4UL << 6, | ||
30 | GPIOMUX_DRV_12MA = 5UL << 6, | ||
31 | GPIOMUX_DRV_14MA = 6UL << 6, | ||
32 | GPIOMUX_DRV_16MA = 7UL << 6, | ||
33 | }; | ||
34 | |||
35 | enum { | ||
36 | GPIOMUX_FUNC_GPIO = 0UL << 2, | ||
37 | GPIOMUX_FUNC_1 = 1UL << 2, | ||
38 | GPIOMUX_FUNC_2 = 2UL << 2, | ||
39 | GPIOMUX_FUNC_3 = 3UL << 2, | ||
40 | GPIOMUX_FUNC_4 = 4UL << 2, | ||
41 | GPIOMUX_FUNC_5 = 5UL << 2, | ||
42 | GPIOMUX_FUNC_6 = 6UL << 2, | ||
43 | GPIOMUX_FUNC_7 = 7UL << 2, | ||
44 | GPIOMUX_FUNC_8 = 8UL << 2, | ||
45 | GPIOMUX_FUNC_9 = 9UL << 2, | ||
46 | GPIOMUX_FUNC_A = 10UL << 2, | ||
47 | GPIOMUX_FUNC_B = 11UL << 2, | ||
48 | GPIOMUX_FUNC_C = 12UL << 2, | ||
49 | GPIOMUX_FUNC_D = 13UL << 2, | ||
50 | GPIOMUX_FUNC_E = 14UL << 2, | ||
51 | GPIOMUX_FUNC_F = 15UL << 2, | ||
52 | }; | ||
53 | |||
54 | enum { | ||
55 | GPIOMUX_PULL_NONE = 0UL, | ||
56 | GPIOMUX_PULL_DOWN = 1UL, | ||
57 | GPIOMUX_PULL_KEEPER = 2UL, | ||
58 | GPIOMUX_PULL_UP = 3UL, | ||
59 | }; | ||
60 | |||
61 | #endif | ||
diff --git a/arch/arm/mach-msm/gpiomux.c b/arch/arm/mach-msm/gpiomux.c new file mode 100644 index 000000000000..53af21abd155 --- /dev/null +++ b/arch/arm/mach-msm/gpiomux.c | |||
@@ -0,0 +1,96 @@ | |||
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 | #include <linux/module.h> | ||
18 | #include <linux/spinlock.h> | ||
19 | #include "gpiomux.h" | ||
20 | |||
21 | static DEFINE_SPINLOCK(gpiomux_lock); | ||
22 | |||
23 | int msm_gpiomux_write(unsigned gpio, | ||
24 | gpiomux_config_t active, | ||
25 | gpiomux_config_t suspended) | ||
26 | { | ||
27 | struct msm_gpiomux_config *cfg = msm_gpiomux_configs + gpio; | ||
28 | unsigned long irq_flags; | ||
29 | gpiomux_config_t setting; | ||
30 | |||
31 | if (gpio >= GPIOMUX_NGPIOS) | ||
32 | return -EINVAL; | ||
33 | |||
34 | spin_lock_irqsave(&gpiomux_lock, irq_flags); | ||
35 | |||
36 | if (active & GPIOMUX_VALID) | ||
37 | cfg->active = active; | ||
38 | |||
39 | if (suspended & GPIOMUX_VALID) | ||
40 | cfg->suspended = suspended; | ||
41 | |||
42 | setting = cfg->ref ? active : suspended; | ||
43 | if (setting & GPIOMUX_VALID) | ||
44 | __msm_gpiomux_write(gpio, setting); | ||
45 | |||
46 | spin_unlock_irqrestore(&gpiomux_lock, irq_flags); | ||
47 | return 0; | ||
48 | } | ||
49 | EXPORT_SYMBOL(msm_gpiomux_write); | ||
50 | |||
51 | int msm_gpiomux_get(unsigned gpio) | ||
52 | { | ||
53 | struct msm_gpiomux_config *cfg = msm_gpiomux_configs + gpio; | ||
54 | unsigned long irq_flags; | ||
55 | |||
56 | if (gpio >= GPIOMUX_NGPIOS) | ||
57 | return -EINVAL; | ||
58 | |||
59 | spin_lock_irqsave(&gpiomux_lock, irq_flags); | ||
60 | if (cfg->ref++ == 0 && cfg->active & GPIOMUX_VALID) | ||
61 | __msm_gpiomux_write(gpio, cfg->active); | ||
62 | spin_unlock_irqrestore(&gpiomux_lock, irq_flags); | ||
63 | return 0; | ||
64 | } | ||
65 | EXPORT_SYMBOL(msm_gpiomux_get); | ||
66 | |||
67 | int msm_gpiomux_put(unsigned gpio) | ||
68 | { | ||
69 | struct msm_gpiomux_config *cfg = msm_gpiomux_configs + gpio; | ||
70 | unsigned long irq_flags; | ||
71 | |||
72 | if (gpio >= GPIOMUX_NGPIOS) | ||
73 | return -EINVAL; | ||
74 | |||
75 | spin_lock_irqsave(&gpiomux_lock, irq_flags); | ||
76 | BUG_ON(cfg->ref == 0); | ||
77 | if (--cfg->ref == 0 && cfg->suspended & GPIOMUX_VALID) | ||
78 | __msm_gpiomux_write(gpio, cfg->suspended); | ||
79 | spin_unlock_irqrestore(&gpiomux_lock, irq_flags); | ||
80 | return 0; | ||
81 | } | ||
82 | EXPORT_SYMBOL(msm_gpiomux_put); | ||
83 | |||
84 | static int __init gpiomux_init(void) | ||
85 | { | ||
86 | unsigned n; | ||
87 | |||
88 | for (n = 0; n < GPIOMUX_NGPIOS; ++n) { | ||
89 | msm_gpiomux_configs[n].ref = 0; | ||
90 | if (!(msm_gpiomux_configs[n].suspended & GPIOMUX_VALID)) | ||
91 | continue; | ||
92 | __msm_gpiomux_write(n, msm_gpiomux_configs[n].suspended); | ||
93 | } | ||
94 | return 0; | ||
95 | } | ||
96 | postcore_initcall(gpiomux_init); | ||
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 | ||
diff --git a/arch/arm/mach-msm/include/mach/msm_iomap-8x60.h b/arch/arm/mach-msm/include/mach/msm_iomap-8x60.h new file mode 100644 index 000000000000..17209f78d4a8 --- /dev/null +++ b/arch/arm/mach-msm/include/mach/msm_iomap-8x60.h | |||
@@ -0,0 +1,42 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007 Google, Inc. | ||
3 | * Copyright (c) 2008-2010, Code Aurora Forum. All rights reserved. | ||
4 | * Author: Brian Swetland <swetland@google.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 | * The MSM peripherals are spread all over across 768MB of physical | ||
17 | * space, which makes just having a simple IO_ADDRESS macro to slide | ||
18 | * them into the right virtual location rough. Instead, we will | ||
19 | * provide a master phys->virt mapping for peripherals here. | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #ifndef __ASM_ARCH_MSM_IOMAP_8X60_H | ||
24 | #define __ASM_ARCH_MSM_IOMAP_8X60_H | ||
25 | |||
26 | /* Physical base address and size of peripherals. | ||
27 | * Ordered by the virtual base addresses they will be mapped at. | ||
28 | * | ||
29 | * MSM_VIC_BASE must be an value that can be loaded via a "mov" | ||
30 | * instruction, otherwise entry-macro.S will not compile. | ||
31 | * | ||
32 | * If you add or remove entries here, you'll want to edit the | ||
33 | * msm_io_desc array in arch/arm/mach-msm/io.c to reflect your | ||
34 | * changes. | ||
35 | * | ||
36 | */ | ||
37 | |||
38 | #define MSM_TLMM_BASE IOMEM(0xF0004000) | ||
39 | #define MSM_TLMM_PHYS 0x00800000 | ||
40 | #define MSM_TLMM_SIZE SZ_16K | ||
41 | |||
42 | #endif | ||
diff --git a/arch/arm/mach-msm/include/mach/msm_iomap.h b/arch/arm/mach-msm/include/mach/msm_iomap.h index e6b1821cc4ea..39c8fbcf33e7 100644 --- a/arch/arm/mach-msm/include/mach/msm_iomap.h +++ b/arch/arm/mach-msm/include/mach/msm_iomap.h | |||
@@ -47,6 +47,8 @@ | |||
47 | #include "msm_iomap-7x30.h" | 47 | #include "msm_iomap-7x30.h" |
48 | #elif defined(CONFIG_ARCH_QSD8X50) | 48 | #elif defined(CONFIG_ARCH_QSD8X50) |
49 | #include "msm_iomap-8x50.h" | 49 | #include "msm_iomap-8x50.h" |
50 | #elif defined(CONFIG_ARCH_MSM8X60) | ||
51 | #include "msm_iomap-8x60.h" | ||
50 | #else | 52 | #else |
51 | #include "msm_iomap-7x00.h" | 53 | #include "msm_iomap-7x00.h" |
52 | #endif | 54 | #endif |