Linux 5.7.7
[linux/fpc-iii.git] / arch / arm / mach-imx / iomux-v3.c
blob043cf3c7cacf2e6a618d6d23fc6d703c31466655
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright 2004-2006 Freescale Semiconductor, Inc. All Rights Reserved.
4 * Copyright (C) 2008 by Sascha Hauer <kernel@pengutronix.de>
5 * Copyright (C) 2009 by Jan Weitzel Phytec Messtechnik GmbH,
6 * <armlinux@phytec.de>
7 */
8 #include <linux/errno.h>
9 #include <linux/init.h>
10 #include <linux/kernel.h>
11 #include <linux/module.h>
12 #include <linux/string.h>
13 #include <linux/gpio.h>
15 #include <asm/mach/map.h>
17 #include "hardware.h"
18 #include "iomux-v3.h"
20 static void __iomem *base;
23 * configures a single pad in the iomuxer
25 int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t pad)
27 u32 mux_ctrl_ofs = (pad & MUX_CTRL_OFS_MASK) >> MUX_CTRL_OFS_SHIFT;
28 u32 mux_mode = (pad & MUX_MODE_MASK) >> MUX_MODE_SHIFT;
29 u32 sel_input_ofs = (pad & MUX_SEL_INPUT_OFS_MASK) >> MUX_SEL_INPUT_OFS_SHIFT;
30 u32 sel_input = (pad & MUX_SEL_INPUT_MASK) >> MUX_SEL_INPUT_SHIFT;
31 u32 pad_ctrl_ofs = (pad & MUX_PAD_CTRL_OFS_MASK) >> MUX_PAD_CTRL_OFS_SHIFT;
32 u32 pad_ctrl = (pad & MUX_PAD_CTRL_MASK) >> MUX_PAD_CTRL_SHIFT;
34 if (mux_ctrl_ofs)
35 imx_writel(mux_mode, base + mux_ctrl_ofs);
37 if (sel_input_ofs)
38 imx_writel(sel_input, base + sel_input_ofs);
40 if (!(pad_ctrl & NO_PAD_CTRL) && pad_ctrl_ofs)
41 imx_writel(pad_ctrl, base + pad_ctrl_ofs);
43 return 0;
46 int mxc_iomux_v3_setup_multiple_pads(const iomux_v3_cfg_t *pad_list,
47 unsigned count)
49 const iomux_v3_cfg_t *p = pad_list;
50 int i;
51 int ret;
53 for (i = 0; i < count; i++) {
54 ret = mxc_iomux_v3_setup_pad(*p);
55 if (ret)
56 return ret;
57 p++;
59 return 0;
62 void mxc_iomux_v3_init(void __iomem *iomux_v3_base)
64 base = iomux_v3_base;