Index: boot/arch/arm32/Makefile.inc
===================================================================
--- boot/arch/arm32/Makefile.inc	(revision 293703eac83c474ec39de43bd1ee4aa8557d6286)
+++ boot/arch/arm32/Makefile.inc	(revision 312e5ff64a7e4151a05801b65b38da2bbe914da0)
@@ -60,12 +60,23 @@
 
 ifeq ($(MACHINE), gta02)
-RD_SRVS_ESSENTIAL += \
-	$(USPACE_PATH)/srv/hid/s3c24xx_ts/s3c24xx_ts \
-	$(USPACE_PATH)/srv/hw/char/s3c24xx_uart/s3c24ser
+	RD_SRVS_ESSENTIAL += \
+		$(USPACE_PATH)/srv/hid/s3c24xx_ts/s3c24xx_ts \
+		$(USPACE_PATH)/srv/hw/char/s3c24xx_uart/s3c24ser
+endif
+
+ifeq ($(MACHINE), $(filter $(MACHINE),beagleboardxm beaglebone))
+	RD_DRVS_ESSENTIAL += \
+		platform/amdm37x \
+		fb/amdm37x_dispc
+endif
+
+ifeq ($(MACHINE), integratorcp)
+	RD_DRVS_ESSENTIAL += \
+		char/pl050 \
+		char/xtkbd \
+		platform/icp
 endif
 
 RD_DRVS_ESSENTIAL += \
-	platform/amdm37x \
-	fb/amdm37x_dispc \
 	bus/usb/ehci \
 	bus/usb/ohci \
Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision 293703eac83c474ec39de43bd1ee4aa8557d6286)
+++ uspace/Makefile	(revision 312e5ff64a7e4151a05801b65b38da2bbe914da0)
@@ -136,4 +136,5 @@
 	drv/block/ata_bd \
 	drv/char/i8042 \
+	drv/char/pl050 \
 	drv/char/ps2mouse \
 	drv/char/xtkbd \
@@ -155,5 +156,6 @@
 	drv/nic/e1k \
 	drv/nic/rtl8139 \
-	drv/nic/rtl8169
+	drv/nic/rtl8169 \
+	drv/platform/icp
 
 ## Platform-specific hardware support
