1*b886d83cSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only 21da177e4SLinus Torvalds /* 31da177e4SLinus Torvalds * Copyright (C) 2004 IBM Corporation 41da177e4SLinus Torvalds * 51da177e4SLinus Torvalds * Authors: 61da177e4SLinus Torvalds * Leendert van Doorn <leendert@watson.ibm.com> 71da177e4SLinus Torvalds * Dave Safford <safford@watson.ibm.com> 81da177e4SLinus Torvalds * Reiner Sailer <sailer@watson.ibm.com> 91da177e4SLinus Torvalds * Kylene Hall <kjhall@us.ibm.com> 101da177e4SLinus Torvalds * 118e81cc13SKent Yoder * Maintained by: <tpmdd-devel@lists.sourceforge.net> 121da177e4SLinus Torvalds * 131da177e4SLinus Torvalds * Device driver for TCG/TCPA TPM (trusted platform module). 141da177e4SLinus Torvalds * Specifications at www.trustedcomputinggroup.org 151da177e4SLinus Torvalds */ 161da177e4SLinus Torvalds 17faba278fSChris Wright #include <linux/platform_device.h> 185a0e3ad6STejun Heo #include <linux/slab.h> 191da177e4SLinus Torvalds #include "tpm.h" 201da177e4SLinus Torvalds 211da177e4SLinus Torvalds /* National definitions */ 223122a88aSKylene Hall enum tpm_nsc_addr{ 23e1a23c66SKylene Hall TPM_NSC_IRQ = 0x07, 24e1a23c66SKylene Hall TPM_NSC_BASE0_HI = 0x60, 25e1a23c66SKylene Hall TPM_NSC_BASE0_LO = 0x61, 26e1a23c66SKylene Hall TPM_NSC_BASE1_HI = 0x62, 27e1a23c66SKylene Hall TPM_NSC_BASE1_LO = 0x63 283122a88aSKylene Hall }; 291da177e4SLinus Torvalds 303122a88aSKylene Hall enum tpm_nsc_index { 313122a88aSKylene Hall NSC_LDN_INDEX = 0x07, 323122a88aSKylene Hall NSC_SID_INDEX = 0x20, 333122a88aSKylene Hall NSC_LDC_INDEX = 0x30, 343122a88aSKylene Hall NSC_DIO_INDEX = 0x60, 353122a88aSKylene Hall NSC_CIO_INDEX = 0x62, 363122a88aSKylene Hall NSC_IRQ_INDEX = 0x70, 373122a88aSKylene Hall NSC_ITS_INDEX = 0x71 383122a88aSKylene Hall }; 391da177e4SLinus Torvalds 403122a88aSKylene Hall enum tpm_nsc_status_loc { 413122a88aSKylene Hall NSC_STATUS = 0x01, 423122a88aSKylene Hall NSC_COMMAND = 0x01, 433122a88aSKylene Hall NSC_DATA = 0x00 443122a88aSKylene Hall }; 451da177e4SLinus Torvalds 461da177e4SLinus Torvalds /* status bits */ 473122a88aSKylene Hall enum tpm_nsc_status { 483122a88aSKylene Hall NSC_STATUS_OBF = 0x01, /* output buffer full */ 493122a88aSKylene Hall NSC_STATUS_IBF = 0x02, /* input buffer full */ 503122a88aSKylene Hall NSC_STATUS_F0 = 0x04, /* F0 */ 513122a88aSKylene Hall NSC_STATUS_A2 = 0x08, /* A2 */ 523122a88aSKylene Hall NSC_STATUS_RDY = 0x10, /* ready to receive command */ 533122a88aSKylene Hall NSC_STATUS_IBR = 0x20 /* ready to receive data */ 543122a88aSKylene Hall }; 55daacdfa6SKylene Jo Hall 561da177e4SLinus Torvalds /* command bits */ 573122a88aSKylene Hall enum tpm_nsc_cmd_mode { 583122a88aSKylene Hall NSC_COMMAND_NORMAL = 0x01, /* normal mode */ 593122a88aSKylene Hall NSC_COMMAND_EOC = 0x03, 603122a88aSKylene Hall NSC_COMMAND_CANCEL = 0x22 613122a88aSKylene Hall }; 62ee177984SJarkko Sakkinen 63ee177984SJarkko Sakkinen struct tpm_nsc_priv { 64ee177984SJarkko Sakkinen unsigned long base; 65ee177984SJarkko Sakkinen }; 66ee177984SJarkko Sakkinen 671da177e4SLinus Torvalds /* 681da177e4SLinus Torvalds * Wait for a certain status to appear 691da177e4SLinus Torvalds */ 701da177e4SLinus Torvalds static int wait_for_stat(struct tpm_chip *chip, u8 mask, u8 val, u8 * data) 711da177e4SLinus Torvalds { 729e0d39d8SChristophe Ricard struct tpm_nsc_priv *priv = dev_get_drvdata(&chip->dev); 73700d8bdcSNishanth Aravamudan unsigned long stop; 741da177e4SLinus Torvalds 751da177e4SLinus Torvalds /* status immediately available check */ 769e0d39d8SChristophe Ricard *data = inb(priv->base + NSC_STATUS); 771da177e4SLinus Torvalds if ((*data & mask) == val) 781da177e4SLinus Torvalds return 0; 791da177e4SLinus Torvalds 801da177e4SLinus Torvalds /* wait for status */ 81700d8bdcSNishanth Aravamudan stop = jiffies + 10 * HZ; 821da177e4SLinus Torvalds do { 83700d8bdcSNishanth Aravamudan msleep(TPM_TIMEOUT); 849e0d39d8SChristophe Ricard *data = inb(priv->base + 1); 85700d8bdcSNishanth Aravamudan if ((*data & mask) == val) 861da177e4SLinus Torvalds return 0; 871da177e4SLinus Torvalds } 88700d8bdcSNishanth Aravamudan while (time_before(jiffies, stop)); 891da177e4SLinus Torvalds 901da177e4SLinus Torvalds return -EBUSY; 911da177e4SLinus Torvalds } 921da177e4SLinus Torvalds 931da177e4SLinus Torvalds static int nsc_wait_for_ready(struct tpm_chip *chip) 941da177e4SLinus Torvalds { 959e0d39d8SChristophe Ricard struct tpm_nsc_priv *priv = dev_get_drvdata(&chip->dev); 961da177e4SLinus Torvalds int status; 97700d8bdcSNishanth Aravamudan unsigned long stop; 981da177e4SLinus Torvalds 991da177e4SLinus Torvalds /* status immediately available check */ 1009e0d39d8SChristophe Ricard status = inb(priv->base + NSC_STATUS); 1011da177e4SLinus Torvalds if (status & NSC_STATUS_OBF) 1029e0d39d8SChristophe Ricard status = inb(priv->base + NSC_DATA); 1031da177e4SLinus Torvalds if (status & NSC_STATUS_RDY) 1041da177e4SLinus Torvalds return 0; 1051da177e4SLinus Torvalds 1061da177e4SLinus Torvalds /* wait for status */ 107700d8bdcSNishanth Aravamudan stop = jiffies + 100; 1081da177e4SLinus Torvalds do { 109700d8bdcSNishanth Aravamudan msleep(TPM_TIMEOUT); 1109e0d39d8SChristophe Ricard status = inb(priv->base + NSC_STATUS); 1111da177e4SLinus Torvalds if (status & NSC_STATUS_OBF) 1129e0d39d8SChristophe Ricard status = inb(priv->base + NSC_DATA); 113700d8bdcSNishanth Aravamudan if (status & NSC_STATUS_RDY) 1141da177e4SLinus Torvalds return 0; 1151da177e4SLinus Torvalds } 116700d8bdcSNishanth Aravamudan while (time_before(jiffies, stop)); 1171da177e4SLinus Torvalds 1188cfffc9dSJason Gunthorpe dev_info(&chip->dev, "wait for ready failed\n"); 1191da177e4SLinus Torvalds return -EBUSY; 1201da177e4SLinus Torvalds } 1211da177e4SLinus Torvalds 1221da177e4SLinus Torvalds 1231da177e4SLinus Torvalds static int tpm_nsc_recv(struct tpm_chip *chip, u8 * buf, size_t count) 1241da177e4SLinus Torvalds { 1259e0d39d8SChristophe Ricard struct tpm_nsc_priv *priv = dev_get_drvdata(&chip->dev); 1261da177e4SLinus Torvalds u8 *buffer = buf; 1271da177e4SLinus Torvalds u8 data, *p; 1281da177e4SLinus Torvalds u32 size; 1291da177e4SLinus Torvalds __be32 *native_size; 1301da177e4SLinus Torvalds 1311da177e4SLinus Torvalds if (count < 6) 1321da177e4SLinus Torvalds return -EIO; 1331da177e4SLinus Torvalds 1341da177e4SLinus Torvalds if (wait_for_stat(chip, NSC_STATUS_F0, NSC_STATUS_F0, &data) < 0) { 1358cfffc9dSJason Gunthorpe dev_err(&chip->dev, "F0 timeout\n"); 1361da177e4SLinus Torvalds return -EIO; 1371da177e4SLinus Torvalds } 138ee177984SJarkko Sakkinen 1399e0d39d8SChristophe Ricard data = inb(priv->base + NSC_DATA); 140ee177984SJarkko Sakkinen if (data != NSC_COMMAND_NORMAL) { 1418cfffc9dSJason Gunthorpe dev_err(&chip->dev, "not in normal mode (0x%x)\n", 1421da177e4SLinus Torvalds data); 1431da177e4SLinus Torvalds return -EIO; 1441da177e4SLinus Torvalds } 1451da177e4SLinus Torvalds 1461da177e4SLinus Torvalds /* read the whole packet */ 1471da177e4SLinus Torvalds for (p = buffer; p < &buffer[count]; p++) { 1481da177e4SLinus Torvalds if (wait_for_stat 1491da177e4SLinus Torvalds (chip, NSC_STATUS_OBF, NSC_STATUS_OBF, &data) < 0) { 1508cfffc9dSJason Gunthorpe dev_err(&chip->dev, 1511da177e4SLinus Torvalds "OBF timeout (while reading data)\n"); 1521da177e4SLinus Torvalds return -EIO; 1531da177e4SLinus Torvalds } 1541da177e4SLinus Torvalds if (data & NSC_STATUS_F0) 1551da177e4SLinus Torvalds break; 1569e0d39d8SChristophe Ricard *p = inb(priv->base + NSC_DATA); 1571da177e4SLinus Torvalds } 1581da177e4SLinus Torvalds 159daacdfa6SKylene Jo Hall if ((data & NSC_STATUS_F0) == 0 && 160daacdfa6SKylene Jo Hall (wait_for_stat(chip, NSC_STATUS_F0, NSC_STATUS_F0, &data) < 0)) { 1618cfffc9dSJason Gunthorpe dev_err(&chip->dev, "F0 not set\n"); 1621da177e4SLinus Torvalds return -EIO; 1631da177e4SLinus Torvalds } 164ee177984SJarkko Sakkinen 1659e0d39d8SChristophe Ricard data = inb(priv->base + NSC_DATA); 166ee177984SJarkko Sakkinen if (data != NSC_COMMAND_EOC) { 1678cfffc9dSJason Gunthorpe dev_err(&chip->dev, 1681da177e4SLinus Torvalds "expected end of command(0x%x)\n", data); 1691da177e4SLinus Torvalds return -EIO; 1701da177e4SLinus Torvalds } 1711da177e4SLinus Torvalds 1721da177e4SLinus Torvalds native_size = (__force __be32 *) (buf + 2); 1731da177e4SLinus Torvalds size = be32_to_cpu(*native_size); 1741da177e4SLinus Torvalds 1751da177e4SLinus Torvalds if (count < size) 1761da177e4SLinus Torvalds return -EIO; 1771da177e4SLinus Torvalds 1781da177e4SLinus Torvalds return size; 1791da177e4SLinus Torvalds } 1801da177e4SLinus Torvalds 1811da177e4SLinus Torvalds static int tpm_nsc_send(struct tpm_chip *chip, u8 * buf, size_t count) 1821da177e4SLinus Torvalds { 1839e0d39d8SChristophe Ricard struct tpm_nsc_priv *priv = dev_get_drvdata(&chip->dev); 1841da177e4SLinus Torvalds u8 data; 1851da177e4SLinus Torvalds int i; 1861da177e4SLinus Torvalds 1871da177e4SLinus Torvalds /* 1881da177e4SLinus Torvalds * If we hit the chip with back to back commands it locks up 1891da177e4SLinus Torvalds * and never set IBF. Hitting it with this "hammer" seems to 1901da177e4SLinus Torvalds * fix it. Not sure why this is needed, we followed the flow 1911da177e4SLinus Torvalds * chart in the manual to the letter. 1921da177e4SLinus Torvalds */ 1939e0d39d8SChristophe Ricard outb(NSC_COMMAND_CANCEL, priv->base + NSC_COMMAND); 1941da177e4SLinus Torvalds 1951da177e4SLinus Torvalds if (nsc_wait_for_ready(chip) != 0) 1961da177e4SLinus Torvalds return -EIO; 1971da177e4SLinus Torvalds 1981da177e4SLinus Torvalds if (wait_for_stat(chip, NSC_STATUS_IBF, 0, &data) < 0) { 1998cfffc9dSJason Gunthorpe dev_err(&chip->dev, "IBF timeout\n"); 2001da177e4SLinus Torvalds return -EIO; 2011da177e4SLinus Torvalds } 2021da177e4SLinus Torvalds 2039e0d39d8SChristophe Ricard outb(NSC_COMMAND_NORMAL, priv->base + NSC_COMMAND); 2041da177e4SLinus Torvalds if (wait_for_stat(chip, NSC_STATUS_IBR, NSC_STATUS_IBR, &data) < 0) { 2058cfffc9dSJason Gunthorpe dev_err(&chip->dev, "IBR timeout\n"); 2061da177e4SLinus Torvalds return -EIO; 2071da177e4SLinus Torvalds } 2081da177e4SLinus Torvalds 2091da177e4SLinus Torvalds for (i = 0; i < count; i++) { 2101da177e4SLinus Torvalds if (wait_for_stat(chip, NSC_STATUS_IBF, 0, &data) < 0) { 2118cfffc9dSJason Gunthorpe dev_err(&chip->dev, 2121da177e4SLinus Torvalds "IBF timeout (while writing data)\n"); 2131da177e4SLinus Torvalds return -EIO; 2141da177e4SLinus Torvalds } 2159e0d39d8SChristophe Ricard outb(buf[i], priv->base + NSC_DATA); 2161da177e4SLinus Torvalds } 2171da177e4SLinus Torvalds 2181da177e4SLinus Torvalds if (wait_for_stat(chip, NSC_STATUS_IBF, 0, &data) < 0) { 2198cfffc9dSJason Gunthorpe dev_err(&chip->dev, "IBF timeout\n"); 2201da177e4SLinus Torvalds return -EIO; 2211da177e4SLinus Torvalds } 2229e0d39d8SChristophe Ricard outb(NSC_COMMAND_EOC, priv->base + NSC_COMMAND); 2231da177e4SLinus Torvalds 224f5595f5bSJarkko Sakkinen return 0; 2251da177e4SLinus Torvalds } 2261da177e4SLinus Torvalds 2271da177e4SLinus Torvalds static void tpm_nsc_cancel(struct tpm_chip *chip) 2281da177e4SLinus Torvalds { 2299e0d39d8SChristophe Ricard struct tpm_nsc_priv *priv = dev_get_drvdata(&chip->dev); 2309e0d39d8SChristophe Ricard 2319e0d39d8SChristophe Ricard outb(NSC_COMMAND_CANCEL, priv->base + NSC_COMMAND); 2321da177e4SLinus Torvalds } 2331da177e4SLinus Torvalds 234b4ed3e3cSKylene Jo Hall static u8 tpm_nsc_status(struct tpm_chip *chip) 235b4ed3e3cSKylene Jo Hall { 2369e0d39d8SChristophe Ricard struct tpm_nsc_priv *priv = dev_get_drvdata(&chip->dev); 2379e0d39d8SChristophe Ricard 2389e0d39d8SChristophe Ricard return inb(priv->base + NSC_STATUS); 239b4ed3e3cSKylene Jo Hall } 240b4ed3e3cSKylene Jo Hall 2411f866057SStefan Berger static bool tpm_nsc_req_canceled(struct tpm_chip *chip, u8 status) 2421f866057SStefan Berger { 2431f866057SStefan Berger return (status == NSC_STATUS_RDY); 2441f866057SStefan Berger } 2451f866057SStefan Berger 24601ad1fa7SJason Gunthorpe static const struct tpm_class_ops tpm_nsc = { 2471da177e4SLinus Torvalds .recv = tpm_nsc_recv, 2481da177e4SLinus Torvalds .send = tpm_nsc_send, 2491da177e4SLinus Torvalds .cancel = tpm_nsc_cancel, 250b4ed3e3cSKylene Jo Hall .status = tpm_nsc_status, 2511da177e4SLinus Torvalds .req_complete_mask = NSC_STATUS_OBF, 2521da177e4SLinus Torvalds .req_complete_val = NSC_STATUS_OBF, 2531f866057SStefan Berger .req_canceled = tpm_nsc_req_canceled, 2541da177e4SLinus Torvalds }; 2551da177e4SLinus Torvalds 256570302a3SKylene Jo Hall static struct platform_device *pdev = NULL; 257570302a3SKylene Jo Hall 2584821cd11SSam Ravnborg static void tpm_nsc_remove(struct device *dev) 259570302a3SKylene Jo Hall { 260570302a3SKylene Jo Hall struct tpm_chip *chip = dev_get_drvdata(dev); 2619e0d39d8SChristophe Ricard struct tpm_nsc_priv *priv = dev_get_drvdata(&chip->dev); 262afb5abc2SJarkko Sakkinen 263afb5abc2SJarkko Sakkinen tpm_chip_unregister(chip); 2649e0d39d8SChristophe Ricard release_region(priv->base, 2); 265570302a3SKylene Jo Hall } 266570302a3SKylene Jo Hall 267ca9a2054SRafael J. Wysocki static SIMPLE_DEV_PM_OPS(tpm_nsc_pm, tpm_pm_suspend, tpm_pm_resume); 26809f50c95SDavid Smith 26909f50c95SDavid Smith static struct platform_driver nsc_drv = { 27009f50c95SDavid Smith .driver = { 271570302a3SKylene Jo Hall .name = "tpm_nsc", 272ca9a2054SRafael J. Wysocki .pm = &tpm_nsc_pm, 27309f50c95SDavid Smith }, 274570302a3SKylene Jo Hall }; 275570302a3SKylene Jo Hall 2761d191553SJarkko Sakkinen static inline int tpm_read_index(int base, int index) 2771d191553SJarkko Sakkinen { 2781d191553SJarkko Sakkinen outb(index, base); 2791d191553SJarkko Sakkinen return inb(base+1) & 0xFF; 2801d191553SJarkko Sakkinen } 2811d191553SJarkko Sakkinen 2821d191553SJarkko Sakkinen static inline void tpm_write_index(int base, int index, int value) 2831d191553SJarkko Sakkinen { 2841d191553SJarkko Sakkinen outb(index, base); 2851d191553SJarkko Sakkinen outb(value & 0xFF, base+1); 2861d191553SJarkko Sakkinen } 2871d191553SJarkko Sakkinen 288570302a3SKylene Jo Hall static int __init init_nsc(void) 2891da177e4SLinus Torvalds { 2901da177e4SLinus Torvalds int rc = 0; 291f33d9bd5SJeff Garzik int lo, hi, err; 292daacdfa6SKylene Jo Hall int nscAddrBase = TPM_ADDR; 293e0dd03caSKylene Jo Hall struct tpm_chip *chip; 294e0dd03caSKylene Jo Hall unsigned long base; 295ee177984SJarkko Sakkinen struct tpm_nsc_priv *priv; 296daacdfa6SKylene Jo Hall 2971da177e4SLinus Torvalds /* verify that it is a National part (SID) */ 298daacdfa6SKylene Jo Hall if (tpm_read_index(TPM_ADDR, NSC_SID_INDEX) != 0xEF) { 299daacdfa6SKylene Jo Hall nscAddrBase = (tpm_read_index(TPM_SUPERIO_ADDR, 0x2C)<<8)| 300daacdfa6SKylene Jo Hall (tpm_read_index(TPM_SUPERIO_ADDR, 0x2B)&0xFE); 301570302a3SKylene Jo Hall if (tpm_read_index(nscAddrBase, NSC_SID_INDEX) != 0xF6) 302570302a3SKylene Jo Hall return -ENODEV; 303daacdfa6SKylene Jo Hall } 304daacdfa6SKylene Jo Hall 30509f50c95SDavid Smith err = platform_driver_register(&nsc_drv); 306f33d9bd5SJeff Garzik if (err) 307f33d9bd5SJeff Garzik return err; 308e2a8f7a1SKylene Jo Hall 309daacdfa6SKylene Jo Hall hi = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_HI); 310daacdfa6SKylene Jo Hall lo = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_LO); 311e0dd03caSKylene Jo Hall base = (hi<<8) | lo; 3121da177e4SLinus Torvalds 313570302a3SKylene Jo Hall /* enable the DPM module */ 314570302a3SKylene Jo Hall tpm_write_index(nscAddrBase, NSC_LDC_INDEX, 0x01); 315570302a3SKylene Jo Hall 31609f50c95SDavid Smith pdev = platform_device_alloc("tpm_nscl0", -1); 317e2a8f7a1SKylene Jo Hall if (!pdev) { 318e2a8f7a1SKylene Jo Hall rc = -ENOMEM; 319e2a8f7a1SKylene Jo Hall goto err_unreg_drv; 320e2a8f7a1SKylene Jo Hall } 321570302a3SKylene Jo Hall 322570302a3SKylene Jo Hall pdev->num_resources = 0; 32309f50c95SDavid Smith pdev->dev.driver = &nsc_drv.driver; 324570302a3SKylene Jo Hall pdev->dev.release = tpm_nsc_remove; 325570302a3SKylene Jo Hall 32629412f0fSStefan Berger if ((rc = platform_device_add(pdev)) < 0) 32729412f0fSStefan Berger goto err_put_dev; 328570302a3SKylene Jo Hall 329ee177984SJarkko Sakkinen priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 330ee177984SJarkko Sakkinen if (!priv) { 331ee177984SJarkko Sakkinen rc = -ENOMEM; 332ee177984SJarkko Sakkinen goto err_del_dev; 333ee177984SJarkko Sakkinen } 334ee177984SJarkko Sakkinen 335ee177984SJarkko Sakkinen priv->base = base; 336ee177984SJarkko Sakkinen 337e0dd03caSKylene Jo Hall if (request_region(base, 2, "tpm_nsc0") == NULL ) { 338e2a8f7a1SKylene Jo Hall rc = -EBUSY; 33929412f0fSStefan Berger goto err_del_dev; 340570302a3SKylene Jo Hall } 341570302a3SKylene Jo Hall 342afb5abc2SJarkko Sakkinen chip = tpmm_chip_alloc(&pdev->dev, &tpm_nsc); 343afb5abc2SJarkko Sakkinen if (IS_ERR(chip)) { 344e0dd03caSKylene Jo Hall rc = -ENODEV; 345e2a8f7a1SKylene Jo Hall goto err_rel_reg; 346e0dd03caSKylene Jo Hall } 347570302a3SKylene Jo Hall 3489e0d39d8SChristophe Ricard dev_set_drvdata(&chip->dev, priv); 349ee177984SJarkko Sakkinen 350afb5abc2SJarkko Sakkinen rc = tpm_chip_register(chip); 351afb5abc2SJarkko Sakkinen if (rc) 352afb5abc2SJarkko Sakkinen goto err_rel_reg; 353afb5abc2SJarkko Sakkinen 354570302a3SKylene Jo Hall dev_dbg(&pdev->dev, "NSC TPM detected\n"); 355570302a3SKylene Jo Hall dev_dbg(&pdev->dev, 3561da177e4SLinus Torvalds "NSC LDN 0x%x, SID 0x%x, SRID 0x%x\n", 357daacdfa6SKylene Jo Hall tpm_read_index(nscAddrBase,0x07), tpm_read_index(nscAddrBase,0x20), 358daacdfa6SKylene Jo Hall tpm_read_index(nscAddrBase,0x27)); 359570302a3SKylene Jo Hall dev_dbg(&pdev->dev, 3601da177e4SLinus Torvalds "NSC SIOCF1 0x%x SIOCF5 0x%x SIOCF6 0x%x SIOCF8 0x%x\n", 361daacdfa6SKylene Jo Hall tpm_read_index(nscAddrBase,0x21), tpm_read_index(nscAddrBase,0x25), 362daacdfa6SKylene Jo Hall tpm_read_index(nscAddrBase,0x26), tpm_read_index(nscAddrBase,0x28)); 363570302a3SKylene Jo Hall dev_dbg(&pdev->dev, "NSC IO Base0 0x%x\n", 364daacdfa6SKylene Jo Hall (tpm_read_index(nscAddrBase,0x60) << 8) | tpm_read_index(nscAddrBase,0x61)); 365570302a3SKylene Jo Hall dev_dbg(&pdev->dev, "NSC IO Base1 0x%x\n", 366daacdfa6SKylene Jo Hall (tpm_read_index(nscAddrBase,0x62) << 8) | tpm_read_index(nscAddrBase,0x63)); 367570302a3SKylene Jo Hall dev_dbg(&pdev->dev, "NSC Interrupt number and wakeup 0x%x\n", 368daacdfa6SKylene Jo Hall tpm_read_index(nscAddrBase,0x70)); 369570302a3SKylene Jo Hall dev_dbg(&pdev->dev, "NSC IRQ type select 0x%x\n", 370daacdfa6SKylene Jo Hall tpm_read_index(nscAddrBase,0x71)); 371570302a3SKylene Jo Hall dev_dbg(&pdev->dev, 3721da177e4SLinus Torvalds "NSC DMA channel select0 0x%x, select1 0x%x\n", 373daacdfa6SKylene Jo Hall tpm_read_index(nscAddrBase,0x74), tpm_read_index(nscAddrBase,0x75)); 374570302a3SKylene Jo Hall dev_dbg(&pdev->dev, 3751da177e4SLinus Torvalds "NSC Config " 3761da177e4SLinus Torvalds "0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n", 377daacdfa6SKylene Jo Hall tpm_read_index(nscAddrBase,0xF0), tpm_read_index(nscAddrBase,0xF1), 378daacdfa6SKylene Jo Hall tpm_read_index(nscAddrBase,0xF2), tpm_read_index(nscAddrBase,0xF3), 379daacdfa6SKylene Jo Hall tpm_read_index(nscAddrBase,0xF4), tpm_read_index(nscAddrBase,0xF5), 380daacdfa6SKylene Jo Hall tpm_read_index(nscAddrBase,0xF6), tpm_read_index(nscAddrBase,0xF7), 381daacdfa6SKylene Jo Hall tpm_read_index(nscAddrBase,0xF8), tpm_read_index(nscAddrBase,0xF9)); 3821da177e4SLinus Torvalds 383570302a3SKylene Jo Hall dev_info(&pdev->dev, 384daacdfa6SKylene Jo Hall "NSC TPM revision %d\n", 385daacdfa6SKylene Jo Hall tpm_read_index(nscAddrBase, 0x27) & 0x1F); 3861da177e4SLinus Torvalds 3871da177e4SLinus Torvalds return 0; 388e2a8f7a1SKylene Jo Hall 389e2a8f7a1SKylene Jo Hall err_rel_reg: 390e0dd03caSKylene Jo Hall release_region(base, 2); 39129412f0fSStefan Berger err_del_dev: 39229412f0fSStefan Berger platform_device_del(pdev); 39329412f0fSStefan Berger err_put_dev: 39429412f0fSStefan Berger platform_device_put(pdev); 395e2a8f7a1SKylene Jo Hall err_unreg_drv: 39609f50c95SDavid Smith platform_driver_unregister(&nsc_drv); 397e2a8f7a1SKylene Jo Hall return rc; 3981da177e4SLinus Torvalds } 3991da177e4SLinus Torvalds 4001da177e4SLinus Torvalds static void __exit cleanup_nsc(void) 4011da177e4SLinus Torvalds { 402570302a3SKylene Jo Hall if (pdev) { 403570302a3SKylene Jo Hall tpm_nsc_remove(&pdev->dev); 404570302a3SKylene Jo Hall platform_device_unregister(pdev); 405570302a3SKylene Jo Hall } 406570302a3SKylene Jo Hall 40709f50c95SDavid Smith platform_driver_unregister(&nsc_drv); 4081da177e4SLinus Torvalds } 4091da177e4SLinus Torvalds 4101da177e4SLinus Torvalds module_init(init_nsc); 4111da177e4SLinus Torvalds module_exit(cleanup_nsc); 4121da177e4SLinus Torvalds 4131da177e4SLinus Torvalds MODULE_AUTHOR("Leendert van Doorn (leendert@watson.ibm.com)"); 4141da177e4SLinus Torvalds MODULE_DESCRIPTION("TPM Driver"); 4151da177e4SLinus Torvalds MODULE_VERSION("2.0"); 4161da177e4SLinus Torvalds MODULE_LICENSE("GPL"); 417