0001 .. include:: ../disclaimer-zh_CN.rst
0002
0003 :Original: Documentation/iio/iio_configfs.rst
0004
0005 :翻译:
0006
0007 司延腾 Yanteng Si <siyanteng@loongson.cn>
0008
0009 .. _cn_iio_configfs:
0010
0011 =====================
0012 工业 IIO configfs支持
0013 =====================
0014
0015 1. 概述
0016 =======
0017
0018 Configfs是一种内核对象的基于文件系统的管理系统,IIO使用一些可以通过
0019 configfs轻松配置的对象(例如:设备,触发器)。
0020
0021 关于configfs是如何运行的,请查阅Documentation/filesystems/configfs.rst
0022 了解更多信息。
0023
0024 2. 用法
0025 =======
0026 为了使configfs支持IIO,我们需要在编译时选中config的CONFIG_IIO_CONFIGFS
0027 选项。
0028
0029 然后,挂载configfs文件系统(通常在 /config directory目录下)::
0030
0031 $ mkdir/config
0032 $ mount -t configfs none/config
0033
0034 此时,将创建所有默认IIO组,并可以在/ config / iio下对其进行访问。 下一章
0035 将介绍可用的IIO配置对象。
0036
0037 3. 软件触发器
0038 =============
0039
0040 IIO默认configfs组之一是“触发器”组。挂载configfs后可以自动访问它,并且可
0041 以在/config/iio/triggers下找到。
0042
0043 IIO软件触发器为创建多种触发器类型提供了支持。通常在include/linux/iio
0044 /sw_trigger.h:中的接口下将新的触发器类型实现为单独的内核模块:
0045 ::
0046
0047 /*
0048 * drivers/iio/trigger/iio-trig-sample.c
0049 * 一种新触发器类型的内核模块实例
0050 */
0051 #include <linux/iio/sw_trigger.h>
0052
0053
0054 static struct iio_sw_trigger *iio_trig_sample_probe(const char *name)
0055 {
0056 /*
0057 * 这将分配并注册一个IIO触发器以及其他触发器类型特性的初始化。
0058 */
0059 }
0060
0061 static int iio_trig_sample_remove(struct iio_sw_trigger *swt)
0062 {
0063 /*
0064 * 这会废弃iio_trig_sample_probe中的操作
0065 */
0066 }
0067
0068 static const struct iio_sw_trigger_ops iio_trig_sample_ops = {
0069 .probe = iio_trig_sample_probe,
0070 .remove = iio_trig_sample_remove,
0071 };
0072
0073 static struct iio_sw_trigger_type iio_trig_sample = {
0074 .name = "trig-sample",
0075 .owner = THIS_MODULE,
0076 .ops = &iio_trig_sample_ops,
0077 };
0078
0079 module_iio_sw_trigger_driver(iio_trig_sample);
0080
0081 每种触发器类型在/config/iio/triggers下都有其自己的目录。加载iio-trig-sample
0082 模块将创建“trig-sample”触发器类型目录/config/iio/triggers/trig-sample.
0083
0084 我们支持以下中断源(触发器类型)
0085
0086 * hrtimer,使用高分辨率定时器作为中断源
0087
0088 3.1 Hrtimer触发器创建与销毁
0089 ---------------------------
0090
0091 加载iio-trig-hrtimer模块将注册hrtimer触发器类型,从而允许用户在
0092 /config/iio/triggers/hrtimer下创建hrtimer触发器。
0093
0094 例如::
0095
0096 $ mkdir /config/iio/triggers/hrtimer/instance1
0097 $ rmdir /config/iio/triggers/hrtimer/instance1
0098
0099 每个触发器可以具有一个或多个独特的触发器类型的属性。
0100
0101 3.2 "hrtimer" 触发器类型属性
0102 ----------------------------
0103
0104 "hrtimer”触发器类型没有来自/config dir的任何可配置属性。
0105 它确实引入了触发目录的sampling_frequency属性。
0106 该属性以Hz为单位设置轮询频率,精度为mHz。