Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8d929d48 authored by Alexander Usyskin's avatar Alexander Usyskin Committed by Greg Kroah-Hartman
Browse files

mei: add per device configuration



Add mei_cfg structure that holds per device configuration
data and hooks, as the first step we add firmware
status register offsets

Signed-off-by: default avatarAlexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c40765d9
Loading
Loading
Loading
Loading
+32 −2
Original line number Original line Diff line number Diff line
@@ -792,14 +792,44 @@ static const struct mei_hw_ops mei_me_hw_ops = {
	.read = mei_me_read_slots
	.read = mei_me_read_slots
};
};


#define MEI_CFG_LEGACY_HFS                      \
	.fw_status.count = 0

#define MEI_CFG_ICH_HFS                        \
	.fw_status.count = 1,                   \
	.fw_status.status[0] = PCI_CFG_HFS_1

#define MEI_CFG_PCH_HFS                         \
	.fw_status.count = 2,                   \
	.fw_status.status[0] = PCI_CFG_HFS_1,   \
	.fw_status.status[1] = PCI_CFG_HFS_2


/* ICH Legacy devices */
const struct mei_cfg mei_me_legacy_cfg = {
	MEI_CFG_LEGACY_HFS,
};

/* ICH devices */
const struct mei_cfg mei_me_ich_cfg = {
	MEI_CFG_ICH_HFS,
};

/* PCH devices */
const struct mei_cfg mei_me_pch_cfg = {
	MEI_CFG_PCH_HFS,
};

/**
/**
 * mei_me_dev_init - allocates and initializes the mei device structure
 * mei_me_dev_init - allocates and initializes the mei device structure
 *
 *
 * @pdev: The pci device structure
 * @pdev: The pci device structure
 * @cfg: per device generation config
 *
 *
 * returns The mei_device_device pointer on success, NULL on failure.
 * returns The mei_device_device pointer on success, NULL on failure.
 */
 */
struct mei_device *mei_me_dev_init(struct pci_dev *pdev)
struct mei_device *mei_me_dev_init(struct pci_dev *pdev,
				   const struct mei_cfg *cfg)
{
{
	struct mei_device *dev;
	struct mei_device *dev;


@@ -808,7 +838,7 @@ struct mei_device *mei_me_dev_init(struct pci_dev *pdev)
	if (!dev)
	if (!dev)
		return NULL;
		return NULL;


	mei_device_init(dev);
	mei_device_init(dev, cfg);


	dev->ops = &mei_me_hw_ops;
	dev->ops = &mei_me_hw_ops;


+6 −1
Original line number Original line Diff line number Diff line
@@ -38,7 +38,12 @@ struct mei_me_hw {


#define to_me_hw(dev) (struct mei_me_hw *)((dev)->hw)
#define to_me_hw(dev) (struct mei_me_hw *)((dev)->hw)


struct mei_device *mei_me_dev_init(struct pci_dev *pdev);
extern const struct mei_cfg mei_me_legacy_cfg;
extern const struct mei_cfg mei_me_ich_cfg;
extern const struct mei_cfg mei_me_pch_cfg;

struct mei_device *mei_me_dev_init(struct pci_dev *pdev,
				   const struct mei_cfg *cfg);


int mei_me_pg_set_sync(struct mei_device *dev);
int mei_me_pg_set_sync(struct mei_device *dev);
int mei_me_pg_unset_sync(struct mei_device *dev);
int mei_me_pg_unset_sync(struct mei_device *dev);
+15 −2
Original line number Original line Diff line number Diff line
@@ -1104,14 +1104,27 @@ static const struct mei_hw_ops mei_txe_hw_ops = {


};
};


#define MEI_CFG_TXE_FW_STS                            \
	.fw_status.count = 2,                         \
	.fw_status.status[0] = PCI_CFG_TXE_FW_STS0,   \
	.fw_status.status[1] = PCI_CFG_TXE_FW_STS1

const struct mei_cfg mei_txe_cfg = {
	MEI_CFG_TXE_FW_STS,
};


/**
/**
 * mei_txe_dev_init - allocates and initializes txe hardware specific structure
 * mei_txe_dev_init - allocates and initializes txe hardware specific structure
 *
 *
 * @pdev - pci device
 * @pdev - pci device
 * @cfg - per device generation config
 *
 * returns struct mei_device * on success or NULL;
 * returns struct mei_device * on success or NULL;
 *
 *
 */
 */
struct mei_device *mei_txe_dev_init(struct pci_dev *pdev)
struct mei_device *mei_txe_dev_init(struct pci_dev *pdev,
				    const struct mei_cfg *cfg)
{
{
	struct mei_device *dev;
	struct mei_device *dev;
	struct mei_txe_hw *hw;
	struct mei_txe_hw *hw;
@@ -1121,7 +1134,7 @@ struct mei_device *mei_txe_dev_init(struct pci_dev *pdev)
	if (!dev)
	if (!dev)
		return NULL;
		return NULL;


	mei_device_init(dev);
	mei_device_init(dev, cfg);


	hw = to_txe_hw(dev);
	hw = to_txe_hw(dev);


+4 −1
Original line number Original line Diff line number Diff line
@@ -61,7 +61,10 @@ static inline struct mei_device *hw_txe_to_mei(struct mei_txe_hw *hw)
	return container_of((void *)hw, struct mei_device, hw);
	return container_of((void *)hw, struct mei_device, hw);
}
}


struct mei_device *mei_txe_dev_init(struct pci_dev *pdev);
extern const struct mei_cfg mei_txe_cfg;

struct mei_device *mei_txe_dev_init(struct pci_dev *pdev,
	const struct mei_cfg *cfg);


irqreturn_t mei_txe_irq_quick_handler(int irq, void *dev_id);
irqreturn_t mei_txe_irq_quick_handler(int irq, void *dev_id);
irqreturn_t mei_txe_irq_thread_handler(int irq, void *dev_id);
irqreturn_t mei_txe_irq_thread_handler(int irq, void *dev_id);
+23 −1
Original line number Original line Diff line number Diff line
@@ -330,7 +330,28 @@ bool mei_write_is_idle(struct mei_device *dev)
}
}
EXPORT_SYMBOL_GPL(mei_write_is_idle);
EXPORT_SYMBOL_GPL(mei_write_is_idle);


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

	if (!fw_status)
		return -EINVAL;

	fw_status->count = fw_src->count;
	for (i = 0; i < fw_src->count && i < MEI_FW_STATUS_MAX; i++) {
		int ret;
		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);

void mei_device_init(struct mei_device *dev, const struct mei_cfg *cfg)
{
{
	/* setup our list array */
	/* setup our list array */
	INIT_LIST_HEAD(&dev->file_list);
	INIT_LIST_HEAD(&dev->file_list);
@@ -368,6 +389,7 @@ void mei_device_init(struct mei_device *dev)
	bitmap_set(dev->host_clients_map, 0, 1);
	bitmap_set(dev->host_clients_map, 0, 1);


	dev->pg_event = MEI_PG_EVENT_IDLE;
	dev->pg_event = MEI_PG_EVENT_IDLE;
	dev->cfg      = cfg;
}
}
EXPORT_SYMBOL_GPL(mei_device_init);
EXPORT_SYMBOL_GPL(mei_device_init);
Loading