Release 4.11 drivers/char/tpm/tpm_atmel.c
/*
* Copyright (C) 2004 IBM Corporation
*
* Authors:
* Leendert van Doorn <leendert@watson.ibm.com>
* Dave Safford <safford@watson.ibm.com>
* Reiner Sailer <sailer@watson.ibm.com>
* Kylene Hall <kjhall@us.ibm.com>
*
* Maintained by: <tpmdd-devel@lists.sourceforge.net>
*
* Device driver for TCG/TCPA TPM (trusted platform module).
* Specifications at www.trustedcomputinggroup.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, version 2 of the
* License.
*
*/
#include "tpm.h"
#include "tpm_atmel.h"
/* write status bits */
enum tpm_atmel_write_status {
ATML_STATUS_ABORT = 0x01,
ATML_STATUS_LASTBYTE = 0x04
};
/* read status bits */
enum tpm_atmel_read_status {
ATML_STATUS_BUSY = 0x01,
ATML_STATUS_DATA_AVAIL = 0x02,
ATML_STATUS_REWRITE = 0x04,
ATML_STATUS_READY = 0x08
};
static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
{
struct tpm_atmel_priv *priv = dev_get_drvdata(&chip->dev);
u8 status, *hdr = buf;
u32 size;
int i;
__be32 *native_size;
/* start reading header */
if (count < 6)
return -EIO;
for (i = 0; i < 6; i++) {
status = ioread8(priv->iobase + 1);
if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
dev_err(&chip->dev, "error reading header\n");
return -EIO;
}
*buf++ = ioread8(priv->iobase);
}
/* size of the data received */
native_size = (__force __be32 *) (hdr + 2);
size = be32_to_cpu(*native_size);
if (count < size) {
dev_err(&chip->dev,
"Recv size(%d) less than available space\n", size);
for (; i < size; i++) { /* clear the waiting data anyway */
status = ioread8(priv->iobase + 1);
if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
dev_err(&chip->dev, "error reading data\n");
return -EIO;
}
}
return -EIO;
}
/* read all the data available */
for (; i < size; i++) {
status = ioread8(priv->iobase + 1);
if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
dev_err(&chip->dev, "error reading data\n");
return -EIO;
}
*buf++ = ioread8(priv->iobase);
}
/* make sure data available is gone */
status = ioread8(priv->iobase + 1);
if (status & ATML_STATUS_DATA_AVAIL) {
dev_err(&chip->dev, "data available is stuck\n");
return -EIO;
}
return size;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Kylene Jo Hall | 288 | 90.85% | 2 | 40.00% |
Christophe Ricard | 19 | 5.99% | 2 | 40.00% |
Jason Gunthorpe | 10 | 3.15% | 1 | 20.00% |
Total | 317 | 100.00% | 5 | 100.00% |
static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count)
{
struct tpm_atmel_priv *priv = dev_get_drvdata(&chip->dev);
int i;
dev_dbg(&chip->dev, "tpm_atml_send:\n");
for (i = 0; i < count; i++) {
dev_dbg(&chip->dev, "%d 0x%x(%d)\n", i, buf[i], buf[i]);
iowrite8(buf[i], priv->iobase);
}
return count;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Kylene Jo Hall | 78 | 81.25% | 3 | 50.00% |
Christophe Ricard | 14 | 14.58% | 2 | 33.33% |
Jason Gunthorpe | 4 | 4.17% | 1 | 16.67% |
Total | 96 | 100.00% | 6 | 100.00% |
static void tpm_atml_cancel(struct tpm_chip *chip)
{
struct tpm_atmel_priv *priv = dev_get_drvdata(&chip->dev);
iowrite8(ATML_STATUS_ABORT, priv->iobase + 1);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Kylene Jo Hall | 21 | 60.00% | 2 | 50.00% |
Christophe Ricard | 14 | 40.00% | 2 | 50.00% |
Total | 35 | 100.00% | 4 | 100.00% |
static u8 tpm_atml_status(struct tpm_chip *chip)
{
struct tpm_atmel_priv *priv = dev_get_drvdata(&chip->dev);
return ioread8(priv->iobase + 1);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Kylene Jo Hall | 18 | 52.94% | 2 | 50.00% |
Christophe Ricard | 16 | 47.06% | 2 | 50.00% |
Total | 34 | 100.00% | 4 | 100.00% |
static bool tpm_atml_req_canceled(struct tpm_chip *chip, u8 status)
{
return (status == ATML_STATUS_READY);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Stefan Berger | 21 | 100.00% | 1 | 100.00% |
Total | 21 | 100.00% | 1 | 100.00% |
static const struct tpm_class_ops tpm_atmel = {
.recv = tpm_atml_recv,
.send = tpm_atml_send,
.cancel = tpm_atml_cancel,
.status = tpm_atml_status,
.req_complete_mask = ATML_STATUS_BUSY | ATML_STATUS_DATA_AVAIL,
.req_complete_val = ATML_STATUS_DATA_AVAIL,
.req_canceled = tpm_atml_req_canceled,
};
static struct platform_device *pdev;
static void atml_plat_remove(void)
{
struct tpm_chip *chip = dev_get_drvdata(&pdev->dev);
struct tpm_atmel_priv *priv = dev_get_drvdata(&chip->dev);
if (chip) {
tpm_chip_unregister(chip);
if (priv->have_region)
atmel_release_region(priv->base, priv->region_size);
atmel_put_base_addr(priv->iobase);
platform_device_unregister(pdev);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Kylene Jo Hall | 52 | 70.27% | 4 | 44.44% |
Jarkko Sakkinen | 16 | 21.62% | 3 | 33.33% |
Christophe Ricard | 6 | 8.11% | 2 | 22.22% |
Total | 74 | 100.00% | 9 | 100.00% |
static SIMPLE_DEV_PM_OPS(tpm_atml_pm, tpm_pm_suspend, tpm_pm_resume);
static struct platform_driver atml_drv = {
.driver = {
.name = "tpm_atmel",
.pm = &tpm_atml_pm,
},
};
static int __init init_atmel(void)
{
int rc = 0;
void __iomem *iobase = NULL;
int have_region, region_size;
unsigned long base;
struct tpm_chip *chip;
struct tpm_atmel_priv *priv;
rc = platform_driver_register(&atml_drv);
if (rc)
return rc;
if ((iobase = atmel_get_base_addr(&base, ®ion_size)) == NULL) {
rc = -ENODEV;
goto err_unreg_drv;
}
have_region =
(atmel_request_region
(base, region_size, "tpm_atmel0") == NULL) ? 0 : 1;
pdev = platform_device_register_simple("tpm_atmel", -1, NULL, 0);
if (IS_ERR(pdev)) {
rc = PTR_ERR(pdev);
goto err_rel_reg;
}
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv) {
rc = -ENOMEM;
goto err_unreg_dev;
}
priv->iobase = iobase;
priv->base = base;
priv->have_region = have_region;
priv->region_size = region_size;
chip = tpmm_chip_alloc(&pdev->dev, &tpm_atmel);
if (IS_ERR(chip)) {
rc = PTR_ERR(chip);
goto err_unreg_dev;
}
dev_set_drvdata(&chip->dev, priv);
rc = tpm_chip_register(chip);
if (rc)
goto err_unreg_dev;
return 0;
err_unreg_dev:
platform_device_unregister(pdev);
err_rel_reg:
atmel_put_base_addr(iobase);
if (have_region)
atmel_release_region(base,
region_size);
err_unreg_drv:
platform_driver_unregister(&atml_drv);
return rc;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Kylene Jo Hall | 169 | 59.09% | 7 | 46.67% |
Jarkko Sakkinen | 83 | 29.02% | 3 | 20.00% |
Jeff Garzik | 15 | 5.24% | 1 | 6.67% |
Christophe Ricard | 12 | 4.20% | 2 | 13.33% |
Philipp Matthias Hahn | 5 | 1.75% | 1 | 6.67% |
Lei Ming | 2 | 0.70% | 1 | 6.67% |
Total | 286 | 100.00% | 15 | 100.00% |
static void __exit cleanup_atmel(void)
{
platform_driver_unregister(&atml_drv);
atml_plat_remove();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Kylene Jo Hall | 17 | 94.44% | 3 | 75.00% |
Lei Ming | 1 | 5.56% | 1 | 25.00% |
Total | 18 | 100.00% | 4 | 100.00% |
module_init(init_atmel);
module_exit(cleanup_atmel);
MODULE_AUTHOR("Leendert van Doorn (leendert@watson.ibm.com)");
MODULE_DESCRIPTION("TPM Driver");
MODULE_VERSION("2.0");
MODULE_LICENSE("GPL");
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Kylene Jo Hall | 773 | 74.61% | 12 | 44.44% |
Jarkko Sakkinen | 99 | 9.56% | 3 | 11.11% |
Christophe Ricard | 81 | 7.82% | 2 | 7.41% |
Stefan Berger | 22 | 2.12% | 1 | 3.70% |
Jeff Garzik | 15 | 1.45% | 1 | 3.70% |
Jason Gunthorpe | 15 | 1.45% | 2 | 7.41% |
Lei Ming | 12 | 1.16% | 1 | 3.70% |
Rafael J. Wysocki | 10 | 0.97% | 1 | 3.70% |
Philipp Matthias Hahn | 5 | 0.48% | 1 | 3.70% |
Chris Wright | 2 | 0.19% | 1 | 3.70% |
Andrew Morton | 1 | 0.10% | 1 | 3.70% |
Kent Yoder | 1 | 0.10% | 1 | 3.70% |
Total | 1036 | 100.00% | 27 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.