2 * Copyright 2004-2006,2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 * Copyright (C) 2008 by Sascha Hauer <kernel@pengutronix.de>
4 * Copyright (C) 2009 by Jan Weitzel Phytec Messtechnik GmbH,
7 * SPDX-License-Identifier: GPL-2.0+
11 #include <linux/errno.h>
13 #include <asm/arch/clock.h>
14 #include <asm/arch/iomux.h>
15 #include <asm/arch/imx-regs.h>
17 #if defined(CONFIG_MX23)
18 #define DRIVE_OFFSET 0x200
19 #define PULL_OFFSET 0x400
20 #elif defined(CONFIG_MX28)
21 #define DRIVE_OFFSET 0x300
22 #define PULL_OFFSET 0x600
24 #error "Please select CONFIG_MX23 or CONFIG_MX28"
28 * configures a single pad in the iomuxer
30 int mxs_iomux_setup_pad(iomux_cfg_t pad)
33 void *iomux_base = (void *)MXS_PINCTRL_BASE;
34 struct mxs_register_32 *mxs_reg;
38 ofs += PAD_BANK(pad) * 0x20 + PAD_PIN(pad) / 16 * 0x10;
39 bp = PAD_PIN(pad) % 16 * 2;
41 reg = readl(iomux_base + ofs);
43 reg |= PAD_MUXSEL(pad) << bp;
44 writel(reg, iomux_base + ofs);
48 ofs += PAD_BANK(pad) * 0x40 + PAD_PIN(pad) / 8 * 0x10;
50 if (PAD_MA_VALID(pad)) {
51 bp = PAD_PIN(pad) % 8 * 4;
53 reg = readl(iomux_base + ofs);
55 reg |= PAD_MA(pad) << bp;
56 writel(reg, iomux_base + ofs);
59 if (PAD_VOL_VALID(pad)) {
60 bp = PAD_PIN(pad) % 8 * 4 + 2;
61 mxs_reg = (struct mxs_register_32 *)(iomux_base + ofs);
63 writel(1 << bp, &mxs_reg->reg_set);
65 writel(1 << bp, &mxs_reg->reg_clr);
69 if (PAD_PULL_VALID(pad)) {
71 ofs += PAD_BANK(pad) * 0x10;
73 mxs_reg = (struct mxs_register_32 *)(iomux_base + ofs);
75 writel(1 << bp, &mxs_reg->reg_set);
77 writel(1 << bp, &mxs_reg->reg_clr);
83 int mxs_iomux_setup_multiple_pads(const iomux_cfg_t *pad_list, unsigned count)
85 const iomux_cfg_t *p = pad_list;
89 for (i = 0; i < count; i++) {
90 ret = mxs_iomux_setup_pad(*p);