i.MX31: Add some enums and a couple helper functions to make dealing with pin muxing...
[kugel-rb.git] / firmware / target / arm / imx31 / iomuxc-imx31.c
blob876b8b2a9cbffc8f1b60d4cee93615913bddfa50
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (c) 2010 Michael Sevakis
12 * i.MX31 IOMUXC helper routines
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
22 ****************************************************************************/
23 #include "config.h"
24 #include "system.h"
25 #include "iomuxc-imx31.h"
28 /* Set the pin multiplexing configuration (functional, GPIO, etc.) */
29 void iomuxc_set_pin_mux(enum IMX31_IOMUXC_PINS pin,
30 unsigned long mux)
32 unsigned long index = pin / 4;
33 unsigned int shift = 8*(pin % 4);
35 imx31_regmod32((unsigned long *)(IOMUXC_BASE_ADDR + 0xc) + index,
36 mux << shift, IOMUXC_MUX_MASK << shift);
40 /* Set the pin pad configuration (keeper, drive strength, etc.) */
41 void iomuxc_set_pad_config(enum IMX31_IOMUXC_PINS pin,
42 unsigned long config)
44 unsigned long padoffs = pin + 2;
45 unsigned long index = padoffs / 3;
46 unsigned int shift = 10*(padoffs % 3);
48 imx31_regmod32((unsigned long *)(IOMUXC_BASE_ADDR + 0x154) + index,
49 config << shift, IOMUXC_PAD_MASK << shift);