Index: uspace/drv/bus/usb/ehci/Makefile
===================================================================
--- uspace/drv/bus/usb/ehci/Makefile	(revision da06e9253c0a4a68b3b298443c0192075df61f63)
+++ uspace/drv/bus/usb/ehci/Makefile	(revision 972e8a943b71418f4c0385c006b252788574e3cf)
@@ -45,5 +45,4 @@
 
 SOURCES = \
-	ehci.c \
 	ehci_rh.c \
 	hc.c \
Index: uspace/drv/bus/usb/ehci/ehci.c
===================================================================
--- uspace/drv/bus/usb/ehci/ehci.c	(revision da06e9253c0a4a68b3b298443c0192075df61f63)
+++ 	(revision )
@@ -1,155 +1,0 @@
-/*
- * Copyright (c) 2011 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.
- */
-
-/** @addtogroup drvusbehci
- * @{
- */
-/** @file
- * @brief EHCI driver
- */
-
-#include <assert.h>
-#include <errno.h>
-#include <ddf/interrupt.h>
-#include <device/hw_res_parsed.h>
-#include <stdbool.h>
-#include <str_error.h>
-#include <sys/types.h>
-
-#include <usb/usb.h>
-#include <usb/debug.h>
-
-#include <usb/host/ddf_helpers.h>
-#include <usb/host/usb_bus.h>
-
-#include "ehci.h"
-//#include "ehci_endpoint.h"
-#include "hc.h"
-
-
-/** IRQ handling callback, identifies device
- *
- * @param[in] dev DDF instance of the device to use.
- * @param[in] iid (Unused).
- * @param[in] call Pointer to the call that represents interrupt.
- */
-static void irq_handler(ddf_dev_t *dev, ipc_callid_t iid, ipc_call_t *call)
-{
-	assert(dev);
-	hcd_t *hcd = dev_to_hcd(dev);
-	if (!hcd || !hcd->driver.data) {
-		usb_log_warning("Interrupt on device that is not ready.\n");
-		return;
-	}
-
-	const uint16_t status = IPC_GET_ARG1(*call);
-	hc_interrupt(hcd->driver.data, status);
-}
-
-/** Initialize hc and rh ddf structures and their respective drivers.
- *
- * @param[in] device DDF instance of the device to use.
- * @param[in] instance EHCI structure to use.
- *
- * This function does all the preparatory work for hc and rh drivers:
- *  - gets device hw resources
- *  - disables EHCI legacy support
- *  - asks for interrupt
- *  - registers interrupt handler
- */
-int device_setup_ehci(ddf_dev_t *device)
-{
-	hw_res_list_parsed_t hw_res;
-	int ret = hcd_ddf_get_registers(device, &hw_res);
-	if (ret != EOK ||
-	    hw_res.irqs.count != 1 || hw_res.mem_ranges.count != 1) {
-		usb_log_error("Failed to get register memory addresses "
-		    "for %" PRIun ": %s.\n", ddf_dev_get_handle(device),
-		    str_error(ret));
-		return ret;
-	}
-
-	/* Initialize generic HCD driver */
-	ret = hcd_ddf_setup_hc(device, USB_SPEED_HIGH,
-	    BANDWIDTH_AVAILABLE_USB20, bandwidth_count_usb20);
-	if (ret != EOK) {
-		usb_log_error("Failed to setup generic hcd structures: %s.",
-		    str_error(ret));
-		hw_res_list_parsed_clean(&hw_res);
-		return ret;
-	}
-
-	hc_t *hc = malloc(sizeof(hc_t));
-	if (!hc) {
-		usb_log_error("Failed to allocate driver structure.\n");
-		hw_res_list_parsed_clean(&hw_res);
-		ret = ENOMEM;
-		goto ddf_hc_clean;
-	}
-
-	/* Try to enable interrupts */
-	bool interrupts = false;
-	const int irq = hcd_ddf_setup_interrupts(device, &hw_res, irq_handler,
-	    hc_gen_irq_code);
-	if (irq < 0) {
-		usb_log_warning("Failed to enable interrupts: %s."
-		    " Falling back to polling\n", str_error(irq));
-	} else {
-		usb_log_debug("Hw interrupts enabled.\n");
-		interrupts = true;
-	}
-
-	/* Initialize EHCI HC */
-	ret = hc_init(hc, &hw_res, interrupts);
-	hw_res_list_parsed_clean(&hw_res);
-	if (ret != EOK) {
-		usb_log_error("Failed to init hc: %s.\n", str_error(ret));
-		goto unregister_irq;
-	}
-
-	/* Connect EHCI to generic HCD */
-	hcd_set_implementation(dev_to_hcd(device), hc,
-	    hc_schedule, NULL, NULL, NULL);
-
-	/* HC should be running OK. We can add root hub */
-	ret = hcd_ddf_setup_root_hub(device);
-	if (ret != EOK) {
-		usb_log_error("Failed to register EHCI root hub: %s.\n",
-		    str_error(ret));
-		hc_fini(hc);
-unregister_irq:
-		unregister_interrupt_handler(device, irq);
-		free(hc);
-ddf_hc_clean:
-		hcd_ddf_clean_hc(device);
-	}
-	return ret;
-}
-/**
- * @}
- */
Index: uspace/drv/bus/usb/ehci/ehci.h
===================================================================
--- uspace/drv/bus/usb/ehci/ehci.h	(revision da06e9253c0a4a68b3b298443c0192075df61f63)
+++ 	(revision )
@@ -1,43 +1,0 @@
-/*
- * Copyright (c) 2013 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.
- */
-/** @addtogroup drvusbehci
- * @{
- */
-/** @file
- * @brief EHCI driver main structure for both host controller and root-hub.
- */
-#ifndef DRV_EHCI_EHCI_H
-#define DRV_EHCI_EHCI_H
-#include <ddf/driver.h>
-
-int device_setup_ehci(ddf_dev_t *device);
-
-#endif
-/**
- * @}
- */
Index: uspace/drv/bus/usb/ehci/main.c
===================================================================
--- uspace/drv/bus/usb/ehci/main.c	(revision da06e9253c0a4a68b3b298443c0192075df61f63)
+++ uspace/drv/bus/usb/ehci/main.c	(revision 972e8a943b71418f4c0385c006b252788574e3cf)
@@ -44,7 +44,40 @@
 
 #include "res.h"
