linux/drivers/char/tpm/tpm_i2c_nuvoton.c

// SPDX-License-Identifier: GPL-2.0-or-later
 /******************************************************************************
 * Nuvoton TPM I2C Device Driver Interface for WPCT301/NPCT501/NPCT6XX,
 * based on the TCG TPM Interface Spec version 1.2.
 * Specifications at www.trustedcomputinggroup.org
 *
 * Copyright (C) 2011, Nuvoton Technology Corporation.
 *  Dan Morav <[email protected]>
 * Copyright (C) 2013, Obsidian Research Corp.
 *  Jason Gunthorpe <[email protected]>
 *
 * Nuvoton contact information: [email protected]
 *****************************************************************************/

#include <linux/init.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
#include <linux/wait.h>
#include <linux/i2c.h>
#include <linux/of.h>
#include <linux/property.h>
#include "tpm.h"

/* I2C interface offsets */
#define TPM_STS
#define TPM_BURST_COUNT
#define TPM_DATA_FIFO_W
#define TPM_DATA_FIFO_R
#define TPM_VID_DID_RID
#define TPM_I2C_RETRIES
/*
 * I2C bus device maximum buffer size w/o counting I2C address or command
 * i.e. max size required for I2C write is 34 = addr, command, 32 bytes data
 */
#define TPM_I2C_MAX_BUF_SIZE
#define TPM_I2C_RETRY_COUNT
#define TPM_I2C_BUS_DELAY
#define TPM_I2C_RETRY_DELAY_SHORT
#define TPM_I2C_RETRY_DELAY_LONG
#define TPM_I2C_DELAY_RANGE

#define OF_IS_TPM2
#define I2C_IS_TPM2

struct priv_data {};

static s32 i2c_nuvoton_read_buf(struct i2c_client *client, u8 offset, u8 size,
				u8 *data)
{}

static s32 i2c_nuvoton_write_buf(struct i2c_client *client, u8 offset, u8 size,
				 u8 *data)
{}

#define TPM_STS_VALID
#define TPM_STS_COMMAND_READY
#define TPM_STS_GO
#define TPM_STS_DATA_AVAIL
#define TPM_STS_EXPECT
#define TPM_STS_RESPONSE_RETRY
#define TPM_STS_ERR_VAL

#define TPM_I2C_SHORT_TIMEOUT
#define TPM_I2C_LONG_TIMEOUT

/* read TPM_STS register */
static u8 i2c_nuvoton_read_status(struct tpm_chip *chip)
{}

/* write byte to TPM_STS register */
static s32 i2c_nuvoton_write_status(struct i2c_client *client, u8 data)
{}

/* write commandReady to TPM_STS register */
static void i2c_nuvoton_ready(struct tpm_chip *chip)
{}

/* read burstCount field from TPM_STS register
 * return -1 on fail to read */
static int i2c_nuvoton_get_burstcount(struct i2c_client *client,
				      struct tpm_chip *chip)
{}

/*
 * WPCT301/NPCT501/NPCT6XX SINT# supports only dataAvail
 * any call to this function which is not waiting for dataAvail will
 * set queue to NULL to avoid waiting for interrupt
 */
static bool i2c_nuvoton_check_status(struct tpm_chip *chip, u8 mask, u8 value)
{}

static int i2c_nuvoton_wait_for_stat(struct tpm_chip *chip, u8 mask, u8 value,
				     u32 timeout, wait_queue_head_t *queue)
{}

/* wait for dataAvail field to be set in the TPM_STS register */
static int i2c_nuvoton_wait_for_data_avail(struct tpm_chip *chip, u32 timeout,
					   wait_queue_head_t *queue)
{}

/* Read @count bytes into @buf from TPM_RD_FIFO register */
static int i2c_nuvoton_recv_data(struct i2c_client *client,
				 struct tpm_chip *chip, u8 *buf, size_t count)
{}

/* Read TPM command results */
static int i2c_nuvoton_recv(struct tpm_chip *chip, u8 *buf, size_t count)
{}

/*
 * Send TPM command.
 *
 * If interrupts are used (signaled by an irq set in the vendor structure)
 * tpm.c can skip polling for the data to be available as the interrupt is
 * waited for here
 */
static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len)
{}

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

static const struct tpm_class_ops tpm_i2c =;

/* The only purpose for the handler is to signal to any waiting threads that
 * the interrupt is currently being asserted. The driver does not do any
 * processing triggered by interrupts, and the chip provides no way to mask at
 * the source (plus that would be slow over I2C). Run the IRQ as a one-shot,
 * this means it cannot be shared. */
static irqreturn_t i2c_nuvoton_int_handler(int dummy, void *dev_id)
{}

static int get_vid(struct i2c_client *client, u32 *res)
{}

static int i2c_nuvoton_probe(struct i2c_client *client)
{}

static void i2c_nuvoton_remove(struct i2c_client *client)
{}

static const struct i2c_device_id i2c_nuvoton_id[] =;
MODULE_DEVICE_TABLE(i2c, i2c_nuvoton_id);

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

static SIMPLE_DEV_PM_OPS(i2c_nuvoton_pm_ops, tpm_pm_suspend, tpm_pm_resume);

static struct i2c_driver i2c_nuvoton_driver =;

module_i2c_driver();

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