Blame view

arch/arm/plat-omap/mux.c 2.19 KB
5e1c5ff47   Tony Lindgren   [PATCH] ARM: 2812...
1
2
3
4
5
  /*
   * linux/arch/arm/plat-omap/mux.c
   *
   * Utility to set the Omap MUX and PULL_DWN registers from a table in mux.h
   *
9330899e0   Tony Lindgren   ARM: OMAP2: Clean...
6
   * Copyright (C) 2003 - 2008 Nokia Corporation
5e1c5ff47   Tony Lindgren   [PATCH] ARM: 2812...
7
   *
9330899e0   Tony Lindgren   ARM: OMAP2: Clean...
8
   * Written by Tony Lindgren
5e1c5ff47   Tony Lindgren   [PATCH] ARM: 2812...
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
   *
   * 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
   *
   */
5e1c5ff47   Tony Lindgren   [PATCH] ARM: 2812...
25
26
  #include <linux/module.h>
  #include <linux/init.h>
1a8bfa1eb   Tony Lindgren   [ARM] 3142/1: OMA...
27
  #include <linux/kernel.h>
fced80c73   Russell King   [ARM] Convert asm...
28
  #include <linux/io.h>
5e1c5ff47   Tony Lindgren   [PATCH] ARM: 2812...
29
  #include <asm/system.h>
5e1c5ff47   Tony Lindgren   [PATCH] ARM: 2812...
30
  #include <linux/spinlock.h>
ce491cf85   Tony Lindgren   omap: headers: Mo...
31
  #include <plat/mux.h>
5e1c5ff47   Tony Lindgren   [PATCH] ARM: 2812...
32
33
  
  #ifdef CONFIG_OMAP_MUX
7d7f665d5   Tony Lindgren   ARM: OMAP: Allow ...
34
  static struct omap_mux_cfg *mux_cfg;
1a8bfa1eb   Tony Lindgren   [ARM] 3142/1: OMA...
35

7d7f665d5   Tony Lindgren   ARM: OMAP: Allow ...
36
  int __init omap_mux_register(struct omap_mux_cfg *arch_mux_cfg)
1a8bfa1eb   Tony Lindgren   [ARM] 3142/1: OMA...
37
  {
7d7f665d5   Tony Lindgren   ARM: OMAP: Allow ...
38
39
40
41
42
43
44
45
  	if (!arch_mux_cfg || !arch_mux_cfg->pins || arch_mux_cfg->size == 0
  			|| !arch_mux_cfg->cfg_reg) {
  		printk(KERN_ERR "Invalid pin table
  ");
  		return -EINVAL;
  	}
  
  	mux_cfg = arch_mux_cfg;
1a8bfa1eb   Tony Lindgren   [ARM] 3142/1: OMA...
46
47
48
  
  	return 0;
  }
5e1c5ff47   Tony Lindgren   [PATCH] ARM: 2812...
49
50
51
  /*
   * Sets the Omap MUX and PULL_DWN registers based on the table
   */
1a8bfa1eb   Tony Lindgren   [ARM] 3142/1: OMA...
52
  int __init_or_module omap_cfg_reg(const unsigned long index)
5e1c5ff47   Tony Lindgren   [PATCH] ARM: 2812...
53
  {
225dfda1d   Tony Lindgren   ARM: OMAP: Split ...
54
  	struct pin_config *reg;
5e1c5ff47   Tony Lindgren   [PATCH] ARM: 2812...
55

c9d8230e3   Tony Lindgren   omap: mux: Remove...
56
  	if (!cpu_class_is_omap1()) {
15ac7afe5   Tony Lindgren   omap: mux: Add ne...
57
58
59
60
61
62
  		printk(KERN_ERR "mux: Broken omap_cfg_reg(%lu) entry
  ",
  				index);
  		WARN_ON(1);
  		return -EINVAL;
  	}
44169075e   Santosh Shilimkar   ARM: OMAP4: Add m...
63

7d7f665d5   Tony Lindgren   ARM: OMAP: Allow ...
64
65
66
67
68
  	if (mux_cfg == NULL) {
  		printk(KERN_ERR "Pin mux table not initialized
  ");
  		return -ENODEV;
  	}
92105bb70   Tony Lindgren   [ARM] 2887/1: OMA...
69

7d7f665d5   Tony Lindgren   ARM: OMAP: Allow ...
70
  	if (index >= mux_cfg->size) {
1a8bfa1eb   Tony Lindgren   [ARM] 3142/1: OMA...
71
72
  		printk(KERN_ERR "Invalid pin mux index: %lu (%lu)
  ",
7d7f665d5   Tony Lindgren   ARM: OMAP: Allow ...
73
  		       index, mux_cfg->size);
1a8bfa1eb   Tony Lindgren   [ARM] 3142/1: OMA...
74
75
  		dump_stack();
  		return -ENODEV;
5e1c5ff47   Tony Lindgren   [PATCH] ARM: 2812...
76
  	}
225dfda1d   Tony Lindgren   ARM: OMAP: Split ...
77
  	reg = (struct pin_config *)&mux_cfg->pins[index];
5e1c5ff47   Tony Lindgren   [PATCH] ARM: 2812...
78

225dfda1d   Tony Lindgren   ARM: OMAP: Split ...
79
80
  	if (!mux_cfg->cfg_reg)
  		return -ENODEV;
5e1c5ff47   Tony Lindgren   [PATCH] ARM: 2812...
81

225dfda1d   Tony Lindgren   ARM: OMAP: Split ...
82
  	return mux_cfg->cfg_reg(reg);
5e1c5ff47   Tony Lindgren   [PATCH] ARM: 2812...
83
  }
5e1c5ff47   Tony Lindgren   [PATCH] ARM: 2812...
84
  EXPORT_SYMBOL(omap_cfg_reg);
1a8bfa1eb   Tony Lindgren   [ARM] 3142/1: OMA...
85
86
87
  #else
  #define omap_mux_init() do {} while(0)
  #define omap_cfg_reg(x)	do {} while(0)
5e1c5ff47   Tony Lindgren   [PATCH] ARM: 2812...
88
  #endif	/* CONFIG_OMAP_MUX */