aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2008-01-24 20:24:15 -0500
committerTony Lindgren <tony@atomide.com>2008-04-14 12:57:13 -0400
commit9330899e0f878ff3b7a23b856de8bbb52c9c04fd (patch)
tree7ea8c0362e6320dfbd7c6dd124e34a0b6ef7c6b1 /arch
parentf7337a199acffa9f12fa9d88253d33bfb56ef14a (diff)
ARM: OMAP2: Clean-up mux code
Misc clean-up for the mux code and remove some unnecessary ifdefs. Patch changes debug function so it can be used on both 24xx and 34xx. Changes are mostly for omap2, but patch also cleans up some omap1 and common mux code. Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-omap1/mux.c28
-rw-r--r--arch/arm/mach-omap2/mux.c69
-rw-r--r--arch/arm/plat-omap/mux.c4
3 files changed, 60 insertions, 41 deletions
diff --git a/arch/arm/mach-omap1/mux.c b/arch/arm/mach-omap1/mux.c
index cf3bdc00cfdb..e207bf7cb853 100644
--- a/arch/arm/mach-omap1/mux.c
+++ b/arch/arm/mach-omap1/mux.c
@@ -3,9 +3,9 @@
3 * 3 *
4 * OMAP1 pin multiplexing configurations 4 * OMAP1 pin multiplexing configurations
5 * 5 *
6 * Copyright (C) 2003 - 2005 Nokia Corporation 6 * Copyright (C) 2003 - 2008 Nokia Corporation
7 * 7 *
8 * Written by Tony Lindgren <tony.lindgren@nokia.com> 8 * Written by Tony Lindgren
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
@@ -35,7 +35,7 @@
35static struct omap_mux_cfg arch_mux_cfg; 35static struct omap_mux_cfg arch_mux_cfg;
36 36
37#ifdef CONFIG_ARCH_OMAP730 37#ifdef CONFIG_ARCH_OMAP730
38struct pin_config __initdata_or_module omap730_pins[] = { 38static struct pin_config __initdata_or_module omap730_pins[] = {
39MUX_CFG_730("E2_730_KBR0", 12, 21, 0, 20, 1, 0) 39MUX_CFG_730("E2_730_KBR0", 12, 21, 0, 20, 1, 0)
40MUX_CFG_730("J7_730_KBR1", 12, 25, 0, 24, 1, 0) 40MUX_CFG_730("J7_730_KBR1", 12, 25, 0, 24, 1, 0)
41MUX_CFG_730("E1_730_KBR2", 12, 29, 0, 28, 1, 0) 41MUX_CFG_730("E1_730_KBR2", 12, 29, 0, 28, 1, 0)
@@ -51,10 +51,14 @@ MUX_CFG_730("AA17_730_USB_DM", 2, 21, 0, 20, 0, 0)
51MUX_CFG_730("W16_730_USB_PU_EN", 2, 25, 0, 24, 0, 0) 51MUX_CFG_730("W16_730_USB_PU_EN", 2, 25, 0, 24, 0, 0)
52MUX_CFG_730("W17_730_USB_VBUSI", 2, 29, 0, 28, 0, 0) 52MUX_CFG_730("W17_730_USB_VBUSI", 2, 29, 0, 28, 0, 0)
53}; 53};
54#endif 54#define OMAP730_PINS_SZ ARRAY_SIZE(omap730_pins)
55#else
56#define omap730_pins NULL
57#define OMAP730_PINS_SZ 0
58#endif /* CONFIG_ARCH_OMAP730 */
55 59
56#if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX) 60#if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX)
57struct pin_config __initdata_or_module omap1xxx_pins[] = { 61static struct pin_config __initdata_or_module omap1xxx_pins[] = {
58/* 62/*
59 * description mux mode mux pull pull pull pu_pd pu dbg 63 * description mux mode mux pull pull pull pu_pd pu dbg
60 * reg offset mode reg bit ena reg 64 * reg offset mode reg bit ena reg
@@ -308,8 +312,11 @@ MUX_CFG("Y12_1610_CCP_CLKP", 8, 18, 6, 1, 24, 1, 1, 0, 0)
308MUX_CFG("W13_1610_CCP_CLKM", 9, 0, 6, 1, 28, 1, 1, 0, 0) 312MUX_CFG("W13_1610_CCP_CLKM", 9, 0, 6, 1, 28, 1, 1, 0, 0)
309MUX_CFG("W14_1610_CCP_DATAP", 9, 24, 6, 2, 4, 1, 2, 0, 0) 313MUX_CFG("W14_1610_CCP_DATAP", 9, 24, 6, 2, 4, 1, 2, 0, 0)
310MUX_CFG("Y14_1610_CCP_DATAM", 9, 21, 6, 2, 3, 1, 2, 0, 0) 314MUX_CFG("Y14_1610_CCP_DATAM", 9, 21, 6, 2, 3, 1, 2, 0, 0)
311
312}; 315};
316#define OMAP1XXX_PINS_SZ ARRAY_SIZE(omap1xxx_pins)
317#else
318#define omap1xxx_pins NULL
319#define OMAP1XXX_PINS_SZ 0
313#endif /* CONFIG_ARCH_OMAP15XX || CONFIG_ARCH_OMAP16XX */ 320#endif /* CONFIG_ARCH_OMAP15XX || CONFIG_ARCH_OMAP16XX */
314 321
315int __init_or_module omap1_cfg_reg(const struct pin_config *cfg) 322int __init_or_module omap1_cfg_reg(const struct pin_config *cfg)
@@ -422,22 +429,17 @@ int __init_or_module omap1_cfg_reg(const struct pin_config *cfg)
422 429
423int __init omap1_mux_init(void) 430int __init omap1_mux_init(void)
424{ 431{
425
426#ifdef CONFIG_ARCH_OMAP730
427 if (cpu_is_omap730()) { 432 if (cpu_is_omap730()) {
428 arch_mux_cfg.pins = omap730_pins; 433 arch_mux_cfg.pins = omap730_pins;
429 arch_mux_cfg.size = ARRAY_SIZE(omap730_pins); 434 arch_mux_cfg.size = OMAP730_PINS_SZ;
430 arch_mux_cfg.cfg_reg = omap1_cfg_reg; 435 arch_mux_cfg.cfg_reg = omap1_cfg_reg;
431 } 436 }
432#endif
433 437
434#if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX)
435 if (cpu_is_omap15xx() || cpu_is_omap16xx()) { 438 if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
436 arch_mux_cfg.pins = omap1xxx_pins; 439 arch_mux_cfg.pins = omap1xxx_pins;
437 arch_mux_cfg.size = ARRAY_SIZE(omap1xxx_pins); 440 arch_mux_cfg.size = OMAP1XXX_PINS_SZ;
438 arch_mux_cfg.cfg_reg = omap1_cfg_reg; 441 arch_mux_cfg.cfg_reg = omap1_cfg_reg;
439 } 442 }
440#endif
441 443
442 return omap_mux_register(&arch_mux_cfg); 444 return omap_mux_register(&arch_mux_cfg);
443} 445}
diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c
index 5cba3a2a2392..0cf7562ff88f 100644
--- a/arch/arm/mach-omap2/mux.c
+++ b/arch/arm/mach-omap2/mux.c
@@ -1,11 +1,12 @@
1/* 1/*
2 * linux/arch/arm/mach-omap2/mux.c 2 * linux/arch/arm/mach-omap2/mux.c
3 * 3 *
4 * OMAP1 pin multiplexing configurations 4 * OMAP2 pin multiplexing configurations
5 * 5 *
6 * Copyright (C) 2003 - 2005 Nokia Corporation 6 * Copyright (C) 2004 - 2008 Texas Instruments Inc.
7 * Copyright (C) 2003 - 2008 Nokia Corporation
7 * 8 *
8 * Written by Tony Lindgren <tony.lindgren@nokia.com> 9 * Written by Tony Lindgren
9 * 10 *
10 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 12 * it under the terms of the GNU General Public License as published by
@@ -36,7 +37,8 @@ static struct omap_mux_cfg arch_mux_cfg;
36 37
37/* NOTE: See mux.h for the enumeration */ 38/* NOTE: See mux.h for the enumeration */
38 39
39struct pin_config __initdata_or_module omap24xx_pins[] = { 40#ifdef CONFIG_ARCH_OMAP24XX
41static struct pin_config __initdata_or_module omap24xx_pins[] = {
40/* 42/*
41 * description mux mux pull pull debug 43 * description mux mux pull pull debug
42 * offset mode ena type 44 * offset mode ena type
@@ -209,54 +211,69 @@ MUX_CFG_24XX("AE13_2430_MCBSP2_DX_OFF", 0x0130, 0, 0, 0, 1)
209MUX_CFG_24XX("AD13_2430_MCBSP2_DR_OFF", 0x0131, 0, 0, 0, 1) 211MUX_CFG_24XX("AD13_2430_MCBSP2_DR_OFF", 0x0131, 0, 0, 0, 1)
210}; 212};
211 213
212#ifdef CONFIG_ARCH_OMAP24XX 214#define OMAP24XX_PINS_SZ ARRAY_SIZE(omap24xx_pins)
215
216#else
217#define omap24xx_pins NULL
218#define OMAP24XX_PINS_SZ 0
219#endif /* CONFIG_ARCH_OMAP24XX */
213 220
214#define OMAP24XX_L4_BASE 0x48000000 221#define OMAP24XX_L4_BASE 0x48000000
215#define OMAP24XX_PULL_ENA (1 << 3) 222#define OMAP24XX_PULL_ENA (1 << 3)
216#define OMAP24XX_PULL_UP (1 << 4) 223#define OMAP24XX_PULL_UP (1 << 4)
217 224
218/* REVISIT: Convert this code to use ctrl_{read,write}_reg */ 225/* REVISIT: Convert this code to use ctrl_{read,write}_reg */
226#if defined(CONFIG_OMAP_MUX_DEBUG) || defined(CONFIG_OMAP_MUX_WARNINGS)
227void __init_or_module omap2_cfg_debug(const struct pin_config *cfg, u8 reg)
228{
229 u16 orig;
230 u8 warn = 0, debug = 0;
231
232 orig = omap_readb(OMAP24XX_L4_BASE + cfg->mux_reg);
233
234#ifdef CONFIG_OMAP_MUX_DEBUG
235 debug = cfg->debug;
236#endif
237 warn = (orig != reg);
238 if (debug || warn)
239 printk(KERN_WARNING
240 "MUX: setup %s (0x%08x): 0x%02x -> 0x%02x\n",
241 cfg->name, omap_readb(OMAP24XX_L4_BASE + cfg->mux_reg));
242}
243#else
244#define omap2_cfg_debug(x, y) do {} while (0)
245#endif
246
247#ifdef CONFIG_ARCH_OMAP24XX
219int __init_or_module omap24xx_cfg_reg(const struct pin_config *cfg) 248int __init_or_module omap24xx_cfg_reg(const struct pin_config *cfg)
220{ 249{
250 static DEFINE_SPINLOCK(mux_spin_lock);
251 unsigned long flags;
221 u8 reg = 0; 252 u8 reg = 0;
222 unsigned int warn = 0;
223 253
254 spin_lock_irqsave(&mux_spin_lock, flags);
224 reg |= cfg->mask & 0x7; 255 reg |= cfg->mask & 0x7;
225 if (cfg->pull_val) 256 if (cfg->pull_val)
226 reg |= OMAP24XX_PULL_ENA; 257 reg |= OMAP24XX_PULL_ENA;
227 if(cfg->pu_pd_val) 258 if (cfg->pu_pd_val)
228 reg |= OMAP24XX_PULL_UP; 259 reg |= OMAP24XX_PULL_UP;
229#if defined(CONFIG_OMAP_MUX_DEBUG) || defined(CONFIG_OMAP_MUX_WARNINGS) 260 omap2_cfg_debug(cfg, reg);
230 {
231 u8 orig = omap_readb(OMAP24XX_L4_BASE + cfg->mux_reg);
232 u8 debug = 0;
233
234#ifdef CONFIG_OMAP_MUX_DEBUG
235 debug = cfg->debug;
236#endif
237 warn = (orig != reg);
238 if (debug || warn)
239 printk("MUX: setup %s (0x%08x): 0x%02x -> 0x%02x\n",
240 cfg->name, OMAP24XX_L4_BASE + cfg->mux_reg,
241 orig, reg);
242 }
243#endif
244 omap_writeb(reg, OMAP24XX_L4_BASE + cfg->mux_reg); 261 omap_writeb(reg, OMAP24XX_L4_BASE + cfg->mux_reg);
262 spin_unlock_irqrestore(&mux_spin_lock, flags);
245 263
246 return 0; 264 return 0;
247} 265}
266#else
267#define omap24xx_cfg_reg 0
248#endif 268#endif
249 269
250int __init omap2_mux_init(void) 270int __init omap2_mux_init(void)
251{ 271{
252
253#ifdef CONFIG_ARCH_OMAP24XX
254 if (cpu_is_omap24xx()) { 272 if (cpu_is_omap24xx()) {
255 arch_mux_cfg.pins = omap24xx_pins; 273 arch_mux_cfg.pins = omap24xx_pins;
256 arch_mux_cfg.size = ARRAY_SIZE(omap24xx_pins); 274 arch_mux_cfg.size = OMAP24XX_PINS_SZ;
257 arch_mux_cfg.cfg_reg = omap24xx_cfg_reg; 275 arch_mux_cfg.cfg_reg = omap24xx_cfg_reg;
258 } 276 }
259#endif
260 277
261 return omap_mux_register(&arch_mux_cfg); 278 return omap_mux_register(&arch_mux_cfg);
262} 279}
diff --git a/arch/arm/plat-omap/mux.c b/arch/arm/plat-omap/mux.c
index 4de18b9ffb16..6f3f459731c8 100644
--- a/arch/arm/plat-omap/mux.c
+++ b/arch/arm/plat-omap/mux.c
@@ -3,9 +3,9 @@
3 * 3 *
4 * Utility to set the Omap MUX and PULL_DWN registers from a table in mux.h 4 * Utility to set the Omap MUX and PULL_DWN registers from a table in mux.h
5 * 5 *
6 * Copyright (C) 2003 - 2005 Nokia Corporation 6 * Copyright (C) 2003 - 2008 Nokia Corporation
7 * 7 *
8 * Written by Tony Lindgren <tony.lindgren@nokia.com> 8 * Written by Tony Lindgren
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by