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