aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-litecell15/misc/lc15bts_par.c
diff options
context:
space:
mode:
authorYves Godin <support@nuranwireless.com>2015-11-12 08:32:07 -0500
committerHarald Welte <laforge@gnumonks.org>2016-02-15 14:26:33 +0100
commit2a711887b7e91893555891e5c033189d6705eec3 (patch)
tree00abee90a3e8d04f01f34df54f7d7f1c3494fd50 /src/osmo-bts-litecell15/misc/lc15bts_par.c
parent5a945dad0cb34dc351427b33a3ce0ed9dd0e394f (diff)
LC15: Add initial support for the NuRAN Wireless Litecell 1.5
This commit adds basic support for the Litecell 1.5. Multi-TRX is not supported yet. Instead, multiple instances of the BTS can be launched using command line parameter -n <HW_TRX_NR> to specify if TRX 1 or 2 must be used by the bts. Note that only TRX 1 opens a connection to the PCU. Full support for GPRS on both TRX will come at the same time than the multi-TRX support. The BTS manager has been adapted to match the new hardware but otherwise it has not been improved or changed compared to the one used on the SuperFemto/Litecell (sysmobts).
Diffstat (limited to 'src/osmo-bts-litecell15/misc/lc15bts_par.c')
-rw-r--r--src/osmo-bts-litecell15/misc/lc15bts_par.c181
1 files changed, 181 insertions, 0 deletions
diff --git a/src/osmo-bts-litecell15/misc/lc15bts_par.c b/src/osmo-bts-litecell15/misc/lc15bts_par.c
new file mode 100644
index 00000000..71544261
--- /dev/null
+++ b/src/osmo-bts-litecell15/misc/lc15bts_par.c
@@ -0,0 +1,181 @@
+/* lc15bts - access to hardware related parameters */
+
+/* Copyright (C) 2015 by Yves Godin <support@nuranwireless.com>
+ *
+ * Based on sysmoBTS:
+ * sysmobts_par.c
+ * (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 <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <limits.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <osmocom/core/utils.h>
+
+#include "lc15bts_par.h"
+
+
+#define FACTORY_ROM_PATH "/mnt/rom/factory"
+#define USER_ROM_PATH "/mnt/rom/user"
+
+const struct value_string lc15bts_par_names[_NUM_LC15BTS_PAR+1] = {
+ { LC15BTS_PAR_TEMP_SUPPLY_MAX, "temp-supply-max" },
+ { LC15BTS_PAR_TEMP_SOC_MAX, "temp-soc-max" },
+ { LC15BTS_PAR_TEMP_FPGA_MAX, "temp-fpga-max" },
+ { LC15BTS_PAR_TEMP_MEMORY_MAX, "temp-memory-max" },
+ { LC15BTS_PAR_TEMP_TX1_MAX, "temp-tx1-max" },
+ { LC15BTS_PAR_TEMP_TX2_MAX, "temp-tx2-max" },
+ { LC15BTS_PAR_TEMP_PA1_MAX, "temp-pa1-max" },
+ { LC15BTS_PAR_TEMP_PA2_MAX, "temp-pa2-max" },
+ { LC15BTS_PAR_SERNR, "serial-nr" },
+ { LC15BTS_PAR_HOURS, "hours-running" },
+ { LC15BTS_PAR_BOOTS, "boot-count" },
+ { LC15BTS_PAR_KEY, "key" },
+ { 0, NULL }
+};
+
+int lc15bts_par_is_int(enum lc15bts_par par)
+{
+ switch (par) {
+ case LC15BTS_PAR_TEMP_SUPPLY_MAX:
+ case LC15BTS_PAR_TEMP_SOC_MAX:
+ case LC15BTS_PAR_TEMP_FPGA_MAX:
+ case LC15BTS_PAR_TEMP_MEMORY_MAX:
+ case LC15BTS_PAR_TEMP_TX1_MAX:
+ case LC15BTS_PAR_TEMP_TX2_MAX:
+ case LC15BTS_PAR_TEMP_PA1_MAX:
+ case LC15BTS_PAR_TEMP_PA2_MAX:
+ case LC15BTS_PAR_SERNR:
+ case LC15BTS_PAR_HOURS:
+ case LC15BTS_PAR_BOOTS:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+int lc15bts_par_get_int(enum lc15bts_par par, int *ret)
+{
+ char fpath[PATH_MAX];
+ FILE *fp;
+ int rc;
+
+ if (par >= _NUM_LC15BTS_PAR)
+ return -ENODEV;
+
+ snprintf(fpath, sizeof(fpath)-1, "%s/%s", USER_ROM_PATH, get_value_string(lc15bts_par_names, par));
+ fpath[sizeof(fpath)-1] = '\0';
+
+ fp = fopen(fpath, "r");
+ if (fp == NULL) {
+ return -errno;
+ }
+
+ rc = fscanf(fp, "%d", ret);
+ if (rc != 1) {
+ fclose(fp);
+ return -EIO;
+ }
+ fclose(fp);
+ return 0;
+}
+
+int lc15bts_par_set_int(enum lc15bts_par par, int val)
+{
+ char fpath[PATH_MAX];
+ FILE *fp;
+ int rc;
+
+ if (par >= _NUM_LC15BTS_PAR)
+ return -ENODEV;
+
+ snprintf(fpath, sizeof(fpath)-1, "%s/%s", USER_ROM_PATH, get_value_string(lc15bts_par_names, par));
+ fpath[sizeof(fpath)-1] = '\0';
+
+ fp = fopen(fpath, "w");
+ if (fp == NULL) {
+ return -errno;
+ }
+
+ rc = fprintf(fp, "%d", val);
+ if (rc < 0) {
+ fclose(fp);
+ return -EIO;
+ }
+ fclose(fp);
+ return 0;
+}
+
+int lc15bts_par_get_buf(enum lc15bts_par par, uint8_t *buf,
+ unsigned int size)
+{
+ char fpath[PATH_MAX];
+ FILE *fp;
+ int rc;
+
+ if (par >= _NUM_LC15BTS_PAR)
+ return -ENODEV;
+
+ snprintf(fpath, sizeof(fpath)-1, "%s/%s", USER_ROM_PATH, get_value_string(lc15bts_par_names, par));
+ fpath[sizeof(fpath)-1] = '\0';
+
+ fp = fopen(fpath, "rb");
+ if (fp == NULL) {
+ return -errno;
+ }
+
+ rc = fread(buf, 1, size, fp);
+
+ fclose(fp);
+
+ return rc;
+}
+
+int lc15bts_par_set_buf(enum lc15bts_par par, const uint8_t *buf,
+ unsigned int size)
+{
+ char fpath[PATH_MAX];
+ FILE *fp;
+ int rc;
+
+ if (par >= _NUM_LC15BTS_PAR)
+ return -ENODEV;
+
+ snprintf(fpath, sizeof(fpath)-1, "%s/%s", USER_ROM_PATH, get_value_string(lc15bts_par_names, par));
+ fpath[sizeof(fpath)-1] = '\0';
+
+ fp = fopen(fpath, "wb");
+ if (fp == NULL) {
+ return -errno;
+ }
+
+ rc = fwrite(buf, 1, size, fp);
+
+ fclose(fp);
+
+ return rc;
+}