[ARM] pxa: add I2C (TWSI) devices to pxa168/pxa910
authorEric Miao <eric.miao@marvell.com>
Mon, 13 Apr 2009 07:34:54 +0000 (15:34 +0800)
committerEric Miao <eric.y.miao@gmail.com>
Fri, 5 Jun 2009 02:32:02 +0000 (10:32 +0800)
Signed-off-by: Paul Shen <paul.shen@marvell.com>
Signed-off-by: Eric Miao <eric.miao@marvell.com>
arch/arm/mach-mmp/include/mach/mfp-pxa168.h
arch/arm/mach-mmp/include/mach/pxa168.h
arch/arm/mach-mmp/include/mach/pxa910.h
arch/arm/mach-mmp/pxa168.c
arch/arm/mach-mmp/pxa910.c

index 2e91464..dc42263 100644 (file)
 #define GPIO58_LCD_PCLK_WR     MFP_CFG(GPIO58, AF1)
 #define GPIO85_LCD_VSYNC       MFP_CFG(GPIO85, AF1)
 
+/* I2C */
+#define GPIO105_CI2C_SDA       MFP_CFG(GPIO105, AF1)
+#define GPIO106_CI2C_SCL       MFP_CFG(GPIO106, AF1)
+
 /* I2S */
 #define GPIO113_I2S_MCLK       MFP_CFG(GPIO113,AF6)
 #define GPIO114_I2S_FRM                MFP_CFG(GPIO114,AF1)
index ef0a8a2..bfdd629 100644 (file)
@@ -1,10 +1,14 @@
 #ifndef __ASM_MACH_PXA168_H
 #define __ASM_MACH_PXA168_H
 
+#include <linux/i2c.h>
 #include <mach/devices.h>
+#include <plat/i2c.h>
 
 extern struct pxa_device_desc pxa168_device_uart1;
 extern struct pxa_device_desc pxa168_device_uart2;
+extern struct pxa_device_desc pxa168_device_twsi0;
+extern struct pxa_device_desc pxa168_device_twsi1;
 
 static inline int pxa168_add_uart(int id)
 {
@@ -20,4 +24,24 @@ static inline int pxa168_add_uart(int id)
 
        return pxa_register_device(d, NULL, 0);
 }
+
+static inline int pxa168_add_twsi(int id, struct i2c_pxa_platform_data *data,
+                                 struct i2c_board_info *info, unsigned size)
+{
+       struct pxa_device_desc *d = NULL;
+       int ret;
+
+       switch (id) {
+       case 0: d = &pxa168_device_twsi0; break;
+       case 1: d = &pxa168_device_twsi1; break;
+       default:
+               return -EINVAL;
+       }
+
+       ret = i2c_register_board_info(id, info, size);
+       if (ret)
+               return ret;
+
+       return pxa_register_device(d, data, sizeof(*data));
+}
 #endif /* __ASM_MACH_PXA168_H */
index b7aeaf5..a0f0cbe 100644 (file)
@@ -1,10 +1,14 @@
 #ifndef __ASM_MACH_PXA910_H
 #define __ASM_MACH_PXA910_H
 
+#include <linux/i2c.h>
 #include <mach/devices.h>
+#include <plat/i2c.h>
 
 extern struct pxa_device_desc pxa910_device_uart1;
 extern struct pxa_device_desc pxa910_device_uart2;
+extern struct pxa_device_desc pxa910_device_twsi0;
+extern struct pxa_device_desc pxa910_device_twsi1;
 
 static inline int pxa910_add_uart(int id)
 {
@@ -20,4 +24,24 @@ static inline int pxa910_add_uart(int id)
 
        return pxa_register_device(d, NULL, 0);
 }
+
+static inline int pxa910_add_twsi(int id, struct i2c_pxa_platform_data *data,
+                                 struct i2c_board_info *info, unsigned size)
+{
+       struct pxa_device_desc *d = NULL;
+       int ret;
+
+       switch (id) {
+       case 0: d = &pxa910_device_twsi0; break;
+       case 1: d = &pxa910_device_twsi1; break;
+       default:
+               return -EINVAL;
+       }
+
+       ret = i2c_register_board_info(id, info, size);
+       if (ret)
+               return ret;
+
+       return pxa_register_device(d, data, sizeof(*data));
+}
 #endif /* __ASM_MACH_PXA910_H */
index ae92446..e0729e3 100644 (file)
@@ -65,11 +65,15 @@ void __init pxa168_init_irq(void)
 /* APB peripheral clocks */
 static APBC_CLK(uart1, PXA168_UART1, 1, 14745600);
 static APBC_CLK(uart2, PXA168_UART2, 1, 14745600);
+static APBC_CLK(twsi0, PXA168_TWSI0, 1, 33000000);
+static APBC_CLK(twsi1, PXA168_TWSI1, 1, 33000000);
 
 /* device and clock bindings */
 static struct clk_lookup pxa168_clkregs[] = {
        INIT_CLKREG(&clk_uart1, "pxa2xx-uart.0", NULL),
        INIT_CLKREG(&clk_uart2, "pxa2xx-uart.1", NULL),
+       INIT_CLKREG(&clk_twsi0, "pxa2xx-i2c.0", NULL),
+       INIT_CLKREG(&clk_twsi1, "pxa2xx-i2c.1", NULL),
 };
 
 static int __init pxa168_init(void)
@@ -109,3 +113,5 @@ struct sys_timer pxa168_timer = {
 /* on-chip devices */
 PXA168_DEVICE(uart1, "pxa2xx-uart", 0, UART1, 0xd4017000, 0x30, 21, 22);
 PXA168_DEVICE(uart2, "pxa2xx-uart", 1, UART2, 0xd4018000, 0x30, 23, 24);
+PXA168_DEVICE(twsi0, "pxa2xx-i2c", 0, TWSI0, 0xd4011000, 0x28);
+PXA168_DEVICE(twsi1, "pxa2xx-i2c", 1, TWSI1, 0xd4025000, 0x28);
index 453f8f7..b97328b 100644 (file)
@@ -103,11 +103,15 @@ void __init pxa910_init_irq(void)
 /* APB peripheral clocks */
 static APBC_CLK(uart1, PXA910_UART0, 1, 14745600);
 static APBC_CLK(uart2, PXA910_UART1, 1, 14745600);
+static APBC_CLK(twsi0, PXA168_TWSI0, 1, 33000000);
+static APBC_CLK(twsi1, PXA168_TWSI1, 1, 33000000);
 
 /* device and clock bindings */
 static struct clk_lookup pxa910_clkregs[] = {
        INIT_CLKREG(&clk_uart1, "pxa2xx-uart.0", NULL),
        INIT_CLKREG(&clk_uart2, "pxa2xx-uart.1", NULL),
+       INIT_CLKREG(&clk_twsi0, "pxa2xx-i2c.0", NULL),
+       INIT_CLKREG(&clk_twsi1, "pxa2xx-i2c.1", NULL),
 };
 
 static int __init pxa910_init(void)
@@ -156,3 +160,5 @@ struct sys_timer pxa910_timer = {
  */
 PXA910_DEVICE(uart1, "pxa2xx-uart", 0, UART2, 0xd4017000, 0x30, 21, 22);
 PXA910_DEVICE(uart2, "pxa2xx-uart", 1, UART3, 0xd4018000, 0x30, 23, 24);
+PXA910_DEVICE(twsi0, "pxa2xx-i2c", 0, TWSI0, 0xd4011000, 0x28);
+PXA910_DEVICE(twsi1, "pxa2xx-i2c", 1, TWSI1, 0xd4025000, 0x28);