Index: uspace/drv/char/pl050/Makefile
===================================================================
--- uspace/drv/char/pl050/Makefile	(revision 312e5ff64a7e4151a05801b65b38da2bbe914da0)
+++ uspace/drv/char/pl050/Makefile	(revision 312e5ff64a7e4151a05801b65b38da2bbe914da0)
@@ -0,0 +1,37 @@
+#
+# Copyright (c) 2014 Jiri Svoboda
+# 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 = pl050
+
+SOURCES = \
+	pl050.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/char/pl050/pl050.c
===================================================================
--- uspace/drv/char/pl050/pl050.c	(revision 312e5ff64a7e4151a05801b65b38da2bbe914da0)
+++ uspace/drv/char/pl050/pl050.c	(revision 312e5ff64a7e4151a05801b65b38da2bbe914da0)
@@ -0,0 +1,361 @@
+/*
+ * Copyright (c) 2009 Vineeth Pillai
+ * Copyright (c) 2014 Jiri Svoboda
+ * 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.
+ */
+
+/** @file
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <errno.h>
+#include <ddf/driver.h>
+#include <ddf/interrupt.h>
+#include <ddf/log.h>
+#include <device/hw_res_parsed.h>
+
+#define NAME "pl050"
+
+#define PL050_STAT	4
+#define PL050_DATA	8
+
+#define PL050_STAT_RXFULL  (1 << 4)
+
+enum {
+	IPC_CHAR_READ = DEV_FIRST_CUSTOM_METHOD,
+	IPC_CHAR_WRITE,
+};
+
+enum {
+	buffer_size = 64
+};
+
+static int pl050_dev_add(ddf_dev_t *);
+static int pl050_fun_online(ddf_fun_t *);
+static int pl050_fun_offline(ddf_fun_t *);
+static void pl050_char_conn(ipc_callid_t, ipc_call_t *, void *);
+
+static driver_ops_t driver_ops = {
+	.dev_add = &pl050_dev_add,
+	.fun_online = &pl050_fun_online,
+	.fun_offline = &pl050_fun_offline
+};
+
+static driver_t pl050_driver = {
+	.name = NAME,
+	.driver_ops = &driver_ops
+};
+
+typedef struct {
+	ddf_dev_t *dev;
+	ddf_fun_t *fun_a;
+	async_sess_t *parent_sess;
+	uintptr_t iobase;
+	size_t iosize;
+	uint8_t buffer[buffer_size];
+	size_t buf_rp;
+	size_t buf_wp;
+	fibril_condvar_t buf_cv;
+	fibril_mutex_t buf_lock;
+} pl050_t;
+
+static irq_pio_range_t pl050_ranges[] = {
+	{
+		.base = 0,
+		.size = 9,
+	}
+};
+
+static irq_cmd_t pl050_cmds[] = {
+	{
+		.cmd = CMD_PIO_READ_8,
+		.addr = NULL,
+		.dstarg = 1
+	},
+	{
+		.cmd = CMD_AND,
+		.value = PL050_STAT_RXFULL,
+		.srcarg = 1,
+		.dstarg = 3
+	},
+	{
+		.cmd = CMD_PREDICATE,
+		.value = 2,
+		.srcarg = 3
+	},
+	{
+		.cmd = CMD_PIO_READ_8,
+		.addr = NULL,  /* Will be patched in run-time */
+		.dstarg = 2
+	},
+	{
+		.cmd = CMD_ACCEPT
+	}
+};
+
+static irq_code_t pl050_irq_code = {
+	sizeof(pl050_ranges) / sizeof(irq_pio_range_t),
+	pl050_ranges,
+	sizeof(pl050_cmds) / sizeof(irq_cmd_t),
+	pl050_cmds
+};
+
+static pl050_t *pl050_from_fun(ddf_fun_t *fun)
+{
+	return (pl050_t *)ddf_dev_data_get(ddf_fun_get_dev(fun));
+}
+
+static void pl050_interrupt(ipc_callid_t iid, ipc_call_t *call, ddf_dev_t *dev)
+{
+	pl050_t *pl050 = (pl050_t *)ddf_dev_data_get(dev);
+	size_t nidx;
+
+	fibril_mutex_lock(&pl050->buf_lock);
+	nidx = (pl050->buf_wp + 1) % buffer_size;
+	if (nidx == pl050->buf_rp) {
+		/** Buffer overrunt */
+		ddf_msg(LVL_WARN, "Buffer overrun.");
+		fibril_mutex_unlock(&pl050->buf_lock);
+		return;
+	}
+
+	pl050->buffer[pl050->buf_wp] = IPC_GET_ARG2(*call);
+	pl050->buf_wp = nidx;
+	fibril_condvar_broadcast(&pl050->buf_cv);
+	fibril_mutex_unlock(&pl050->buf_lock);
+}
+
+static int pl050_init(pl050_t *pl050)
+{
+	hw_res_list_parsed_t res;
+	int rc;
+
+	fibril_mutex_initialize(&pl050->buf_lock);
+	fibril_condvar_initialize(&pl050->buf_cv);
+	pl050->buf_rp = pl050->buf_wp = 0;
+
+	pl050->parent_sess = ddf_dev_parent_sess_create(pl050->dev,
+	    EXCHANGE_SERIALIZE);
+	if (pl050->parent_sess == NULL) {
+		ddf_msg(LVL_ERROR, "Failed connecitng parent driver.");
+		rc = ENOMEM;
+		goto error;
+	}
+
+	hw_res_list_parsed_init(&res);
+	rc = hw_res_get_list_parsed(pl050->parent_sess, &res, 0);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Failed getting resource list.");
+		goto error;
+	}
+
+	if (res.mem_ranges.count != 1) {
+		ddf_msg(LVL_ERROR, "Expected exactly one memory range.");
+		rc = EINVAL;
+		goto error;
+	}
+
+	pl050->iobase = RNGABS(res.mem_ranges.ranges[0]);
+	pl050->iosize = RNGSZ(res.mem_ranges.ranges[0]);
+
+	pl050_irq_code.ranges[0].base = pl050->iobase;
+	pl050_irq_code.cmds[0].addr = (void *) pl050->iobase + PL050_STAT;
+	pl050_irq_code.cmds[3].addr = (void *) pl050->iobase + PL050_DATA;
+
+	if (res.irqs.count != 1) {
+		ddf_msg(LVL_ERROR, "Expected exactly one IRQ.");
+		rc = EINVAL;
+		goto error;
+	}
+
+	ddf_msg(LVL_DEBUG, "iobase=%p irq=%d", (void *)pl050->iobase,
+	    res.irqs.irqs[0]);
+
+	rc = register_interrupt_handler(pl050->dev, res.irqs.irqs[0],
+	    pl050_interrupt, &pl050_irq_code);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Failed registering interrupt handler. (%d)",
+		    rc);
+		goto error;
+	}
+
+	return EOK;
+error:
+	return rc;
+}
+
+static int pl050_read(pl050_t *pl050, void *buffer, size_t size)
+{
+	uint8_t *bp = buffer;
+	fibril_mutex_lock(&pl050->buf_lock);
+
+	while (size > 0) {
+		while (pl050->buf_rp == pl050->buf_wp)
+			fibril_condvar_wait(&pl050->buf_cv, &pl050->buf_lock);
+		*bp++ = pl050->buffer[pl050->buf_rp];
+		--size;
+		pl050->buf_rp = (pl050->buf_rp + 1) % buffer_size;
+	}
+
+	fibril_mutex_unlock(&pl050->buf_lock);
+
+	return EOK;
+}
+
+static int pl050_write(pl050_t *pl050, void *data, size_t size)
+{
+	return EOK;
+}
+
+void pl050_char_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)
+{
+	pl050_t *pl050 = pl050_from_fun((ddf_fun_t *)arg);
+
+	/* Accept the connection */
+	async_answer_0(iid, EOK);
+
+	while (true) {
+		ipc_call_t call;
+		ipc_callid_t callid = async_get_call(&call);
+		sysarg_t method = IPC_GET_IMETHOD(call);
+		size_t size = IPC_GET_ARG1(call);
+
+		if (!method) {
+			/* The other side has hung up */
+			async_answer_0(callid, EOK);
+			break;
+		}
+
+		switch (method) {
+		case IPC_CHAR_READ:
+			if (size <= 4 * sizeof(sysarg_t)) {
+				sysarg_t message[4] = {};
+
+				pl050_read(pl050, (char *) message, size);
+				async_answer_4(callid, size, message[0], message[1],
+				    message[2], message[3]);
+			} else
+				async_answer_0(callid, ELIMIT);
+			break;
+
+		case IPC_CHAR_WRITE:
+			if (size <= 3 * sizeof(sysarg_t)) {
+				const sysarg_t message[3] = {
+					IPC_GET_ARG2(call),
+					IPC_GET_ARG3(call),
+					IPC_GET_ARG4(call)
+				};
+
+				pl050_write(pl050, (char *) message, size);
+				async_answer_0(callid, size);
+			} else
+				async_answer_0(callid, ELIMIT);
+
+		default:
+			async_answer_0(callid, EINVAL);
+		}
+	}
+}
+
+/** Add device. */
+static int pl050_dev_add(ddf_dev_t *dev)
+{
+	ddf_fun_t *fun_a;
+	pl050_t *pl050;
+	int rc;
+
+	ddf_msg(LVL_DEBUG, "pl050_dev_add()");
+
+	pl050 = ddf_dev_data_alloc(dev, sizeof(pl050_t));
+	if (pl050 == NULL) {
+		ddf_msg(LVL_ERROR, "Failed allocating soft state.\n");
+		rc = ENOMEM;
+		goto error;
+	}
+
+	fun_a = ddf_fun_create(dev, fun_inner, "a");
+	if (fun_a == NULL) {
+		ddf_msg(LVL_ERROR, "Failed creating function 'a'.");
+		rc = ENOMEM;
+		goto error;
+	}
+
+	pl050->fun_a = fun_a;
+	pl050->dev = dev;
+
+	rc = pl050_init(pl050);
+	if (rc != EOK)
+		goto error;
+
+	rc = ddf_fun_add_match_id(fun_a, "char/xtkbd", 10);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s",
+		    "char/xtkbd");
+		goto error;
+	}
+
+	ddf_fun_set_conn_handler(fun_a, pl050_char_conn);
+
+	rc = ddf_fun_bind(fun_a);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Failed binding function 'a'. (%d)", rc);
+		ddf_fun_destroy(fun_a);
+		goto error;
+	}
+
+	ddf_msg(LVL_DEBUG, "Device added.");
+	return EOK;
+error:
+	return rc;
+}
+
+static int pl050_fun_online(ddf_fun_t *fun)
+{
+	ddf_msg(LVL_DEBUG, "pl050_fun_online()");
+	return ddf_fun_online(fun);
+}
+
+static int pl050_fun_offline(ddf_fun_t *fun)
+{
+	ddf_msg(LVL_DEBUG, "pl050_fun_offline()");
+	return ddf_fun_offline(fun);
+}
+
+int main(int argc, char *argv[])
+{
+	int rc;
+
+	printf(NAME ": HelenOS pl050 serial device driver\n");
+	rc = ddf_log_init(NAME);
+	if (rc != EOK) {
+		printf(NAME ": Error connecting logging service.");
+		return 1;
+	}
+
+	return ddf_driver_main(&pl050_driver);
+}
+
Index: uspace/drv/char/pl050/pl050.ma
===================================================================
--- uspace/drv/char/pl050/pl050.ma	(revision 312e5ff64a7e4151a05801b65b38da2bbe914da0)
+++ uspace/drv/char/pl050/pl050.ma	(revision 312e5ff64a7e4151a05801b65b38da2bbe914da0)
@@ -0,0 +1,1 @@
+10 arm/pl050
Index: uspace/drv/char/xtkbd/xtkbd.c
===================================================================
--- uspace/drv/char/xtkbd/xtkbd.c	(revision 293703eac83c474ec39de43bd1ee4aa8557d6286)
+++ uspace/drv/char/xtkbd/xtkbd.c	(revision 312e5ff64a7e4151a05801b65b38da2bbe914da0)
@@ -199,5 +199,5 @@
  * @param dev DDF device structure.
  *
