• Home
  • Raw
  • Download

Lines Matching +full:phy +full:- +full:i2c

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * STMicroelectronics TPM I2C Linux driver for TPM ST33ZP24
4 * Copyright (C) 2009 - 2016 STMicroelectronics
8 #include <linux/i2c.h>
30 * Send byte to the TIS register according to the ST33ZP24 I2C protocol.
38 struct st33zp24_i2c_phy *phy = phy_id; in write8_reg() local
40 phy->buf[0] = tpm_register; in write8_reg()
41 memcpy(phy->buf + 1, tpm_data, tpm_size); in write8_reg()
42 return i2c_master_send(phy->client, phy->buf, tpm_size + 1); in write8_reg()
47 * Recv byte from the TIS register according to the ST33ZP24 I2C protocol.
55 struct st33zp24_i2c_phy *phy = phy_id; in read8_reg() local
60 status = write8_reg(phy, tpm_register, &data, 1); in read8_reg()
62 status = i2c_master_recv(phy->client, tpm_data, tpm_size); in read8_reg()
68 * Send byte to the TIS register according to the ST33ZP24 I2C protocol.
69 * @param: phy_id, the phy description
84 * Recv byte from the TIS register according to the ST33ZP24 I2C protocol.
85 * @param: phy_id, the phy description
105 { "lpcpd-gpios", &lpcpd_gpios, 1 },
112 struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev); in st33zp24_i2c_acpi_request_resources()
113 struct st33zp24_i2c_phy *phy = tpm_dev->phy_id; in st33zp24_i2c_acpi_request_resources() local
115 struct device *dev = &client->dev; in st33zp24_i2c_acpi_request_resources()
125 dev_err(&client->dev, in st33zp24_i2c_acpi_request_resources()
126 "Failed to retrieve lpcpd-gpios from acpi.\n"); in st33zp24_i2c_acpi_request_resources()
127 phy->io_lpcpd = -1; in st33zp24_i2c_acpi_request_resources()
136 phy->io_lpcpd = desc_to_gpio(gpiod_lpcpd); in st33zp24_i2c_acpi_request_resources()
144 struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev); in st33zp24_i2c_of_request_resources()
145 struct st33zp24_i2c_phy *phy = tpm_dev->phy_id; in st33zp24_i2c_of_request_resources() local
150 pp = client->dev.of_node; in st33zp24_i2c_of_request_resources()
152 dev_err(&client->dev, "No platform data\n"); in st33zp24_i2c_of_request_resources()
153 return -ENODEV; in st33zp24_i2c_of_request_resources()
157 gpio = of_get_named_gpio(pp, "lpcpd-gpios", 0); in st33zp24_i2c_of_request_resources()
159 dev_err(&client->dev, in st33zp24_i2c_of_request_resources()
160 "Failed to retrieve lpcpd-gpios from dts.\n"); in st33zp24_i2c_of_request_resources()
161 phy->io_lpcpd = -1; in st33zp24_i2c_of_request_resources()
170 ret = devm_gpio_request_one(&client->dev, gpio, in st33zp24_i2c_of_request_resources()
173 dev_err(&client->dev, "Failed to request lpcpd pin\n"); in st33zp24_i2c_of_request_resources()
174 return -ENODEV; in st33zp24_i2c_of_request_resources()
176 phy->io_lpcpd = gpio; in st33zp24_i2c_of_request_resources()
184 struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev); in st33zp24_i2c_request_resources()
185 struct st33zp24_i2c_phy *phy = tpm_dev->phy_id; in st33zp24_i2c_request_resources() local
189 pdata = client->dev.platform_data; in st33zp24_i2c_request_resources()
191 dev_err(&client->dev, "No platform data\n"); in st33zp24_i2c_request_resources()
192 return -ENODEV; in st33zp24_i2c_request_resources()
196 phy->io_lpcpd = pdata->io_lpcpd; in st33zp24_i2c_request_resources()
198 if (gpio_is_valid(pdata->io_lpcpd)) { in st33zp24_i2c_request_resources()
199 ret = devm_gpio_request_one(&client->dev, in st33zp24_i2c_request_resources()
200 pdata->io_lpcpd, GPIOF_OUT_INIT_HIGH, in st33zp24_i2c_request_resources()
203 dev_err(&client->dev, "Failed to request lpcpd pin\n"); in st33zp24_i2c_request_resources()
213 * @param: client, the i2c_client description (TPM I2C description).
216 * -1 in other case.
223 struct st33zp24_i2c_phy *phy; in st33zp24_i2c_probe() local
226 pr_info("%s: i2c client is NULL. Device not accessible.\n", in st33zp24_i2c_probe()
228 return -ENODEV; in st33zp24_i2c_probe()
231 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { in st33zp24_i2c_probe()
232 dev_info(&client->dev, "client not i2c capable\n"); in st33zp24_i2c_probe()
233 return -ENODEV; in st33zp24_i2c_probe()
236 phy = devm_kzalloc(&client->dev, sizeof(struct st33zp24_i2c_phy), in st33zp24_i2c_probe()
238 if (!phy) in st33zp24_i2c_probe()
239 return -ENOMEM; in st33zp24_i2c_probe()
241 phy->client = client; in st33zp24_i2c_probe()
243 pdata = client->dev.platform_data; in st33zp24_i2c_probe()
244 if (!pdata && client->dev.of_node) { in st33zp24_i2c_probe()
252 } else if (ACPI_HANDLE(&client->dev)) { in st33zp24_i2c_probe()
258 return st33zp24_probe(phy, &i2c_phy_ops, &client->dev, client->irq, in st33zp24_i2c_probe()
259 phy->io_lpcpd); in st33zp24_i2c_probe()
264 * @param: client, the i2c_client description (TPM I2C description).
283 MODULE_DEVICE_TABLE(i2c, st33zp24_i2c_id);
286 { .compatible = "st,st33zp24-i2c", },
315 MODULE_DESCRIPTION("STM TPM 1.2 I2C ST33 Driver");