aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-davinci/mux.c
diff options
context:
space:
mode:
authorCyril Chemparathy <cyril@ti.com>2010-05-07 17:06:38 -0400
committerKevin Hilman <khilman@deeprootsystems.com>2010-05-13 13:05:29 -0400
commit779b0d53ca41873d59225eb776c5d4493a0abd0f (patch)
treecf47ab5746105d9116e6c9e33f7ad142ff726d7a /arch/arm/mach-davinci/mux.c
parentbd808947040ba53b2b0e52dde598a9414fb27bba (diff)
Davinci: pinmux - use ioremap()
This patch modifies the pinmux implementation so as to ioremap() the pinmux register area on first use. Signed-off-by: Cyril Chemparathy <cyril@ti.com> Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
Diffstat (limited to 'arch/arm/mach-davinci/mux.c')
-rw-r--r--arch/arm/mach-davinci/mux.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/arch/arm/mach-davinci/mux.c b/arch/arm/mach-davinci/mux.c
index e9d530a8f79f..f34a8dcdae2b 100644
--- a/arch/arm/mach-davinci/mux.c
+++ b/arch/arm/mach-davinci/mux.c
@@ -22,6 +22,8 @@
22#include <mach/mux.h> 22#include <mach/mux.h>
23#include <mach/common.h> 23#include <mach/common.h>
24 24
25static void __iomem *pinmux_base;
26
25/* 27/*
26 * Sets the DAVINCI MUX register based on the table 28 * Sets the DAVINCI MUX register based on the table
27 */ 29 */
@@ -29,14 +31,19 @@ int __init_or_module davinci_cfg_reg(const unsigned long index)
29{ 31{
30 static DEFINE_SPINLOCK(mux_spin_lock); 32 static DEFINE_SPINLOCK(mux_spin_lock);
31 struct davinci_soc_info *soc_info = &davinci_soc_info; 33 struct davinci_soc_info *soc_info = &davinci_soc_info;
32 void __iomem *base = soc_info->pinmux_base;
33 unsigned long flags; 34 unsigned long flags;
34 const struct mux_config *cfg; 35 const struct mux_config *cfg;
35 unsigned int reg_orig = 0, reg = 0; 36 unsigned int reg_orig = 0, reg = 0;
36 unsigned int mask, warn = 0; 37 unsigned int mask, warn = 0;
37 38
38 if (!soc_info->pinmux_pins) 39 if (WARN_ON(!soc_info->pinmux_pins))
39 BUG(); 40 return -ENODEV;
41
42 if (!pinmux_base) {
43 pinmux_base = ioremap(soc_info->pinmux_base, SZ_4K);
44 if (WARN_ON(!pinmux_base))
45 return -ENOMEM;
46 }
40 47
41 if (index >= soc_info->pinmux_pins_num) { 48 if (index >= soc_info->pinmux_pins_num) {
42 printk(KERN_ERR "Invalid pin mux index: %lu (%lu)\n", 49 printk(KERN_ERR "Invalid pin mux index: %lu (%lu)\n",
@@ -57,7 +64,7 @@ int __init_or_module davinci_cfg_reg(const unsigned long index)
57 unsigned tmp1, tmp2; 64 unsigned tmp1, tmp2;
58 65
59 spin_lock_irqsave(&mux_spin_lock, flags); 66 spin_lock_irqsave(&mux_spin_lock, flags);
60 reg_orig = __raw_readl(base + cfg->mux_reg); 67 reg_orig = __raw_readl(pinmux_base + cfg->mux_reg);
61 68
62 mask = (cfg->mask << cfg->mask_offset); 69 mask = (cfg->mask << cfg->mask_offset);
63 tmp1 = reg_orig & mask; 70 tmp1 = reg_orig & mask;
@@ -69,7 +76,7 @@ int __init_or_module davinci_cfg_reg(const unsigned long index)
69 if (tmp1 != tmp2) 76 if (tmp1 != tmp2)
70 warn = 1; 77 warn = 1;
71 78
72 __raw_writel(reg, base + cfg->mux_reg); 79 __raw_writel(reg, pinmux_base + cfg->mux_reg);
73 spin_unlock_irqrestore(&mux_spin_lock, flags); 80 spin_unlock_irqrestore(&mux_spin_lock, flags);
74 } 81 }
75 82