Lines Matching +full:m +full:- +full:phy
1 // SPDX-License-Identifier: GPL-2.0-only
8 * Christophe Ricard <christophe-h.ricard@st.com>
10 * Maintained by: <tpmdd-devel@lists.sourceforge.net>
46 * [1] https://trustedcomputinggroup.org/resource/pc-client-platform-tpm-profile-ptp-specification/
48 static int tpm_tis_spi_flow_control(struct tpm_tis_spi_phy *phy, in tpm_tis_spi_flow_control() argument
51 struct spi_message m; in tpm_tis_spi_flow_control() local
54 if ((phy->iobuf[3] & 0x01) == 0) { in tpm_tis_spi_flow_control()
57 spi_xfer->len = 1; in tpm_tis_spi_flow_control()
58 spi_message_init(&m); in tpm_tis_spi_flow_control()
59 spi_message_add_tail(spi_xfer, &m); in tpm_tis_spi_flow_control()
60 ret = spi_sync_locked(phy->spi_device, &m); in tpm_tis_spi_flow_control()
63 if (phy->iobuf[0] & 0x01) in tpm_tis_spi_flow_control()
68 return -ETIMEDOUT; in tpm_tis_spi_flow_control()
77 struct tpm_tis_spi_phy *phy = to_tpm_tis_spi_phy(data); in tpm_tis_spi_transfer() local
79 struct spi_message m; in tpm_tis_spi_transfer() local
83 spi_bus_lock(phy->spi_device->master); in tpm_tis_spi_transfer()
88 phy->iobuf[0] = (in ? 0x80 : 0) | (transfer_len - 1); in tpm_tis_spi_transfer()
89 phy->iobuf[1] = 0xd4; in tpm_tis_spi_transfer()
90 phy->iobuf[2] = addr >> 8; in tpm_tis_spi_transfer()
91 phy->iobuf[3] = addr; in tpm_tis_spi_transfer()
94 spi_xfer.tx_buf = phy->iobuf; in tpm_tis_spi_transfer()
95 spi_xfer.rx_buf = phy->iobuf; in tpm_tis_spi_transfer()
99 spi_message_init(&m); in tpm_tis_spi_transfer()
100 spi_message_add_tail(&spi_xfer, &m); in tpm_tis_spi_transfer()
101 ret = spi_sync_locked(phy->spi_device, &m); in tpm_tis_spi_transfer()
107 ret = phy->flow_control(phy, &spi_xfer); in tpm_tis_spi_transfer()
117 spi_xfer.tx_buf = phy->iobuf; in tpm_tis_spi_transfer()
119 memcpy(phy->iobuf, out, transfer_len); in tpm_tis_spi_transfer()
123 spi_message_init(&m); in tpm_tis_spi_transfer()
124 spi_message_add_tail(&spi_xfer, &m); in tpm_tis_spi_transfer()
125 reinit_completion(&phy->ready); in tpm_tis_spi_transfer()
126 ret = spi_sync_locked(phy->spi_device, &m); in tpm_tis_spi_transfer()
131 memcpy(in, phy->iobuf, transfer_len); in tpm_tis_spi_transfer()
135 len -= transfer_len; in tpm_tis_spi_transfer()
139 spi_bus_unlock(phy->spi_device->master); in tpm_tis_spi_transfer()
160 rc = data->phy_ops->read_bytes(data, addr, sizeof(u16), in tpm_tis_spi_read16()
173 rc = data->phy_ops->read_bytes(data, addr, sizeof(u32), in tpm_tis_spi_read32()
187 rc = data->phy_ops->write_bytes(data, addr, sizeof(u32), in tpm_tis_spi_write32()
193 int tpm_tis_spi_init(struct spi_device *spi, struct tpm_tis_spi_phy *phy, in tpm_tis_spi_init() argument
196 phy->iobuf = devm_kmalloc(&spi->dev, MAX_SPI_FRAMESIZE, GFP_KERNEL); in tpm_tis_spi_init()
197 if (!phy->iobuf) in tpm_tis_spi_init()
198 return -ENOMEM; in tpm_tis_spi_init()
200 phy->spi_device = spi; in tpm_tis_spi_init()
202 return tpm_tis_core_init(&spi->dev, &phy->priv, irq, phy_ops, NULL); in tpm_tis_spi_init()
215 struct tpm_tis_spi_phy *phy; in tpm_tis_spi_probe() local
218 phy = devm_kzalloc(&dev->dev, sizeof(struct tpm_tis_spi_phy), in tpm_tis_spi_probe()
220 if (!phy) in tpm_tis_spi_probe()
221 return -ENOMEM; in tpm_tis_spi_probe()
223 phy->flow_control = tpm_tis_spi_flow_control; in tpm_tis_spi_probe()
226 if (dev->irq > 0) in tpm_tis_spi_probe()
227 irq = dev->irq; in tpm_tis_spi_probe()
229 irq = -1; in tpm_tis_spi_probe()
231 init_completion(&phy->ready); in tpm_tis_spi_probe()
232 return tpm_tis_spi_init(dev, phy, irq, &tpm_spi_phy_ops); in tpm_tis_spi_probe()
242 probe_func = of_device_get_match_data(&spi->dev); in tpm_tis_spi_driver_probe()
244 probe_func = (tpm_tis_spi_probe_func)spi_dev_id->driver_data; in tpm_tis_spi_driver_probe()
246 return -ENODEV; in tpm_tis_spi_driver_probe()
270 { .compatible = "st,st33htpm-spi", .data = tpm_tis_spi_probe },
272 { .compatible = "tcg,tpm_tis-spi", .data = tpm_tis_spi_probe },