- * Connects to parent, creates mouse function, starts polling fibril.
+ * Connects to parent, creates keyboard function, starts polling fibril.
  */
 int xt_kbd_init(xt_kbd_t *kbd, ddf_dev_t *dev)
@@ -207,9 +207,12 @@
 	kbd->client_sess = NULL;
 	kbd->parent_sess = ddf_dev_parent_sess_create(dev, EXCHANGE_SERIALIZE);
-	if (!kbd->parent_sess)
-		return ENOMEM;
+	if (!kbd->parent_sess) {
+		ddf_msg(LVL_ERROR, "Failed creating parent session.");
+		return EIO;
+	}
 
 	kbd->kbd_fun = ddf_fun_create(dev, fun_exposed, "kbd");
 	if (!kbd->kbd_fun) {
+		ddf_msg(LVL_ERROR, "Failed creating function 'kbd'.");
 		return ENOMEM;
 	}
@@ -218,10 +221,13 @@
 	int ret = ddf_fun_bind(kbd->kbd_fun);
 	if (ret != EOK) {
+		ddf_msg(LVL_ERROR, "Failed binding function 'kbd'.");
 		ddf_fun_destroy(kbd->kbd_fun);
-		return ENOMEM;
+		return EEXIST;
 	}
 
 	ret = ddf_fun_add_to_category(kbd->kbd_fun, "keyboard");
 	if (ret != EOK) {
+		ddf_msg(LVL_ERROR, "Failed adding function 'kbd' to category "
+		    "'keyboard'.");
 		ddf_fun_unbind(kbd->kbd_fun);
 		ddf_fun_destroy(kbd->kbd_fun);
@@ -231,8 +237,10 @@
 	kbd->polling_fibril = fibril_create(polling, kbd);
 	if (!kbd->polling_fibril) {
+		ddf_msg(LVL_ERROR, "Failed creating polling fibril.");
 		ddf_fun_unbind(kbd->kbd_fun);
 		ddf_fun_destroy(kbd->kbd_fun);
 		return ENOMEM;
 	}
+
 	fibril_add_ready(kbd->polling_fibril);
 	return EOK;
@@ -241,5 +249,5 @@
 /** Get data and parse scancodes.
  * @param arg Pointer to xt_kbd_t structure.
- * @return Never.
+ * @return EIO on error.
  */
 int polling(void *arg)
@@ -259,4 +267,6 @@
 		uint8_t code = 0;
 		ssize_t size = chardev_read(parent_exch, &code, 1);
+		if (size != 1)
+			return EIO;
 
 		/** Ignore AT command reply */
@@ -269,12 +279,9 @@
 			map_size = sizeof(scanmap_e0) / sizeof(int);
 			size = chardev_read(parent_exch, &code, 1);
+			if (size != 1)
+				return EIO;
+
 			// TODO handle print screen
 		}
