diff options
author | Harald Welte <laforge@gnumonks.org> | 2012-05-31 23:15:38 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2012-06-01 00:06:58 +0200 |
commit | 799ea59c2feeb9fe7ea9e9c202376e973ffca711 (patch) | |
tree | 967a162fd8b11b2f078ef65fb27b1e696f0561b7 /src | |
parent | 700c645478249319dcf7e7e138c13dbbb9c04ba9 (diff) |
sysmobts: set the RF ACTIVE LED when we bring RF up
Once we get RF-ACTIVATE.conf from L1, we now enable the corresponding
LED. We also switch it off on RF-DEACTIVATE.conf. We do _not_ switch
it off when osmo-bts crashes or terminates before RF-DEACTIVATE.conf.
The latter is intentional, as RF may very well still be active at that
point. The re-spawning script will re-set the DSP and therby turn off
the RF and then disable the LED.
A better solution might be to do all this in the kernel driver for the
DSP.
Diffstat (limited to 'src')
-rw-r--r-- | src/osmo-bts-sysmo/Makefile.am | 2 | ||||
-rw-r--r-- | src/osmo-bts-sysmo/hw_misc.c | 113 | ||||
-rw-r--r-- | src/osmo-bts-sysmo/hw_misc.h | 12 | ||||
-rw-r--r-- | src/osmo-bts-sysmo/l1_if.c | 6 |
4 files changed, 131 insertions, 2 deletions
diff --git a/src/osmo-bts-sysmo/Makefile.am b/src/osmo-bts-sysmo/Makefile.am index 0ae85f8b..ab3e706f 100644 --- a/src/osmo-bts-sysmo/Makefile.am +++ b/src/osmo-bts-sysmo/Makefile.am @@ -4,7 +4,7 @@ LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMOTRAU_ bin_PROGRAMS = sysmobts sysmobts-remote l1fwd-proxy -COMMON_SOURCES = main.c femtobts.c l1_if.c oml.c sysmobts_vty.c tch.c +COMMON_SOURCES = main.c femtobts.c l1_if.c oml.c sysmobts_vty.c tch.c hw_misc.c sysmobts_SOURCES = $(COMMON_SOURCES) l1_transp_hw.c sysmobts_LDADD = $(top_builddir)/src/common/libbts.a $(LDADD) diff --git a/src/osmo-bts-sysmo/hw_misc.c b/src/osmo-bts-sysmo/hw_misc.c new file mode 100644 index 00000000..6aa3b83f --- /dev/null +++ b/src/osmo-bts-sysmo/hw_misc.c @@ -0,0 +1,113 @@ +/* Misc HW routines for Sysmocom BTS */ + +/* (C) 2012 by Harald Welte <laforge@gnumonks.org> + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 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 Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include <stdint.h> +#include <unistd.h> +#include <limits.h> +#include <fcntl.h> +#include <errno.h> +#include <stdio.h> +#include <string.h> + +#include <sys/types.h> +#include <sys/stat.h> + +#include <osmocom/core/utils.h> + +#include "hw_misc.h" + +static const struct value_string sysmobts_led_names[] = { + { LED_RF_ACTIVE, "activity_led" }, + { LED_ONLINE, "online_led" }, + { 0, NULL } +}; + +int sysmobts_led_set(enum sysmobts_led nr, int on) +{ + char tmp[PATH_MAX+1]; + const char *filename; + int fd; + uint8_t byte; + + if (on) + byte = '1'; + else + byte = '0'; + + filename = get_value_string(sysmobts_led_names, nr); + if (!filename) + return -EINVAL; + + snprintf(tmp, sizeof(tmp)-1, "/sys/class/leds/%s/brightness", filename); + tmp[sizeof(tmp)-1] = '\0'; + + fd = open(tmp, O_WRONLY); + if (fd < 0) + return -ENODEV; + + write(fd, &byte, 1); + + close(fd); + + return 0; +} + +#if 0 +#define HWMON_PREFIX "/sys/class/hwmon/hwmon0/device" + +static FILE *temperature_f[NUM_TEMP]; + +int sysmobts_temp_init() +{ + char tmp[PATH_MAX+1]; + FILE *in; + int rc = 0; + + for (i = 0; i < NUM_TEMP; i++) { + snprintf(tmp, sizeof(tmp)-1, HWMON_PREFIX "/temp%u_input", i+1), + tmp[sizeof(tmp)-1] = '\0'; + + temperature_f[i] = fopen(tmp, "r"); + if (!temperature_f[i]) + rc = -ENODEV; + } + + return 0; +} + +int sysmobts_temp_get(uint8_t num) +{ + if (num >= NUM_TEMP) + return -EINVAL; + + if (!temperature_f[num]) + return -ENODEV; + + + in = fopen(tmp, "r"); + if (!in) + return -ENODEV; + + fclose(tmp); + + return 0; +} +#endif diff --git a/src/osmo-bts-sysmo/hw_misc.h b/src/osmo-bts-sysmo/hw_misc.h new file mode 100644 index 00000000..c4838dbf --- /dev/null +++ b/src/osmo-bts-sysmo/hw_misc.h @@ -0,0 +1,12 @@ +#ifndef _SYSMOBTS_HW_MISC_H +#define _SYSMOBTS_HW_MISC_H + +enum sysmobts_led { + LED_NONE, + LED_RF_ACTIVE, + LED_ONLINE, +}; + +int sysmobts_led_set(enum sysmobts_led nr, int on); + +#endif diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c index 74d08f10..f5813b65 100644 --- a/src/osmo-bts-sysmo/l1_if.c +++ b/src/osmo-bts-sysmo/l1_if.c @@ -54,6 +54,7 @@ #include "femtobts.h" #include "l1_if.h" #include "l1_transp.h" +#include "hw_misc.h" /* FIXME: make threshold configurable */ #define MIN_QUAL_RACH 5.0f /* at least 5 dB C/I */ @@ -847,7 +848,9 @@ static int activate_rf_compl_cb(struct msgb *resp, void *data) LOGP(DL1C, LOGL_FATAL, "RF-ACT.conf with status %s\n", get_value_string(femtobts_l1status_names, status)); bts_shutdown(trx->bts, "RF-ACT failure"); - } + } else + sysmobts_led_set(LED_RF_ACTIVE, 1); + /* signal availability */ oml_mo_state_chg(&trx->mo, NM_OPSTATE_DISABLED, NM_AVSTATE_OK); oml_mo_tx_sw_act_rep(&trx->mo); @@ -857,6 +860,7 @@ static int activate_rf_compl_cb(struct msgb *resp, void *data) for (i = 0; i < ARRAY_SIZE(trx->ts); i++) oml_mo_state_chg(&trx->ts[i].mo, NM_OPSTATE_DISABLED, NM_AVSTATE_DEPENDENCY); } else { + sysmobts_led_set(LED_RF_ACTIVE, 0); oml_mo_state_chg(&trx->mo, NM_OPSTATE_DISABLED, NM_AVSTATE_OFF_LINE); oml_mo_state_chg(&trx->bb_transc.mo, NM_OPSTATE_DISABLED, NM_AVSTATE_OFF_LINE); } |