-#include "ehci.h"
+#include "hc.h"
 
 #define NAME "ehci"
+// TODO: This should be merged to hc_interrupt
+static void ehci_interrupt(hcd_t *hcd, uint32_t status)
+{
+	assert(hcd);
+	if (hcd->driver.data)
+		hc_interrupt(hcd->driver.data, status);
+}
+
+static int ehci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res, bool irq)
+{
+	assert(hcd);
+	assert(hcd->driver.data == NULL);
+
+	hc_t *instance = malloc(sizeof(hc_t));
+	if (!instance)
+		return ENOMEM;
+
+	const int ret =  hc_init(instance, res, irq);
+	if (ret == EOK)
+		hcd_set_implementation(hcd, instance, hc_schedule,
+		    NULL, NULL, ehci_interrupt);
+	return ret;
+}
+
+static void ehci_driver_fini(hcd_t *hcd)
+{
+	assert(hcd);
+	if (hcd->driver.data)
+		hc_fini(hcd->driver.data);
+
+	free(hcd->driver.data);
+	hcd_set_implementation(hcd, NULL, NULL, NULL, NULL, NULL);
+}
 
 static int ehci_dev_add(ddf_dev_t *device);
@@ -67,38 +100,17 @@
 static int ehci_dev_add(ddf_dev_t *device)
 {
+	usb_log_debug("ehci_dev_add() called\n");
 	assert(device);
-	hw_res_list_parsed_t hw_res;
-	int ret = hcd_ddf_get_registers(device, &hw_res);
-	if (ret != EOK ||
-	    hw_res.irqs.count != 1 || hw_res.mem_ranges.count != 1) {
-		usb_log_error("Failed to get register memory addresses "
-		    "for %" PRIun ": %s.\n", ddf_dev_get_handle(device),
+
+	const int ret = ddf_hcd_device_setup_all(device, USB_SPEED_HIGH,
+	    BANDWIDTH_AVAILABLE_USB20, bandwidth_count_usb11,
+	    ddf_hcd_gen_irq_handler, hc_gen_irq_code,
+	    ehci_driver_init, ehci_driver_fini);
+	if (ret != EOK) {
+		usb_log_error("Failed to initialize EHCI driver: %s.\n",
 		    str_error(ret));
-		return ret;
 	}
-	addr_range_t regs = hw_res.mem_ranges.ranges[0];
-	const int irq = hw_res.irqs.irqs[0];
-	hw_res_list_parsed_clean(&hw_res);
-
-	usb_log_info("Memory mapped regs at %p (size %zu), IRQ %d.\n",
-	    RNGABSPTR(regs), RNGSZ(regs), irq);
-
-	ret = disable_legacy(device, &regs);
-	if (ret != EOK) {
-		usb_log_error("Failed to disable legacy USB: %s.\n",
-		    str_error(ret));
-		return ret;
-	}
-
-	/* High Speed, no bandwidth */
-	ret = device_setup_ehci(device);
-	if (ret != EOK) {
-		usb_log_error("Failed to init ehci driver: %s\n",
-		    str_error(ret));
-		return ret;
-	}
-
-	usb_log_info("Controlling new EHCI device `%s' (handle %" PRIun ").\n",
-	    ddf_dev_get_name(device), ddf_dev_get_handle(device));
+	usb_log_info("Controlling new EHCI device '%s'.\n",
+	    ddf_dev_get_name(device));
 
 	return EOK;
