ia64/xen-unstable

changeset 8745:514f2585d102

Converge the TPM drivers in the Xen repository
with those coming from the 2.6.15 kernel. Some files can now be
taken from 2.6.15 directly and can therefore be removed.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
author cl349@firebug.cl.cam.ac.uk
date Fri Feb 03 09:31:28 2006 +0000 (2006-02-03)
parents cc63196c0d2f
children 7bafcb7c24eb
files linux-2.6-xen-sparse/drivers/char/tpm/tpm.c linux-2.6-xen-sparse/drivers/char/tpm/tpm.h linux-2.6-xen-sparse/drivers/char/tpm/tpm_atmel.c linux-2.6-xen-sparse/drivers/char/tpm/tpm_nsc.c linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/char/tpm/tpm.c	Thu Feb 02 21:21:47 2006 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/char/tpm/tpm.c	Fri Feb 03 09:31:28 2006 +0000
     1.3 @@ -28,9 +28,6 @@
     1.4  #include <linux/spinlock.h>
     1.5  #include "tpm.h"
     1.6  
     1.7 -#define TPM_CHIP_NUM_MASK	0x0000ffff
     1.8 -#define TPM_CHIP_TYPE_SHIFT	16	
     1.9 -
    1.10  enum tpm_const {
    1.11  	TPM_MINOR = 224,	/* officially assigned */
    1.12  	TPM_MIN_BUFSIZE = 2048,
     2.1 --- a/linux-2.6-xen-sparse/drivers/char/tpm/tpm.h	Thu Feb 02 21:21:47 2006 +0000
     2.2 +++ b/linux-2.6-xen-sparse/drivers/char/tpm/tpm.h	Fri Feb 03 09:31:28 2006 +0000
     2.3 @@ -50,9 +50,12 @@ struct tpm_vendor_specific {
     2.4  	u8 req_complete_mask;
     2.5  	u8 req_complete_val;
     2.6  	u8 req_canceled;
     2.7 -	u16 base;		/* TPM base address */
     2.8 -	int drv_type;
     2.9  	u32 buffersize;
    2.10 +	void __iomem *iobase;		/* ioremapped address */
    2.11 +	unsigned long base;		/* TPM base address */
    2.12 +
    2.13 +	int region_size;
    2.14 +	int have_region;
    2.15  
    2.16  	int (*recv) (struct tpm_chip *, u8 *, size_t);
    2.17  	int (*send) (struct tpm_chip *, u8 *, size_t);
    2.18 @@ -106,8 +109,8 @@ extern ssize_t tpm_write(struct file *, 
    2.19  			 loff_t *);
    2.20  extern ssize_t tpm_read(struct file *, char __user *, size_t, loff_t *);
    2.21  extern void tpm_remove_hardware(struct device *);
    2.22 -extern int tpm_pm_suspend(struct pci_dev *, pm_message_t);
    2.23 -extern int tpm_pm_resume(struct pci_dev *);
    2.24 +extern int tpm_pm_suspend(struct device *, pm_message_t);
    2.25 +extern int tpm_pm_resume(struct device *);
    2.26  
    2.27  #ifdef CONFIG_ACPI
    2.28  extern struct dentry ** tpm_bios_log_setup(char *);
     3.1 --- a/linux-2.6-xen-sparse/drivers/char/tpm/tpm_atmel.c	Thu Feb 02 21:21:47 2006 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,262 +0,0 @@
     3.4 -/*
     3.5 - * Copyright (C) 2004 IBM Corporation
     3.6 - *
     3.7 - * Authors:
     3.8 - * Leendert van Doorn <leendert@watson.ibm.com>
     3.9 - * Dave Safford <safford@watson.ibm.com>
    3.10 - * Reiner Sailer <sailer@watson.ibm.com>
    3.11 - * Kylene Hall <kjhall@us.ibm.com>
    3.12 - *
    3.13 - * Maintained by: <tpmdd_devel@lists.sourceforge.net>
    3.14 - *
    3.15 - * Device driver for TCG/TCPA TPM (trusted platform module).
    3.16 - * Specifications at www.trustedcomputinggroup.org	 
    3.17 - *
    3.18 - * This program is free software; you can redistribute it and/or
    3.19 - * modify it under the terms of the GNU General Public License as
    3.20 - * published by the Free Software Foundation, version 2 of the
    3.21 - * License.
    3.22 - * 
    3.23 - */
    3.24 -
    3.25 -#include "tpm.h"
    3.26 -#include "tpm_atmel.h"
    3.27 -
    3.28 -/* write status bits */
    3.29 -enum tpm_atmel_write_status {
    3.30 -	ATML_STATUS_ABORT = 0x01,
    3.31 -	ATML_STATUS_LASTBYTE = 0x04
    3.32 -};
    3.33 -/* read status bits */
    3.34 -enum tpm_atmel_read_status {
    3.35 -	ATML_STATUS_BUSY = 0x01,
    3.36 -	ATML_STATUS_DATA_AVAIL = 0x02,
    3.37 -	ATML_STATUS_REWRITE = 0x04,
    3.38 -	ATML_STATUS_READY = 0x08
    3.39 -};
    3.40 -
    3.41 -static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
    3.42 -{
    3.43 -	u8 status, *hdr = buf;
    3.44 -	u32 size;
    3.45 -	int i;
    3.46 -	__be32 *native_size;
    3.47 -
    3.48 -	/* start reading header */
    3.49 -	if (count < 6)
    3.50 -		return -EIO;
    3.51 -
    3.52 -	for (i = 0; i < 6; i++) {
    3.53 -		status = atmel_getb(chip, 1);
    3.54 -		if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
    3.55 -			dev_err(chip->dev, "error reading header\n");
    3.56 -			return -EIO;
    3.57 -		}
    3.58 -		*buf++ = atmel_getb(chip, 0);
    3.59 -	}
    3.60 -
    3.61 -	/* size of the data received */
    3.62 -	native_size = (__force __be32 *) (hdr + 2);
    3.63 -	size = be32_to_cpu(*native_size);
    3.64 -
    3.65 -	if (count < size) {
    3.66 -		dev_err(chip->dev,
    3.67 -			"Recv size(%d) less than available space\n", size);
    3.68 -		for (; i < size; i++) {	/* clear the waiting data anyway */
    3.69 -			status = atmel_getb(chip, 1);
    3.70 -			if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
    3.71 -				dev_err(chip->dev, "error reading data\n");
    3.72 -				return -EIO;
    3.73 -			}
    3.74 -		}
    3.75 -		return -EIO;
    3.76 -	}
    3.77 -
    3.78 -	/* read all the data available */
    3.79 -	for (; i < size; i++) {
    3.80 -		status = atmel_getb(chip, 1);
    3.81 -		if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
    3.82 -			dev_err(chip->dev, "error reading data\n");
    3.83 -			return -EIO;
    3.84 -		}
    3.85 -		*buf++ = atmel_getb(chip, 0);
    3.86 -	}
    3.87 -
    3.88 -	/* make sure data available is gone */
    3.89 -	status = atmel_getb(chip, 1);
    3.90 -	if (status & ATML_STATUS_DATA_AVAIL) {
    3.91 -		dev_err(chip->dev, "data available is stuck\n");
    3.92 -		return -EIO;
    3.93 -	}
    3.94 -
    3.95 -	return size;
    3.96 -}
    3.97 -
    3.98 -static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count)
    3.99 -{
   3.100 -	int i;
   3.101 -
   3.102 -	dev_dbg(chip->dev, "tpm_atml_send:\n");
   3.103 -	for (i = 0; i < count; i++) {
   3.104 -		dev_dbg(chip->dev, "%d 0x%x(%d)\n",  i, buf[i], buf[i]);
   3.105 -		atmel_putb(buf[i], chip, 0);
   3.106 -	}
   3.107 -
   3.108 -	return count;
   3.109 -}
   3.110 -
   3.111 -static void tpm_atml_cancel(struct tpm_chip *chip)
   3.112 -{
   3.113 -	atmel_putb(ATML_STATUS_ABORT, chip, 1);
   3.114 -}
   3.115 -
   3.116 -static u8 tpm_atml_status(struct tpm_chip *chip)
   3.117 -{
   3.118 -	return atmel_getb(chip, 1);
   3.119 -}
   3.120 -
   3.121 -static struct file_operations atmel_ops = {
   3.122 -	.owner = THIS_MODULE,
   3.123 -	.llseek = no_llseek,
   3.124 -	.open = tpm_open,
   3.125 -	.read = tpm_read,
   3.126 -	.write = tpm_write,
   3.127 -	.release = tpm_release,
   3.128 -};
   3.129 -
   3.130 -static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL);
   3.131 -static DEVICE_ATTR(pcrs, S_IRUGO, tpm_show_pcrs, NULL);
   3.132 -static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps, NULL);
   3.133 -static DEVICE_ATTR(cancel, S_IWUSR |S_IWGRP, NULL, tpm_store_cancel);
   3.134 -
   3.135 -static struct attribute* atmel_attrs[] = {
   3.136 -	&dev_attr_pubek.attr,
   3.137 -	&dev_attr_pcrs.attr,
   3.138 -	&dev_attr_caps.attr,
   3.139 -	&dev_attr_cancel.attr,
   3.140 -	NULL,
   3.141 -};
   3.142 -
   3.143 -static struct attribute_group atmel_attr_grp = { .attrs = atmel_attrs };
   3.144 -
   3.145 -static struct tpm_vendor_specific tpm_atmel = {
   3.146 -	.recv = tpm_atml_recv,
   3.147 -	.send = tpm_atml_send,
   3.148 -	.cancel = tpm_atml_cancel,
   3.149 -	.status = tpm_atml_status,
   3.150 -	.req_complete_mask = ATML_STATUS_BUSY | ATML_STATUS_DATA_AVAIL,
   3.151 -	.req_complete_val = ATML_STATUS_DATA_AVAIL,
   3.152 -	.req_canceled = ATML_STATUS_READY,
   3.153 -	.attr_group = &atmel_attr_grp,
   3.154 -	.miscdev = { .fops = &atmel_ops, },
   3.155 -};
   3.156 -
   3.157 -static struct platform_device *pdev;
   3.158 -
   3.159 -static void atml_plat_remove(void)
   3.160 -{
   3.161 -	struct tpm_chip *chip = dev_get_drvdata(&pdev->dev);
   3.162 -
   3.163 -	if (chip) {
   3.164 -		if (chip->vendor->have_region)
   3.165 -			atmel_release_region(chip->vendor->base,
   3.166 -					     chip->vendor->region_size);
   3.167 -		atmel_put_base_addr(chip->vendor);
   3.168 -		tpm_remove_hardware(chip->dev);
   3.169 -		platform_device_unregister(pdev);
   3.170 -	}
   3.171 -}
   3.172 -
   3.173 -static struct device_driver atml_drv = {
   3.174 -	.name = "tpm_atmel",
   3.175 -	.bus = &platform_bus_type,
   3.176 -	.owner = THIS_MODULE,
   3.177 -	.suspend = tpm_pm_suspend,
   3.178 -	.resume = tpm_pm_resume,
   3.179 -};
   3.180 -
   3.181 -static int __init init_atmel(void)
   3.182 -{
   3.183 -	int rc = 0;
   3.184 -
   3.185 -	driver_register(&atml_drv);
   3.186 -
   3.187 -	if ((tpm_atmel.iobase = atmel_get_base_addr(&tpm_atmel)) == NULL) {
   3.188 -		rc = -ENODEV;
   3.189 -		goto err_unreg_drv;
   3.190 -	}
   3.191 -
   3.192 -	/* query chip for its version number */
   3.193 -	if ((version[0] = tpm_read_index(TPM_ADDR, 0x00)) != 0xFF) {
   3.194 -		version[1] = tpm_read_index(TPM_ADDR, 0x01);
   3.195 -		version[2] = tpm_read_index(TPM_ADDR, 0x02);
   3.196 -		version[3] = tpm_read_index(TPM_ADDR, 0x03);
   3.197 -	} else {
   3.198 -		dev_info(&pci_dev->dev, "version query failed\n");
   3.199 -		rc = -ENODEV;
   3.200 -		goto out_err;
   3.201 -	}
   3.202 -
   3.203 -	if ((rc = tpm_register_hardware(&pci_dev->dev, &tpm_atmel)) < 0)
   3.204 -		goto out_err;
   3.205 -
   3.206 -	dev_info(&pci_dev->dev,
   3.207 -		 "Atmel TPM version %d.%d.%d.%d\n", version[0], version[1],
   3.208 -		 version[2], version[3]);
   3.209 -
   3.210 -	return 0;
   3.211 -out_err:
   3.212 -	pci_disable_device(pci_dev);
   3.213 -	return rc;
   3.214 -}
   3.215 -
   3.216 -static void __devexit tpm_atml_remove(struct pci_dev *pci_dev) 
   3.217 -{
   3.218 -	struct tpm_chip *chip = pci_get_drvdata(pci_dev);
   3.219 -
   3.220 -	if ( chip )
   3.221 -		tpm_remove_hardware(chip->dev);
   3.222 -}
   3.223 -
   3.224 -static struct pci_device_id tpm_pci_tbl[] __devinitdata = {
   3.225 -	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_0)},
   3.226 -	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_12)},
   3.227 -	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0)},
   3.228 -	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12)},
   3.229 -	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0)},
   3.230 -	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_0)},
   3.231 -	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1)},
   3.232 -	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0)},
   3.233 -	{PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_LPC)},
   3.234 -	{PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6LPC)},
   3.235 -	{0,}
   3.236 -};
   3.237 -
   3.238 -MODULE_DEVICE_TABLE(pci, tpm_pci_tbl);
   3.239 -
   3.240 -static struct pci_driver atmel_pci_driver = {
   3.241 -	.name = "tpm_atmel",
   3.242 -	.id_table = tpm_pci_tbl,
   3.243 -	.probe = tpm_atml_init,
   3.244 -	.remove = __devexit_p(tpm_atml_remove),
   3.245 -	.suspend = tpm_pm_suspend,
   3.246 -	.resume = tpm_pm_resume,
   3.247 -};
   3.248 -
   3.249 -static int __init init_atmel(void)
   3.250 -{
   3.251 -	return pci_register_driver(&atmel_pci_driver);
   3.252 -}
   3.253 -
   3.254 -static void __exit cleanup_atmel(void)
   3.255 -{
   3.256 -	pci_unregister_driver(&atmel_pci_driver);
   3.257 -}
   3.258 -
   3.259 -fs_initcall(init_atmel);
   3.260 -module_exit(cleanup_atmel);
   3.261 -
   3.262 -MODULE_AUTHOR("Leendert van Doorn (leendert@watson.ibm.com)");
   3.263 -MODULE_DESCRIPTION("TPM Driver");
   3.264 -MODULE_VERSION("2.0");
   3.265 -MODULE_LICENSE("GPL");
     4.1 --- a/linux-2.6-xen-sparse/drivers/char/tpm/tpm_nsc.c	Thu Feb 02 21:21:47 2006 +0000
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,386 +0,0 @@
     4.4 -/*
     4.5 - * Copyright (C) 2004 IBM Corporation
     4.6 - *
     4.7 - * Authors:
     4.8 - * Leendert van Doorn <leendert@watson.ibm.com>
     4.9 - * Dave Safford <safford@watson.ibm.com>
    4.10 - * Reiner Sailer <sailer@watson.ibm.com>
    4.11 - * Kylene Hall <kjhall@us.ibm.com>
    4.12 - *
    4.13 - * Maintained by: <tpmdd_devel@lists.sourceforge.net>
    4.14 - *
    4.15 - * Device driver for TCG/TCPA TPM (trusted platform module).
    4.16 - * Specifications at www.trustedcomputinggroup.org	 
    4.17 - *
    4.18 - * This program is free software; you can redistribute it and/or
    4.19 - * modify it under the terms of the GNU General Public License as
    4.20 - * published by the Free Software Foundation, version 2 of the
    4.21 - * License.
    4.22 - * 
    4.23 - */
    4.24 -
    4.25 -#include "tpm.h"
    4.26 -
    4.27 -/* National definitions */
    4.28 -enum tpm_nsc_addr{
    4.29 -	TPM_NSC_IRQ = 0x07,
    4.30 -	TPM_NSC_BASE0_HI = 0x60,
    4.31 -	TPM_NSC_BASE0_LO = 0x61,
    4.32 -	TPM_NSC_BASE1_HI = 0x62,
    4.33 -	TPM_NSC_BASE1_LO = 0x63
    4.34 -};
    4.35 -
    4.36 -enum tpm_nsc_index {
    4.37 -	NSC_LDN_INDEX = 0x07,
    4.38 -	NSC_SID_INDEX = 0x20,
    4.39 -	NSC_LDC_INDEX = 0x30,
    4.40 -	NSC_DIO_INDEX = 0x60,
    4.41 -	NSC_CIO_INDEX = 0x62,
    4.42 -	NSC_IRQ_INDEX = 0x70,
    4.43 -	NSC_ITS_INDEX = 0x71
    4.44 -};
    4.45 -
    4.46 -enum tpm_nsc_status_loc {
    4.47 -	NSC_STATUS = 0x01,
    4.48 -	NSC_COMMAND = 0x01,
    4.49 -	NSC_DATA = 0x00
    4.50 -};
    4.51 -
    4.52 -/* status bits */
    4.53 -enum tpm_nsc_status {
    4.54 -	NSC_STATUS_OBF = 0x01,	/* output buffer full */
    4.55 -	NSC_STATUS_IBF = 0x02,	/* input buffer full */
    4.56 -	NSC_STATUS_F0 = 0x04,	/* F0 */
    4.57 -	NSC_STATUS_A2 = 0x08,	/* A2 */
    4.58 -	NSC_STATUS_RDY = 0x10,	/* ready to receive command */
    4.59 -	NSC_STATUS_IBR = 0x20	/* ready to receive data */
    4.60 -};
    4.61 -
    4.62 -/* command bits */
    4.63 -enum tpm_nsc_cmd_mode {
    4.64 -	NSC_COMMAND_NORMAL = 0x01,	/* normal mode */
    4.65 -	NSC_COMMAND_EOC = 0x03,
    4.66 -	NSC_COMMAND_CANCEL = 0x22
    4.67 -};
    4.68 -/*
    4.69 - * Wait for a certain status to appear
    4.70 - */
    4.71 -static int wait_for_stat(struct tpm_chip *chip, u8 mask, u8 val, u8 * data)
    4.72 -{
    4.73 -	unsigned long stop;
    4.74 -
    4.75 -	/* status immediately available check */
    4.76 -	*data = inb(chip->vendor->base + NSC_STATUS);
    4.77 -	if ((*data & mask) == val)
    4.78 -		return 0;
    4.79 -
    4.80 -	/* wait for status */
    4.81 -	stop = jiffies + 10 * HZ;
    4.82 -	do {
    4.83 -		msleep(TPM_TIMEOUT);
    4.84 -		*data = inb(chip->vendor->base + 1);
    4.85 -		if ((*data & mask) == val)
    4.86 -			return 0;
    4.87 -	}
    4.88 -	while (time_before(jiffies, stop));
    4.89 -
    4.90 -	return -EBUSY;
    4.91 -}
    4.92 -
    4.93 -static int nsc_wait_for_ready(struct tpm_chip *chip)
    4.94 -{
    4.95 -	int status;
    4.96 -	unsigned long stop;
    4.97 -
    4.98 -	/* status immediately available check */
    4.99 -	status = inb(chip->vendor->base + NSC_STATUS);
   4.100 -	if (status & NSC_STATUS_OBF)
   4.101 -		status = inb(chip->vendor->base + NSC_DATA);
   4.102 -	if (status & NSC_STATUS_RDY)
   4.103 -		return 0;
   4.104 -
   4.105 -	/* wait for status */
   4.106 -	stop = jiffies + 100;
   4.107 -	do {
   4.108 -		msleep(TPM_TIMEOUT);
   4.109 -		status = inb(chip->vendor->base + NSC_STATUS);
   4.110 -		if (status & NSC_STATUS_OBF)
   4.111 -			status = inb(chip->vendor->base + NSC_DATA);
   4.112 -		if (status & NSC_STATUS_RDY)
   4.113 -			return 0;
   4.114 -	}
   4.115 -	while (time_before(jiffies, stop));
   4.116 -
   4.117 -	dev_info(chip->dev, "wait for ready failed\n");
   4.118 -	return -EBUSY;
   4.119 -}
   4.120 -
   4.121 -
   4.122 -static int tpm_nsc_recv(struct tpm_chip *chip, u8 * buf, size_t count)
   4.123 -{
   4.124 -	u8 *buffer = buf;
   4.125 -	u8 data, *p;
   4.126 -	u32 size;
   4.127 -	__be32 *native_size;
   4.128 -
   4.129 -	if (count < 6)
   4.130 -		return -EIO;
   4.131 -
   4.132 -	if (wait_for_stat(chip, NSC_STATUS_F0, NSC_STATUS_F0, &data) < 0) {
   4.133 -		dev_err(chip->dev, "F0 timeout\n");
   4.134 -		return -EIO;
   4.135 -	}
   4.136 -	if ((data =
   4.137 -	     inb(chip->vendor->base + NSC_DATA)) != NSC_COMMAND_NORMAL) {
   4.138 -		dev_err(chip->dev, "not in normal mode (0x%x)\n",
   4.139 -			data);
   4.140 -		return -EIO;
   4.141 -	}
   4.142 -
   4.143 -	/* read the whole packet */
   4.144 -	for (p = buffer; p < &buffer[count]; p++) {
   4.145 -		if (wait_for_stat
   4.146 -		    (chip, NSC_STATUS_OBF, NSC_STATUS_OBF, &data) < 0) {
   4.147 -			dev_err(chip->dev,
   4.148 -				"OBF timeout (while reading data)\n");
   4.149 -			return -EIO;
   4.150 -		}
   4.151 -		if (data & NSC_STATUS_F0)
   4.152 -			break;
   4.153 -		*p = inb(chip->vendor->base + NSC_DATA);
   4.154 -	}
   4.155 -
   4.156 -	if ((data & NSC_STATUS_F0) == 0 &&
   4.157 -	(wait_for_stat(chip, NSC_STATUS_F0, NSC_STATUS_F0, &data) < 0)) {
   4.158 -		dev_err(chip->dev, "F0 not set\n");
   4.159 -		return -EIO;
   4.160 -	}
   4.161 -	if ((data = inb(chip->vendor->base + NSC_DATA)) != NSC_COMMAND_EOC) {
   4.162 -		dev_err(chip->dev,
   4.163 -			"expected end of command(0x%x)\n", data);
   4.164 -		return -EIO;
   4.165 -	}
   4.166 -
   4.167 -	native_size = (__force __be32 *) (buf + 2);
   4.168 -	size = be32_to_cpu(*native_size);
   4.169 -
   4.170 -	if (count < size)
   4.171 -		return -EIO;
   4.172 -
   4.173 -	return size;
   4.174 -}
   4.175 -
   4.176 -static int tpm_nsc_send(struct tpm_chip *chip, u8 * buf, size_t count)
   4.177 -{
   4.178 -	u8 data;
   4.179 -	int i;
   4.180 -
   4.181 -	/*
   4.182 -	 * If we hit the chip with back to back commands it locks up
   4.183 -	 * and never set IBF. Hitting it with this "hammer" seems to
   4.184 -	 * fix it. Not sure why this is needed, we followed the flow
   4.185 -	 * chart in the manual to the letter.
   4.186 -	 */
   4.187 -	outb(NSC_COMMAND_CANCEL, chip->vendor->base + NSC_COMMAND);
   4.188 -
   4.189 -	if (nsc_wait_for_ready(chip) != 0)
   4.190 -		return -EIO;
   4.191 -
   4.192 -	if (wait_for_stat(chip, NSC_STATUS_IBF, 0, &data) < 0) {
   4.193 -		dev_err(chip->dev, "IBF timeout\n");
   4.194 -		return -EIO;
   4.195 -	}
   4.196 -
   4.197 -	outb(NSC_COMMAND_NORMAL, chip->vendor->base + NSC_COMMAND);
   4.198 -	if (wait_for_stat(chip, NSC_STATUS_IBR, NSC_STATUS_IBR, &data) < 0) {
   4.199 -		dev_err(chip->dev, "IBR timeout\n");
   4.200 -		return -EIO;
   4.201 -	}
   4.202 -
   4.203 -	for (i = 0; i < count; i++) {
   4.204 -		if (wait_for_stat(chip, NSC_STATUS_IBF, 0, &data) < 0) {
   4.205 -			dev_err(chip->dev,
   4.206 -				"IBF timeout (while writing data)\n");
   4.207 -			return -EIO;
   4.208 -		}
   4.209 -		outb(buf[i], chip->vendor->base + NSC_DATA);
   4.210 -	}
   4.211 -
   4.212 -	if (wait_for_stat(chip, NSC_STATUS_IBF, 0, &data) < 0) {
   4.213 -		dev_err(chip->dev, "IBF timeout\n");
   4.214 -		return -EIO;
   4.215 -	}
   4.216 -	outb(NSC_COMMAND_EOC, chip->vendor->base + NSC_COMMAND);
   4.217 -
   4.218 -	return count;
   4.219 -}
   4.220 -
   4.221 -static void tpm_nsc_cancel(struct tpm_chip *chip)
   4.222 -{
   4.223 -	outb(NSC_COMMAND_CANCEL, chip->vendor->base + NSC_COMMAND);
   4.224 -}
   4.225 -
   4.226 -static u8 tpm_nsc_status(struct tpm_chip *chip)
   4.227 -{
   4.228 -	return inb(chip->vendor->base + NSC_STATUS);
   4.229 -}
   4.230 -
   4.231 -static struct file_operations nsc_ops = {
   4.232 -	.owner = THIS_MODULE,
   4.233 -	.llseek = no_llseek,
   4.234 -	.open = tpm_open,
   4.235 -	.read = tpm_read,
   4.236 -	.write = tpm_write,
   4.237 -	.release = tpm_release,
   4.238 -};
   4.239 -
   4.240 -static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL);
   4.241 -static DEVICE_ATTR(pcrs, S_IRUGO, tpm_show_pcrs, NULL);
   4.242 -static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps, NULL);
   4.243 -static DEVICE_ATTR(cancel, S_IWUSR|S_IWGRP, NULL, tpm_store_cancel);
   4.244 -
   4.245 -static struct attribute * nsc_attrs[] = {
   4.246 -	&dev_attr_pubek.attr,
   4.247 -	&dev_attr_pcrs.attr,
   4.248 -	&dev_attr_caps.attr,
   4.249 -	&dev_attr_cancel.attr,
   4.250 -	0,
   4.251 -};
   4.252 -
   4.253 -static struct attribute_group nsc_attr_grp = { .attrs = nsc_attrs };
   4.254 -
   4.255 -static struct tpm_vendor_specific tpm_nsc = {
   4.256 -	.recv = tpm_nsc_recv,
   4.257 -	.send = tpm_nsc_send,
   4.258 -	.cancel = tpm_nsc_cancel,
   4.259 -	.status = tpm_nsc_status,
   4.260 -	.req_complete_mask = NSC_STATUS_OBF,
   4.261 -	.req_complete_val = NSC_STATUS_OBF,
   4.262 -	.req_canceled = NSC_STATUS_RDY,
   4.263 -	.attr_group = &nsc_attr_grp,
   4.264 -	.miscdev = { .fops = &nsc_ops, },
   4.265 -};
   4.266 -
   4.267 -static int __devinit tpm_nsc_init(struct pci_dev *pci_dev,
   4.268 -				  const struct pci_device_id *pci_id)
   4.269 -{
   4.270 -	int rc = 0;
   4.271 -	int lo, hi;
   4.272 -	int nscAddrBase = TPM_ADDR;
   4.273 -
   4.274 -
   4.275 -	if (pci_enable_device(pci_dev))
   4.276 -		return -EIO;
   4.277 -
   4.278 -	/* select PM channel 1 */
   4.279 -	tpm_write_index(nscAddrBase,NSC_LDN_INDEX, 0x12);
   4.280 -
   4.281 -	/* verify that it is a National part (SID) */
   4.282 -	if (tpm_read_index(TPM_ADDR, NSC_SID_INDEX) != 0xEF) {
   4.283 -		nscAddrBase = (tpm_read_index(TPM_SUPERIO_ADDR, 0x2C)<<8)|
   4.284 -			(tpm_read_index(TPM_SUPERIO_ADDR, 0x2B)&0xFE);
   4.285 -		if (tpm_read_index(nscAddrBase, NSC_SID_INDEX) != 0xF6) {
   4.286 -			rc = -ENODEV;
   4.287 -			goto out_err;
   4.288 -		}
   4.289 -	}
   4.290 -
   4.291 -	hi = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_HI);
   4.292 -	lo = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_LO);
   4.293 -	tpm_nsc.base = (hi<<8) | lo;
   4.294 -
   4.295 -	dev_dbg(&pci_dev->dev, "NSC TPM detected\n");
   4.296 -	dev_dbg(&pci_dev->dev,
   4.297 -		"NSC LDN 0x%x, SID 0x%x, SRID 0x%x\n",
   4.298 -		tpm_read_index(nscAddrBase,0x07), tpm_read_index(nscAddrBase,0x20),
   4.299 -		tpm_read_index(nscAddrBase,0x27));
   4.300 -	dev_dbg(&pci_dev->dev,
   4.301 -		"NSC SIOCF1 0x%x SIOCF5 0x%x SIOCF6 0x%x SIOCF8 0x%x\n",
   4.302 -		tpm_read_index(nscAddrBase,0x21), tpm_read_index(nscAddrBase,0x25),
   4.303 -		tpm_read_index(nscAddrBase,0x26), tpm_read_index(nscAddrBase,0x28));
   4.304 -	dev_dbg(&pci_dev->dev, "NSC IO Base0 0x%x\n",
   4.305 -		(tpm_read_index(nscAddrBase,0x60) << 8) | tpm_read_index(nscAddrBase,0x61));
   4.306 -	dev_dbg(&pci_dev->dev, "NSC IO Base1 0x%x\n",
   4.307 -		(tpm_read_index(nscAddrBase,0x62) << 8) | tpm_read_index(nscAddrBase,0x63));
   4.308 -	dev_dbg(&pci_dev->dev, "NSC Interrupt number and wakeup 0x%x\n",
   4.309 -		tpm_read_index(nscAddrBase,0x70));
   4.310 -	dev_dbg(&pci_dev->dev, "NSC IRQ type select 0x%x\n",
   4.311 -		tpm_read_index(nscAddrBase,0x71));
   4.312 -	dev_dbg(&pci_dev->dev,
   4.313 -		"NSC DMA channel select0 0x%x, select1 0x%x\n",
   4.314 -		tpm_read_index(nscAddrBase,0x74), tpm_read_index(nscAddrBase,0x75));
   4.315 -	dev_dbg(&pci_dev->dev,
   4.316 -		"NSC Config "
   4.317 -		"0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
   4.318 -		tpm_read_index(nscAddrBase,0xF0), tpm_read_index(nscAddrBase,0xF1),
   4.319 -		tpm_read_index(nscAddrBase,0xF2), tpm_read_index(nscAddrBase,0xF3),
   4.320 -		tpm_read_index(nscAddrBase,0xF4), tpm_read_index(nscAddrBase,0xF5),
   4.321 -		tpm_read_index(nscAddrBase,0xF6), tpm_read_index(nscAddrBase,0xF7),
   4.322 -		tpm_read_index(nscAddrBase,0xF8), tpm_read_index(nscAddrBase,0xF9));
   4.323 -
   4.324 -	dev_info(&pci_dev->dev,
   4.325 -		 "NSC TPM revision %d\n",
   4.326 -		 tpm_read_index(nscAddrBase, 0x27) & 0x1F);
   4.327 -
   4.328 -	/* enable the DPM module */
   4.329 -	tpm_write_index(nscAddrBase, NSC_LDC_INDEX, 0x01);
   4.330 -
   4.331 -	if ((rc = tpm_register_hardware(&pci_dev->dev, &tpm_nsc)) < 0)
   4.332 -		goto out_err;
   4.333 -
   4.334 -	return 0;
   4.335 -
   4.336 -out_err:
   4.337 -	pci_disable_device(pci_dev);
   4.338 -	return rc;
   4.339 -}
   4.340 -
   4.341 -static void __devexit tpm_nsc_remove(struct pci_dev *pci_dev) 
   4.342 -{
   4.343 -	struct tpm_chip *chip = pci_get_drvdata(pci_dev);
   4.344 -
   4.345 -	if ( chip )
   4.346 -		tpm_remove_hardware(chip->dev);
   4.347 -}
   4.348 -
   4.349 -static struct pci_device_id tpm_pci_tbl[] __devinitdata = {
   4.350 -	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_0)},
   4.351 -	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_12)},
   4.352 -	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0)},
   4.353 -	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12)},
   4.354 -	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0)},
   4.355 -	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_0)},
   4.356 -	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1)},
   4.357 -	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0)},
   4.358 -	{PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_LPC)},
   4.359 -	{0,}
   4.360 -};
   4.361 -
   4.362 -MODULE_DEVICE_TABLE(pci, tpm_pci_tbl);
   4.363 -
   4.364 -static struct pci_driver nsc_pci_driver = {
   4.365 -	.name = "tpm_nsc",
   4.366 -	.id_table = tpm_pci_tbl,
   4.367 -	.probe = tpm_nsc_init,
   4.368 -	.remove = __devexit_p(tpm_nsc_remove),
   4.369 -	.suspend = tpm_pm_suspend,
   4.370 -	.resume = tpm_pm_resume,
   4.371 -};
   4.372 -
   4.373 -static int __init init_nsc(void)
   4.374 -{
   4.375 -	return pci_register_driver(&nsc_pci_driver);
   4.376 -}
   4.377 -
   4.378 -static void __exit cleanup_nsc(void)
   4.379 -{
   4.380 -	pci_unregister_driver(&nsc_pci_driver);
   4.381 -}
   4.382 -
   4.383 -fs_initcall(init_nsc);
   4.384 -module_exit(cleanup_nsc);
   4.385 -
   4.386 -MODULE_AUTHOR("Leendert van Doorn (leendert@watson.ibm.com)");
   4.387 -MODULE_DESCRIPTION("TPM Driver");
   4.388 -MODULE_VERSION("2.0");
   4.389 -MODULE_LICENSE("GPL");
     5.1 --- a/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c	Thu Feb 02 21:21:47 2006 +0000
     5.2 +++ b/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c	Fri Feb 03 09:31:28 2006 +0000
     5.3 @@ -86,11 +86,7 @@ static void __exit cleanup_xen(void);
     5.4  static inline struct transmission *
     5.5  transmission_alloc(void)
     5.6  {
     5.7 -	struct transmission *t = kmalloc(sizeof(*t), GFP_KERNEL);
     5.8 -	if (t) {
     5.9 -		memset(t, 0x0, sizeof(*t));
    5.10 -	}
    5.11 -	return t;
    5.12 +	return kzalloc(sizeof(struct transmission), GFP_KERNEL);
    5.13  }
    5.14  
    5.15  static inline unsigned char *