[ARM] 3819/1: iop3xx: factor out shared i2c code
authorLennert Buytenhek <buytenh@wantstofly.org>
Mon, 18 Sep 2006 22:15:21 +0000 (23:15 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Mon, 25 Sep 2006 09:25:38 +0000 (10:25 +0100)
Move the i2c bits shared between iop32x and iop33x to plat-iop/i2c.c
and include/asm-arm/hardware/iop3xx.h.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/mach-iop32x/common.c
arch/arm/mach-iop32x/setup.c
arch/arm/mach-iop33x/setup.c
arch/arm/plat-iop/Makefile
arch/arm/plat-iop/i2c.c [new file with mode: 0644]
include/asm-arm/arch-iop32x/iop321.h
include/asm-arm/arch-iop33x/iop331.h
include/asm-arm/hardware/iop3xx.h

index 8044af6a54e14b8cc46caefc0dfd065ffe4b375f..17e7d650fecbb39bab7d6eb18b79fe561d90192a 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <linux/delay.h>
 #include <asm/hardware.h>
+#include <asm/hardware/iop3xx.h>
 
 /*
  * Shared variables
@@ -39,23 +40,23 @@ void ep80219_power_off(void)
      */
 
        /* Send the Address byte w/ the start condition */
-       *IOP321_IDBR1 = 0x60;
-       *IOP321_ICR1 = 0xE9;
+       *IOP3XX_IDBR1 = 0x60;
+       *IOP3XX_ICR1 = 0xE9;
     mdelay(1);
 
        /* Send the START_MSG byte w/ no start or stop condition */
-       *IOP321_IDBR1 = 0x0F;
-       *IOP321_ICR1 = 0xE8;
+       *IOP3XX_IDBR1 = 0x0F;
+       *IOP3XX_ICR1 = 0xE8;
     mdelay(1);
 
        /* Send the SHUTDOWN_COMPLETE Message ID byte w/ no start or stop condition */
-       *IOP321_IDBR1 = 0x03;
-       *IOP321_ICR1 = 0xE8;
+       *IOP3XX_IDBR1 = 0x03;
+       *IOP3XX_ICR1 = 0xE8;
     mdelay(1);
 
        /* Send an ignored byte w/ stop condition */
-       *IOP321_IDBR1 = 0x00;
-       *IOP321_ICR1 = 0xEA;
+       *IOP3XX_IDBR1 = 0x00;
+       *IOP3XX_ICR1 = 0xEA;
 
        while (1) ;
 }
index 48d806474f40714b9e7f508b7b24c2dbcb632938..1a03b0b41baa05b097e68502b0602183bf256b47 100644 (file)
@@ -29,6 +29,7 @@
 #include <asm/hardware.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
+#include <asm/hardware/iop3xx.h>
 
 #define IOP321_UART_XTAL 1843200
 
@@ -57,58 +58,10 @@ static struct uart_port iop321_serial_ports[] = {
        }
 };
 
-static struct resource iop32x_i2c_0_resources[] = {
-       [0] = {
-               .start = 0xfffff680,
-               .end = 0xfffff698,
-               .flags = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start = IRQ_IOP321_I2C_0,
-               .end = IRQ_IOP321_I2C_0,
-               .flags = IORESOURCE_IRQ
-       }
-};
-
-static struct resource iop32x_i2c_1_resources[] = {
-       [0] = {
-               .start = 0xfffff6a0,
-               .end = 0xfffff6b8,
-               .flags = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start = IRQ_IOP321_I2C_1,
-               .end = IRQ_IOP321_I2C_1,
-               .flags = IORESOURCE_IRQ
-       }
-};
-
-static struct platform_device iop32x_i2c_0_controller = {
-       .name = "IOP3xx-I2C",
-       .id = 0,
-       .num_resources = 2,
-       .resource = iop32x_i2c_0_resources
-};
-
-static struct platform_device iop32x_i2c_1_controller = {
-       .name = "IOP3xx-I2C",
-       .id = 1,
-       .num_resources = 2,
-       .resource = iop32x_i2c_1_resources
-};
-
-static struct platform_device *iop32x_devices[] __initdata = {
-       &iop32x_i2c_0_controller,
-       &iop32x_i2c_1_controller
-};
-
 void __init iop32x_init(void)
 {
-       if(iop_is_321())
-       {
-               platform_add_devices(iop32x_devices,
-                               ARRAY_SIZE(iop32x_devices));
-       }
+       platform_device_register(&iop3xx_i2c0_device);
+       platform_device_register(&iop3xx_i2c1_device);
        early_serial_setup(&iop321_serial_ports[0]);
 }
 
index 67cb21cb0ad9d3ae0cdadd712218d61b2e2ef0f3..ad737d6582b529be80a98275777ce2b5df96b38a 100644 (file)
@@ -100,51 +100,9 @@ static struct platform_device iop33x_uart1 = {
        .resource = iop33x_uart1_resources,
 };
 
