Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- drivers/adb_bus.c | 60 +++++++++++++++++++++++++++++---------------- drivers/adb_kbd.c | 28 ++++++++++++++------- drivers/adb_mouse.c | 34 +++++++++++++++++-------- 3 files changed, 82 insertions(+), 40 deletions(-)
diff --git a/drivers/adb_bus.c b/drivers/adb_bus.c index 88a3a2d..c505322 100644 --- a/drivers/adb_bus.c +++ b/drivers/adb_bus.c @@ -28,25 +28,7 @@ #include "adb_kbd.h" #include "adb_mouse.h"
-DECLARE_UNNAMED_NODE( adb, INSTALL_OPEN, sizeof(int)); - -static void -adb_initialize (int *idx) -{ - phandle_t ph=get_cur_dev(); - - push_str("adb"); - fword("device-type"); - - if (has_pmu()) { - set_property(ph, "compatible", "pmu-99", 7); - } else { - set_property(ph, "compatible", "adb", 4); - } - - set_int_property(ph, "#address-cells", 1); - set_int_property(ph, "#size-cells", 0); -} +DECLARE_UNNAMED_NODE( adb, 0, sizeof(int));
static void adb_open(int *idx) @@ -60,7 +42,6 @@ adb_close(int *idx) }
NODE_METHODS( adb ) = { - { NULL, adb_initialize }, { "open", adb_open }, { "close", adb_close }, }; @@ -95,8 +76,43 @@ int adb_bus_init (char *path, adb_bus_t *bus) int reloc = 0, next_free = 7; int keep;
+ push_str(path); + fword("find-device"); + + fword("new-device"); + + push_str("adb"); + fword("device-name"); + + push_str("adb"); + fword("device-type"); + + if (has_pmu()) { + push_str("pmu-99"); + fword("encode-string"); + push_str("compatible"); + fword("property"); + } else { + push_str("adb"); + fword("encode-string"); + push_str("compatible"); + fword("property"); + } + + PUSH(1); + fword("encode-int"); + push_str("#address-cells"); + fword("property"); + + PUSH(0); + fword("encode-int"); + push_str("#size-cells"); + fword("property"); + + BIND_NODE_METHODS(get_cur_dev(), adb); + snprintf(buf, sizeof(buf), "%s/adb", path); - REGISTER_NAMED_NODE( adb, buf); + /* Reset the bus */ // ADB_DPRINTF("\n"); adb_reset(bus); @@ -195,6 +211,8 @@ int adb_bus_init (char *path, adb_bus_t *bus) } }
+ fword("finish-device"); + return 0; }
diff --git a/drivers/adb_kbd.c b/drivers/adb_kbd.c index be6099a..df53fe0 100644 --- a/drivers/adb_kbd.c +++ b/drivers/adb_kbd.c @@ -28,7 +28,7 @@ #include "adb_bus.h" #include "adb_kbd.h"
-DECLARE_UNNAMED_NODE( keyboard, INSTALL_OPEN, sizeof(int)); +DECLARE_UNNAMED_NODE( keyboard, 0, sizeof(int));
static void keyboard_open(int *idx) @@ -523,8 +523,7 @@ static int adb_kbd_read (void *private) void *adb_kbd_new (char *path, void *private) { char buf[64]; - int props[1]; - phandle_t ph, aliases; + phandle_t aliases; adb_kbd_t *kbd; adb_dev_t *dev = private; kbd = (adb_kbd_t*)malloc(sizeof(adb_kbd_t)); @@ -553,16 +552,27 @@ void *adb_kbd_new (char *path, void *private) my_adb_dev = dev; }
- snprintf(buf, sizeof(buf), "%s/keyboard", path); - REGISTER_NAMED_NODE( keyboard, buf); + push_str(path); + fword("find-device");
- ph = find_dev(buf); + fword("new-device");
- set_property(ph, "device_type", "keyboard", 9); - props[0] = __cpu_to_be32(dev->addr); - set_property(ph, "reg", (char *)&props, sizeof(props)); + push_str("keyboard"); + fword("device-name"); + + push_str("keyboard"); + fword("device-type"); + + PUSH(dev->addr); + fword("encode-int"); + push_str("reg"); + fword("property"); + + BIND_NODE_METHODS(get_cur_dev(), keyboard); + fword("finish-device");
aliases = find_dev("/aliases"); + snprintf(buf, sizeof(buf), "%s/keyboard", path); set_property(aliases, "adb-keyboard", buf, strlen(buf) + 1);
return kbd; diff --git a/drivers/adb_mouse.c b/drivers/adb_mouse.c index b94a344..6ee512f 100644 --- a/drivers/adb_mouse.c +++ b/drivers/adb_mouse.c @@ -27,7 +27,7 @@ #include "adb_bus.h" #include "adb_mouse.h"
-DECLARE_UNNAMED_NODE( mouse, INSTALL_OPEN, sizeof(int)); +DECLARE_UNNAMED_NODE( mouse, 0, sizeof(int));
static void mouse_open(int *idx) @@ -48,20 +48,34 @@ NODE_METHODS( mouse ) = { void adb_mouse_new (char *path, void *private) { char buf[64]; - int props[1]; - phandle_t ph, aliases; + phandle_t aliases; adb_dev_t *dev = private;
- snprintf(buf, sizeof(buf), "%s/mouse", path); - REGISTER_NAMED_NODE( mouse, buf); + push_str(path); + fword("find-device");
- ph = find_dev(buf); + fword("new-device");
- set_property(ph, "device_type", "mouse", 6); - props[0] = __cpu_to_be32(dev->addr); - set_property(ph, "reg", (char *)&props, sizeof(props)); - set_int_property(ph, "#buttons", 3); + push_str("mouse"); + fword("device-name"); + + push_str("mouse"); + fword("device-type"); + + PUSH(dev->addr); + fword("encode-int"); + push_str("reg"); + fword("property"); + + PUSH(3); + fword("encode-int"); + push_str("#buttons"); + fword("property"); + + BIND_NODE_METHODS(get_cur_dev(), mouse); + fword("finish-device");
aliases = find_dev("/aliases"); + snprintf(buf, sizeof(buf), "%s/mouse", path); set_property(aliases, "adb-mouse", buf, strlen(buf) + 1); }