blob: d63dcbe94d6403aff3c36732ae9bf2de487e5f96 [file] [log] [blame]
Stefan Reinauer3008bbad2011-10-11 14:46:25 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2011 The Chromium OS Authors. All rights reserved.
Frans Hendriks6cc937e2018-10-29 14:30:58 +01005 * Copyright (C) 2018 Eltan B.V.
Stefan Reinauer3008bbad2011-10-11 14:46:25 -07006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Stefan Reinauer3008bbad2011-10-11 14:46:25 -070015 */
16
17/*
18 * The code in this file has been heavily based on the article "Writing a TPM
19 * Device Driver" published on http://ptgmedia.pearsoncmg.com and the
20 * submission by Stefan Berger on Qemu-devel mailing list.
21 *
22 * One principal difference is that in the simplest config the other than 0
23 * TPM localities do not get mapped by some devices (for instance, by
24 * Infineon slb9635), so this driver provides access to locality 0 only.
25 */
26
Stefan Reinauer3008bbad2011-10-11 14:46:25 -070027#include <stdlib.h>
28#include <string.h>
29#include <delay.h>
30#include <arch/io.h>
Naresh G Solanki80ff0382016-11-15 11:01:33 +053031#include <arch/acpi.h>
32#include <arch/acpigen.h>
33#include <arch/acpi_device.h>
34#include <device/device.h>
Stefan Reinauer3008bbad2011-10-11 14:46:25 -070035#include <console/console.h>
Philipp Deppenwiesed88fb362017-10-18 20:26:18 +020036#include <security/tpm/tis.h>
Stefan Reinauerfd4f4132013-06-19 12:25:44 -070037#include <arch/early_variables.h>
Duncan Lauriedd281ed2014-10-30 15:20:19 -070038#include <device/pnp.h>
39#include "chip.h"
Stefan Reinauer3008bbad2011-10-11 14:46:25 -070040
Stefan Reinauer3008bbad2011-10-11 14:46:25 -070041#define PREFIX "lpc_tpm: "
Naresh G Solanki80ff0382016-11-15 11:01:33 +053042/* TCG Physical Presence Interface */
43#define TPM_PPI_UUID "3dddfaa6-361b-4eb4-a424-8d10089d1653"
44/* TCG Memory Clear Interface */
45#define TPM_MCI_UUID "376054ed-cc13-4675-901c-4756d7f2d45d"
Stefan Reinauer3008bbad2011-10-11 14:46:25 -070046/* coreboot wrapper for TPM driver (start) */
47#define TPM_DEBUG(fmt, args...) \
Denis 'GNUtoo' Carikli0e92bb02016-02-20 17:32:03 +010048 if (IS_ENABLED(CONFIG_DEBUG_TPM)) { \
Stefan Reinauer3008bbad2011-10-11 14:46:25 -070049 printk(BIOS_DEBUG, PREFIX); \
Elyes HAOUASa342f392018-10-17 10:56:26 +020050 printk(BIOS_DEBUG, fmt, ##args); \
Stefan Reinauer3008bbad2011-10-11 14:46:25 -070051 }
Aaron Durbinc4220022013-07-24 16:02:14 -050052#define TPM_DEBUG_IO_READ(reg_, val_) \
53 TPM_DEBUG("Read reg 0x%x returns 0x%x\n", (reg_), (val_))
54#define TPM_DEBUG_IO_WRITE(reg_, val_) \
55 TPM_DEBUG("Write reg 0x%x with 0x%x\n", (reg_), (val_))
Stefan Reinauer3008bbad2011-10-11 14:46:25 -070056#define printf(x...) printk(BIOS_ERR, x)
57
Stefan Reinauer3008bbad2011-10-11 14:46:25 -070058/* coreboot wrapper for TPM driver (end) */
59
Stefan Reinauer3008bbad2011-10-11 14:46:25 -070060/* the macro accepts the locality value, but only locality 0 is operational */
61#define TIS_REG(LOCALITY, REG) \
Martin Rothb9810a42017-07-23 20:00:04 -060062 (void *)(CONFIG_TPM_TIS_BASE_ADDRESS + (LOCALITY << 12) + REG)
Stefan Reinauer3008bbad2011-10-11 14:46:25 -070063
64/* hardware registers' offsets */
65#define TIS_REG_ACCESS 0x0
66#define TIS_REG_INT_ENABLE 0x8
67#define TIS_REG_INT_VECTOR 0xc
68#define TIS_REG_INT_STATUS 0x10
69#define TIS_REG_INTF_CAPABILITY 0x14
70#define TIS_REG_STS 0x18
Aaron Durbinc4220022013-07-24 16:02:14 -050071#define TIS_REG_BURST_COUNT 0x19
Stefan Reinauer3008bbad2011-10-11 14:46:25 -070072#define TIS_REG_DATA_FIFO 0x24
73#define TIS_REG_DID_VID 0xf00
74#define TIS_REG_RID 0xf04
75
76/* Some registers' bit field definitions */
77#define TIS_STS_VALID (1 << 7) /* 0x80 */
78#define TIS_STS_COMMAND_READY (1 << 6) /* 0x40 */
79#define TIS_STS_TPM_GO (1 << 5) /* 0x20 */
80#define TIS_STS_DATA_AVAILABLE (1 << 4) /* 0x10 */
81#define TIS_STS_EXPECT (1 << 3) /* 0x08 */
82#define TIS_STS_RESPONSE_RETRY (1 << 1) /* 0x02 */
83
84#define TIS_ACCESS_TPM_REG_VALID_STS (1 << 7) /* 0x80 */
85#define TIS_ACCESS_ACTIVE_LOCALITY (1 << 5) /* 0x20 */
86#define TIS_ACCESS_BEEN_SEIZED (1 << 4) /* 0x10 */
87#define TIS_ACCESS_SEIZE (1 << 3) /* 0x08 */
88#define TIS_ACCESS_PENDING_REQUEST (1 << 2) /* 0x04 */
89#define TIS_ACCESS_REQUEST_USE (1 << 1) /* 0x02 */
90#define TIS_ACCESS_TPM_ESTABLISHMENT (1 << 0) /* 0x01 */
91
Stefan Reinauer3008bbad2011-10-11 14:46:25 -070092/*
93 * Error value returned if a tpm register does not enter the expected state
94 * after continuous polling. No actual TPM register reading ever returns ~0,
95 * so this value is a safe error indication to be mixed with possible status
96 * register values.
97 */
98#define TPM_TIMEOUT_ERR (~0)
99
100/* Error value returned on various TPM driver errors */
101#define TPM_DRIVER_ERR (~0)
102
103 /* 1 second is plenty for anything TPM does.*/
104#define MAX_DELAY_US (1000 * 1000)
105
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700106/*
107 * Structures defined below allow creating descriptions of TPM vendor/device
108 * ID information for run time discovery. The only device the system knows
109 * about at this time is Infineon slb9635
110 */
111struct device_name {
112 u16 dev_id;
Elyes HAOUASb0b0c8c2018-07-08 12:33:47 +0200113 const char *const dev_name;
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700114};
115
116struct vendor_name {
117 u16 vendor_id;
Elyes HAOUASb0b0c8c2018-07-08 12:33:47 +0200118 const char *vendor_name;
119 const struct device_name *dev_names;
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700120};
121
Stefan Reinauerc908fc72012-04-30 16:33:44 -0700122static const struct device_name atmel_devices[] = {
123 {0x3204, "AT97SC3204"},
124 {0xffff}
125};
126
Stefan Reinauerc668af72011-10-27 21:28:25 +0000127static const struct device_name infineon_devices[] = {
Stefan Reinauerc908fc72012-04-30 16:33:44 -0700128 {0x000b, "SLB9635 TT 1.2"},
Subrata Banik5b8c4a72016-11-11 09:28:45 +0530129#if IS_ENABLED(CONFIG_TPM2)
Kamil Wcislobf5ccfd2017-10-12 13:12:11 +0200130 {0x001a, "SLB9665 TT 2.0"},
Subrata Banik5b8c4a72016-11-11 09:28:45 +0530131 {0x001b, "SLB9670 TT 2.0"},
132#else
Kamil Wcislobf5ccfd2017-10-12 13:12:11 +0200133 {0x001a, "SLB9660 TT 1.2"},
Wenkai Du641529b2015-05-29 10:54:27 -0700134 {0x001b, "SLB9670 TT 1.2"},
Subrata Banik5b8c4a72016-11-11 09:28:45 +0530135#endif
Stefan Reinauerc908fc72012-04-30 16:33:44 -0700136 {0xffff}
137};
138
139static const struct device_name nuvoton_devices[] = {
140 {0x00fe, "NPCT420AA V2"},
141 {0xffff}
142};
143
144static const struct device_name stmicro_devices[] = {
145 {0x0000, "ST33ZP24" },
146 {0xffff}
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700147};
148
149static const struct vendor_name vendor_names[] = {
Stefan Reinauerc908fc72012-04-30 16:33:44 -0700150 {0x1114, "Atmel", atmel_devices},
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700151 {0x15d1, "Infineon", infineon_devices},
Stefan Reinauerc908fc72012-04-30 16:33:44 -0700152 {0x1050, "Nuvoton", nuvoton_devices},
153 {0x104a, "ST Microelectronics", stmicro_devices},
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700154};
155
156/*
157 * Cached vendor/device ID pair to indicate that the device has been already
158 * discovered
159 */
Stefan Reinauerc668af72011-10-27 21:28:25 +0000160static u32 vendor_dev_id CAR_GLOBAL;
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700161
Aaron Durbinc4220022013-07-24 16:02:14 -0500162static inline u8 tpm_read_status(int locality)
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700163{
Julius Werner2f37bd62015-02-19 14:51:15 -0800164 u8 value = read8(TIS_REG(locality, TIS_REG_STS));
Aaron Durbinc4220022013-07-24 16:02:14 -0500165 TPM_DEBUG_IO_READ(TIS_REG_STS, value);
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700166 return value;
167}
168
Aaron Durbinc4220022013-07-24 16:02:14 -0500169static inline void tpm_write_status(u8 sts, int locality)
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700170{
Aaron Durbinc4220022013-07-24 16:02:14 -0500171 TPM_DEBUG_IO_WRITE(TIS_REG_STS, sts);
Julius Werner2f37bd62015-02-19 14:51:15 -0800172 write8(TIS_REG(locality, TIS_REG_STS), sts);
Aaron Durbinc4220022013-07-24 16:02:14 -0500173}
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700174
Aaron Durbinc4220022013-07-24 16:02:14 -0500175static inline u8 tpm_read_data(int locality)
176{
Julius Werner2f37bd62015-02-19 14:51:15 -0800177 u8 value = read8(TIS_REG(locality, TIS_REG_DATA_FIFO));
Aaron Durbinc4220022013-07-24 16:02:14 -0500178 TPM_DEBUG_IO_READ(TIS_REG_DATA_FIFO, value);
179 return value;
180}
181
182static inline void tpm_write_data(u8 data, int locality)
183{
184 TPM_DEBUG_IO_WRITE(TIS_REG_STS, data);
Julius Werner2f37bd62015-02-19 14:51:15 -0800185 write8(TIS_REG(locality, TIS_REG_DATA_FIFO), data);
Aaron Durbinc4220022013-07-24 16:02:14 -0500186}
187
188static inline u16 tpm_read_burst_count(int locality)
189{
190 u16 count;
Julius Werner2f37bd62015-02-19 14:51:15 -0800191 count = read8(TIS_REG(locality, TIS_REG_BURST_COUNT));
192 count |= read8(TIS_REG(locality, TIS_REG_BURST_COUNT + 1)) << 8;
Aaron Durbinc4220022013-07-24 16:02:14 -0500193 TPM_DEBUG_IO_READ(TIS_REG_BURST_COUNT, count);
194 return count;
195}
196
197static inline u8 tpm_read_access(int locality)
198{
Julius Werner2f37bd62015-02-19 14:51:15 -0800199 u8 value = read8(TIS_REG(locality, TIS_REG_ACCESS));
Aaron Durbinc4220022013-07-24 16:02:14 -0500200 TPM_DEBUG_IO_READ(TIS_REG_ACCESS, value);
201 return value;
202}
203
204static inline void tpm_write_access(u8 data, int locality)
205{
206 TPM_DEBUG_IO_WRITE(TIS_REG_ACCESS, data);
Julius Werner2f37bd62015-02-19 14:51:15 -0800207 write8(TIS_REG(locality, TIS_REG_ACCESS), data);
Aaron Durbinc4220022013-07-24 16:02:14 -0500208}
209
210static inline u32 tpm_read_did_vid(int locality)
211{
Julius Werner2f37bd62015-02-19 14:51:15 -0800212 u32 value = read32(TIS_REG(locality, TIS_REG_DID_VID));
Aaron Durbinc4220022013-07-24 16:02:14 -0500213 TPM_DEBUG_IO_READ(TIS_REG_DID_VID, value);
214 return value;
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700215}
216
Duncan Lauriedd281ed2014-10-30 15:20:19 -0700217static inline void tpm_write_int_vector(int vector, int locality)
218{
219 TPM_DEBUG_IO_WRITE(TIS_REG_INT_VECTOR, vector);
Julius Werner2f37bd62015-02-19 14:51:15 -0800220 write8(TIS_REG(locality, TIS_REG_INT_VECTOR), vector & 0xf);
Duncan Lauriedd281ed2014-10-30 15:20:19 -0700221}
222
Naresh G Solanki80ff0382016-11-15 11:01:33 +0530223static inline u8 tpm_read_int_vector(int locality)
224{
225 u8 value = read8(TIS_REG(locality, TIS_REG_INT_VECTOR));
226 TPM_DEBUG_IO_READ(TIS_REG_INT_VECTOR, value);
227 return value;
228}
229
Duncan Lauriedd281ed2014-10-30 15:20:19 -0700230static inline void tpm_write_int_polarity(int polarity, int locality)
231{
232 /* Set polarity and leave all other bits at 0 */
233 u32 value = (polarity & 0x3) << 3;
234 TPM_DEBUG_IO_WRITE(TIS_REG_INT_ENABLE, value);
Julius Werner2f37bd62015-02-19 14:51:15 -0800235 write32(TIS_REG(locality, TIS_REG_INT_ENABLE), value);
Duncan Lauriedd281ed2014-10-30 15:20:19 -0700236}
237
Naresh G Solanki80ff0382016-11-15 11:01:33 +0530238static inline u32 tpm_read_int_polarity(int locality)
239{
240 /* Get polarity and leave all other bits */
241 u32 value = read8(TIS_REG(locality, TIS_REG_INT_ENABLE));
242 value = (value >> 3) & 0x3;
243 TPM_DEBUG_IO_READ(TIS_REG_INT_ENABLE, value);
244 return value;
245}
246
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700247/*
Aaron Durbinc4220022013-07-24 16:02:14 -0500248 * tis_wait_sts()
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700249 *
Aaron Durbinc4220022013-07-24 16:02:14 -0500250 * Wait for at least a second for a status to change its state to match the
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700251 * expected state. Normally the transition happens within microseconds.
252 *
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700253 * @locality - locality
254 * @mask - bitmask for the bitfield(s) to watch
255 * @expected - value the field(s) are supposed to be set to
256 *
Aaron Durbinc4220022013-07-24 16:02:14 -0500257 * Returns 0 on success or TPM_TIMEOUT_ERR on timeout.
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700258 */
Aaron Durbinc4220022013-07-24 16:02:14 -0500259static int tis_wait_sts(int locality, u8 mask, u8 expected)
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700260{
261 u32 time_us = MAX_DELAY_US;
262 while (time_us > 0) {
Aaron Durbinc4220022013-07-24 16:02:14 -0500263 u8 value = tpm_read_status(locality);
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700264 if ((value & mask) == expected)
Aaron Durbinc4220022013-07-24 16:02:14 -0500265 return 0;
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700266 udelay(1); /* 1 us */
267 time_us--;
268 }
269 return TPM_TIMEOUT_ERR;
270}
271
Aaron Durbinc4220022013-07-24 16:02:14 -0500272static inline int tis_wait_ready(int locality)
273{
274 return tis_wait_sts(locality, TIS_STS_COMMAND_READY,
275 TIS_STS_COMMAND_READY);
276}
277
278static inline int tis_wait_valid(int locality)
279{
280 return tis_wait_sts(locality, TIS_STS_VALID, TIS_STS_VALID);
281}
282
283static inline int tis_wait_valid_data(int locality)
284{
285 const u8 has_data = TIS_STS_DATA_AVAILABLE | TIS_STS_VALID;
286 return tis_wait_sts(locality, has_data, has_data);
287}
288
289static inline int tis_has_valid_data(int locality)
290{
291 const u8 has_data = TIS_STS_DATA_AVAILABLE | TIS_STS_VALID;
292 return (tpm_read_status(locality) & has_data) == has_data;
293}
294
295static inline int tis_expect_data(int locality)
296{
297 return !!(tpm_read_status(locality) & TIS_STS_EXPECT);
298}
299
300/*
301 * tis_wait_access()
302 *
303 * Wait for at least a second for a access to change its state to match the
304 * expected state. Normally the transition happens within microseconds.
305 *
306 * @locality - locality
307 * @mask - bitmask for the bitfield(s) to watch
308 * @expected - value the field(s) are supposed to be set to
309 *
310 * Returns 0 on success or TPM_TIMEOUT_ERR on timeout.
311 */
312static int tis_wait_access(int locality, u8 mask, u8 expected)
313{
314 u32 time_us = MAX_DELAY_US;
315 while (time_us > 0) {
316 u8 value = tpm_read_access(locality);
317 if ((value & mask) == expected)
318 return 0;
319 udelay(1); /* 1 us */
320 time_us--;
321 }
322 return TPM_TIMEOUT_ERR;
323}
324
325static inline int tis_wait_dropped_access(int locality)
326{
327 return tis_wait_access(locality, TIS_ACCESS_ACTIVE_LOCALITY, 0);
328}
329
330static inline int tis_wait_received_access(int locality)
331{
332 return tis_wait_access(locality, TIS_ACCESS_ACTIVE_LOCALITY,
333 TIS_ACCESS_ACTIVE_LOCALITY);
334}
335
336static inline int tis_has_access(int locality)
337{
338 return !!(tpm_read_access(locality) & TIS_ACCESS_ACTIVE_LOCALITY);
339}
340
341static inline void tis_request_access(int locality)
342{
343 tpm_write_access(TIS_ACCESS_REQUEST_USE, locality);
344}
345
346static inline void tis_drop_access(int locality)
347{
348 tpm_write_access(TIS_ACCESS_ACTIVE_LOCALITY, locality);
349}
350
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700351/*
Stefan Reinauerc908fc72012-04-30 16:33:44 -0700352 * PC Client Specific TPM Interface Specification section 11.2.12:
353 *
354 * Software must be prepared to send two writes of a "1" to command ready
355 * field: the first to indicate successful read of all the data, thus
356 * clearing the data from the ReadFIFO and freeing the TPM's resources,
357 * and the second to indicate to the TPM it is about to send a new command.
358 *
359 * In practice not all TPMs behave the same so it is necessary to be
360 * flexible when trying to set command ready.
361 *
362 * Returns 0 on success if the TPM is ready for transactions.
363 * Returns TPM_TIMEOUT_ERR if the command ready bit does not get set.
364 */
365static int tis_command_ready(u8 locality)
366{
367 u32 status;
368
369 /* 1st attempt to set command ready */
Aaron Durbinc4220022013-07-24 16:02:14 -0500370 tpm_write_status(TIS_STS_COMMAND_READY, locality);
Stefan Reinauerc908fc72012-04-30 16:33:44 -0700371
372 /* Wait for response */
Aaron Durbinc4220022013-07-24 16:02:14 -0500373 status = tpm_read_status(locality);
Stefan Reinauerc908fc72012-04-30 16:33:44 -0700374
375 /* Check if command ready is set yet */
376 if (status & TIS_STS_COMMAND_READY)
377 return 0;
378
379 /* 2nd attempt to set command ready */
Aaron Durbinc4220022013-07-24 16:02:14 -0500380 tpm_write_status(TIS_STS_COMMAND_READY, locality);
Stefan Reinauerc908fc72012-04-30 16:33:44 -0700381
Aaron Durbinc4220022013-07-24 16:02:14 -0500382 return tis_wait_ready(locality);
Stefan Reinauerc908fc72012-04-30 16:33:44 -0700383}
384
385/*
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700386 * Probe the TPM device and try determining its manufacturer/device name.
387 *
388 * Returns 0 on success (the device is found or was found during an earlier
389 * invocation) or TPM_DRIVER_ERR if the device is not found.
390 */
391static u32 tis_probe(void)
392{
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700393 const char *device_name = "unknown";
394 const char *vendor_name = device_name;
Stefan Reinauerc908fc72012-04-30 16:33:44 -0700395 const struct device_name *dev;
396 u32 didvid;
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700397 u16 vid, did;
Stefan Reinauerc908fc72012-04-30 16:33:44 -0700398 int i;
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700399
Aaron Durbincb997d32013-05-10 00:40:56 -0500400 if (car_get_var(vendor_dev_id))
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700401 return 0; /* Already probed. */
402
Aaron Durbinc4220022013-07-24 16:02:14 -0500403 didvid = tpm_read_did_vid(0);
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700404 if (!didvid || (didvid == 0xffffffff)) {
405 printf("%s: No TPM device found\n", __FUNCTION__);
406 return TPM_DRIVER_ERR;
407 }
408
Aaron Durbincb997d32013-05-10 00:40:56 -0500409 car_set_var(vendor_dev_id, didvid);
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700410
411 vid = didvid & 0xffff;
412 did = (didvid >> 16) & 0xffff;
413 for (i = 0; i < ARRAY_SIZE(vendor_names); i++) {
414 int j = 0;
415 u16 known_did;
416 if (vid == vendor_names[i].vendor_id) {
417 vendor_name = vendor_names[i].vendor_name;
Stefan Reinauerc908fc72012-04-30 16:33:44 -0700418 } else {
419 continue;
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700420 }
Stefan Reinauerc908fc72012-04-30 16:33:44 -0700421 dev = &vendor_names[i].dev_names[j];
422 while ((known_did = dev->dev_id) != 0xffff) {
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700423 if (known_did == did) {
Stefan Reinauerc908fc72012-04-30 16:33:44 -0700424 device_name = dev->dev_name;
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700425 break;
426 }
427 j++;
Subrata41b08d92015-05-14 14:38:07 +0530428 dev = &vendor_names[i].dev_names[j];
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700429 }
430 break;
431 }
432 /* this will have to be converted into debug printout */
Duncan Laurie17ba9442015-09-03 16:00:49 -0700433 printk(BIOS_INFO, "Found TPM %s by %s\n", device_name, vendor_name);
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700434 return 0;
435}
436
437/*
438 * tis_senddata()
439 *
440 * send the passed in data to the TPM device.
441 *
442 * @data - address of the data to send, byte by byte
443 * @len - length of the data to send
444 *
445 * Returns 0 on success, TPM_DRIVER_ERR on error (in case the device does
446 * not accept the entire command).
447 */
Elyes HAOUASb0b0c8c2018-07-08 12:33:47 +0200448static u32 tis_senddata(const u8 *const data, u32 len)
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700449{
450 u32 offset = 0;
451 u16 burst = 0;
452 u32 max_cycles = 0;
453 u8 locality = 0;
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700454
Aaron Durbinc4220022013-07-24 16:02:14 -0500455 if (tis_wait_ready(locality)) {
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700456 printf("%s:%d - failed to get 'command_ready' status\n",
457 __FILE__, __LINE__);
458 return TPM_DRIVER_ERR;
459 }
Aaron Durbinc4220022013-07-24 16:02:14 -0500460 burst = tpm_read_burst_count(locality);
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700461
462 while (1) {
463 unsigned count;
464
465 /* Wait till the device is ready to accept more data. */
466 while (!burst) {
467 if (max_cycles++ == MAX_DELAY_US) {
468 printf("%s:%d failed to feed %d bytes of %d\n",
469 __FILE__, __LINE__, len - offset, len);
470 return TPM_DRIVER_ERR;
471 }
472 udelay(1);
Aaron Durbinc4220022013-07-24 16:02:14 -0500473 burst = tpm_read_burst_count(locality);
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700474 }
475
476 max_cycles = 0;
477
478 /*
479 * Calculate number of bytes the TPM is ready to accept in one
480 * shot.
481 *
482 * We want to send the last byte outside of the loop (hence
483 * the -1 below) to make sure that the 'expected' status bit
484 * changes to zero exactly after the last byte is fed into the
485 * FIFO.
486 */
487 count = min(burst, len - offset - 1);
488 while (count--)
Aaron Durbinc4220022013-07-24 16:02:14 -0500489 tpm_write_data(data[offset++], locality);
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700490
Aaron Durbinc4220022013-07-24 16:02:14 -0500491 if (tis_wait_valid(locality) || !tis_expect_data(locality)) {
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700492 printf("%s:%d TPM command feed overflow\n",
493 __FILE__, __LINE__);
494 return TPM_DRIVER_ERR;
495 }
496
Aaron Durbinc4220022013-07-24 16:02:14 -0500497 burst = tpm_read_burst_count(locality);
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700498 if ((offset == (len - 1)) && burst)
499 /*
500 * We need to be able to send the last byte to the
501 * device, so burst size must be nonzero before we
502 * break out.
503 */
504 break;
505 }
506
507 /* Send the last byte. */
Aaron Durbinc4220022013-07-24 16:02:14 -0500508 tpm_write_data(data[offset++], locality);
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700509
510 /*
511 * Verify that TPM does not expect any more data as part of this
512 * command.
513 */
Aaron Durbinc4220022013-07-24 16:02:14 -0500514 if (tis_wait_valid(locality) || tis_expect_data(locality)) {
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700515 printf("%s:%d unexpected TPM status 0x%x\n",
Aaron Durbinc4220022013-07-24 16:02:14 -0500516 __FILE__, __LINE__, tpm_read_status(locality));
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700517 return TPM_DRIVER_ERR;
518 }
519
520 /* OK, sitting pretty, let's start the command execution. */
Aaron Durbinc4220022013-07-24 16:02:14 -0500521 tpm_write_status(TIS_STS_TPM_GO, locality);
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700522
523 return 0;
524}
525
526/*
527 * tis_readresponse()
528 *
529 * read the TPM device response after a command was issued.
530 *
531 * @buffer - address where to read the response, byte by byte.
532 * @len - pointer to the size of buffer
533 *
534 * On success stores the number of received bytes to len and returns 0. On
535 * errors (misformatted TPM data or synchronization problems) returns
536 * TPM_DRIVER_ERR.
537 */
538static u32 tis_readresponse(u8 *buffer, size_t *len)
539{
540 u16 burst_count;
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700541 u32 offset = 0;
542 u8 locality = 0;
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700543 u32 expected_count = *len;
544 int max_cycles = 0;
545
546 /* Wait for the TPM to process the command */
Aaron Durbinc4220022013-07-24 16:02:14 -0500547 if (tis_wait_valid_data(locality)) {
548 printf("%s:%d failed processing command\n", __FILE__, __LINE__);
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700549 return TPM_DRIVER_ERR;
550 }
551
552 do {
Aaron Durbinc4220022013-07-24 16:02:14 -0500553 while ((burst_count = tpm_read_burst_count(locality)) == 0) {
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700554 if (max_cycles++ == MAX_DELAY_US) {
555 printf("%s:%d TPM stuck on read\n",
556 __FILE__, __LINE__);
557 return TPM_DRIVER_ERR;
558 }
559 udelay(1);
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700560 }
561
562 max_cycles = 0;
563
564 while (burst_count-- && (offset < expected_count)) {
Aaron Durbinc4220022013-07-24 16:02:14 -0500565 buffer[offset++] = tpm_read_data(locality);
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700566 if (offset == 6) {
567 /*
568 * We got the first six bytes of the reply,
569 * let's figure out how many bytes to expect
570 * total - it is stored as a 4 byte number in
571 * network order, starting with offset 2 into
572 * the body of the reply.
573 */
574 u32 real_length;
575 memcpy(&real_length,
576 buffer + 2,
577 sizeof(real_length));
578 expected_count = be32_to_cpu(real_length);
579
580 if ((expected_count < offset) ||
581 (expected_count > *len)) {
582 printf("%s:%d bad response size %d\n",
583 __FILE__, __LINE__,
584 expected_count);
585 return TPM_DRIVER_ERR;
586 }
587 }
588 }
589
590 /* Wait for the next portion */
Aaron Durbinc4220022013-07-24 16:02:14 -0500591 if (tis_wait_valid(locality)) {
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700592 printf("%s:%d failed to read response\n",
593 __FILE__, __LINE__);
594 return TPM_DRIVER_ERR;
595 }
596
597 if (offset == expected_count)
598 break; /* We got all we need */
599
Bill XIEa4bf0b72018-03-22 17:07:43 +0800600 /*
601 * Certain TPMs seem to need some delay between tis_wait_valid()
602 * and tis_has_valid_data(), or some race-condition-related
603 * issue will occur.
604 */
605 if (IS_ENABLED(CONFIG_TPM_RDRESP_NEED_DELAY))
606 udelay(10);
607
Aaron Durbinc4220022013-07-24 16:02:14 -0500608 } while (tis_has_valid_data(locality));
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700609
Aaron Durbinc4220022013-07-24 16:02:14 -0500610 /* * Make sure we indeed read all there was. */
611 if (tis_has_valid_data(locality)) {
612 printf("%s:%d wrong receive status: %x %d bytes left\n",
613 __FILE__, __LINE__, tpm_read_status(locality),
614 tpm_read_burst_count(locality));
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700615 return TPM_DRIVER_ERR;
616 }
617
618 /* Tell the TPM that we are done. */
Stefan Reinauerc908fc72012-04-30 16:33:44 -0700619 if (tis_command_ready(locality) == TPM_TIMEOUT_ERR)
620 return TPM_DRIVER_ERR;
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700621
622 *len = offset;
623 return 0;
624}
625
626/*
627 * tis_init()
628 *
629 * Initialize the TPM device. Returns 0 on success or TPM_DRIVER_ERR on
630 * failure (in case device probing did not succeed).
631 */
632int tis_init(void)
633{
634 if (tis_probe())
635 return TPM_DRIVER_ERR;
636 return 0;
637}
638
639/*
640 * tis_open()
641 *
642 * Requests access to locality 0 for the caller. After all commands have been
643 * completed the caller is supposed to call tis_close().
644 *
645 * Returns 0 on success, TPM_DRIVER_ERR on failure.
646 */
647int tis_open(void)
648{
649 u8 locality = 0; /* we use locality zero for everything */
650
651 if (tis_close())
652 return TPM_DRIVER_ERR;
653
654 /* now request access to locality */
Aaron Durbinc4220022013-07-24 16:02:14 -0500655 tis_request_access(locality);
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700656
657 /* did we get a lock? */
Aaron Durbinc4220022013-07-24 16:02:14 -0500658 if (tis_wait_received_access(locality)) {
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700659 printf("%s:%d - failed to lock locality %d\n",
660 __FILE__, __LINE__, locality);
661 return TPM_DRIVER_ERR;
662 }
663
Stefan Reinauerc908fc72012-04-30 16:33:44 -0700664 /* Certain TPMs seem to need some delay here or they hang... */
665 udelay(10);
666
667 if (tis_command_ready(locality) == TPM_TIMEOUT_ERR)
668 return TPM_DRIVER_ERR;
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700669
670 return 0;
671}
672
673/*
674 * tis_close()
675 *
Martin Roth56889792013-07-09 21:39:46 -0600676 * terminate the current session with the TPM by releasing the locked
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700677 * locality. Returns 0 on success of TPM_DRIVER_ERR on failure (in case lock
678 * removal did not succeed).
679 */
680int tis_close(void)
681{
682 u8 locality = 0;
Aaron Durbinc4220022013-07-24 16:02:14 -0500683 if (tis_has_access(locality)) {
684 tis_drop_access(locality);
685 if (tis_wait_dropped_access(locality)) {
Stefan Reinauer3008bbad2011-10-11 14:46:25 -0700686 printf("%s:%d - failed to release locality %d\n",
687 __FILE__, __LINE__, locality);
688 return TPM_DRIVER_ERR;
689 }
690 }
691 return 0;
692}
693
694/*
695 * tis_sendrecv()
696 *
697 * Send the requested data to the TPM and then try to get its response
698 *
699 * @sendbuf - buffer of the data to send
700 * @send_size size of the data to send
701 * @recvbuf - memory to save the response to
702 * @recv_len - pointer to the size of the response buffer
703 *
704 * Returns 0 on success (and places the number of response bytes at recv_len)
705 * or TPM_DRIVER_ERR on failure.
706 */
707int tis_sendrecv(const uint8_t *sendbuf, size_t send_size,
708 uint8_t *recvbuf, size_t *recv_len)
709{
710 if (tis_senddata(sendbuf, send_size)) {
711 printf("%s:%d failed sending data to TPM\n",
712 __FILE__, __LINE__);
713 return TPM_DRIVER_ERR;
714 }
715
716 return tis_readresponse(recvbuf, recv_len);
717}
Duncan Lauriedd281ed2014-10-30 15:20:19 -0700718
719#ifdef __RAMSTAGE__
720
721/*
722 * tis_setup_interrupt()
723 *
724 * Set up the interrupt vector and polarity for locality 0 and
725 * disable all interrupts so they are unused in firmware but can
726 * be enabled by the OS.
727 *
728 * The values used here must match what is passed in the TPM ACPI
729 * device if ACPI is used on the platform.
730 *
731 * @vector - TPM interrupt vector
732 * @polarity - TPM interrupt polarity
733 *
734 * Returns 0 on success, TPM_DRIVER_ERR on failure.
735 */
736static int tis_setup_interrupt(int vector, int polarity)
737{
738 u8 locality = 0;
739 int has_access = tis_has_access(locality);
740
741 /* Open connection and request access if not already granted */
742 if (!has_access && tis_open() < 0)
743 return TPM_DRIVER_ERR;
744
745 /* Set TPM interrupt vector */
746 tpm_write_int_vector(vector, locality);
747
Elyes HAOUAS18958382018-08-07 12:23:16 +0200748 /* Set TPM interrupt polarity and disable interrupts */
Duncan Lauriedd281ed2014-10-30 15:20:19 -0700749 tpm_write_int_polarity(polarity, locality);
750
751 /* Close connection if it was opened */
752 if (!has_access && tis_close() < 0)
753 return TPM_DRIVER_ERR;
754
755 return 0;
756}
757
758static void lpc_tpm_read_resources(struct device *dev)
759{
760 /* Static 5K memory region specified in Kconfig */
761 mmio_resource(dev, 0, CONFIG_TPM_TIS_BASE_ADDRESS >> 10, 0x5000 >> 10);
762}
763
764static void lpc_tpm_set_resources(struct device *dev)
765{
766 tpm_config_t *config = (tpm_config_t *)dev->chip_info;
767 struct resource *res;
768
769 for (res = dev->resource_list; res; res = res->next) {
770 if (!(res->flags & IORESOURCE_ASSIGNED))
771 continue;
772
773 if (res->flags & IORESOURCE_IRQ) {
774 /* Set interrupt vector */
775 tis_setup_interrupt((int)res->base,
776 config->irq_polarity);
777 } else {
Duncan Lauriedd281ed2014-10-30 15:20:19 -0700778 continue;
779 }
780
781 res->flags |= IORESOURCE_STORED;
782 report_resource_stored(dev, res, " <tpm>");
783 }
784}
785
Naresh G Solanki80ff0382016-11-15 11:01:33 +0530786#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
787
788static void tpm_ppi_func0_cb(void *arg)
789{
790 /* Functions 1-8. */
791 u8 buf[] = {0xff, 0x01};
792 acpigen_write_return_byte_buffer(buf, 2);
793}
794
795static void tpm_ppi_func1_cb(void *arg)
796{
797 if (IS_ENABLED(CONFIG_TPM2))
798 /* Interface version: 2.0 */
799 acpigen_write_return_string("2.0");
800 else
801 /* Interface version: 1.2 */
802 acpigen_write_return_string("1.2");
803}
804
805static void tpm_ppi_func2_cb(void *arg)
806{
807 /* Submit operations: drop on the floor and return success. */
808 acpigen_write_return_byte(0);
809}
810
811static void tpm_ppi_func3_cb(void *arg)
812{
813 /* Pending operation: none. */
814 acpigen_emit_byte(RETURN_OP);
815 acpigen_write_package(2);
816 acpigen_write_byte(0);
817 acpigen_write_byte(0);
818 acpigen_pop_len();
819}
820static void tpm_ppi_func4_cb(void *arg)
821{
822 /* Pre-OS transition method: reboot. */
823 acpigen_write_return_byte(2);
824}
825static void tpm_ppi_func5_cb(void *arg)
826{
827 /* Operation response: no operation executed. */
828 acpigen_emit_byte(RETURN_OP);
829 acpigen_write_package(3);
830 acpigen_write_byte(0);
831 acpigen_write_byte(0);
832 acpigen_write_byte(0);
833 acpigen_pop_len();
834}
835static void tpm_ppi_func6_cb(void *arg)
836{
837 /*
838 * Set preferred user language: deprecated and must return 3 aka
839 * "not implemented".
840 */
841 acpigen_write_return_byte(3);
842}
843static void tpm_ppi_func7_cb(void *arg)
844{
845 /* Submit operations: deny. */
846 acpigen_write_return_byte(3);
847}
848static void tpm_ppi_func8_cb(void *arg)
849{
850 /* All actions are forbidden. */
851 acpigen_write_return_byte(1);
852}
853static void (*tpm_ppi_callbacks[])(void *) = {
854 tpm_ppi_func0_cb,
855 tpm_ppi_func1_cb,
856 tpm_ppi_func2_cb,
857 tpm_ppi_func3_cb,
858 tpm_ppi_func4_cb,
859 tpm_ppi_func5_cb,
860 tpm_ppi_func6_cb,
861 tpm_ppi_func7_cb,
862 tpm_ppi_func8_cb,
863};
864
865static void tpm_mci_func0_cb(void *arg)
866{
867 /* Function 1. */
868 acpigen_write_return_singleton_buffer(0x3);
869}
870static void tpm_mci_func1_cb(void *arg)
871{
872 /* Just return success. */
873 acpigen_write_return_byte(0);
874}
875
876static void (*tpm_mci_callbacks[])(void *) = {
877 tpm_mci_func0_cb,
878 tpm_mci_func1_cb,
879};
880
881static void lpc_tpm_fill_ssdt(struct device *dev)
882{
883 const char *path = acpi_device_path(dev->bus->dev);
884 u32 arg;
Naresh G Solanki80ff0382016-11-15 11:01:33 +0530885
Philipp Deppenwiese3a1fbea2016-12-14 01:06:55 +0100886 if (!path) {
Tobias Diedrich36537f12017-02-10 00:28:45 +0100887 path = "\\_SB_.PCI0.LPCB";
Philipp Deppenwiese3a1fbea2016-12-14 01:06:55 +0100888 printk(BIOS_DEBUG, "Using default TPM ACPI path: '%s'\n", path);
889 }
Naresh G Solanki80ff0382016-11-15 11:01:33 +0530890
891 /* Device */
892 acpigen_write_scope(path);
893 acpigen_write_device(acpi_device_name(dev));
894
895 acpigen_write_name("_HID");
896 acpigen_emit_eisaid("PNP0C31");
897
898 acpigen_write_name("_CID");
899 acpigen_emit_eisaid("PNP0C31");
900
901 acpigen_write_name_integer("_UID", 1);
902
Naresh G Solanki80ff0382016-11-15 11:01:33 +0530903 u32 did_vid = tpm_read_did_vid(0);
904 if (did_vid > 0 && did_vid < 0xffffffff)
905 acpigen_write_STA(ACPI_STATUS_DEVICE_ALL_ON);
906 else
907 acpigen_write_STA(ACPI_STATUS_DEVICE_ALL_OFF);
908
Kevin Cody-Littlec97b5af2018-05-09 14:14:59 -0400909 u16 port = dev->path.pnp.port;
910
Naresh G Solanki80ff0382016-11-15 11:01:33 +0530911 /* Resources */
912 acpigen_write_name("_CRS");
913 acpigen_write_resourcetemplate_header();
914 acpigen_write_mem32fixed(1, CONFIG_TPM_TIS_BASE_ADDRESS, 0x5000);
Frans Hendriks6cc937e2018-10-29 14:30:58 +0100915 if (port)
916 acpigen_write_io16(port, port, 1, 2, 1);
Naresh G Solanki80ff0382016-11-15 11:01:33 +0530917
918 if (CONFIG_TPM_PIRQ) {
919 /*
920 * PIRQ: Update interrupt vector with configured PIRQ
921 * Active-Low Level-Triggered Shared
922 */
Furquan Shaikh5b9b5932017-02-21 13:16:30 -0800923 struct acpi_irq tpm_irq_a = ACPI_IRQ_LEVEL_LOW(CONFIG_TPM_PIRQ);
Naresh G Solanki80ff0382016-11-15 11:01:33 +0530924 acpi_device_write_interrupt(&tpm_irq_a);
925 } else if (tpm_read_int_vector(0) > 0) {
926 u8 int_vec = tpm_read_int_vector(0);
927 u8 int_pol = tpm_read_int_polarity(0);
Furquan Shaikh5b9b5932017-02-21 13:16:30 -0800928 struct acpi_irq tpm_irq = ACPI_IRQ_LEVEL_LOW(int_vec);
Naresh G Solanki80ff0382016-11-15 11:01:33 +0530929
930 if (int_pol & 1)
Furquan Shaikh5b9b5932017-02-21 13:16:30 -0800931 tpm_irq.polarity = ACPI_IRQ_ACTIVE_LOW;
Naresh G Solanki80ff0382016-11-15 11:01:33 +0530932 else
Furquan Shaikh5b9b5932017-02-21 13:16:30 -0800933 tpm_irq.polarity = ACPI_IRQ_ACTIVE_HIGH;
Naresh G Solanki80ff0382016-11-15 11:01:33 +0530934
935 if (int_pol & 2)
Furquan Shaikh5b9b5932017-02-21 13:16:30 -0800936 tpm_irq.mode = ACPI_IRQ_EDGE_TRIGGERED;
Naresh G Solanki80ff0382016-11-15 11:01:33 +0530937 else
Furquan Shaikh5b9b5932017-02-21 13:16:30 -0800938 tpm_irq.mode = ACPI_IRQ_LEVEL_TRIGGERED;
Naresh G Solanki80ff0382016-11-15 11:01:33 +0530939
940 acpi_device_write_interrupt(&tpm_irq);
941 }
942
943 acpigen_write_resourcetemplate_footer();
944
945 if (!IS_ENABLED(CONFIG_CHROMEOS)) {
946 /*
947 * _DSM method
948 */
949 struct dsm_uuid ids[] = {
950 /* Physical presence interface.
951 * This is used to submit commands like "Clear TPM" to
952 * be run at next reboot provided that user confirms
953 * them. Spec allows user to cancel all commands and/or
954 * configure BIOS to reject commands. So we pretend that
955 * user did just this: cancelled everything. If user
956 * really wants to clear TPM the only option now is to
957 * do it manually in payload.
958 */
959 DSM_UUID(TPM_PPI_UUID, &tpm_ppi_callbacks[0],
960 ARRAY_SIZE(tpm_ppi_callbacks), (void *) &arg),
961 /* Memory clearing on boot: just a dummy. */
962 DSM_UUID(TPM_MCI_UUID, &tpm_mci_callbacks[0],
963 ARRAY_SIZE(tpm_mci_callbacks), (void *) &arg),
964 };
965
966 acpigen_write_dsm_uuid_arr(ids, ARRAY_SIZE(ids));
967 }
968 acpigen_pop_len(); /* Device */
969 acpigen_pop_len(); /* Scope */
970
971 printk(BIOS_INFO, "%s.%s: %s %s\n", path, acpi_device_name(dev),
972 dev->chip_ops->name, dev_path(dev));
973}
974
Aaron Durbinaa090cb2017-09-13 16:01:52 -0600975static const char *lpc_tpm_acpi_name(const struct device *dev)
Naresh G Solanki80ff0382016-11-15 11:01:33 +0530976{
977 return "TPM";
978}
979#endif
980
Duncan Lauriedd281ed2014-10-30 15:20:19 -0700981static struct device_operations lpc_tpm_ops = {
Elyes HAOUAS2aa3b162018-11-27 17:02:10 +0100982 .read_resources = lpc_tpm_read_resources,
983 .set_resources = lpc_tpm_set_resources,
Naresh G Solanki80ff0382016-11-15 11:01:33 +0530984#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
Elyes HAOUAS2aa3b162018-11-27 17:02:10 +0100985 .acpi_name = lpc_tpm_acpi_name,
986 .acpi_fill_ssdt_generator = lpc_tpm_fill_ssdt,
Naresh G Solanki80ff0382016-11-15 11:01:33 +0530987#endif
Duncan Lauriedd281ed2014-10-30 15:20:19 -0700988};
989
990static struct pnp_info pnp_dev_info[] = {
991 { .flags = PNP_IRQ0 }
992};
993
994static void enable_dev(struct device *dev)
995{
996 pnp_enable_devices(dev, &lpc_tpm_ops,
997 ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
998}
999
1000struct chip_operations drivers_pc80_tpm_ops = {
1001 CHIP_NAME("LPC TPM")
1002 .enable_dev = enable_dev
1003};
1004
1005#endif /* __RAMSTAGE__ */