diff options
author | Guillaume Aubertin <g-aubertin@ti.com> | 2012-07-13 16:26:25 +0200 |
---|---|---|
committer | Andy Green <andy.green@linaro.org> | 2012-09-07 13:05:27 +0800 |
commit | e0da729f6d6aaf6efb85c36f3151d034b3c3d2a9 (patch) | |
tree | 17ee8d33de69b2ef263d04fe724c58eccd08b779 /drivers | |
parent | bef68a479cd782545e5bf48b3740f81776f3db1c (diff) |
rpmsg: adding remote daemon driver
rdaemon uses a simple implementation of rpmsg to communicate
with a remotecore that instantiates the RTSC rdaemon library.
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/Kconfig | 2 | ||||
-rw-r--r-- | drivers/staging/Makefile | 1 | ||||
-rw-r--r-- | drivers/staging/rdaemon/Kconfig | 9 | ||||
-rw-r--r-- | drivers/staging/rdaemon/Makefile | 2 | ||||
-rw-r--r-- | drivers/staging/rdaemon/rdaemon.c | 139 | ||||
-rw-r--r-- | drivers/staging/rdaemon/rdaemon.h | 33 |
6 files changed, 186 insertions, 0 deletions
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 7a873c08eefa..4ad02c9905ad 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -136,4 +136,6 @@ source "drivers/staging/thermal_framework/Kconfig" source "drivers/staging/omapdce/Kconfig" +source "drivers/staging/rdaemon/Kconfig" + endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index a78452d620c1..a3bc940f1366 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -59,3 +59,4 @@ obj-$(CONFIG_RAMSTER) += ramster/ obj-$(CONFIG_USB_WPAN_HCD) += ozwpan/ obj-$(CONFIG_OMAP_THERMAL) += thermal_framework/ obj-$(CONFIG_DRM_OMAP_DCE) += omapdce/ +obj-$(CONFIG_OMAP_RPMSG_RDAEMON) += rdaemon/
\ No newline at end of file diff --git a/drivers/staging/rdaemon/Kconfig b/drivers/staging/rdaemon/Kconfig new file mode 100644 index 000000000000..19f26dab3f56 --- /dev/null +++ b/drivers/staging/rdaemon/Kconfig @@ -0,0 +1,9 @@ +config OMAP_RPMSG_RDAEMON + tristate "OMAP Rdaemon for rpmsg" + select OMAP_RPMSG + select OMAP_REMOTEPROC + default n + help + Plugin for RPMSG driver on OMAP to test/debug remote processors + + diff --git a/drivers/staging/rdaemon/Makefile b/drivers/staging/rdaemon/Makefile new file mode 100644 index 000000000000..1f23220233ed --- /dev/null +++ b/drivers/staging/rdaemon/Makefile @@ -0,0 +1,2 @@ + omap_rdaemon-y := rdaemon.o +obj-$(CONFIG_OMAP_RPMSG_RDAEMON) += omap_rdaemon.o diff --git a/drivers/staging/rdaemon/rdaemon.c b/drivers/staging/rdaemon/rdaemon.c new file mode 100644 index 000000000000..460c51492261 --- /dev/null +++ b/drivers/staging/rdaemon/rdaemon.c @@ -0,0 +1,139 @@ +/* + * drivers/staging/rdaemon/rdaemon.c + * + * Copyright (C) 2012 Texas Instruments + * Author: Guillaume Aubertin <g-aubertin@ti.com> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#define pr_fmt(fmt) "%s: " fmt, __func__ + +#include <linux/module.h> +#include <linux/types.h> +#include <linux/rpmsg.h> +#include <linux/slab.h> +#include <linux/kernel.h> +#include <linux/debugfs.h> +#include <linux/device.h> +#include <linux/uaccess.h> +#include <linux/string.h> +#include "rdaemon.h" + +/* debugfs parent dir */ +static struct dentry *rdaemon_dbg; +static u32 ping_count; + +static ssize_t rdaemon_ping_write(struct file *filp, + const char __user *user_buf, size_t count, loff_t *ppos) +{ + int ret = 0; + struct rdaemon_msg_frame frame; + struct rpmsg_channel *rpdev = filp->private_data; + + /* create message */ + frame.msg_type = RDAEMON_PING; + frame.data = ping_count; + + /* send ping msg */ + ret = rpmsg_send(rpdev, (void *)(&frame), + sizeof(struct rdaemon_msg_frame)); + if (ret) { + printk(KERN_ERR"rpmsg_send failed: %d", ret); + return ret; + } + + ping_count++; + + return count; +} + +static const struct file_operations rdaemon_ping_ops = { + .write = rdaemon_ping_write, + .open = simple_open, + .llseek = generic_file_llseek, +}; + +static void rdaemon_create_debug_tree(struct rpmsg_channel *rpdev) +{ + struct device *dev = &rpdev->dev; + struct dentry *d; + + d = debugfs_create_dir(dev_name(dev), rdaemon_dbg); + + ping_count = 0; + + debugfs_create_file("ping", 0400, d, + rpdev, &rdaemon_ping_ops); +} + +static int rpmsg_probe(struct rpmsg_channel *_rpdev) +{ + /* create debugfs */ + rdaemon_create_debug_tree(_rpdev); + + return 0; +} + +static void rpmsg_cb(struct rpmsg_channel *rpdev, void *data, + int len, void *priv, u32 src) +{ + printk(KERN_ERR"len=%d, src=%d", len, src); +} + +static void __devexit rpmsg_remove(struct rpmsg_channel *_rpdev) +{ + rdaemon_dbg = NULL; +} + + +static struct rpmsg_device_id rpmsg_id_table[] = { + { .name = "rpmsg-rdaemon" }, + { }, +}; + +static struct rpmsg_driver rpmsg_driver = { + .drv.name = KBUILD_MODNAME, + .drv.owner = THIS_MODULE, + .id_table = rpmsg_id_table, + .probe = rpmsg_probe, + .callback = rpmsg_cb, + .remove = __devexit_p(rpmsg_remove), +}; + +static int __init rdaemon_init(void) +{ + if (debugfs_initialized()) { + rdaemon_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL); + if (!rdaemon_dbg) { + pr_err("can't create debugfs dir\n"); + return -1; + } + } + return register_rpmsg_driver(&rpmsg_driver); +} + +static void __exit rdaemon_fini(void) +{ + if (rdaemon_dbg) + debugfs_remove(rdaemon_dbg); + + unregister_rpmsg_driver(&rpmsg_driver); +} + +module_init(rdaemon_init); +module_exit(rdaemon_fini); + +MODULE_AUTHOR("Guillaume Aubertin <g-aubertin@ti.com>"); +MODULE_DESCRIPTION("OMAP remote daemon for rpmsg"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/staging/rdaemon/rdaemon.h b/drivers/staging/rdaemon/rdaemon.h new file mode 100644 index 000000000000..a28eb39881da --- /dev/null +++ b/drivers/staging/rdaemon/rdaemon.h @@ -0,0 +1,33 @@ +/* + * drivers/staging/rdaemon/rdaemon.h + * + * Copyright (C) 2012 Texas Instruments + * Author: Guillaume Aubertin <g-aubertin@ti.com> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ +#ifndef RDAEMON_H +#define RDAEMON_H + +/* message type */ +enum rdaemon_msg_type { + RDAEMON_PING, +}; + +/* message frame */ +struct rdaemon_msg_frame { + int msg_type; + u32 data; +}; + +#endif /* RDAEMON_H */ |