1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2004-2006,2010 Freescale Semiconductor, Inc. All Rights Reserved.
5 * Copyright (C) 2009 by Jan Weitzel Phytec Messtechnik GmbH,
10 #include <linux/errno.h>
12 #include <asm/arch/clock.h>
13 #include <asm/arch/iomux.h>
14 #include <asm/arch/imx-regs.h>
16 #if defined(CONFIG_MX23)
17 #define DRIVE_OFFSET 0x200
18 #define PULL_OFFSET 0x400
19 #elif defined(CONFIG_MX28)
20 #define DRIVE_OFFSET 0x300
21 #define PULL_OFFSET 0x600
23 #error "Please select CONFIG_MX23 or CONFIG_MX28"
27 * configures a single pad in the iomuxer
29 int mxs_iomux_setup_pad(iomux_cfg_t pad)
32 void *iomux_base = (void *)MXS_PINCTRL_BASE;
33 struct mxs_register_32 *mxs_reg;
37 ofs += PAD_BANK(pad) * 0x20 + PAD_PIN(pad) / 16 * 0x10;
38 bp = PAD_PIN(pad) % 16 * 2;
40 reg = readl(iomux_base + ofs);
42 reg |= PAD_MUXSEL(pad) << bp;
43 writel(reg, iomux_base + ofs);
47 ofs += PAD_BANK(pad) * 0x40 + PAD_PIN(pad) / 8 * 0x10;
49 if (PAD_MA_VALID(pad)) {
50 bp = PAD_PIN(pad) % 8 * 4;
52 reg = readl(iomux_base + ofs);
54 reg |= PAD_MA(pad) << bp;
55 writel(reg, iomux_base + ofs);
58 if (PAD_VOL_VALID(pad)) {
59 bp = PAD_PIN(pad) % 8 * 4 + 2;
60 mxs_reg = (struct mxs_register_32 *)(iomux_base + ofs);
62 writel(1 << bp, &mxs_reg->reg_set);
64 writel(1 << bp, &mxs_reg->reg_clr);
68 if (PAD_PULL_VALID(pad)) {
70 ofs += PAD_BANK(pad) * 0x10;
72 mxs_reg = (struct mxs_register_32 *)(iomux_base + ofs);
74 writel(1 << bp, &mxs_reg->reg_set);
76 writel(1 << bp, &mxs_reg->reg_clr);
82 int mxs_iomux_setup_multiple_pads(const iomux_cfg_t *pad_list, unsigned count)
84 const iomux_cfg_t *p = pad_list;
88 for (i = 0; i < count; i++) {
89 ret = mxs_iomux_setup_pad(*p);