66
77#include <linux/module.h>
88#include <linux/spi/spi.h>
9- #include <linux/gpio.h>
10- #include <linux/gpio/consumer.h>
11- #include <linux/of_irq.h>
12- #include <linux/of_gpio.h>
9+ #include <linux/of.h>
1310#include <linux/acpi.h>
1411#include <linux/tpm.h>
1512
@@ -60,7 +57,6 @@ struct st33zp24_spi_phy {
6057 u8 tx_buf [ST33ZP24_SPI_BUFFER_SIZE ];
6158 u8 rx_buf [ST33ZP24_SPI_BUFFER_SIZE ];
6259
63- int io_lpcpd ;
6460 int latency ;
6561};
6662
@@ -217,84 +213,6 @@ static const struct st33zp24_phy_ops spi_phy_ops = {
217213 .recv = st33zp24_spi_recv ,
218214};
219215
220- static const struct acpi_gpio_params lpcpd_gpios = { 1 , 0 , false };
221-
222- static const struct acpi_gpio_mapping acpi_st33zp24_gpios [] = {
223- { "lpcpd-gpios" , & lpcpd_gpios , 1 },
224- {},
225- };
226-
227- static int st33zp24_spi_acpi_request_resources (struct spi_device * spi_dev )
228- {
229- struct tpm_chip * chip = spi_get_drvdata (spi_dev );
230- struct st33zp24_dev * tpm_dev = dev_get_drvdata (& chip -> dev );
231- struct st33zp24_spi_phy * phy = tpm_dev -> phy_id ;
232- struct gpio_desc * gpiod_lpcpd ;
233- struct device * dev = & spi_dev -> dev ;
234- int ret ;
235-
236- ret = devm_acpi_dev_add_driver_gpios (dev , acpi_st33zp24_gpios );
237- if (ret )
238- return ret ;
239-
240- /* Get LPCPD GPIO from ACPI */
241- gpiod_lpcpd = devm_gpiod_get (dev , "lpcpd" , GPIOD_OUT_HIGH );
242- if (IS_ERR (gpiod_lpcpd )) {
243- dev_err (dev , "Failed to retrieve lpcpd-gpios from acpi.\n" );
244- phy -> io_lpcpd = -1 ;
245- /*
246- * lpcpd pin is not specified. This is not an issue as
247- * power management can be also managed by TPM specific
248- * commands. So leave with a success status code.
249- */
250- return 0 ;
251- }
252-
253- phy -> io_lpcpd = desc_to_gpio (gpiod_lpcpd );
254-
255- return 0 ;
256- }
257-
258- static int st33zp24_spi_of_request_resources (struct spi_device * spi_dev )
259- {
260- struct tpm_chip * chip = spi_get_drvdata (spi_dev );
261- struct st33zp24_dev * tpm_dev = dev_get_drvdata (& chip -> dev );
262- struct st33zp24_spi_phy * phy = tpm_dev -> phy_id ;
263- struct device_node * pp ;
264- int gpio ;
265- int ret ;
266-
267- pp = spi_dev -> dev .of_node ;
268- if (!pp ) {
269- dev_err (& spi_dev -> dev , "No platform data\n" );
270- return - ENODEV ;
271- }
272-
273- /* Get GPIO from device tree */
274- gpio = of_get_named_gpio (pp , "lpcpd-gpios" , 0 );
275- if (gpio < 0 ) {
276- dev_err (& spi_dev -> dev ,
277- "Failed to retrieve lpcpd-gpios from dts.\n" );
278- phy -> io_lpcpd = -1 ;
279- /*
280- * lpcpd pin is not specified. This is not an issue as
281- * power management can be also managed by TPM specific
282- * commands. So leave with a success status code.
283- */
284- return 0 ;
285- }
286- /* GPIO request and configuration */
287- ret = devm_gpio_request_one (& spi_dev -> dev , gpio ,
288- GPIOF_OUT_INIT_HIGH , "TPM IO LPCPD" );
289- if (ret ) {
290- dev_err (& spi_dev -> dev , "Failed to request lpcpd pin\n" );
291- return - ENODEV ;
292- }
293- phy -> io_lpcpd = gpio ;
294-
295- return 0 ;
296- }
297-
298216/*
299217 * st33zp24_spi_probe initialize the TPM device
300218 * @param: dev, the spi_device description (TPM SPI description).
@@ -303,7 +221,6 @@ static int st33zp24_spi_of_request_resources(struct spi_device *spi_dev)
303221 */
304222static int st33zp24_spi_probe (struct spi_device * dev )
305223{
306- int ret ;
307224 struct st33zp24_spi_phy * phy ;
308225
309226 /* Check SPI platform functionnalities */
@@ -320,24 +237,11 @@ static int st33zp24_spi_probe(struct spi_device *dev)
320237
321238 phy -> spi_device = dev ;
322239
323- if (dev -> dev .of_node ) {
324- ret = st33zp24_spi_of_request_resources (dev );
325- if (ret )
326- return ret ;
327- } else if (ACPI_HANDLE (& dev -> dev )) {
328- ret = st33zp24_spi_acpi_request_resources (dev );
329- if (ret )
330- return ret ;
331- } else {
332- return - ENODEV ;
333- }
334-
335240 phy -> latency = st33zp24_spi_evaluate_latency (phy );
336241 if (phy -> latency <= 0 )
337242 return - ENODEV ;
338243
339- return st33zp24_probe (phy , & spi_phy_ops , & dev -> dev , dev -> irq ,
340- phy -> io_lpcpd );
244+ return st33zp24_probe (phy , & spi_phy_ops , & dev -> dev , dev -> irq );
341245}
342246
343247/*
0 commit comments