From patchwork Wed Mar 12 14:09:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alvaro Neira X-Patchwork-Id: 329473 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ganesha.gnumonks.org (ganesha.gnumonks.org [IPv6:2001:780:45:1d:225:90ff:fe52:c662]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A95872C00E4 for ; Thu, 13 Mar 2014 01:10:50 +1100 (EST) Received: from localhost ([127.0.0.1] helo=ganesha.gnumonks.org) by ganesha.gnumonks.org with esmtp (Exim 4.72) (envelope-from ) id 1WNjrd-0001DY-JJ; Wed, 12 Mar 2014 15:10:34 +0100 Received: from mail.sysmocom.de ([2a01:4f8:191:444c::2:4]) by ganesha.gnumonks.org with esmtp (Exim 4.72) (envelope-from ) id 1WNjqZ-0000ce-Aq for openbsc@lists.osmocom.org; Wed, 12 Mar 2014 15:09:29 +0100 Received: from [127.0.1.1] (p5099b351.dip0.t-ipconnect.de [80.153.179.81]) by mail.sysmocom.de (Postfix) with ESMTPSA id 1ED864B449 for ; Wed, 12 Mar 2014 14:09:27 +0000 (UTC) Subject: [osmo-bts PATCH v3 2/2] misc/sysmobts_misc: function for switching off/on and requesting status power To: openbsc@lists.osmocom.org From: Alvaro Neira Date: Wed, 12 Mar 2014 15:09:15 +0100 Message-ID: <20140312140911.9518.60507.stgit@Ph0enix> In-Reply-To: <20140312135649.9518.84048.stgit@Ph0enix> References: <20140312135649.9518.84048.stgit@Ph0enix> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Spam-Score: 0.0 (/) X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Development of the OpenBSC GSM base station controller List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: openbsc-bounces@lists.osmocom.org Errors-To: openbsc-bounces@lists.osmocom.org From: Álvaro Neira Ayuso 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 --- src/osmo-bts-sysmo/misc/sysmobts_misc.c | 81 +++++++++++++++++++++++++++++++ src/osmo-bts-sysmo/misc/sysmobts_misc.h | 10 ++++ 2 files changed, 91 insertions(+) diff --git a/src/osmo-bts-sysmo/misc/sysmobts_misc.c b/src/osmo-bts-sysmo/misc/sysmobts_misc.c index 081b65f..310c681 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_misc.c +++ b/src/osmo-bts-sysmo/misc/sysmobts_misc.c @@ -114,6 +114,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; } @@ -132,6 +138,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; } @@ -175,6 +192,70 @@ err: } /********************************************************************** + * 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; + } + msgb_free(msg); +} + +/********************************************************************** + * 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"); + + msgb_free(msg); +} + +/********************************************************************** * Uc temperature handling *********************************************************************/ void sbts2050_uc_check_temp(struct uc *ucontrol, int *temp_pa, int *temp_board) diff --git a/src/osmo-bts-sysmo/misc/sysmobts_misc.h b/src/osmo-bts-sysmo/misc/sysmobts_misc.h index a0c57a4..9967853 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_misc.h +++ b/src/osmo-bts-sysmo/misc/sysmobts_misc.h @@ -13,6 +13,12 @@ enum sysmobts_temp_type { _NUM_TEMP_TYPES }; +enum sbts2050_status_rqt { + SBTS2050_STATUS_MASTER, + SBTS2050_STATUS_SLAVE, + SBTS2050_STATUS_PA +}; + struct uc { int id; int fd; @@ -35,6 +41,10 @@ struct msgb *sbts2050_ucinfo_get(struct uc *ucontrol, struct ucinfo info); void sbts2050_uc_check_temp(struct uc *ucontrol, int *temp_pa, int *temp_board); +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 {