aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVaibhav Jain <vaibhav@linux.vnet.ibm.com>2017-05-31 09:09:01 -0400
committerAlexandre Belloni <alexandre.belloni@free-electrons.com>2017-06-24 01:48:30 -0400
commit0ec7769a98b00866e37740328d65cba6594d178d (patch)
tree9be00963531c1c085cc13100a2607739da61cca0
parent5c82a6ae0242416cfead597bb2b42aa3481a0ba7 (diff)
rtc: opal: Implement rtc_class_ops.alarm_irq_enable callback
Provide an implementation of the callback rtc_class_ops.alarm_irq_enable for rtc-opal driver. This callback is called when the wake alarm is disabled via the command: 'echo 0 > /sys/class/rtc/rtc0/wakealarm' Without this the Timed-Power-On(TPO) config remains set even when its disabled by the above command and FSP will still force machine boot at previously configured alarm time. The callback is implemented as function opal_tpo_alarm_irq_enable() which calls opal_set_tpo_time() with alarm.enabled == 0. A branch is added to opal_set_tpo_time() to handle this case by passing y_m_d == h_m_s_ms == 0 to opal as arguments for opal_tpo_write() call. Signed-off-by: Vaibhav Jain <vaibhav@linux.vnet.ibm.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
-rw-r--r--drivers/rtc/rtc-opal.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/drivers/rtc/rtc-opal.c b/drivers/rtc/rtc-opal.c
index 2d84e2a28772..e2a946c0e667 100644
--- a/drivers/rtc/rtc-opal.c
+++ b/drivers/rtc/rtc-opal.c
@@ -167,7 +167,14 @@ static int opal_set_tpo_time(struct device *dev, struct rtc_wkalrm *alarm)
167 u32 y_m_d = 0; 167 u32 y_m_d = 0;
168 int token, rc; 168 int token, rc;
169 169
170 tm_to_opal(&alarm->time, &y_m_d, &h_m_s_ms); 170 /* if alarm is enabled */
171 if (alarm->enabled) {
172 tm_to_opal(&alarm->time, &y_m_d, &h_m_s_ms);
173 pr_debug("Alarm set to %x %llx\n", y_m_d, h_m_s_ms);
174
175 } else {
176 pr_debug("Alarm getting disabled\n");
177 }
171 178
172 token = opal_async_get_token_interruptible(); 179 token = opal_async_get_token_interruptible();
173 if (token < 0) { 180 if (token < 0) {
@@ -200,6 +207,18 @@ exit:
200 return rc; 207 return rc;
201} 208}
202 209
210int opal_tpo_alarm_irq_enable(struct device *dev, unsigned int enabled)
211{
212 struct rtc_wkalrm alarm = { .enabled = 0 };
213
214 /*
215 * TPO is automatically enabled when opal_set_tpo_time() is called with
216 * non-zero rtc-time. We only handle disable case which needs to be
217 * explicitly told to opal.
218 */
219 return enabled ? 0 : opal_set_tpo_time(dev, &alarm);
220}
221
203static struct rtc_class_ops opal_rtc_ops = { 222static struct rtc_class_ops opal_rtc_ops = {
204 .read_time = opal_get_rtc_time, 223 .read_time = opal_get_rtc_time,
205 .set_time = opal_set_rtc_time, 224 .set_time = opal_set_rtc_time,
@@ -215,6 +234,7 @@ static int opal_rtc_probe(struct platform_device *pdev)
215 device_set_wakeup_capable(&pdev->dev, true); 234 device_set_wakeup_capable(&pdev->dev, true);
216 opal_rtc_ops.read_alarm = opal_get_tpo_time; 235 opal_rtc_ops.read_alarm = opal_get_tpo_time;
217 opal_rtc_ops.set_alarm = opal_set_tpo_time; 236 opal_rtc_ops.set_alarm = opal_set_tpo_time;
237 opal_rtc_ops.alarm_irq_enable = opal_tpo_alarm_irq_enable;
218 } 238 }
219 239
220 rtc = devm_rtc_device_register(&pdev->dev, DRVNAME, &opal_rtc_ops, 240 rtc = devm_rtc_device_register(&pdev->dev, DRVNAME, &opal_rtc_ops,