// SPDX-License-Identifier: GPL-2.0-or-later /* * STMicroelectronics TPM I2C Linux driver for TPM ST33ZP24 * Copyright (C) 2009 - 2016 STMicroelectronics */ #include <linux/module.h> #include <linux/i2c.h> #include <linux/of.h> #include <linux/acpi.h> #include <linux/tpm.h> #include "../tpm.h" #include "st33zp24.h" #define TPM_DUMMY_BYTE … struct st33zp24_i2c_phy { … }; /* * write8_reg * Send byte to the TIS register according to the ST33ZP24 I2C protocol. * @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: Returns negative errno, or else the number of bytes written. */ static int write8_reg(void *phy_id, u8 tpm_register, u8 *tpm_data, int tpm_size) { … } /* write8_reg() */ /* * read8_reg * Recv byte from the TIS register according to the ST33ZP24 I2C protocol. * @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 read8_reg(void *phy_id, u8 tpm_register, u8 *tpm_data, int tpm_size) { … } /* read8_reg() */ /* * st33zp24_i2c_send * Send byte to the TIS register according to the ST33ZP24 I2C 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: number of byte written successfully: should be one if success. */ static int st33zp24_i2c_send(void *phy_id, u8 tpm_register, u8 *tpm_data, int tpm_size) { … } /* * st33zp24_i2c_recv * Recv byte from the TIS register according to the ST33ZP24 I2C 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_i2c_recv(void *phy_id, u8 tpm_register, u8 *tpm_data, int tpm_size) { … } static const struct st33zp24_phy_ops i2c_phy_ops = …; /* * st33zp24_i2c_probe initialize the TPM device * @param: client, the i2c_client description (TPM I2C description). * @param: id, the i2c_device_id struct. * @return: 0 in case of success. * -1 in other case. */ static int st33zp24_i2c_probe(struct i2c_client *client) { … } /* * st33zp24_i2c_remove remove the TPM device * @param: client, the i2c_client description (TPM I2C description). * @return: 0 in case of success. */ static void st33zp24_i2c_remove(struct i2c_client *client) { … } static const struct i2c_device_id st33zp24_i2c_id[] = …; MODULE_DEVICE_TABLE(i2c, st33zp24_i2c_id); static const struct of_device_id of_st33zp24_i2c_match[] __maybe_unused = …; MODULE_DEVICE_TABLE(of, of_st33zp24_i2c_match); static const struct acpi_device_id st33zp24_i2c_acpi_match[] __maybe_unused = …; MODULE_DEVICE_TABLE(acpi, st33zp24_i2c_acpi_match); static SIMPLE_DEV_PM_OPS(st33zp24_i2c_ops, st33zp24_pm_suspend, st33zp24_pm_resume); static struct i2c_driver st33zp24_i2c_driver = …; module_i2c_driver(…) …; MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…) …; MODULE_VERSION(…) …; MODULE_LICENSE(…) …;