[osmo-bts PATCH 3/3] misc/sysmobts_misc: function for switching off/on

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Alvaro Neira anayuso at sysmocom.de
Thu Feb 27 11:30:27 UTC 2014


From: Álvaro Neira Ayuso <anayuso at sysmocom.de>

and requesting status power

I have extended the principal function that we use for requesting
information to the microcontroller for switching off/on the board
and the PA. And i have extended too with a function for requesting
the power status information of the board and the PA.

Signed-off-by: Alvaro Neira Ayuso <anayuso at sysmocom.de>
---
 src/osmo-bts-sysmo/misc/sysmobts_misc.c |   78 +++++++++++++++++++++++++++++++
 src/osmo-bts-sysmo/misc/sysmobts_misc.h |   12 +++++
 2 files changed, 90 insertions(+)

diff --git a/src/osmo-bts-sysmo/misc/sysmobts_misc.c b/src/osmo-bts-sysmo/misc/sysmobts_misc.c
index aee892d..4737ff1 100644
--- a/src/osmo-bts-sysmo/misc/sysmobts_misc.c
+++ b/src/osmo-bts-sysmo/misc/sysmobts_misc.c
@@ -115,6 +115,12 @@ struct msgb *sbts2050_ucinfo_get(struct uc ucontrol, struct ucinfo info)
 	case SBTS2050_TEMP_RQT:
 		num = sizeof(command->cmd.tempGet);
 		break;
+	case SBTS2050_PWR_RQT:
+		num = sizeof(command->cmd.pwrSetState);
+		break;
+	case SBTS2050_PWR_STATUS:
+		num = sizeof(command->cmd.pwrGetStatus);
+		break;
 	default:
 		return NULL;
 	}
@@ -133,6 +139,17 @@ struct msgb *sbts2050_ucinfo_get(struct uc ucontrol, struct ucinfo info)
 		command->u8Id = info.id;
 		command->u8Len = sizeof(command->cmd.tempGet);
 		break;
+	case SBTS2050_PWR_RQT:
+		command->u8Id = info.id;
+		command->u8Len = sizeof(command->cmd.pwrSetState);
+		command->cmd.pwrSetState.u1MasterEn = !!info.master;
+		command->cmd.pwrSetState.u1SlaveEn  = !!info.slave;
+		command->cmd.pwrSetState.u1PwrAmpEn = !!info.pa;
+		break;
+	case SBTS2050_PWR_STATUS:
+		command->u8Id     = info.id;
+		command->u8Len    = sizeof(command->cmd.pwrGetStatus);
+		break;
 	default:
 		goto err_free;
 	}
@@ -183,6 +200,67 @@ err_free:
 }
 
 /**********************************************************************
+ *	Get power status function
+ *********************************************************************/
+int sbts2050_uc_status(struct uc ucontrol, enum sbts2050_status_rqt status)
+{
+	struct msgb *msg;
+	struct ucinfo info = {
+		.id = SBTS2050_PWR_STATUS,
+	};
+	rsppkt_t *response;
+
+	msg = sbts2050_ucinfo_get(ucontrol, info);
+
+	if (msg == NULL) {
+		LOGP(DTEMP, LOGL_ERROR, "Error switching off some unit");
+		return -1;
+	}
+
+	response = (rsppkt_t *)msg->data;
+
+	switch (status) {
+	case SBTS2050_STATUS_MASTER:
+		return response->rsp.pwrGetStatus.u1MasterEn;
+	case SBTS2050_STATUS_SLAVE:
+		return response->rsp.pwrGetStatus.u1SlaveEn;
+	case SBTS2050_STATUS_PA:
+		return response->rsp.pwrGetStatus.u1PwrAmpEn;
+	default:
+		return -1;
+	}
+}
+
+/**********************************************************************
+ *	Uc Power Switching handling
+ *********************************************************************/
+void sbts2050_uc_power(struct uc ucontrol, int pmaster, int pslave, int ppa)
+{
+	struct msgb *msg;
+	struct ucinfo info = {
+		.id = 0x00,
+		.master = pmaster,
+		.slave = pslave,
+		.pa = ppa
+	};
+
+	msg = sbts2050_ucinfo_get(ucontrol, info);
+
+	if (msg == NULL) {
+		LOGP(DTEMP, LOGL_ERROR, "Error switching off some unit");
+		return;
+	}
+
+	LOGP(DTEMP, LOGL_DEBUG, "Switch off/on success:\n"
+				"MASTER %s\n"
+				"SLAVE %s\n"
+				"PA %s\n",
+				pmaster ? "ON" : "OFF",
+				pslave ? "ON" : "OFF",
+				ppa ? "ON" : "OFF");
+}
+
+/**********************************************************************
  *	Uc temperature handling
  *********************************************************************/
 void sbts2050_uc_check_temp(struct uc ucontrol)
diff --git a/src/osmo-bts-sysmo/misc/sysmobts_misc.h b/src/osmo-bts-sysmo/misc/sysmobts_misc.h
index f80df16..3d74a12 100644
--- a/src/osmo-bts-sysmo/misc/sysmobts_misc.h
+++ b/src/osmo-bts-sysmo/misc/sysmobts_misc.h
@@ -16,9 +16,17 @@ enum sysmobts_temp_type {
 };
 
 enum sbts2050_ids_request {
+	SBTS2050_PWR_RQT = 0x00,
+	SBTS2050_PWR_STATUS = 0x01,
 	SBTS2050_TEMP_RQT = 0x10
 };
 
+enum sbts2050_status_rqt {
+	SBTS2050_STATUS_MASTER,
+	SBTS2050_STATUS_SLAVE,
+	SBTS2050_STATUS_PA
+};
+
 struct uc {
 	int id;
 	const char *path;
@@ -40,6 +48,10 @@ struct msgb *sbts2050_ucinfo_get(struct uc ucontrol, struct ucinfo info);
 
 void sbts2050_uc_check_temp(struct uc ucontrol);
 
+void sbts2050_uc_power(struct uc ucontrol, int pmaster, int pslave, int ppa);
+
+int sbts2050_uc_status(struct uc ucontrol, enum sbts2050_status_rqt status);
+
 int sysmobts_update_hours(int no_epprom_write);
 
 enum sysmobts_firmware_type {





More information about the OpenBSC mailing list