Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/Makefile	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -192,4 +192,9 @@
 endif
 
+ifeq ($(UARCH),arm32)
+	DIRS += \
+		drv/infrastructure/rootamdm37x
+endif
+
 ## System libraries
 #
Index: uspace/app/tester/float/softfloat1.c
===================================================================
--- uspace/app/tester/float/softfloat1.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/app/tester/float/softfloat1.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -35,8 +35,9 @@
 #include <div.h>
 #include <comparison.h>
+#include <conversion.h>
 #include <bool.h>
 #include "../tester.h"
 
-#define OPERANDS  6 
+#define OPERANDS  10
 #define PRECISION  10000
 
@@ -44,21 +45,29 @@
 
 typedef int32_t cmptype_t;
-typedef void (* float_op_t)(float, float, float *, float_t *);
-typedef void (* double_op_t)(double, double, double *, double_t *);
+
+typedef void (* uint_to_double_op_t)(unsigned int, double *, double_t *);
+typedef void (* double_to_uint_op_t)(double, unsigned int *, unsigned int *);
+typedef void (* float_binary_op_t)(float, float, float *, float_t *);
+typedef void (* double_binary_op_t)(double, double, double *, double_t *);
 typedef void (* double_cmp_op_t)(double, double, cmptype_t *, cmptype_t *);
