Skip to content

Commit

Permalink
mei: move fw_status back to hw ops handlers
Browse files Browse the repository at this point in the history
fw status retrieval has pci specific implementation
so we push it back to the hw layer

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Tomas Winkler authored and Greg Kroah-Hartman committed Sep 29, 2014
1 parent 2bf94ca commit 1bd30b6
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 22 deletions.
28 changes: 28 additions & 0 deletions drivers/misc/mei/hw-me.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,33 @@ static inline void mei_hcsr_set(struct mei_me_hw *hw, u32 hcsr)
mei_me_reg_write(hw, H_CSR, hcsr);
}

/**
* mei_me_fw_status - read fw status register from pci config space
*
* @dev: mei device
* @fw_status: fw status register values
*/
static int mei_me_fw_status(struct mei_device *dev,
struct mei_fw_status *fw_status)
{
const struct mei_fw_status *fw_src = &dev->cfg->fw_status;
struct pci_dev *pdev = to_pci_dev(dev->dev);
int ret;
int i;

if (!fw_status)
return -EINVAL;

fw_status->count = fw_src->count;
for (i = 0; i < fw_src->count && i < MEI_FW_STATUS_MAX; i++) {
ret = pci_read_config_dword(pdev,
fw_src->status[i], &fw_status->status[i]);
if (ret)
return ret;
}

return 0;
}

/**
* mei_me_hw_config - configure hw dependent settings
Expand Down Expand Up @@ -714,6 +741,7 @@ irqreturn_t mei_me_irq_thread_handler(int irq, void *dev_id)

static const struct mei_hw_ops mei_me_hw_ops = {

.fw_status = mei_me_fw_status,
.pg_state = mei_me_pg_state,

.host_is_ready = mei_me_host_is_ready,
Expand Down
30 changes: 30 additions & 0 deletions drivers/misc/mei/hw-txe.c
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,35 @@ static int mei_txe_readiness_wait(struct mei_device *dev)
return 0;
}


/**
* mei_txe_fw_status - read fw status register from pci config space
*
* @dev: mei device
* @fw_status: fw status register values
*/
static int mei_txe_fw_status(struct mei_device *dev,
struct mei_fw_status *fw_status)
{
const struct mei_fw_status *fw_src = &dev->cfg->fw_status;
struct pci_dev *pdev = to_pci_dev(dev->dev);
int ret;
int i;

if (!fw_status)
return -EINVAL;

fw_status->count = fw_src->count;
for (i = 0; i < fw_src->count && i < MEI_FW_STATUS_MAX; i++) {
ret = pci_read_config_dword(pdev,
fw_src->status[i], &fw_status->status[i]);
if (ret)
return ret;
}

return 0;
}

/**
* mei_txe_hw_config - configure hardware at the start of the devices
*
Expand Down Expand Up @@ -1064,6 +1093,7 @@ static const struct mei_hw_ops mei_txe_hw_ops = {

.host_is_ready = mei_txe_host_is_ready,

.fw_status = mei_txe_fw_status,
.pg_state = mei_txe_pg_state,

.hw_is_ready = mei_txe_hw_is_ready,
Expand Down
21 changes: 0 additions & 21 deletions drivers/misc/mei/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,27 +344,6 @@ bool mei_write_is_idle(struct mei_device *dev)
}
EXPORT_SYMBOL_GPL(mei_write_is_idle);

int mei_fw_status(struct mei_device *dev, struct mei_fw_status *fw_status)
{
const struct mei_fw_status *fw_src = &dev->cfg->fw_status;
int ret;
int i;

if (!fw_status)
return -EINVAL;

fw_status->count = fw_src->count;
for (i = 0; i < fw_src->count && i < MEI_FW_STATUS_MAX; i++) {
ret = pci_read_config_dword(dev->pdev,
fw_src->status[i], &fw_status->status[i]);
if (ret)
return ret;
}

return 0;
}
EXPORT_SYMBOL_GPL(mei_fw_status);

/**
* mei_device_init -- initialize mei_device structure
*
Expand Down
9 changes: 8 additions & 1 deletion drivers/misc/mei/mei_dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ struct mei_cl {
* @hw_start - start hw after reset
* @hw_config - configure hw
* @fw_status - get fw status registers
* @pg_state - power gating state of the device
* @pg_is_enabled - is power gating enabled
Expand Down Expand Up @@ -260,6 +261,8 @@ struct mei_hw_ops {
int (*hw_start)(struct mei_device *dev);
void (*hw_config)(struct mei_device *dev);


int (*fw_status)(struct mei_device *dev, struct mei_fw_status *fw_sts);
enum mei_pg_state (*pg_state)(struct mei_device *dev);
bool (*pg_is_enabled)(struct mei_device *dev);

Expand Down Expand Up @@ -731,7 +734,11 @@ static inline int mei_count_full_read_slots(struct mei_device *dev)
return dev->ops->rdbuf_full_slots(dev);
}

int mei_fw_status(struct mei_device *dev, struct mei_fw_status *fw_status);
static inline int mei_fw_status(struct mei_device *dev,
struct mei_fw_status *fw_status)
{
return dev->ops->fw_status(dev, fw_status);
}

#define FW_STS_FMT "%08X %08X"
#define FW_STS_PRM(fw_status) \
Expand Down

0 comments on commit 1bd30b6

Please sign in to comment.