2005-07-10 22:58:15 +04:00
|
|
|
/*
|
|
|
|
* linux/arch/arm/plat-omap/mux.c
|
|
|
|
*
|
|
|
|
* Utility to set the Omap MUX and PULL_DWN registers from a table in mux.h
|
|
|
|
*
|
2008-01-25 04:24:15 +03:00
|
|
|
* Copyright (C) 2003 - 2008 Nokia Corporation
|
2005-07-10 22:58:15 +04:00
|
|
|
*
|
2008-01-25 04:24:15 +03:00
|
|
|
* Written by Tony Lindgren
|
2005-07-10 22:58:15 +04:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
2005-11-10 17:26:50 +03:00
|
|
|
#include <linux/kernel.h>
|
2008-09-06 15:10:45 +04:00
|
|
|
#include <linux/io.h>
|
2005-07-10 22:58:15 +04:00
|
|
|
#include <asm/system.h>
|
|
|
|
#include <linux/spinlock.h>
|
2008-08-05 19:14:15 +04:00
|
|
|
#include <mach/mux.h>
|
2005-07-10 22:58:15 +04:00
|
|
|
|
|
|
|
#ifdef CONFIG_OMAP_MUX
|
|
|
|
|
2008-01-25 11:42:48 +03:00
|
|
|
static struct omap_mux_cfg *mux_cfg;
|
2005-11-10 17:26:50 +03:00
|
|
|
|
2008-01-25 11:42:48 +03:00
|
|
|
int __init omap_mux_register(struct omap_mux_cfg *arch_mux_cfg)
|
2005-11-10 17:26:50 +03:00
|
|
|
{
|
2008-01-25 11:42:48 +03:00
|
|
|
if (!arch_mux_cfg || !arch_mux_cfg->pins || arch_mux_cfg->size == 0
|
|
|
|
|| !arch_mux_cfg->cfg_reg) {
|
|
|
|
printk(KERN_ERR "Invalid pin table\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
mux_cfg = arch_mux_cfg;
|
2005-11-10 17:26:50 +03:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-07-10 22:58:15 +04:00
|
|
|
/*
|
|
|
|
* Sets the Omap MUX and PULL_DWN registers based on the table
|
|
|
|
*/
|
2005-11-10 17:26:50 +03:00
|
|
|
int __init_or_module omap_cfg_reg(const unsigned long index)
|
2005-07-10 22:58:15 +04:00
|
|
|
{
|
2008-01-25 11:42:48 +03:00
|
|
|
struct pin_config *reg;
|
2005-07-10 22:58:15 +04:00
|
|
|
|
2008-01-25 11:42:48 +03:00
|
|
|
if (mux_cfg == NULL) {
|
|
|
|
printk(KERN_ERR "Pin mux table not initialized\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
2005-09-07 20:20:26 +04:00
|
|
|
|
2008-01-25 11:42:48 +03:00
|
|
|
if (index >= mux_cfg->size) {
|
2005-11-10 17:26:50 +03:00
|
|
|
printk(KERN_ERR "Invalid pin mux index: %lu (%lu)\n",
|
2008-01-25 11:42:48 +03:00
|
|
|
index, mux_cfg->size);
|
2005-11-10 17:26:50 +03:00
|
|
|
dump_stack();
|
|
|
|
return -ENODEV;
|
2005-07-10 22:58:15 +04:00
|
|
|
}
|
|
|
|
|
2008-01-25 11:42:48 +03:00
|
|
|
reg = (struct pin_config *)&mux_cfg->pins[index];
|
2005-07-10 22:58:15 +04:00
|
|
|
|
2008-01-25 11:42:48 +03:00
|
|
|
if (!mux_cfg->cfg_reg)
|
|
|
|
return -ENODEV;
|
2005-07-10 22:58:15 +04:00
|
|
|
|
2008-01-25 11:42:48 +03:00
|
|
|
return mux_cfg->cfg_reg(reg);
|
2005-07-10 22:58:15 +04:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(omap_cfg_reg);
|
2005-11-10 17:26:50 +03:00
|
|
|
#else
|
|
|
|
#define omap_mux_init() do {} while(0)
|
|
|
|
#define omap_cfg_reg(x) do {} while(0)
|
2005-07-10 22:58:15 +04:00
|
|
|
#endif /* CONFIG_OMAP_MUX */
|