Skip to content

Commit

Permalink
3.8: capebus improvements by mranostay
Browse files Browse the repository at this point in the history
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
  • Loading branch information
koenkooi committed Mar 19, 2013
1 parent 4bfe375 commit a5c4357
Show file tree
Hide file tree
Showing 7 changed files with 536 additions and 3 deletions.
5 changes: 2 additions & 3 deletions configs/beaglebone
@@ -1,6 +1,6 @@
#
# Automatically generated file; DO NOT EDIT.
# Linux/arm 3.8.2 Kernel Configuration
# Linux/arm 3.8.3 Kernel Configuration
#
CONFIG_ARM=y
CONFIG_SYS_SUPPORTS_APM_EMULATION=y
Expand Down Expand Up @@ -1326,6 +1326,7 @@ CONFIG_TI_ST=m
#
# CONFIG_ALTERA_STAPL is not set
CONFIG_BEAGLEBONE_PINMUX_HELPER=y
CONFIG_BEAGLEBONE_IIO_HELPER=m
CONFIG_CAPE_BEAGLEBONE=y
CONFIG_CAPE_BEAGLEBONE_GEIGER=y
CONFIG_CAPE_BEAGLEBONE_NIXIE=y
Expand Down Expand Up @@ -2783,7 +2784,6 @@ CONFIG_FB_SYS_FOPS=y
CONFIG_FB_DEFERRED_IO=y
# CONFIG_FB_SVGALIB is not set
# CONFIG_FB_MACMODES is not set
# CONFIG_FB_BACKLIGHT is not set
CONFIG_FB_MODE_HELPERS=y
CONFIG_FB_TILEBLITTING=y

Expand Down Expand Up @@ -3179,7 +3179,6 @@ CONFIG_USB_CYPRESS_CY7C63=m
CONFIG_USB_CYTHERM=m
CONFIG_USB_IDMOUSE=m
CONFIG_USB_FTDI_ELAN=m
CONFIG_USB_APPLEDISPLAY=m
# CONFIG_USB_SISUSBVGA is not set
CONFIG_USB_LD=m
CONFIG_USB_TRANCEVIBRATOR=m
Expand Down
231 changes: 231 additions & 0 deletions patches/not-capebus/0125-cape-Added-support-for-IIO-helper-cape.patch
@@ -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

@@ -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

@@ -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

@@ -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

0 comments on commit a5c4357

Please sign in to comment.