summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2009-12-03 14:13:41 +0100
committerMarc Kleine-Budde <mkl@pengutronix.de>2009-12-09 02:33:07 +0100
commitc78b85061f38b911b0b434f53c4330c4199d62e1 (patch)
tree3d0c0f4526db3b61f14d329fe99ab4473371400c
parentb2b8904a91d7c4d1d0dae1c993ba77e7944e37f5 (diff)
downloadbarebox-c78b85061f38b911b0b434f53c4330c4199d62e1.tar.gz
barebox-c78b85061f38b911b0b434f53c4330c4199d62e1.tar.xz
i.MX: split out iomux-v1 support
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
-rw-r--r--arch/arm/mach-imx/Makefile6
-rw-r--r--arch/arm/mach-imx/gpio.c60
-rw-r--r--arch/arm/mach-imx/iomux-v1.c87
3 files changed, 90 insertions, 63 deletions
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 8eda61f309..767cd30552 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -1,8 +1,8 @@
obj-y += clocksource.o
-obj-$(CONFIG_ARCH_IMX1) += speed-imx1.o gpio.o
+obj-$(CONFIG_ARCH_IMX1) += speed-imx1.o gpio.o iomux-v1.o
obj-$(CONFIG_ARCH_IMX25) += speed-imx25.o iomux-v3.o
-obj-$(CONFIG_ARCH_IMX21) += speed-imx21.o gpio.o imx21.o
-obj-$(CONFIG_ARCH_IMX27) += speed-imx27.o gpio.o imx27.o
+obj-$(CONFIG_ARCH_IMX21) += speed-imx21.o gpio.o imx21.o iomux-v1.o
+obj-$(CONFIG_ARCH_IMX27) += speed-imx27.o gpio.o imx27.o iomux-v1.o
obj-$(CONFIG_ARCH_IMX31) += speed-imx31.o iomux-v2.o
obj-$(CONFIG_ARCH_IMX35) += speed-imx35.o iomux-v3.o
obj-$(CONFIG_IMX_CLKO) += clko.o
diff --git a/arch/arm/mach-imx/gpio.c b/arch/arm/mach-imx/gpio.c
index 2e1362c965..eb095ec93c 100644
--- a/arch/arm/mach-imx/gpio.c
+++ b/arch/arm/mach-imx/gpio.c
@@ -26,66 +26,6 @@
#include <common.h>
#include <mach/imx-regs.h>
-void imx_gpio_mode(int gpio_mode)
-{
- unsigned int pin = gpio_mode & GPIO_PIN_MASK;
- unsigned int port = (gpio_mode & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT;
- unsigned int ocr = (gpio_mode & GPIO_OCR_MASK) >> GPIO_OCR_SHIFT;
- unsigned int aout = (gpio_mode & GPIO_AOUT_MASK) >> GPIO_AOUT_SHIFT;
- unsigned int bout = (gpio_mode & GPIO_BOUT_MASK) >> GPIO_BOUT_SHIFT;
- unsigned int tmp;
-
- /* Pullup enable */
- if(gpio_mode & GPIO_PUEN)
- PUEN(port) |= (1 << pin);
- else
- PUEN(port) &= ~(1 << pin);
-
- /* Data direction */
- if(gpio_mode & GPIO_OUT)
- DDIR(port) |= 1 << pin;
- else
- DDIR(port) &= ~(1 << pin);
-
- /* Primary / alternate function */
- if(gpio_mode & GPIO_AF)
- GPR(port) |= (1 << pin);
- else
- GPR(port) &= ~(1 << pin);
-
- /* use as gpio? */
- if(!(gpio_mode & (GPIO_PF | GPIO_AF)))
- GIUS(port) |= (1 << pin);
- else
- GIUS(port) &= ~(1 << pin);
-
- /* Output / input configuration */
- if (pin < 16) {
- tmp = OCR1(port);
- tmp &= ~(3 << (pin * 2));
- tmp |= (ocr << (pin * 2));
- OCR1(port) = tmp;
-
- ICONFA1(port) &= ~(3 << (pin * 2));
- ICONFA1(port) |= aout << (pin * 2);
- ICONFB1(port) &= ~(3 << (pin * 2));
- ICONFB1(port) |= bout << (pin * 2);
- } else {
- pin -= 16;
-
- tmp = OCR2(port);
- tmp &= ~(3 << (pin * 2));
- tmp |= (ocr << (pin * 2));
- OCR2(port) = tmp;
-
- ICONFA2(port) &= ~(3 << (pin * 2));
- ICONFA2(port) |= aout << (pin * 2);
- ICONFB2(port) &= ~(3 << (pin * 2));
- ICONFB2(port) |= bout << (pin * 2);
- }
-
-}
-
void gpio_set_value(unsigned gpio, int value)
{
if(value)
diff --git a/arch/arm/mach-imx/iomux-v1.c b/arch/arm/mach-imx/iomux-v1.c
new file mode 100644
index 0000000000..f2dfdb3ffd
--- /dev/null
+++ b/arch/arm/mach-imx/iomux-v1.c
@@ -0,0 +1,87 @@
+#include <common.h>
+#include <mach/imx-regs.h>
+
+/*
+ * GPIO Module and I/O Multiplexer
+ * x = 0..3 for reg_A, reg_B, reg_C, reg_D
+ *
+ * i.MX1 and i.MXL: 0 <= x <= 3
+ * i.MX27 : 0 <= x <= 5
+ */
+#define DDIR(x) __REG2(IMX_GPIO_BASE + 0x00, ((x) & 7) << 8)
+#define OCR1(x) __REG2(IMX_GPIO_BASE + 0x04, ((x) & 7) << 8)
+#define OCR2(x) __REG2(IMX_GPIO_BASE + 0x08, ((x) & 7) << 8)
+#define ICONFA1(x) __REG2(IMX_GPIO_BASE + 0x0c, ((x) & 7) << 8)
+#define ICONFA2(x) __REG2(IMX_GPIO_BASE + 0x10, ((x) & 7) << 8)
+#define ICONFB1(x) __REG2(IMX_GPIO_BASE + 0x14, ((x) & 7) << 8)
+#define ICONFB2(x) __REG2(IMX_GPIO_BASE + 0x18, ((x) & 7) << 8)
+#define DR(x) __REG2(IMX_GPIO_BASE + 0x1c, ((x) & 7) << 8)
+#define GIUS(x) __REG2(IMX_GPIO_BASE + 0x20, ((x) & 7) << 8)
+#define SSR(x) __REG2(IMX_GPIO_BASE + 0x24, ((x) & 7) << 8)
+#define ICR1(x) __REG2(IMX_GPIO_BASE + 0x28, ((x) & 7) << 8)
+#define ICR2(x) __REG2(IMX_GPIO_BASE + 0x2c, ((x) & 7) << 8)
+#define IMR(x) __REG2(IMX_GPIO_BASE + 0x30, ((x) & 7) << 8)
+#define ISR(x) __REG2(IMX_GPIO_BASE + 0x34, ((x) & 7) << 8)
+#define GPR(x) __REG2(IMX_GPIO_BASE + 0x38, ((x) & 7) << 8)
+#define SWR(x) __REG2(IMX_GPIO_BASE + 0x3c, ((x) & 7) << 8)
+#define PUEN(x) __REG2(IMX_GPIO_BASE + 0x40, ((x) & 7) << 8)
+
+void imx_gpio_mode(int gpio_mode)
+{
+ unsigned int pin = gpio_mode & GPIO_PIN_MASK;
+ unsigned int port = (gpio_mode & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT;
+ unsigned int ocr = (gpio_mode & GPIO_OCR_MASK) >> GPIO_OCR_SHIFT;
+ unsigned int aout = (gpio_mode & GPIO_AOUT_MASK) >> GPIO_AOUT_SHIFT;
+ unsigned int bout = (gpio_mode & GPIO_BOUT_MASK) >> GPIO_BOUT_SHIFT;
+ unsigned int tmp;
+
+ /* Pullup enable */
+ if(gpio_mode & GPIO_PUEN)
+ PUEN(port) |= (1 << pin);
+ else
+ PUEN(port) &= ~(1 << pin);
+
+ /* Data direction */
+ if(gpio_mode & GPIO_OUT)
+ DDIR(port) |= 1 << pin;
+ else
+ DDIR(port) &= ~(1 << pin);
+
+ /* Primary / alternate function */
+ if(gpio_mode & GPIO_AF)
+ GPR(port) |= (1 << pin);
+ else
+ GPR(port) &= ~(1 << pin);
+
+ /* use as gpio? */
+ if(!(gpio_mode & (GPIO_PF | GPIO_AF)))
+ GIUS(port) |= (1 << pin);
+ else
+ GIUS(port) &= ~(1 << pin);
+
+ /* Output / input configuration */
+ if (pin < 16) {
+ tmp = OCR1(port);
+ tmp &= ~(3 << (pin * 2));
+ tmp |= (ocr << (pin * 2));
+ OCR1(port) = tmp;
+
+ ICONFA1(port) &= ~(3 << (pin * 2));
+ ICONFA1(port) |= aout << (pin * 2);
+ ICONFB1(port) &= ~(3 << (pin * 2));
+ ICONFB1(port) |= bout << (pin * 2);
+ } else {
+ pin -= 16;
+
+ tmp = OCR2(port);
+ tmp &= ~(3 << (pin * 2));
+ tmp |= (ocr << (pin * 2));
+ OCR2(port) = tmp;
+
+ ICONFA2(port) &= ~(3 << (pin * 2));
+ ICONFA2(port) |= aout << (pin * 2);
+ ICONFB2(port) &= ~(3 << (pin * 2));
+ ICONFB2(port) |= bout << (pin * 2);
+ }
+}
+