linux/drivers/char/tpm/st33zp24/spi.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * STMicroelectronics TPM SPI Linux driver for TPM ST33ZP24
 * Copyright (C) 2009 - 2016 STMicroelectronics
 */

#include <linux/module.h>
#include <linux/spi/spi.h>
#include <linux/of.h>
#include <linux/acpi.h>
#include <linux/tpm.h>

#include "../tpm.h"
#include "st33zp24.h"

#define TPM_DATA_FIFO
#define TPM_INTF_CAPABILITY

#define TPM_DUMMY_BYTE

#define MAX_SPI_LATENCY
#define LOCALITY0

#define ST33ZP24_OK
#define ST33ZP24_UNDEFINED_ERR
#define ST33ZP24_BADLOCALITY
#define ST33ZP24_TISREGISTER_UNKNOWN
#define ST33ZP24_LOCALITY_NOT_ACTIVATED
#define ST33ZP24_HASH_END_BEFORE_HASH_START
#define ST33ZP24_BAD_COMMAND_ORDER
#define ST33ZP24_INCORECT_RECEIVED_LENGTH
#define ST33ZP24_TPM_FIFO_OVERFLOW
#define ST33ZP24_UNEXPECTED_READ_FIFO
#define ST33ZP24_UNEXPECTED_WRITE_FIFO
#define ST33ZP24_CMDRDY_SET_WHEN_PROCESSING_HASH_END
#define ST33ZP24_DUMMY_BYTES

/*
 * TPM command can be up to 2048 byte, A TPM response can be up to
 * 1024 byte.
 * Between command and response, there are latency byte (up to 15
 * usually on st33zp24 2 are enough).
 *
 * Overall when sending a command and expecting an answer we need if
 * worst case:
 * 2048 (for the TPM command) + 1024 (for the TPM answer).  We need
 * some latency byte before the answer is available (max 15).
 * We have 2048 + 1024 + 15.
 */
#define ST33ZP24_SPI_BUFFER_SIZE


struct st33zp24_spi_phy {};

static int st33zp24_status_to_errno(u8 code)
{}

/*
 * st33zp24_spi_send
 * Send byte to the TIS register according to the ST33ZP24 SPI protocol.
 * @param: phy_id, the phy description
 * @param: tpm_register, the tpm tis register where the data should be written
 * @param: tpm_data, the tpm_data to write inside the tpm_register
 * @param: tpm_size, The length of the data
 * @return: should be zero if success else a negative error code.
 */
static int st33zp24_spi_send(void *phy_id, u8 tpm_register, u8 *tpm_data,
			     int tpm_size)
{} /* st33zp24_spi_send() */

/*
 * st33zp24_spi_read8_recv
 * Recv byte from the TIS register according to the ST33ZP24 SPI protocol.
 * @param: phy_id, the phy description
 * @param: tpm_register, the tpm tis register where the data should be read
 * @param: tpm_data, the TPM response
 * @param: tpm_size, tpm TPM response size to read.
 * @return: should be zero if success else a negative error code.
 */
static int st33zp24_spi_read8_reg(void *phy_id, u8 tpm_register, u8 *tpm_data,
				  int tpm_size)
{} /* st33zp24_spi_read8_reg() */

/*
 * st33zp24_spi_recv
 * Recv byte from the TIS register according to the ST33ZP24 SPI protocol.
 * @param: phy_id, the phy description
 * @param: tpm_register, the tpm tis register where the data should be read
 * @param: tpm_data, the TPM response
 * @param: tpm_size, tpm TPM response size to read.
 * @return: number of byte read successfully: should be one if success.
 */
static int st33zp24_spi_recv(void *phy_id, u8 tpm_register, u8 *tpm_data,
			     int tpm_size)
{} /* st33zp24_spi_recv() */

static int st33zp24_spi_evaluate_latency(void *phy_id)
{} /* evaluate_latency() */

static const struct st33zp24_phy_ops spi_phy_ops =;

/*
 * st33zp24_spi_probe initialize the TPM device
 * @param: dev, the spi_device description (TPM SPI description).
 * @return: 0 in case of success.
 *	 or a negative value describing the error.
 */
static int st33zp24_spi_probe(struct spi_device *dev)
{}

/*
 * st33zp24_spi_remove remove the TPM device
 * @param: client, the spi_device description (TPM SPI description).
 * @return: 0 in case of success.
 */
static void st33zp24_spi_remove(struct spi_device *dev)
{}

static const struct spi_device_id st33zp24_spi_id[] =;
MODULE_DEVICE_TABLE(spi, st33zp24_spi_id);

static const struct of_device_id of_st33zp24_spi_match[] __maybe_unused =;
MODULE_DEVICE_TABLE(of, of_st33zp24_spi_match);

static const struct acpi_device_id st33zp24_spi_acpi_match[] __maybe_unused =;
MODULE_DEVICE_TABLE(acpi, st33zp24_spi_acpi_match);

static SIMPLE_DEV_PM_OPS(st33zp24_spi_ops, st33zp24_pm_suspend,
			 st33zp24_pm_resume);

static struct spi_driver st33zp24_spi_driver =;

module_spi_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_VERSION();
MODULE_LICENSE();