diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
commit | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch) | |
tree | a57612d1888735a2ec7972891b68c1ac5ec8faea /arch/arm/plat-omap/mux.c | |
parent | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff) |
Diffstat (limited to 'arch/arm/plat-omap/mux.c')
-rw-r--r-- | arch/arm/plat-omap/mux.c | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/arch/arm/plat-omap/mux.c b/arch/arm/plat-omap/mux.c new file mode 100644 index 00000000000..0d4aa0d5876 --- /dev/null +++ b/arch/arm/plat-omap/mux.c | |||
@@ -0,0 +1,87 @@ | |||
1 | /* | ||
2 | * linux/arch/arm/plat-omap/mux.c | ||
3 | * | ||
4 | * Utility to set the Omap MUX and PULL_DWN registers from a table in mux.h | ||
5 | * | ||
6 | * Copyright (C) 2003 - 2008 Nokia Corporation | ||
7 | * | ||
8 | * Written by Tony Lindgren | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
23 | * | ||
24 | */ | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/init.h> | ||
27 | #include <linux/kernel.h> | ||
28 | #include <linux/io.h> | ||
29 | #include <asm/system.h> | ||
30 | #include <linux/spinlock.h> | ||
31 | #include <plat/mux.h> | ||
32 | |||
33 | #ifdef CONFIG_OMAP_MUX | ||
34 | |||
35 | static struct omap_mux_cfg *mux_cfg; | ||
36 | |||
37 | int __init omap_mux_register(struct omap_mux_cfg *arch_mux_cfg) | ||
38 | { | ||
39 | if (!arch_mux_cfg || !arch_mux_cfg->pins || arch_mux_cfg->size == 0 | ||
40 | || !arch_mux_cfg->cfg_reg) { | ||
41 | printk(KERN_ERR "Invalid pin table\n"); | ||
42 | return -EINVAL; | ||
43 | } | ||
44 | |||
45 | mux_cfg = arch_mux_cfg; | ||
46 | |||
47 | return 0; | ||
48 | } | ||
49 | |||
50 | /* | ||
51 | * Sets the Omap MUX and PULL_DWN registers based on the table | ||
52 | */ | ||
53 | int __init_or_module omap_cfg_reg(const unsigned long index) | ||
54 | { | ||
55 | struct pin_config *reg; | ||
56 | |||
57 | if (!cpu_class_is_omap1()) { | ||
58 | printk(KERN_ERR "mux: Broken omap_cfg_reg(%lu) entry\n", | ||
59 | index); | ||
60 | WARN_ON(1); | ||
61 | return -EINVAL; | ||
62 | } | ||
63 | |||
64 | if (mux_cfg == NULL) { | ||
65 | printk(KERN_ERR "Pin mux table not initialized\n"); | ||
66 | return -ENODEV; | ||
67 | } | ||
68 | |||
69 | if (index >= mux_cfg->size) { | ||
70 | printk(KERN_ERR "Invalid pin mux index: %lu (%lu)\n", | ||
71 | index, mux_cfg->size); | ||
72 | dump_stack(); | ||
73 | return -ENODEV; | ||
74 | } | ||
75 | |||
76 | reg = (struct pin_config *)&mux_cfg->pins[index]; | ||
77 | |||
78 | if (!mux_cfg->cfg_reg) | ||
79 | return -ENODEV; | ||
80 | |||
81 | return mux_cfg->cfg_reg(reg); | ||
82 | } | ||
83 | EXPORT_SYMBOL(omap_cfg_reg); | ||
84 | #else | ||
85 | #define omap_mux_init() do {} while(0) | ||
86 | #define omap_cfg_reg(x) do {} while(0) | ||
87 | #endif /* CONFIG_OMAP_MUX */ | ||