/**
 * tpm_ibmvtpm_resume - Resume from suspend
 * @dev:	device struct
 *
 * Return value:
 *	0
 */
static int tpm_ibmvtpm_resume(struct device *dev)
{
	struct ibmvtpm_dev *ibmvtpm = ibmvtpm_get_data(dev);
	int rc = 0;

	do {
		if (rc)
			msleep(100);
		rc = plpar_hcall_norets(H_ENABLE_CRQ,
					ibmvtpm->vdev->unit_address);
	} while (rc == H_IN_PROGRESS || rc == H_BUSY || H_IS_LONG_BUSY(rc));

	if (rc) {
		dev_err(dev, "Error enabling ibmvtpm rc=%d\n", rc);
		return rc;
	}

	rc = vio_enable_interrupts(ibmvtpm->vdev);
	if (rc) {
		dev_err(dev, "Error vio_enable_interrupts rc=%d\n", rc);
		return rc;
	}

	rc = ibmvtpm_crq_send_init(ibmvtpm);
	if (rc)
		dev_err(dev, "Error send_init rc=%d\n", rc);

	return rc;
}
Beispiel #2
0
/**
 * tpm_ibmvtpm_remove - ibm vtpm remove entry point
 * @vdev:	vio device struct
 *
 * Return value:
 *	0
 */
static int tpm_ibmvtpm_remove(struct vio_dev *vdev)
{
	struct ibmvtpm_dev *ibmvtpm = ibmvtpm_get_data(&vdev->dev);
	int rc = 0;

	free_irq(vdev->irq, ibmvtpm);

	do {
		if (rc)
			msleep(100);
		rc = plpar_hcall_norets(H_FREE_CRQ, vdev->unit_address);
	} while (rc == H_BUSY || H_IS_LONG_BUSY(rc));

	dma_unmap_single(ibmvtpm->dev, ibmvtpm->crq_dma_handle,
			 CRQ_RES_BUF_SIZE, DMA_BIDIRECTIONAL);
	free_page((unsigned long)ibmvtpm->crq_queue.crq_addr);

	if (ibmvtpm->rtce_buf) {
		dma_unmap_single(ibmvtpm->dev, ibmvtpm->rtce_dma_handle,
				 ibmvtpm->rtce_size, DMA_BIDIRECTIONAL);
		kfree(ibmvtpm->rtce_buf);
	}

	tpm_remove_hardware(ibmvtpm->dev);

	kfree(ibmvtpm);

	return 0;
}
/**
 * tpm_ibmvtpm_get_desired_dma - Get DMA size needed by this driver
 * @vdev:	vio device struct
 *
 * Return value:
 *	Number of bytes the driver needs to DMA map
 */
static unsigned long tpm_ibmvtpm_get_desired_dma(struct vio_dev *vdev)
{
	struct ibmvtpm_dev *ibmvtpm = ibmvtpm_get_data(&vdev->dev);

	/* ibmvtpm initializes at probe time, so the data we are
	* asking for may not be set yet. Estimate that 4K required
	* for TCE-mapped buffer in addition to CRQ.
	*/
	if (!ibmvtpm)
		return CRQ_RES_BUF_SIZE + PAGE_SIZE;

	return CRQ_RES_BUF_SIZE + ibmvtpm->rtce_size;
}
Beispiel #4
0
/**
 * tpm_ibmvtpm_suspend - Suspend
 * @dev:	device struct
 *
 * Return value:
 *	0
 */
static int tpm_ibmvtpm_suspend(struct device *dev)
{
	struct ibmvtpm_dev *ibmvtpm = ibmvtpm_get_data(dev);
	struct ibmvtpm_crq crq;
	u64 *buf = (u64 *) &crq;
	int rc = 0;

	crq.valid = (u8)IBMVTPM_VALID_CMD;
	crq.msg = (u8)VTPM_PREPARE_TO_SUSPEND;

	rc = ibmvtpm_send_crq(ibmvtpm->vdev, buf[0], buf[1]);
	if (rc != H_SUCCESS)
		dev_err(ibmvtpm->dev,
			"tpm_ibmvtpm_suspend failed rc=%d\n", rc);

	return rc;
}
Beispiel #5
0
/**
 * tpm_ibmvtpm_get_desired_dma - Get DMA size needed by this driver
 * @vdev:	vio device struct
 *
 * Return value:
 *	Number of bytes the driver needs to DMA map
 */
static unsigned long tpm_ibmvtpm_get_desired_dma(struct vio_dev *vdev)
{
	struct ibmvtpm_dev *ibmvtpm = ibmvtpm_get_data(&vdev->dev);
	return CRQ_RES_BUF_SIZE + ibmvtpm->rtce_size;
}