Created
June 9, 2021 16:40
-
-
Save Th3Fanbus/b4b74863dd326a6c4522964425b5d536 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <inttypes.h> | |
#include <stdbool.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <string.h> | |
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) | |
static const bool is_ivybridge = true; | |
static const uint32_t compofst2_ivb[] = { | |
is_ivybridge ? 0x0C235924 : 0x0C21410C, | |
is_ivybridge ? 0x0C446964 : 0x0C42514C, | |
is_ivybridge ? 0x0C6671E4 : 0x0C6369CC, | |
is_ivybridge ? 0x0CA8C264 : 0x0CA57A4C, | |
is_ivybridge ? 0x0CEBDB64 : 0x0CE7C34C, | |
is_ivybridge ? 0x0D6FF5E4 : 0x0D6BEDCC, | |
}; | |
union comp_ofst_2_reg { | |
struct { | |
uint32_t cmd_drv_down : 3; /* [ 2.. 0] */ | |
uint32_t cmd_drv_up : 3; /* [ 5.. 3] */ | |
uint32_t clk_scomp : 5; /* [10.. 6] */ | |
uint32_t dq_scomp : 5; /* [15..11] */ | |
uint32_t cmd_scomp : 5; /* [20..16] */ | |
uint32_t ctl_scomp : 5; /* [25..21] */ | |
uint32_t drv_sleg_down : 1; /* [26..26] */ | |
uint32_t drv_sleg_up : 1; /* [27..27] */ | |
uint32_t : 4; | |
}; | |
uint32_t raw; | |
}; | |
int main(void) | |
{ | |
printf(" CMD CMD CLK DQ CMD CTL SLEG SLEG\n"); | |
printf("Raw value DRV DN DRV UP SCOMP SCOMP SCOMP SCOMP DN UP\n"); | |
for (size_t i = 0; i < ARRAY_SIZE(compofst2_ivb); i++) { | |
const union comp_ofst_2_reg reg = { | |
.raw = compofst2_ivb[i], | |
}; | |
printf("0x%08x %6u %6u %5u %5u %5u %5u %4u %4u\n", | |
reg.raw, | |
reg.cmd_drv_down, | |
reg.cmd_drv_up, | |
reg.clk_scomp, | |
reg.dq_scomp, | |
reg.cmd_scomp, | |
reg.ctl_scomp, | |
reg.drv_sleg_down, | |
reg.drv_sleg_up); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment