Index: uspace/drv/infrastructure/rootamdm37x/rootamdm37x.c
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/rootamdm37x.c	(revision 09a0a8f0999e95475a4a5baea3f5192fb662f4db)
+++ uspace/drv/infrastructure/rootamdm37x/rootamdm37x.c	(revision 09a0a8f0999e95475a4a5baea3f5192fb662f4db)
@@ -0,0 +1,214 @@
+/*
+ * Copyright (c) 2012 Jan Vesely
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @defgroup root_amdm37x TI AM/DM37x platform driver.
+ * @brief HelenOS TI AM/DM37x platform driver.
+ * @{
+ */
+
+/** @file
+ */
+
+#include <ddf/driver.h>
+#include <ddf/log.h>
+#include <errno.h>
+#include <ops/hw_res.h>
+#include <stdio.h>
+
+#define NAME  "rootamdm37x"
+
+/** Obtain function soft-state from DDF function node */
+#define ROOTMAC_FUN(fnode) \
+	((rootamdm37x_fun_t *) (fnode)->driver_data)
+
+typedef struct {
+	hw_resource_list_t hw_resources;
+} rootamdm37x_fun_t;
+
+static hw_resource_t ohci_res[] = {
+	{
+		.type = MEM_RANGE,
+		/* See amdm37x TRM page. 3316 for these values */
+		.res.io_range = {
+			.address = 0x48064400,
+			.size = 1024,
+			.endianness = LITTLE_ENDIAN
+		},
+	},
+	{
+		.type = INTERRUPT,
+		.res.interrupt = { .irq = 76 },
+	},
+};
+
+static hw_resource_t ehci_res[] = {
+	{
+		.type = MEM_RANGE,
+		/* See amdm37x TRM page. 3316 for these values */
+		.res.io_range = {
+			.address = 0x48064800,
+			.size = 1024,
+			.endianness = LITTLE_ENDIAN
+		},
+	},
+	{
+		.type = INTERRUPT,
+		.res.interrupt = { .irq = 77 },
+	},
+};
+
+static const rootamdm37x_fun_t ohci = {
+	.hw_resources = {
+	    .resources = ohci_res,
+	    .count = sizeof(ohci_res)/sizeof(ohci_res[0]),
+	}
+};
+
+static const rootamdm37x_fun_t ehci = {
+	.hw_resources = {
+	    .resources = ehci_res,
+	    .count = sizeof(ehci_res)/sizeof(ehci_res[0]),
+	}
+};
+
+
+static ddf_dev_ops_t rootamdm37x_fun_ops;
+
+static bool rootamdm37x_add_fun(ddf_dev_t *dev, const char *name,
+    const char *str_match_id, const rootamdm37x_fun_t *fun)
+{
+	ddf_msg(LVL_DEBUG, "Adding new function '%s'.", name);
+	
+	ddf_fun_t *fnode = NULL;
+	match_id_t *match_id = NULL;
+	
+	/* Create new device. */
+	fnode = ddf_fun_create(dev, fun_inner, name);
+	if (fnode == NULL)
+		goto failure;
+	
+	fnode->driver_data = (void*)fun;
+	
+	/* Initialize match id list */
+	match_id = create_match_id();
+	if (match_id == NULL)
+		goto failure;
+	
+	match_id->id = str_match_id;
+	match_id->score = 100;
+	add_match_id(&fnode->match_ids, match_id);
+	
+	/* Set provided operations to the device. */
+	fnode->ops = &rootamdm37x_fun_ops;
+	
+	/* Register function. */
+	if (ddf_fun_bind(fnode) != EOK) {
+		ddf_msg(LVL_ERROR, "Failed binding function %s.", name);
+		goto failure;
+	}
+	
+	return true;
+	
+failure:
+	if (match_id != NULL)
+		match_id->id = NULL;
+	
+	if (fnode != NULL) {
+		fnode->driver_data = NULL;
+		ddf_fun_destroy(fnode);
+	}
+	
+	ddf_msg(LVL_ERROR, "Failed adding function '%s'.", name);
+	
+	return false;
+}
+
+/** Get the root device.
+ *
+ * @param dev Device which is root of the whole device tree
+ *            (both of HW and pseudo devices).
+ *
+ * @return Zero on success, negative error number otherwise.
+ *
+ */
+static int rootamdm37x_dev_add(ddf_dev_t *dev)
+{
+	/* Register functions */
+	if (!rootamdm37x_add_fun(dev, "ohci", "usb/host=ohci", &ohci))
+		ddf_msg(LVL_ERROR, "Failed to add OHCI function for "
+		    "BeagleBoard-xM platform.");
+	if (!rootamdm37x_add_fun(dev, "ehci", "usb/host=ehci", &ehci))
+		ddf_msg(LVL_ERROR, "Failed to add EHCI function for "
+		    "BeagleBoard-xM platform.");
+
+	return EOK;
+}
+
+/** The root device driver's standard operations. */
+static driver_ops_t rootamdm37x_ops = {
+	.dev_add = &rootamdm37x_dev_add
+};
+
+/** The root device driver structure. */
+static driver_t rootamdm37x_driver = {
+	.name = NAME,
+	.driver_ops = &rootamdm37x_ops
+};
+
+static hw_resource_list_t *rootamdm37x_get_resources(ddf_fun_t *fnode)
+{
+	rootamdm37x_fun_t *fun = ROOTMAC_FUN(fnode);
+	assert(fun != NULL);
+	
+	return &fun->hw_resources;
+}
+
+static bool rootamdm37x_enable_interrupt(ddf_fun_t *fun)
+{
+	/* TODO */
+	
+	return false;
+}
+
+static hw_res_ops_t fun_hw_res_ops = {
+   	.get_resource_list = &rootamdm37x_get_resources,
+	.enable_interrupt = &rootamdm37x_enable_interrupt
+};
+
+int main(int argc, char *argv[])
+{
+	printf("%s: HelenOS AM/DM37x(OMAP37x) platform driver\n", NAME);
+	ddf_log_init(NAME, LVL_ERROR);
+	rootamdm37x_fun_ops.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops;
+	return ddf_driver_main(&rootamdm37x_driver);
+}
+
+/**
+ * @}
+ */
