- header.validation = cpu_to_le32(VALIDATION_WORD);
- header.version = version;
- header.flags = flags;
- header.length_u32 = cpu_to_le16(length_bytes/4);
- header.zero = 0;
- header.checksum = cpu_to_le16(hdr_checksum(&header));
-
- memcpy(buf, &header, sizeof(header));
+ struct socfpga_header_v0 header_v0 = {
+ .validation = cpu_to_le32(VALIDATION_WORD),
+ .version = 0,
+ .flags = flags,
+ .length_u32 = cpu_to_le16(length_bytes / 4),
+ .zero = 0,
+ };
+
+ struct socfpga_header_v1 header_v1 = {
+ .validation = cpu_to_le32(VALIDATION_WORD),
+ .version = 1,
+ .flags = flags,
+ .header_u8 = cpu_to_le16(sizeof(header_v1)),
+ .length_u8 = cpu_to_le32(length_bytes),
+ .entry_offset = cpu_to_le32(0x14), /* Trampoline offset */
+ .zero = 0,
+ };
+
+ uint16_t csum;
+
+ if (ver == 0) {
+ csum = sfp_hdr_checksum((uint8_t *)&header_v0, 0);
+ header_v0.checksum = cpu_to_le16(csum);
+ memcpy(buf, &header_v0, sizeof(header_v0));
+ } else {
+ csum = sfp_hdr_checksum((uint8_t *)&header_v1, 1);
+ header_v1.checksum = cpu_to_le16(csum);
+ memcpy(buf, &header_v1, sizeof(header_v1));
+ }