]>
git.ipfire.org Git - people/ms/u-boot.git/blob - arch/arm/mach-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 * SPDX-License-Identifier: GPL-2.0+
13 #include <asm/arch/hardware.h>
15 #include <asm/arch/davinci_misc.h>
18 * Change the setting of a pin multiplexer field.
20 * Takes an array of pinmux settings similar to:
22 * struct pinmux_config uart_pins[] = {
23 * { &davinci_syscfg_regs->pinmux[8], 2, 7 },
24 * { &davinci_syscfg_regs->pinmux[9], 2, 0 }
27 * Stepping through the array, each pinmux[n] register has the given value
28 * set in the pin mux field specified.
30 * The number of pins in the array must be passed (ARRAY_SIZE can provide
31 * this value conveniently).
33 * Returns 0 if all field numbers and values are in the correct range,
36 int davinci_configure_pin_mux(const struct pinmux_config
*pins
,
41 /* check for invalid pinmux values */
42 for (i
= 0; i
< n_pins
; i
++) {
43 if (pins
[i
].field
>= PIN_MUX_NUM_FIELDS
||
44 (pins
[i
].value
& ~PIN_MUX_FIELD_MASK
) != 0)
48 /* configure the pinmuxes */
49 for (i
= 0; i
< n_pins
; i
++) {
50 const int offset
= pins
[i
].field
* PIN_MUX_FIELD_SIZE
;
51 const unsigned int value
= pins
[i
].value
<< offset
;
52 const unsigned int mask
= PIN_MUX_FIELD_MASK
<< offset
;
53 const dv_reg
*mux
= pins
[i
].mux
;
55 writel(value
| (readl(mux
) & (~mask
)), mux
);
62 * Configure multiple pinmux resources.
64 * Takes an pinmux_resource array of pinmux_config and pin counts:
66 * const struct pinmux_resource pinmuxes[] = {
67 * PINMUX_ITEM(uart_pins),
68 * PINMUX_ITEM(i2c_pins),
71 * The number of items in the array must be passed (ARRAY_SIZE can provide
72 * this value conveniently).
74 * Each item entry is configured in the defined order. If configuration
75 * of any item fails, -1 is returned and none of the following items are
76 * configured. On success, 0 is returned.
78 int davinci_configure_pin_mux_items(const struct pinmux_resource
*item
,
83 for (i
= 0; i
< n_items
; i
++) {
84 if (davinci_configure_pin_mux(item
[i
].pins
,