rtc: imxdi: monitor a security violation at runtime
authorJuergen Borleis <jbe@pengutronix.de>
Mon, 27 Apr 2015 13:59:50 +0000 (15:59 +0200)
committerAlexandre Belloni <alexandre.belloni@free-electrons.com>
Fri, 19 Jun 2015 18:03:21 +0000 (20:03 +0200)
Maybe the unit enters the hardware related state at runtime and not at
system boot time (after a power cycle).

Signed-off-by: Juergen Borleis <jbe@pengutronix.de>
Signed-off-by: Robert Schwebel <rsc@pengutronix.de>
[rsc: got NDA clearance from Freescale]
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
drivers/rtc/rtc-imxdi.c

index 3d7f0390170e82bef916c4ff9d213b610e03810d..a08da4a353dbdb1d774630cc6d1d333abac834c4 100644 (file)
@@ -665,6 +665,25 @@ static irqreturn_t dryice_norm_irq(int irq, void *dev_id)
        irqreturn_t rc = IRQ_NONE;
 
        dier = readl(imxdi->ioaddr + DIER);
+       dsr = readl(imxdi->ioaddr + DSR);
+
+       /* handle the security violation event */
+       if (dier & DIER_SVIE) {
+               if (dsr & DSR_SVF) {
+                       /*
+                        * Disable the interrupt when this kind of event has
+                        * happened.
+                        * There cannot be more than one event of this type,
+                        * because it needs a complex state change
+                        * including a main power cycle to get again out of
+                        * this state.
+                        */
+                       di_int_disable(imxdi, DIER_SVIE);
+                       /* report the violation */
+                       di_report_tamper_info(imxdi, dsr);
+                       rc = IRQ_HANDLED;
+               }
+       }
 
        /* handle write complete and write error cases */
        if (dier & DIER_WCIE) {
@@ -675,7 +694,6 @@ static irqreturn_t dryice_norm_irq(int irq, void *dev_id)
                        return rc;
 
                /* DSR_WCF clears itself on DSR read */
-               dsr = readl(imxdi->ioaddr + DSR);
                if (dsr & (DSR_WCF | DSR_WEF)) {
                        /* mask the interrupt */
                        di_int_disable(imxdi, DIER_WCIE);
@@ -691,7 +709,6 @@ static irqreturn_t dryice_norm_irq(int irq, void *dev_id)
        /* handle the alarm case */
        if (dier & DIER_CAIE) {
                /* DSR_WCF clears itself on DSR read */
-               dsr = readl(imxdi->ioaddr + DSR);
                if (dsr & DSR_CAF) {
                        /* mask the interrupt */
                        di_int_disable(imxdi, DIER_CAIE);