]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[ARM] mv78xx0: wire i2c support
authorRiku Voipio <riku.voipio@iki.fi>
Tue, 3 Mar 2009 19:13:50 +0000 (21:13 +0200)
committerNicolas Pitre <nico@cam.org>
Wed, 4 Mar 2009 02:06:12 +0000 (21:06 -0500)
All the pieces were ready, just matter of assembling
them together.

Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Nicolas Pitre <nico@marvell.com>
arch/arm/mach-mv78xx0/common.c
arch/arm/mach-mv78xx0/common.h
arch/arm/mach-mv78xx0/db78x00-bp-setup.c
arch/arm/mach-mv78xx0/include/mach/mv78xx0.h

index 15f9913f4a909545aa2597978ed48cee07915b4f..a575daaa62d15694dc2fcab7692878a9d77e1245 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/serial_8250.h>
 #include <linux/mbus.h>
 #include <linux/mv643xx_eth.h>
+#include <linux/mv643xx_i2c.h>
 #include <linux/ata_platform.h>
 #include <linux/ethtool.h>
 #include <asm/mach/map.h>
@@ -518,6 +519,81 @@ void __init mv78xx0_ge11_init(struct mv643xx_eth_platform_data *eth_data)
        platform_device_register(&mv78xx0_ge11);
 }
 
+/*****************************************************************************
+ * I2C bus 0
+ ****************************************************************************/
+
+static struct mv64xxx_i2c_pdata mv78xx0_i2c_0_pdata = {
+       .freq_m         = 8, /* assumes 166 MHz TCLK */
+       .freq_n         = 3,
+       .timeout        = 1000, /* Default timeout of 1 second */
+};
+
+static struct resource mv78xx0_i2c_0_resources[] = {
+       {
+               .name   = "i2c 0 base",
+               .start  = I2C_0_PHYS_BASE,
+               .end    = I2C_0_PHYS_BASE + 0x1f,
+               .flags  = IORESOURCE_MEM,
+       }, {
+               .name   = "i2c 0 irq",
+               .start  = IRQ_MV78XX0_I2C_0,
+               .end    = IRQ_MV78XX0_I2C_0,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+
+static struct platform_device mv78xx0_i2c_0 = {
+       .name           = MV64XXX_I2C_CTLR_NAME,
+       .id             = 0,
+       .num_resources  = ARRAY_SIZE(mv78xx0_i2c_0_resources),
+       .resource       = mv78xx0_i2c_0_resources,
+       .dev            = {
+               .platform_data  = &mv78xx0_i2c_0_pdata,
+       },
+};
+
+/*****************************************************************************
+ * I2C bus 1
+ ****************************************************************************/
+
+static struct mv64xxx_i2c_pdata mv78xx0_i2c_1_pdata = {
+       .freq_m         = 8, /* assumes 166 MHz TCLK */
+       .freq_n         = 3,
+       .timeout        = 1000, /* Default timeout of 1 second */
+};
+
+static struct resource mv78xx0_i2c_1_resources[] = {
+       {
+               .name   = "i2c 1 base",
+               .start  = I2C_1_PHYS_BASE,
+               .end    = I2C_1_PHYS_BASE + 0x1f,
+               .flags  = IORESOURCE_MEM,
+       }, {
+               .name   = "i2c 1 irq",
+               .start  = IRQ_MV78XX0_I2C_1,
+               .end    = IRQ_MV78XX0_I2C_1,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+
+static struct platform_device mv78xx0_i2c_1 = {
+       .name           = MV64XXX_I2C_CTLR_NAME,
+       .id             = 1,
+       .num_resources  = ARRAY_SIZE(mv78xx0_i2c_1_resources),
+       .resource       = mv78xx0_i2c_1_resources,
+       .dev            = {
+               .platform_data  = &mv78xx0_i2c_1_pdata,
+       },
+};
+
+void __init mv78xx0_i2c_init(void)
+{
+       platform_device_register(&mv78xx0_i2c_0);
+       platform_device_register(&mv78xx0_i2c_1);
+}
 
 /*****************************************************************************
  * SATA
index f6274db6192d553e3904df777de7774613b79d7f..befc224754691d93b265addfbc6e5912cd8e6c50 100644 (file)
@@ -44,6 +44,7 @@ void mv78xx0_uart0_init(void);
 void mv78xx0_uart1_init(void);
 void mv78xx0_uart2_init(void);
 void mv78xx0_uart3_init(void);
+void mv78xx0_i2c_init(void);
 
 extern struct sys_timer mv78xx0_timer;
 
index be0a59a6139eaeb4e685a1c2154d6c306e3ae7b9..efdabe04c69ef80bad21f5a5ad3a661741cbae79 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/ata_platform.h>
 #include <linux/mv643xx_eth.h>
 #include <linux/ethtool.h>
+#include <linux/i2c.h>
 #include <mach/mv78xx0.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -39,6 +40,11 @@ static struct mv_sata_platform_data db78x00_sata_data = {
        .n_ports        = 2,
 };
 
+static struct i2c_board_info __initdata db78x00_i2c_rtc = {
+       I2C_BOARD_INFO("ds1338", 0x68),
+};
+
+
 static void __init db78x00_init(void)
 {
        /*
@@ -60,6 +66,8 @@ static void __init db78x00_init(void)
                mv78xx0_sata_init(&db78x00_sata_data);
                mv78xx0_uart0_init();
                mv78xx0_uart2_init();
+               mv78xx0_i2c_init();
+               i2c_register_board_info(0, &db78x00_i2c_rtc, 1);
        } else {
                mv78xx0_uart1_init();
                mv78xx0_uart3_init();
index 328a02e029a025bc468c01353ad4426f6b931411..582cffc733ade63485c16f33d96bff034a869f85 100644 (file)
 #define DEV_BUS_VIRT_BASE      (MV78XX0_REGS_VIRT_BASE | 0x10000)
 #define  SAMPLE_AT_RESET_LOW   (DEV_BUS_VIRT_BASE | 0x0030)
 #define  SAMPLE_AT_RESET_HIGH  (DEV_BUS_VIRT_BASE | 0x0034)
+#define  I2C_0_PHYS_BASE       (DEV_BUS_PHYS_BASE | 0x1000)
+#define  I2C_1_PHYS_BASE       (DEV_BUS_PHYS_BASE | 0x1100)
 #define  UART0_PHYS_BASE       (DEV_BUS_PHYS_BASE | 0x2000)
 #define  UART0_VIRT_BASE       (DEV_BUS_VIRT_BASE | 0x2000)
 #define  UART1_PHYS_BASE       (DEV_BUS_PHYS_BASE | 0x2100)