aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennert Buytenhek <buytenh@wantstofly.org>2006-09-18 18:23:07 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2006-09-25 05:25:47 -0400
commit72edd84a6b2db1a21d1ed07929cae560e276a0a6 (patch)
treeb67000e2bbf7447968c784cc3696a680ad66c47e
parent610300e8f4f833904096ca1233ffd9dbd73fb11f (diff)
[ARM] 3827/1: iop3xx: add common gpio module
Implement the gpio_line_{config,get,set} API for iop3xx. Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/plat-iop/Makefile2
-rw-r--r--arch/arm/plat-iop/gpio.c48
-rw-r--r--drivers/i2c/busses/i2c-iop3xx.c16
-rw-r--r--include/asm-arm/arch-iop32x/iop321.h1
-rw-r--r--include/asm-arm/arch-iop33x/iop331.h1
-rw-r--r--include/asm-arm/hardware/iop3xx.h21
6 files changed, 81 insertions, 8 deletions
diff --git a/arch/arm/plat-iop/Makefile b/arch/arm/plat-iop/Makefile
index d20cdec3a944..23da00b11517 100644
--- a/arch/arm/plat-iop/Makefile
+++ b/arch/arm/plat-iop/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the linux kernel. 2# Makefile for the linux kernel.
3# 3#
4 4
5obj-y := i2c.o pci.o setup.o time.o 5obj-y := gpio.o i2c.o pci.o setup.o time.o
6obj-m := 6obj-m :=
7obj-n := 7obj-n :=
8obj- := 8obj- :=
diff --git a/arch/arm/plat-iop/gpio.c b/arch/arm/plat-iop/gpio.c
new file mode 100644
index 000000000000..eda436083417
--- /dev/null
+++ b/arch/arm/plat-iop/gpio.c
@@ -0,0 +1,48 @@
1/*
2 * arch/arm/plat-iop/gpio.c
3 * GPIO handling for Intel IOP3xx processors.
4 *
5 * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or (at
10 * your option) any later version.
11 */
12
13#include <linux/device.h>
14#include <asm/hardware/iop3xx.h>
15
16void gpio_line_config(int line, int direction)
17{
18 unsigned long flags;
19
20 local_irq_save(flags);
21 if (direction == GPIO_IN) {
22 *IOP3XX_GPOE |= 1 << line;
23 } else if (direction == GPIO_OUT) {
24 *IOP3XX_GPOE &= ~(1 << line);
25 }
26 local_irq_restore(flags);
27}
28EXPORT_SYMBOL(gpio_line_config);
29
30int gpio_line_get(int line)
31{
32 return !!(*IOP3XX_GPID & (1 << line));
33}
34EXPORT_SYMBOL(gpio_line_get);
35
36void gpio_line_set(int line, int value)
37{
38 unsigned long flags;
39
40 local_irq_save(flags);
41 if (value == GPIO_LOW) {
42 *IOP3XX_GPOD &= ~(1 << line);
43 } else if (value == GPIO_HIGH) {
44 *IOP3XX_GPOD |= 1 << line;
45 }
46 local_irq_restore(flags);
47}
48EXPORT_SYMBOL(gpio_line_set);
diff --git a/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c
index 035417f5a003..a2d0cc3a7785 100644
--- a/drivers/i2c/busses/i2c-iop3xx.c
+++ b/drivers/i2c/busses/i2c-iop3xx.c
@@ -82,14 +82,16 @@ iop3xx_i2c_enable(struct i2c_algo_iop3xx_data *iop3xx_adap)
82 82
83 /* 83 /*
84 * Every time unit enable is asserted, GPOD needs to be cleared 84 * Every time unit enable is asserted, GPOD needs to be cleared
85 * on IOP32X to avoid data corruption on the bus. 85 * on IOP3XX to avoid data corruption on the bus.
86 */ 86 */
87#ifdef CONFIG_ARCH_IOP32X 87#ifdef CONFIG_PLAT_IOP
88#define IOP321_GPOD_I2C0 0x00c0 /* clear these bits to enable ch0 */ 88 if (iop3xx_adap->id == 0) {
89#define IOP321_GPOD_I2C1 0x0030 /* clear these bits to enable ch1 */ 89 gpio_line_set(IOP3XX_GPIO_LINE(7), GPIO_LOW);
90 90 gpio_line_set(IOP3XX_GPIO_LINE(6), GPIO_LOW);
91 *IOP321_GPOD &= (iop3xx_adap->id == 0) ? ~IOP321_GPOD_I2C0 : 91 } else {
92 ~IOP321_GPOD_I2C1; 92 gpio_line_set(IOP3XX_GPIO_LINE(5), GPIO_LOW);
93 gpio_line_set(IOP3XX_GPIO_LINE(4), GPIO_LOW);
94 }
93#endif 95#endif
94 /* NB SR bits not same position as CR IE bits :-( */ 96 /* NB SR bits not same position as CR IE bits :-( */
95 iop3xx_adap->SR_enabled = 97 iop3xx_adap->SR_enabled =
diff --git a/include/asm-arm/arch-iop32x/iop321.h b/include/asm-arm/arch-iop32x/iop321.h
index 34fe07f0a44e..1e57e0094767 100644
--- a/include/asm-arm/arch-iop32x/iop321.h
+++ b/include/asm-arm/arch-iop32x/iop321.h
@@ -216,6 +216,7 @@
216 * Peripherals that are shared between the iop32x and iop33x but 216 * Peripherals that are shared between the iop32x and iop33x but
217 * located at different addresses. 217 * located at different addresses.
218 */ 218 */
219#define IOP3XX_GPIO_REG(reg) (IOP3XX_PERIPHERAL_VIRT_BASE + 0x07c0 + (reg))
219#define IOP3XX_TIMER_REG(reg) (IOP3XX_PERIPHERAL_VIRT_BASE + 0x07e0 + (reg)) 220#define IOP3XX_TIMER_REG(reg) (IOP3XX_PERIPHERAL_VIRT_BASE + 0x07e0 + (reg))
220 221
221#include <asm/hardware/iop3xx.h> 222#include <asm/hardware/iop3xx.h>
diff --git a/include/asm-arm/arch-iop33x/iop331.h b/include/asm-arm/arch-iop33x/iop331.h
index 4ebcd7197c86..d12a95aa967a 100644
--- a/include/asm-arm/arch-iop33x/iop331.h
+++ b/include/asm-arm/arch-iop33x/iop331.h
@@ -221,6 +221,7 @@
221 * Peripherals that are shared between the iop32x and iop33x but 221 * Peripherals that are shared between the iop32x and iop33x but
222 * located at different addresses. 222 * located at different addresses.
223 */ 223 */
224#define IOP3XX_GPIO_REG(reg) (IOP3XX_PERIPHERAL_VIRT_BASE + 0x1780 + (reg))
224#define IOP3XX_TIMER_REG(reg) (IOP3XX_PERIPHERAL_VIRT_BASE + 0x07d0 + (reg)) 225#define IOP3XX_TIMER_REG(reg) (IOP3XX_PERIPHERAL_VIRT_BASE + 0x07d0 + (reg))
225 226
226#include <asm/hardware/iop3xx.h> 227#include <asm/hardware/iop3xx.h>
diff --git a/include/asm-arm/hardware/iop3xx.h b/include/asm-arm/hardware/iop3xx.h
index 98b7cbc405e6..f3c61d041fca 100644
--- a/include/asm-arm/hardware/iop3xx.h
+++ b/include/asm-arm/hardware/iop3xx.h
@@ -16,6 +16,22 @@
16#define __IOP3XX_H 16#define __IOP3XX_H
17 17
18/* 18/*
19 * IOP3XX GPIO handling
20 */
21#define GPIO_IN 0
22#define GPIO_OUT 1
23#define GPIO_LOW 0
24#define GPIO_HIGH 1
25#define IOP3XX_GPIO_LINE(x) (x)
26
27#ifndef __ASSEMBLY__
28extern void gpio_line_config(int line, int direction);
29extern int gpio_line_get(int line);
30extern void gpio_line_set(int line, int value);
31#endif
32
33
34/*
19 * IOP3XX processor registers 35 * IOP3XX processor registers
20 */ 36 */
21#define IOP3XX_PERIPHERAL_PHYS_BASE 0xffffe000 37#define IOP3XX_PERIPHERAL_PHYS_BASE 0xffffe000
@@ -81,6 +97,11 @@
81#define IOP3XX_PCIXSR (volatile u32 *)IOP3XX_REG_ADDR(0x01e4) 97#define IOP3XX_PCIXSR (volatile u32 *)IOP3XX_REG_ADDR(0x01e4)
82#define IOP3XX_PCIIRSR (volatile u32 *)IOP3XX_REG_ADDR(0x01ec) 98#define IOP3XX_PCIIRSR (volatile u32 *)IOP3XX_REG_ADDR(0x01ec)
83 99
100/* General Purpose I/O */
101#define IOP3XX_GPOE (volatile u32 *)IOP3XX_GPIO_REG(0x0004)
102#define IOP3XX_GPID (volatile u32 *)IOP3XX_GPIO_REG(0x0008)
103#define IOP3XX_GPOD (volatile u32 *)IOP3XX_GPIO_REG(0x000c)
104
84/* Timers */ 105/* Timers */
85#define IOP3XX_TU_TMR0 (volatile u32 *)IOP3XX_TIMER_REG(0x0000) 106#define IOP3XX_TU_TMR0 (volatile u32 *)IOP3XX_TIMER_REG(0x0000)
86#define IOP3XX_TU_TMR1 (volatile u32 *)IOP3XX_TIMER_REG(0x0004) 107#define IOP3XX_TU_TMR1 (volatile u32 *)IOP3XX_TIMER_REG(0x0004)