2005-07-10 19:58:15 +01: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 17:24:15 -08:00
* Copyright ( C ) 2003 - 2008 Nokia Corporation
2005-07-10 19:58:15 +01:00
*
2008-01-24 17:24:15 -08:00
* Written by Tony Lindgren
2005-07-10 19:58:15 +01: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 12:10:45 +01:00
# include <linux/io.h>
2005-07-10 19:58:15 +01:00
# include <asm/system.h>
# include <linux/spinlock.h>
2009-10-20 09:40:47 -07:00
# include <plat/mux.h>
2005-07-10 19:58:15 +01:00
# ifdef CONFIG_OMAP_MUX
2008-01-25 00:42:48 -08:00
static struct omap_mux_cfg * mux_cfg ;
2005-11-10 14:26:50 +00:00
2008-01-25 00:42:48 -08:00
int __init omap_mux_register ( struct omap_mux_cfg * arch_mux_cfg )
2005-11-10 14:26:50 +00:00
{
2008-01-25 00:42:48 -08: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 19:58:15 +01: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 19:58:15 +01:00
{
2008-01-25 00:42:48 -08:00
struct pin_config * reg ;
2005-07-10 19:58:15 +01:00
2010-07-05 16:31:40 +03:00
if ( ! cpu_class_is_omap1 ( ) ) {
2009-12-11 16:16:32 -08:00
printk ( KERN_ERR " mux: Broken omap_cfg_reg(%lu) entry \n " ,
index ) ;
WARN_ON ( 1 ) ;
return - EINVAL ;
}
2009-05-28 14:16:04 -07:00
2008-01-25 00:42:48 -08:00
if ( mux_cfg = = NULL ) {
printk ( KERN_ERR " Pin mux table not initialized \n " ) ;
return - ENODEV ;
}
2005-09-07 17:20:26 +01:00
2008-01-25 00:42:48 -08: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 00:42:48 -08:00
index , mux_cfg - > size ) ;
2005-11-10 14:26:50 +00:00
dump_stack ( ) ;
return - ENODEV ;
2005-07-10 19:58:15 +01:00
}
2008-01-25 00:42:48 -08:00
reg = ( struct pin_config * ) & mux_cfg - > pins [ index ] ;
2005-07-10 19:58:15 +01:00
2008-01-25 00:42:48 -08:00
if ( ! mux_cfg - > cfg_reg )
return - ENODEV ;
2005-07-10 19:58:15 +01:00
2008-01-25 00:42:48 -08:00
return mux_cfg - > cfg_reg ( reg ) ;
2005-07-10 19:58:15 +01: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 19:58:15 +01:00
# endif /* CONFIG_OMAP_MUX */