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