Patchwork [6/9] Add the Versatile I2C device to versatilepb.c

login
register
mail settings
Submitter Benoit Canet
Date Aug. 14, 2009, 8:23 p.m.
Message ID <1250281397-7660-7-git-send-email-benoit.canet@gmail.com>
Download mbox | patch
Permalink /patch/31438/
State Superseded
Headers show

Comments

Benoit Canet - Aug. 14, 2009, 8:23 p.m.
Signed-off-by: Benoit Canet <benoit.canet@gmail.com>
---
 hw/versatilepb.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

Patch

diff --git a/hw/versatilepb.c b/hw/versatilepb.c
index 3371121..afc473d 100644
--- a/hw/versatilepb.c
+++ b/hw/versatilepb.c
@@ -9,6 +9,7 @@ 
 
 #include "sysbus.h"
 #include "arm-misc.h"
+#include "i2c.h"
 #include "primecell.h"
 #include "devices.h"
 #include "net.h"
@@ -170,6 +171,9 @@  static void versatile_init(ram_addr_t ram_size,
     NICInfo *nd;
     int n;
     int done_smc = 0;
+    DeviceState *bitbang_i2c_dev;
+    DeviceState *i2c_dev;
+    i2c_bus *i2c;
 
     if (!cpu_model)
         cpu_model = "arm926";
@@ -224,6 +228,15 @@  static void versatile_init(ram_addr_t ram_size,
         n--;
     }
 
+    bitbang_i2c_dev = sysbus_create_varargs("bitbang_i2c", 0, NULL);
+    i2c = (i2c_bus *)qdev_get_child_bus(bitbang_i2c_dev, "i2c");
+
+    i2c_dev = sysbus_create_varargs("versatile,i2c", 0x10002000, NULL);
+
+    qdev_connect_gpio_out(bitbang_i2c_dev, 0, qdev_get_gpio_in(i2c_dev, 0));
+    qdev_connect_gpio_out(i2c_dev, 0, qdev_get_gpio_in(bitbang_i2c_dev, 0));
+    qdev_connect_gpio_out(i2c_dev, 1, qdev_get_gpio_in(bitbang_i2c_dev, 1));
+
     sysbus_create_simple("pl011", 0x101f1000, pic[12]);
     sysbus_create_simple("pl011", 0x101f2000, pic[13]);
     sysbus_create_simple("pl011", 0x101f3000, pic[14]);
@@ -243,6 +256,9 @@  static void versatile_init(ram_addr_t ram_size,
     /* Add PL031 Real Time Clock. */
     sysbus_create_simple("pl031", 0x101e8000, pic[10]);
 
+    dev = sysbus_create_simple("bitbang_i2c", 0, NULL);
+    i2c = (i2c_bus *)qdev_get_child_bus(i2c_dev, "i2c");
+
     /* Memory map for Versatile/PB:  */
     /* 0x10000000 System registers.  */
     /* 0x10001000 PCI controller config registers.  */