24 #include <linux/errno.h>
26 #include <linux/kernel.h>
27 #include <linux/module.h>
28 #include <linux/string.h>
31 #include <mach/hardware.h>
35 static void __iomem *imx_iomuxv1_baseaddr;
36 static unsigned imx_iomuxv1_numports;
38 static inline unsigned long imx_iomuxv1_readl(
unsigned offset)
43 static inline void imx_iomuxv1_writel(
unsigned long val,
unsigned offset)
48 static inline void imx_iomuxv1_rmwl(
unsigned offset,
51 unsigned long reg = imx_iomuxv1_readl(offset);
56 imx_iomuxv1_writel(reg, offset);
59 static inline void imx_iomuxv1_set_puen(
60 unsigned int port,
unsigned int pin,
int on)
64 imx_iomuxv1_rmwl(
MXC_PUEN(port), mask, on ? mask : 0);
67 static inline void imx_iomuxv1_set_ddir(
68 unsigned int port,
unsigned int pin,
int out)
70 unsigned long mask = 1 <<
pin;
72 imx_iomuxv1_rmwl(
MXC_DDIR(port), mask, out ? mask : 0);
75 static inline void imx_iomuxv1_set_gpr(
76 unsigned int port,
unsigned int pin,
int af)
78 unsigned long mask = 1 <<
pin;
80 imx_iomuxv1_rmwl(
MXC_GPR(port), mask, af ? mask : 0);
83 static inline void imx_iomuxv1_set_gius(
84 unsigned int port,
unsigned int pin,
int inuse)
86 unsigned long mask = 1 <<
pin;
88 imx_iomuxv1_rmwl(
MXC_GIUS(port), mask, inuse ? mask : 0);
91 static inline void imx_iomuxv1_set_ocr(
92 unsigned int port,
unsigned int pin,
unsigned int ocr)
94 unsigned long shift = (pin & 0xf) << 1;
95 unsigned long mask = 3 << shift;
96 unsigned long value = ocr << shift;
99 imx_iomuxv1_rmwl(offset, mask, value);
102 static inline void imx_iomuxv1_set_iconfa(
103 unsigned int port,
unsigned int pin,
unsigned int aout)
105 unsigned long shift = (pin & 0xf) << 1;
106 unsigned long mask = 3 << shift;
107 unsigned long value = aout << shift;
110 imx_iomuxv1_rmwl(offset, mask, value);
113 static inline void imx_iomuxv1_set_iconfb(
114 unsigned int port,
unsigned int pin,
unsigned int bout)
116 unsigned long shift = (pin & 0xf) << 1;
117 unsigned long mask = 3 << shift;
118 unsigned long value = bout << shift;
121 imx_iomuxv1_rmwl(offset, mask, value);
132 if (port >= imx_iomuxv1_numports)
136 imx_iomuxv1_set_puen(port, pin, gpio_mode &
GPIO_PUEN);
139 imx_iomuxv1_set_ddir(port, pin, gpio_mode &
GPIO_OUT);
142 imx_iomuxv1_set_gpr(port, pin, gpio_mode &
GPIO_AF);
145 imx_iomuxv1_set_gius(port, pin, !(gpio_mode & (
GPIO_PF | GPIO_AF)));
147 imx_iomuxv1_set_ocr(port, pin, ocr);
149 imx_iomuxv1_set_iconfa(port, pin, aout);
151 imx_iomuxv1_set_iconfb(port, pin, bout);
157 static int imx_iomuxv1_setup_multiple(
const int *
list,
unsigned count)
162 for (i = 0; i <
count; ++
i) {
177 ret = imx_iomuxv1_setup_multiple(pin_list, count);
184 imx_iomuxv1_baseaddr = base;
185 imx_iomuxv1_numports = numports;