linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Vipin K Parashar <vipin@linux.vnet.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: stewart@linux.vnet.ibm.com,
	Vipin K Parashar <vipin@linux.vnet.ibm.com>,
	joel@jms.id.au
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	[thread overview]
Message-ID: <1430991020-7556-3-git-send-email-vipin@linux.vnet.ibm.com> (raw)
In-Reply-To: <1430991020-7556-1-git-send-email-vipin@linux.vnet.ibm.com>

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 <vipin@linux.vnet.ibm.com>
---
 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);
-- 
1.9.3

      parent reply	other threads:[~2015-05-07  9:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-07  9:30 [PATCH v2 0/2] Poweroff (EPOW, DPO) events support for PowerNV platform Vipin K Parashar
2015-05-07  9:30 ` [PATCH v2 1/2] powerpc/powernv: Add poweroff " Vipin K Parashar
2015-05-08  1:26   ` Joel Stanley
2015-05-11  7:01     ` Vipin K Parashar
2015-05-08  7:37   ` trigg
2015-05-11 22:31     ` Stewart Smith
     [not found]       ` <CAPfuKjKtSHB3Q03vGD9XDnk2yFV31mC8wdJGr3q8XYZfvSx3LA@mail.gmail.com>
2015-05-12 17:09         ` Triggering
2015-05-11  6:49   ` Michael Ellerman
2015-05-11  9:01     ` Vipin K Parashar
2015-05-11 10:47       ` Vipin K Parashar
2015-05-13 20:17     ` Vipin K Parashar
2015-05-07  9:30 ` Vipin K Parashar [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1430991020-7556-3-git-send-email-vipin@linux.vnet.ibm.com \
    --to=vipin@linux.vnet.ibm.com \
    --cc=joel@jms.id.au \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=stewart@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).