Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / char / tpm / tpm_tis_spi.h
blobbba73979c368707cfd2a3678ce5f60e66500492d
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright (C) 2015 Infineon Technologies AG
4 * Copyright (C) 2016 STMicroelectronics SAS
5 */
7 #ifndef TPM_TIS_SPI_H
8 #define TPM_TIS_SPI_H
10 #include "tpm_tis_core.h"
12 struct tpm_tis_spi_phy {
13 struct tpm_tis_data priv;
14 struct spi_device *spi_device;
15 int (*flow_control)(struct tpm_tis_spi_phy *phy,
16 struct spi_transfer *xfer);
17 struct completion ready;
18 unsigned long wake_after;
20 u8 *iobuf;
23 static inline struct tpm_tis_spi_phy *to_tpm_tis_spi_phy(struct tpm_tis_data *data)
25 return container_of(data, struct tpm_tis_spi_phy, priv);
28 extern int tpm_tis_spi_init(struct spi_device *spi, struct tpm_tis_spi_phy *phy,
29 int irq, const struct tpm_tis_phy_ops *phy_ops);
31 extern int tpm_tis_spi_transfer(struct tpm_tis_data *data, u32 addr, u16 len,
32 u8 *in, const u8 *out);
34 extern int tpm_tis_spi_read16(struct tpm_tis_data *data, u32 addr, u16 *result);
35 extern int tpm_tis_spi_read32(struct tpm_tis_data *data, u32 addr, u32 *result);
36 extern int tpm_tis_spi_write32(struct tpm_tis_data *data, u32 addr, u32 value);
38 #ifdef CONFIG_TCG_TIS_SPI_CR50
39 extern int cr50_spi_probe(struct spi_device *spi);
40 #else
41 static inline int cr50_spi_probe(struct spi_device *spi)
43 return -ENODEV;
45 #endif
47 #if defined(CONFIG_PM_SLEEP) && defined(CONFIG_TCG_TIS_SPI_CR50)
48 extern int tpm_tis_spi_resume(struct device *dev);
49 #else
50 #define tpm_tis_spi_resume NULL
51 #endif
53 #endif