Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3.8: capebus improvements by mranostay
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
- Loading branch information
Showing
7 changed files
with
536 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
231 changes: 231 additions & 0 deletions
231
patches/not-capebus/0125-cape-Added-support-for-IIO-helper-cape.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,231 @@ | ||
From 2c1ec37d4484ef77a325e25ea94a8a43d8d57596 Mon Sep 17 00:00:00 2001 | ||
From: Matt Ranostay <mranostay@gmail.com> | ||
Date: Tue, 19 Mar 2013 17:06:03 +0000 | ||
Subject: [PATCH 125/130] cape: Added support for IIO helper cape | ||
|
||
Since we currently can't export the IIO channels from the | ||
ADCs this patch exposes an sysfs entry to read a respective | ||
channel. | ||
|
||
Signed-off-by: Matt Ranostay <mranostay@gmail.com> | ||
--- | ||
drivers/misc/cape/beaglebone/Kconfig | 7 + | ||
drivers/misc/cape/beaglebone/Makefile | 1 + | ||
drivers/misc/cape/beaglebone/bone-iio-helper.c | 175 +++++++++++++++++++++++++ | ||
3 files changed, 183 insertions(+) | ||
create mode 100644 drivers/misc/cape/beaglebone/bone-iio-helper.c | ||
|
||
diff --git a/drivers/misc/cape/beaglebone/Kconfig b/drivers/misc/cape/beaglebone/Kconfig | ||
index 9bf5ac0..4937577 100644 | ||
--- a/drivers/misc/cape/beaglebone/Kconfig | ||
+++ b/drivers/misc/cape/beaglebone/Kconfig | ||
@@ -9,6 +9,13 @@ config BEAGLEBONE_PINMUX_HELPER | ||
help | ||
Say Y here to include support for the pinmux helper | ||
|
||
+config BEAGLEBONE_IIO_HELPER | ||
+ tristate "Beaglebone AM335x TSCADC Helper" | ||
+ depends on ARCH_OMAP2PLUS && OF && MFD_TI_AM335X_TSCADC | ||
+ default n | ||
+ help | ||
+ Say Y here to include support for the IIO helper | ||
+ | ||
config CAPE_BEAGLEBONE | ||
tristate "Beaglebone cape support" | ||
depends on ARCH_OMAP2PLUS && OF && I2C | ||
diff --git a/drivers/misc/cape/beaglebone/Makefile b/drivers/misc/cape/beaglebone/Makefile | ||
index 508b931..e32550d 100644 | ||
--- a/drivers/misc/cape/beaglebone/Makefile | ||
+++ b/drivers/misc/cape/beaglebone/Makefile | ||
@@ -3,6 +3,7 @@ | ||
# | ||
|
||
obj-$(CONFIG_BEAGLEBONE_PINMUX_HELPER) += bone-pinmux-helper.o | ||
+obj-$(CONFIG_BEAGLEBONE_IIO_HELPER) += bone-iio-helper.o | ||
|
||
obj-$(CONFIG_CAPE_BEAGLEBONE) += capemgr.o | ||
obj-$(CONFIG_CAPE_BEAGLEBONE_GEIGER) += cape-bone-geiger.o | ||
diff --git a/drivers/misc/cape/beaglebone/bone-iio-helper.c b/drivers/misc/cape/beaglebone/bone-iio-helper.c | ||
new file mode 100644 | ||
index 0000000..d2c76e1 | ||
--- /dev/null | ||
+++ b/drivers/misc/cape/beaglebone/bone-iio-helper.c | ||
@@ -0,0 +1,175 @@ | ||
+/* | ||
+ * Industrial IO helper driver | ||
+ * | ||
+ * Copyright (C) 2013 Matt Ranostay <mranostay@gmail.com> | ||
+ * | ||
+ * Based on original work by | ||
+ * Copyright (C) 2012 Pantelis Antoniou <panto@antoniou-consulting.com> | ||
+ * | ||
+ * This program is free software; you can redistribute it and/or modify | ||
+ * it under the terms of the GNU General Public License as published by | ||
+ * the Free Software Foundation; either version 2 of the License, or | ||
+ * (at your option) any later version. | ||
+ * | ||
+ * 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, write to the Free Software | ||
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
+ */ | ||
+ | ||
+#include <linux/module.h> | ||
+#include <linux/slab.h> | ||
+#include <linux/kernel.h> | ||
+#include <linux/errno.h> | ||
+#include <linux/init.h> | ||
+#include <linux/err.h> | ||
+#include <linux/of.h> | ||
+#include <linux/of_device.h> | ||
+#include <linux/math64.h> | ||
+#include <linux/input/ti_am335x_tsc.h> | ||
+#include <linux/platform_data/ti_am335x_adc.h> | ||
+#include <linux/mfd/ti_am335x_tscadc.h> | ||
+#include <linux/iio/iio.h> | ||
+#include <linux/iio/machine.h> | ||
+#include <linux/iio/consumer.h> | ||
+ | ||
+static const struct of_device_id bone_iio_helper_of_match[] = { | ||
+ { | ||
+ .compatible = "bone-iio-helper", | ||
+ }, | ||
+ { }, | ||
+}; | ||
+MODULE_DEVICE_TABLE(of, bone_iio_helper_of_match); | ||
+ | ||
+struct iio_helper_info { | ||
+ struct platform_device *pdev; | ||
+ const char *vsense_name; | ||
+ unsigned int vsense_scale; | ||
+ struct iio_channel *vsense_channel; | ||
+}; | ||
+ | ||
+static ssize_t iio_helper_show_mvolts(struct device *dev, | ||
+ struct device_attribute *attr, char *buf) | ||
+{ | ||
+ struct platform_device *pdev = to_platform_device(dev); | ||
+ struct iio_helper_info *info = platform_get_drvdata(pdev); | ||
+ int ret, val; | ||
+ u32 mvolts; | ||
+ | ||
+ ret = iio_read_channel_raw(info->vsense_channel, &val); | ||
+ if (ret < 0) | ||
+ return ret; | ||
+ | ||
+ /* volts = ((1800 / 4096) * val * scale) = (1.8 * val * scale /4096) */ | ||
+ mvolts = div_u64(1800 * info->vsense_scale * (u64)val, 4096 * 100); | ||
+ | ||
+ return sprintf(buf, "%d\n", mvolts); | ||
+} | ||
+ | ||
+static DEVICE_ATTR(mvolts, S_IRUGO, | ||
+ iio_helper_show_mvolts, NULL); | ||
+ | ||
+static int iio_helper_sysfs_register(struct platform_device *pdev) | ||
+{ | ||
+ return device_create_file(&pdev->dev, &dev_attr_mvolts); | ||
+} | ||
+ | ||
+static int bone_iio_helper_probe(struct platform_device *pdev) | ||
+{ | ||
+ struct iio_helper_info *info; | ||
+ struct device_node *pnode = pdev->dev.of_node; | ||
+ int err; | ||
+ | ||
+ /* we only support OF */ | ||
+ if (pnode == NULL) { | ||
+ dev_err(&pdev->dev, "No platform of_node!\n"); | ||
+ return -ENODEV; | ||
+ } | ||
+ | ||
+ info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); | ||
+ if (info == NULL) { | ||
+ dev_err(&pdev->dev, "Failed to allocate info\n"); | ||
+ err = -ENOMEM; | ||
+ goto err_no_mem; | ||
+ } | ||
+ platform_set_drvdata(pdev, info); | ||
+ info->pdev = pdev; | ||
+ | ||
+ if (of_property_read_string(pnode, "vsense-name", &info->vsense_name) != 0) { | ||
+ dev_err(&pdev->dev, "Could not read vsense-name property."); | ||
+ err = -EINVAL; | ||
+ goto err_no_vsense; | ||
+ } | ||
+ | ||
+ if (of_property_read_u32(pnode, "vsense-scale", &info->vsense_scale) != 0) { | ||
+ dev_err(&pdev->dev, "Could not read vsense-scale property"); | ||
+ err = -EINVAL; | ||
+ goto err_no_vsense; | ||
+ } | ||
+ | ||
+ if (info->vsense_scale == 0) { | ||
+ dev_err(&pdev->dev, "Invalid vsense-scale property"); | ||
+ err = -EINVAL; | ||
+ goto err_no_vsense; | ||
+ } | ||
+ | ||
+ info->vsense_channel = iio_channel_get(NULL, info->vsense_name); | ||
+ if (IS_ERR(info->vsense_channel)) { | ||
+ dev_err(&pdev->dev, "Could not get %s analog input\n", | ||
+ info->vsense_name); | ||
+ err = PTR_ERR(info->vsense_channel); | ||
+ goto err_no_vsense; | ||
+ } | ||
+ | ||
+ err = iio_helper_sysfs_register(pdev); | ||
+ if (err != 0) { | ||
+ dev_err(&pdev->dev, "unable to register sysfs\n"); | ||
+ goto err_no_sysfs; | ||
+ } | ||
+ | ||
+ dev_info(&pdev->dev, "ready\n"); | ||
+ | ||
+ return 0; | ||
+ | ||
+err_no_sysfs: | ||
+ /* fall-through */ | ||
+err_no_vsense: | ||
+ kfree(info); | ||
+err_no_mem: | ||
+ return err; | ||
+} | ||
+ | ||
+ | ||
+static int bone_iio_helper_remove(struct platform_device *pdev) | ||
+{ | ||
+ struct iio_helper_info *info = platform_get_drvdata(pdev); | ||
+ struct device *dev = &pdev->dev; | ||
+ | ||
+ iio_channel_release(info->vsense_channel); | ||
+ device_remove_file(dev, &dev_attr_mvolts); | ||
+ kfree(info->vsense_name); | ||
+ devm_kfree(dev, info); | ||
+ | ||
+ return 0; | ||
+} | ||
+ | ||
+struct platform_driver bone_iio_helper_driver = { | ||
+ .probe = bone_iio_helper_probe, | ||
+ .remove = bone_iio_helper_remove, | ||
+ .driver = { | ||
+ .name = "bone-iio-helper", | ||
+ .owner = THIS_MODULE, | ||
+ .of_match_table = bone_iio_helper_of_match, | ||
+ }, | ||
+}; | ||
+ | ||
+module_platform_driver(bone_iio_helper_driver); | ||
+ | ||
+MODULE_AUTHOR("Matt Ranostay"); | ||
+MODULE_DESCRIPTION("Beaglebone IIO helper driver"); | ||
+MODULE_LICENSE("GPL"); | ||
+MODULE_ALIAS("platform:bone-iio-helper"); | ||
-- | ||
1.8.1.4 | ||
|
70 changes: 70 additions & 0 deletions
70
patches/not-capebus/0126-cape-Added-example-IIO-tester-dynamics-overlay.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
From aa63c6acf6af2c15062736ed7754466245800cd7 Mon Sep 17 00:00:00 2001 | ||
From: Matt Ranostay <mranostay@gmail.com> | ||
Date: Tue, 19 Mar 2013 17:06:04 +0000 | ||
Subject: [PATCH 126/130] cape: Added example IIO tester dynamics overlay | ||
|
||
Added an example usage of the IIO exporter for an current sensor | ||
reading. | ||
|
||
Scale factor works with INA169 current sensor at 10k load. | ||
|
||
Signed-off-by: Matt Ranostay <mranostay@gmail.com> | ||
--- | ||
firmware/Makefile | 1 + | ||
firmware/capes/cape-bone-iio-00A0.dts | 32 ++++++++++++++++++++++++++++++++ | ||
2 files changed, 33 insertions(+) | ||
create mode 100644 firmware/capes/cape-bone-iio-00A0.dts | ||
|
||
diff --git a/firmware/Makefile b/firmware/Makefile | ||
index 4f51526..95067d2 100644 | ||
--- a/firmware/Makefile | ||
+++ b/firmware/Makefile | ||
@@ -146,6 +146,7 @@ fw-shipped-$(CONFIG_CAPE_BEAGLEBONE) += \ | ||
cape-bone-lcd3-00A0.dtbo \ | ||
cape-bone-lcd3-00A2.dtbo \ | ||
BB-BONE-LCD7-01-00A2.dtbo \ | ||
+ cape-bone-iio-00A0.dtbo \ | ||
cape-bone-pinmux-test-00A0.dtbo | ||
|
||
# the geiger cape | ||
diff --git a/firmware/capes/cape-bone-iio-00A0.dts b/firmware/capes/cape-bone-iio-00A0.dts | ||
new file mode 100644 | ||
index 0000000..3165702 | ||
--- /dev/null | ||
+++ b/firmware/capes/cape-bone-iio-00A0.dts | ||
@@ -0,0 +1,32 @@ | ||
+/* | ||
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.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. | ||
+ */ | ||
+/dts-v1/; | ||
+/plugin/; | ||
+ | ||
+/ { | ||
+ compatible = "ti,beaglebone", "ti,beaglebone-black"; | ||
+ | ||
+ /* identification */ | ||
+ part-number = "iio-test"; | ||
+ | ||
+ fragment@0 { | ||
+ target = <&ocp>; | ||
+ __overlay__ { | ||
+ /* avoid stupid warning */ | ||
+ #address-cells = <1>; | ||
+ #size-cells = <1>; | ||
+ | ||
+ test_helper: helper { | ||
+ compatible = "bone-iio-helper"; | ||
+ vsense-name = "AIN6"; | ||
+ vsense-scale = <100>; | ||
+ status = "okay"; | ||
+ }; | ||
+ }; | ||
+ }; | ||
+}; | ||
-- | ||
1.8.1.4 | ||
|
29 changes: 29 additions & 0 deletions
29
patches/not-capebus/0127-docs-Added-capemanager-extra_override-usage.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
From e189910899175c4f56220c92b4a666f91f44cc6f Mon Sep 17 00:00:00 2001 | ||
From: Matt Ranostay <mranostay@gmail.com> | ||
Date: Tue, 19 Mar 2013 17:05:01 +0000 | ||
Subject: [PATCH 127/130] docs: Added capemanager extra_override usage | ||
|
||
Gave an example on using the kernel-command-line override | ||
slot options for capemanager. | ||
|
||
Signed-off-by: Matt Ranostay <mranostay@gmail.com> | ||
--- | ||
Documentation/devicetree/bindings/misc/capes-beaglebone.txt | 5 ++++- | ||
1 file changed, 4 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/Documentation/devicetree/bindings/misc/capes-beaglebone.txt b/Documentation/devicetree/bindings/misc/capes-beaglebone.txt | ||
index f73cab5..1af627a 100644 | ||
--- a/Documentation/devicetree/bindings/misc/capes-beaglebone.txt | ||
+++ b/Documentation/devicetree/bindings/misc/capes-beaglebone.txt | ||
@@ -107,4 +107,7 @@ Example of the override syntax when used on a bone compatible foo board. | ||
}; | ||
|
||
}; | ||
- | ||
+ | ||
+Example of the same override syntax when used from the kernel command-line: | ||
+ | ||
+ capemgr.extra_override=FOO-hardcoded:00A0,FOO-another-hardcoded:00A0 | ||
-- | ||
1.8.1.4 | ||
|
27 changes: 27 additions & 0 deletions
27
patches/not-capebus/0128-capemgr-Added-module-param-descriptions.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
From 3f0c7923a3535ff9b5929c307243eb35cc44dd82 Mon Sep 17 00:00:00 2001 | ||
From: Matt Ranostay <mranostay@gmail.com> | ||
Date: Tue, 19 Mar 2013 17:05:02 +0000 | ||
Subject: [PATCH 128/130] capemgr: Added module param descriptions | ||
|
||
Added a simple MODULE_PARM_DESC for the extra_override option | ||
|
||
Signed-off-by: Matt Ranostay <mranostay@gmail.com> | ||
--- | ||
drivers/misc/cape/beaglebone/capemgr.c | 1 + | ||
1 file changed, 1 insertion(+) | ||
|
||
diff --git a/drivers/misc/cape/beaglebone/capemgr.c b/drivers/misc/cape/beaglebone/capemgr.c | ||
index 255c491..2ee7b11 100644 | ||
--- a/drivers/misc/cape/beaglebone/capemgr.c | ||
+++ b/drivers/misc/cape/beaglebone/capemgr.c | ||
@@ -47,6 +47,7 @@ | ||
/* extra command line overrides */ | ||
static char *extra_override = NULL; | ||
module_param(extra_override, charp, 0444); | ||
+MODULE_PARM_DESC(extra_override, "Comma delimited list of PART-NUMBER[:REV] overrides"); | ||
|
||
struct bone_capemgr_info; | ||
|
||
-- | ||
1.8.1.4 | ||
|
Oops, something went wrong.