-static struct resource iop33x_i2c_0_resources[] = {
-       [0] = {
-               .start = 0xfffff680,
-               .end = 0xfffff698,
-               .flags = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start = IRQ_IOP331_I2C_0,
-               .end = IRQ_IOP331_I2C_0,
-               .flags = IORESOURCE_IRQ
-       }
-};
-
-static struct resource iop33x_i2c_1_resources[] = {
-       [0] = {
-               .start = 0xfffff6a0,
-               .end = 0xfffff6b8,
-               .flags = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start = IRQ_IOP331_I2C_1,
-               .end = IRQ_IOP331_I2C_1,
-               .flags = IORESOURCE_IRQ
-       }
-};
-
-static struct platform_device iop33x_i2c_0_controller = {
-       .name = "IOP3xx-I2C",
-       .id = 0,
-       .num_resources = 2,
-       .resource = iop33x_i2c_0_resources
-};
-
-static struct platform_device iop33x_i2c_1_controller = {
-       .name = "IOP3xx-I2C",
-       .id = 1,
-       .num_resources = 2,
-       .resource = iop33x_i2c_1_resources
-};
-
 static struct platform_device *iop33x_devices[] __initdata = {
        &iop33x_uart0,
        &iop33x_uart1,
-       &iop33x_i2c_0_controller,
-       &iop33x_i2c_1_controller
 };
 
 void __init iop33x_init(void)
@@ -154,6 +112,8 @@ void __init iop33x_init(void)
                platform_add_devices(iop33x_devices,
                                ARRAY_SIZE(iop33x_devices));
        }
+       platform_device_register(&iop3xx_i2c0_device);
+       platform_device_register(&iop3xx_i2c1_device);
 }
 
 #ifdef CONFIG_ARCH_IOP33X
index b299103537c579c6f3ac71edb26a8bc77335587b..be6ab7c71ca31bcf7a5f43f236cd1eb4c6237a1f 100644 (file)
@@ -2,7 +2,7 @@
 # Makefile for the linux kernel.
 #
 
-obj-y                  := setup.o
+obj-y                  := i2c.o setup.o
 obj-m                  :=
 obj-n                  :=
 obj-                   :=
