blob: 6e46ea8dcdeb0d762626faec9c8e3d649e9f9b17 [file] [log] [blame]
Jason Liudec11122011-11-25 00:18:02 +00001/*
2 * Based on the iomux-v3.c from Linux kernel:
3 * Copyright (C) 2008 by Sascha Hauer <kernel@pengutronix.de>
4 * Copyright (C) 2009 by Jan Weitzel Phytec Messtechnik GmbH,
5 * <armlinux@phytec.de>
6 *
7 * Copyright (C) 2004-2011 Freescale Semiconductor, Inc.
8 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02009 * SPDX-License-Identifier: GPL-2.0+
Jason Liudec11122011-11-25 00:18:02 +000010 */
11#include <common.h>
12#include <asm/io.h>
13#include <asm/arch/imx-regs.h>
Troy Kisky2714e172012-07-19 08:18:22 +000014#include <asm/imx-common/iomux-v3.h>
Jason Liudec11122011-11-25 00:18:02 +000015
16static void *base = (void *)IOMUXC_BASE_ADDR;
17
18/*
19 * configures a single pad in the iomuxer
20 */
Stefan Roese4982d9a2013-04-10 23:06:46 +000021void imx_iomux_v3_setup_pad(iomux_v3_cfg_t pad)
Jason Liudec11122011-11-25 00:18:02 +000022{
23 u32 mux_ctrl_ofs = (pad & MUX_CTRL_OFS_MASK) >> MUX_CTRL_OFS_SHIFT;
24 u32 mux_mode = (pad & MUX_MODE_MASK) >> MUX_MODE_SHIFT;
25 u32 sel_input_ofs =
26 (pad & MUX_SEL_INPUT_OFS_MASK) >> MUX_SEL_INPUT_OFS_SHIFT;
27 u32 sel_input =
28 (pad & MUX_SEL_INPUT_MASK) >> MUX_SEL_INPUT_SHIFT;
29 u32 pad_ctrl_ofs =
30 (pad & MUX_PAD_CTRL_OFS_MASK) >> MUX_PAD_CTRL_OFS_SHIFT;
31 u32 pad_ctrl = (pad & MUX_PAD_CTRL_MASK) >> MUX_PAD_CTRL_SHIFT;
32
Fabio Estevamd3b17422014-04-29 10:15:46 -030033#if defined CONFIG_MX6SL
34 /* Check whether LVE bit needs to be set */
35 if (pad_ctrl & PAD_CTL_LVE) {
36 pad_ctrl &= ~PAD_CTL_LVE;
37 pad_ctrl |= PAD_CTL_LVE_BIT;
38 }
39#endif
40
Jason Liudec11122011-11-25 00:18:02 +000041 if (mux_ctrl_ofs)
42 __raw_writel(mux_mode, base + mux_ctrl_ofs);
43
44 if (sel_input_ofs)
45 __raw_writel(sel_input, base + sel_input_ofs);
46
Alison Wang831beaf2013-05-27 22:55:41 +000047#ifdef CONFIG_IOMUX_SHARE_CONF_REG
48 if (!(pad_ctrl & NO_PAD_CTRL))
49 __raw_writel((mux_mode << PAD_MUX_MODE_SHIFT) | pad_ctrl,
50 base + pad_ctrl_ofs);
51#else
Jason Liudec11122011-11-25 00:18:02 +000052 if (!(pad_ctrl & NO_PAD_CTRL) && pad_ctrl_ofs)
53 __raw_writel(pad_ctrl, base + pad_ctrl_ofs);
Alison Wang831beaf2013-05-27 22:55:41 +000054#endif
Jason Liudec11122011-11-25 00:18:02 +000055}
56
Stefan Roese4982d9a2013-04-10 23:06:46 +000057void imx_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t const *pad_list,
58 unsigned count)
Jason Liudec11122011-11-25 00:18:02 +000059{
Eric Nelson89110832012-10-03 07:26:37 +000060 iomux_v3_cfg_t const *p = pad_list;
Jason Liudec11122011-11-25 00:18:02 +000061 int i;
Jason Liudec11122011-11-25 00:18:02 +000062
Stefan Roese4982d9a2013-04-10 23:06:46 +000063 for (i = 0; i < count; i++)
64 imx_iomux_v3_setup_pad(*p++);
Jason Liudec11122011-11-25 00:18:02 +000065}