summaryrefslogtreecommitdiff
path: root/io-tool/mts-io-sysfs-inc.sh
blob: c4a48db022c5839cf15cd46eccdb85d6663cee57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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=mtcdp
SYSFS_PLATFORM_DIR=/sys/devices/platform/${PLATFORM_NAME}

MTS_IO_CONTROLS_STATUS_LED=false
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
}