diff --git a/arch/arm/plat-iop/i2c.c b/arch/arm/plat-iop/i2c.c
new file mode 100644 (file)
index 0000000..7ae149c
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * arch/arm/plat-iop/i2c.c
+ *
+ * Author: Nicolas Pitre <nico@cam.org>
+ * Copyright (C) 2001 MontaVista Software, Inc.
+ * Copyright (C) 2004 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/mm.h>
+#include <linux/init.h>
+#include <linux/major.h>
+#include <linux/fs.h>
+#include <linux/platform_device.h>
+#include <linux/serial.h>
+#include <linux/tty.h>
+#include <linux/serial_core.h>
+#include <asm/io.h>
+#include <asm/pgtable.h>
+#include <asm/page.h>
+#include <asm/mach/map.h>
+#include <asm/setup.h>
+#include <asm/system.h>
+#include <asm/memory.h>
+#include <asm/hardware.h>
+#include <asm/hardware/iop3xx.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+
+#ifdef CONFIG_ARCH_IOP32X
+#define IRQ_IOP3XX_I2C_0       IRQ_IOP321_I2C_0
+#define IRQ_IOP3XX_I2C_1       IRQ_IOP321_I2C_1
+#endif
+#ifdef CONFIG_ARCH_IOP33X
+#define IRQ_IOP3XX_I2C_0       IRQ_IOP331_I2C_0
+#define IRQ_IOP3XX_I2C_1       IRQ_IOP331_I2C_1
+#endif
+
+static struct resource iop3xx_i2c0_resources[] = {
+       [0] = {
+               .start  = 0xfffff680,
+               .end    = 0xfffff697,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = IRQ_IOP3XX_I2C_0,
+               .end    = IRQ_IOP3XX_I2C_0,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+struct platform_device iop3xx_i2c0_device = {
+       .name           = "IOP3xx-I2C",
+       .id             = 0,
+       .num_resources  = 2,
+       .resource       = iop3xx_i2c0_resources,
+};
+
+
+static struct resource iop3xx_i2c1_resources[] = {
+       [0] = {
+               .start  = 0xfffff6a0,
+               .end    = 0xfffff6b7,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = IRQ_IOP3XX_I2C_1,
+               .end    = IRQ_IOP3XX_I2C_1,
+               .flags  = IORESOURCE_IRQ,
+       }
+};
+
+struct platform_device iop3xx_i2c1_device = {
+       .name           = "IOP3xx-I2C",
+       .id             = 1,
+       .num_resources  = 2,
+       .resource       = iop3xx_i2c1_resources,
+};
index 307272b078098faa723c3fd6370ea3ce838723c0..1a82dd96bf50571d5991881a7447d2740f321cd1 100644 (file)
 
 /* SSP serial port unit 0x00001600 - 0x0000167F */
 /* I2C bus interface unit 0x00001680 - 0x000016FF */
-#define IOP321_ICR0       (volatile u32 *)IOP321_REG_ADDR(0x00001680)
-#define IOP321_ISR0       (volatile u32 *)IOP321_REG_ADDR(0x00001684)
-#define IOP321_ISAR0      (volatile u32 *)IOP321_REG_ADDR(0x00001688)
-#define IOP321_IDBR0      (volatile u32 *)IOP321_REG_ADDR(0x0000168C)
-/* Reserved 0x00001690 */
-#define IOP321_IBMR0      (volatile u32 *)IOP321_REG_ADDR(0x00001694)
-/* Reserved 0x00001698 */
-/* Reserved 0x0000169C */
-#define IOP321_ICR1       (volatile u32 *)IOP321_REG_ADDR(0x000016A0)
-#define IOP321_ISR1       (volatile u32 *)IOP321_REG_ADDR(0x000016A4)
-#define IOP321_ISAR1      (volatile u32 *)IOP321_REG_ADDR(0x000016A8)
-#define IOP321_IDBR1      (volatile u32 *)IOP321_REG_ADDR(0x000016AC)
-#define IOP321_IBMR1      (volatile u32 *)IOP321_REG_ADDR(0x000016B4)
-/* Reserved 0x000016B8 through 0x000016FC */
 
 /* for I2C bit defs see drivers/i2c/i2c-iop3xx.h */
 
index 21430f877ea755c678e78fd4c49aea9594614a4f..a7f47122c5e187e23ae10a18998596baff90ec92 100644 (file)
 /* SSP serial port unit 0x00001600 - 0x0000167F */
 
 /* I2C bus interface unit 0x00001680 - 0x000016FF */
-/* for I2C bit defs see drivers/i2c/i2c-iop3xx.h */
-
-#define IOP331_ICR0       (volatile u32 *)IOP331_REG_ADDR(0x00001680)
-#define IOP331_ISR0       (volatile u32 *)IOP331_REG_ADDR(0x00001684)
-#define IOP331_ISAR0      (volatile u32 *)IOP331_REG_ADDR(0x00001688)
-#define IOP331_IDBR0      (volatile u32 *)IOP331_REG_ADDR(0x0000168C)
-/* Reserved 0x00001690 */
-#define IOP331_IBMR0      (volatile u32 *)IOP331_REG_ADDR(0x00001694)
-/* Reserved 0x00001698 */
-/* Reserved 0x0000169C */
-#define IOP331_ICR1       (volatile u32 *)IOP331_REG_ADDR(0x000016A0)
-#define IOP331_ISR1       (volatile u32 *)IOP331_REG_ADDR(0x000016A4)
-#define IOP331_ISAR1      (volatile u32 *)IOP331_REG_ADDR(0x000016A8)
-#define IOP331_IDBR1      (volatile u32 *)IOP331_REG_ADDR(0x000016AC)
-#define IOP331_IBMR1      (volatile u32 *)IOP331_REG_ADDR(0x000016B4)
-/* Reserved 0x000016B8 through 0x000016FF */
 
 /* 0x00001700 through 0x0000172C  UART 0 */
 
index c17cc19cdfabe798494962f494fdd20fe43b425c..ea7d05970001587d4466f697944f24f3a0c45fa4 100644 (file)
 #define IOP3XX_PERIPHERAL_SIZE         0x00002000
 #define IOP3XX_REG_ADDR(reg)           (IOP3XX_PERIPHERAL_VIRT_BASE + (reg))
 
+/* I2C bus interface unit  */
+#define IOP3XX_ICR0            (volatile u32 *)IOP3XX_REG_ADDR(0x1680)
+#define IOP3XX_ISR0            (volatile u32 *)IOP3XX_REG_ADDR(0x1684)
+#define IOP3XX_ISAR0           (volatile u32 *)IOP3XX_REG_ADDR(0x1688)
+#define IOP3XX_IDBR0           (volatile u32 *)IOP3XX_REG_ADDR(0x168c)
+#define IOP3XX_IBMR0           (volatile u32 *)IOP3XX_REG_ADDR(0x1694)
+#define IOP3XX_ICR1            (volatile u32 *)IOP3XX_REG_ADDR(0x16a0)
+#define IOP3XX_ISR1            (volatile u32 *)IOP3XX_REG_ADDR(0x16a4)
+#define IOP3XX_ISAR1           (volatile u32 *)IOP3XX_REG_ADDR(0x16a8)
+#define IOP3XX_IDBR1           (volatile u32 *)IOP3XX_REG_ADDR(0x16ac)
+#define IOP3XX_IBMR1           (volatile u32 *)IOP3XX_REG_ADDR(0x16b4)
+
 
 /*
  * IOP3XX I/O and Mem space regions for PCI autoconfiguration
@@ -37,6 +49,9 @@
 
 #ifndef __ASSEMBLY__
 void iop3xx_map_io(void);
+
+extern struct platform_device iop3xx_i2c0_device;
+extern struct platform_device iop3xx_i2c1_device;
 #endif