tpm_tis.c (af782f339a5d6ea202652c9f06880e1a28c43813) tpm_tis.c (9e0d39d8a6a0a8805d05fba22e3fbe80b5c8c4cb)
1/*
2 * Copyright (C) 2005, 2006 IBM Corporation
3 * Copyright (C) 2014, 2015 Intel Corporation
4 *
5 * Authors:
6 * Leendert van Doorn <leendert@watson.ibm.com>
7 * Kylene Hall <kjhall@us.ibm.com>
8 *

--- 118 unchanged lines hidden (view full) ---

127#endif
128
129/* Before we attempt to access the TPM we must see that the valid bit is set.
130 * The specification says that this bit is 0 at reset and remains 0 until the
131 * 'TPM has gone through its self test and initialization and has established
132 * correct values in the other bits.' */
133static int wait_startup(struct tpm_chip *chip, int l)
134{
1/*
2 * Copyright (C) 2005, 2006 IBM Corporation
3 * Copyright (C) 2014, 2015 Intel Corporation
4 *
5 * Authors:
6 * Leendert van Doorn <leendert@watson.ibm.com>
7 * Kylene Hall <kjhall@us.ibm.com>
8 *

--- 118 unchanged lines hidden (view full) ---

127#endif
128
129/* Before we attempt to access the TPM we must see that the valid bit is set.
130 * The specification says that this bit is 0 at reset and remains 0 until the
131 * 'TPM has gone through its self test and initialization and has established
132 * correct values in the other bits.' */
133static int wait_startup(struct tpm_chip *chip, int l)
134{
135 struct priv_data *priv = chip->vendor.priv;
135 struct priv_data *priv = dev_get_drvdata(&chip->dev);
136 unsigned long stop = jiffies + chip->timeout_a;
137 do {
138 if (ioread8(priv->iobase + TPM_ACCESS(l)) &
139 TPM_ACCESS_VALID)
140 return 0;
141 msleep(TPM_TIMEOUT);
142 } while (time_before(jiffies, stop));
143 return -1;
144}
145
146static int check_locality(struct tpm_chip *chip, int l)
147{
136 unsigned long stop = jiffies + chip->timeout_a;
137 do {
138 if (ioread8(priv->iobase + TPM_ACCESS(l)) &
139 TPM_ACCESS_VALID)
140 return 0;
141 msleep(TPM_TIMEOUT);
142 } while (time_before(jiffies, stop));
143 return -1;
144}
145
146static int check_locality(struct tpm_chip *chip, int l)
147{
148 struct priv_data *priv = chip->vendor.priv;
148 struct priv_data *priv = dev_get_drvdata(&chip->dev);
149
150 if ((ioread8(priv->iobase + TPM_ACCESS(l)) &
151 (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) ==
152 (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID))
153 return priv->locality = l;
154
155 return -1;
156}
157
158static void release_locality(struct tpm_chip *chip, int l, int force)
159{
149
150 if ((ioread8(priv->iobase + TPM_ACCESS(l)) &
151 (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) ==
152 (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID))
153 return priv->locality = l;
154
155 return -1;
156}
157
158static void release_locality(struct tpm_chip *chip, int l, int force)
159{
160 struct priv_data *priv = chip->vendor.priv;
160 struct priv_data *priv = dev_get_drvdata(&chip->dev);
161
162 if (force || (ioread8(priv->iobase + TPM_ACCESS(l)) &
163 (TPM_ACCESS_REQUEST_PENDING | TPM_ACCESS_VALID)) ==
164 (TPM_ACCESS_REQUEST_PENDING | TPM_ACCESS_VALID))
165 iowrite8(TPM_ACCESS_ACTIVE_LOCALITY,
166 priv->iobase + TPM_ACCESS(l));
167}
168
169static int request_locality(struct tpm_chip *chip, int l)
170{
161
162 if (force || (ioread8(priv->iobase + TPM_ACCESS(l)) &
163 (TPM_ACCESS_REQUEST_PENDING | TPM_ACCESS_VALID)) ==
164 (TPM_ACCESS_REQUEST_PENDING | TPM_ACCESS_VALID))
165 iowrite8(TPM_ACCESS_ACTIVE_LOCALITY,
166 priv->iobase + TPM_ACCESS(l));
167}
168
169static int request_locality(struct tpm_chip *chip, int l)
170{
171 struct priv_data *priv = chip->vendor.priv;
171 struct priv_data *priv = dev_get_drvdata(&chip->dev);
172 unsigned long stop, timeout;
173 long rc;
174
175 if (check_locality(chip, l) >= 0)
176 return l;
177
178 iowrite8(TPM_ACCESS_REQUEST_USE,
179 priv->iobase + TPM_ACCESS(l));

--- 24 unchanged lines hidden (view full) ---

204 }
205 while (time_before(jiffies, stop));
206 }
207 return -1;
208}
209
210static u8 tpm_tis_status(struct tpm_chip *chip)
211{
172 unsigned long stop, timeout;
173 long rc;
174
175 if (check_locality(chip, l) >= 0)
176 return l;
177
178 iowrite8(TPM_ACCESS_REQUEST_USE,
179 priv->iobase + TPM_ACCESS(l));

--- 24 unchanged lines hidden (view full) ---

204 }
205 while (time_before(jiffies, stop));
206 }
207 return -1;
208}
209
210static u8 tpm_tis_status(struct tpm_chip *chip)
211{
212 struct priv_data *priv = chip->vendor.priv;
212 struct priv_data *priv = dev_get_drvdata(&chip->dev);
213
214 return ioread8(priv->iobase +
215 TPM_STS(priv->locality));
216}
217
218static void tpm_tis_ready(struct tpm_chip *chip)
219{
213
214 return ioread8(priv->iobase +
215 TPM_STS(priv->locality));
216}
217
218static void tpm_tis_ready(struct tpm_chip *chip)
219{
220 struct priv_data *priv = chip->vendor.priv;
220 struct priv_data *priv = dev_get_drvdata(&chip->dev);
221
222 /* this causes the current command to be aborted */
223 iowrite8(TPM_STS_COMMAND_READY,
224 priv->iobase + TPM_STS(priv->locality));
225}
226
227static int get_burstcount(struct tpm_chip *chip)
228{
221
222 /* this causes the current command to be aborted */
223 iowrite8(TPM_STS_COMMAND_READY,
224 priv->iobase + TPM_STS(priv->locality));
225}
226
227static int get_burstcount(struct tpm_chip *chip)
228{
229 struct priv_data *priv = chip->vendor.priv;
229 struct priv_data *priv = dev_get_drvdata(&chip->dev);
230 unsigned long stop;
231 int burstcnt;
232
233 /* wait for burstcount */
234 /* which timeout value, spec has 2 answers (c & d) */
235 stop = jiffies + chip->timeout_d;
236 do {
237 burstcnt = ioread8(priv->iobase +

--- 5 unchanged lines hidden (view full) ---

243 return burstcnt;
244 msleep(TPM_TIMEOUT);
245 } while (time_before(jiffies, stop));
246 return -EBUSY;
247}
248
249static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
250{
230 unsigned long stop;
231 int burstcnt;
232
233 /* wait for burstcount */
234 /* which timeout value, spec has 2 answers (c & d) */
235 stop = jiffies + chip->timeout_d;
236 do {
237 burstcnt = ioread8(priv->iobase +

--- 5 unchanged lines hidden (view full) ---

243 return burstcnt;
244 msleep(TPM_TIMEOUT);
245 } while (time_before(jiffies, stop));
246 return -EBUSY;
247}
248
249static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
250{
251 struct priv_data *priv = chip->vendor.priv;
251 struct priv_data *priv = dev_get_drvdata(&chip->dev);
252 int size = 0, burstcnt;
253 while (size < count &&
254 wait_for_tpm_stat(chip,
255 TPM_STS_DATA_AVAIL | TPM_STS_VALID,
256 chip->timeout_c,
257 &priv->read_queue, true)
258 == 0) {
259 burstcnt = get_burstcount(chip);
260 for (; burstcnt > 0 && size < count; burstcnt--)
261 buf[size++] = ioread8(priv->iobase +
262 TPM_DATA_FIFO(priv->locality));
263 }
264 return size;
265}
266
267static int tpm_tis_recv(struct tpm_chip *chip, u8 *buf, size_t count)
268{
252 int size = 0, burstcnt;
253 while (size < count &&
254 wait_for_tpm_stat(chip,
255 TPM_STS_DATA_AVAIL | TPM_STS_VALID,
256 chip->timeout_c,
257 &priv->read_queue, true)
258 == 0) {
259 burstcnt = get_burstcount(chip);
260 for (; burstcnt > 0 && size < count; burstcnt--)
261 buf[size++] = ioread8(priv->iobase +
262 TPM_DATA_FIFO(priv->locality));
263 }
264 return size;
265}
266
267static int tpm_tis_recv(struct tpm_chip *chip, u8 *buf, size_t count)
268{
269 struct priv_data *priv = chip->vendor.priv;
269 struct priv_data *priv = dev_get_drvdata(&chip->dev);
270 int size = 0;
271 int expected, status;
272
273 if (count < TPM_HEADER_SIZE) {
274 size = -EIO;
275 goto out;
276 }
277

--- 39 unchanged lines hidden (view full) ---

317
318/*
319 * If interrupts are used (signaled by an irq set in the vendor structure)
320 * tpm.c can skip polling for the data to be available as the interrupt is
321 * waited for here
322 */
323static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len)
324{
270 int size = 0;
271 int expected, status;
272
273 if (count < TPM_HEADER_SIZE) {
274 size = -EIO;
275 goto out;
276 }
277

--- 39 unchanged lines hidden (view full) ---

317
318/*
319 * If interrupts are used (signaled by an irq set in the vendor structure)
320 * tpm.c can skip polling for the data to be available as the interrupt is
321 * waited for here
322 */
323static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len)
324{
325 struct priv_data *priv = chip->vendor.priv;
325 struct priv_data *priv = dev_get_drvdata(&chip->dev);
326 int rc, status, burstcnt;
327 size_t count = 0;
328
329 if (request_locality(chip, 0) < 0)
330 return -EBUSY;
331
332 status = tpm_tis_status(chip);
333 if ((status & TPM_STS_COMMAND_READY) == 0) {

--- 39 unchanged lines hidden (view full) ---

373out_err:
374 tpm_tis_ready(chip);
375 release_locality(chip, priv->locality, 0);
376 return rc;
377}
378
379static void disable_interrupts(struct tpm_chip *chip)
380{
326 int rc, status, burstcnt;
327 size_t count = 0;
328
329 if (request_locality(chip, 0) < 0)
330 return -EBUSY;
331
332 status = tpm_tis_status(chip);
333 if ((status & TPM_STS_COMMAND_READY) == 0) {

--- 39 unchanged lines hidden (view full) ---

373out_err:
374 tpm_tis_ready(chip);
375 release_locality(chip, priv->locality, 0);
376 return rc;
377}
378
379static void disable_interrupts(struct tpm_chip *chip)
380{
381 struct priv_data *priv = chip->vendor.priv;
381 struct priv_data *priv = dev_get_drvdata(&chip->dev);
382 u32 intmask;
383
384 intmask =
385 ioread32(priv->iobase +
386 TPM_INT_ENABLE(priv->locality));
387 intmask &= ~TPM_GLOBAL_INT_ENABLE;
388 iowrite32(intmask,
389 priv->iobase + TPM_INT_ENABLE(priv->locality));

--- 4 unchanged lines hidden (view full) ---

394
395/*
396 * If interrupts are used (signaled by an irq set in the vendor structure)
397 * tpm.c can skip polling for the data to be available as the interrupt is
398 * waited for here
399 */
400static int tpm_tis_send_main(struct tpm_chip *chip, u8 *buf, size_t len)
401{
382 u32 intmask;
383
384 intmask =
385 ioread32(priv->iobase +
386 TPM_INT_ENABLE(priv->locality));
387 intmask &= ~TPM_GLOBAL_INT_ENABLE;
388 iowrite32(intmask,
389 priv->iobase + TPM_INT_ENABLE(priv->locality));

--- 4 unchanged lines hidden (view full) ---

394
395/*
396 * If interrupts are used (signaled by an irq set in the vendor structure)
397 * tpm.c can skip polling for the data to be available as the interrupt is
398 * waited for here
399 */
400static int tpm_tis_send_main(struct tpm_chip *chip, u8 *buf, size_t len)
401{
402 struct priv_data *priv = chip->vendor.priv;
402 struct priv_data *priv = dev_get_drvdata(&chip->dev);
403 int rc;
404 u32 ordinal;
405 unsigned long dur;
406
407 rc = tpm_tis_send_data(chip, buf, len);
408 if (rc < 0)
409 return rc;
410

--- 21 unchanged lines hidden (view full) ---

432 tpm_tis_ready(chip);
433 release_locality(chip, priv->locality, 0);
434 return rc;
435}
436
437static int tpm_tis_send(struct tpm_chip *chip, u8 *buf, size_t len)
438{
439 int rc, irq;
403 int rc;
404 u32 ordinal;
405 unsigned long dur;
406
407 rc = tpm_tis_send_data(chip, buf, len);
408 if (rc < 0)
409 return rc;
410

--- 21 unchanged lines hidden (view full) ---

432 tpm_tis_ready(chip);
433 release_locality(chip, priv->locality, 0);
434 return rc;
435}
436
437static int tpm_tis_send(struct tpm_chip *chip, u8 *buf, size_t len)
438{
439 int rc, irq;
440 struct priv_data *priv = chip->vendor.priv;
440 struct priv_data *priv = dev_get_drvdata(&chip->dev);
441
442 if (!(chip->flags & TPM_CHIP_FLAG_IRQ) || priv->irq_tested)
443 return tpm_tis_send_main(chip, buf, len);
444
445 /* Verify receipt of the expected IRQ */
446 irq = priv->irq;
447 priv->irq = 0;
448 chip->flags &= ~TPM_CHIP_FLAG_IRQ;

--- 17 unchanged lines hidden (view full) ---

466 /* Atmel 3204 */
467 { 0x32041114, { (TIS_SHORT_TIMEOUT*1000), (TIS_LONG_TIMEOUT*1000),
468 (TIS_SHORT_TIMEOUT*1000), (TIS_SHORT_TIMEOUT*1000) } },
469};
470
471static bool tpm_tis_update_timeouts(struct tpm_chip *chip,
472 unsigned long *timeout_cap)
473{
441
442 if (!(chip->flags & TPM_CHIP_FLAG_IRQ) || priv->irq_tested)
443 return tpm_tis_send_main(chip, buf, len);
444
445 /* Verify receipt of the expected IRQ */
446 irq = priv->irq;
447 priv->irq = 0;
448 chip->flags &= ~TPM_CHIP_FLAG_IRQ;

--- 17 unchanged lines hidden (view full) ---

466 /* Atmel 3204 */
467 { 0x32041114, { (TIS_SHORT_TIMEOUT*1000), (TIS_LONG_TIMEOUT*1000),
468 (TIS_SHORT_TIMEOUT*1000), (TIS_SHORT_TIMEOUT*1000) } },
469};
470
471static bool tpm_tis_update_timeouts(struct tpm_chip *chip,
472 unsigned long *timeout_cap)
473{
474 struct priv_data *priv = chip->vendor.priv;
474 struct priv_data *priv = dev_get_drvdata(&chip->dev);
475 int i;
476 u32 did_vid;
477
478 did_vid = ioread32(priv->iobase + TPM_DID_VID(0));
479
480 for (i = 0; i != ARRAY_SIZE(vendor_timeout_overrides); i++) {
481 if (vendor_timeout_overrides[i].did_vid != did_vid)
482 continue;

--- 7 unchanged lines hidden (view full) ---

490
491/*
492 * Early probing for iTPM with STS_DATA_EXPECT flaw.
493 * Try sending command without itpm flag set and if that
494 * fails, repeat with itpm flag set.
495 */
496static int probe_itpm(struct tpm_chip *chip)
497{
475 int i;
476 u32 did_vid;
477
478 did_vid = ioread32(priv->iobase + TPM_DID_VID(0));
479
480 for (i = 0; i != ARRAY_SIZE(vendor_timeout_overrides); i++) {
481 if (vendor_timeout_overrides[i].did_vid != did_vid)
482 continue;

--- 7 unchanged lines hidden (view full) ---

490
491/*
492 * Early probing for iTPM with STS_DATA_EXPECT flaw.
493 * Try sending command without itpm flag set and if that
494 * fails, repeat with itpm flag set.
495 */
496static int probe_itpm(struct tpm_chip *chip)
497{
498 struct priv_data *priv = chip->vendor.priv;
498 struct priv_data *priv = dev_get_drvdata(&chip->dev);
499 int rc = 0;
500 u8 cmd_getticks[] = {
501 0x00, 0xc1, 0x00, 0x00, 0x00, 0x0a,
502 0x00, 0x00, 0x00, 0xf1
503 };
504 size_t len = sizeof(cmd_getticks);
505 bool rem_itpm = itpm;
506 u16 vendor = ioread16(priv->iobase + TPM_DID_VID(0));

--- 25 unchanged lines hidden (view full) ---

532 tpm_tis_ready(chip);
533 release_locality(chip, priv->locality, 0);
534
535 return rc;
536}
537
538static bool tpm_tis_req_canceled(struct tpm_chip *chip, u8 status)
539{
499 int rc = 0;
500 u8 cmd_getticks[] = {
501 0x00, 0xc1, 0x00, 0x00, 0x00, 0x0a,
502 0x00, 0x00, 0x00, 0xf1
503 };
504 size_t len = sizeof(cmd_getticks);
505 bool rem_itpm = itpm;
506 u16 vendor = ioread16(priv->iobase + TPM_DID_VID(0));

--- 25 unchanged lines hidden (view full) ---

532 tpm_tis_ready(chip);
533 release_locality(chip, priv->locality, 0);
534
535 return rc;
536}
537
538static bool tpm_tis_req_canceled(struct tpm_chip *chip, u8 status)
539{
540 struct priv_data *priv = chip->vendor.priv;
540 struct priv_data *priv = dev_get_drvdata(&chip->dev);
541
542 switch (priv->manufacturer_id) {
543 case TPM_VID_WINBOND:
544 return ((status == TPM_STS_VALID) ||
545 (status == (TPM_STS_VALID | TPM_STS_COMMAND_READY)));
546 case TPM_VID_STM:
547 return (status == (TPM_STS_VALID | TPM_STS_COMMAND_READY));
548 default:

--- 10 unchanged lines hidden (view full) ---

559 .req_complete_mask = TPM_STS_DATA_AVAIL | TPM_STS_VALID,
560 .req_complete_val = TPM_STS_DATA_AVAIL | TPM_STS_VALID,
561 .req_canceled = tpm_tis_req_canceled,
562};
563
564static irqreturn_t tis_int_handler(int dummy, void *dev_id)
565{
566 struct tpm_chip *chip = dev_id;
541
542 switch (priv->manufacturer_id) {
543 case TPM_VID_WINBOND:
544 return ((status == TPM_STS_VALID) ||
545 (status == (TPM_STS_VALID | TPM_STS_COMMAND_READY)));
546 case TPM_VID_STM:
547 return (status == (TPM_STS_VALID | TPM_STS_COMMAND_READY));
548 default:

--- 10 unchanged lines hidden (view full) ---

559 .req_complete_mask = TPM_STS_DATA_AVAIL | TPM_STS_VALID,
560 .req_complete_val = TPM_STS_DATA_AVAIL | TPM_STS_VALID,
561 .req_canceled = tpm_tis_req_canceled,
562};
563
564static irqreturn_t tis_int_handler(int dummy, void *dev_id)
565{
566 struct tpm_chip *chip = dev_id;
567 struct priv_data *priv = chip->vendor.priv;
567 struct priv_data *priv = dev_get_drvdata(&chip->dev);
568 u32 interrupt;
569 int i;
570
571 interrupt = ioread32(priv->iobase +
572 TPM_INT_STATUS(priv->locality));
573
574 if (interrupt == 0)
575 return IRQ_NONE;
576
568 u32 interrupt;
569 int i;
570
571 interrupt = ioread32(priv->iobase +
572 TPM_INT_STATUS(priv->locality));
573
574 if (interrupt == 0)
575 return IRQ_NONE;
576
577 ((struct priv_data *)chip->vendor.priv)->irq_tested = true;
577 priv->irq_tested = true;
578 if (interrupt & TPM_INTF_DATA_AVAIL_INT)
579 wake_up_interruptible(&priv->read_queue);
580 if (interrupt & TPM_INTF_LOCALITY_CHANGE_INT)
581 for (i = 0; i < 5; i++)
582 if (check_locality(chip, i) >= 0)
583 break;
584 if (interrupt &
585 (TPM_INTF_LOCALITY_CHANGE_INT | TPM_INTF_STS_VALID_INT |

--- 10 unchanged lines hidden (view full) ---

596
597/* Register the IRQ and issue a command that will cause an interrupt. If an
598 * irq is seen then leave the chip setup for IRQ operation, otherwise reverse
599 * everything and leave in polling mode. Returns 0 on success.
600 */
601static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
602 int flags, int irq)
603{
578 if (interrupt & TPM_INTF_DATA_AVAIL_INT)
579 wake_up_interruptible(&priv->read_queue);
580 if (interrupt & TPM_INTF_LOCALITY_CHANGE_INT)
581 for (i = 0; i < 5; i++)
582 if (check_locality(chip, i) >= 0)
583 break;
584 if (interrupt &
585 (TPM_INTF_LOCALITY_CHANGE_INT | TPM_INTF_STS_VALID_INT |

--- 10 unchanged lines hidden (view full) ---

596
597/* Register the IRQ and issue a command that will cause an interrupt. If an
598 * irq is seen then leave the chip setup for IRQ operation, otherwise reverse
599 * everything and leave in polling mode. Returns 0 on success.
600 */
601static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
602 int flags, int irq)
603{
604 struct priv_data *priv = chip->vendor.priv;
604 struct priv_data *priv = dev_get_drvdata(&chip->dev);
605 u8 original_int_vec;
606
607 if (devm_request_irq(&chip->dev, irq, tis_int_handler, flags,
608 dev_name(&chip->dev), chip) != 0) {
609 dev_info(&chip->dev, "Unable to request irq: %d for probe\n",
610 irq);
611 return -1;
612 }

--- 36 unchanged lines hidden (view full) ---

649}
650
651/* Try to find the IRQ the TPM is using. This is for legacy x86 systems that
652 * do not have ACPI/etc. We typically expect the interrupt to be declared if
653 * present.
654 */
655static void tpm_tis_probe_irq(struct tpm_chip *chip, u32 intmask)
656{
605 u8 original_int_vec;
606
607 if (devm_request_irq(&chip->dev, irq, tis_int_handler, flags,
608 dev_name(&chip->dev), chip) != 0) {
609 dev_info(&chip->dev, "Unable to request irq: %d for probe\n",
610 irq);
611 return -1;
612 }

--- 36 unchanged lines hidden (view full) ---

649}
650
651/* Try to find the IRQ the TPM is using. This is for legacy x86 systems that
652 * do not have ACPI/etc. We typically expect the interrupt to be declared if
653 * present.
654 */
655static void tpm_tis_probe_irq(struct tpm_chip *chip, u32 intmask)
656{
657 struct priv_data *priv = chip->vendor.priv;
657 struct priv_data *priv = dev_get_drvdata(&chip->dev);
658 u8 original_int_vec;
659 int i;
660
661 original_int_vec = ioread8(priv->iobase +
662 TPM_INT_VECTOR(priv->locality));
663
664 if (!original_int_vec) {
665 if (IS_ENABLED(CONFIG_X86))

--- 7 unchanged lines hidden (view full) ---

673}
674
675static bool interrupts = true;
676module_param(interrupts, bool, 0444);
677MODULE_PARM_DESC(interrupts, "Enable interrupts");
678
679static void tpm_tis_remove(struct tpm_chip *chip)
680{
658 u8 original_int_vec;
659 int i;
660
661 original_int_vec = ioread8(priv->iobase +
662 TPM_INT_VECTOR(priv->locality));
663
664 if (!original_int_vec) {
665 if (IS_ENABLED(CONFIG_X86))

--- 7 unchanged lines hidden (view full) ---

673}
674
675static bool interrupts = true;
676module_param(interrupts, bool, 0444);
677MODULE_PARM_DESC(interrupts, "Enable interrupts");
678
679static void tpm_tis_remove(struct tpm_chip *chip)
680{
681 struct priv_data *priv = chip->vendor.priv;
681 struct priv_data *priv = dev_get_drvdata(&chip->dev);
682 void __iomem *reg = priv->iobase + TPM_INT_ENABLE(priv->locality);
683
684 iowrite32(~TPM_GLOBAL_INT_ENABLE & ioread32(reg), reg);
685 release_locality(chip, priv->locality, 1);
686}
687
688static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
689 acpi_handle acpi_dev_handle)

--- 6 unchanged lines hidden (view full) ---

696 priv = devm_kzalloc(dev, sizeof(struct priv_data), GFP_KERNEL);
697 if (priv == NULL)
698 return -ENOMEM;
699
700 chip = tpmm_chip_alloc(dev, &tpm_tis);
701 if (IS_ERR(chip))
702 return PTR_ERR(chip);
703
682 void __iomem *reg = priv->iobase + TPM_INT_ENABLE(priv->locality);
683
684 iowrite32(~TPM_GLOBAL_INT_ENABLE & ioread32(reg), reg);
685 release_locality(chip, priv->locality, 1);
686}
687
688static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
689 acpi_handle acpi_dev_handle)

--- 6 unchanged lines hidden (view full) ---

696 priv = devm_kzalloc(dev, sizeof(struct priv_data), GFP_KERNEL);
697 if (priv == NULL)
698 return -ENOMEM;
699
700 chip = tpmm_chip_alloc(dev, &tpm_tis);
701 if (IS_ERR(chip))
702 return PTR_ERR(chip);
703
704 chip->vendor.priv = priv;
705#ifdef CONFIG_ACPI
706 chip->acpi_dev_handle = acpi_dev_handle;
707#endif
708
709 priv->iobase = devm_ioremap_resource(dev, &tpm_info->res);
710 if (IS_ERR(priv->iobase))
711 return PTR_ERR(priv->iobase);
712
713 /* Maximum timeouts */
714 chip->timeout_a = TIS_TIMEOUT_A_MAX;
715 chip->timeout_b = TIS_TIMEOUT_B_MAX;
716 chip->timeout_c = TIS_TIMEOUT_C_MAX;
717 chip->timeout_d = TIS_TIMEOUT_D_MAX;
718
704#ifdef CONFIG_ACPI
705 chip->acpi_dev_handle = acpi_dev_handle;
706#endif
707
708 priv->iobase = devm_ioremap_resource(dev, &tpm_info->res);
709 if (IS_ERR(priv->iobase))
710 return PTR_ERR(priv->iobase);
711
712 /* Maximum timeouts */
713 chip->timeout_a = TIS_TIMEOUT_A_MAX;
714 chip->timeout_b = TIS_TIMEOUT_B_MAX;
715 chip->timeout_c = TIS_TIMEOUT_C_MAX;
716 chip->timeout_d = TIS_TIMEOUT_D_MAX;
717
718 dev_set_drvdata(&chip->dev, priv);
719
719 if (wait_startup(chip, 0) != 0) {
720 rc = -ENODEV;
721 goto out_err;
722 }
723
724 /* Take control of the TPM's interrupt hardware and shut it off */
725 intmask = ioread32(priv->iobase +
726 TPM_INT_ENABLE(priv->locality));

--- 108 unchanged lines hidden (view full) ---

835out_err:
836 tpm_tis_remove(chip);
837 return rc;
838}
839
840#ifdef CONFIG_PM_SLEEP
841static void tpm_tis_reenable_interrupts(struct tpm_chip *chip)
842{
720 if (wait_startup(chip, 0) != 0) {
721 rc = -ENODEV;
722 goto out_err;
723 }
724
725 /* Take control of the TPM's interrupt hardware and shut it off */
726 intmask = ioread32(priv->iobase +
727 TPM_INT_ENABLE(priv->locality));

--- 108 unchanged lines hidden (view full) ---

836out_err:
837 tpm_tis_remove(chip);
838 return rc;
839}
840
841#ifdef CONFIG_PM_SLEEP
842static void tpm_tis_reenable_interrupts(struct tpm_chip *chip)
843{
843 struct priv_data *priv = chip->vendor.priv;
844 struct priv_data *priv = dev_get_drvdata(&chip->dev);
844 u32 intmask;
845
846 /* reenable interrupts that device may have lost or
847 BIOS/firmware may have disabled */
848 iowrite8(priv->irq, priv->iobase +
849 TPM_INT_VECTOR(priv->locality));
850
851 intmask =

--- 322 unchanged lines hidden ---
845 u32 intmask;
846
847 /* reenable interrupts that device may have lost or
848 BIOS/firmware may have disabled */
849 iowrite8(priv->irq, priv->iobase +
850 TPM_INT_VECTOR(priv->locality));
851
852 intmask =

--- 322 unchanged lines hidden ---