[ARM] Kirkwood: Hook up I2C
authorMartin Michlmayr <tbm@cyrius.com>
Mon, 23 Mar 2009 18:13:21 +0000 (19:13 +0100)
committerNicolas Pitre <nico@cam.org>
Mon, 23 Mar 2009 18:42:00 +0000 (14:42 -0400)
Hook up I2C on Marvell Kirkwood.  Tested on a QNAP TS-219 which has
RTC connected through I2C.

Signed-off-by: Martin Michlmayr <tbm@cyrius.com>
Signed-off-by: Nicolas Pitre <nico@marvell.com>
arch/arm/mach-kirkwood/common.c
arch/arm/mach-kirkwood/common.h
arch/arm/mach-kirkwood/include/mach/kirkwood.h

index 9f012551794de7a58cfd593ebd7ae11fe4e7d49a..19b03f62c3f40e4d5047ad7278036d8e67c0a2db 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/spi/orion_spi.h>
 #include <net/dsa.h>
@@ -370,6 +371,45 @@ void __init kirkwood_spi_init()
 }
 
 
+/*****************************************************************************
+ * I2C
+ ****************************************************************************/
+static struct mv64xxx_i2c_pdata kirkwood_i2c_pdata = {
+       .freq_m         = 8, /* assumes 166 MHz TCLK */
+       .freq_n         = 3,
+       .timeout        = 1000, /* Default timeout of 1 second */
+};
+
+static struct resource kirkwood_i2c_resources[] = {
+       {
+               .name   = "i2c",
+               .start  = I2C_PHYS_BASE,
+               .end    = I2C_PHYS_BASE + 0x1f,
+               .flags  = IORESOURCE_MEM,
+       }, {
+               .name   = "i2c",
+               .start  = IRQ_KIRKWOOD_TWSI,
+               .end    = IRQ_KIRKWOOD_TWSI,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device kirkwood_i2c = {
+       .name           = MV64XXX_I2C_CTLR_NAME,
+       .id             = 0,
+       .num_resources  = ARRAY_SIZE(kirkwood_i2c_resources),
+       .resource       = kirkwood_i2c_resources,
+       .dev            = {
+               .platform_data  = &kirkwood_i2c_pdata,
+       },
+};
+
+void __init kirkwood_i2c_init(void)
+{
+       platform_device_register(&kirkwood_i2c);
+}
+
+
 /*****************************************************************************
  * UART0
  ****************************************************************************/
index 9e5282684d58d3270c532082d20fc1fb6b8e0f71..c66a25066ceaafeabc223a1c4a552d202c6ef047 100644 (file)
@@ -37,6 +37,7 @@ void kirkwood_pcie_init(void);
 void kirkwood_sata_init(struct mv_sata_platform_data *sata_data);
 void kirkwood_sdio_init(struct mvsdio_platform_data *mvsdio_data);
 void kirkwood_spi_init(void);
+void kirkwood_i2c_init(void);
 void kirkwood_uart0_init(void);
 void kirkwood_uart1_init(void);
 
index d3db30fe763b937e61b57e01cf32860cd3a34ebf..38c9868535902c3f984621a80a123392b9127048 100644 (file)
@@ -93,6 +93,7 @@
 #define  DEVICE_ID             (DEV_BUS_VIRT_BASE | 0x0034)
 #define  RTC_PHYS_BASE         (DEV_BUS_PHYS_BASE | 0x0300)
 #define  SPI_PHYS_BASE         (DEV_BUS_PHYS_BASE | 0x0600)
+#define  I2C_PHYS_BASE         (DEV_BUS_PHYS_BASE | 0x1000)
 #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)