blob: b59b802830677b240af7ce915394b41a8a1a1831 [file] [log] [blame]
Jason Liu23608e22011-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 Denk1a459662013-07-08 09:37:19 +02009 * SPDX-License-Identifier: GPL-2.0+
Jason Liu23608e22011-11-25 00:18:02 +000010 */
11#include <common.h>
12#include <asm/io.h>
13#include <asm/arch/imx-regs.h>
Troy Kiskyaf2a35f2012-07-19 08:18:22 +000014#include <asm/imx-common/iomux-v3.h>
Jason Liu23608e22011-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 Roese59efa052013-04-10 23:06:46 +000021void imx_iomux_v3_setup_pad(iomux_v3_cfg_t pad)
Jason Liu23608e22011-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
33 if (mux_ctrl_ofs)
34 __raw_writel(mux_mode, base + mux_ctrl_ofs);
35
36 if (sel_input_ofs)
37 __raw_writel(sel_input, base + sel_input_ofs);
38
Alison Wangcfd701b2013-05-27 22:55:41 +000039#ifdef CONFIG_IOMUX_SHARE_CONF_REG
40 if (!(pad_ctrl & NO_PAD_CTRL))
41 __raw_writel((mux_mode << PAD_MUX_MODE_SHIFT) | pad_ctrl,
42 base + pad_ctrl_ofs);
43#else
Jason Liu23608e22011-11-25 00:18:02 +000044 if (!(pad_ctrl & NO_PAD_CTRL) && pad_ctrl_ofs)
45 __raw_writel(pad_ctrl, base + pad_ctrl_ofs);
Alison Wangcfd701b2013-05-27 22:55:41 +000046#endif
Jason Liu23608e22011-11-25 00:18:02 +000047}
48
Stefan Roese59efa052013-04-10 23:06:46 +000049void imx_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t const *pad_list,
50 unsigned count)
Jason Liu23608e22011-11-25 00:18:02 +000051{
Eric Nelson5ae28d22012-10-03 07:26:37 +000052 iomux_v3_cfg_t const *p = pad_list;
Jason Liu23608e22011-11-25 00:18:02 +000053 int i;
Jason Liu23608e22011-11-25 00:18:02 +000054
Stefan Roese59efa052013-04-10 23:06:46 +000055 for (i = 0; i < count; i++)
56 imx_iomux_v3_setup_pad(*p++);
Jason Liu23608e22011-11-25 00:18:02 +000057}