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