]> git.sur5r.net Git - u-boot/blobdiff - drivers/tpm/tpm_tis_i2c.h
pci: Set PCI_COMMAND_IO bit for VGA device
[u-boot] / drivers / tpm / tpm_tis_i2c.h
index 2a4ad774293df90be2b272bf39622661f0073173..3b510d101e773baf3aa6db107d8e78cc5ca2a6fe 100644 (file)
 #include <linux/types.h>
 
 enum tpm_timeout {
-       TPM_TIMEOUT = 5,        /* msecs */
+       TPM_TIMEOUT_MS                  = 5,
+       TIS_SHORT_TIMEOUT_MS            = 750,
+       TIS_LONG_TIMEOUT_MS             = 2000,
+       SLEEP_DURATION_US               = 60,
+       SLEEP_DURATION_LONG_US          = 210,
 };
 
 /* Size of external transmit buffer (used in tpm_transmit)*/
@@ -33,17 +37,18 @@ enum tpm_timeout {
 #define TPM_RSP_SIZE_BYTE      2
 #define TPM_RSP_RC_BYTE                6
 
-struct tpm_chip;
+enum i2c_chip_type {
+       SLB9635,
+       SLB9645,
+       UNKNOWN,
+};
 
 struct tpm_chip {
        int is_open;
-       u8 req_complete_mask;
-       u8 req_complete_val;
-       u8 req_canceled;
-       int irq;
        int locality;
+       u32 vend_dev;
        unsigned long timeout_a, timeout_b, timeout_c, timeout_d;  /* msec */
-       unsigned long duration[3];  /* msec */
+       enum i2c_chip_type chip_type;
 };
 
 struct tpm_input_header {
@@ -102,9 +107,40 @@ struct tpm_cmd_t {
        union tpm_cmd_params params;
 } __packed;
 
-struct udevice;
-int tpm_vendor_init(struct udevice *dev);
+/* Max number of iterations after i2c NAK */
+#define MAX_COUNT              3
+
+/*
+ * Max number of iterations after i2c NAK for 'long' commands
+ *
+ * We need this especially for sending TPM_READY, since the cleanup after the
+ * transtion to the ready state may take some time, but it is unpredictable
+ * how long it will take.
+ */
+#define MAX_COUNT_LONG         50
+
+enum tis_access {
+       TPM_ACCESS_VALID                = 0x80,
+       TPM_ACCESS_ACTIVE_LOCALITY      = 0x20,
+       TPM_ACCESS_REQUEST_PENDING      = 0x04,
+       TPM_ACCESS_REQUEST_USE          = 0x02,
+};
+
+enum tis_status {
+       TPM_STS_VALID                   = 0x80,
+       TPM_STS_COMMAND_READY           = 0x40,
+       TPM_STS_GO                      = 0x20,
+       TPM_STS_DATA_AVAIL              = 0x10,
+       TPM_STS_DATA_EXPECT             = 0x08,
+};
+
+/* expected value for DIDVID register */
+#define TPM_TIS_I2C_DID_VID_9635 0x000b15d1L
+#define TPM_TIS_I2C_DID_VID_9645 0x001a15d1L
 
-void tpm_vendor_cleanup(struct tpm_chip *chip);
+#define        TPM_ACCESS(l)                   (0x0000 | ((l) << 4))
+#define        TPM_STS(l)                      (0x0001 | ((l) << 4))
+#define        TPM_DATA_FIFO(l)                (0x0005 | ((l) << 4))
+#define        TPM_DID_VID(l)                  (0x0006 | ((l) << 4))
 
 #endif