23 #include <linux/slab.h>
76 if ((*data & mask) == val)
84 if ((*data & mask) == val)
92 static int nsc_wait_for_ready(
struct tpm_chip *chip)
109 if (status & NSC_STATUS_OBF)
111 if (status & NSC_STATUS_RDY)
137 dev_err(chip->
dev,
"not in normal mode (0x%x)\n",
143 for (p = buffer; p < &buffer[
count]; p++) {
145 (chip, NSC_STATUS_OBF, NSC_STATUS_OBF, &data) < 0) {
147 "OBF timeout (while reading data)\n");
156 (wait_for_stat(chip, NSC_STATUS_F0, NSC_STATUS_F0, &data) < 0)) {
162 "expected end of command(0x%x)\n", data);
175 static int tpm_nsc_send(
struct tpm_chip *chip,
u8 * buf,
size_t count)
188 if (nsc_wait_for_ready(chip) != 0)
202 for (i = 0; i <
count; i++) {
205 "IBF timeout (while writing data)\n");
220 static void tpm_nsc_cancel(
struct tpm_chip *chip)
244 static struct attribute * nsc_attrs[] = {
245 &dev_attr_pubek.attr,
248 &dev_attr_cancel.attr,
255 .recv = tpm_nsc_recv,
256 .send = tpm_nsc_send,
257 .cancel = tpm_nsc_cancel,
262 .attr_group = &nsc_attr_grp,
263 .miscdev = { .fops = &nsc_ops, },
268 static void tpm_nsc_remove(
struct device *
dev)
287 static int __init init_nsc(
void)
322 pdev->
dev.release = tpm_nsc_remove;
339 "NSC LDN 0x%x, SID 0x%x, SRID 0x%x\n",
340 tpm_read_index(nscAddrBase,0x07), tpm_read_index(nscAddrBase,0x20),
341 tpm_read_index(nscAddrBase,0x27));
343 "NSC SIOCF1 0x%x SIOCF5 0x%x SIOCF6 0x%x SIOCF8 0x%x\n",
344 tpm_read_index(nscAddrBase,0x21), tpm_read_index(nscAddrBase,0x25),
345 tpm_read_index(nscAddrBase,0x26), tpm_read_index(nscAddrBase,0x28));
347 (tpm_read_index(nscAddrBase,0x60) << 8) | tpm_read_index(nscAddrBase,0x61));
349 (tpm_read_index(nscAddrBase,0x62) << 8) | tpm_read_index(nscAddrBase,0x63));
350 dev_dbg(&pdev->
dev,
"NSC Interrupt number and wakeup 0x%x\n",
351 tpm_read_index(nscAddrBase,0x70));
352 dev_dbg(&pdev->
dev,
"NSC IRQ type select 0x%x\n",
353 tpm_read_index(nscAddrBase,0x71));
355 "NSC DMA channel select0 0x%x, select1 0x%x\n",
356 tpm_read_index(nscAddrBase,0x74), tpm_read_index(nscAddrBase,0x75));
359 "0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
360 tpm_read_index(nscAddrBase,0xF0), tpm_read_index(nscAddrBase,0xF1),
361 tpm_read_index(nscAddrBase,0xF2), tpm_read_index(nscAddrBase,0xF3),
362 tpm_read_index(nscAddrBase,0xF4), tpm_read_index(nscAddrBase,0xF5),
363 tpm_read_index(nscAddrBase,0xF6), tpm_read_index(nscAddrBase,0xF7),
364 tpm_read_index(nscAddrBase,0xF8), tpm_read_index(nscAddrBase,0xF9));
367 "NSC TPM revision %d\n",
368 tpm_read_index(nscAddrBase, 0x27) & 0x1F);
385 static void __exit cleanup_nsc(
void)
388 tpm_nsc_remove(&pdev->
dev);