spi.c (20ab99f89d574ba3c3944a6682bec5a6e0c0dcd9) | spi.c (9e0d39d8a6a0a8805d05fba22e3fbe80b5c8c4cb) |
---|---|
1/* 2 * STMicroelectronics TPM SPI Linux driver for TPM ST33ZP24 3 * Copyright (C) 2009 - 2016 STMicroelectronics 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. --- 12 unchanged lines hidden (view full) --- 21#include <linux/gpio.h> 22#include <linux/gpio/consumer.h> 23#include <linux/of_irq.h> 24#include <linux/of_gpio.h> 25#include <linux/acpi.h> 26#include <linux/tpm.h> 27#include <linux/platform_data/st33zp24.h> 28 | 1/* 2 * STMicroelectronics TPM SPI Linux driver for TPM ST33ZP24 3 * Copyright (C) 2009 - 2016 STMicroelectronics 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. --- 12 unchanged lines hidden (view full) --- 21#include <linux/gpio.h> 22#include <linux/gpio/consumer.h> 23#include <linux/of_irq.h> 24#include <linux/of_gpio.h> 25#include <linux/acpi.h> 26#include <linux/tpm.h> 27#include <linux/platform_data/st33zp24.h> 28 |
29#include "../tpm.h" |
|
29#include "st33zp24.h" 30 31#define TPM_DATA_FIFO 0x24 32#define TPM_INTF_CAPABILITY 0x14 33 34#define TPM_DUMMY_BYTE 0x00 35 36#define MAX_SPI_LATENCY 15 --- 189 unchanged lines hidden (view full) --- 226 227static const struct st33zp24_phy_ops spi_phy_ops = { 228 .send = st33zp24_spi_send, 229 .recv = st33zp24_spi_recv, 230}; 231 232static int st33zp24_spi_acpi_request_resources(struct spi_device *spi_dev) 233{ | 30#include "st33zp24.h" 31 32#define TPM_DATA_FIFO 0x24 33#define TPM_INTF_CAPABILITY 0x14 34 35#define TPM_DUMMY_BYTE 0x00 36 37#define MAX_SPI_LATENCY 15 --- 189 unchanged lines hidden (view full) --- 227 228static const struct st33zp24_phy_ops spi_phy_ops = { 229 .send = st33zp24_spi_send, 230 .recv = st33zp24_spi_recv, 231}; 232 233static int st33zp24_spi_acpi_request_resources(struct spi_device *spi_dev) 234{ |
234 struct st33zp24_spi_phy *phy = spi_get_drvdata(spi_dev); | 235 struct tpm_chip *chip = spi_get_drvdata(spi_dev); 236 struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev); 237 struct st33zp24_spi_phy *phy = tpm_dev->phy_id; |
235 struct gpio_desc *gpiod_lpcpd; 236 struct device *dev = &spi_dev->dev; 237 238 /* Get LPCPD GPIO from ACPI */ 239 gpiod_lpcpd = devm_gpiod_get_index(dev, "TPM IO LPCPD", 1, 240 GPIOD_OUT_HIGH); 241 if (IS_ERR(gpiod_lpcpd)) { 242 dev_err(dev, "Failed to retrieve lpcpd-gpios from acpi.\n"); --- 8 unchanged lines hidden (view full) --- 251 252 phy->io_lpcpd = desc_to_gpio(gpiod_lpcpd); 253 254 return 0; 255} 256 257static int st33zp24_spi_of_request_resources(struct spi_device *spi_dev) 258{ | 238 struct gpio_desc *gpiod_lpcpd; 239 struct device *dev = &spi_dev->dev; 240 241 /* Get LPCPD GPIO from ACPI */ 242 gpiod_lpcpd = devm_gpiod_get_index(dev, "TPM IO LPCPD", 1, 243 GPIOD_OUT_HIGH); 244 if (IS_ERR(gpiod_lpcpd)) { 245 dev_err(dev, "Failed to retrieve lpcpd-gpios from acpi.\n"); --- 8 unchanged lines hidden (view full) --- 254 255 phy->io_lpcpd = desc_to_gpio(gpiod_lpcpd); 256 257 return 0; 258} 259 260static int st33zp24_spi_of_request_resources(struct spi_device *spi_dev) 261{ |
259 struct st33zp24_spi_phy *phy = spi_get_drvdata(spi_dev); | 262 struct tpm_chip *chip = spi_get_drvdata(spi_dev); 263 struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev); 264 struct st33zp24_spi_phy *phy = tpm_dev->phy_id; |
260 struct device_node *pp; 261 int gpio; 262 int ret; 263 264 pp = spi_dev->dev.of_node; 265 if (!pp) { 266 dev_err(&spi_dev->dev, "No platform data\n"); 267 return -ENODEV; --- 21 unchanged lines hidden (view full) --- 289 } 290 phy->io_lpcpd = gpio; 291 292 return 0; 293} 294 295static int st33zp24_spi_request_resources(struct spi_device *dev) 296{ | 265 struct device_node *pp; 266 int gpio; 267 int ret; 268 269 pp = spi_dev->dev.of_node; 270 if (!pp) { 271 dev_err(&spi_dev->dev, "No platform data\n"); 272 return -ENODEV; --- 21 unchanged lines hidden (view full) --- 294 } 295 phy->io_lpcpd = gpio; 296 297 return 0; 298} 299 300static int st33zp24_spi_request_resources(struct spi_device *dev) 301{ |
297 struct st33zp24_spi_phy *phy = spi_get_drvdata(dev); | 302 struct tpm_chip *chip = spi_get_drvdata(dev); 303 struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev); 304 struct st33zp24_spi_phy *phy = tpm_dev->phy_id; |
298 struct st33zp24_platform_data *pdata; 299 int ret; 300 301 pdata = dev->dev.platform_data; 302 if (!pdata) { 303 dev_err(&dev->dev, "No platform data\n"); 304 return -ENODEV; 305 } --- 36 unchanged lines hidden (view full) --- 342 343 phy = devm_kzalloc(&dev->dev, sizeof(struct st33zp24_spi_phy), 344 GFP_KERNEL); 345 if (!phy) 346 return -ENOMEM; 347 348 phy->spi_device = dev; 349 | 305 struct st33zp24_platform_data *pdata; 306 int ret; 307 308 pdata = dev->dev.platform_data; 309 if (!pdata) { 310 dev_err(&dev->dev, "No platform data\n"); 311 return -ENODEV; 312 } --- 36 unchanged lines hidden (view full) --- 349 350 phy = devm_kzalloc(&dev->dev, sizeof(struct st33zp24_spi_phy), 351 GFP_KERNEL); 352 if (!phy) 353 return -ENOMEM; 354 355 phy->spi_device = dev; 356 |
350 spi_set_drvdata(dev, phy); 351 | |
352 pdata = dev->dev.platform_data; 353 if (!pdata && dev->dev.of_node) { 354 ret = st33zp24_spi_of_request_resources(dev); 355 if (ret) 356 return ret; 357 } else if (pdata) { 358 ret = st33zp24_spi_request_resources(dev); 359 if (ret) --- 66 unchanged lines hidden --- | 357 pdata = dev->dev.platform_data; 358 if (!pdata && dev->dev.of_node) { 359 ret = st33zp24_spi_of_request_resources(dev); 360 if (ret) 361 return ret; 362 } else if (pdata) { 363 ret = st33zp24_spi_request_resources(dev); 364 if (ret) --- 66 unchanged lines hidden --- |