-
-		/* Invalid read. */
-		if (size != 1) {
-			continue;
-		}
-
 
 		/* Bit 7 indicates press/release */
Index: uspace/drv/platform/icp/Makefile
===================================================================
--- uspace/drv/platform/icp/Makefile	(revision 312e5ff64a7e4151a05801b65b38da2bbe914da0)
+++ uspace/drv/platform/icp/Makefile	(revision 312e5ff64a7e4151a05801b65b38da2bbe914da0)
@@ -0,0 +1,37 @@
+#
+# Copyright (c) 2014 Jiri Svoboda
+# 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 = icp
+
+SOURCES = \
+	icp.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/platform/icp/icp.c
===================================================================
--- uspace/drv/platform/icp/icp.c	(revision 312e5ff64a7e4151a05801b65b38da2bbe914da0)
+++ uspace/drv/platform/icp/icp.c	(revision 312e5ff64a7e4151a05801b65b38da2bbe914da0)
@@ -0,0 +1,224 @@
+/*
+ * Copyright (c) 2014 Jiri Svoboda
+ * 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 icp IntegratorCP platform driver.
+ * @brief HelenOS IntegratorCP platform driver.
+ * @{
+ */
+
+/** @file
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <stdlib.h>
+
+#include <ddf/driver.h>
+#include <ddf/log.h>
+#include <ops/hw_res.h>
+#include <ops/pio_window.h>
+
+#define NAME "icp"
+
+enum {
+	icp_kbd_base = 0x18000000,
+	icp_kbd_irq = 3
+};
+
+typedef struct icp_fun {
+	hw_resource_list_t hw_resources;
+} icp_fun_t;
+
+static int icp_dev_add(ddf_dev_t *dev);
+
+static driver_ops_t icp_ops = {
+	.dev_add = &icp_dev_add
+};
+
+static driver_t icp_driver = {
+	.name = NAME,
+	.driver_ops = &icp_ops
+};
+
+static hw_resource_t icp_pl050_res[] = {
+	{
+		.type = MEM_RANGE,
+		.res.mem_range = {
+			.address = icp_kbd_base,
+			.size = 9,
+			.relative = false,
+			.endianness = LITTLE_ENDIAN
+		}
+	},
+	{
+		.type = INTERRUPT,
+		.res.interrupt = {
+			.irq = icp_kbd_irq
+		}
+	}
+};
+
+static pio_window_t icp_pio_window = {
+	.mem = {
+		.base = 0,
+		.size = -1
+	}
+};
+
+static icp_fun_t icp_pl050_fun_proto = {
+	.hw_resources = {
+		sizeof(icp_pl050_res) / sizeof(icp_pl050_res[0]),
+		icp_pl050_res
+	},
+};
+
+/** Obtain function soft-state from DDF function node */
+static icp_fun_t *icp_fun(ddf_fun_t *fnode)
+{
+	return ddf_fun_data_get(fnode);
+}
+
+static hw_resource_list_t *icp_get_resources(ddf_fun_t *fnode)
+{
+	icp_fun_t *fun = icp_fun(fnode);
+
+	assert(fun != NULL);
+	return &fun->hw_resources;
+}
+
+static bool icp_enable_interrupt(ddf_fun_t *fun)
+{
+	/* TODO */
+	return false;
+}
+
+static pio_window_t *icp_get_pio_window(ddf_fun_t *fnode)
+{
+	return &icp_pio_window;
+}
+
+static hw_res_ops_t icp_hw_res_ops = {
+	.get_resource_list = &icp_get_resources,
+	.enable_interrupt = &icp_enable_interrupt,
+};
+
+static pio_window_ops_t icp_pio_window_ops = {
+	.get_pio_window = &icp_get_pio_window
+};
+
+static ddf_dev_ops_t icp_fun_ops = {
+	.interfaces = {
+		[HW_RES_DEV_IFACE] = &icp_hw_res_ops,
+		[PIO_WINDOW_DEV_IFACE] = &icp_pio_window_ops
+	}
+};
+
+static int icp_add_fun(ddf_dev_t *dev, const char *name, const char *str_match_id,
+    icp_fun_t *fun_proto)
+{
+	ddf_msg(LVL_NOTE, "Adding function '%s'.", name);
+
+	ddf_fun_t *fnode = NULL;
+	int rc;
+
+	/* Create new device. */
+	fnode = ddf_fun_create(dev, fun_inner, name);
+	if (fnode == NULL) {
+		ddf_msg(LVL_ERROR, "Error creating function '%s'", name);
+		rc = ENOMEM;
+		goto error;
+	}
+
+	icp_fun_t *fun = ddf_fun_data_alloc(fnode, sizeof(icp_fun_t));
+	*fun = *fun_proto;
+
+	/* Add match ID */
+	rc = ddf_fun_add_match_id(fnode, str_match_id, 100);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Error adding match ID");
+		goto error;
+	}
+
+	/* Set provided operations to the device. */
+	ddf_fun_set_ops(fnode, &icp_fun_ops);
+
+	/* Register function. */
+	if (ddf_fun_bind(fnode) != EOK) {
+		ddf_msg(LVL_ERROR, "Failed binding function %s.", name);
+		goto error;
+	}
+
+	return EOK;
+
+error:
+	if (fnode != NULL)
+		ddf_fun_destroy(fnode);
+
+	return rc;
+}
+
+static int icp_add_functions(ddf_dev_t *dev)
+{
+	return icp_add_fun(dev, "pl050", "arm/pl050", &icp_pl050_fun_proto);
+}
+
+/** Add device. */
+static int icp_dev_add(ddf_dev_t *dev)
+{
+	ddf_msg(LVL_NOTE, "icp_dev_add, device handle = %d",
+	    (int)ddf_dev_get_handle(dev));
+
+	/* Register functions. */
+	if (icp_add_functions(dev)) {
+		ddf_msg(LVL_ERROR, "Failed to add functions for ICP platform.");
+	}
+
+	return EOK;
+}
+
+int main(int argc, char *argv[])
+{
+	int rc;
+
+	printf(NAME ": HelenOS IntegratorCP platform driver\n");
+
+	rc = ddf_log_init(NAME);
+	if (rc != EOK) {
+		printf(NAME ": Failed initializing logging service");
+		return 1;
+	}
+
+	return ddf_driver_main(&icp_driver);
+}
+
+/**
+ * @}
+ */
Index: uspace/drv/platform/icp/icp.ma
===================================================================
--- uspace/drv/platform/icp/icp.ma	(revision 312e5ff64a7e4151a05801b65b38da2bbe914da0)
+++ uspace/drv/platform/icp/icp.ma	(revision 312e5ff64a7e4151a05801b65b38da2bbe914da0)
@@ -0,0 +1,1 @@
+10 platform/integratorcp
Index: uspace/srv/hid/input/Makefile
===================================================================
--- uspace/srv/hid/input/Makefile	(revision 293703eac83c474ec39de43bd1ee4aa8557d6286)
+++ uspace/srv/hid/input/Makefile	(revision 312e5ff64a7e4151a05801b65b38da2bbe914da0)
@@ -42,5 +42,4 @@
 	port/niagara.c \
 	port/ns16550.c \
