Lines Matching +full:st33zp24 +full:- +full:spi
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * STMicroelectronics TPM SPI Linux driver for TPM ST33ZP24
4 * Copyright (C) 2009 - 2016 STMicroelectronics
8 #include <linux/spi/spi.h>
14 #include "st33zp24.h"
42 * usually on st33zp24 2 are enough).
77 return -EPROTO; in st33zp24_status_to_errno()
80 return -EMSGSIZE; in st33zp24_status_to_errno()
82 return -ENOSYS; in st33zp24_status_to_errno()
89 * Send byte to the TIS register according to the ST33ZP24 SPI protocol.
101 struct spi_device *dev = phy->spi_device; in st33zp24_spi_send()
103 .tx_buf = phy->tx_buf, in st33zp24_spi_send()
104 .rx_buf = phy->rx_buf, in st33zp24_spi_send()
107 /* Pre-Header */ in st33zp24_spi_send()
108 phy->tx_buf[total_length++] = TPM_WRITE_DIRECTION | LOCALITY0; in st33zp24_spi_send()
109 phy->tx_buf[total_length++] = tpm_register; in st33zp24_spi_send()
112 phy->tx_buf[total_length++] = tpm_size >> 8; in st33zp24_spi_send()
113 phy->tx_buf[total_length++] = tpm_size; in st33zp24_spi_send()
116 memcpy(&phy->tx_buf[total_length], tpm_data, tpm_size); in st33zp24_spi_send()
119 memset(&phy->tx_buf[total_length], TPM_DUMMY_BYTE, phy->latency); in st33zp24_spi_send()
121 spi_xfer.len = total_length + phy->latency; in st33zp24_spi_send()
125 ret = phy->rx_buf[total_length + phy->latency - 1]; in st33zp24_spi_send()
132 * Recv byte from the TIS register according to the ST33ZP24 SPI protocol.
144 struct spi_device *dev = phy->spi_device; in st33zp24_spi_read8_reg()
146 .tx_buf = phy->tx_buf, in st33zp24_spi_read8_reg()
147 .rx_buf = phy->rx_buf, in st33zp24_spi_read8_reg()
150 /* Pre-Header */ in st33zp24_spi_read8_reg()
151 phy->tx_buf[total_length++] = LOCALITY0; in st33zp24_spi_read8_reg()
152 phy->tx_buf[total_length++] = tpm_register; in st33zp24_spi_read8_reg()
154 memset(&phy->tx_buf[total_length], TPM_DUMMY_BYTE, in st33zp24_spi_read8_reg()
155 phy->latency + tpm_size); in st33zp24_spi_read8_reg()
157 spi_xfer.len = total_length + phy->latency + tpm_size; in st33zp24_spi_read8_reg()
162 ret = phy->rx_buf[total_length + phy->latency - 1]; in st33zp24_spi_read8_reg()
164 memcpy(tpm_data, phy->rx_buf + total_length + phy->latency, in st33zp24_spi_read8_reg()
173 * Recv byte from the TIS register according to the ST33ZP24 SPI protocol.
198 phy->latency = latency; in st33zp24_spi_evaluate_latency()
206 return -ENODEV; in st33zp24_spi_evaluate_latency()
208 return latency - 1; in st33zp24_spi_evaluate_latency()
218 * @param: dev, the spi_device description (TPM SPI description).
226 phy = devm_kzalloc(&dev->dev, sizeof(struct st33zp24_spi_phy), in st33zp24_spi_probe()
229 return -ENOMEM; in st33zp24_spi_probe()
231 phy->spi_device = dev; in st33zp24_spi_probe()
233 phy->latency = st33zp24_spi_evaluate_latency(phy); in st33zp24_spi_probe()
234 if (phy->latency <= 0) in st33zp24_spi_probe()
235 return -ENODEV; in st33zp24_spi_probe()
237 return st33zp24_probe(phy, &spi_phy_ops, &dev->dev, dev->irq); in st33zp24_spi_probe()
242 * @param: client, the spi_device description (TPM SPI description).
256 MODULE_DEVICE_TABLE(spi, st33zp24_spi_id);
259 { .compatible = "st,st33zp24-spi", },
275 .name = "st33zp24-spi",
288 MODULE_DESCRIPTION("STM TPM 1.2 SPI ST33 Driver");