-typedef void (* template_t)(void *, unsigned, unsigned, cmptype_t *,
+
+typedef void (* template_unary_t)(void *, unsigned, cmptype_t *, cmptype_t *);
+typedef void (* template_binary_t)(void *, unsigned, unsigned, cmptype_t *,
     cmptype_t *);
 
-static float fop_a[OPERANDS] =
-	{3.5, -2.1, 100.0, 50.0, -1024.0, 0.0};
-
-static float fop_b[OPERANDS] =
-	{-2.1, 100.0, 50.0, -1024.0, 3.5, 0.0};
-
-static double dop_a[OPERANDS] =
-	{3.5, -2.1, 100.0, 50.0, -1024.0, 0.0};
-
-static double dop_b[OPERANDS] =
-	{-2.1, 100.0, 50.0, -1024.0, 3.5, 0.0};
+#define NUMBERS	\
+	3.5, -2.1, 100.0, 50.0, -1024.0, 0.0, 768.3156, 1080.499999, -600.0, 1.0
+
+static float fop_a[OPERANDS] = {
+	NUMBERS
+};
+
+static double dop_a[OPERANDS] =	{
+	NUMBERS
+};
+
+static unsigned int uop_a[OPERANDS] = {
+	4, -100, 100, 50, 1024, 0, 1000000, -1U, 0x80000000U, 500
+};
 
 static cmptype_t cmpabs(cmptype_t a)
@@ -81,5 +90,34 @@
 
 static void
-float_template(void *f, unsigned i, unsigned j, cmptype_t *pic,
+uint_to_double_template(void *f, unsigned i, cmptype_t *pic, cmptype_t *pisc)
+{
+	double c;
+	double_t sc;
+
+	uint_to_double_op_t op = (uint_to_double_op_t) f;
+	
+	op(uop_a[i], &c, &sc);
+
+	*pic = (cmptype_t) (c * PRECISION);
+	*pisc = (cmptype_t) (sc.val * PRECISION);
+}
+
+static void
+double_to_uint_template(void *f, unsigned i, cmptype_t *pic, cmptype_t *pisc)
+{
+	unsigned int c;
+	unsigned int sc;
+
+	double_to_uint_op_t op = (double_to_uint_op_t) f;
+	
+	op(dop_a[i], &c, &sc);
+
+	*pic = (cmptype_t) c;
+	*pisc = (cmptype_t) sc;
+}
+
+
+static void
+float_template_binary(void *f, unsigned i, unsigned j, cmptype_t *pic,
     cmptype_t *pisc)
 {
@@ -87,7 +125,7 @@
 	float_t sc;
 
-	float_op_t op = (float_op_t) f;
-	
-	op(fop_a[i], fop_b[j], &c, &sc);
+	float_binary_op_t op = (float_binary_op_t) f;
+	
+	op(fop_a[i], fop_a[j], &c, &sc);
 
 	*pic = (cmptype_t) (c * PRECISION);
@@ -96,5 +134,5 @@
 
 static void
-double_template(void *f, unsigned i, unsigned j, cmptype_t *pic,
+double_template_binary(void *f, unsigned i, unsigned j, cmptype_t *pic,
     cmptype_t *pisc)
 {
@@ -102,7 +140,7 @@
 	double_t sc;
 
-	double_op_t op = (double_op_t) f;
-	
-	op(dop_a[i], dop_b[j], &c, &sc);
+	double_binary_op_t op = (double_binary_op_t) f;
+	
+	op(dop_a[i], dop_a[j], &c, &sc);
 
 	*pic = (cmptype_t) (c * PRECISION);
@@ -116,8 +154,28 @@
 	double_cmp_op_t op = (double_cmp_op_t) f;
 	
-	op(dop_a[i], dop_b[j], pis, piss);
-}
-
-static bool test_template(template_t template, void *f)
+	op(dop_a[i], dop_a[j], pis, piss);
+}
+
+static bool test_template_unary(template_unary_t template, void *f)
+{
+	bool correct = true;
+	
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		cmptype_t ic;
+		cmptype_t isc;
+
+		template(f, i, &ic, &isc);	
+		cmptype_t diff = cmpabs(ic - isc);
+			
+		if (diff != 0) {
+			TPRINTF("i=%u diff=%" PRIdCMPTYPE "\n", i, diff);
+			correct = false;
+		}
+	}
+	
+	return correct;
+}
+
+static bool test_template_binary(template_binary_t template, void *f)
 {
 	bool correct = true;
@@ -142,4 +200,32 @@
 }
 
+static void uint_to_double_operator(unsigned int a, double *pc, double_t *psc)
+{
+	*pc = (double) a;
+	psc->data = uint_to_double(a);
+}
+
+static void
+double_to_uint_operator(double a, unsigned int *pc, unsigned int *psc)
+{
+	double_t sa;
+
+	sa.val = a;
+
+	*pc = (unsigned int) a;
+	*psc = double_to_uint(sa.data);
+}
+
+static void
+double_to_int_operator(double a, unsigned int *pc, unsigned int *psc)
+{
+	double_t sa;
+
+	sa.val = a;
+
+	*pc = (int) a;
+	*psc = double_to_int(sa.data);
+}
+
 static void float_add_operator(float a, float b, float *pc, float_t *psc)
 {
@@ -267,32 +353,47 @@
 	const char *err = NULL;
 
-	if (!test_template(float_template, float_add_operator)) {
+	if (!test_template_binary(float_template_binary, float_add_operator)) {
 		err = "Float addition failed";
 		TPRINTF("%s\n", err);
 	}
-	if (!test_template(float_template, float_mul_operator)) {
+	if (!test_template_binary(float_template_binary, float_mul_operator)) {
 		err = "Float multiplication failed";
 		TPRINTF("%s\n", err);
 	}
-	if (!test_template(float_template, float_div_operator)) {
+	if (!test_template_binary(float_template_binary, float_div_operator)) {
 		err = "Float division failed";
 		TPRINTF("%s\n", err);
 	}
-	if (!test_template(double_template, double_add_operator)) {
+	if (!test_template_binary(double_template_binary, double_add_operator)) {
 		err = "Double addition failed";
 		TPRINTF("%s\n", err);
 	}
-	if (!test_template(double_template, double_mul_operator)) {
+	if (!test_template_binary(double_template_binary, double_mul_operator)) {
 		err = "Double multiplication failed";
 		TPRINTF("%s\n", err);
 	}
-	if (!test_template(double_template, double_div_operator)) {
+	if (!test_template_binary(double_template_binary, double_div_operator)) {
 		err = "Double division failed";
 		TPRINTF("%s\n", err);
 	}
-	if (!test_template(double_compare_template, double_cmp_operator)) {
+	if (!test_template_binary(double_compare_template, double_cmp_operator)) {
 		err = "Double comparison failed";
 		TPRINTF("%s\n", err);
 	}
+	if (!test_template_unary(uint_to_double_template,
+	    uint_to_double_operator)) {
+		err = "Conversion from unsigned int to double failed";
+		TPRINTF("%s\n", err);
+	}
+	if (!test_template_unary(double_to_uint_template,
+	    double_to_uint_operator)) {
+		err = "Conversion from double to unsigned int failed";
+		TPRINTF("%s\n", err);
+	}
+	if (!test_template_unary(double_to_uint_template,
+	    double_to_int_operator)) {
+		err = "Conversion from double to signed int failed";
+		TPRINTF("%s\n", err);
+	}
 	
 	return err;
Index: uspace/app/tester/mm/common.c
===================================================================
--- uspace/app/tester/mm/common.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/app/tester/mm/common.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -343,5 +343,5 @@
 	
 	area->addr = as_area_create(AS_AREA_ANY, size,
-	    AS_AREA_WRITE | AS_AREA_READ);
+	    AS_AREA_WRITE | AS_AREA_READ | AS_AREA_CACHEABLE);
 	if (area->addr == AS_MAP_FAILED) {
 		free(area);
Index: uspace/app/tester/mm/mapping1.c
===================================================================
--- uspace/app/tester/mm/mapping1.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/app/tester/mm/mapping1.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -43,5 +43,5 @@
 	
 	void *result = as_area_create(AS_AREA_ANY, size,
-	    AS_AREA_READ | AS_AREA_WRITE);
+	    AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
 	if (result == AS_MAP_FAILED)
 		return NULL;
Index: uspace/drv/bus/isa/i8237.c
===================================================================
--- uspace/drv/bus/isa/i8237.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/drv/bus/isa/i8237.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -40,5 +40,4 @@
 #include <fibril_synch.h>
 #include <ddi.h>
-#include <libarch/ddi.h>
 #include <ddf/log.h>
 #include "i8237.h"
Index: uspace/drv/bus/pci/pciintel/pci.c
===================================================================
--- uspace/drv/bus/pci/pciintel/pci.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/drv/bus/pci/pciintel/pci.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -58,5 +58,4 @@
 #include <device/hw_res.h>
 #include <ddi.h>
-#include <libarch/ddi.h>
 #include <pci_dev_iface.h>
 
Index: uspace/drv/bus/usb/ehci/ehci.ma
===================================================================
--- uspace/drv/bus/usb/ehci/ehci.ma	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/drv/bus/usb/ehci/ehci.ma	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -1,1 +1,2 @@
+20 usb/host=ehci
 10 pci/class=0c&subclass=03&progif=20
Index: uspace/drv/bus/usb/ohci/ohci.ma
===================================================================
--- uspace/drv/bus/usb/ohci/ohci.ma	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/drv/bus/usb/ohci/ohci.ma	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -1,1 +1,2 @@
+20 usb/host=ohci
 10 pci/class=0c&subclass=03&progif=10
Index: uspace/drv/bus/usb/ohci/ohci_regs.h
===================================================================
--- uspace/drv/bus/usb/ohci/ohci_regs.h	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/drv/bus/usb/ohci/ohci_regs.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -245,5 +245,5 @@
 #define RHPS_PRSC_FLAG (1 << 20) /* port reset status change WC */
 #define RHPS_CHANGE_WC_MASK (0x1f0000)
-} __attribute__((packed)) ohci_regs_t;
+} ohci_regs_t;
 #endif
 /**
Index: uspace/drv/bus/usb/uhci/hc.c
===================================================================
--- uspace/drv/bus/usb/uhci/hc.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/drv/bus/usb/uhci/hc.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -35,5 +35,5 @@
 #include <str_error.h>
 #include <adt/list.h>
-#include <libarch/ddi.h>
+#include <ddi.h>
 
 #include <usb/debug.h>
Index: uspace/drv/bus/usb/uhci/hc.h
===================================================================
--- uspace/drv/bus/usb/uhci/hc.h	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/drv/bus/usb/uhci/hc.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -37,6 +37,4 @@
 
 #include <fibril.h>
-#include <ddi.h>
-
 #include <usb/host/hcd.h>
 
Index: uspace/drv/bus/usb/uhcirh/port.c
===================================================================
--- uspace/drv/bus/usb/uhcirh/port.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/drv/bus/usb/uhcirh/port.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -32,5 +32,5 @@
  * @brief UHCI root hub port routines
  */
-#include <libarch/ddi.h>  /* pio_read and pio_write */
+#include <ddi.h>
 #include <fibril_synch.h> /* async_usleep */
 #include <errno.h>
Index: uspace/drv/char/i8042/i8042.c
===================================================================
--- uspace/drv/char/i8042/i8042.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/drv/char/i8042/i8042.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -41,5 +41,4 @@
 #include <device/hw_res.h>
 #include <ddi.h>
-#include <libarch/ddi.h>
 #include <errno.h>
 #include <str_error.h>
Index: uspace/drv/char/ns8250/ns8250.c
===================================================================
--- uspace/drv/char/ns8250/ns8250.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/drv/char/ns8250/ns8250.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -51,5 +51,4 @@
 #include <sys/stat.h>
 #include <ddi.h>
-#include <libarch/ddi.h>
 
 #include <ddf/driver.h>
Index: uspace/drv/infrastructure/rootamdm37x/Makefile
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/Makefile	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
+++ uspace/drv/infrastructure/rootamdm37x/Makefile	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -0,0 +1,38 @@
+#
+# 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.
+#
+
+USPACE_PREFIX = ../../..
+LIBS = $(LIBDRV_PREFIX)/libdrv.a
+EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
+BINARY = rootamdm37x
+
+SOURCES = \
+	amdm37x.c \
+	rootamdm37x.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/infrastructure/rootamdm37x/amdm37x.c
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/amdm37x.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
+++ uspace/drv/infrastructure/rootamdm37x/amdm37x.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -0,0 +1,404 @@
+/*
+ * 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 "amdm37x.h"
+
+#include <assert.h>
+#include <ddi.h>
+#include <ddf/log.h>
+#include <errno.h>
+#include <stdio.h>
+
+static void log(const volatile void *place, uint32_t val, volatile void* base, size_t size, void *data, bool write)
+{
+	printf("PIO %s: %p(%p) %#"PRIx32"\n", write ? "WRITE" : "READ",
+	    (place - base) + data, place, val);
+}
+
+
+int amdm37x_init(amdm37x_t *device, bool trace)
+{
+	assert(device);
+	int ret = EOK;
+
+	ret = pio_enable((void*)USBHOST_CM_BASE_ADDRESS, USBHOST_CM_SIZE,
+	    (void**)&device->cm.usbhost);
+	if (ret != EOK)
+		return ret;
+
+	ret = pio_enable((void*)CORE_CM_BASE_ADDRESS, CORE_CM_SIZE,
+	    (void**)&device->cm.core);
+	if (ret != EOK)
+		return ret;
+
+	ret = pio_enable((void*)CLOCK_CONTROL_CM_BASE_ADDRESS,
+		    CLOCK_CONTROL_CM_SIZE, (void**)&device->cm.clocks);
+	if (ret != EOK)
+		return ret;
+
+	ret = pio_enable((void*)MPU_CM_BASE_ADDRESS,
+		    MPU_CM_SIZE, (void**)&device->cm.mpu);
+	if (ret != EOK)
+		return ret;
+
+	ret = pio_enable((void*)IVA2_CM_BASE_ADDRESS,
+		    IVA2_CM_SIZE, (void**)&device->cm.iva2);
+	if (ret != EOK)
+		return ret;
+
+	ret = pio_enable((void*)CLOCK_CONTROL_PRM_BASE_ADDRESS,
+	    CLOCK_CONTROL_PRM_SIZE, (void**)&device->prm.clocks);
+	if (ret != EOK)
+		return ret;
+
+	ret = pio_enable((void*)GLOBAL_REG_PRM_BASE_ADDRESS,
+	    GLOBAL_REG_PRM_SIZE, (void**)&device->prm.global);
+	if (ret != EOK)
+		return ret;
+
+	ret = pio_enable((void*)AMDM37x_USBTLL_BASE_ADDRESS,
+	    AMDM37x_USBTLL_SIZE, (void**)&device->tll);
+	if (ret != EOK)
+		return ret;
+
+	ret = pio_enable((void*)AMDM37x_UHH_BASE_ADDRESS,
+	    AMDM37x_UHH_SIZE, (void**)&device->uhh);
+	if (ret != EOK)
+		return ret;
+
+	if (trace) {
+		pio_trace_enable(device->tll, AMDM37x_USBTLL_SIZE, log, (void*)AMDM37x_USBTLL_BASE_ADDRESS);
+		pio_trace_enable(device->cm.clocks, CLOCK_CONTROL_CM_SIZE, log, (void*)CLOCK_CONTROL_CM_BASE_ADDRESS);
+		pio_trace_enable(device->cm.core, CORE_CM_SIZE, log, (void*)CORE_CM_BASE_ADDRESS);
+		pio_trace_enable(device->cm.mpu, MPU_CM_SIZE, log, (void*)MPU_CM_BASE_ADDRESS);
+		pio_trace_enable(device->cm.iva2, IVA2_CM_SIZE, log, (void*)IVA2_CM_BASE_ADDRESS);
+		pio_trace_enable(device->cm.usbhost, USBHOST_CM_SIZE, log, (void*)USBHOST_CM_BASE_ADDRESS);
+		pio_trace_enable(device->uhh, AMDM37x_UHH_SIZE, log, (void*)AMDM37x_UHH_BASE_ADDRESS);
+		pio_trace_enable(device->prm.clocks, CLOCK_CONTROL_PRM_SIZE, log, (void*)CLOCK_CONTROL_PRM_BASE_ADDRESS);
+		pio_trace_enable(device->prm.global, GLOBAL_REG_PRM_SIZE, log, (void*)GLOBAL_REG_PRM_BASE_ADDRESS);
+	}
+	return EOK;
+}
+
+
+/** Set DPLLs 1,2,3,4,5 to ON (locked) and autoidle.
+ * @param device Register map.
+ *
+ * The idea is to get all DPLLs running and make hw control their power mode,
+ * based on the module requirements (module ICLKs and FCLKs).
+ */
+void amdm37x_setup_dpll_on_autoidle(amdm37x_t *device)
+{
+	assert(device);
+	/* Get SYS_CLK value, it is used as reference clock by all DPLLs,
+	 * NFI who sets this or why it is set to specific value. */
+	const unsigned osc_clk = pio_read_32(&device->prm.clocks->clksel)
+	    & CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_MASK;
+	const unsigned clk_reg = pio_read_32(&device->prm.global->clksrc_ctrl);
+	const unsigned base_freq = sys_clk_freq_kHz(osc_clk)
+	    / GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKDIV_GET(clk_reg);
+	ddf_msg(LVL_NOTE, "Base frequency: %d.%dMhz",
+	    base_freq / 1000, base_freq % 1000);
+
+
+	/* DPLL1 provides MPU(CPU) clock.
+	 * It uses SYS_CLK as reference clock and core clock (DPLL3) as
+	 * high frequency bypass (MPU then runs on L3 interconnect freq).
+	 * It should be setup by fw or u-boot.*/
+	mpu_cm_regs_t *mpu = device->cm.mpu;
+
+	/* Current MPU frequency. */
+	if (pio_read_32(&mpu->clkstst) & MPU_CM_CLKSTST_CLKACTIVITY_MPU_ACTIVE_FLAG) {
+		if (pio_read_32(&mpu->idlest_pll) & MPU_CM_IDLEST_PLL_ST_MPU_CLK_LOCKED_FLAG) {
+			/* DPLL active and locked */
+			const uint32_t reg = pio_read_32(&mpu->clksel1_pll);
+			const unsigned multiplier =
+			    (reg & MPU_CM_CLKSEL1_PLL_MPU_DPLL_MULT_MASK)
+				>> MPU_CM_CLKSEL1_PLL_MPU_DPLL_MULT_SHIFT;
+			const unsigned divisor =
+			    (reg & MPU_CM_CLKSEL1_PLL_MPU_DPLL_DIV_MASK)
+				>> MPU_CM_CLKSEL1_PLL_MPU_DPLL_DIV_SHIFT;
+			const unsigned divisor2 =
+			    (pio_read_32(&mpu->clksel2_pll)
+			        & MPU_CM_CLKSEL2_PLL_MPU_DPLL_CLKOUT_DIV_MASK);
+			if (multiplier && divisor && divisor2) {
+				/** See AMDM37x TRM p. 300 for the formula */
+				const unsigned freq =
+				    ((base_freq * multiplier) / (divisor + 1))
+				    / divisor2;
+				ddf_msg(LVL_NOTE, "MPU running at %d.%d MHz",
+				    freq / 1000, freq % 1000);
+			} else {
+				ddf_msg(LVL_WARN, "Frequency divisor and/or "
+				    "multiplier value invalid: %d %d %d",
+				    multiplier, divisor, divisor2);
+			}
+		} else {
+			/* DPLL in LP bypass mode */
+			const unsigned divisor =
+			    MPU_CM_CLKSEL1_PLL_MPU_CLK_SRC_VAL(
+			        pio_read_32(&mpu->clksel1_pll));
+			ddf_msg(LVL_NOTE, "MPU DPLL in bypass mode, running at"
+			    " CORE CLK / %d MHz", divisor);
+		}
+	} else {
+		ddf_msg(LVL_WARN, "MPU clock domain is not active, we should not be running...");
+	}
+	// TODO: Enable this (automatic MPU downclocking):
+#if 0
+	/* Enable low power bypass mode, this will take effect the next lock or
+	 * relock sequence. */
+	//TODO: We might need to force re-lock after enabling this
+	pio_set_32(&mpu->clken_pll, MPU_CM_CLKEN_PLL_EN_MPU_DPLL_LP_MODE_FLAG, 5);
+	/* Enable automatic relocking */
+	pio_change_32(&mpu->autoidle_pll, MPU_CM_AUTOIDLE_PLL_AUTO_MPU_DPLL_ENABLED, MPU_CM_AUTOIDLE_PLL_AUTO_MPU_DPLL_MASK, 5);
+#endif
+
+	/* DPLL2 provides IVA(video acceleration) clock.
+	 * It uses SYS_CLK as reference clokc and core clock (DPLL3) as
+	 * high frequency bypass (IVA runs on L3 freq).
+	 */
+	// TODO: We can probably turn this off entirely. IVA is left unused.
+	/* Enable low power bypass mode, this will take effect the next lock or
+	 * relock sequence. */
+	//TODO: We might need to force re-lock after enabling this
+	pio_set_32(&device->cm.iva2->clken_pll, MPU_CM_CLKEN_PLL_EN_MPU_DPLL_LP_MODE_FLAG, 5);
+	/* Enable automatic relocking */
+	pio_change_32(&device->cm.iva2->autoidle_pll, MPU_CM_AUTOIDLE_PLL_AUTO_MPU_DPLL_ENABLED, MPU_CM_AUTOIDLE_PLL_AUTO_MPU_DPLL_MASK, 5);
+
+	/* DPLL3 provides tons of clocks:
+	 * CORE_CLK, COREX2_CLK, DSS_TV_CLK, 12M_CLK, 48M_CLK, 96M_CLK, L3_ICLK,
+	 * and L4_ICLK. It uses SYS_CLK as reference clock and low frequency
+	 * bypass. It should be setup by fw or u-boot as it controls critical
+	 * interconnects.
+	 */
+	if (pio_read_32(&device->cm.clocks->idlest_ckgen) & CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_CORE_CLK_FLAG) {
+		/* DPLL active and locked */
+		const uint32_t reg =
+		    pio_read_32(&device->cm.clocks->clksel1_pll);
+		const unsigned multiplier =
+		    CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_MULT_GET(reg);
+		const unsigned divisor =
+		    CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_DIV_GET(reg);
+		const unsigned divisor2 =
+		    CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_CLKOUT_DIV_GET(reg);
+		if (multiplier && divisor && divisor2) {
+			/** See AMDM37x TRM p. 300 for the formula */
+			const unsigned freq =
+			    ((base_freq * multiplier) / (divisor + 1)) / divisor2;
+			ddf_msg(LVL_NOTE, "CORE CLK running at %d.%d MHz",
+			    freq / 1000, freq % 1000);
+			const unsigned l3_div =
+			    pio_read_32(&device->cm.core->clksel)
+			    & CORE_CM_CLKSEL_CLKSEL_L3_MASK;
+			if (l3_div == CORE_CM_CLKSEL_CLKSEL_L3_DIVIDED1 ||
+			    l3_div == CORE_CM_CLKSEL_CLKSEL_L3_DIVIDED2) {
+				ddf_msg(LVL_NOTE, "L3 interface at %d.%d MHz",
+				    (freq / l3_div) / 1000,
+				    (freq / l3_div) % 1000);
+			} else {
+				ddf_msg(LVL_WARN,"L3 interface clock divisor is"
+				    " invalid: %d", l3_div);
+			}
+		} else {
+			ddf_msg(LVL_WARN, "DPLL3 frequency divisor and/or "
+			    "multiplier value invalid: %d %d %d",
+			    multiplier, divisor, divisor2);
+		}
+	} else {
+		ddf_msg(LVL_WARN, "CORE CLK in bypass mode, fruunig at SYS_CLK"
+		   " frreq of %d.%d MHz", base_freq / 1000, base_freq % 1000);
+	}
+
+	/* Set DPLL3 to automatic to save power */
+	pio_change_32(&device->cm.clocks->autoidle_pll,
+	    CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_CORE_DPLL_AUTOMATIC,
+	    CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_CORE_DPLL_MASK, 5);
+
+	/* DPLL4 provides peripheral domain clocks:
+	 * CAM_MCLK, EMU_PER_ALWON_CLK, DSS1_ALWON_FCLK, and 96M_ALWON_FCLK.
+	 * It uses SYS_CLK as reference clock and low frequency bypass.
+	 * 96M clock is used by McBSP[1,5], MMC[1,2,3], I2C[1,2,3], so
+	 * we can probably turn this off entirely (DSS is still non-functional).
+	 */
+	/* Set DPLL4 to automatic to save power */
+	pio_change_32(&device->cm.clocks->autoidle_pll,
+	    CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_PERIPH_DPLL_AUTOMATIC,
+	    CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_PERIPH_DPLL_MASK, 5);
+
+	/* DPLL5 provide peripheral domain clocks: 120M_FCLK.
+	 * It uses SYS_CLK as reference clock and low frequency bypass.
+	 * 120M clock is used by HS USB and USB TLL.
+	 */
+	// TODO setup DPLL5
+	if ((pio_read_32(&device->cm.clocks->clken2_pll)
+	        & CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_MASK)
+	    != CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_LOCK) {
+		/* Compute divisors and multiplier
+		 * See AMDM37x TRM p. 300 for the formula */
+		// TODO: base_freq does not have to be rounded to Mhz
+		// (that's why I used KHz as unit).
+		const unsigned mult = 120;
+		const unsigned div = (base_freq / 1000) - 1;
+		const unsigned div2 = 1;
+		if ( ((base_freq % 1000) != 0) || (div > 127)) {
+			ddf_msg(LVL_ERROR, "Rounding error, or divisor to big "
+			    "freq: %d, div: %d", base_freq, div);
+			return;
+		};
+		assert(div <= 127);
+
+		/* Set multiplier */
+		pio_change_32(&device->cm.clocks->clksel4_pll,
+		    CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_MULT_CREATE(mult),
+		    CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_MULT_MASK, 10);
+
+		/* Set DPLL divisor */
+		pio_change_32(&device->cm.clocks->clksel4_pll,
+		    CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_DIV_CREATE(div),
+		    CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_DIV_MASK, 10);
+
+		/* Set output clock divisor */
+		pio_change_32(&device->cm.clocks->clksel5_pll,
+		    CLOCK_CONTROL_CM_CLKSEL5_PLL_DIV120M_CREATE(div2),
+		    CLOCK_CONTROL_CM_CLKSEL5_PLL_DIV120M_MASK, 10);
+
+		/* Start DPLL5 */
+		pio_change_32(&device->cm.clocks->clken2_pll,
+		    CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_LOCK,
+		    CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_MASK, 10);
+
+	}
+	/* Set DPLL5 to automatic to save power */
+	pio_change_32(&device->cm.clocks->autoidle2_pll,
+	    CLOCK_CONTROL_CM_AUTOIDLE2_PLL_AUTO_PERIPH2_DPLL_AUTOMATIC,
+	    CLOCK_CONTROL_CM_AUTOIDLE2_PLL_AUTO_PERIPH2_DPLL_MASK, 5);
+}
+
+/** Enable/disable function and interface clocks for USBTLL and USBHOST.
+ * @param device Register map.
+ * @param on True to switch clocks on.
+ */
+void amdm37x_usb_clocks_set(amdm37x_t *device, bool enabled)
+{
+	if (enabled) {
+		/* Enable interface and function clock for USB TLL */
+		pio_set_32(&device->cm.core->fclken3,
+		    CORE_CM_FCLKEN3_EN_USBTLL_FLAG, 5);
+		pio_set_32(&device->cm.core->iclken3,
+		    CORE_CM_ICLKEN3_EN_USBTLL_FLAG, 5);
+
+		/* Enable interface and function clock for USB hosts */
+		pio_set_32(&device->cm.usbhost->fclken,
+		    USBHOST_CM_FCLKEN_EN_USBHOST1_FLAG |
+		    USBHOST_CM_FCLKEN_EN_USBHOST2_FLAG, 5);
+		pio_set_32(&device->cm.usbhost->iclken,
+		    USBHOST_CM_ICLKEN_EN_USBHOST, 5);
+#if 0
+		printf("DPLL5 (and everything else) should be on: %"
+		    PRIx32" %"PRIx32".\n",
+		    pio_read_32(&device->cm.clocks->idlest_ckgen),
+		    pio_read_32(&device->cm.clocks->idlest2_ckgen));
+#endif
+	} else {
+		/* Disable interface and function clock for USB hosts */
+		pio_clear_32(&device->cm.usbhost->iclken,
+		    USBHOST_CM_ICLKEN_EN_USBHOST, 5);
+		pio_clear_32(&device->cm.usbhost->fclken,
+		    USBHOST_CM_FCLKEN_EN_USBHOST1_FLAG |
+		    USBHOST_CM_FCLKEN_EN_USBHOST2_FLAG, 5);
+
+		/* Disable interface and function clock for USB TLL */
+		pio_clear_32(&device->cm.core->iclken3,
+		    CORE_CM_ICLKEN3_EN_USBTLL_FLAG, 5);
+		pio_clear_32(&device->cm.core->fclken3,
+		    CORE_CM_FCLKEN3_EN_USBTLL_FLAG, 5);
+	}
+}
+
+/** Initialize USB TLL port connections.
+ *
+ * Different modes are on page 3312 of the Manual Figure 22-34.
+ * Select mode than can operate in FS/LS.
+ */
+int amdm37x_usb_tll_init(amdm37x_t *device)
+{
+	/* Check access */
+	if (pio_read_32(&device->cm.core->idlest3) & CORE_CM_IDLEST3_ST_USBTLL_FLAG) {
+		ddf_msg(LVL_ERROR, "USB TLL is not accessible");
+		return EIO;
+	}
+
+	/* Reset USB TLL */
+	pio_set_32(&device->tll->sysconfig, TLL_SYSCONFIG_SOFTRESET_FLAG, 5);
+	ddf_msg(LVL_DEBUG2, "Waiting for USB TLL reset");
+	while (!(pio_read_32(&device->tll->sysstatus) & TLL_SYSSTATUS_RESET_DONE_FLAG));
+	ddf_msg(LVL_DEBUG, "USB TLL Reset done.");
+
+	/* Setup idle mode (smart idle) */
+	pio_change_32(&device->tll->sysconfig,
+	    TLL_SYSCONFIG_CLOCKACTIVITY_FLAG | TLL_SYSCONFIG_AUTOIDLE_FLAG |
+	    TLL_SYSCONFIG_SIDLE_MODE_SMART, TLL_SYSCONFIG_SIDLE_MODE_MASK, 5);
+
+	/* Smart idle for UHH */
+	pio_change_32(&device->uhh->sysconfig,
+	    UHH_SYSCONFIG_CLOCKACTIVITY_FLAG | UHH_SYSCONFIG_AUTOIDLE_FLAG |
+	    UHH_SYSCONFIG_SIDLE_MODE_SMART, UHH_SYSCONFIG_SIDLE_MODE_MASK, 5);
+
+	/* Set all ports to go through TLL(UTMI)
+	 * Direct connection can only work in HS mode */
+	pio_set_32(&device->uhh->hostconfig,
+	    UHH_HOSTCONFIG_P1_ULPI_BYPASS_FLAG |
+	    UHH_HOSTCONFIG_P2_ULPI_BYPASS_FLAG |
+	    UHH_HOSTCONFIG_P3_ULPI_BYPASS_FLAG, 5);
+
+	/* What is this? */
+	pio_set_32(&device->tll->shared_conf, TLL_SHARED_CONF_FCLK_IS_ON_FLAG, 5);
+
+	for (unsigned i = 0; i < 3; ++i) {
+		/* Serial mode is the only one capable of FS/LS operation.
+		 * Select FS/LS mode, no idea what the difference is
+		 * one of bidirectional modes might be good choice
+		 * 2 = 3pin bidi phy. */
+		pio_change_32(&device->tll->channel_conf[i],
+		    TLL_CHANNEL_CONF_CHANMODE_UTMI_SERIAL_MODE |
+		    TLL_CHANNEL_CONF_FSLSMODE_3PIN_BIDI_PHY,
+		    TLL_CHANNEL_CONF_CHANMODE_MASK |
+		    TLL_CHANNEL_CONF_FSLSMODE_MASK, 5);
+	}
+	return EOK;
+}
Index: uspace/drv/infrastructure/rootamdm37x/amdm37x.h
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/amdm37x.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
+++ uspace/drv/infrastructure/rootamdm37x/amdm37x.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup amdm37xdrv
+ * @{
+ */
+/** @file
+ * @brief AM/DM 37x device.
+ */
+#ifndef AMDM37x_H
+#define AMDM37x_H
+
+#include "uhh.h"
+#include "usbtll.h"
+
+#include "cm/core.h"
+#include "cm/clock_control.h"
+#include "cm/usbhost.h"
+#include "cm/mpu.h"
+#include "cm/iva2.h"
+
+#include "prm/clock_control.h"
+#include "prm/global_reg.h"
+
+#include <bool.h>
+
+typedef struct {
+	uhh_regs_t *uhh;
+	tll_regs_t *tll;
+	struct {
+		mpu_cm_regs_t *mpu;
+		iva2_cm_regs_t *iva2;
+		core_cm_regs_t *core;
+		clock_control_cm_regs_t *clocks;
+		usbhost_cm_regs_t *usbhost;
+	} cm;
+	struct {
+		clock_control_prm_regs_t *clocks;
+		global_reg_prm_regs_t *global;
+	} prm;
+} amdm37x_t;
+
+int amdm37x_init(amdm37x_t *device, bool trace_io);
+int amdm37x_usb_tll_init(amdm37x_t *device);
+void amdm37x_setup_dpll_on_autoidle(amdm37x_t *device);
+void amdm37x_usb_clocks_set(amdm37x_t *device, bool enabled);
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/infrastructure/rootamdm37x/cm/clock_control.h
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/cm/clock_control.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
+++ uspace/drv/infrastructure/rootamdm37x/cm/clock_control.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -0,0 +1,161 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup amdm37xdrvclockcontrolcm
+ * @{
+ */
+/** @file
+ * @brief Clock Control Clock Management IO register structure.
+ */
+#ifndef AMDM37x_CLOCK_CONTROL_CM_H
+#define AMDM37x_CLOCK_CONTROL_CM_H
+#include <sys/types.h>
+#include <macros.h>
+
+/* AM/DM37x TRM p.485 */
+#define CLOCK_CONTROL_CM_BASE_ADDRESS  0x48004d00
+#define CLOCK_CONTROL_CM_SIZE  8192
+
+/** Clock control register map
+ *
+ * Periph DPLL == DPLL4
+ * Core DPLL == DPLL3
+ */
+typedef struct {
+	ioport32_t clken_pll;
+#define CLOCK_CONTROL_CM_CLKEN_PLL_PWRDN_EMU_PERIPH_FLAG   (1 << 31)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_PWRDN_CAM_FLAG   (1 << 30)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_PWRDN_DSS1_FLAG   (1 << 29)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_PWRDN_TV_FLAG   (1 << 28)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_PWRDN_96M_FLAG   (1 << 27)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_PERIPH_DPLL_DRIFTGUARD_FLAG   (1 << 19)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_PERIPH_DPLL_MASK   (0x7 << 16)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_PERIPH_DPLL_LP_STOP   (0x1 << 16)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_PERIPH_DPLL_LOCK   (0x7 << 16)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_PWRDN_EMU_CORE_FLAG   (1 << 12)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_CORE_DPLL_LPMODE_FLAG   (1 << 10)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_CORE_DPLL_DRIFTGUARD_FLAG   (1 << 3)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_CORE_DPLL_MASK   (0x7)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_CORE_DPLL_LP_BYPASS   (0x5)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_CORE_DPLL_FAST_RELOCK   (0x6)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_CORE_DPLL_LOCK   (0x7)
+
+	ioport32_t clken2_pll;
+#define CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_LPMODE_FLAG   (1 << 10)
+#define CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_DRIFTGUARD_FLAG   (1 << 3)
+#define CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_MASK   (0x7)
+#define CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_LP_STOP   (0x1)
+#define CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_LOCK   (0x7)
+
+	PADD32[6];
+
+	const ioport32_t idlest_ckgen;
+#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_EMU_PERIPH_CLK_FLAG   (1 << 13)
+#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_CAM_CLK_FLAG   (1 << 12)
+#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_DSS1_CLK_FLAG   (1 << 11)
+#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_TV_CLK_FLAG   (1 << 10)
+#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_FUNC96M_CLK_FLAG   (1 << 9)
+#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_EMU_CORE_CLK_FLAG   (1 << 8)
+#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_54M_CLK_FLAG   (1 << 5)
+#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_12M_CLK_FLAG   (1 << 4)
+#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_48M_CLK_FLAG   (1 << 3)
+#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_96M_CLK_FLAG   (1 << 2)
+#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_PERIPH_CLK_FLAG   (1 << 1)
+#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_CORE_CLK_FLAG   (1 << 0)
+
+	const ioport32_t idlest2_ckgen;
+#define CLOCK_CONTROL_CM_IDLEST2_CKGEN_ST_FUNC120M_CLK_FLAG   (1 << 3)
+#define CLOCK_CONTROL_CM_IDLEST2_CKGEN_ST_120M_CLK_FLAG   (1 << 1)
+#define CLOCK_CONTROL_CM_IDLEST2_CKGEN_ST_PERIPH2_CLK_FLAG   (1 << 0)
+
+	PADD32[2];
+
+	ioport32_t autoidle_pll;
+#define CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_PERIPH_DPLL_MASK   (0x7 << 3)
+#define CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_PERIPH_DPLL_DISABLED   (0x0 << 3)
+#define CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_PERIPH_DPLL_AUTOMATIC   (0x1 << 3)
+#define CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_CORE_DPLL_MASK   (0x7)
+#define CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_CORE_DPLL_DISABLED   (0x0)
+#define CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_CORE_DPLL_AUTOMATIC   (0x1)
+#define CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_CORE_DPLL_AUTOMATIC_BYPASS   (0x5)
+
+	ioport32_t autoidle2_pll;
+#define CLOCK_CONTROL_CM_AUTOIDLE2_PLL_AUTO_PERIPH2_DPLL_MASK   (0x7)
+#define CLOCK_CONTROL_CM_AUTOIDLE2_PLL_AUTO_PERIPH2_DPLL_DISABLED   (0x0)
+#define CLOCK_CONTROL_CM_AUTOIDLE2_PLL_AUTO_PERIPH2_DPLL_AUTOMATIC   (0x1)
+
+	PADD32[2];
+
+	ioport32_t clksel1_pll;
+#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_CLKOUT_DIV_MASK   (0x1f << 27)
+#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_CLKOUT_DIV_CREATE(x)   (((x) & 0x1f) << 27)
+#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_CLKOUT_DIV_GET(x)   (((x) >> 27) & 0x1f)
+#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_MULT_MASK   (0x7ff << 16)
+#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_MULT_CREATE(x)   (((x) & 0x7ff) << 16)
+#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_MULT_GET(x)   (((x) >> 16) & 0x7ff)
+#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_DIV_MASK   (0x7f << 8)
+#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_DIV_CREATE(x)   (((x) & 0x7f) << 8)
+#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_DIV_GET(x)   (((x) >> 8) & 0x7f)
+#define CLOCK_CONTROL_CM_CLKSEL1_PLL_SOURCE_96M_FLAG   (1 << 6)
+#define CLOCK_CONTROL_CM_CLKSEL1_PLL_SOURCE_54M_FLAG   (1 << 5)
+#define CLOCK_CONTROL_CM_CLKSEL1_PLL_SOURCE_48M_FLAG   (1 << 3)
+
+	ioport32_t clksel2_pll;
+#define CLOCK_CONTROL_CM_CLKSEL2_PLL_SD_DIV_MASK   (0xff << 24)
+#define CLOCK_CONTROL_CM_CLKSEL2_PLL_SD_DIV_(x)   (((x) & 0xff) << 24)
+#define CLOCK_CONTROL_CM_CLKSEL2_PLL_DCO_SEL_MASK   (0x7 << 21)
+#define CLOCK_CONTROL_CM_CLKSEL2_PLL_DCO_SEL_500   (0x2 << 21)
+#define CLOCK_CONTROL_CM_CLKSEL2_PLL_DCO_SEL_1000   (0x4 << 21)
+#define CLOCK_CONTROL_CM_CLKSEL2_PLL_PERIPH_DPLL_MULT_MASK   (0xfff << 8)
+#define CLOCK_CONTROL_CM_CLKSEL2_PLL_PERIPH_DPLL_MULT(x)   (((x) & 0xfff) << 8)
+#define CLOCK_CONTROL_CM_CLKSEL2_PLL_PERIPH_DPLL_DIV_MASK   (0x7f)
+#define CLOCK_CONTROL_CM_CLKSEL2_PLL_PERIPH_DPLL_DIV(x)   ((x) & 0x7f)
+
+	ioport32_t clksel3_pll;
+#define CLOCK_CONTROL_CM_CLKSEL3_PLL_DIV_96M_MASK   (0xf)
+#define CLOCK_CONTROL_CM_CLKSEL3_PLL_DIV_96M(x)   ((x) & 0xf)
+
+	ioport32_t clksel4_pll;
+#define CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_MULT_MASK   (0x7ff << 8)
+#define CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_MULT_CREATE(x)   (((x) & 0x7ff) << 8)
+#define CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_MULT_GET(x)   (((x) >> 8) & 0x7ff)
+#define CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_DIV_MASK   (0x7f)
+#define CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_DIV_CREATE(x)   ((x) & 0x7f)
+#define CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_DIV_GET(x)   ((x) & 0x7f)
+
+	ioport32_t clksel5_pll;
+#define CLOCK_CONTROL_CM_CLKSEL5_PLL_DIV120M_MASK   (0x1f)
+#define CLOCK_CONTROL_CM_CLKSEL5_PLL_DIV120M_CREATE(x)   ((x) & 0x1f)
+#define CLOCK_CONTROL_CM_CLKSEL5_PLL_DIV120M_GET(x)   ((x) & 0x1f)
+} clock_control_cm_regs_t;
+
+#endif
+/**
+ * @}
+ */
+
Index: uspace/drv/infrastructure/rootamdm37x/cm/core.h
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/cm/core.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
+++ uspace/drv/infrastructure/rootamdm37x/cm/core.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -0,0 +1,188 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup amdm37xdrvcorecm
+ * @{
+ */
+/** @file
+ * @brief CORE Clock Management IO register structure.
+ */
+#ifndef AMDM37x_CORE_CM_H
+#define AMDM37x_CORE_CM_H
+#include <sys/types.h>
+#include <macros.h>
+
+/* AM/DM37x TRM p.447 */
+#define CORE_CM_BASE_ADDRESS  0x48004a00
+#define CORE_CM_SIZE  8192
+
+typedef struct {
+	ioport32_t fclken1;
+#define CORE_CM_FCLKEN1_EN_MCBSP1_FLAG  (1 << 9)
+#define CORE_CM_FCLKEN1_EN_MCBSP5_FLAG  (1 << 10)
+#define CORE_CM_FCLKEN1_EN_GPT10_FLAG  (1 << 11)
+#define CORE_CM_FCLKEN1_EN_GPT11_FLAG  (1 << 12)
+#define CORE_CM_FCLKEN1_EN_UART1_FLAG  (1 << 13)
+#define CORE_CM_FCLKEN1_EN_UART2_FLAG  (1 << 14)
+#define CORE_CM_FCLKEN1_EN_I2C1_FLAG  (1 << 15)
+#define CORE_CM_FCLKEN1_EN_I2C2_FLAG  (1 << 16)
+#define CORE_CM_FCLKEN1_EN_I2C3_FLAG  (1 << 17)
+#define CORE_CM_FCLKEN1_EN_MCSPI1_FLAG  (1 << 18)
+#define CORE_CM_FCLKEN1_EN_MCSPI2_FLAG  (1 << 19)
+#define CORE_CM_FCLKEN1_EN_MCSPI3_FLAG  (1 << 20)
+#define CORE_CM_FCLKEN1_EN_MCSPI4_FLAG  (1 << 21)
+#define CORE_CM_FCLKEN1_EN_HDQ_FLAG  (1 << 22)
+#define CORE_CM_FCLKEN1_EN_MMC1_FLAG  (1 << 24)
+#define CORE_CM_FCLKEN1_EN_MMC2_FLAG  (1 << 25)
+#define CORE_CM_FCLKEN1_EN_MMC3_FLAG  (1 << 30)
+
+	PADD32;
+	ioport32_t fclken3;
+#define CORE_CM_FCLKEN3_EN_TS_FLAG  (1 << 1)
+#define CORE_CM_FCLKEN3_EN_USBTLL_FLAG  (1 << 2)
+
+	PADD32;
+	ioport32_t iclken1;
+#define CORE_CM_ICLKEN1_EN_SDRC_FLAG  (1 << 1)
+#define CORE_CM_ICLKEN1_EN_HSOTGUSB_FLAG  (1 << 4)
+#define CORE_CM_ICLKEN1_EN_SCMCTRL_FLAG  (1 << 6)
+#define CORE_CM_ICLKEN1_EN_MAILBOXES_FLAG  (1 << 7)
+#define CORE_CM_ICLKEN1_EN_MCBSP1_FLAG  (1 << 9)
+#define CORE_CM_ICLKEN1_EN_MCBSP5_FLAG  (1 << 10)
+#define CORE_CM_ICLKEN1_EN_GPT10_FLAG  (1 << 11)
+#define CORE_CM_ICLKEN1_EN_GPT11_FLAG  (1 << 12)
+#define CORE_CM_ICLKEN1_EN_UART1_FLAG  (1 << 13)
+#define CORE_CM_ICLKEN1_EN_UART2_FLAG  (1 << 14)
+#define CORE_CM_ICLKEN1_EN_I2C1_FLAG  (1 << 15)
+#define CORE_CM_ICLKEN1_EN_I2C2_FLAG  (1 << 16)
+#define CORE_CM_ICLKEN1_EN_I2C3_FLAG  (1 << 17)
+#define CORE_CM_ICLKEN1_EN_MCSPI1_FLAG  (1 << 18)
+#define CORE_CM_ICLKEN1_EN_MCSPI2_FLAG  (1 << 19)
+#define CORE_CM_ICLKEN1_EN_MCSPI3_FLAG  (1 << 20)
+#define CORE_CM_ICLKEN1_EN_MCSPI4_FLAG  (1 << 21)
+#define CORE_CM_ICLKEN1_EN_HDQ_FLAG  (1 << 22)
+#define CORE_CM_ICLKEN1_EN_MMC1_FLAG  (1 << 24)
+#define CORE_CM_ICLKEN1_EN_MMC2_FLAG  (1 << 25)
+#define CORE_CM_ICLKEN1_EN_ICR_FLAG  (1 << 29)
+#define CORE_CM_ICLKEN1_EN_MMC3_FLAG  (1 << 30)
+
+	ioport32_t reserved1;
+	ioport32_t iclken3;
+#define CORE_CM_ICLKEN3_EN_USBTLL_FLAG  (1 << 2)
+
+	PADD32;
+	const ioport32_t idlest1;
+#define CORE_CM_IDLEST1_ST_SDRC_FLAG  (1 << 1)
+#define CORE_CM_IDLEST1_ST_SDMA_FLAG  (1 << 2)
+#define CORE_CM_IDLEST1_ST_HSOTGUSB_STBY_FLAG  (1 << 4)
+#define CORE_CM_IDLEST1_ST_HSOTGUSB_IDLE_FLAG  (1 << 5)
+#define CORE_CM_IDLEST1_ST_SCMCTRL_FLAG  (1 << 6)
+#define CORE_CM_IDLEST1_ST_MAILBOXES_FLAG  (1 << 7)
+#define CORE_CM_IDLEST1_ST_MCBSP1_FLAG  (1 << 9)
+#define CORE_CM_IDLEST1_ST_MCBSP5_FLAG  (1 << 10)
+#define CORE_CM_IDLEST1_ST_GPT10_FLAG  (1 << 11)
+#define CORE_CM_IDLEST1_ST_GPT11_FLAG  (1 << 12)
+#define CORE_CM_IDLEST1_ST_UART1_FLAG  (1 << 13)
+#define CORE_CM_IDLEST1_ST_UART2_FLAG  (1 << 14)
+#define CORE_CM_IDLEST1_ST_I2C1_FLAG  (1 << 15)
+#define CORE_CM_IDLEST1_ST_I2C2_FLAG  (1 << 16)
+#define CORE_CM_IDLEST1_ST_I2C3_FLAG  (1 << 17)
+#define CORE_CM_IDLEST1_ST_MCSPI1_FLAG  (1 << 18)
+#define CORE_CM_IDLEST1_ST_MCSPI2_FLAG  (1 << 19)
+#define CORE_CM_IDLEST1_ST_MCSPI3_FLAG  (1 << 20)
+#define CORE_CM_IDLEST1_ST_MCSPI4_FLAG  (1 << 21)
+#define CORE_CM_IDLEST1_ST_HDQ_FLAG  (1 << 22)
+#define CORE_CM_IDLEST1_ST_MMC1_FLAG  (1 << 24)
+#define CORE_CM_IDLEST1_ST_MMC2_FLAG  (1 << 25)
+#define CORE_CM_IDLEST1_ST_ICR_FLAG  (1 << 29)
+#define CORE_CM_IDLEST1_ST_MMC3_FLAG  (1 << 30)
+
+	const ioport32_t reserved2;
+	const ioport32_t idlest3;
+#define CORE_CM_IDLEST3_ST_USBTLL_FLAG  (1 << 2)
+
+	PADD32;
+	ioport32_t autoidle1;
+#define CORE_CM_AUTOIDLE1_AUTO_HSOTGUSB_FLAG  (1 << 4)
+#define CORE_CM_AUTOIDLE1_AUTO_SCMCTRL_FLAG  (1 << 6)
+#define CORE_CM_AUTOIDLE1_AUTO_MAILBOXES_FLAG  (1 << 7)
+#define CORE_CM_AUTOIDLE1_AUTO_MCBSP1_FLAG  (1 << 9)
+#define CORE_CM_AUTOIDLE1_AUTO_MCBSP5_FLAG  (1 << 10)
+#define CORE_CM_AUTOIDLE1_AUTO_GPT10_FLAG  (1 << 11)
+#define CORE_CM_AUTOIDLE1_AUTO_GPT11_FLAG  (1 << 12)
+#define CORE_CM_AUTOIDLE1_AUTO_UART1_FLAG  (1 << 13)
+#define CORE_CM_AUTOIDLE1_AUTO_UART2_FLAG  (1 << 14)
+#define CORE_CM_AUTOIDLE1_AUTO_I2C1_FLAG  (1 << 15)
+#define CORE_CM_AUTOIDLE1_AUTO_I2C2_FLAG  (1 << 16)
+#define CORE_CM_AUTOIDLE1_AUTO_I2C3_FLAG  (1 << 17)
+#define CORE_CM_AUTOIDLE1_AUTO_MCSPI1_FLAG  (1 << 18)
+#define CORE_CM_AUTOIDLE1_AUTO_MCSPI2_FLAG  (1 << 19)
+#define CORE_CM_AUTOIDLE1_AUTO_MCSPI3_FLAG  (1 << 20)
+#define CORE_CM_AUTOIDLE1_AUTO_MCSPI4_FLAG  (1 << 21)
+#define CORE_CM_AUTOIDLE1_AUTO_HDQ_FLAG  (1 << 22)
+#define CORE_CM_AUTOIDLE1_AUTO_MMC1_FLAG  (1 << 24)
+#define CORE_CM_AUTOIDLE1_AUTO_MMC2_FLAG  (1 << 25)
+#define CORE_CM_AUTOIDLE1_AUTO_ICR_FLAG  (1 << 29)
+#define CORE_CM_AUTOIDLE1_AUTO_MMC3_FLAG  (1 << 30)
+
+	ioport32_t reserved3;
+	ioport32_t autoidle3;
+#define CORE_CM_AUTOIDLE3_AUTO_USBTLL_FLAG  (1 << 2)
+
+	PADD32;
+	ioport32_t clksel;
+#define CORE_CM_CLKSEL_CLKSEL_L3_MASK  (0x3 << 0)
+#define CORE_CM_CLKSEL_CLKSEL_L3_DIVIDED1  (0x1 << 0)
+#define CORE_CM_CLKSEL_CLKSEL_L3_DIVIDED2  (0x2 << 0)
+#define CORE_CM_CLKSEL_CLKSEL_L4_MASK  (0x3 << 2)
+#define CORE_CM_CLKSEL_CLKSEL_L4_DIVIDED1  (0x1 << 2)
+#define CORE_CM_CLKSEL_CLKSEL_L4_DIVIDED2  (0x2 << 2)
+#define CORE_CM_CLKSEL_CLKSEL_96M_MASK  (0x3 << 12)
+#define CORE_CM_CLKSEL_CLKSEL_96M_DIVIDED1  (0x1 << 12)
+#define CORE_CM_CLKSEL_CLKSEL_96M_DIVIDED2  (0x2 << 12)
+#define CORE_CM_CLKSEL_CLKSEL_GPT10_FLAG (1 << 6)
+#define CORE_CM_CLKSEL_CLKSEL_GPT11_FLAG (1 << 7)
+
+	PADD32;
+	ioport32_t clkstctrl;
+#define CORE_CM_CLKCTRL_CLKCTRL_L3_MASK  (0x3 << 0)
+#define CORE_CM_CLKCTRL_CLKCTRL_L3_AUTO_EN  (0x0 << 0)
+#define CORE_CM_CLKCTRL_CLKCTRL_L3_AUTO_DIS  (0x3 << 0)
+#define CORE_CM_CLKCTRL_CLKCTRL_L4_MASK  (0x3 << 2)
+#define CORE_CM_CLKCTRL_CLKCTRL_L4_AUTO_EN  (0x0 << 2)
+#define CORE_CM_CLKCTRL_CLKCTRL_L4_AUTO_DIS  (0x3 << 2)
+
+	const ioport32_t clkstst;
+#define CORE_CM_CLKSTST_CLKACTIVITY_L3_FLAG  (1 << 0)
+#define CORE_CM_CLKSTST_CLKACTIVITY_L4_FLAG  (1 << 1)
+} core_cm_regs_t;
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/infrastructure/rootamdm37x/cm/iva2.h
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/cm/iva2.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
+++ uspace/drv/infrastructure/rootamdm37x/cm/iva2.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -0,0 +1,101 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup amdm37xdrvcm
+ * @{
+ */
+/** @file
+ * @brief MPU Clock Management IO register structure.
+ */
+#ifndef AMDM37x_IVA2_CM_H
+#define AMDM37x_IVA2_CM_H
+#include <sys/types.h>
+#include <macros.h>
+
+/* AM/DM37x TRM p.446 */
+#define IVA2_CM_BASE_ADDRESS  0x48004000
+#define IVA2_CM_SIZE  8192
+
+typedef struct {
+	ioport32_t fclken;
+#define IVA2_CM_FCLKEN_EN_IVA2_FLAG   (1 << 0)
+
+	ioport32_t clken_pll;
+#define IVA2_CM_CLKEN_PLL_EN_IVA2_DPLL_LP_MODE_FLAG   (1 << 10)
+#define IVA2_CM_CLKEN_PLL_EN_IVA2_DPLL_DRIFTGUARD   (1 << 3)
+#define IVA2_CM_CLKEN_PLL_EN_IVA2_DPLL_EN_IVA2_DPLL_MASK   (0x7)
+#define IVA2_CM_CLKEN_PLL_EN_IVA2_DPLL_EN_IVA2_DPLL_LP_STOP   (0x1)
+#define IVA2_CM_CLKEN_PLL_EN_IVA2_DPLL_EN_IVA2_DPLL_LP_BYPASS   (0x5)
+#define IVA2_CM_CLKEN_PLL_EN_IVA2_DPLL_EN_IVA2_DPLL_LOCKED   (0x7)
+
+	PADD32[6];
+	const ioport32_t idlest;
+#define IVA2_CM_IDLEST_ST_IVA2_STANDBY_FLAG   (1 << 0)
+
+	const ioport32_t idlest_pll;
+#define IVA2_CM_IDLEST_PLL_ST_IVA2_CLK_LOCKED_FLAG   (1 << 0)
+
+	PADD32[3];
+	ioport32_t autoidle_pll;
+#define IVA2_CM_AUTOIDLE_PLL_AUTO_IVA2_DPLL_MASK   (0x7)
+#define IVA2_CM_AUTOIDLE_PLL_AUTO_IVA2_DPLL_DISABLED   (0x0)
+#define IVA2_CM_AUTOIDLE_PLL_AUTO_IVA2_DPLL_ENABLED   (0x1)
+
+	PADD32[2];
+	ioport32_t clksel1_pll;
+#define IVA2_CM_CLKSEL1_PLL_IVA2_CLK_SRC_MASK   (0x7 << 19)
+#define IVA2_CM_CLKSEL1_PLL_IVA2_CLK_SRC_SHIFT   (19)
+#define IVA2_CM_CLKSEL1_PLL_IVA2_CLK_SRC_VAL(x)   ((x >> 19) & 0x7)
+#define IVA2_CM_CLKSEL1_PLL_IVA2_CLK_SRC_CORE_DIV_1   (0x1 << 19)
+#define IVA2_CM_CLKSEL1_PLL_IVA2_CLK_SRC_CORE_DIV_2   (0x2 << 19)
+#define IVA2_CM_CLKSEL1_PLL_IVA2_CLK_SRC_CORE_DIV_4   (0x4 << 19)
+#define IVA2_CM_CLKSEL1_PLL_IVA2_DPLL_MULT_MASK   (0x7ff << 8)
+#define IVA2_CM_CLKSEL1_PLL_IVA2_DPLL_MULT_SHIFT   (8)
+#define IVA2_CM_CLKSEL1_PLL_IVA2_DPLL_DIV_MASK  (0x7f << 0)
+#define IVA2_CM_CLKSEL1_PLL_IVA2_DPLL_DIV_SHIFT  (0)
+
+	ioport32_t clksel2_pll;
+#define IVA2_CM_CLKSEL2_PLL_IVA2_DPLL_CLKOUT_DIV_MASK   (0x1f)
+
+	ioport32_t clkstctrl;
+#define IVA2_CM_CLKSCTRL_CLKTRCTRL_IVA2_MASK   (0x3)
+#define IVA2_CM_CLKSCTRL_CLKTRCTRL_IVA2_DISABLED   (0x0)
+#define IVA2_CM_CLKSCTRL_CLKTRCTRL_IVA2_START_SLEEP   (0x2)
+#define IVA2_CM_CLKSCTRL_CLKTRCTRL_IVA2_START_WAKEUP   (0x2)
+#define IVA2_CM_CLKSCTRL_CLKTRCTRL_IVA2_AUTOMATIC   (0x3)
+
+	const ioport32_t clkstst;
+#define IVA2_CM_CLKSTST_CLKACTIVITY_IVA2_ACTIVE_FLAG   (1 << 0)
+
+} iva2_cm_regs_t;
+
+#endif
+/**
+ * @}
+ */
+
Index: uspace/drv/infrastructure/rootamdm37x/cm/mpu.h
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/cm/mpu.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
+++ uspace/drv/infrastructure/rootamdm37x/cm/mpu.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -0,0 +1,97 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup amdm37xdrvcm
+ * @{
+ */
+/** @file
+ * @brief MPU Clock Management IO register structure.
+ */
+#ifndef AMDM37x_MPU_CM_H
+#define AMDM37x_MPU_CM_H
+#include <sys/types.h>
+#include <macros.h>
+
+/* AM/DM37x TRM p.455 */
+#define MPU_CM_BASE_ADDRESS  0x48004900
+#define MPU_CM_SIZE  8192
+
+typedef struct {
+	PADD32;
+	ioport32_t clken_pll;
+#define MPU_CM_CLKEN_PLL_EN_MPU_DPLL_LP_MODE_FLAG   (1 << 10)
+#define MPU_CM_CLKEN_PLL_EN_MPU_DPLL_DRIFTGUARD   (1 << 3)
+#define MPU_CM_CLKEN_PLL_EN_MPU_DPLL_EN_MPU_DPLL_MASK   (0x7)
+#define MPU_CM_CLKEN_PLL_EN_MPU_DPLL_EN_MPU_DPLL_LP_BYPASS   (0x5)
+#define MPU_CM_CLKEN_PLL_EN_MPU_DPLL_EN_MPU_DPLL_LOCKED   (0x7)
+
+	PADD32[6];
+	const ioport32_t idlest;
+#define MPU_CM_IDLEST_ST_MPU_STANDBY_FLAG   (1 << 0)
+
+	const ioport32_t idlest_pll;
+#define MPU_CM_IDLEST_PLL_ST_MPU_CLK_LOCKED_FLAG   (1 << 0)
+
+	PADD32[3];
+	ioport32_t autoidle_pll;
+#define MPU_CM_AUTOIDLE_PLL_AUTO_MPU_DPLL_MASK   (0x7)
+#define MPU_CM_AUTOIDLE_PLL_AUTO_MPU_DPLL_DISABLED   (0x0)
+#define MPU_CM_AUTOIDLE_PLL_AUTO_MPU_DPLL_ENABLED   (0x1)
+
+	PADD32[2];
+	ioport32_t clksel1_pll;
+#define MPU_CM_CLKSEL1_PLL_MPU_CLK_SRC_MASK   (0x7 << 19)
+#define MPU_CM_CLKSEL1_PLL_MPU_CLK_SRC_SHIFT   (19)
+#define MPU_CM_CLKSEL1_PLL_MPU_CLK_SRC_VAL(x)   ((x >> 19) & 0x7)
+#define MPU_CM_CLKSEL1_PLL_MPU_CLK_SRC_CORE_DIV_1   (0x1 << 19)
+#define MPU_CM_CLKSEL1_PLL_MPU_CLK_SRC_CORE_DIV_2   (0x2 << 19)
+#define MPU_CM_CLKSEL1_PLL_MPU_CLK_SRC_CORE_DIV_4   (0x4 << 19)
+#define MPU_CM_CLKSEL1_PLL_MPU_DPLL_MULT_MASK   (0x7ff << 8)
+#define MPU_CM_CLKSEL1_PLL_MPU_DPLL_MULT_SHIFT   (8)
+#define MPU_CM_CLKSEL1_PLL_MPU_DPLL_DIV_MASK  (0x7f << 0)
+#define MPU_CM_CLKSEL1_PLL_MPU_DPLL_DIV_SHIFT  (0)
+
+	ioport32_t clksel2_pll;
+#define MPU_CM_CLKSEL2_PLL_MPU_DPLL_CLKOUT_DIV_MASK   (0x1f)
+
+	ioport32_t clkstctrl;
+#define MPU_CM_CLKSCTRL_CLKTRCTRL_MPU_MASK   (0x3)
+#define MPU_CM_CLKSCTRL_CLKTRCTRL_MPU_DISABLED   (0x0)
+#define MPU_CM_CLKSCTRL_CLKTRCTRL_MPU_START_WAKEUP   (0x2)
+#define MPU_CM_CLKSCTRL_CLKTRCTRL_MPU_AUTOMATIC   (0x3)
+
+	const ioport32_t clkstst;
+#define MPU_CM_CLKSTST_CLKACTIVITY_MPU_ACTIVE_FLAG   (1 << 0)
+
+} mpu_cm_regs_t;
+
+#endif
+/**
+ * @}
+ */
+
Index: uspace/drv/infrastructure/rootamdm37x/cm/usbhost.h
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/cm/usbhost.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
+++ uspace/drv/infrastructure/rootamdm37x/cm/usbhost.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -0,0 +1,82 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup amdm37xdrvusbhostcm
+ * @{
+ */
+/** @file
+ * @brief USBHOST Clock Management IO register structure.
+ */
+#ifndef AMDM37x_USBHOST_CM_H
+#define AMDM37x_USBHOST_CM_H
+#include <macros.h>
+#include <sys/types.h>
+
+/* AM/DM37x TRM p.447 */
+#define USBHOST_CM_BASE_ADDRESS  0x48005400
+#define USBHOST_CM_SIZE  8192
+
+typedef struct {
+	ioport32_t fclken;
+#define USBHOST_CM_FCLKEN_EN_USBHOST1_FLAG  (1 << 0)
+#define USBHOST_CM_FCLKEN_EN_USBHOST2_FLAG  (1 << 1)
+
+	PADD32[3];
+	ioport32_t iclken;
+#define USBHOST_CM_ICLKEN_EN_USBHOST  (1 << 0)
+
+	PADD32[3];
+	const ioport32_t idlest;
+#define USBHOST_CM_IDLEST_ST_USBHOST_STDBY_FLAG  (1 << 0)
+#define USBHOST_CM_IDLEST_ST_USBHOST_IDLE_FLAG  (1 << 1)
+
+	PADD32[3];
+	ioport32_t autoidle;
+#define USBHOST_CM_AUTOIDLE_AUTO_USBHOST_FLAG  (1 << 0)
+
+	PADD32[4];
+	ioport32_t sleepdep;
+#define USBHOST_CM_SLEEPDEP_EN_MPU_FLAG  (1 << 1)
+#define USBHOST_CM_SLEEPDEP_EN_IVA2_FLAG  (1 << 2)
+
+	ioport32_t clkstctrl;
+#define USBHOST_CM_CLKSTCTRL_CLKSTCTRL_USBHOST_MASK  (0x3 << 0)
+#define USBHOST_CM_CLKSTCTRL_CLKSTCTRL_USBHOST_AUTO_DIS  (0x0 << 0)
+#define USBHOST_CM_CLKSTCTRL_CLKSTCTRL_USBHOST_SUPERVISED_SLEEP  (0x1 << 0)
+#define USBHOST_CM_CLKSTCTRL_CLKSTCTRL_USBHOST_SUPERVISED_WAKEUP  (0x2 << 0)
+#define USBHOST_CM_CLKSTCTRL_CLKSTCTRL_USBHOST_AUTO_EN  (0x3 << 0)
+
+	ioport32_t clkstst;
+#define USBHOST_CM_CLKSTCTRL_CLKSTST_CLKACTIVITY_USBHOST  (1 << 0)
+} usbhost_cm_regs_t;
+
+#endif
+/**
+ * @}
+ */
+
Index: uspace/drv/infrastructure/rootamdm37x/prm/clock_control.h
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/prm/clock_control.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
+++ uspace/drv/infrastructure/rootamdm37x/prm/clock_control.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup amdm37xdrvprm
+ * @{
+ */
+/** @file
+ * @brief Clock Control Clock Management IO register structure.
+ */
+#ifndef AMDM37X_PRM_CLOCK_CONTROL_H
+#define AMDM37X_PRM_CLOCK_CONTROL_H
+#include <sys/types.h>
+#include <macros.h>
+
+/* AM/DM37x TRM p.536 and p.589 */
+#define CLOCK_CONTROL_PRM_BASE_ADDRESS  0x48306d00
+#define CLOCK_CONTROL_PRM_SIZE  8192
+
+/** Clock control PRM register map
+ */
+typedef struct {
+	PADD32[16];
+	ioport32_t clksel;
+#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_MASK   (0x7)
+#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_12M   (0x0)
+#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_13M   (0x1)
+#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_19_2M   (0x2)
+#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_26M   (0x3)
+#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_38_4M   (0x4)
+#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_16_8M   (0x5)
+
+	PADD32[12];
+	ioport32_t clkout_ctrl;
+#define CLOCK_CONTROL_PRM_CLKOUT_CTRL_CLKOUOUT_EN_FLAG   (1 << 7)
+
+} clock_control_prm_regs_t;
+
+static inline unsigned sys_clk_freq_kHz(unsigned reg_val)
+{
+	switch(reg_val)
+	{
+	case CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_12M: return 12000;
+	case CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_13M: return 13000;
+	case CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_19_2M: return 19200;
+	case CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_26M: return 26000;
+	case CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_38_4M: return 38400;
+	case CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_16_8M: return 16800;
+	}
+	return 0;
+}
+
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/infrastructure/rootamdm37x/prm/global_reg.h
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/prm/global_reg.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
+++ uspace/drv/infrastructure/rootamdm37x/prm/global_reg.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -0,0 +1,300 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup amdm37xdrvprm
+ * @{
+ */
+/** @file
+ * @brief Clock Control Clock Management IO register structure.
+ */
+#ifndef AMDM37X_PRM_GLOBAL_REG_H
+#define AMDM37X_PRM_GLOBAL_REG_H
+#include <sys/types.h>
+#include <macros.h>
+
+/* AM/DM37x TRM p.536 and p.615 */
+#define GLOBAL_REG_PRM_BASE_ADDRESS  0x48307200
+#define GLOBAL_REG_PRM_SIZE  65536
+
+/** Global Reg PRM register map
+ */
+typedef struct {
+	PADD32[8];
+	struct {
+		ioport32_t smps_sa;
+#define GLOBAL_REG_PRM_VC_SMPS_SA_SA0_MASK   (0x7f << 0)
+#define GLOBAL_REG_PRM_VC_SMPS_SA_SA0_CREATE(x)   (((x) & 0x7f) << 0)
+#define GLOBAL_REG_PRM_VC_SMPS_SA_SA0_GET(r)   (r & 0x7f)
+#define GLOBAL_REG_PRM_VC_SMPS_SA_SA1_MASK   (0x7f << 16)
+#define GLOBAL_REG_PRM_VC_SMPS_SA_SA1_CREATE(x)   (((x) & 0x7f) << 16)
+#define GLOBAL_REG_PRM_VC_SMPS_SA_SA1_GET(r)   (((r) >> 16 ) & 0x7f)
+
+		ioport32_t smps_vol_ra;
+#define GLOBAL_REG_PRM_VC_SMPS_VOL_RA_VOLRA0_MASK   (0xff << 0)
+#define GLOBAL_REG_PRM_VC_SMPS_VOL_RA_VOLRA0_CREATE(x)   (((x) & 0xff) << 0)
+#define GLOBAL_REG_PRM_VC_SMPS_VOL_RA_VOLRA0_GET(r)   (r & 0xff)
+#define GLOBAL_REG_PRM_VC_SMPS_VOL_RA_VOLRA1_MASK   (0xff << 16)
+#define GLOBAL_REG_PRM_VC_SMPS_VOL_RA_VOLRA1_CREATE(x)   (((x) & 0xff) << 16)
+#define GLOBAL_REG_PRM_VC_SMPS_VOL_RA_VOLRA1_GET(r)   (((r) >> 16 ) & 0xff)
+
+		ioport32_t smps_cmd_ra;
+#define GLOBAL_REG_PRM_VC_SMPS_CMD_RA_CMDRA0_MASK   (0xff << 0)
+#define GLOBAL_REG_PRM_VC_SMPS_CMD_RA_CMDRA0_CREATE(x)   (((x) & 0xff) << 0)
+#define GLOBAL_REG_PRM_VC_SMPS_CMD_RA_CMDRA0_GET(r)   (r & 0xff)
+#define GLOBAL_REG_PRM_VC_SMPS_CMD_RA_CMDRA1_MASK   (0xff << 16)
+#define GLOBAL_REG_PRM_VC_SMPS_CMD_RA_CMDRA1_CREATE(x)   (((x) & 0xff) << 16)
+#define GLOBAL_REG_PRM_VC_SMPS_CMD_RA_CMDRA1_GET(r)   (((r) >> 16 ) & 0xff)
+
+		ioport32_t cmd_val_0;
+#define GLOBAL_REG_PRM_VC_CMD_VAL_0_ON_MASK   (0xff << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_0_ON_CREATE(x)   (((x) & 0xff) << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_0_ON_GET(r)   (((x) >> 24) & 0xff)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_0_ONLP_MASK   (0xff << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_0_ONLP_CREATE(x)   (((x) & 0xff) << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_0_ONLP_GET(r)   (((x) >> 24) & 0xff)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_0_RET_MASK   (0xff << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_0_RET_CREATE(x)   (((x) & 0xff) << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_0_RET_GET(r)   (((x) >> 24) & 0xff)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_0_OFF_MASK   (0xff << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_0_OFF_CREATE(x)   (((x) & 0xff) << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_0_OFF_GET(r)   (((x) >> 24) & 0xff)
+
+		ioport32_t cmd_val_1;
+#define GLOBAL_REG_PRM_VC_CMD_VAL_1_ON_MASK   (0xff << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_1_ON_CREATE(x)   (((x) & 0xff) << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_1_ON_GET(r)   (((x) >> 24) & 0xff)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_1_ONLP_MASK   (0xff << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_1_ONLP_CREATE(x)   (((x) & 0xff) << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_1_ONLP_GET(r)   (((x) >> 24) & 0xff)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_1_RET_MASK   (0xff << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_1_RET_CREATE(x)   (((x) & 0xff) << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_1_RET_GET(r)   (((x) >> 24) & 0xff)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_1_OFF_MASK   (0xff << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_1_OFF_CREATE(x)   (((x) & 0xff) << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_1_OFF_GET(r)   (((x) >> 24) & 0xff)
+
+		ioport32_t ch_conf;
+#define GLOBAL_REG_PRM_VC_CH_CONF_CMD1_FLAG   (1 << 20)
+#define GLOBAL_REG_PRM_VC_CH_CONF_RACEN1_FLAG   (1 << 19)
+#define GLOBAL_REG_PRM_VC_CH_CONF_RAC1_FLAG   (1 << 18)
+#define GLOBAL_REG_PRM_VC_CH_CONF_RAV1_FLAG   (1 << 17)
+#define GLOBAL_REG_PRM_VC_CH_CONF_SA1_FLAG   (1 << 16)
+#define GLOBAL_REG_PRM_VC_CH_CONF_CMD0_FLAG   (1 << 4)
+#define GLOBAL_REG_PRM_VC_CH_CONF_RACEN0_FLAG   (1 << 3)
+#define GLOBAL_REG_PRM_VC_CH_CONF_RAC0_FLAG   (1 << 2)
+#define GLOBAL_REG_PRM_VC_CH_CONF_RAV0_FLAG   (1 << 1)
+#define GLOBAL_REG_PRM_VC_CH_CONF_SA0_FLAG   (1 << 0)
+
+		ioport32_t i2c_cfg;
+#define GLOBAL_REG_PRM_VC_I2C_CFG_HSMASTER_FLAG   (1 << 5)
+#define GLOBAL_REG_PRM_VC_I2C_CFG_SREN_FLAG   (1 << 4)
+#define GLOBAL_REG_PRM_VC_I2C_CFG_HSEN_FLAG   (1 << 3)
+#define GLOBAL_REG_PRM_VC_I2C_CFG_MCODE_MASK   (0x3 << 0)
+#define GLOBAL_REG_PRM_VC_I2C_CFG_MCODE_CREATE(x)   ((x) & 0x3)
+#define GLOBAL_REG_PRM_VC_I2C_CFG_MCODE_GET(r)   ((r) & 0x3)
+
+		ioport32_t bypass_val;
+#define GLOBAL_REG_PRM_VC_BYPASS_VAL_VALID_FLAG   (1 << 24)
+#define GLOBAL_REG_PRM_VC_BYPASS_VAL_DATA_MASK   (0xff << 16)
+#define GLOBAL_REG_PRM_VC_BYPASS_VAL_DATA_CREATE(x)   (((x) & 0xff) << 16)
+#define GLOBAL_REG_PRM_VC_BYPASS_VAL_DATA_GET(r)   (((r) >> 16) & 0xff)
+#define GLOBAL_REG_PRM_VC_BYPASS_VAL_REGADDR_MASK   (0xff << 8)
+#define GLOBAL_REG_PRM_VC_BYPASS_VAL_REGADDR_CREATE(x)   (((x) & 0xff) << 8)
+#define GLOBAL_REG_PRM_VC_BYPASS_VAL_REGADDR_GET(r)   (((r) >> 8) & 0xff)
+#define GLOBAL_REG_PRM_VC_BYPASS_VAL_SLAVEADDR_MASK   (0x7f << 0)
+#define GLOBAL_REG_PRM_VC_BYPASS_VAL_SLAVEADDR_CREATE(x)   (((x) & 0x7f) << 0)
+#define GLOBAL_REG_PRM_VC_BYPASS_VAL_SLAVEADDR_GET(r)   (((r) >> 0) & 0x7f)
+	} vc;
+
+	PADD32[4];
+	ioport32_t rstctrl;
+#define GLOBAL_REG_PRM_RSTCTRL_RST_DPLL3_FLAG   (1 << 2)
+#define GLOBAL_REG_PRM_RSTCTRL_RST_GS_FLAG   (1 << 1)
+
+	ioport32_t rsttime;
+#define GLOBAL_REG_PRM_RSTTIME_RSTTIME2_MASK   (0x1f << 8)
+#define GLOBAL_REG_PRM_RSTTIME_RSTTIME2_CREATE(x)   (((x) & 0x1f) << 8)
+#define GLOBAL_REG_PRM_RSTTIME_RSTTIME2_GET(r)   (((r) >> 8) & 0x1f)
+#define GLOBAL_REG_PRM_RSTTIME_RSTTIME1_MASK   (0xff << 0)
+#define GLOBAL_REG_PRM_RSTTIME_RSTTIME1_CREATE(x)   (((x) & 0xff) << 0)
+#define GLOBAL_REG_PRM_RSTTIME_RSTTIME1_GET(r)   (((r) >> 0) & 0xff)
+
+	ioport32_t rstst;
+#define GLOBAL_REG_PRM_RSTST_ICECRUSHER_RST_FLAG   (1 << 10)
+#define GLOBAL_REG_PRM_RSTST_ICEPICK_RST_FLAG   (1 << 9)
+#define GLOBAL_REG_PRM_RSTST_VDD2_VOLTAGE_MGR_RST_FLAG   (1 << 8)
+#define GLOBAL_REG_PRM_RSTST_VDD1_VOLTAGE_MGR_RST_FLAG   (1 << 7)
+#define GLOBAL_REG_PRM_RSTST_EXTERNAL_WARM_REST_FLAG   (1 << 6)
+#define GLOBAL_REG_PRM_RSTST_MPU_WD_RST_FLAG   (1 << 4)
+#define GLOBAL_REG_PRM_RSTST_GLOBAL_SW_RST_FLAG   (1 << 1)
+#define GLOBAL_REG_PRM_RSTST_GLOABL_COLD_RST_FLAG   (1 << 0)
+
+	PADD32;
+	ioport32_t volctrl;
+#define GLOBAL_REG_PRM_VOLCTRL_SEL_VMODE_FLAG   (1 << 4)
+#define GLOBAL_REG_PRM_VOLCTRL_SEL_OFF_FLAG   (1 << 3)
+#define GLOBAL_REG_PRM_VOLCTRL_AUTO_OFF_FLAG   (1 << 2)
+#define GLOBAL_REG_PRM_VOLCTRL_AUTO_RET_FLAG   (1 << 1)
+#define GLOBAL_REG_PRM_VOLCTRL_AUTO_SLEEP_FLAG   (1 << 0)
+
+	ioport32_t sram_pcharge;
+#define GLOBAL_REG_PRM_SRAM_PCHARGE_PCHARGE_TIME_MASK   (0xff)
+#define GLOBAL_REG_PRM_SRAM_PCHARGE_PCHARGE_TIME_CREATE(x)   ((x) & 0xff)
+#define GLOBAL_REG_PRM_SRAM_PCHARGE_PCHARGE_TIME_GET(r)   ((r) & 0xff)
+
+	PADD32[2];
+	ioport32_t clksrc_ctrl;
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_DPLL4_CLKINP_DIV_65_FLAG   (1 << 8)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKDIV_MASK   (0x3 << 6)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKDIV_1   (0x1 << 6)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKDIV_2   (0x2 << 6)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKDIV_GET(r)   (((r) >> 6) & 0x3)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_AUTOEXTCLKMODE_MASK   (0x3 << 3)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_AUTOEXTCLKMODE_ON   (0x0 << 3)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_AUTOEXTCLKMODE_SLEEP   (0x1 << 3)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_AUTOEXTCLKMODE_RET   (0x2 << 3)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_AUTOEXTCLKMODE_OFF   (0x3 << 3)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_AUTOEXTCLKMODE_GET(r)   (((r) >> 3) & 0x3)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKSEL_MASK   (0x3 << 0)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKSEL_BYPASS   (0x0 << 0)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKSEL_OSCILLATOR   (0x1 << 0)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKSEL_UNKNOWN   (0x3 << 0)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKSEL_GET(r)   (((r) >> 0) & 0x3)
+
+	PADD32[3];
+	const ioport32_t obs;
+#define GLOBAL_REG_PRM_OBS_OBS_BUS_MASK   (0x3ff)
+
+	PADD32[3];
+	ioport32_t voltsetup1;
+#define GLOBAL_REG_PRM_VOLTSETUP1_SETUPTIME2_MASK   (0xff << 16)
+#define GLOBAL_REG_PRM_VOLTSETUP1_SETUPTIME2_CREATE(x)   (((x) & 0xff) << 16)
+#define GLOBAL_REG_PRM_VOLTSETUP1_SETUPTIME2_GET(r)   (((r) >> 16) & 0xff)
+#define GLOBAL_REG_PRM_VOLTSETUP1_SETUPTIME1_MASK   (0xff << 0)
+#define GLOBAL_REG_PRM_VOLTSETUP1_SETUPTIME1_CREATE(x)   (((x) & 0xff) << 0)
+#define GLOBAL_REG_PRM_VOLTSETUP1_SETUPTIME1_GET(r)   (((r) >> 0) & 0xff)
+
+	ioport32_t voltoffset;
+#define GLOBAL_REG_PRM_VOLTOFFSET_OFFSET_TIME_MASK   (0xffff << 0)
+#define GLOBAL_REG_PRM_VOLTOFFSET_OFFSET_TIME_CREATE(x)   (((x) & 0xffff) << 0)
+#define GLOBAL_REG_PRM_VOLTOFFSET_OFFSET_TIME_GET(r)   (((r) >> 0) & 0xffff)
+
+	ioport32_t clksetup;
+#define GLOBAL_REG_PRM_CLKSETUP_SETUP_TIME_MASK   (0xffff << 0)
+#define GLOBAL_REG_PRM_CLKSETUP_SETUP_TIME_CREATE(x)   (((x) & 0xffff) << 0)
+#define GLOBAL_REG_PRM_CLKSETUP_SETUP_TIME_GET(r)   (((r) >> 0) & 0xffff)
+
+	ioport32_t polctrl;
+#define GLOBAL_REG_PRM_POLCTRL_OFFMODE_POL_FLAG   (1 << 3)
+#define GLOBAL_REG_PRM_POLCTRL_CLKOUT_POL_FLAG   (1 << 2)
+#define GLOBAL_REG_PRM_POLCTRL_CLKREG_POL_FLAG   (1 << 1)
+#define GLOBAL_REG_PRM_POLCTRL_EXTVOL_POL_FLAG   (1 << 0)
+
+	ioport32_t voltsetup2;
+#define GLOBAL_REG_PRM_VOLTSETUP2_OFFMODESETUPTIME_MASK   (0xffff << 0)
+#define GLOBAL_REG_PRM_VOLTSETUP2_OFFMODESETUPTIME_CREATE(x)   (((x) & 0xffff) << 0)
+#define GLOBAL_REG_PRM_VOLTSETUP2_OFFMODESETUPTIME_GET(r)   (((r) >> 0) & 0xffff)
+
+	PADD32[3];
+	struct {
+		ioport32_t config;
+#define GLOBAL_REG_PRM_VP_CONFIG_ERROROFFSET_MASK   (0xff << 24)
+#define GLOBAL_REG_PRM_VP_CONFIG_ERROROFFSET_CREATE(x)   (((x) & 0xff) << 24)
+#define GLOBAL_REG_PRM_VP_CONFIG_ERROROFFSET_GET(r)   (((r) >> 0xff << 24)
+#define GLOBAL_REG_PRM_VP_CONFIG_ERRORGAIN_MASK   (0xff << 16)
+#define GLOBAL_REG_PRM_VP_CONFIG_ERRORGAIN_CREATE(x)   (((x) & 0xff) << 16)
+#define GLOBAL_REG_PRM_VP_CONFIG_ERRORGAIN_GET(r)   (((r) >> 0xff << 16)
+#define GLOBAL_REG_PRM_VP_CONFIG_INITVOLTAGE_MASK   (0xff << 8)
+#define GLOBAL_REG_PRM_VP_CONFIG_INITVOLTAGE_CREATE(x)   (((x) & 0xff) << 8)
+#define GLOBAL_REG_PRM_VP_CONFIG_INITVOLTAGE_GET(r)   (((r) >> 0xff << 8)
+#define GLOBAL_REG_PRM_VP_CONFIG_TIMEOUTEN_FLAG    (1 << 3)
+#define GLOBAL_REG_PRM_VP_CONFIG_INITVDD_FLAG   (1 << 2)
+#define GLOBAL_REG_PRM_VP_CONFIG_FORCEUPDATE_FLAG   (1 << 1)
+#define GLOBAL_REG_PRM_VP_CONFIG_VPENABLE_FLAG   (1 << 0)
+
+		ioport32_t vstepmin;
+#define GLOBAL_REG_PRM_VP_VSTEPMIN_SMPSWAITTIMEMIN_MASK   (0xffff << 8)
+#define GLOBAL_REG_PRM_VP_VSTEPMIN_SMPSWAITTIMEMIN_CREATE(x)   (((x)0xffff << 8)
+#define GLOBAL_REG_PRM_VP_VSTEPMIN_SMPSWAITTIMEMIN_GET(r)   (((r) >> 8) & 0xffff)
+#define GLOBAL_REG_PRM_VP_VSTEPMIN_VSTEPMIN_MASK   (0xff << 0)
+#define GLOBAL_REG_PRM_VP_VSTEPMIN_VSTEPMIN_CREATE(x)   (((x)0xff << 0)
+#define GLOBAL_REG_PRM_VP_VSTEPMIN_VSTEPMIN_GET(r)   (((r) >> 0) & 0xff)
+
+		ioport32_t vstepmax;
+#define GLOBAL_REG_PRM_VP_VSTEPMAX_SMPSWAITTIMEMIN_MASK   (0xffff << 8)
+#define GLOBAL_REG_PRM_VP_VSTEPMAX_SMPSWAITTIMEMIN_CREATE(x)   (((x)0xffff << 8)
+#define GLOBAL_REG_PRM_VP_VSTEPMAX_SMPSWAITTIMEMIN_GET(r)   (((r) >> 8) & 0xffff)
+#define GLOBAL_REG_PRM_VP_VSTEPMAX_VSTEPMIN_MASK   (0xff << 0)
+#define GLOBAL_REG_PRM_VP_VSTEPMAX_VSTEPMIN_CREATE(x)   (((x)0xff << 0)
+#define GLOBAL_REG_PRM_VP_VSTEPMAX_VSTEPMIN_GET(r)   (((r) >> 0) & 0xff)
+
+		ioport32_t vlimitto;
+#define GLOBAL_REG_PRM_VP_VLIMITTO_VDDMAX_MASK   (0xff << 24)
+#define GLOBAL_REG_PRM_VP_VLIMITTO_VDDMAX_CREATE(x)   (((x)0xff << 24)
+#define GLOBAL_REG_PRM_VP_VLIMITTO_VDDMAX_GET(r)   (((r) >> 24) & 0xff)
+#define GLOBAL_REG_PRM_VP_VLIMITTO_VDDMIN_MASK   (0xff << 16)
+#define GLOBAL_REG_PRM_VP_VLIMITTO_VDDMIN_CREATE(x)   (((x)0xff << 16)
+#define GLOBAL_REG_PRM_VP_VLIMITTO_VDDMIN_GET(r)   (((r) >> 16) & 0xff)
+#define GLOBAL_REG_PRM_VP_VLIMITTO_TIMEOUT_MASK   (0xffff << 0)
+#define GLOBAL_REG_PRM_VP_VLIMITTO_TIMEOUT_CREATE(x)   (((x)0xffff << 0)
+#define GLOBAL_REG_PRM_VP_VLIMITTO_TIMEOUT_GET(r)   (((r) >> 0) & 0xffff)
+
+		const ioport32_t voltage;
+#define GLOBAL_REG_PRM_VP_VOLTAGE_VPVOLTAGE_MASK   (0xff)
+#define GLOBAL_REG_PRM_VP_VOLTAGE_VPVOLTAGE_GET(r)   ((r) & 0xff)
+
+		const ioport32_t status;
+#define GLOBAL_REG_PRM_VP_STATUS_VPINIDLE_FLAG   (1 << 0)
+
+		PADD32[2];
+	} vp[2];
+
+	ioport32_t ldo_abb_setup;
+#define GLOBAL_REG_PRM_LDO_ABB_SETUP_SR2_IN_TRANSITION   (1 << 6)
+#define GLOBAL_REG_PRM_LDO_ABB_SETUP_SR2_STATUS_MASK   (0x3 << 3)
+#define GLOBAL_REG_PRM_LDO_ABB_SETUP_SR2_STATUS_BYPASS   (0x0 << 3)
+#define GLOBAL_REG_PRM_LDO_ABB_SETUP_SR2_STATUS_FBB   (0x2 << 3)
+#define GLOBAL_REG_PRM_LDO_ABB_SETUP_SR2_OPP_CHANGE_FLAG  (1 << 2)
+#define GLOBAL_REG_PRM_LDO_ABB_SETUP_OPP_SEL_MASK   (0x3 << 0)
+#define GLOBAL_REG_PRM_LDO_ABB_SETUP_OPP_SEL_DEFAULT   (0x0 << 0)
+#define GLOBAL_REG_PRM_LDO_ABB_SETUP_OPP_SEL_FAST   (0x1 << 0)
+#define GLOBAL_REG_PRM_LDO_ABB_SETUP_OPP_SEL_NOMINAL   (0x2 << 0)
+#define GLOBAL_REG_PRM_LDO_ABB_SETUP_OPP_SEL_SLOW   (0x3 << 0)
+
+	ioport32_t ldo_abb_ctrl;
+#define GLOBAL_REG_PRM_LDO_ABB_CTRL_SR2_WTCNT_VALUE_MASK   (0xff << 8)
+#define GLOBAL_REG_PRM_LDO_ABB_CTRL_SR2_WTCNT_VALUE_CREATE(x)   (((x) & 0xff) << 8)
+#define GLOBAL_REG_PRM_LDO_ABB_CTRL_SR2_WTCNT_VALUE_GET(r)   (((r) >> 8) & 0xff)
+#define GLOBAL_REG_PRM_LDO_ABB_CTRL_ACTIVE_FBB_SEL_FLAG   (1 << 2)
+#define GLOBAL_REG_PRM_LDO_ABB_CTRL_SR2EN   (1 << 0)
+} global_reg_prm_regs_t;
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/infrastructure/rootamdm37x/prm/usbhost.h
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/prm/usbhost.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
+++ uspace/drv/infrastructure/rootamdm37x/prm/usbhost.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -0,0 +1,111 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup amdm37xdrvprm
+ * @{
+ */
+/** @file
+ * @brief Clock Control Clock Management IO register structure.
+ */
+#ifndef AMDM37X_PRM_CLOCK_CONTROL_H
+#define AMDM37X_PRM_CLOCK_CONTROL_H
+#include <sys/types.h>
+#include <macros.h>
+
+/* AM/DM37x TRM p.536 and p.589 */
+#define CLOCK_CONTROL_CM_BASE_ADDRESS  0x48307400
+#define CLOCK_CONTROL_CM_SIZE  8192
+
+/** Clock control PRM register map
+ *
+ * Periph DPLL == DPLL4
+ * Core DPLL == DPLL3
+ */
+typedef struct {
+	PADD32[22];
+	ioport32_t rm_rstst;
+#define USBHOST_PRM_RM_RSTST_COREDOMAINWKUP_RST_FLAG   (1 << 3)
+#define USBHOST_PRM_RM_RSTST_DOMAINWKUP_RST_FLAG   (1 << 2)
+#define USBHOST_PRM_RM_RSTST_GLOBALWARM_RST_FLAG   (1 << 1)
+#define USBHOST_PRM_RM_RSTST_GLOBALCOLD_RST_FLAG   (1 << 0)
+
+	PADD32[18];
+	ioport32_t pm_wken;
+#define USBHOST_PRM_PM_WKEN_EN_USBHOST_FLAG   (1 << 0)
+
+	ioport32_t pm_mpugrpsel;
+#define USBHOST_PRM_PM_MPUGRPSEL_GRPSEL_USBHOST_FLAG   (1 << 0)
+
+	ioport32_t pm_iva2grpsel;
+#define USBHOST_PRM_PM_IVA2GRPSEL_GRPSEL_USBHOST_FLAG   (1 << 0)
+
+	PADD32;
+	ioport32_t pm_wkst;
+#define USBHOST_PRM_PM_WKST_ST_USBHOST_FLAG   (1 << 0)
+
+	PADD32[5];
+	ioport32_t pm_wkdep;
+#define USBHOST_PRM_PM_WKDEP_EN_WKUP_FLAG   (1 << 4)
+#define USBHOST_PRM_PM_WKDEP_EN_IVA2_FLAG   (1 << 2)
+#define USBHOST_PRM_PM_WKDEP_EN_MPU_FLAG   (1 << 1)
+#define USBHOST_PRM_PM_WKDEP_EN_CORE_FLAG   (1 << 0)
+
+	PADD32[5];
+	ioport32_t pm_pwstctrl;
+#define USBHOST_PRM_PM_PWSTCTRL_MEMONSTATE_MASK   (0x3 << 16)
+#define USBHOST_PRM_PM_PWSTCTRL_MEMONSTATE_ALWAYS_ON   (0x3 << 16)
+#define USBHOST_PRM_PM_PWSTCTRL_MEMRETSTATE_FLAG   (1 << 8)
+#define USBHOST_PRM_PM_PWSTCTRL_SAVEANDRESTORE_FLAG   (1 << 4)
+#define USBHOST_PRM_PM_PWSTCTRL_LOGICRESTATE_FLAG   (1 << 2)
+#define USBHOST_PRM_PM_PWSTCTRL_POWERSTATE_MASK   (0x3 << 0)
+#define USBHOST_PRM_PM_PWSTCTRL_POWERSTATE_OFF   (0x0 << 0)
+#define USBHOST_PRM_PM_PWSTCTRL_POWERSTATE_RETENTION   (0x1 << 0)
+#define USBHOST_PRM_PM_PWSTCTRL_POWERSTATE_ON   (0x3 << 0)
+
+	const ioport32_t pm_pwstst;
+#define USBHOST_PRM_PM_PWSTST_INTRANSITION_FLAG   (1 << 20)
+#define USBHOST_PRM_PM_PWSTST_POWERSTATEST_MASK   (0x3 << 0)
+#define USBHOST_PRM_PM_PWSTST_POWERSTATEST_OFF   (0x0 << 0)
+#define USBHOST_PRM_PM_PWSTST_POWERSTATEST_RETENTION  (0x1 << 0)
+#define USBHOST_PRM_PM_PWSTST_POWERSTATEST_INACTIVE  (0x2 << 0)
+#define USBHOST_PRM_PM_PWSTST_POWERSTATEST_ON  (0x3 << 0)
+
+	ioport32_t pm_prepwstst;
+#define USBHOST_PRM_PM_PREPWSTST_LASTPOWERSTATEENTERED_MASK   (0x3 << 0)
+#define USBHOST_PRM_PM_PREPWSTST_LASTPOWERSTATEENTERED_OFF   (0x0 << 0)
+#define USBHOST_PRM_PM_PREPWSTST_LASTPOWERSTATEENTERED_RETENTION  (0x1 << 0)
+#define USBHOST_PRM_PM_PREPWSTST_LASTPOWERSTATEENTERED_INACTIVE  (0x2 << 0)
+#define USBHOST_PRM_PM_PREPWSTST_LASTPOWERSTATEENTERED_ON  (0x3 << 0)
+
+} usbhost_prm_regs_t;
+
+#endif
+/**
+ * @}
+ */
+
Index: uspace/drv/infrastructure/rootamdm37x/rootamdm37x.c
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/rootamdm37x.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
+++ uspace/drv/infrastructure/rootamdm37x/rootamdm37x.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -0,0 +1,234 @@
+/*
+ * 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
+ */
+
+#define DEBUG_CM 0
+
+#include <ddf/log.h>
+#include <errno.h>
+#include <ops/hw_res.h>
+#include <stdio.h>
+
+#include "amdm37x.h"
+
+#define NAME  "rootamdm37x"
+
+typedef struct {
+	hw_resource_list_t hw_resources;
+} rootamdm37x_fun_t;
+
+/* See amdm37x TRM page. 3316 for these values */
+#define OHCI_BASE_ADDRESS  0x48064400
+#define OHCI_SIZE  1024
+#define EHCI_BASE_ADDRESS  0x48064800
+#define EHCI_SIZE  1024
+
+static hw_resource_t ohci_res[] = {
+	{
+		.type = MEM_RANGE,
+		.res.io_range = {
+			.address = OHCI_BASE_ADDRESS,
+			.size = OHCI_SIZE,
+			.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 = EHCI_BASE_ADDRESS,
+			.size = EHCI_SIZE,
+			.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 hw_resource_list_t *rootamdm37x_get_resources(ddf_fun_t *fnode);
+static bool rootamdm37x_enable_interrupt(ddf_fun_t *fun);
+
+static hw_res_ops_t fun_hw_res_ops = {
+	.get_resource_list = &rootamdm37x_get_resources,
+	.enable_interrupt = &rootamdm37x_enable_interrupt,
+};
+
+static ddf_dev_ops_t rootamdm37x_fun_ops = {
+	.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops
+};
+
+static int 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);
+	
+	/* Create new device function. */
+	ddf_fun_t *fnode = ddf_fun_create(dev, fun_inner, name);
+	if (fnode == NULL)
+		return ENOMEM;
+	
+	/* Add match id */
+	int ret = ddf_fun_add_match_id(fnode, str_match_id, 100);
+	if (ret != EOK) {
+		ddf_fun_destroy(fnode);
+		return ret;
+	}
+	
+	/* Alloc needed data */
+	rootamdm37x_fun_t *rf =
+	    ddf_fun_data_alloc(fnode, sizeof(rootamdm37x_fun_t));
+	if (!rf) {
+		ddf_fun_destroy(fnode);
+		return ENOMEM;
+	}
+	*rf = *fun;
+
+	/* Set provided operations to the device. */
+	ddf_fun_set_ops(fnode, &rootamdm37x_fun_ops);
+	
+	/* Register function. */
+	ret = ddf_fun_bind(fnode);
+	if (ret != EOK) {
+		ddf_msg(LVL_ERROR, "Failed binding function %s.", name);
+		ddf_fun_destroy(fnode);
+		return ret;
+	}
+	
+	return EOK;
+}
+
+/** Add 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)
+{
+	assert(dev);
+	amdm37x_t *device = ddf_dev_data_alloc(dev, sizeof(amdm37x_t));
+	if (!device)
+		return ENOMEM;
+	int ret = amdm37x_init(device, DEBUG_CM);
+	if (ret != EOK) {
+		ddf_msg(LVL_FATAL, "Failed to setup hw access!.\n");
+		return ret;
+	}
+
+	/* Set dplls to ON and automatic */
+	amdm37x_setup_dpll_on_autoidle(device);
+
+	/* Enable function and interface clocks */
+	amdm37x_usb_clocks_set(device, true);
+
+	/* Init TLL */
+	ret = amdm37x_usb_tll_init(device);
+	if (ret != EOK) {
+		ddf_msg(LVL_FATAL, "Failed to init USB TLL!.\n");
+		amdm37x_usb_clocks_set(device, false);
+		return ret;
+	}
+
+	/* Register functions */
+	if (rootamdm37x_add_fun(dev, "ohci", "usb/host=ohci", &ohci) != EOK)
+		ddf_msg(LVL_ERROR, "Failed to add OHCI function for "
+		    "BeagleBoard-xM platform.");
+	if (rootamdm37x_add_fun(dev, "ehci", "usb/host=ehci", &ehci) != EOK)
+		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 = ddf_fun_data_get(fnode);
+	assert(fun != NULL);
+	return &fun->hw_resources;
+}
+
+static bool rootamdm37x_enable_interrupt(ddf_fun_t *fun)
+{
+	//TODO: Implement
+	return false;
+}
+
+int main(int argc, char *argv[])
+{
+	printf("%s: HelenOS AM/DM37x(OMAP37x) platform driver\n", NAME);
+	ddf_log_init(NAME);
+	return ddf_driver_main(&rootamdm37x_driver);
+}
+
+/**
+ * @}
+ */
Index: uspace/drv/infrastructure/rootamdm37x/rootamdm37x.ma
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/rootamdm37x.ma	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
+++ uspace/drv/infrastructure/rootamdm37x/rootamdm37x.ma	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -0,0 +1,1 @@
+10 platform/beagleboardxm
Index: uspace/drv/infrastructure/rootamdm37x/uhh.h
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/uhh.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
+++ uspace/drv/infrastructure/rootamdm37x/uhh.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -0,0 +1,97 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup amdm37xdrvuhh
+ * @{
+ */
+/** @file
+ * @brief UHH IO register structure.
+ */
+#ifndef AMDM37x_UHH_H
+#define AMDM37x_UHH_H
+#include <macros.h>
+#include <sys/types.h>
+
+#define AMDM37x_UHH_BASE_ADDRESS  0x48064000
+#define AMDM37x_UHH_SIZE  1024
+
+typedef struct {
+	const ioport32_t revision;
+#define UHH_REVISION_MINOR_MASK  0x0f
+#define UHH_REVISION_MAJOR_MASK  0xf0
+
+	PADD32[3];
+	ioport32_t sysconfig;
+#define UHH_SYSCONFIG_AUTOIDLE_FLAG  (1 << 0)
+#define UHH_SYSCONFIG_SOFTRESET_FLAG  (1 << 1)
+#define UHH_SYSCONFIG_ENWAKEUP_FLAG  (1 << 2)
+#define UHH_SYSCONFIG_SIDLE_MODE_MASK  (0x3 << 3)
+#define UHH_SYSCONFIG_SIDLE_MODE_FORCE  (0x0 << 3)
+#define UHH_SYSCONFIG_SIDLE_MODE_NO  (0x1 << 3)
+#define UHH_SYSCONFIG_SIDLE_MODE_SMART  (0x2 << 3)
+#define UHH_SYSCONFIG_CLOCKACTIVITY_FLAG  (1 << 8)
+#define UHH_SYSCONFIG_MIDLE_MODE_MASK  (0x3 << 12)
+#define UHH_SYSCONFIG_MIDLE_MODE_FORCE  (0x0 << 12)
+#define UHH_SYSCONFIG_MIDLE_MODE_NO  (0x1 << 12)
+#define UHH_SYSCONFIG_MIDLE_MODE_SMART  (0x2 << 12)
+
+	const ioport32_t sysstatus;
+#define UHH_SYSSTATUS_RESETDONE_FLAG  (1 << 0)
+#define UHH_SYSSTATUS_OHCI_RESETDONE_FLAG  (1 << 1)
+#define UHH_SYSSTATUS_EHCI_RESETDONE_FLAG  (1 << 2)
+
+	PADD32[10];
+	ioport32_t hostconfig;
+#define UHH_HOSTCONFIG_P1_ULPI_BYPASS_FLAG  (1 << 0)
+#define UHH_HOSTCONFIG_AUTOPPD_ON_OVERCUR_EN_FLAG  (1 << 1)
+#define UHH_HOSTCONFIG_ENA_INCR4_FLAG  (1 << 2)
+#define UHH_HOSTCONFIG_ENA_INCR8_FLAG  (1 << 3)
+#define UHH_HOSTCONFIG_ENA_INCR16_FLA  (1 << 4)
+#define UHH_HOSTCONFIG_ENA_INCR_ALIGN_FLAG  (1 << 5)
+#define UHH_HOSTCONFIG_P1_CONNECT_STATUS_FLAG  (1 << 8)
+#define UHH_HOSTCONFIG_P2_CONNECT_STATUS_FLAG  (1 << 9)
+#define UHH_HOSTCONFIG_P3_CONNECT_STATUS_FLAG  (1 << 10)
+#define UHH_HOSTCONFIG_P2_ULPI_BYPASS_FLAG  (1 << 11)
+#define UHH_HOSTCONFIG_P3_ULPI_BYPASS_FLAG  (1 << 12)
+
+	ioport32_t debug_csr;
+#define UHH_DEBUG_CSR_EHCI_FLADJ_MASK  (0x3f << 0)
+#define UHH_DEBUG_CSR_EHCI_FLADJ(x)  ((x) & 0x3f)
+#define UHH_DEBUG_CSR_EHCI_SIMULATION_MODE_FLAG  (1 << 6)
+#define UHH_DEBUG_CSR_OHCI_CNTSEL_FLAG  (1 << 7)
+#define UHH_DEBUG_CSR_OHCI_GLOBAL_sUSPEND_FLAG  (1 << 16)
+#define UHH_DEBUG_CSR_OHCI_CCS1_FLAG  (1 << 17)
+#define UHH_DEBUG_CSR_OHCI_CCS2_FLAG  (1 << 18)
+#define UHH_DEBUG_CSR_OHCI_CCS3_FLAG  (1 << 19)
+
+} uhh_regs_t;
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/infrastructure/rootamdm37x/usbtll.h
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/usbtll.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
+++ uspace/drv/infrastructure/rootamdm37x/usbtll.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -0,0 +1,129 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup amdm37xdrvusbtll
+ * @{
+ */
+/** @file
+ * @brief USBTLL IO register structure.
+ */
+#ifndef AMDM37x_USBTLL_H
+#define AMDM37x_USBTLL_H
+#include <macros.h>
+#include <sys/types.h>
+
+#define AMDM37x_USBTLL_BASE_ADDRESS  0x48062000
+#define AMDM37x_USBTLL_SIZE  4096
+
+typedef struct {
+	const ioport32_t revision;
+#define TLL_REVISION_MINOR_MASK  0x0f
+#define TLL_REVISION_MAJOR_MASK  0xf0
+
+	PADD32[3];
+	ioport32_t sysconfig;
+#define TLL_SYSCONFIG_AUTOIDLE_FLAG  (1 << 0)
+#define TLL_SYSCONFIG_SOFTRESET_FLAG  (1 << 1)
+#define TLL_SYSCONFIG_ENWAKEUP_FLAG  (1 << 2)
+#define TLL_SYSCONFIG_SIDLE_MODE_MASK  (0x3 << 3)
+#define TLL_SYSCONFIG_SIDLE_MODE_FORCE  (0x0 << 3)
+#define TLL_SYSCONFIG_SIDLE_MODE_NO  (0x1 << 3)
+#define TLL_SYSCONFIG_SIDLE_MODE_SMART  (0x2 << 3)
+#define TLL_SYSCONFIG_CLOCKACTIVITY_FLAG  (1 << 8)
+
+	const ioport32_t sysstatus;
+#define TLL_SYSSTATUS_RESET_DONE_FLAG  (1 << 0)
+
+	const ioport32_t irqstatus;
+#define TLL_IRQSTATUS_FCLK_START_FLAG  (1 << 0)
+#define TLL_IRQSTATUS_FCLK_END_FLAG  (1 << 1)
+#define TLL_IRQSTATUS_ACCESS_ERROR_FLAG  (1 << 2)
+
+	ioport32_t irqenable;
+#define TLL_IRQSTATUS_FCLK_START_EN_FLAG  (1 << 0)
+#define TLL_IRQSTATUS_FCLK_END_EN_FLAG  (1 << 1)
+#define TLL_IRQSTATUS_ACCESS_ERROR_EN_FLAG  (1 << 2)
+
+	PADD32[4];
+	ioport32_t shared_conf;
+#define TLL_SHARED_CONF_FCLK_IS_ON_FLAG  (1 << 0)
+#define TLL_SHARED_CONF_FCLK_REQ_FLAG  (1 << 1)
+#define TLL_SHARED_CONF_USB_DIVRATIO_MASK  (0x7 << 2)
+#define TLL_SHARED_CONF_USB_DIVRATIO(x)  (((x) & 0x7) << 2)
+#define TLL_SHARED_CONF_USB_180D_SDR_EN_FLAG  (1 << 5)
+#define TLL_SHARED_CONF_USB_90D_DDR_EN_FLAG  (1 << 6)
+
+	PADD32[3];
+	ioport32_t channel_conf[3];
+#define TLL_CHANNEL_CONF_CHANEN_FLAG  (1 << 0)
+#define TLL_CHANNEL_CONF_CHANMODE_MASK  (0x3 << 1)
+#define TLL_CHANNEL_CONF_CHANMODE_UTMI_ULPI_MODE (0x0 << 1)
+#define TLL_CHANNEL_CONF_CHANMODE_UTMI_SERIAL_MODE (0x1 << 1)
+#define TLL_CHANNEL_CONF_CHANMODE_UTMI_TRANS_MODE (0x2 << 1)
+#define TLL_CHANNEL_CONF_CHANMODE_NO_MODE (0x3 << 1)
+#define TLL_CHANNEL_CONF_UTMIISADEV_FLAG  (1 << 3)
+#define TLL_CHANNEL_CONF_TLLATTACH_FLAG  (1 << 4)
+#define TLL_CHANNEL_CONF_TLLCONNECT_FLAG  (1 << 5)
+#define TLL_CHANNEL_CONF_TLLFULLSPEED_FLAG  (1 << 6)
+#define TLL_CHANNEL_CONF_ULPIOUTCLKMODE_FLAG  (1 << 7)
+#define TLL_CHANNEL_CONF_ULPIDDRMODE_FLAG  (1 << 8)
+#define TLL_CHANNEL_CONF_UTMIAUTOIDLE_FLAG  (1 << 9)
+#define TLL_CHANNEL_CONF_ULPIAUTOIDLE_FLAG  (1 << 10)
+#define TLL_CHANNEL_CONF_ULPINOBITSTUFF_FLAG  (1 << 11)
+#define TLL_CHANNEL_CONF_CHRGVBUS_FLAG  (1 << 15)
+#define TLL_CHANNEL_CONF_DRVVBUS_FLAG  (1 << 16)
+#define TLL_CHANNEL_CONF_TESTEN_FLAG  (1 << 17)
+#define TLL_CHANNEL_CONF_TESTTXEN_FLAG  (1 << 18)
+#define TLL_CHANNEL_CONF_TESTTXDAT_FLAG  (1 << 19)
+#define TLL_CHANNEL_CONF_TESTTXSE0_FLAG  (1 << 20)
+#define TLL_CHANNEL_CONF_FSLSMODE_MASK   (0xf << 24)
+#define TLL_CHANNEL_CONF_FSLSMODE_6PIN_UNI_PHY_TX_DATSE0   (0x0 << 24)
+#define TLL_CHANNEL_CONF_FSLSMODE_6PIN_UNI_PHY_TX_DPDM   (0x1 << 24)
+#define TLL_CHANNEL_CONF_FSLSMODE_3PIN_BIDI_PHY   (0x2 << 24)
+#define TLL_CHANNEL_CONF_FSLSMODE_4PIN_BIDI_PHY   (0x3 << 24)
+#define TLL_CHANNEL_CONF_FSLSMODE_6PIN_UNI_TLL_TX_DATSE0  (0x4 << 24)
+#define TLL_CHANNEL_CONF_FSLSMODE_6PIN_UNI_TLL_TX_DPDM  (0x5 << 24)
+#define TLL_CHANNEL_CONF_FSLSMODE_3PIN_BIDI_TLL  (0x6 << 24)
+#define TLL_CHANNEL_CONF_FSLSMODE_4PIN_BIDI_TLL  (0x7 << 24)
+#define TLL_CHANNEL_CONF_FSLSMODE_2PIN_BIDI_TLL_DATSE0  (0xa << 24)
+#define TLL_CHANNEL_CONF_FSLSMODE_2PIN_BIDI_TLL_DPDM  (0xb << 24)
+
+#define TLL_CHANNEL_CONF_FSLSLINESTATE_MASK  (0x3 << 28)
+#define TLL_CHANNEL_CONF_FSLSLINESTATE_SE0  (0x0 << 28)
+#define TLL_CHANNEL_CONF_FSLSLINESTATE_FS_J  (0x1 << 28)
+#define TLL_CHANNEL_CONF_FSLSLINESTATE_FS_K  (0x2 << 28)
+#define TLL_CHANNEL_CONF_FSLSLINESTATE_SE1  (0x3 << 28)
+
+	/* The rest are 8bit ULPI registers */
+} tll_regs_t;
+
+#endif
+/**
+ * @}
+ */
+
Index: uspace/drv/nic/e1k/e1k.c
===================================================================
--- uspace/drv/nic/e1k/e1k.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/drv/nic/e1k/e1k.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -45,5 +45,5 @@
 #include <ipc/irc.h>
 #include <ipc/ns.h>
-#include <libarch/ddi.h>
+#include <ddi.h>
 #include <as.h>
 #include <ddf/log.h>
Index: uspace/drv/nic/ne2k/dp8390.c
===================================================================
--- uspace/drv/nic/ne2k/dp8390.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/drv/nic/ne2k/dp8390.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -58,5 +58,5 @@
 #include <errno.h>
 #include <stdio.h>
-#include <libarch/ddi.h>
+#include <ddi.h>
 #include "dp8390.h"
 
Index: uspace/drv/nic/rtl8139/defs.h
===================================================================
--- uspace/drv/nic/rtl8139/defs.h	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/drv/nic/rtl8139/defs.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -37,5 +37,5 @@
 
 #include <sys/types.h>
-#include <libarch/ddi.h>
+#include <ddi.h>
 
 /** Size of RTL8139 registers address space */
Index: uspace/drv/nic/rtl8139/driver.c
===================================================================
--- uspace/drv/nic/rtl8139/driver.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/drv/nic/rtl8139/driver.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -34,5 +34,4 @@
 #include <align.h>
 #include <byteorder.h>
-#include <libarch/ddi.h>
 #include <libarch/barrier.h>
 
Index: uspace/drv/time/cmos-rtc/cmos-rtc.c
===================================================================
--- uspace/drv/time/cmos-rtc/cmos-rtc.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/drv/time/cmos-rtc/cmos-rtc.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -40,5 +40,4 @@
 #include <as.h>
 #include <sysinfo.h>
-#include <libarch/ddi.h>
 #include <libarch/barrier.h>
 #include <stdio.h>
Index: uspace/lib/c/Makefile
===================================================================
--- uspace/lib/c/Makefile	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/lib/c/Makefile	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -140,9 +140,11 @@
 	generic/net/socket_client.c \
 	generic/net/socket_parse.c \
+	generic/stack.c \
 	generic/stacktrace.c \
 	generic/arg_parse.c \
 	generic/sort.c \
 	generic/stats.c \
-	generic/assert.c
+	generic/assert.c \
+	generic/pio_trace.c
 
 ifeq ($(CONFIG_RTLD),y)
Index: uspace/lib/c/arch/abs32le/include/ddi.h
===================================================================
--- uspace/lib/c/arch/abs32le/include/ddi.h	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/lib/c/arch/abs32le/include/ddi.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -36,30 +36,30 @@
 #include <libarch/types.h>
 
-static inline void pio_write_8(ioport8_t *port, uint8_t v)
+static inline void arch_pio_write_8(ioport8_t *port, uint8_t v)
 {
 	*port = v;
 }
 
-static inline void pio_write_16(ioport16_t *port, uint16_t v)
+static inline void arch_pio_write_16(ioport16_t *port, uint16_t v)
 {
 	*port = v;
 }
 
-static inline void pio_write_32(ioport32_t *port, uint32_t v)
+static inline void arch_pio_write_32(ioport32_t *port, uint32_t v)
 {
 	*port = v;
 }
 
-static inline uint8_t pio_read_8(ioport8_t *port)
+static inline uint8_t arch_pio_read_8(const ioport8_t *port)
 {
 	return *port;
 }
 
-static inline uint16_t pio_read_16(ioport16_t *port)
+static inline uint16_t arch_pio_read_16(const ioport16_t *port)
 {
 	return *port;
 }
 
-static inline uint32_t pio_read_32(ioport32_t *port)
+static inline uint32_t arch_pio_read_32(const ioport32_t *port)
 {
 	return *port;
Index: uspace/lib/c/arch/arm32/Makefile.common
===================================================================
--- uspace/lib/c/arch/arm32/Makefile.common	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/lib/c/arch/arm32/Makefile.common	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -29,5 +29,5 @@
 
 BASE_LIBS += $(LIBSOFTFLOAT_PREFIX)/libsoftfloat.a
-GCC_CFLAGS += -ffixed-r9 -mtp=soft -fno-omit-frame-pointer -march=armv4 -mapcs-frame
+GCC_CFLAGS += -ffixed-r9 -mtp=soft -fno-omit-frame-pointer -mapcs-frame -march=$(subst _,-,$(PROCESSOR))
 
 ENDIANESS = LE
Index: uspace/lib/c/arch/arm32/include/ddi.h
===================================================================
--- uspace/lib/c/arch/arm32/include/ddi.h	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/lib/c/arch/arm32/include/ddi.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -37,30 +37,30 @@
 #include <libarch/types.h>
 
-static inline void pio_write_8(ioport8_t *port, uint8_t v)
+static inline void arch_pio_write_8(ioport8_t *port, uint8_t v)
 {
 	*port = v;
 }
 
-static inline void pio_write_16(ioport16_t *port, uint16_t v)
+static inline void arch_pio_write_16(ioport16_t *port, uint16_t v)
 {
 	*port = v;
 }
 
-static inline void pio_write_32(ioport32_t *port, uint32_t v)
+static inline void arch_pio_write_32(ioport32_t *port, uint32_t v)
 {
 	*port = v;
 }
 
-static inline uint8_t pio_read_8(ioport8_t *port)
+static inline uint8_t arch_pio_read_8(const ioport8_t *port)
 {
 	return *port;
 }
 
-static inline uint16_t pio_read_16(ioport16_t *port)
+static inline uint16_t arch_pio_read_16(const ioport16_t *port)
 {
 	return *port;
 }
 
-static inline uint32_t pio_read_32(ioport32_t *port)
+static inline uint32_t arch_pio_read_32(const ioport32_t *port)
 {
 	return *port;
Index: uspace/lib/c/arch/ia32/include/ddi.h
===================================================================
--- uspace/lib/c/arch/ia32/include/ddi.h	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/lib/c/arch/ia32/include/ddi.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -39,5 +39,5 @@
 #define IO_SPACE_BOUNDARY  ((void *) (64 * 1024))
 
-static inline uint8_t pio_read_8(ioport8_t *port)
+static inline uint8_t arch_pio_read_8(const ioport8_t *port)
 {
 	if (port < (ioport8_t *) IO_SPACE_BOUNDARY) {
@@ -55,5 +55,5 @@
 }
 
-static inline uint16_t pio_read_16(ioport16_t *port)
+static inline uint16_t arch_pio_read_16(const ioport16_t *port)
 {
 	if (port < (ioport16_t *) IO_SPACE_BOUNDARY) {
@@ -71,5 +71,5 @@
 }
 
-static inline uint32_t pio_read_32(ioport32_t *port)
+static inline uint32_t arch_pio_read_32(const ioport32_t *port)
 {
 	if (port < (ioport32_t *) IO_SPACE_BOUNDARY) {
@@ -87,5 +87,5 @@
 }
 
-static inline void pio_write_8(ioport8_t *port, uint8_t val)
+static inline void arch_pio_write_8(ioport8_t *port, uint8_t val)
 {
 	if (port < (ioport8_t *) IO_SPACE_BOUNDARY) {
@@ -98,5 +98,5 @@
 }
 
-static inline void pio_write_16(ioport16_t *port, uint16_t val)
+static inline void arch_pio_write_16(ioport16_t *port, uint16_t val)
 {
 	if (port < (ioport16_t *) IO_SPACE_BOUNDARY) {
@@ -109,5 +109,5 @@
 }
 
-static inline void pio_write_32(ioport32_t *port, uint32_t val)
+static inline void arch_pio_write_32(ioport32_t *port, uint32_t val)
 {
 	if (port < (ioport32_t *) IO_SPACE_BOUNDARY) {
Index: uspace/lib/c/arch/ia64/include/ddi.h
===================================================================
--- uspace/lib/c/arch/ia64/include/ddi.h	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/lib/c/arch/ia64/include/ddi.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -50,5 +50,5 @@
 	    (ia64_iospace_address = get_ia64_iospace_address()))
 
-static inline void pio_write_8(ioport8_t *port, uint8_t v)
+static inline void arch_pio_write_8(ioport8_t *port, uint8_t v)
 {
 	if (port < (ioport8_t *) IO_SPACE_BOUNDARY) {
@@ -65,5 +65,5 @@
 }
 
-static inline void pio_write_16(ioport16_t *port, uint16_t v)
+static inline void arch_pio_write_16(ioport16_t *port, uint16_t v)
 {
 	if (port < (ioport16_t *) IO_SPACE_BOUNDARY) {
@@ -80,5 +80,5 @@
 }
 
-static inline void pio_write_32(ioport32_t *port, uint32_t v)
+static inline void arch_pio_write_32(ioport32_t *port, uint32_t v)
 {
 	if (port < (ioport32_t *) IO_SPACE_BOUNDARY) {
@@ -95,5 +95,5 @@
 }
 
-static inline uint8_t pio_read_8(ioport8_t *port)
+static inline uint8_t arch_pio_read_8(const ioport8_t *port)
 {
 	uint8_t v;
@@ -115,5 +115,5 @@
 }
 
-static inline uint16_t pio_read_16(ioport16_t *port)
+static inline uint16_t arch_pio_read_16(const ioport16_t *port)
 {
 	uint16_t v;
@@ -135,5 +135,5 @@
 }
 
-static inline uint32_t pio_read_32(ioport32_t *port)
+static inline uint32_t arch_pio_read_32(const ioport32_t *port)
 {
 	uint32_t v;
Index: uspace/lib/c/arch/ia64/src/ddi.c
===================================================================
--- uspace/lib/c/arch/ia64/src/ddi.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/lib/c/arch/ia64/src/ddi.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -1,2 +1,29 @@
+/*
+ * Copyright (c) 2006 Martin Decky
+ * 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.
+ */
 #include <libarch/ddi.h>
 #include <sysinfo.h>
@@ -12,3 +39,2 @@
 	return addr;
 }
-
Index: uspace/lib/c/arch/mips32/include/ddi.h
===================================================================
--- uspace/lib/c/arch/mips32/include/ddi.h	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/lib/c/arch/mips32/include/ddi.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -37,30 +37,30 @@
 #include <libarch/types.h>
 
-static inline void pio_write_8(ioport8_t *port, uint8_t v)
+static inline void arch_pio_write_8(ioport8_t *port, uint8_t v)
 {
 	*port = v;
 }
 
-static inline void pio_write_16(ioport16_t *port, uint16_t v)
+static inline void arch_pio_write_16(ioport16_t *port, uint16_t v)
 {
 	*port = v;
 }
 
-static inline void pio_write_32(ioport32_t *port, uint32_t v)
+static inline void arch_pio_write_32(ioport32_t *port, uint32_t v)
 {
 	*port = v;
 }
 
-static inline uint8_t pio_read_8(ioport8_t *port)
+static inline uint8_t arch_pio_read_8(const ioport8_t *port)
 {
 	return *port;
 }
 
-static inline uint16_t pio_read_16(ioport16_t *port)
+static inline uint16_t arch_pio_read_16(const ioport16_t *port)
 {
 	return *port;
 }
 
-static inline uint32_t pio_read_32(ioport32_t *port)
+static inline uint32_t arch_pio_read_32(const ioport32_t *port)
 {
 	return *port;
Index: uspace/lib/c/arch/mips64/include/ddi.h
===================================================================
--- uspace/lib/c/arch/mips64/include/ddi.h	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/lib/c/arch/mips64/include/ddi.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -37,30 +37,30 @@
 #include <libarch/types.h>
 
-static inline void pio_write_8(ioport8_t *port, uint8_t v)
+static inline void arch_pio_write_8(ioport8_t *port, uint8_t v)
 {
 	*port = v;
 }
 
-static inline void pio_write_16(ioport16_t *port, uint16_t v)
+static inline void arch_pio_write_16(ioport16_t *port, uint16_t v)
 {
 	*port = v;
 }
 
-static inline void pio_write_32(ioport32_t *port, uint32_t v)
+static inline void arch_pio_write_32(ioport32_t *port, uint32_t v)
 {
 	*port = v;
 }
 
-static inline uint8_t pio_read_8(ioport8_t *port)
+static inline uint8_t arch_pio_read_8(const ioport8_t *port)
 {
 	return *port;
 }
 
-static inline uint16_t pio_read_16(ioport16_t *port)
+static inline uint16_t arch_pio_read_16(const ioport16_t *port)
 {
 	return *port;
 }
 
-static inline uint32_t pio_read_32(ioport32_t *port)
+static inline uint32_t arch_pio_read_32(const ioport32_t *port)
 {
 	return *port;
Index: uspace/lib/c/arch/ppc32/include/ddi.h
===================================================================
--- uspace/lib/c/arch/ppc32/include/ddi.h	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/lib/c/arch/ppc32/include/ddi.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -37,30 +37,30 @@
 #include <libarch/types.h>
 
-static inline void pio_write_8(ioport8_t *port, uint8_t v)
+static inline void arch_pio_write_8(ioport8_t *port, uint8_t v)
 {
 	*port = v;
 }
 
-static inline void pio_write_16(ioport16_t *port, uint16_t v)
+static inline void arch_pio_write_16(ioport16_t *port, uint16_t v)
 {
 	*port = v;
 }
 
-static inline void pio_write_32(ioport32_t *port, uint32_t v)
+static inline void arch_pio_write_32(ioport32_t *port, uint32_t v)
 {
 	*port = v;
 }
 
-static inline uint8_t pio_read_8(ioport8_t *port)
+static inline uint8_t arch_pio_read_8(const ioport8_t *port)
 {
 	return *port;
 }
 
-static inline uint16_t pio_read_16(ioport16_t *port)
+static inline uint16_t arch_pio_read_16(const ioport16_t *port)
 {
 	return *port;
 }
 
-static inline uint32_t pio_read_32(ioport32_t *port)
+static inline uint32_t arch_pio_read_32(const ioport32_t *port)
 {
 	return *port;
Index: uspace/lib/c/arch/sparc64/include/ddi.h
===================================================================
--- uspace/lib/c/arch/sparc64/include/ddi.h	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/lib/c/arch/sparc64/include/ddi.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -45,5 +45,5 @@
 }
 
-static inline void pio_write_8(ioport8_t *port, uint8_t v)
+static inline void arch_pio_write_8(ioport8_t *port, uint8_t v)
 {
 	*port = v;
@@ -51,5 +51,5 @@
 }
 
-static inline void pio_write_16(ioport16_t *port, uint16_t v)
+static inline void arch_pio_write_16(ioport16_t *port, uint16_t v)
 {
 	*port = v;
@@ -57,5 +57,5 @@
 }
 
-static inline void pio_write_32(ioport32_t *port, uint32_t v)
+static inline void arch_pio_write_32(ioport32_t *port, uint32_t v)
 {
 	*port = v;
@@ -63,5 +63,5 @@
 }
 
-static inline uint8_t pio_read_8(ioport8_t *port)
+static inline uint8_t arch_pio_read_8(const ioport8_t *port)
 {
 	uint8_t rv;
@@ -73,5 +73,5 @@
 }
 
-static inline uint16_t pio_read_16(ioport16_t *port)
+static inline uint16_t arch_pio_read_16(const ioport16_t *port)
 {
 	uint16_t rv;
@@ -83,5 +83,5 @@
 }
 
-static inline uint32_t pio_read_32(ioport32_t *port)
+static inline uint32_t arch_pio_read_32(const ioport32_t *port)
 {
 	uint32_t rv;
Index: uspace/lib/c/generic/ddi.c
===================================================================
--- uspace/lib/c/generic/ddi.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/lib/c/generic/ddi.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -34,5 +34,7 @@
 
 #include <assert.h>
+#include <atomic.h>
 #include <unistd.h>
+#include <stdio.h>
 #include <errno.h>
 #include <sys/types.h>
@@ -47,4 +49,5 @@
 #include "private/libc.h"
 
+
 /** Return unique device number.
  *
@@ -120,11 +123,11 @@
  *
  */
-int iospace_enable(task_id_t id, void *ioaddr, unsigned long size)
-{
-	ddi_ioarg_t arg;
-	
-	arg.task_id = id;
-	arg.ioaddr = ioaddr;
-	arg.size = size;
+static int iospace_enable(task_id_t id, void *ioaddr, size_t size)
+{
+	const ddi_ioarg_t arg = {
+		.task_id = id,
+		.ioaddr = ioaddr,
+		.size = size
+	};
 	
 	return __SYSCALL1(SYS_IOSPACE_ENABLE, (sysarg_t) &arg);
@@ -136,5 +139,5 @@
  * @param size     Size of the I/O region.
  * @param virt     Virtual address for application's
- *                 PIO operations.
+ *                 PIO operations. Can be NULL for PMIO.
  *
  * @return EOK on success.
@@ -146,9 +149,14 @@
 #ifdef IO_SPACE_BOUNDARY
 	if (pio_addr < IO_SPACE_BOUNDARY) {
-		*virt = pio_addr;
+		if (virt)
+			*virt = pio_addr;
 		return iospace_enable(task_get_id(), pio_addr, size);
 	}
+#else
+	(void) iospace_enable;
 #endif
-	
+	if (!virt)
+		return EINVAL;
+
 	void *phys_frame =
 	    (void *) ALIGN_DOWN((uintptr_t) pio_addr, PAGE_SIZE);
@@ -166,4 +174,43 @@
 }
 
+void pio_write_8(ioport8_t *reg, uint8_t val)
+{
+	pio_trace_log(reg, val, true);
+	arch_pio_write_8(reg, val);
+}
+
+void pio_write_16(ioport16_t *reg, uint16_t val)
+{
+	pio_trace_log(reg, val, true);
+	arch_pio_write_16(reg, val);
+}
+
+void pio_write_32(ioport32_t *reg, uint32_t val)
+{
+	pio_trace_log(reg, val, true);
+	arch_pio_write_32(reg, val);
+}
+
+uint8_t pio_read_8(const ioport8_t *reg)
+{
+	const uint8_t val = arch_pio_read_8(reg);
+	pio_trace_log(reg, val, false);
+	return val;
+}
+
+uint16_t pio_read_16(const ioport16_t *reg)
+{
+	const uint16_t val = arch_pio_read_16(reg);
+	pio_trace_log(reg, val, false);
+	return val;
+}
+
+uint32_t pio_read_32(const ioport32_t *reg)
+{
+	const uint32_t val = arch_pio_read_32(reg);
+	pio_trace_log(reg, val, false);
+	return val;
+}
+
 /** Register IRQ notification.
  *
Index: uspace/lib/c/generic/fibril.c
===================================================================
--- uspace/lib/c/generic/fibril.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/lib/c/generic/fibril.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -37,6 +37,9 @@
 #include <fibril.h>
 #include <thread.h>
+#include <stack.h>
 #include <tls.h>
 #include <malloc.h>
+#include <abi/mm/as.h>
+#include <as.h>
 #include <unistd.h>
 #include <stdio.h>
@@ -46,8 +49,4 @@
 #include <assert.h>
 #include <async.h>
-
-#ifndef FIBRIL_INITIAL_STACK_PAGES_NO
-	#define FIBRIL_INITIAL_STACK_PAGES_NO  1
-#endif
 
 /**
@@ -195,5 +194,5 @@
 					 * stack member filled.
 					 */
-					free(stack);
+					as_area_destroy(stack);
 				}
 				fibril_teardown(srcf->clean_after_me);
@@ -269,7 +268,9 @@
 		return 0;
 	
-	fibril->stack =
-	    (char *) malloc(FIBRIL_INITIAL_STACK_PAGES_NO * getpagesize());
-	if (!fibril->stack) {
+	size_t stack_size = stack_size_get();
+	fibril->stack = as_area_create((void *) -1, stack_size,
+	    AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE | AS_AREA_GUARD |
+	    AS_AREA_LATE_RESERVE);
+	if (fibril->stack == (void *) -1) {
 		fibril_teardown(fibril);
 		return 0;
@@ -281,5 +282,5 @@
 	context_save(&fibril->ctx);
 	context_set(&fibril->ctx, FADDR(fibril_main), fibril->stack,
-	    FIBRIL_INITIAL_STACK_PAGES_NO * getpagesize(), fibril->tcb);
+	    stack_size, fibril->tcb);
 
 	return (fid_t) fibril;
@@ -298,5 +299,5 @@
 	fibril_t *fibril = (fibril_t *) fid;
 	
-	free(fibril->stack);
+	as_area_destroy(fibril->stack);
 	fibril_teardown(fibril);
 }
Index: uspace/lib/c/generic/malloc.c
===================================================================
--- uspace/lib/c/generic/malloc.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/lib/c/generic/malloc.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -289,5 +289,5 @@
 	size_t asize = ALIGN_UP(size, PAGE_SIZE);
 	void *astart = as_area_create(AS_AREA_ANY, asize,
-	    AS_AREA_WRITE | AS_AREA_READ);
+	    AS_AREA_WRITE | AS_AREA_READ | AS_AREA_CACHEABLE);
 	if (astart == AS_MAP_FAILED)
 		return false;
Index: uspace/lib/c/generic/pio_trace.c
===================================================================
--- uspace/lib/c/generic/pio_trace.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
+++ uspace/lib/c/generic/pio_trace.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -0,0 +1,145 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/** @file
+ */
+
+#include <assert.h>
+#include <errno.h>
+#include <malloc.h>
+#include <adt/list.h>
+#include <fibril_synch.h>
+#include <ddi.h>
+#include <str.h>
+
+
+typedef struct {
+	link_t link;
+	volatile void *base;
+	size_t size;
+	void *data;
+	trace_fnc log;
+} region_t;
+
+static inline region_t * region_instance(link_t *l)
+{
+	return list_get_instance(l, region_t, link);
+}
+
+static inline region_t * region_create(volatile void* base, size_t size,
+    trace_fnc log, void* data)
+{
+	region_t *new_reg = malloc(sizeof(region_t));
+	if (new_reg) {
+		link_initialize(&new_reg->link);
+		new_reg->base = base;
+		new_reg->data = data;
+		new_reg->size = size;
+		new_reg->log = log;
+	}
+	return new_reg;
+}
+
+static inline void region_destroy(region_t *r)
+{
+	free(r);
+}
+
+typedef struct {
+	list_t list;
+	fibril_rwlock_t guard;
+} pio_regions_t;
+
+static pio_regions_t * get_regions(void)
+{
+	static pio_regions_t regions = {
+		.list = {
+			.head = { &regions.list.head, &regions.list.head },
+		},
+		.guard = FIBRIL_RWLOCK_INITIALIZER(regions.guard),
+	};
+	return &regions;
+}
+
+
+void pio_trace_log(const volatile void *r, uint32_t val, bool write)
+{
+	pio_regions_t *regions = get_regions();
+	fibril_rwlock_read_lock(&regions->guard);
+	list_foreach(regions->list, it) {
+		assert(it);
+		region_t *reg = region_instance(it);
+		assert(reg);
+		if ((r >= reg->base) && (r < reg->base + reg->size)) {
+			if (reg->log)
+				reg->log(r, val, reg->base,
+				    reg->size, reg->data, write);
+			break;
+		}
+	}
+	fibril_rwlock_read_unlock(&regions->guard);
+}
+
+int pio_trace_enable(void *base, size_t size, trace_fnc log, void *data)
+{
+	pio_regions_t *regions = get_regions();
+	assert(regions);
+
+	region_t *region = region_create(base, size, log, data);
+	if (!region)
+		return ENOMEM;
+
+	fibril_rwlock_write_lock(&regions->guard);
+	list_append(&region->link, &regions->list);
+	fibril_rwlock_write_unlock(&regions->guard);
+	return EOK;
+}
+
+void pio_trace_disable(void *r)
+{
+	pio_regions_t *regions = get_regions();
+	assert(regions);
+
+	fibril_rwlock_write_lock(&regions->guard);
+	list_foreach_safe(regions->list, it, next) {
+		assert(it);
+		region_t *reg = region_instance(it);
+		assert(reg);
+		if (r >= reg->base && (r < reg->base + reg->size)) {
+				list_remove(&reg->link);
+				region_destroy(reg);
+		}
+	}
+	fibril_rwlock_write_unlock(&regions->guard);
+}
+
+/** @}
+ */
Index: uspace/lib/c/generic/stack.c
===================================================================
--- uspace/lib/c/generic/stack.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
+++ uspace/lib/c/generic/stack.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2012 Jakub Jermar
+ * 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 libc
+ * @{
+ */
+/** @file
+ */
+
+#include <stack.h>
+#include <sysinfo.h>
+
+size_t stack_size_get(void)
+{
+	static sysarg_t stack_size = 0;
+
+	if (!stack_size)
+		sysinfo_get_value("default.stack_size", &stack_size);
+
+	return (size_t) stack_size;
+}
+
+/** @}
+ */
Index: uspace/lib/c/generic/stdlib.c
===================================================================
--- uspace/lib/c/generic/stdlib.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/lib/c/generic/stdlib.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -39,10 +39,10 @@
 long int random(void)
 {
-	return glbl_seed = ((1366*glbl_seed + 150889) % RAND_MAX);
+	return glbl_seed = ((1366 * glbl_seed + 150889) % RAND_MAX);
 }
 
 void srandom(unsigned int seed)
 {
-	glbl_seed = seed;
+	glbl_seed = seed % RAND_MAX;
 }
 
Index: uspace/lib/c/generic/thread.c
===================================================================
--- uspace/lib/c/generic/thread.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/lib/c/generic/thread.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -39,4 +39,5 @@
 #include <abi/proc/uarg.h>
 #include <fibril.h>
+#include <stack.h>
 #include <str.h>
 #include <async.h>
@@ -44,8 +45,4 @@
 #include <as.h>
 #include "private/thread.h"
-
-#ifndef THREAD_INITIAL_STACK_PAGES
-	#define THREAD_INITIAL_STACK_PAGES  2
-#endif
 
 /** Main thread function.
@@ -101,7 +98,8 @@
 		return ENOMEM;
 	
-	size_t stack_size = getpagesize() * THREAD_INITIAL_STACK_PAGES;
+	size_t stack_size = stack_size_get();
 	void *stack = as_area_create(AS_AREA_ANY, stack_size,
-	    AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
+	    AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE | AS_AREA_GUARD |
+	    AS_AREA_LATE_RESERVE);
 	if (stack == AS_MAP_FAILED) {
 		free(uarg);
Index: uspace/lib/c/include/ddi.h
===================================================================
--- uspace/lib/c/include/ddi.h	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/lib/c/include/ddi.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -36,5 +36,7 @@
 #define LIBC_DDI_H_
 
+#include <bool.h>
 #include <sys/types.h>
+#include <sys/time.h>
 #include <abi/ddi/irq.h>
 #include <task.h>
@@ -50,6 +52,73 @@
 extern int dmamem_unmap_anonymous(void *);
 
-extern int iospace_enable(task_id_t, void *, unsigned long);
 extern int pio_enable(void *, size_t, void **);
+
+typedef void (*trace_fnc)(const volatile void *place, uint32_t val,
+    volatile void* base, size_t size, void *data, bool write);
+
+extern int pio_trace_enable(void *, size_t, trace_fnc, void *);
+extern void pio_trace_log(const volatile void *, uint32_t val, bool write);
+extern void pio_trace_disable(void *);
+
+extern void pio_write_8(ioport8_t *, uint8_t);
+extern void pio_write_16(ioport16_t *, uint16_t);
+extern void pio_write_32(ioport32_t *, uint32_t);
+
+extern uint8_t pio_read_8(const ioport8_t *);
+extern uint16_t pio_read_16(const ioport16_t *);
+extern uint32_t pio_read_32(const ioport32_t *);
+
+static inline uint8_t pio_change_8(
+    ioport8_t *reg, uint8_t val, uint8_t mask, useconds_t delay)
+{
+	uint8_t v = pio_read_8(reg);
+	udelay(delay);
+	pio_write_8(reg, (v & ~mask) | val);
+	return v;
+}
+
+static inline uint16_t pio_change_16(
+    ioport16_t *reg, uint16_t val, uint16_t mask, useconds_t delay)
+{
+	uint16_t v = pio_read_16(reg);
+	udelay(delay);
+	pio_write_16(reg, (v & ~mask) | val);
+	return v;
+}
+
+static inline uint32_t pio_change_32(
+    ioport32_t *reg, uint32_t val, uint32_t mask, useconds_t delay)
+{
+	uint32_t v = pio_read_32(reg);
+	udelay(delay);
+	pio_write_32(reg, (v & ~mask) | val);
+	return v;
+}
+
+static inline uint8_t pio_set_8(ioport8_t *r, uint8_t v, useconds_t d)
+{
+	return pio_change_8(r, v, 0, d);
+}
+static inline uint16_t pio_set_16(ioport16_t *r, uint16_t v, useconds_t d)
+{
+	return pio_change_16(r, v, 0, d);
+}
+static inline uint32_t pio_set_32(ioport32_t *r, uint32_t v, useconds_t d)
+{
+	return pio_change_32(r, v, 0, d);
+}
+
+static inline uint8_t pio_clear_8(ioport8_t *r, uint8_t v, useconds_t d)
+{
+	return pio_change_8(r, 0, v, d);
+}
+static inline uint16_t pio_clear_16(ioport16_t *r, uint16_t v, useconds_t d)
+{
+	return pio_change_16(r, 0, v, d);
+}
+static inline uint32_t pio_clear_32(ioport32_t *r, uint32_t v, useconds_t d)
+{
+	return pio_change_32(r, 0, v, d);
+}
 
 extern int irq_register(int, int, int, irq_code_t *);
Index: uspace/lib/c/include/macros.h
===================================================================
--- uspace/lib/c/include/macros.h	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/lib/c/include/macros.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -62,4 +62,10 @@
 #endif
 
+#define _paddname(line) PADD_ ## line ## __
+#define _padd(width, line) uint ## width ## _t _paddname(line)
+#define PADD32 _padd(32, __LINE__)
+#define PADD16 _padd(16, __LINE__)
+#define PADD8 _padd(8, __LINE__)
+
 /** @}
  */
Index: uspace/lib/c/include/stack.h
===================================================================
--- uspace/lib/c/include/stack.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
+++ uspace/lib/c/include/stack.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2012 Jakub Jermar
+ * 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 libc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_STACK_H_
+#define LIBC_STACK_H_
+
+#include <libarch/types.h>
+
+extern size_t stack_size_get(void);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/softfloat/common.c
===================================================================
--- uspace/lib/softfloat/common.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/lib/softfloat/common.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -39,5 +39,5 @@
 /* Table for fast leading zeroes counting. */
 char zeroTable[256] = {
-	8, 7, 7, 6, 6, 6, 6, 4, 4, 4, 4, 4, 4, 4, 4, \
+	8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, \
 	3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \
 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
@@ -307,16 +307,24 @@
 /**
  * Round and normalize number expressed by exponent and fraction with
- * first bit (equal to hidden bit) at 62nd bit.
+ * first bit (equal to hidden bit) at bit 62.
  *
  * @param exp Exponent part.
- * @param fraction Fraction with hidden bit shifted to 62nd bit.
+ * @param fraction Fraction with hidden bit shifted to bit 62.
  */
 void round_float64(int32_t *exp, uint64_t *fraction)
 {
-	/* rounding - if first bit after fraction is set then round up */
+	/*
+	 * Rounding - if first bit after fraction is set then round up.
+	 */
+
+	/*
+	 * Add 1 to the least significant bit of the fraction respecting the
+	 * current shift to bit 62 and see if there will be a carry to bit 63.
+	 */
 	(*fraction) += (0x1 << (64 - FLOAT64_FRACTION_SIZE - 3));
 	
+	/* See if there was a carry to bit 63. */
 	if ((*fraction) & 
-	    (FLOAT64_HIDDEN_BIT_MASK << (64 - FLOAT64_FRACTION_SIZE - 3))) {
+	    (FLOAT64_HIDDEN_BIT_MASK << (64 - FLOAT64_FRACTION_SIZE - 1))) {
 		/* rounding overflow */
 		++(*exp);
Index: uspace/lib/usbdev/include/usb/dev/request.h
===================================================================
--- uspace/lib/usbdev/include/usb/dev/request.h	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/lib/usbdev/include/usb/dev/request.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -93,8 +93,8 @@
 	uint8_t request;
 	/** Main parameter to the request. */
-	union {
+	union __attribute__ ((packed)) {
 		uint16_t value;
 		/* FIXME: add #ifdefs according to host endianness */
-		struct {
+		struct __attribute__ ((packed)) {
 			uint8_t value_low;
 			uint8_t value_high;
@@ -108,4 +108,6 @@
 	uint16_t length;
 } __attribute__ ((packed)) usb_device_request_setup_packet_t;
+
+int assert[(sizeof(usb_device_request_setup_packet_t) == 8) ? 1: -1];
 
 int usb_control_request_set(usb_pipe_t *,
Index: uspace/srv/bd/ata_bd/ata_bd.c
===================================================================
--- uspace/srv/bd/ata_bd/ata_bd.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/srv/bd/ata_bd/ata_bd.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -49,5 +49,4 @@
 
 #include <stdio.h>
-#include <libarch/ddi.h>
 #include <ddi.h>
 #include <async.h>
Index: uspace/srv/bd/gxe_bd/gxe_bd.c
===================================================================
--- uspace/srv/bd/gxe_bd/gxe_bd.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/srv/bd/gxe_bd/gxe_bd.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -37,5 +37,4 @@
 
 #include <stdio.h>
-#include <libarch/ddi.h>
 #include <ddi.h>
 #include <async.h>
Index: uspace/srv/hid/input/port/pl050.c
===================================================================
--- uspace/srv/hid/input/port/pl050.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/srv/hid/input/port/pl050.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -37,9 +37,7 @@
 
 #include <ddi.h>
-#include <libarch/ddi.h>
 #include <async.h>
 #include <unistd.h>
 #include <sysinfo.h>
-#include <ddi.h>
 #include <stdio.h>
 #include <errno.h>
Index: uspace/srv/hid/output/port/ega.c
===================================================================
--- uspace/srv/hid/output/port/ega.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/srv/hid/output/port/ega.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -36,5 +36,4 @@
 #include <as.h>
 #include <ddi.h>
-#include <libarch/ddi.h>
 #include <io/chargrid.h>
 #include "../output.h"
@@ -211,6 +210,5 @@
 		return rc;
 	
-	rc = iospace_enable(task_get_id(), (void *) EGA_IO_BASE,
-	    EGA_IO_SIZE);
+	rc = pio_enable((void*)EGA_IO_BASE, EGA_IO_SIZE, NULL);
 	if (rc != EOK)
 		return rc;
Index: uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c
===================================================================
--- uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -38,5 +38,4 @@
 
 #include <ddi.h>
-#include <libarch/ddi.h>
 #include <loc.h>
 #include <io/console.h>
Index: uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c
===================================================================
--- uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -38,5 +38,4 @@
 
 #include <ddi.h>
-#include <libarch/ddi.h>
 #include <loc.h>
 #include <ipc/char.h>
Index: uspace/srv/hw/irc/i8259/i8259.c
===================================================================
--- uspace/srv/hw/irc/i8259/i8259.c	(revision 82edef2f5532d5ca29a1c05cbe6b80ccf84adbd2)
+++ uspace/srv/hw/irc/i8259/i8259.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -42,5 +42,4 @@
 #include <as.h>
 #include <ddi.h>
-#include <libarch/ddi.h>
 #include <align.h>
 #include <bool.h>
