mei: abstract host and device readieness

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>
This commit is contained in:
Tomas Winkler 2013-01-08 23:07:29 +02:00 committed by Greg Kroah-Hartman
parent 9ea73ddd4f
commit 115ba28c5e
4 changed files with 54 additions and 18 deletions

View 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;

View 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:

View 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;

View 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"