return -EIO;
for (i = 0; i < 6; i++) {
- status = atmel_getb(chip, 1);
+ status = ioread8(chip->vendor->iobase + 1);
if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
- dev_err(chip->dev,
- "error reading header\n");
+ dev_err(chip->dev, "error reading header\n");
return -EIO;
}
- *buf++ = atmel_getb(chip, 0);
+ *buf++ = ioread8(chip->vendor->iobase);
}
/* size of the data received */
dev_err(chip->dev,
"Recv size(%d) less than available space\n", size);
for (; i < size; i++) { /* clear the waiting data anyway */
- status = atmel_getb(chip, 1);
+ status = ioread8(chip->vendor->iobase + 1);
if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
- dev_err(chip->dev,
- "error reading data\n");
+ dev_err(chip->dev, "error reading data\n");
return -EIO;
}
}
/* read all the data available */
for (; i < size; i++) {
- status = atmel_getb(chip, 1);
+ status = ioread8(chip->vendor->iobase + 1);
if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
- dev_err(chip->dev,
- "error reading data\n");
+ dev_err(chip->dev, "error reading data\n");
return -EIO;
}
- *buf++ = atmel_getb(chip, 0);
+ *buf++ = ioread8(chip->vendor->iobase);
}
/* make sure data available is gone */
- status = atmel_getb(chip, 1);
+ status = ioread8(chip->vendor->iobase + 1);
+
if (status & ATML_STATUS_DATA_AVAIL) {
dev_err(chip->dev, "data available is stuck\n");
return -EIO;
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]);
- atmel_putb(buf[i], chip, 0);
+ iowrite8(buf[i], chip->vendor->iobase);
}
return count;
static void tpm_atml_cancel(struct tpm_chip *chip)
{
- atmel_putb(ATML_STATUS_ABORT, chip, 1);
+ iowrite8(ATML_STATUS_ABORT, chip->vendor->iobase + 1);
}
static u8 tpm_atml_status(struct tpm_chip *chip)
{
- return atmel_getb(chip, 1);
+ return ioread8(chip->vendor->iobase + 1);
}
static struct file_operations atmel_ops = {
if (chip) {
if (chip->vendor->have_region)
- atmel_release_region(chip->vendor->base, chip->vendor->region_size);
+ atmel_release_region(chip->vendor->base,
+ chip->vendor->region_size);
atmel_put_base_addr(chip->vendor);
tpm_remove_hardware(chip->dev);
platform_device_unregister(pdev);
driver_register(&atml_drv);
- if (atmel_get_base_addr(&tpm_atmel) != 0) {
+ if ((tpm_atmel.iobase = atmel_get_base_addr(&tpm_atmel)) == NULL) {
rc = -ENODEV;
goto err_unreg_drv;
}
- tpm_atmel.have_region = (atmel_request_region( tpm_atmel.base, tpm_atmel.region_size, "tpm_atmel0") == NULL) ? 0 : 1;
+ tpm_atmel.have_region =
+ (atmel_request_region
+ (tpm_atmel.base, tpm_atmel.region_size,
+ "tpm_atmel0") == NULL) ? 0 : 1;
- if (IS_ERR(pdev = platform_device_register_simple("tpm_atmel", -1, NULL, 0 ))) {
+ if (IS_ERR
+ (pdev =
+ platform_device_register_simple("tpm_atmel", -1, NULL, 0))) {
rc = PTR_ERR(pdev);
goto err_rel_reg;
}
err_unreg_dev:
platform_device_unregister(pdev);
err_rel_reg:
- if (tpm_atmel.have_region)
- atmel_release_region(tpm_atmel.base, tpm_atmel.region_size);
atmel_put_base_addr(&tpm_atmel);
+ if (tpm_atmel.have_region)
+ atmel_release_region(tpm_atmel.base,
+ tpm_atmel.region_size);
err_unreg_drv:
driver_unregister(&atml_drv);
return rc;
#define atmel_putb(val, chip, offset) writeb(val, chip->vendor->iobase + offset)
#define atmel_request_region request_mem_region
#define atmel_release_region release_mem_region
-static inline void atmel_put_base_addr(struct tpm_vendor_specific *vendor)
+
+static inline void atmel_put_base_addr(struct tpm_vendor_specific
+ *vendor)
{
iounmap(vendor->iobase);
}
-static int atmel_get_base_addr(struct tpm_vendor_specific *vendor)
+static void __iomem * atmel_get_base_addr(struct tpm_vendor_specific *vendor)
{
struct device_node *dn;
unsigned long address, size;
dn = of_find_node_by_name(NULL, "tpm");
if (!dn)
- return 1;
+ return NULL;
if (!device_is_compatible(dn, "AT97SC3201")) {
of_node_put(dn);
- return 1;
+ return NULL;
}
reg = (unsigned int *) get_property(dn, "reg", ®len);
vendor->base = address;
vendor->region_size = size;
- vendor->iobase = ioremap(address, size);
- return 0;
+ return ioremap(vendor->base, vendor->region_size);
}
#else
#define atmel_getb(chip, offset) inb(chip->vendor->base + offset)
return 0;
}
-static inline void atmel_put_base_addr(struct tpm_vendor_specific *vendor)
+static inline void atmel_put_base_addr(struct tpm_vendor_specific
+ *vendor)
{
}
/* Determine where to talk to device */
-static unsigned long atmel_get_base_addr(struct tpm_vendor_specific
+static void __iomem * atmel_get_base_addr(struct tpm_vendor_specific
*vendor)
{
int lo, hi;
if (atmel_verify_tpm11() != 0)
- return 1;
+ return NULL;
lo = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_LO);
hi = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_HI);
vendor->base = (hi << 8) | lo;
vendor->region_size = 2;
- return 0;
+ return ioport_map(vendor->base, vendor->region_size);
}
#endif