11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * Copyright (C) 2004 IBM Corporation 31da177e4SLinus Torvalds * 41da177e4SLinus Torvalds * Authors: 51da177e4SLinus Torvalds * Leendert van Doorn <leendert@watson.ibm.com> 61da177e4SLinus Torvalds * Dave Safford <safford@watson.ibm.com> 71da177e4SLinus Torvalds * Reiner Sailer <sailer@watson.ibm.com> 81da177e4SLinus Torvalds * Kylene Hall <kjhall@us.ibm.com> 91da177e4SLinus Torvalds * 108e81cc13SKent Yoder * Maintained by: <tpmdd-devel@lists.sourceforge.net> 111da177e4SLinus Torvalds * 121da177e4SLinus Torvalds * Device driver for TCG/TCPA TPM (trusted platform module). 131da177e4SLinus Torvalds * Specifications at www.trustedcomputinggroup.org 141da177e4SLinus Torvalds * 151da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or 161da177e4SLinus Torvalds * modify it under the terms of the GNU General Public License as 171da177e4SLinus Torvalds * published by the Free Software Foundation, version 2 of the 181da177e4SLinus Torvalds * License. 191da177e4SLinus Torvalds * 201da177e4SLinus Torvalds */ 211da177e4SLinus Torvalds 22faba278fSChris Wright #include <linux/platform_device.h> 235a0e3ad6STejun Heo #include <linux/slab.h> 241da177e4SLinus Torvalds #include "tpm.h" 251da177e4SLinus Torvalds 261da177e4SLinus Torvalds /* National definitions */ 273122a88aSKylene Hall enum tpm_nsc_addr{ 28e1a23c66SKylene Hall TPM_NSC_IRQ = 0x07, 29e1a23c66SKylene Hall TPM_NSC_BASE0_HI = 0x60, 30e1a23c66SKylene Hall TPM_NSC_BASE0_LO = 0x61, 31e1a23c66SKylene Hall TPM_NSC_BASE1_HI = 0x62, 32e1a23c66SKylene Hall TPM_NSC_BASE1_LO = 0x63 333122a88aSKylene Hall }; 341da177e4SLinus Torvalds 353122a88aSKylene Hall enum tpm_nsc_index { 363122a88aSKylene Hall NSC_LDN_INDEX = 0x07, 373122a88aSKylene Hall NSC_SID_INDEX = 0x20, 383122a88aSKylene Hall NSC_LDC_INDEX = 0x30, 393122a88aSKylene Hall NSC_DIO_INDEX = 0x60, 403122a88aSKylene Hall NSC_CIO_INDEX = 0x62, 413122a88aSKylene Hall NSC_IRQ_INDEX = 0x70, 423122a88aSKylene Hall NSC_ITS_INDEX = 0x71 433122a88aSKylene Hall }; 441da177e4SLinus Torvalds 453122a88aSKylene Hall enum tpm_nsc_status_loc { 463122a88aSKylene Hall NSC_STATUS = 0x01, 473122a88aSKylene Hall NSC_COMMAND = 0x01, 483122a88aSKylene Hall NSC_DATA = 0x00 493122a88aSKylene Hall }; 501da177e4SLinus Torvalds 511da177e4SLinus Torvalds /* status bits */ 523122a88aSKylene Hall enum tpm_nsc_status { 533122a88aSKylene Hall NSC_STATUS_OBF = 0x01, /* output buffer full */ 543122a88aSKylene Hall NSC_STATUS_IBF = 0x02, /* input buffer full */ 553122a88aSKylene Hall NSC_STATUS_F0 = 0x04, /* F0 */ 563122a88aSKylene Hall NSC_STATUS_A2 = 0x08, /* A2 */ 573122a88aSKylene Hall NSC_STATUS_RDY = 0x10, /* ready to receive command */ 583122a88aSKylene Hall NSC_STATUS_IBR = 0x20 /* ready to receive data */ 593122a88aSKylene Hall }; 60daacdfa6SKylene Jo Hall 611da177e4SLinus Torvalds /* command bits */ 623122a88aSKylene Hall enum tpm_nsc_cmd_mode { 633122a88aSKylene Hall NSC_COMMAND_NORMAL = 0x01, /* normal mode */ 643122a88aSKylene Hall NSC_COMMAND_EOC = 0x03, 653122a88aSKylene Hall NSC_COMMAND_CANCEL = 0x22 663122a88aSKylene Hall }; 67ee177984SJarkko Sakkinen 68ee177984SJarkko Sakkinen struct tpm_nsc_priv { 69ee177984SJarkko Sakkinen unsigned long base; 70ee177984SJarkko Sakkinen }; 71ee177984SJarkko Sakkinen 721da177e4SLinus Torvalds /* 731da177e4SLinus Torvalds * Wait for a certain status to appear 741da177e4SLinus Torvalds */ 751da177e4SLinus Torvalds static int wait_for_stat(struct tpm_chip *chip, u8 mask, u8 val, u8 * data) 761da177e4SLinus Torvalds { 779e0d39d8SChristophe Ricard struct tpm_nsc_priv *priv = dev_get_drvdata(&chip->dev); 78700d8bdcSNishanth Aravamudan unsigned long stop; 791da177e4SLinus Torvalds 801da177e4SLinus Torvalds /* status immediately available check */ 819e0d39d8SChristophe Ricard *data = inb(priv->base + NSC_STATUS); 821da177e4SLinus Torvalds if ((*data & mask) == val) 831da177e4SLinus Torvalds return 0; 841da177e4SLinus Torvalds 851da177e4SLinus Torvalds /* wait for status */ 86700d8bdcSNishanth Aravamudan stop = jiffies + 10 * HZ; 871da177e4SLinus Torvalds do { 88700d8bdcSNishanth Aravamudan msleep(TPM_TIMEOUT); 899e0d39d8SChristophe Ricard *data = inb(priv->base + 1); 90700d8bdcSNishanth Aravamudan if ((*data & mask) == val) 911da177e4SLinus Torvalds return 0; 921da177e4SLinus Torvalds } 93700d8bdcSNishanth Aravamudan while (time_before(jiffies, stop)); 941da177e4SLinus Torvalds 951da177e4SLinus Torvalds return -EBUSY; 961da177e4SLinus Torvalds } 971da177e4SLinus Torvalds 981da177e4SLinus Torvalds static int nsc_wait_for_ready(struct tpm_chip *chip) 991da177e4SLinus Torvalds { 1009e0d39d8SChristophe Ricard struct tpm_nsc_priv *priv = dev_get_drvdata(&chip->dev); 1011da177e4SLinus Torvalds int status; 102700d8bdcSNishanth Aravamudan unsigned long stop; 1031da177e4SLinus Torvalds 1041da177e4SLinus Torvalds /* status immediately available check */ 1059e0d39d8SChristophe Ricard status = inb(priv->base + NSC_STATUS); 1061da177e4SLinus Torvalds if (status & NSC_STATUS_OBF) 1079e0d39d8SChristophe Ricard status = inb(priv->base + NSC_DATA); 1081da177e4SLinus Torvalds if (status & NSC_STATUS_RDY) 1091da177e4SLinus Torvalds return 0; 1101da177e4SLinus Torvalds 1111da177e4SLinus Torvalds /* wait for status */ 112700d8bdcSNishanth Aravamudan stop = jiffies + 100; 1131da177e4SLinus Torvalds do { 114700d8bdcSNishanth Aravamudan msleep(TPM_TIMEOUT); 1159e0d39d8SChristophe Ricard status = inb(priv->base + NSC_STATUS); 1161da177e4SLinus Torvalds if (status & NSC_STATUS_OBF) 1179e0d39d8SChristophe Ricard status = inb(priv->base + NSC_DATA); 118700d8bdcSNishanth Aravamudan if (status & NSC_STATUS_RDY) 1191da177e4SLinus Torvalds return 0; 1201da177e4SLinus Torvalds } 121700d8bdcSNishanth Aravamudan while (time_before(jiffies, stop)); 1221da177e4SLinus Torvalds 1238cfffc9dSJason Gunthorpe dev_info(&chip->dev, "wait for ready failed\n"); 1241da177e4SLinus Torvalds return -EBUSY; 1251da177e4SLinus Torvalds } 1261da177e4SLinus Torvalds 1271da177e4SLinus Torvalds 1281da177e4SLinus Torvalds static int tpm_nsc_recv(struct tpm_chip *chip, u8 * buf, size_t count) 1291da177e4SLinus Torvalds { 1309e0d39d8SChristophe Ricard struct tpm_nsc_priv *priv = dev_get_drvdata(&chip->dev); 1311da177e4SLinus Torvalds u8 *buffer = buf; 1321da177e4SLinus Torvalds u8 data, *p; 1331da177e4SLinus Torvalds u32 size; 1341da177e4SLinus Torvalds __be32 *native_size; 1351da177e4SLinus Torvalds 1361da177e4SLinus Torvalds if (count < 6) 1371da177e4SLinus Torvalds return -EIO; 1381da177e4SLinus Torvalds 1391da177e4SLinus Torvalds if (wait_for_stat(chip, NSC_STATUS_F0, NSC_STATUS_F0, &data) < 0) { 1408cfffc9dSJason Gunthorpe dev_err(&chip->dev, "F0 timeout\n"); 1411da177e4SLinus Torvalds return -EIO; 1421da177e4SLinus Torvalds } 143ee177984SJarkko Sakkinen 1449e0d39d8SChristophe Ricard data = inb(priv->base + NSC_DATA); 145ee177984SJarkko Sakkinen if (data != NSC_COMMAND_NORMAL) { 1468cfffc9dSJason Gunthorpe dev_err(&chip->dev, "not in normal mode (0x%x)\n", 1471da177e4SLinus Torvalds data); 1481da177e4SLinus Torvalds return -EIO; 1491da177e4SLinus Torvalds } 1501da177e4SLinus Torvalds 1511da177e4SLinus Torvalds /* read the whole packet */ 1521da177e4SLinus Torvalds for (p = buffer; p < &buffer[count]; p++) { 1531da177e4SLinus Torvalds if (wait_for_stat 1541da177e4SLinus Torvalds (chip, NSC_STATUS_OBF, NSC_STATUS_OBF, &data) < 0) { 1558cfffc9dSJason Gunthorpe dev_err(&chip->dev, 1561da177e4SLinus Torvalds "OBF timeout (while reading data)\n"); 1571da177e4SLinus Torvalds return -EIO; 1581da177e4SLinus Torvalds } 1591da177e4SLinus Torvalds if (data & NSC_STATUS_F0) 1601da177e4SLinus Torvalds break; 1619e0d39d8SChristophe Ricard *p = inb(priv->base + NSC_DATA); 1621da177e4SLinus Torvalds } 1631da177e4SLinus Torvalds 164daacdfa6SKylene Jo Hall if ((data & NSC_STATUS_F0) == 0 && 165daacdfa6SKylene Jo Hall (wait_for_stat(chip, NSC_STATUS_F0, NSC_STATUS_F0, &data) < 0)) { 1668cfffc9dSJason Gunthorpe dev_err(&chip->dev, "F0 not set\n"); 1671da177e4SLinus Torvalds return -EIO; 1681da177e4SLinus Torvalds } 169ee177984SJarkko Sakkinen 1709e0d39d8SChristophe Ricard data = inb(priv->base + NSC_DATA); 171ee177984SJarkko Sakkinen if (data != NSC_COMMAND_EOC) { 1728cfffc9dSJason Gunthorpe dev_err(&chip->dev, 1731da177e4SLinus Torvalds "expected end of command(0x%x)\n", data); 1741da177e4SLinus Torvalds return -EIO; 1751da177e4SLinus Torvalds } 1761da177e4SLinus Torvalds 1771da177e4SLinus Torvalds native_size = (__force __be32 *) (buf + 2); 1781da177e4SLinus Torvalds size = be32_to_cpu(*native_size); 1791da177e4SLinus Torvalds 1801da177e4SLinus Torvalds if (count < size) 1811da177e4SLinus Torvalds return -EIO; 1821da177e4SLinus Torvalds 1831da177e4SLinus Torvalds return size; 1841da177e4SLinus Torvalds } 1851da177e4SLinus Torvalds 1861da177e4SLinus Torvalds static int tpm_nsc_send(struct tpm_chip *chip, u8 * buf, size_t count) 1871da177e4SLinus Torvalds { 1889e0d39d8SChristophe Ricard struct tpm_nsc_priv *priv = dev_get_drvdata(&chip->dev); 1891da177e4SLinus Torvalds u8 data; 1901da177e4SLinus Torvalds int i; 1911da177e4SLinus Torvalds 1921da177e4SLinus Torvalds /* 1931da177e4SLinus Torvalds * If we hit the chip with back to back commands it locks up 1941da177e4SLinus Torvalds * and never set IBF. Hitting it with this "hammer" seems to 1951da177e4SLinus Torvalds * fix it. Not sure why this is needed, we followed the flow 1961da177e4SLinus Torvalds * chart in the manual to the letter. 1971da177e4SLinus Torvalds */ 1989e0d39d8SChristophe Ricard outb(NSC_COMMAND_CANCEL, priv->base + NSC_COMMAND); 1991da177e4SLinus Torvalds 2001da177e4SLinus Torvalds if (nsc_wait_for_ready(chip) != 0) 2011da177e4SLinus Torvalds return -EIO; 2021da177e4SLinus Torvalds 2031da177e4SLinus Torvalds if (wait_for_stat(chip, NSC_STATUS_IBF, 0, &data) < 0) { 2048cfffc9dSJason Gunthorpe dev_err(&chip->dev, "IBF timeout\n"); 2051da177e4SLinus Torvalds return -EIO; 2061da177e4SLinus Torvalds } 2071da177e4SLinus Torvalds 2089e0d39d8SChristophe Ricard outb(NSC_COMMAND_NORMAL, priv->base + NSC_COMMAND); 2091da177e4SLinus Torvalds if (wait_for_stat(chip, NSC_STATUS_IBR, NSC_STATUS_IBR, &data) < 0) { 2108cfffc9dSJason Gunthorpe dev_err(&chip->dev, "IBR timeout\n"); 2111da177e4SLinus Torvalds return -EIO; 2121da177e4SLinus Torvalds } 2131da177e4SLinus Torvalds 2141da177e4SLinus Torvalds for (i = 0; i < count; i++) { 2151da177e4SLinus Torvalds if (wait_for_stat(chip, NSC_STATUS_IBF, 0, &data) < 0) { 2168cfffc9dSJason Gunthorpe dev_err(&chip->dev, 2171da177e4SLinus Torvalds "IBF timeout (while writing data)\n"); 2181da177e4SLinus Torvalds return -EIO; 2191da177e4SLinus Torvalds } 2209e0d39d8SChristophe Ricard outb(buf[i], priv->base + NSC_DATA); 2211da177e4SLinus Torvalds } 2221da177e4SLinus Torvalds 2231da177e4SLinus Torvalds if (wait_for_stat(chip, NSC_STATUS_IBF, 0, &data) < 0) { 2248cfffc9dSJason Gunthorpe dev_err(&chip->dev, "IBF timeout\n"); 2251da177e4SLinus Torvalds return -EIO; 2261da177e4SLinus Torvalds } 2279e0d39d8SChristophe Ricard outb(NSC_COMMAND_EOC, priv->base + NSC_COMMAND); 2281da177e4SLinus Torvalds 2291da177e4SLinus Torvalds return count; 2301da177e4SLinus Torvalds } 2311da177e4SLinus Torvalds 2321da177e4SLinus Torvalds static void tpm_nsc_cancel(struct tpm_chip *chip) 2331da177e4SLinus Torvalds { 2349e0d39d8SChristophe Ricard struct tpm_nsc_priv *priv = dev_get_drvdata(&chip->dev); 2359e0d39d8SChristophe Ricard 2369e0d39d8SChristophe Ricard outb(NSC_COMMAND_CANCEL, priv->base + NSC_COMMAND); 2371da177e4SLinus Torvalds } 2381da177e4SLinus Torvalds 239b4ed3e3cSKylene Jo Hall static u8 tpm_nsc_status(struct tpm_chip *chip) 240b4ed3e3cSKylene Jo Hall { 2419e0d39d8SChristophe Ricard struct tpm_nsc_priv *priv = dev_get_drvdata(&chip->dev); 2429e0d39d8SChristophe Ricard 2439e0d39d8SChristophe Ricard return inb(priv->base + NSC_STATUS); 244b4ed3e3cSKylene Jo Hall } 245b4ed3e3cSKylene Jo Hall 2461f866057SStefan Berger static bool tpm_nsc_req_canceled(struct tpm_chip *chip, u8 status) 2471f866057SStefan Berger { 2481f866057SStefan Berger return (status == NSC_STATUS_RDY); 2491f866057SStefan Berger } 2501f866057SStefan Berger 25101ad1fa7SJason Gunthorpe static const struct tpm_class_ops tpm_nsc = { 2521da177e4SLinus Torvalds .recv = tpm_nsc_recv, 2531da177e4SLinus Torvalds .send = tpm_nsc_send, 2541da177e4SLinus Torvalds .cancel = tpm_nsc_cancel, 255b4ed3e3cSKylene Jo Hall .status = tpm_nsc_status, 2561da177e4SLinus Torvalds .req_complete_mask = NSC_STATUS_OBF, 2571da177e4SLinus Torvalds .req_complete_val = NSC_STATUS_OBF, 2581f866057SStefan Berger .req_canceled = tpm_nsc_req_canceled, 2591da177e4SLinus Torvalds }; 2601da177e4SLinus Torvalds 261570302a3SKylene Jo Hall static struct platform_device *pdev = NULL; 262570302a3SKylene Jo Hall 2634821cd11SSam Ravnborg static void tpm_nsc_remove(struct device *dev) 264570302a3SKylene Jo Hall { 265570302a3SKylene Jo Hall struct tpm_chip *chip = dev_get_drvdata(dev); 2669e0d39d8SChristophe Ricard struct tpm_nsc_priv *priv = dev_get_drvdata(&chip->dev); 267afb5abc2SJarkko Sakkinen 268afb5abc2SJarkko Sakkinen tpm_chip_unregister(chip); 2699e0d39d8SChristophe Ricard release_region(priv->base, 2); 270570302a3SKylene Jo Hall } 271570302a3SKylene Jo Hall 272ca9a2054SRafael J. Wysocki static SIMPLE_DEV_PM_OPS(tpm_nsc_pm, tpm_pm_suspend, tpm_pm_resume); 27309f50c95SDavid Smith 27409f50c95SDavid Smith static struct platform_driver nsc_drv = { 27509f50c95SDavid Smith .driver = { 276570302a3SKylene Jo Hall .name = "tpm_nsc", 277ca9a2054SRafael J. Wysocki .pm = &tpm_nsc_pm, 27809f50c95SDavid Smith }, 279570302a3SKylene Jo Hall }; 280570302a3SKylene Jo Hall 281*1d191553SJarkko Sakkinen static inline int tpm_read_index(int base, int index) 282*1d191553SJarkko Sakkinen { 283*1d191553SJarkko Sakkinen outb(index, base); 284*1d191553SJarkko Sakkinen return inb(base+1) & 0xFF; 285*1d191553SJarkko Sakkinen } 286*1d191553SJarkko Sakkinen 287*1d191553SJarkko Sakkinen static inline void tpm_write_index(int base, int index, int value) 288*1d191553SJarkko Sakkinen { 289*1d191553SJarkko Sakkinen outb(index, base); 290*1d191553SJarkko Sakkinen outb(value & 0xFF, base+1); 291*1d191553SJarkko Sakkinen } 292*1d191553SJarkko Sakkinen 293570302a3SKylene Jo Hall static int __init init_nsc(void) 2941da177e4SLinus Torvalds { 2951da177e4SLinus Torvalds int rc = 0; 296f33d9bd5SJeff Garzik int lo, hi, err; 297daacdfa6SKylene Jo Hall int nscAddrBase = TPM_ADDR; 298e0dd03caSKylene Jo Hall struct tpm_chip *chip; 299e0dd03caSKylene Jo Hall unsigned long base; 300ee177984SJarkko Sakkinen struct tpm_nsc_priv *priv; 301daacdfa6SKylene Jo Hall 3021da177e4SLinus Torvalds /* verify that it is a National part (SID) */ 303daacdfa6SKylene Jo Hall if (tpm_read_index(TPM_ADDR, NSC_SID_INDEX) != 0xEF) { 304daacdfa6SKylene Jo Hall nscAddrBase = (tpm_read_index(TPM_SUPERIO_ADDR, 0x2C)<<8)| 305daacdfa6SKylene Jo Hall (tpm_read_index(TPM_SUPERIO_ADDR, 0x2B)&0xFE); 306570302a3SKylene Jo Hall if (tpm_read_index(nscAddrBase, NSC_SID_INDEX) != 0xF6) 307570302a3SKylene Jo Hall return -ENODEV; 308daacdfa6SKylene Jo Hall } 309daacdfa6SKylene Jo Hall 31009f50c95SDavid Smith err = platform_driver_register(&nsc_drv); 311f33d9bd5SJeff Garzik if (err) 312f33d9bd5SJeff Garzik return err; 313e2a8f7a1SKylene Jo Hall 314daacdfa6SKylene Jo Hall hi = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_HI); 315daacdfa6SKylene Jo Hall lo = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_LO); 316e0dd03caSKylene Jo Hall base = (hi<<8) | lo; 3171da177e4SLinus Torvalds 318570302a3SKylene Jo Hall /* enable the DPM module */ 319570302a3SKylene Jo Hall tpm_write_index(nscAddrBase, NSC_LDC_INDEX, 0x01); 320570302a3SKylene Jo Hall 32109f50c95SDavid Smith pdev = platform_device_alloc("tpm_nscl0", -1); 322e2a8f7a1SKylene Jo Hall if (!pdev) { 323e2a8f7a1SKylene Jo Hall rc = -ENOMEM; 324e2a8f7a1SKylene Jo Hall goto err_unreg_drv; 325e2a8f7a1SKylene Jo Hall } 326570302a3SKylene Jo Hall 327570302a3SKylene Jo Hall pdev->num_resources = 0; 32809f50c95SDavid Smith pdev->dev.driver = &nsc_drv.driver; 329570302a3SKylene Jo Hall pdev->dev.release = tpm_nsc_remove; 330570302a3SKylene Jo Hall 33129412f0fSStefan Berger if ((rc = platform_device_add(pdev)) < 0) 33229412f0fSStefan Berger goto err_put_dev; 333570302a3SKylene Jo Hall 334ee177984SJarkko Sakkinen priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 335ee177984SJarkko Sakkinen if (!priv) { 336ee177984SJarkko Sakkinen rc = -ENOMEM; 337ee177984SJarkko Sakkinen goto err_del_dev; 338ee177984SJarkko Sakkinen } 339ee177984SJarkko Sakkinen 340ee177984SJarkko Sakkinen priv->base = base; 341ee177984SJarkko Sakkinen 342e0dd03caSKylene Jo Hall if (request_region(base, 2, "tpm_nsc0") == NULL ) { 343e2a8f7a1SKylene Jo Hall rc = -EBUSY; 34429412f0fSStefan Berger goto err_del_dev; 345570302a3SKylene Jo Hall } 346570302a3SKylene Jo Hall 347afb5abc2SJarkko Sakkinen chip = tpmm_chip_alloc(&pdev->dev, &tpm_nsc); 348afb5abc2SJarkko Sakkinen if (IS_ERR(chip)) { 349e0dd03caSKylene Jo Hall rc = -ENODEV; 350e2a8f7a1SKylene Jo Hall goto err_rel_reg; 351e0dd03caSKylene Jo Hall } 352570302a3SKylene Jo Hall 3539e0d39d8SChristophe Ricard dev_set_drvdata(&chip->dev, priv); 354ee177984SJarkko Sakkinen 355afb5abc2SJarkko Sakkinen rc = tpm_chip_register(chip); 356afb5abc2SJarkko Sakkinen if (rc) 357afb5abc2SJarkko Sakkinen goto err_rel_reg; 358afb5abc2SJarkko Sakkinen 359570302a3SKylene Jo Hall dev_dbg(&pdev->dev, "NSC TPM detected\n"); 360570302a3SKylene Jo Hall dev_dbg(&pdev->dev, 3611da177e4SLinus Torvalds "NSC LDN 0x%x, SID 0x%x, SRID 0x%x\n", 362daacdfa6SKylene Jo Hall tpm_read_index(nscAddrBase,0x07), tpm_read_index(nscAddrBase,0x20), 363daacdfa6SKylene Jo Hall tpm_read_index(nscAddrBase,0x27)); 364570302a3SKylene Jo Hall dev_dbg(&pdev->dev, 3651da177e4SLinus Torvalds "NSC SIOCF1 0x%x SIOCF5 0x%x SIOCF6 0x%x SIOCF8 0x%x\n", 366daacdfa6SKylene Jo Hall tpm_read_index(nscAddrBase,0x21), tpm_read_index(nscAddrBase,0x25), 367daacdfa6SKylene Jo Hall tpm_read_index(nscAddrBase,0x26), tpm_read_index(nscAddrBase,0x28)); 368570302a3SKylene Jo Hall dev_dbg(&pdev->dev, "NSC IO Base0 0x%x\n", 369daacdfa6SKylene Jo Hall (tpm_read_index(nscAddrBase,0x60) << 8) | tpm_read_index(nscAddrBase,0x61)); 370570302a3SKylene Jo Hall dev_dbg(&pdev->dev, "NSC IO Base1 0x%x\n", 371daacdfa6SKylene Jo Hall (tpm_read_index(nscAddrBase,0x62) << 8) | tpm_read_index(nscAddrBase,0x63)); 372570302a3SKylene Jo Hall dev_dbg(&pdev->dev, "NSC Interrupt number and wakeup 0x%x\n", 373daacdfa6SKylene Jo Hall tpm_read_index(nscAddrBase,0x70)); 374570302a3SKylene Jo Hall dev_dbg(&pdev->dev, "NSC IRQ type select 0x%x\n", 375daacdfa6SKylene Jo Hall tpm_read_index(nscAddrBase,0x71)); 376570302a3SKylene Jo Hall dev_dbg(&pdev->dev, 3771da177e4SLinus Torvalds "NSC DMA channel select0 0x%x, select1 0x%x\n", 378daacdfa6SKylene Jo Hall tpm_read_index(nscAddrBase,0x74), tpm_read_index(nscAddrBase,0x75)); 379570302a3SKylene Jo Hall dev_dbg(&pdev->dev, 3801da177e4SLinus Torvalds "NSC Config " 3811da177e4SLinus Torvalds "0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n", 382daacdfa6SKylene Jo Hall tpm_read_index(nscAddrBase,0xF0), tpm_read_index(nscAddrBase,0xF1), 383daacdfa6SKylene Jo Hall tpm_read_index(nscAddrBase,0xF2), tpm_read_index(nscAddrBase,0xF3), 384daacdfa6SKylene Jo Hall tpm_read_index(nscAddrBase,0xF4), tpm_read_index(nscAddrBase,0xF5), 385daacdfa6SKylene Jo Hall tpm_read_index(nscAddrBase,0xF6), tpm_read_index(nscAddrBase,0xF7), 386daacdfa6SKylene Jo Hall tpm_read_index(nscAddrBase,0xF8), tpm_read_index(nscAddrBase,0xF9)); 3871da177e4SLinus Torvalds 388570302a3SKylene Jo Hall dev_info(&pdev->dev, 389daacdfa6SKylene Jo Hall "NSC TPM revision %d\n", 390daacdfa6SKylene Jo Hall tpm_read_index(nscAddrBase, 0x27) & 0x1F); 3911da177e4SLinus Torvalds 3921da177e4SLinus Torvalds return 0; 393e2a8f7a1SKylene Jo Hall 394e2a8f7a1SKylene Jo Hall err_rel_reg: 395e0dd03caSKylene Jo Hall release_region(base, 2); 39629412f0fSStefan Berger err_del_dev: 39729412f0fSStefan Berger platform_device_del(pdev); 39829412f0fSStefan Berger err_put_dev: 39929412f0fSStefan Berger platform_device_put(pdev); 400e2a8f7a1SKylene Jo Hall err_unreg_drv: 40109f50c95SDavid Smith platform_driver_unregister(&nsc_drv); 402e2a8f7a1SKylene Jo Hall return rc; 4031da177e4SLinus Torvalds } 4041da177e4SLinus Torvalds 4051da177e4SLinus Torvalds static void __exit cleanup_nsc(void) 4061da177e4SLinus Torvalds { 407570302a3SKylene Jo Hall if (pdev) { 408570302a3SKylene Jo Hall tpm_nsc_remove(&pdev->dev); 409570302a3SKylene Jo Hall platform_device_unregister(pdev); 410570302a3SKylene Jo Hall } 411570302a3SKylene Jo Hall 41209f50c95SDavid Smith platform_driver_unregister(&nsc_drv); 4131da177e4SLinus Torvalds } 4141da177e4SLinus Torvalds 4151da177e4SLinus Torvalds module_init(init_nsc); 4161da177e4SLinus Torvalds module_exit(cleanup_nsc); 4171da177e4SLinus Torvalds 4181da177e4SLinus Torvalds MODULE_AUTHOR("Leendert van Doorn (leendert@watson.ibm.com)"); 4191da177e4SLinus Torvalds MODULE_DESCRIPTION("TPM Driver"); 4201da177e4SLinus Torvalds MODULE_VERSION("2.0"); 4211da177e4SLinus Torvalds MODULE_LICENSE("GPL"); 422