]>
git.ipfire.org Git - people/ms/u-boot.git/blob - arch/arm/cpu/arm926ejs/davinci/pinmux.c
2 * DaVinci pinmux functions.
4 * Copyright (C) 2009 Nick Thompson, GE Fanuc Ltd, <nick.thompson@gefanuc.com>
5 * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
6 * Copyright (C) 2008 Lyrtech <www.lyrtech.com>
7 * Copyright (C) 2004 Texas Instruments.
9 * See file CREDITS for list of people who contributed to this
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #include <asm/arch/hardware.h>
30 #include <asm/arch/davinci_misc.h>
33 * Change the setting of a pin multiplexer field.
35 * Takes an array of pinmux settings similar to:
37 * struct pinmux_config uart_pins[] = {
38 * { &davinci_syscfg_regs->pinmux[8], 2, 7 },
39 * { &davinci_syscfg_regs->pinmux[9], 2, 0 }
42 * Stepping through the array, each pinmux[n] register has the given value
43 * set in the pin mux field specified.
45 * The number of pins in the array must be passed (ARRAY_SIZE can provide
46 * this value conveniently).
48 * Returns 0 if all field numbers and values are in the correct range,
51 int davinci_configure_pin_mux(const struct pinmux_config
*pins
,
56 /* check for invalid pinmux values */
57 for (i
= 0; i
< n_pins
; i
++) {
58 if (pins
[i
].field
>= PIN_MUX_NUM_FIELDS
||
59 (pins
[i
].value
& ~PIN_MUX_FIELD_MASK
) != 0)
63 /* configure the pinmuxes */
64 for (i
= 0; i
< n_pins
; i
++) {
65 const int offset
= pins
[i
].field
* PIN_MUX_FIELD_SIZE
;
66 const unsigned int value
= pins
[i
].value
<< offset
;
67 const unsigned int mask
= PIN_MUX_FIELD_MASK
<< offset
;
68 const dv_reg
*mux
= pins
[i
].mux
;
70 writel(value
| (readl(mux
) & (~mask
)), mux
);
77 * Configure multiple pinmux resources.
79 * Takes an pinmux_resource array of pinmux_config and pin counts:
81 * const struct pinmux_resource pinmuxes[] = {
82 * PINMUX_ITEM(uart_pins),
83 * PINMUX_ITEM(i2c_pins),
86 * The number of items in the array must be passed (ARRAY_SIZE can provide
87 * this value conveniently).
89 * Each item entry is configured in the defined order. If configuration
90 * of any item fails, -1 is returned and none of the following items are
91 * configured. On success, 0 is returned.
93 int davinci_configure_pin_mux_items(const struct pinmux_resource
*item
,
98 for (i
= 0; i
< n_items
; i
++) {
99 if (davinci_configure_pin_mux(item
[i
].pins
,
100 item
[i
].n_pins
) != 0)