linux/drivers/char/tpm/tpm_i2c_infineon.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (C) 2012,2013 Infineon Technologies
 *
 * Authors:
 * Peter Huewe <[email protected]>
 *
 * Device driver for TCG/TCPA TPM (trusted platform module).
 * Specifications at www.trustedcomputinggroup.org
 *
 * This device driver implements the TPM interface as defined in
 * the TCG TPM Interface Spec version 1.2, revision 1.0 and the
 * Infineon I2C Protocol Stack Specification v0.20.
 *
 * It is based on the original tpm_tis device driver from Leendert van
 * Dorn and Kyleen Hall.
 */
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/wait.h>
#include "tpm.h"

#define TPM_I2C_INFINEON_BUFSIZE

/* max. number of iterations after I2C NAK */
#define MAX_COUNT

#define SLEEP_DURATION_LOW
#define SLEEP_DURATION_HI

/* max. number of iterations after I2C NAK for 'long' commands
 * we need this especially for sending TPM_READY, since the cleanup after the
 * transtion to the ready state may take some time, but it is unpredictable
 * how long it will take.
 */
#define MAX_COUNT_LONG

#define SLEEP_DURATION_LONG_LOW
#define SLEEP_DURATION_LONG_HI

/* After sending TPM_READY to 'reset' the TPM we have to sleep even longer */
#define SLEEP_DURATION_RESET_LOW
#define SLEEP_DURATION_RESET_HI

/* we want to use usleep_range instead of msleep for the 5ms TPM_TIMEOUT */
#define TPM_TIMEOUT_US_LOW
#define TPM_TIMEOUT_US_HI

/* expected value for DIDVID register */
#define TPM_TIS_I2C_DID_VID_9635
#define TPM_TIS_I2C_DID_VID_9645

enum i2c_chip_type {};

struct tpm_inf_dev {};

static struct tpm_inf_dev tpm_dev;

/*
 * iic_tpm_read() - read from TPM register
 * @addr: register address to read from
 * @buffer: provided by caller
 * @len: number of bytes to read
 *
 * Read len bytes from TPM register and put them into
 * buffer (little-endian format, i.e. first byte is put into buffer[0]).
 *
 * NOTE: TPM is big-endian for multi-byte values. Multi-byte
 * values have to be swapped.
 *
 * NOTE: We can't unfortunately use the combined read/write functions
 * provided by the i2c core as the TPM currently does not support the
 * repeated start condition and due to it's special requirements.
 * The i2c_smbus* functions do not work for this chip.
 *
 * Return -EIO on error, 0 on success.
 */
static int iic_tpm_read(u8 addr, u8 *buffer, size_t len)
{}

static int iic_tpm_write_generic(u8 addr, u8 *buffer, size_t len,
				 unsigned int sleep_low,
				 unsigned int sleep_hi, u8 max_count)
{}

/*
 * iic_tpm_write() - write to TPM register
 * @addr: register address to write to
 * @buffer: containing data to be written
 * @len: number of bytes to write
 *
 * Write len bytes from provided buffer to TPM register (little
 * endian format, i.e. buffer[0] is written as first byte).
 *
 * NOTE: TPM is big-endian for multi-byte values. Multi-byte
 * values have to be swapped.
 *
 * NOTE: use this function instead of the iic_tpm_write_generic function.
 *
 * Return -EIO on error, 0 on success
 */
static int iic_tpm_write(u8 addr, u8 *buffer, size_t len)
{}

/*
 * This function is needed especially for the cleanup situation after
 * sending TPM_READY
 * */
static int iic_tpm_write_long(u8 addr, u8 *buffer, size_t len)
{}

enum tis_access {};

enum tis_status {};

enum tis_defaults {};

#define TPM_ACCESS(l)
#define TPM_STS(l)
#define TPM_DATA_FIFO(l)
#define TPM_DID_VID(l)

static bool check_locality(struct tpm_chip *chip, int loc)
{}

/* implementation similar to tpm_tis */
static void release_locality(struct tpm_chip *chip, int loc, int force)
{}

static int request_locality(struct tpm_chip *chip, int loc)
{}

static u8 tpm_tis_i2c_status(struct tpm_chip *chip)
{}

static void tpm_tis_i2c_ready(struct tpm_chip *chip)
{}

static ssize_t get_burstcount(struct tpm_chip *chip)
{}

static int wait_for_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout,
			 int *status)
{}

static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
{}

static int tpm_tis_i2c_recv(struct tpm_chip *chip, u8 *buf, size_t count)
{}

static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)
{}

static bool tpm_tis_i2c_req_canceled(struct tpm_chip *chip, u8 status)
{}

static const struct tpm_class_ops tpm_tis_i2c =;

static int tpm_tis_i2c_init(struct device *dev)
{}

static const struct i2c_device_id tpm_tis_i2c_table[] =;

MODULE_DEVICE_TABLE(i2c, tpm_tis_i2c_table);

#ifdef CONFIG_OF
static const struct of_device_id tpm_tis_i2c_of_match[] =;
MODULE_DEVICE_TABLE(of, tpm_tis_i2c_of_match);
#endif

static SIMPLE_DEV_PM_OPS(tpm_tis_i2c_ops, tpm_pm_suspend, tpm_pm_resume);

static int tpm_tis_i2c_probe(struct i2c_client *client)
{}

static void tpm_tis_i2c_remove(struct i2c_client *client)
{}

static struct i2c_driver tpm_tis_i2c_driver =;

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