-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fby3: dl: Add oem get fw version for server board #418
fby3: dl: Add oem get fw version for server board #418
Conversation
Summary: - as the title.
@GoldenBug has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
i2c_msg.tx_len = 1; | ||
i2c_msg.rx_len = 7; | ||
i2c_msg.bus = I2C_BUS8; | ||
i2c_msg.data[0] = PMBUS_IC_DEVICE_ID; | ||
|
||
if (i2c_master_read(&i2c_msg, retry)) { | ||
msg->completion_code = CC_UNSPECIFIED_ERROR; | ||
return; | ||
} | ||
|
||
if (memcmp(i2c_msg.data, ISL69254_DEVICE_ID, sizeof(ISL69254_DEVICE_ID)) == 0) { | ||
/* Renesas isl69254 */ | ||
i2c_msg.tx_len = 3; | ||
i2c_msg.data[0] = 0xC7; //command code | ||
i2c_msg.data[1] = 0x3F; //register | ||
i2c_msg.data[2] = 0x00; //dummy data | ||
|
||
if (i2c_master_write(&i2c_msg, retry)) { | ||
msg->completion_code = CC_UNSPECIFIED_ERROR; | ||
return; | ||
} | ||
|
||
i2c_msg.tx_len = 1; | ||
i2c_msg.rx_len = 4; | ||
i2c_msg.data[0] = 0xC5; //command code | ||
|
||
if (i2c_master_read(&i2c_msg, retry)) { | ||
msg->completion_code = CC_UNSPECIFIED_ERROR; | ||
return; | ||
} | ||
|
||
msg->data[0] = i2c_msg.data[3]; | ||
msg->data[1] = i2c_msg.data[2]; | ||
msg->data[2] = i2c_msg.data[1]; | ||
msg->data[3] = i2c_msg.data[0]; | ||
msg->data_len = 4; | ||
msg->completion_code = CC_SUCCESS; | ||
|
||
} else if (memcmp(i2c_msg.data, XDPE12284C_DEVICE_ID, | ||
sizeof(XDPE12284C_DEVICE_ID)) == 0) { | ||
/* Infineon xdpe12284c */ | ||
i2c_msg.tx_len = 2; | ||
i2c_msg.data[0] = 0x00; | ||
i2c_msg.data[1] = 0x62; //set page to 0x62 | ||
|
||
if (i2c_master_write(&i2c_msg, retry)) { | ||
msg->completion_code = CC_UNSPECIFIED_ERROR; | ||
return; | ||
} | ||
|
||
//Read lower word for the 32bit checksum value | ||
i2c_msg.tx_len = 1; | ||
i2c_msg.rx_len = 2; | ||
i2c_msg.data[0] = 0x43; | ||
if (i2c_master_read(&i2c_msg, retry)) { | ||
msg->completion_code = CC_UNSPECIFIED_ERROR; | ||
return; | ||
} | ||
|
||
msg->data[0] = i2c_msg.data[1]; | ||
msg->data[1] = i2c_msg.data[0]; | ||
|
||
i2c_msg.tx_len = 2; | ||
i2c_msg.data[0] = 0x00; | ||
i2c_msg.data[1] = 0x62; //set page to 0x62 | ||
|
||
if (i2c_master_write(&i2c_msg, retry)) { | ||
msg->completion_code = CC_UNSPECIFIED_ERROR; | ||
return; | ||
} | ||
|
||
//Read higher word for the 32bit checksum value | ||
i2c_msg.tx_len = 1; | ||
i2c_msg.rx_len = 2; | ||
i2c_msg.data[0] = 0x42; | ||
if (i2c_master_read(&i2c_msg, retry)) { | ||
msg->completion_code = CC_UNSPECIFIED_ERROR; | ||
return; | ||
} | ||
|
||
msg->data[2] = i2c_msg.data[1]; | ||
msg->data[3] = i2c_msg.data[0]; | ||
msg->data_len = 4; | ||
msg->completion_code = CC_SUCCESS; | ||
} else { | ||
msg->completion_code = CC_UNSPECIFIED_ERROR; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we break this out into a separate function?
if ((component == DL_COMPNT_PVCCIN) || (component == DL_COMPNT_PVCCSA)) { | ||
i2c_msg.target_addr = VCCIN_VCCSA_ADDR; | ||
} | ||
if ((component == DL_COMPNT_PVCCIO) || (component == DL_COMPNT_P3V3_STBY)) { | ||
i2c_msg.target_addr = VCCIO_P3V3_STBY_ADDR; | ||
} | ||
if (component == DL_COMPNT_PVDDR_ABC) { | ||
i2c_msg.target_addr = VDDQ_ABC_ADDR; | ||
} | ||
if (component == DL_COMPNT_PVDDR_DEF) { | ||
i2c_msg.target_addr = VDDQ_DEF_ADDR; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once the code below is a separate function we can pass in the target address as a parameter, and refactor these into the case statements above.
Summary: