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