-	port/pl050.c \
 	port/ski.c \
 	proto/adb.c \
@@ -48,5 +47,4 @@
 	ctl/apple.c \
 	ctl/kbdev.c \
-	ctl/pc.c \
 	ctl/stty.c \
 	ctl/sun.c \
Index: pace/srv/hid/input/ctl/pc.c
===================================================================
--- uspace/srv/hid/input/ctl/pc.c	(revision 293703eac83c474ec39de43bd1ee4aa8557d6286)
+++ 	(revision )
@@ -1,285 +1,0 @@
-/*
- * Copyright (c) 2011 Jiri Svoboda
- * 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 kbd_ctl
- * @ingroup input
- * @{
- */
-/**
- * @file
- * @brief PC keyboard controller driver.
- */
-
-#include <io/console.h>
-#include <io/keycode.h>
-#include "../gsp.h"
-#include "../kbd.h"
-#include "../kbd_port.h"
-#include "../kbd_ctl.h"
-
-static void pc_ctl_parse(sysarg_t);
-static int pc_ctl_init(kbd_dev_t *);
-static void pc_ctl_set_ind(kbd_dev_t *, unsigned int);
-
-kbd_ctl_ops_t pc_ctl = {
-	.parse = pc_ctl_parse,
-	.init = pc_ctl_init,
-	.set_ind = pc_ctl_set_ind
-};
-
-enum dec_state {
-	ds_s,
-	ds_e
-};
-
-enum special_code {
-	SC_ACK = 0xfa,
-	SC_NAK = 0xfe
-};
-
-enum lock_ind_bits {
-	LI_SCROLL	= 0x01,
-	LI_NUM		= 0x02,
-	LI_CAPS		= 0x04
-};
-
-enum kbd_command {
-	KBD_CMD_SET_LEDS = 0xed
-};
-
-static enum dec_state ds;
-static kbd_dev_t *kbd_dev;
-
-static int scanmap_simple[] = {
-
-	[0x29] = KC_BACKTICK,
-
-	[0x02] = KC_1,
-	[0x03] = KC_2,
-	[0x04] = KC_3,
-	[0x05] = KC_4,
-	[0x06] = KC_5,
-	[0x07] = KC_6,
-	[0x08] = KC_7,
-	[0x09] = KC_8,
-	[0x0a] = KC_9,
-	[0x0b] = KC_0,
-
-	[0x0c] = KC_MINUS,
-	[0x0d] = KC_EQUALS,
-	[0x0e] = KC_BACKSPACE,
-
-	[0x0f] = KC_TAB,
-
-	[0x10] = KC_Q,
-	[0x11] = KC_W,
-	[0x12] = KC_E,
-	[0x13] = KC_R,
-	[0x14] = KC_T,
-	[0x15] = KC_Y,
-	[0x16] = KC_U,
-	[0x17] = KC_I,
-	[0x18] = KC_O,
-	[0x19] = KC_P,
-
-	[0x1a] = KC_LBRACKET,
-	[0x1b] = KC_RBRACKET,
-
-	[0x3a] = KC_CAPS_LOCK,
-
-	[0x1e] = KC_A,
-	[0x1f] = KC_S,
-	[0x20] = KC_D,
-	[0x21] = KC_F,
-	[0x22] = KC_G,
-	[0x23] = KC_H,
-	[0x24] = KC_J,
-	[0x25] = KC_K,
-	[0x26] = KC_L,
-
-	[0x27] = KC_SEMICOLON,
-	[0x28] = KC_QUOTE,
-	[0x2b] = KC_BACKSLASH,
-
-	[0x2a] = KC_LSHIFT,
-
-	[0x2c] = KC_Z,
-	[0x2d] = KC_X,
-	[0x2e] = KC_C,
-	[0x2f] = KC_V,
-	[0x30] = KC_B,
-	[0x31] = KC_N,
-	[0x32] = KC_M,
-
-	[0x33] = KC_COMMA,
-	[0x34] = KC_PERIOD,
-	[0x35] = KC_SLASH,
-
-	[0x36] = KC_RSHIFT,
-
-	[0x1d] = KC_LCTRL,
-	[0x38] = KC_LALT,
-	[0x39] = KC_SPACE,
-
-	[0x01] = KC_ESCAPE,
-
-	[0x3b] = KC_F1,
-	[0x3c] = KC_F2,
-	[0x3d] = KC_F3,
-	[0x3e] = KC_F4,
-	[0x3f] = KC_F5,
-	[0x40] = KC_F6,
-	[0x41] = KC_F7,
-
-	[0x42] = KC_F8,
-	[0x43] = KC_F9,
-	[0x44] = KC_F10,
-
-	[0x57] = KC_F11,
-	[0x58] = KC_F12,
-
-	[0x46] = KC_SCROLL_LOCK,
-
-	[0x1c] = KC_ENTER,
-
-	[0x45] = KC_NUM_LOCK,
-	[0x37] = KC_NTIMES,
-	[0x4a] = KC_NMINUS,
-	[0x4e] = KC_NPLUS,
-	[0x47] = KC_N7,
-	[0x48] = KC_N8,
-	[0x49] = KC_N9,
-	[0x4b] = KC_N4,
-	[0x4c] = KC_N5,
-	[0x4d] = KC_N6,
-	[0x4f] = KC_N1,
-	[0x50] = KC_N2,
-	[0x51] = KC_N3,
-	[0x52] = KC_N0,
-	[0x53] = KC_NPERIOD
-};
-
-static int scanmap_e0[] = {
-	[0x38] = KC_RALT,
-	[0x1d] = KC_RCTRL,
-
-	[0x37] = KC_PRTSCR,
-
-	[0x52] = KC_INSERT,
-	[0x47] = KC_HOME,
-	[0x49] = KC_PAGE_UP,
-
-	[0x53] = KC_DELETE,
-	[0x4f] = KC_END,
-	[0x51] = KC_PAGE_DOWN,
-
-	[0x48] = KC_UP,
-	[0x4b] = KC_LEFT,
-	[0x50] = KC_DOWN,
-	[0x4d] = KC_RIGHT,
-
-	[0x35] = KC_NSLASH,
-	[0x1c] = KC_NENTER
-};
-
-static int pc_ctl_init(kbd_dev_t *kdev)
-{
-	kbd_dev = kdev;
-	ds = ds_s;
-	return 0;
-}
-
-static void pc_ctl_parse(sysarg_t scancode)
-{
-	kbd_event_type_t type;
-	unsigned int key;
-	int *map;
-	size_t map_length;
-
-	/*
-	 * ACK/NAK are returned as response to us sending a command.
-	 * We are not interested in them.
-	 */
-	if (scancode == SC_ACK || scancode == SC_NAK)
-		return;
-
-	if (scancode == 0xe0) {
-		ds = ds_e;
-		return;
-	}
-
-	switch (ds) {
-	case ds_s:
-		map = scanmap_simple;
-		map_length = sizeof(scanmap_simple) / sizeof(int);
-		break;
-	case ds_e:
-		map = scanmap_e0;
-		map_length = sizeof(scanmap_e0) / sizeof(int);
-		break;
-	default:
-		map = NULL;
-		map_length = 0;
-	}
-
-	ds = ds_s;
-
-	if (scancode & 0x80) {
-		scancode &= ~0x80;
-		type = KEY_RELEASE;
-	} else {
-		type = KEY_PRESS;
-	}
-
-	if ((size_t) scancode >= map_length)
-		return;
-
-	key = map[scancode];
-	if (key != 0)
-		kbd_push_event(kbd_dev, type, key);
-}
-
-static void pc_ctl_set_ind(kbd_dev_t *kdev, unsigned mods)
-{
-	uint8_t b;
-
-	b = 0;
-	if ((mods & KM_CAPS_LOCK) != 0)
-		b = b | LI_CAPS;
-	if ((mods & KM_NUM_LOCK) != 0)
-		b = b | LI_NUM;
-	if ((mods & KM_SCROLL_LOCK) != 0)
-		b = b | LI_SCROLL;
-
-	(*kbd_dev->port_ops->write)(KBD_CMD_SET_LEDS);
-	(*kbd_dev->port_ops->write)(b);
-}
-
-/**
- * @}
- */ 
Index: uspace/srv/hid/input/input.c
===================================================================
--- uspace/srv/hid/input/input.c	(revision 293703eac83c474ec39de43bd1ee4aa8557d6286)
+++ uspace/srv/hid/input/input.c	(revision 312e5ff64a7e4151a05801b65b38da2bbe914da0)
@@ -539,7 +539,4 @@
 	kbd_add_dev(&chardev_port, &stty_ctl);
 #endif
