mei: abstract host and device readieness
authorTomas Winkler <tomas.winkler@intel.com>
Tue, 8 Jan 2013 21:07:29 +0000 (23:07 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 9 Jan 2013 00:40:47 +0000 (16:40 -0800)
Add mei_host_set_ready function to enable the device
and is_ready function to query the host and me readiness

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/mei/hw-me.c
drivers/misc/mei/init.c
drivers/misc/mei/interrupt.c
drivers/misc/mei/mei_dev.h

index ed61659fd388f387a80ebc7e6a080d5e208e97bd..49b558ddf5b544b39f05695e90612dda59394578 100644 (file)
@@ -172,6 +172,39 @@ void mei_hw_reset(struct mei_device *dev, bool intr_enable)
        dev_dbg(&dev->pdev->dev, "current HCSR = 0x%08x.\n", hcsr);
 }
 
+/**
+ * mei_host_set_ready - enable device
+ *
+ * @dev - mei device
+ * returns bool
+ */
+
+void mei_host_set_ready(struct mei_device *dev)
+{
+       dev->host_hw_state |= H_IE | H_IG | H_RDY;
+       mei_hcsr_set(dev);
+}
+/**
+ * mei_host_is_ready - check whether the host has turned ready
+ *
+ * @dev - mei device
+ * returns bool
+ */
+bool mei_host_is_ready(struct mei_device *dev)
+{
+       return (dev->host_hw_state & H_RDY) == H_RDY;
+}
+
+/**
+ * mei_me_is_ready - check whether the me has turned ready
+ *
+ * @dev - mei device
+ * returns bool
+ */
+bool mei_me_is_ready(struct mei_device *dev)
+{
+       return (dev->me_hw_state & ME_RDY_HRA) == ME_RDY_HRA;
+}
 
 /**
  * mei_interrupt_quick_handler - The ISR of the MEI device
@@ -290,7 +323,7 @@ int mei_write_message(struct mei_device *dev, struct mei_msg_hdr *header,
        dev->host_hw_state |= H_IG;
        mei_hcsr_set(dev);
        dev->me_hw_state = mei_mecsr_read(dev);
-       if ((dev->me_hw_state & ME_RDY_HRA) != ME_RDY_HRA)
+       if (!mei_me_is_ready(dev))
                return -EIO;
 
        return 0;
index 5c2054d06f6bf2263518a2b52e75c1786713db37..d0ee02ac82014a3cfd4771f1dc4b13c80d52418d 100644 (file)
@@ -131,18 +131,18 @@ int mei_hw_init(struct mei_device *dev)
                goto out;
        }
 
-       if (!(((dev->host_hw_state & H_RDY) == H_RDY) &&
-             ((dev->me_hw_state & ME_RDY_HRA) == ME_RDY_HRA))) {
+       if (!(mei_host_is_ready(dev) && mei_me_is_ready(dev))) {
                dev->dev_state = MEI_DEV_DISABLED;
+
                dev_dbg(&dev->pdev->dev,
                        "host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n",
                        dev->host_hw_state, dev->me_hw_state);
 
-               if (!(dev->host_hw_state & H_RDY))
-                       dev_dbg(&dev->pdev->dev, "host turn off H_RDY.\n");
+               if (!mei_host_is_ready(dev))
+                       dev_dbg(&dev->pdev->dev, "host is not ready.\n");
 
-               if (!(dev->me_hw_state & ME_RDY_HRA))
-                       dev_dbg(&dev->pdev->dev, "ME turn off ME_RDY.\n");
+               if (!mei_me_is_ready(dev))
+                       dev_dbg(&dev->pdev->dev, "ME is not ready.\n");
 
                dev_err(&dev->pdev->dev, "link layer initialization failed.\n");
                ret = -ENODEV;
@@ -159,9 +159,7 @@ int mei_hw_init(struct mei_device *dev)
        dev->recvd_msg = false;
        dev_dbg(&dev->pdev->dev, "host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n",
            dev->host_hw_state, dev->me_hw_state);
-       dev_dbg(&dev->pdev->dev, "ME turn on ME_RDY and host turn on H_RDY.\n");
        dev_dbg(&dev->pdev->dev, "link layer has been established.\n");
-       dev_dbg(&dev->pdev->dev, "MEI  start success.\n");
        ret = 0;
 
 out:
index d7e1b797e87b388a4461ef2d5bce70783ee5c038..27374b6b642433341f68937a236641d41769bd02 100644 (file)
@@ -700,7 +700,7 @@ irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id)
        dev->me_hw_state = mei_mecsr_read(dev);
 
        /* check if ME wants a reset */
-       if ((dev->me_hw_state & ME_RDY_HRA) == 0 &&
+       if (!mei_me_is_ready(dev) &&
            dev->dev_state != MEI_DEV_RESETING &&
            dev->dev_state != MEI_DEV_INITIALIZING) {
                dev_dbg(&dev->pdev->dev, "FW not ready.\n");
@@ -711,16 +711,17 @@ irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id)
 
        dev->host_hw_state = mei_hcsr_read(dev);
        /*  check if we need to start the dev */
-       if ((dev->host_hw_state & H_RDY) == 0) {
-               if ((dev->me_hw_state & ME_RDY_HRA) == ME_RDY_HRA) {
+       if (!mei_host_is_ready(dev)) {
+               if (mei_me_is_ready(dev)) {
                        dev_dbg(&dev->pdev->dev, "we need to start the dev.\n");
-                       dev->host_hw_state |= (H_IE | H_IG | H_RDY);
-                       mei_hcsr_set(dev);
-                       dev->dev_state = MEI_DEV_INIT_CLIENTS;
+
+                       mei_host_set_ready(dev);
+
                        dev_dbg(&dev->pdev->dev, "link is established start sending messages.\n");
-                       /* link is established
-                        * start sending messages.
-                        */
+                       /* link is established * start sending messages.  */
+
+                       dev->dev_state = MEI_DEV_INIT_CLIENTS;
+
                        mei_hbm_start_req(dev);
                        mutex_unlock(&dev->device_lock);
                        return IRQ_HANDLED;
index 8692ac8c98d443f452e18b769d47707669865b60..7b4365952be5ab0df37dddbe9a71d490ae214f29 100644 (file)
@@ -396,6 +396,10 @@ void mei_clear_interrupts(struct mei_device *dev);
 void mei_enable_interrupts(struct mei_device *dev);
 void mei_disable_interrupts(struct mei_device *dev);
 
+void mei_host_set_ready(struct mei_device *dev);
+bool mei_host_is_ready(struct mei_device *dev);
+bool mei_me_is_ready(struct mei_device *dev);
+
 
 
 #define MEI_HDR_FMT "hdr:host=%02d me=%02d len=%d comp=%1d"
This page took 0.029076 seconds and 5 git commands to generate.