1*797c0113SAndrey Pronin /* SPDX-License-Identifier: GPL-2.0-only */
2*797c0113SAndrey Pronin /*
3*797c0113SAndrey Pronin * Copyright (C) 2015 Infineon Technologies AG
4*797c0113SAndrey Pronin * Copyright (C) 2016 STMicroelectronics SAS
5*797c0113SAndrey Pronin */
6*797c0113SAndrey Pronin
7*797c0113SAndrey Pronin #ifndef TPM_TIS_SPI_H
8*797c0113SAndrey Pronin #define TPM_TIS_SPI_H
9*797c0113SAndrey Pronin
10*797c0113SAndrey Pronin #include "tpm_tis_core.h"
11*797c0113SAndrey Pronin
12*797c0113SAndrey Pronin struct tpm_tis_spi_phy {
13*797c0113SAndrey Pronin struct tpm_tis_data priv;
14*797c0113SAndrey Pronin struct spi_device *spi_device;
15*797c0113SAndrey Pronin int (*flow_control)(struct tpm_tis_spi_phy *phy,
16*797c0113SAndrey Pronin struct spi_transfer *xfer);
17*797c0113SAndrey Pronin struct completion ready;
18*797c0113SAndrey Pronin unsigned long wake_after;
19*797c0113SAndrey Pronin
20*797c0113SAndrey Pronin u8 *iobuf;
21*797c0113SAndrey Pronin };
22*797c0113SAndrey Pronin
to_tpm_tis_spi_phy(struct tpm_tis_data * data)23*797c0113SAndrey Pronin static inline struct tpm_tis_spi_phy *to_tpm_tis_spi_phy(struct tpm_tis_data *data)
24*797c0113SAndrey Pronin {
25*797c0113SAndrey Pronin return container_of(data, struct tpm_tis_spi_phy, priv);
26*797c0113SAndrey Pronin }
27*797c0113SAndrey Pronin
28*797c0113SAndrey Pronin extern int tpm_tis_spi_init(struct spi_device *spi, struct tpm_tis_spi_phy *phy,
29*797c0113SAndrey Pronin int irq, const struct tpm_tis_phy_ops *phy_ops);
30*797c0113SAndrey Pronin
31*797c0113SAndrey Pronin extern int tpm_tis_spi_transfer(struct tpm_tis_data *data, u32 addr, u16 len,
32*797c0113SAndrey Pronin u8 *in, const u8 *out);
33*797c0113SAndrey Pronin
34*797c0113SAndrey Pronin #ifdef CONFIG_TCG_TIS_SPI_CR50
35*797c0113SAndrey Pronin extern int cr50_spi_probe(struct spi_device *spi);
36*797c0113SAndrey Pronin #else
cr50_spi_probe(struct spi_device * spi)37*797c0113SAndrey Pronin static inline int cr50_spi_probe(struct spi_device *spi)
38*797c0113SAndrey Pronin {
39*797c0113SAndrey Pronin return -ENODEV;
40*797c0113SAndrey Pronin }
41*797c0113SAndrey Pronin #endif
42*797c0113SAndrey Pronin
43*797c0113SAndrey Pronin #if defined(CONFIG_PM_SLEEP) && defined(CONFIG_TCG_TIS_SPI_CR50)
44*797c0113SAndrey Pronin extern int tpm_tis_spi_resume(struct device *dev);
45*797c0113SAndrey Pronin #else
46*797c0113SAndrey Pronin #define tpm_tis_spi_resume NULL
47*797c0113SAndrey Pronin #endif
48*797c0113SAndrey Pronin
49*797c0113SAndrey Pronin #endif
50