tpm_tis_spi.h 1.2 KB

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