aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/mux.c
diff options
context:
space:
mode:
authorMike Rapoport <mike@compulab.co.il>2009-12-11 19:16:31 -0500
committerTony Lindgren <tony@atomide.com>2009-12-11 19:16:31 -0500
commit92c9f5018997dbc5f5e91eae2400d78ada2760b0 (patch)
treeab98e9539cd6a554be1cec164ca9528b55cf1cc4 /arch/arm/mach-omap2/mux.c
parent24ed45aa0776f9f645aa1ac1a88b2e1d5f29a9aa (diff)
omap2: mux: intoduce omap_mux_{read,write}
intoduce omap_mux_{read,write} Signed-off-by: Mike Rapoport <mike@compulab.co.il> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap2/mux.c')
-rw-r--r--arch/arm/mach-omap2/mux.c44
1 files changed, 38 insertions, 6 deletions
diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c
index c18a94eca641..64250c504c64 100644
--- a/arch/arm/mach-omap2/mux.c
+++ b/arch/arm/mach-omap2/mux.c
@@ -35,7 +35,27 @@
35 35
36#ifdef CONFIG_OMAP_MUX 36#ifdef CONFIG_OMAP_MUX
37 37
38#define OMAP_MUX_BASE_OFFSET 0x30 /* Offset from CTRL_BASE */
39#define OMAP_MUX_BASE_SZ 0x5ca
40
38static struct omap_mux_cfg arch_mux_cfg; 41static struct omap_mux_cfg arch_mux_cfg;
42static void __iomem *mux_base;
43
44static inline u16 omap_mux_read(u16 reg)
45{
46 if (cpu_is_omap24xx())
47 return __raw_readb(mux_base + reg);
48 else
49 return __raw_readw(mux_base + reg);
50}
51
52static inline void omap_mux_write(u16 val, u16 reg)
53{
54 if (cpu_is_omap24xx())
55 __raw_writeb(val, mux_base + reg);
56 else
57 __raw_writew(val, mux_base + reg);
58}
39 59
40/* NOTE: See mux.h for the enumeration */ 60/* NOTE: See mux.h for the enumeration */
41 61
@@ -581,10 +601,7 @@ static void __init_or_module omap2_cfg_debug(const struct pin_config *cfg, u16 r
581 u16 orig; 601 u16 orig;
582 u8 warn = 0, debug = 0; 602 u8 warn = 0, debug = 0;
583 603
584 if (cpu_is_omap24xx()) 604 orig = omap_mux_read(cfg->mux_reg - OMAP_MUX_BASE_OFFSET);
585 orig = omap_ctrl_readb(cfg->mux_reg);
586 else
587 orig = omap_ctrl_readw(cfg->mux_reg);
588 605
589#ifdef CONFIG_OMAP_MUX_DEBUG 606#ifdef CONFIG_OMAP_MUX_DEBUG
590 debug = cfg->debug; 607 debug = cfg->debug;
@@ -614,7 +631,7 @@ static int __init_or_module omap24xx_cfg_reg(const struct pin_config *cfg)
614 if (cfg->pu_pd_val) 631 if (cfg->pu_pd_val)
615 reg |= OMAP2_PULL_UP; 632 reg |= OMAP2_PULL_UP;
616 omap2_cfg_debug(cfg, reg); 633 omap2_cfg_debug(cfg, reg);
617 omap_ctrl_writeb(reg, cfg->mux_reg); 634 omap_mux_write(reg, cfg->mux_reg - OMAP_MUX_BASE_OFFSET);
618 spin_unlock_irqrestore(&mux_spin_lock, flags); 635 spin_unlock_irqrestore(&mux_spin_lock, flags);
619 636
620 return 0; 637 return 0;
@@ -633,7 +650,7 @@ static int __init_or_module omap34xx_cfg_reg(const struct pin_config *cfg)
633 spin_lock_irqsave(&mux_spin_lock, flags); 650 spin_lock_irqsave(&mux_spin_lock, flags);
634 reg |= cfg->mux_val; 651 reg |= cfg->mux_val;
635 omap2_cfg_debug(cfg, reg); 652 omap2_cfg_debug(cfg, reg);
636 omap_ctrl_writew(reg, cfg->mux_reg); 653 omap_mux_write(reg, cfg->mux_reg - OMAP_MUX_BASE_OFFSET);
637 spin_unlock_irqrestore(&mux_spin_lock, flags); 654 spin_unlock_irqrestore(&mux_spin_lock, flags);
638 655
639 return 0; 656 return 0;
@@ -644,6 +661,21 @@ static int __init_or_module omap34xx_cfg_reg(const struct pin_config *cfg)
644 661
645int __init omap2_mux_init(void) 662int __init omap2_mux_init(void)
646{ 663{
664 u32 mux_pbase;
665
666 if (cpu_is_omap2420())
667 mux_pbase = OMAP2420_CTRL_BASE + OMAP_MUX_BASE_OFFSET;
668 else if (cpu_is_omap2430())
669 mux_pbase = OMAP243X_CTRL_BASE + OMAP_MUX_BASE_OFFSET;
670 else if (cpu_is_omap34xx())
671 mux_pbase = OMAP343X_CTRL_BASE + OMAP_MUX_BASE_OFFSET;
672
673 mux_base = ioremap(mux_pbase, OMAP_MUX_BASE_SZ);
674 if (!mux_base) {
675 printk(KERN_ERR "mux: Could not ioremap\n");
676 return -ENODEV;
677 }
678
647 if (cpu_is_omap24xx()) { 679 if (cpu_is_omap24xx()) {
648 arch_mux_cfg.pins = omap24xx_pins; 680 arch_mux_cfg.pins = omap24xx_pins;
649 arch_mux_cfg.size = OMAP24XX_PINS_SZ; 681 arch_mux_cfg.size = OMAP24XX_PINS_SZ;