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 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23 #include <asm/errno.h>
25 #include <asm/arch/clock.h>
26 #include <asm/arch/iomux.h>
27 #include <asm/arch/imx-regs.h>
29 #if defined(CONFIG_MX23)
30 #define DRIVE_OFFSET 0x200
31 #define PULL_OFFSET 0x400
32 #elif defined(CONFIG_MX28)
33 #define DRIVE_OFFSET 0x300
34 #define PULL_OFFSET 0x600
36 #error "Please select CONFIG_MX23 or CONFIG_MX28"
40 * configures a single pad in the iomuxer
42 int mxs_iomux_setup_pad(iomux_cfg_t pad)
45 void *iomux_base = (void *)MXS_PINCTRL_BASE;
46 struct mx28_register_32 *mxs_reg;
50 ofs += PAD_BANK(pad) * 0x20 + PAD_PIN(pad) / 16 * 0x10;
51 bp = PAD_PIN(pad) % 16 * 2;
53 reg = readl(iomux_base + ofs);
55 reg |= PAD_MUXSEL(pad) << bp;
56 writel(reg, iomux_base + ofs);
60 ofs += PAD_BANK(pad) * 0x40 + PAD_PIN(pad) / 8 * 0x10;
62 if (PAD_MA_VALID(pad)) {
63 bp = PAD_PIN(pad) % 8 * 4;
65 reg = readl(iomux_base + ofs);
67 reg |= PAD_MA(pad) << bp;
68 writel(reg, iomux_base + ofs);
71 if (PAD_VOL_VALID(pad)) {
72 bp = PAD_PIN(pad) % 8 * 4 + 2;
73 mxs_reg = (struct mx28_register_32 *)(iomux_base + ofs);
75 writel(1 << bp, &mxs_reg->reg_set);
77 writel(1 << bp, &mxs_reg->reg_clr);
81 if (PAD_PULL_VALID(pad)) {
83 ofs += PAD_BANK(pad) * 0x10;
85 mxs_reg = (struct mx28_register_32 *)(iomux_base + ofs);
87 writel(1 << bp, &mxs_reg->reg_set);
89 writel(1 << bp, &mxs_reg->reg_clr);
95 int mxs_iomux_setup_multiple_pads(const iomux_cfg_t *pad_list, unsigned count)
97 const iomux_cfg_t *p = pad_list;
101 for (i = 0; i < count; i++) {
102 ret = mxs_iomux_setup_pad(*p);