From patchwork Thu May 7 09:30:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vipin K Parashar X-Patchwork-Id: 469371 X-Patchwork-Delegate: michael@ellerman.id.au Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 20EAF14028F for ; Thu, 7 May 2015 19:35:05 +1000 (AEST) Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id DCB5E1A1A59 for ; Thu, 7 May 2015 19:35:04 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from e23smtp06.au.ibm.com (e23smtp06.au.ibm.com [202.81.31.148]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id C59681A1196 for ; Thu, 7 May 2015 19:32:29 +1000 (AEST) Received: from /spool/local by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 7 May 2015 19:32:27 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp06.au.ibm.com (202.81.31.212) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 7 May 2015 19:32:27 +1000 Received: from d23relay07.au.ibm.com (d23relay07.au.ibm.com [9.190.26.37]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 433F22CE8054 for ; Thu, 7 May 2015 19:32:26 +1000 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay07.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t479WIGk17039570 for ; Thu, 7 May 2015 19:32:26 +1000 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t479Vrdh019423 for ; Thu, 7 May 2015 19:31:54 +1000 Received: from localhost.in.ibm.com ([9.124.218.44]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t479UqTw017352; Thu, 7 May 2015 19:31:52 +1000 From: Vipin K Parashar To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH v2 2/2] powerpc/powernv: Extract EPOW events timeout values from OPAL device tree Date: Thu, 7 May 2015 15:00:20 +0530 Message-Id: <1430991020-7556-3-git-send-email-vipin@linux.vnet.ibm.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1430991020-7556-1-git-send-email-vipin@linux.vnet.ibm.com> References: <1430991020-7556-1-git-send-email-vipin@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15050709-0021-0000-0000-00000133DF69 Cc: stewart@linux.vnet.ibm.com, Vipin K Parashar , joel@jms.id.au X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" OPAL exports plaform timeout values for various EPOW events under EPOW device tree node. EPOW node contains sub nodes for each EPOW class. Under each class platform timeout property files are located for EPOW events under that class. Each file contains platform timeout value for corresponding EPOW event in seconds. Support for extracting EPOW event timeout values from OPAL device tree is added by this patch. Below property files are parsed to extract EPOW event timeout values. Power EPOW =========== ups-timeout ups-low-timeout Temp EPOW ========== high-ambient-temp-timeout crit-ambient-temp-timeout high-internal-temp-timeout crit-internal-temp-timeout Signed-off-by: Vipin K Parashar --- arch/powerpc/platforms/powernv/opal-power.c | 79 +++++++++++++++++++++++++---- 1 file changed, 70 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/platforms/powernv/opal-power.c b/arch/powerpc/platforms/powernv/opal-power.c index 7c1b2f8..5b015f3 100644 --- a/arch/powerpc/platforms/powernv/opal-power.c +++ b/arch/powerpc/platforms/powernv/opal-power.c @@ -60,15 +60,7 @@ static const char * const epow_events_map[] = { }; /* Poweroff EPOW events timeout values in seconds */ -static const int epow_timeout[] = { - [EPOW_POWER_UPS] = 900, - [EPOW_POWER_UPS_LOW] = 20, - [EPOW_TEMP_HIGH_AMB] = 900, - [EPOW_TEMP_CRIT_AMB] = 20, - [EPOW_TEMP_HIGH_INT] = 900, - [EPOW_TEMP_CRIT_INT] = 20, - [EPOW_UNKNOWN] = 0, -}; +static int epow_timeout[MAX_EPOW_EVENTS]; /* System poweroff function. */ static void epow_poweroff(unsigned long event) @@ -125,6 +117,72 @@ static void stop_epow_timer(void) pr_info("Poweroff timer deactivated\n"); } +/* Extract timeout value from device tree property */ +static int get_timeout_value(struct device_node *node, const char *prop) +{ + const __be32 *pval; + int timeout = 0; + + pval = of_get_property(node, prop, NULL); + if (pval) + timeout = be32_to_cpup(pval); + else + pr_err("Didn't find %s dt property\n", prop); + + return timeout; +} + +/* Get EPOW events timeout values from OPAL device tree */ +static void get_epow_timeouts(void) +{ + struct device_node *epow_power, *epow_temp; + + /* EPOW power class event timeouts */ + epow_power = of_find_node_by_path("/ibm,opal/epow/power"); + if (epow_power) { + epow_timeout[EPOW_POWER_UPS] = + get_timeout_value(epow_power, "ups-timeout"); + pr_info("Power EPOW ups-timeout = %d seconds\n", + epow_timeout[EPOW_POWER_UPS]); + + epow_timeout[EPOW_POWER_UPS_LOW] = + get_timeout_value(epow_power, "ups-low-timeout"); + pr_info("Power EPOW ups-low-timeout = %d seconds\n", + epow_timeout[EPOW_POWER_UPS_LOW]); + + of_node_put(epow_power); + } else + pr_info("Power EPOW class not supported in OPAL\n"); + + /* EPOW temp class event timeouts */ + epow_temp = of_find_node_by_path("/ibm,opal/epow/temp"); + if (epow_temp) { + epow_timeout[EPOW_TEMP_HIGH_AMB] = + get_timeout_value(epow_temp, "high-ambient-temp-timeout"); + pr_info("Temp EPOW high-ambient-temp-timeout = %d seconds\n", + epow_timeout[EPOW_TEMP_HIGH_AMB]); + + epow_timeout[EPOW_TEMP_CRIT_AMB] = + get_timeout_value(epow_temp, "crit-ambient-temp-timeout"); + pr_info("Temp EPOW crit-ambient-temp-timeout = %d seconds\n", + epow_timeout[EPOW_TEMP_CRIT_AMB]); + + epow_timeout[EPOW_TEMP_HIGH_INT] = + get_timeout_value(epow_temp, "high-internal-temp-timeout"); + pr_info("Temp EPOW high-inernal-temp-timeout = %d seconds\n", + epow_timeout[EPOW_TEMP_HIGH_INT]); + + epow_timeout[EPOW_TEMP_CRIT_INT] = + get_timeout_value(epow_temp, "crit-internal-temp-timeout"); + pr_info("Temp EPOW crit-inernal-temp-timeout = %d seconds\n", + epow_timeout[EPOW_TEMP_CRIT_INT]); + + of_node_put(epow_temp); + } else + pr_info("Temp EPOW class not supported in OPAL\n"); + +} + /* Get DPO status */ static bool get_dpo_status(int32_t *dpo_timeout) { @@ -366,6 +424,9 @@ static int __init opal_poweroff_events_init(void) init_timer(&epow_timer); epow_timer.function = epow_poweroff; + /* Get EPOW events timeout value */ + get_epow_timeouts(); + /* Register EPOW event notifier */ ret = opal_message_notifier_register(OPAL_MSG_EPOW, &opal_epow_nb);