From 34609050e110fdeaf9cd63888c5902031ca21b1f Mon Sep 17 00:00:00 2001 From: James Maki Date: Fri, 23 Apr 2010 15:10:19 -0500 Subject: initial commit --- io-tool/mts-io-sysfs-inc.sh | 92 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 io-tool/mts-io-sysfs-inc.sh (limited to 'io-tool/mts-io-sysfs-inc.sh') 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 +# +# 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 +} + + -- cgit v1.2.3