-#if defined(UARCH_arm32) && defined(MACHINE_integratorcp)
-	kbd_add_dev(&pl050_port, &pc_ctl);
-#endif
 #if defined(MACHINE_ski)
 	kbd_add_dev(&ski_port, &stty_ctl);
Index: uspace/srv/hid/input/kbd_ctl.h
===================================================================
--- uspace/srv/hid/input/kbd_ctl.h	(revision 293703eac83c474ec39de43bd1ee4aa8557d6286)
+++ uspace/srv/hid/input/kbd_ctl.h	(revision 312e5ff64a7e4151a05801b65b38da2bbe914da0)
@@ -50,5 +50,4 @@
 extern kbd_ctl_ops_t apple_ctl;
 extern kbd_ctl_ops_t kbdev_ctl;
-extern kbd_ctl_ops_t pc_ctl;
 extern kbd_ctl_ops_t stty_ctl;
 extern kbd_ctl_ops_t sun_ctl;
Index: uspace/srv/hid/input/kbd_port.h
===================================================================
--- uspace/srv/hid/input/kbd_port.h	(revision 293703eac83c474ec39de43bd1ee4aa8557d6286)
+++ uspace/srv/hid/input/kbd_port.h	(revision 312e5ff64a7e4151a05801b65b38da2bbe914da0)
@@ -52,5 +52,4 @@
 extern kbd_port_ops_t niagara_port;
 extern kbd_port_ops_t ns16550_port;
