summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-05-16 09:45:56 -0700
committerSascha Hauer <s.hauer@pengutronix.de>2016-05-18 07:47:46 +0200
commit914480a542aabd56ba5220afe0e234fd8213411e (patch)
treeff46c8b566612f54265f8fcedbe2e2d15179ede2 /include
parente9add3ae570a381568fb4851a3a43f0b5ca3b089 (diff)
downloadbarebox-914480a542aabd56ba5220afe0e234fd8213411e.tar.gz
barebox-914480a542aabd56ba5220afe0e234fd8213411e.tar.xz
drivers: Introduce AIODEV subsystem
AIODEV/Aiodevice is a analog I/O framework that can be thought of as a simplified hybrid between 'hwmon' and 'IIO' subsystems of Linux kernel This commit is very heavily based on 'iodevice' framework proposal written by Sascha Hauer. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r--include/aiodev.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/include/aiodev.h b/include/aiodev.h
new file mode 100644
index 0000000000..0d4f7a2940
--- /dev/null
+++ b/include/aiodev.h
@@ -0,0 +1,59 @@
+/*
+ * core.c - Code implementing core functionality of AIODEV susbsystem
+ *
+ * Copyright (c) 2015 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
+ * Copyright (c) 2015 Zodiac Inflight Innovation
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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.
+ */
+
+#ifndef __AIODEVICE_H
+#define __AIODEVICE_H
+
+struct aiodevice;
+struct aiochannel {
+ int index;
+ char *unit;
+ struct aiodevice *aiodev;
+
+ int value;
+ char *name;
+};
+
+struct aiodevice {
+ const char *name;
+ int (*read)(struct aiochannel *, int *val);
+ struct device_d dev;
+ struct device_d *hwdev;
+ struct aiochannel **channels;
+ int num_channels;
+ struct list_head list;
+};
+
+int aiodevice_register(struct aiodevice *aiodev);
+
+struct aiochannel *aiochannel_get(struct device_d *dev, int index);
+struct aiochannel *aiochannel_get_by_name(const char *name);
+
+int aiochannel_get_value(struct aiochannel *aiochan, int *value);
+int aiochannel_get_index(struct aiochannel *aiochan);
+
+static inline const char *aiochannel_get_unit(struct aiochannel *aiochan)
+{
+ return aiochan->unit;
+}
+
+extern struct list_head aiodevices;
+#define for_each_aiodevice(aiodevice) list_for_each_entry(aiodevice, &aiodevices, list)
+
+#endif