[PATCH] tpm: tpm_infineon updated to latest interface changes
Apply the latest changes in the TPM interface to the Infineon TPM-driver. Signed-off-by: Marcel Selhorst <selhorst@crypto.rub.de> Acked-by: Kylie Hall <kjhall@us.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
10685a9530
commit
e496f54054
|
@ -104,7 +104,7 @@ static int empty_fifo(struct tpm_chip *chip, int clear_wrfifo)
|
||||||
|
|
||||||
if (clear_wrfifo) {
|
if (clear_wrfifo) {
|
||||||
for (i = 0; i < 4096; i++) {
|
for (i = 0; i < 4096; i++) {
|
||||||
status = inb(chip->vendor->base + WRFIFO);
|
status = inb(chip->vendor.base + WRFIFO);
|
||||||
if (status == 0xff) {
|
if (status == 0xff) {
|
||||||
if (check == 5)
|
if (check == 5)
|
||||||
break;
|
break;
|
||||||
|
@ -124,8 +124,8 @@ static int empty_fifo(struct tpm_chip *chip, int clear_wrfifo)
|
||||||
*/
|
*/
|
||||||
i = 0;
|
i = 0;
|
||||||
do {
|
do {
|
||||||
status = inb(chip->vendor->base + RDFIFO);
|
status = inb(chip->vendor.base + RDFIFO);
|
||||||
status = inb(chip->vendor->base + STAT);
|
status = inb(chip->vendor.base + STAT);
|
||||||
i++;
|
i++;
|
||||||
if (i == TPM_MAX_TRIES)
|
if (i == TPM_MAX_TRIES)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
@ -138,7 +138,7 @@ static int wait(struct tpm_chip *chip, int wait_for_bit)
|
||||||
int status;
|
int status;
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < TPM_MAX_TRIES; i++) {
|
for (i = 0; i < TPM_MAX_TRIES; i++) {
|
||||||
status = inb(chip->vendor->base + STAT);
|
status = inb(chip->vendor.base + STAT);
|
||||||
/* check the status-register if wait_for_bit is set */
|
/* check the status-register if wait_for_bit is set */
|
||||||
if (status & 1 << wait_for_bit)
|
if (status & 1 << wait_for_bit)
|
||||||
break;
|
break;
|
||||||
|
@ -157,7 +157,7 @@ static int wait(struct tpm_chip *chip, int wait_for_bit)
|
||||||
static void wait_and_send(struct tpm_chip *chip, u8 sendbyte)
|
static void wait_and_send(struct tpm_chip *chip, u8 sendbyte)
|
||||||
{
|
{
|
||||||
wait(chip, STAT_XFE);
|
wait(chip, STAT_XFE);
|
||||||
outb(sendbyte, chip->vendor->base + WRFIFO);
|
outb(sendbyte, chip->vendor.base + WRFIFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Note: WTX means Waiting-Time-Extension. Whenever the TPM needs more
|
/* Note: WTX means Waiting-Time-Extension. Whenever the TPM needs more
|
||||||
|
@ -204,7 +204,7 @@ recv_begin:
|
||||||
ret = wait(chip, STAT_RDA);
|
ret = wait(chip, STAT_RDA);
|
||||||
if (ret)
|
if (ret)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
buf[i] = inb(chip->vendor->base + RDFIFO);
|
buf[i] = inb(chip->vendor.base + RDFIFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] != TPM_VL_VER) {
|
if (buf[0] != TPM_VL_VER) {
|
||||||
|
@ -219,7 +219,7 @@ recv_begin:
|
||||||
|
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
wait(chip, STAT_RDA);
|
wait(chip, STAT_RDA);
|
||||||
buf[i] = inb(chip->vendor->base + RDFIFO);
|
buf[i] = inb(chip->vendor.base + RDFIFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((size == 0x6D00) && (buf[1] == 0x80)) {
|
if ((size == 0x6D00) && (buf[1] == 0x80)) {
|
||||||
|
@ -268,7 +268,7 @@ static int tpm_inf_send(struct tpm_chip *chip, u8 * buf, size_t count)
|
||||||
u8 count_high, count_low, count_4, count_3, count_2, count_1;
|
u8 count_high, count_low, count_4, count_3, count_2, count_1;
|
||||||
|
|
||||||
/* Disabling Reset, LP and IRQC */
|
/* Disabling Reset, LP and IRQC */
|
||||||
outb(RESET_LP_IRQC_DISABLE, chip->vendor->base + CMD);
|
outb(RESET_LP_IRQC_DISABLE, chip->vendor.base + CMD);
|
||||||
|
|
||||||
ret = empty_fifo(chip, 1);
|
ret = empty_fifo(chip, 1);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
@ -319,7 +319,7 @@ static void tpm_inf_cancel(struct tpm_chip *chip)
|
||||||
|
|
||||||
static u8 tpm_inf_status(struct tpm_chip *chip)
|
static u8 tpm_inf_status(struct tpm_chip *chip)
|
||||||
{
|
{
|
||||||
return inb(chip->vendor->base + STAT);
|
return inb(chip->vendor.base + STAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL);
|
static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL);
|
||||||
|
@ -346,7 +346,7 @@ static struct file_operations inf_ops = {
|
||||||
.release = tpm_release,
|
.release = tpm_release,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct tpm_vendor_specific tpm_inf = {
|
static const struct tpm_vendor_specific tpm_inf = {
|
||||||
.recv = tpm_inf_recv,
|
.recv = tpm_inf_recv,
|
||||||
.send = tpm_inf_send,
|
.send = tpm_inf_send,
|
||||||
.cancel = tpm_inf_cancel,
|
.cancel = tpm_inf_cancel,
|
||||||
|
@ -375,6 +375,7 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev,
|
||||||
int version[2];
|
int version[2];
|
||||||
int productid[2];
|
int productid[2];
|
||||||
char chipname[20];
|
char chipname[20];
|
||||||
|
struct tpm_chip *chip;
|
||||||
|
|
||||||
/* read IO-ports through PnP */
|
/* read IO-ports through PnP */
|
||||||
if (pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) &&
|
if (pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) &&
|
||||||
|
@ -395,14 +396,13 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev,
|
||||||
goto err_last;
|
goto err_last;
|
||||||
}
|
}
|
||||||
/* publish my base address and request region */
|
/* publish my base address and request region */
|
||||||
tpm_inf.base = TPM_INF_BASE;
|
|
||||||
if (request_region
|
if (request_region
|
||||||
(tpm_inf.base, TPM_INF_PORT_LEN, "tpm_infineon0") == NULL) {
|
(TPM_INF_BASE, TPM_INF_PORT_LEN, "tpm_infineon0") == NULL) {
|
||||||
rc = -EINVAL;
|
rc = -EINVAL;
|
||||||
goto err_last;
|
goto err_last;
|
||||||
}
|
}
|
||||||
if (request_region(TPM_INF_ADDR, TPM_INF_ADDR_LEN,
|
if (request_region
|
||||||
"tpm_infineon0") == NULL) {
|
(TPM_INF_ADDR, TPM_INF_ADDR_LEN, "tpm_infineon0") == NULL) {
|
||||||
rc = -EINVAL;
|
rc = -EINVAL;
|
||||||
goto err_last;
|
goto err_last;
|
||||||
}
|
}
|
||||||
|
@ -442,9 +442,9 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev,
|
||||||
|
|
||||||
/* configure TPM with IO-ports */
|
/* configure TPM with IO-ports */
|
||||||
outb(IOLIMH, TPM_INF_ADDR);
|
outb(IOLIMH, TPM_INF_ADDR);
|
||||||
outb(((tpm_inf.base >> 8) & 0xff), TPM_INF_DATA);
|
outb(((TPM_INF_BASE >> 8) & 0xff), TPM_INF_DATA);
|
||||||
outb(IOLIML, TPM_INF_ADDR);
|
outb(IOLIML, TPM_INF_ADDR);
|
||||||
outb((tpm_inf.base & 0xff), TPM_INF_DATA);
|
outb((TPM_INF_BASE & 0xff), TPM_INF_DATA);
|
||||||
|
|
||||||
/* control if IO-ports are set correctly */
|
/* control if IO-ports are set correctly */
|
||||||
outb(IOLIMH, TPM_INF_ADDR);
|
outb(IOLIMH, TPM_INF_ADDR);
|
||||||
|
@ -452,10 +452,10 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev,
|
||||||
outb(IOLIML, TPM_INF_ADDR);
|
outb(IOLIML, TPM_INF_ADDR);
|
||||||
iol = inb(TPM_INF_DATA);
|
iol = inb(TPM_INF_DATA);
|
||||||
|
|
||||||
if ((ioh << 8 | iol) != tpm_inf.base) {
|
if ((ioh << 8 | iol) != TPM_INF_BASE) {
|
||||||
dev_err(&dev->dev,
|
dev_err(&dev->dev,
|
||||||
"Could not set IO-ports to 0x%lx\n",
|
"Could not set IO-ports to 0x%x\n",
|
||||||
tpm_inf.base);
|
TPM_INF_BASE);
|
||||||
rc = -EIO;
|
rc = -EIO;
|
||||||
goto err_release_region;
|
goto err_release_region;
|
||||||
}
|
}
|
||||||
|
@ -466,15 +466,15 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev,
|
||||||
outb(DISABLE_REGISTER_PAIR, TPM_INF_ADDR);
|
outb(DISABLE_REGISTER_PAIR, TPM_INF_ADDR);
|
||||||
|
|
||||||
/* disable RESET, LP and IRQC */
|
/* disable RESET, LP and IRQC */
|
||||||
outb(RESET_LP_IRQC_DISABLE, tpm_inf.base + CMD);
|
outb(RESET_LP_IRQC_DISABLE, TPM_INF_BASE + CMD);
|
||||||
|
|
||||||
/* Finally, we're done, print some infos */
|
/* Finally, we're done, print some infos */
|
||||||
dev_info(&dev->dev, "TPM found: "
|
dev_info(&dev->dev, "TPM found: "
|
||||||
"config base 0x%x, "
|
"config base 0x%x, "
|
||||||
"io base 0x%x, "
|
"io base 0x%x, "
|
||||||
"chip version %02x%02x, "
|
"chip version 0x%02x%02x, "
|
||||||
"vendor id %x%x (Infineon), "
|
"vendor id 0x%x%x (Infineon), "
|
||||||
"product id %02x%02x"
|
"product id 0x%02x%02x"
|
||||||
"%s\n",
|
"%s\n",
|
||||||
TPM_INF_ADDR,
|
TPM_INF_ADDR,
|
||||||
TPM_INF_BASE,
|
TPM_INF_BASE,
|
||||||
|
@ -482,11 +482,10 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev,
|
||||||
vendorid[0], vendorid[1],
|
vendorid[0], vendorid[1],
|
||||||
productid[0], productid[1], chipname);
|
productid[0], productid[1], chipname);
|
||||||
|
|
||||||
rc = tpm_register_hardware(&dev->dev, &tpm_inf);
|
if (!(chip = tpm_register_hardware(&dev->dev, &tpm_inf))) {
|
||||||
if (rc < 0) {
|
|
||||||
rc = -ENODEV;
|
|
||||||
goto err_release_region;
|
goto err_release_region;
|
||||||
}
|
}
|
||||||
|
chip->vendor.base = TPM_INF_BASE;
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
rc = -ENODEV;
|
rc = -ENODEV;
|
||||||
|
@ -494,7 +493,7 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
err_release_region:
|
err_release_region:
|
||||||
release_region(tpm_inf.base, TPM_INF_PORT_LEN);
|
release_region(TPM_INF_BASE, TPM_INF_PORT_LEN);
|
||||||
release_region(TPM_INF_ADDR, TPM_INF_ADDR_LEN);
|
release_region(TPM_INF_ADDR, TPM_INF_ADDR_LEN);
|
||||||
|
|
||||||
err_last:
|
err_last:
|
||||||
|
@ -506,7 +505,8 @@ static __devexit void tpm_inf_pnp_remove(struct pnp_dev *dev)
|
||||||
struct tpm_chip *chip = pnp_get_drvdata(dev);
|
struct tpm_chip *chip = pnp_get_drvdata(dev);
|
||||||
|
|
||||||
if (chip) {
|
if (chip) {
|
||||||
release_region(chip->vendor->base, TPM_INF_PORT_LEN);
|
release_region(TPM_INF_BASE, TPM_INF_PORT_LEN);
|
||||||
|
release_region(TPM_INF_ADDR, TPM_INF_ADDR_LEN);
|
||||||
tpm_remove_hardware(chip->dev);
|
tpm_remove_hardware(chip->dev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -538,5 +538,5 @@ module_exit(cleanup_inf);
|
||||||
|
|
||||||
MODULE_AUTHOR("Marcel Selhorst <selhorst@crypto.rub.de>");
|
MODULE_AUTHOR("Marcel Selhorst <selhorst@crypto.rub.de>");
|
||||||
MODULE_DESCRIPTION("Driver for Infineon TPM SLD 9630 TT 1.1 / SLB 9635 TT 1.2");
|
MODULE_DESCRIPTION("Driver for Infineon TPM SLD 9630 TT 1.1 / SLB 9635 TT 1.2");
|
||||||
MODULE_VERSION("1.7");
|
MODULE_VERSION("1.8");
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
|
|
Loading…
Reference in New Issue