net: ks8851: Use 16bit RXQCR access
[oweals/u-boot.git] / drivers / tpm / tpm-uclass.c
index c83f53ab86b6e6364530a252769d4c5551666d3e..6ea795bc0c982b42ec5ceaf8dedb60bdc23b7030 100644 (file)
@@ -6,6 +6,8 @@
 
 #include <common.h>
 #include <dm.h>
+#include <log.h>
+#include <linux/delay.h>
 #include <linux/unaligned/be_byteshift.h>
 #include <tpm-v1.h>
 #include <tpm-v2.h>
@@ -72,7 +74,7 @@ int tpm_xfer(struct udevice *dev, const uint8_t *sendbuf, size_t send_size,
        struct tpm_ops *ops = tpm_get_ops(dev);
        ulong start, stop;
        uint count, ordinal;
-       int ret, ret2;
+       int ret, ret2 = 0;
 
        if (ops->xfer)
                return ops->xfer(dev, sendbuf, send_size, recvbuf, recv_size);
@@ -120,14 +122,24 @@ int tpm_xfer(struct udevice *dev, const uint8_t *sendbuf, size_t send_size,
                }
        } while (ret);
 
-       ret2 = ops->cleanup ? ops->cleanup(dev) : 0;
+       if (ret) {
+               if (ops->cleanup) {
+                       ret2 = ops->cleanup(dev);
+                       if (ret2)
+                               return log_msg_ret("cleanup", ret2);
+               }
+               return log_msg_ret("xfer", ret);
+       }
 
-       return ret2 ? ret2 : ret;
+       return 0;
 }
 
 UCLASS_DRIVER(tpm) = {
-       .id             = UCLASS_TPM,
-       .name           = "tpm",
-       .flags          = DM_UC_FLAG_SEQ_ALIAS,
+       .id             = UCLASS_TPM,
+       .name           = "tpm",
+       .flags          = DM_UC_FLAG_SEQ_ALIAS,
+#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
+       .post_bind      = dm_scan_fdt_dev,
+#endif
        .per_device_auto_alloc_size     = sizeof(struct tpm_chip_priv),
 };