Do not expect all BTSs support TSC != BCC

We introduce a new feature indicating if the given BTS model
supports a TSC that is different from the BCC (lower 3 bits of BSIC).
diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c
index 3b85892..b906c2e 100644
--- a/openbsc/src/libbsc/bsc_vty.c
+++ b/openbsc/src/libbsc/bsc_vty.c
@@ -491,8 +491,10 @@
 	vty_out(vty, "  cell_identity %u%s", bts->cell_identity, VTY_NEWLINE);
 	vty_out(vty, "  location_area_code %u%s", bts->location_area_code,
 		VTY_NEWLINE);
-	vty_out(vty, "  training_sequence_code %u%s", bts->tsc, VTY_NEWLINE);
 	vty_out(vty, "  base_station_id_code %u%s", bts->bsic, VTY_NEWLINE);
+	if (bts->tsc != (bts->bsic & 7))
+		vty_out(vty, "  training_sequence_code %u%s", bts->tsc,
+			VTY_NEWLINE);
 	if (bts->tz.override != 0) {
 		if (bts->tz.dst)
 			vty_out(vty, "  timezone %d %d %d%s",
@@ -1634,6 +1636,13 @@
 	struct gsm_bts *bts = vty->index;
 	int tsc = atoi(argv[0]);
 
+	if (!gsm_bts_has_feature(bts, BTS_FEAT_MULTI_TSC)) {
+		vty_out(vty, "%% This BTS does not support a TSC != BCC, "
+			"falling back to BCC%s", VTY_NEWLINE);
+		bts->tsc = bts->bsic & 7;
+		return CMD_WARNING;
+	}
+
 	bts->tsc = tsc;
 
 	return CMD_SUCCESS;
@@ -1655,6 +1664,11 @@
 	}
 	bts->bsic = bsic;
 
+	/* automatically re-configuer the TSC if we change the BCC
+	 * which is the lower 3 bits of the BSIC */
+	if (!gsm_bts_has_feature(bts, BTS_FEAT_MULTI_TSC))
+		bts->tsc = bts->bsic & 7;
+
 	return CMD_SUCCESS;
 }
 
@@ -2977,6 +2991,13 @@
 {
 	struct gsm_bts_trx_ts *ts = vty->index;
 
+	if (!gsm_bts_has_feature(ts->trx->bts, BTS_FEAT_MULTI_TSC)) {
+		vty_out(vty, "%% This BTS does not support a TSC != BCC, "
+			"falling back to BCC%s", VTY_NEWLINE);
+		ts->tsc = -1;
+		return CMD_WARNING;
+	}
+
 	ts->tsc = atoi(argv[0]);
 
 	return CMD_SUCCESS;