+typedef struct QEMU_PACKED UfsReg {
+ uint32_t cap;
+ uint32_t rsvd0;
+ uint32_t ver;
+ uint32_t rsvd1;
+ uint32_t hcpid;
+ uint32_t hcmid;
+ uint32_t ahit;
+ uint32_t rsvd2;
+ uint32_t is;
+ uint32_t ie;
+ uint32_t rsvd3[2];
+ uint32_t hcs;
+ uint32_t hce;
+ uint32_t uecpa;
+ uint32_t uecdl;
+ uint32_t uecn;
+ uint32_t uect;
+ uint32_t uecdme;
+ uint32_t utriacr;
+ uint32_t utrlba;
+ uint32_t utrlbau;
+ uint32_t utrldbr;
+ uint32_t utrlclr;
+ uint32_t utrlrsr;
+ uint32_t utrlcnr;
+ uint32_t rsvd4[2];
+ uint32_t utmrlba;
+ uint32_t utmrlbau;
+ uint32_t utmrldbr;
+ uint32_t utmrlclr;
+ uint32_t utmrlrsr;
+ uint32_t rsvd5[3];
+ uint32_t uiccmd;
+ uint32_t ucmdarg1;
+ uint32_t ucmdarg2;
+ uint32_t ucmdarg3;
+ uint32_t rsvd6[4];
+ uint32_t rsvd7[4];
+ uint32_t rsvd8[16];
+ uint32_t ccap;
+} UfsReg;
+
+enum UfsRegOfs {
+ UFS_REG_CAP = offsetof(UfsReg, cap),
+ UFS_REG_VER = offsetof(UfsReg, ver),
+ UFS_REG_HCPID = offsetof(UfsReg, hcpid),
+ UFS_REG_HCMID = offsetof(UfsReg, hcmid),
+ UFS_REG_AHIT = offsetof(UfsReg, ahit),
+ UFS_REG_IS = offsetof(UfsReg, is),
+ UFS_REG_IE = offsetof(UfsReg, ie),
+ UFS_REG_HCS = offsetof(UfsReg, hcs),
+ UFS_REG_HCE = offsetof(UfsReg, hce),
+ UFS_REG_UECPA = offsetof(UfsReg, uecpa),
+ UFS_REG_UECDL = offsetof(UfsReg, uecdl),
+ UFS_REG_UECN = offsetof(UfsReg, uecn),
+ UFS_REG_UECT = offsetof(UfsReg, uect),
+ UFS_REG_UECDME = offsetof(UfsReg, uecdme),
+ UFS_REG_UTRIACR = offsetof(UfsReg, utriacr),
+ UFS_REG_UTRLBA = offsetof(UfsReg, utrlba),
+ UFS_REG_UTRLBAU = offsetof(UfsReg, utrlbau),
+ UFS_REG_UTRLDBR = offsetof(UfsReg, utrldbr),
+ UFS_REG_UTRLCLR = offsetof(UfsReg, utrlclr),
+ UFS_REG_UTRLRSR = offsetof(UfsReg, utrlrsr),
+ UFS_REG_UTRLCNR = offsetof(UfsReg, utrlcnr),
+ UFS_REG_UTMRLBA = offsetof(UfsReg, utmrlba),
+ UFS_REG_UTMRLBAU = offsetof(UfsReg, utmrlbau),
+ UFS_REG_UTMRLDBR = offsetof(UfsReg, utmrldbr),
+ UFS_REG_UTMRLCLR = offsetof(UfsReg, utmrlclr),
+ UFS_REG_UTMRLRSR = offsetof(UfsReg, utmrlrsr),
+ UFS_REG_UICCMD = offsetof(UfsReg, uiccmd),
+ UFS_REG_UCMDARG1 = offsetof(UfsReg, ucmdarg1),
+ UFS_REG_UCMDARG2 = offsetof(UfsReg, ucmdarg2),
+ UFS_REG_UCMDARG3 = offsetof(UfsReg, ucmdarg3),
+ UFS_REG_CCAP = offsetof(UfsReg, ccap),
+};
+
+enum UfsCapShift {
+ CAP_NUTRS_SHIFT = 0,
+ CAP_RTT_SHIFT = 8,
+ CAP_NUTMRS_SHIFT = 16,
+ CAP_AUTOH8_SHIFT = 23,
+ CAP_64AS_SHIFT = 24,
+ CAP_OODDS_SHIFT = 25,
+ CAP_UICDMETMS_SHIFT = 26,
+ CAP_CS_SHIFT = 28,
+};
+
+enum UfsCapMask {
+ CAP_NUTRS_MASK = 0x1f,
+ CAP_RTT_MASK = 0xff,
+ CAP_NUTMRS_MASK = 0x7,
+ CAP_AUTOH8_MASK = 0x1,
+ CAP_64AS_MASK = 0x1,
+ CAP_OODDS_MASK = 0x1,
+ CAP_UICDMETMS_MASK = 0x1,
+ CAP_CS_MASK = 0x1,
+};
+
+#define UFS_CAP_NUTRS(cap) (((cap) >> CAP_NUTRS_SHIFT) & CAP_NUTRS_MASK)
+#define UFS_CAP_RTT(cap) (((cap) >> CAP_RTT_SHIFT) & CAP_RTT_MASK)
+#define UFS_CAP_NUTMRS(cap) (((cap) >> CAP_NUTMRS_SHIFT) & CAP_NUTMRS_MASK)
+#define UFS_CAP_AUTOH8(cap) (((cap) >> CAP_AUTOH8_SHIFT) & CAP_AUTOH8_MASK)
+#define UFS_CAP_64AS(cap) (((cap) >> CAP_64AS_SHIFT) & CAP_64AS_MASK)
+#define UFS_CAP_OODDS(cap) (((cap) >> CAP_OODDS_SHIFT) & CAP_OODDS_MASK)
+#define UFS_CAP_UICDMETMS(cap) \
+ (((cap) >> CAP_UICDMETMS_SHIFT) & CAP_UICDMETMS_MASK)
+#define UFS_CAP_CS(cap) (((cap) >> CAP_CS_SHIFT) & CAP_CS_MASK)
+
+#define UFS_CAP_SET_NUTRS(cap, val) \
+ (cap = (cap & ~(CAP_NUTRS_MASK << CAP_NUTRS_SHIFT)) | \
+ ((uint32_t)val & CAP_NUTRS_MASK) << CAP_NUTRS_SHIFT)
+#define UFS_CAP_SET_RTT(cap, val) \
+ (cap = (cap & ~(CAP_RTT_MASK << CAP_RTT_SHIFT)) | \
+ ((uint32_t)val & CAP_RTT_MASK) << CAP_RTT_SHIFT)
+#define UFS_CAP_SET_NUTMRS(cap, val) \
+ (cap = (cap & ~(CAP_NUTMRS_MASK << CAP_NUTMRS_SHIFT)) | \
+ ((uint32_t)val & CAP_NUTMRS_MASK) << CAP_NUTMRS_SHIFT)
+#define UFS_CAP_SET_AUTOH8(cap, val) \
+ (cap = (cap & ~(CAP_AUTOH8_MASK << CAP_AUTOH8_SHIFT)) | \
+ ((uint32_t)val & CAP_AUTOH8_MASK) << CAP_AUTOH8_SHIFT)
+#define UFS_CAP_SET_64AS(cap, val) \
+ (cap = (cap & ~(CAP_64AS_MASK << CAP_64AS_SHIFT)) | \
+ ((uint32_t)val & CAP_64AS_MASK) << CAP_64AS_SHIFT)
+#define UFS_CAP_SET_OODDS(cap, val) \
+ (cap = (cap & ~(CAP_OODDS_MASK << CAP_OODDS_SHIFT)) | \
+ ((uint32_t)val & CAP_OODDS_MASK) << CAP_OODDS_SHIFT)
+#define UFS_CAP_SET_UICDMETMS(cap, val) \
+ (cap = (cap & ~(CAP_UICDMETMS_MASK << CAP_UICDMETMS_SHIFT)) | \
+ ((uint32_t)val & CAP_UICDMETMS_MASK) << CAP_UICDMETMS_SHIFT)
+#define UFS_CAP_SET_CS(cap, val) \
+ (cap = (cap & ~(CAP_CS_MASK << CAP_CS_SHIFT)) | \
+ ((uint32_t)val & CAP_CS_MASK) << CAP_CS_SHIFT)