summaryrefslogtreecommitdiff
path: root/io-tool/mts-io-sysfs-inc.sh
diff options
context:
space:
mode:
Diffstat (limited to 'io-tool/mts-io-sysfs-inc.sh')
-rw-r--r--io-tool/mts-io-sysfs-inc.sh92
1 files changed, 92 insertions, 0 deletions
diff --git a/io-tool/mts-io-sysfs-inc.sh b/io-tool/mts-io-sysfs-inc.sh
new file mode 100644
index 0000000..f3fde5f
--- /dev/null
+++ b/io-tool/mts-io-sysfs-inc.sh
@@ -0,0 +1,92 @@
+#!/usr/bin/env bash
+#
+# vim: set sw=2 ts=2 expandtab:
+#
+# Copyright (C) 2010 by Multi-Tech Systems
+#
+# Author: James Maki <jmaki@multitech.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+VERBOSE=false
+
+PLATFORM_NAME=sparkcell
+SYSFS_PLATFORM_DIR=/sys/devices/platform/${PLATFORM_NAME}
+
+MTS_IO_CONTROLS_STATUS_LED=true
+MTS_IO_CONTROLS_LS_LED=false
+
+LEDS_GPIO_DIR=/sys/devices/platform/leds-gpio/leds
+
+log_info() {
+ if [ "${VERBOSE}" = "true" ]; then
+ echo "info:" "$@"
+ fi
+}
+
+log_error() {
+ echo "error:" "$@" >&2
+}
+
+store() {
+ if [ $# -ne 2 ]; then
+ log_error "store name value"
+ exit 99
+ fi
+
+ local name=${1}
+ local value=${2}
+
+ log_info "setting ${name} to '${value}'"
+ echo -n "${value}" > ${SYSFS_PLATFORM_DIR}/${name}
+}
+
+show() {
+ if [ $# -ne 1 ]; then
+ log_error "show name"
+ exit 99
+ fi
+
+ local name=${1}
+
+ cat ${SYSFS_PLATFORM_DIR}/${name}
+}
+
+store_trigger() {
+ if [ $# -ne 2 ]; then
+ log_error "store_trigger name value"
+ exit 99
+ fi
+
+ local name=${1}
+ local value=${2}
+
+ log_info "setting ${name} to '${value}'"
+ echo -n "${value}" > cat ${LEDS_GPIO_DIR}/${name}/trigger
+}
+
+show_trigger() {
+ if [ $# -ne 1 ]; then
+ log_error "show_trigger name"
+ exit 99
+ fi
+
+ local name=${1}
+
+ cat ${LEDS_GPIO_DIR}/${name}/trigger
+}
+
+