-extern kbd_port_ops_t pl050_port;
 extern kbd_port_ops_t ski_port;
 
Index: pace/srv/hid/input/port/pl050.c
===================================================================
--- uspace/srv/hid/input/port/pl050.c	(revision 293703eac83c474ec39de43bd1ee4aa8557d6286)
+++ 	(revision )
@@ -1,137 +1,0 @@
-/*
- * Copyright (c) 2009 Vineeth Pillai
- * Copyright (c) 2011 Jiri Svoboda
- * 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 kbd_port
- * @ingroup kbd
- * @{
- */ 
-/** @file
- * @brief pl050 port driver.
- */
-
-#include <ddi.h>
-#include <async.h>
-#include <unistd.h>
-#include <sysinfo.h>
-#include <stdio.h>
-#include <errno.h>
-#include "../kbd_port.h"
-#include "../kbd.h"
-
-static int pl050_port_init(kbd_dev_t *);
-static void pl050_port_write(uint8_t data);
-
-kbd_port_ops_t pl050_port = {
-	.init = pl050_port_init,
-	.write = pl050_port_write
-};
-
-static kbd_dev_t *kbd_dev;
-
-#define PL050_STAT	4
-#define PL050_DATA	8
-
-#define PL050_STAT_RXFULL  (1 << 4)
-
-static irq_pio_range_t pl050_ranges[] = {
-	{
-		.base = 0,
-		.size = 9, 
-	}
-};
-
-static irq_cmd_t pl050_cmds[] = {
-	{
-		.cmd = CMD_PIO_READ_8,
-		.addr = NULL,
-		.dstarg = 1
-	},
-	{
-		.cmd = CMD_AND,
-		.value = PL050_STAT_RXFULL,
-		.srcarg = 1,
-		.dstarg = 3
-	},
-	{
-		.cmd = CMD_PREDICATE,
-		.value = 2,
-		.srcarg = 3
-	},
-	{
-		.cmd = CMD_PIO_READ_8,
-		.addr = NULL,  /* Will be patched in run-time */
-		.dstarg = 2
-	},
-	{
-		.cmd = CMD_ACCEPT
-	}
-};
-
-static irq_code_t pl050_kbd = {
-	sizeof(pl050_ranges) / sizeof(irq_pio_range_t),
-	pl050_ranges,
-	sizeof(pl050_cmds) / sizeof(irq_cmd_t),
-	pl050_cmds
-};
-
-static void pl050_irq_handler(ipc_callid_t iid, ipc_call_t *call, void *arg)
-{
-	kbd_push_data(kbd_dev, IPC_GET_ARG2(*call));
-}
-
-static int pl050_port_init(kbd_dev_t *kdev)
-{
-	kbd_dev = kdev;
-	
-	sysarg_t addr;
-	if (sysinfo_get_value("kbd.address.physical", &addr) != EOK)
-		return -1;
-	
-	pl050_kbd.ranges[0].base = addr;
-	pl050_kbd.cmds[0].addr = (void *) addr + PL050_STAT;
-	pl050_kbd.cmds[3].addr = (void *) addr + PL050_DATA;
-	
-	sysarg_t inr;
-	if (sysinfo_get_value("kbd.inr", &inr) != EOK)
-		return -1;
-	
-	async_irq_subscribe(inr, device_assign_devno(), pl050_irq_handler, NULL,
-	    &pl050_kbd);
-	
-	return 0;
-}
-
-static void pl050_port_write(uint8_t data)
-{
-	(void) data;
-}
-
-/**
- * @}
- */
