Skip to content

main_v2 - fby3.5: cl: new sensor reading structure and support MP5990 sensor reading#229

Closed
DelphineChiu wants to merge 2 commits into
facebook:main_v2from
Wiwynn:Ren/MP5990
Closed

main_v2 - fby3.5: cl: new sensor reading structure and support MP5990 sensor reading#229
DelphineChiu wants to merge 2 commits into
facebook:main_v2from
Wiwynn:Ren/MP5990

Conversation

@DelphineChiu

Copy link
Copy Markdown

Summary:

  • common: Phase in new sensor reading structure with README file
  • fby3.5: cl: Support MP5990 sensor reading
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 15, 2022
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@GoldenBug has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Comment thread common/dev/adm1278.c
uint8_t adm1278_read(uint8_t sensor_num, int *reading)
{
if ((reading == NULL) ||
(sensor_config[sensor_config_index_map[sensor_num]].init_args == NULL)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a temporary variable for this in this function to improve readability?

Something like:
sensor_cfg config = sensor_config[sensor_config_index_map[sensor_num]];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and then use the temporary variable everywhere that ensor_config[sensor_config_index_map[sensor_num]] is used

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stack memory is limited to BIC.
The size of sensor_cfg is 60 bytes.
So, we propose not to define a temporary variable.

Comment thread common/dev/adm1278.c
{
snr_cfg *cfg = &sensor_config[sensor_config_index_map[sensor_num]];
float val = 0;
if (!sensor_config[sensor_config_index_map[sensor_num]].init_args) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here, can we use a temporary variable for sensor_config[sensor_config_index_map[sensor_num]] so we can make it more readable

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stack memory is limited to BIC.
The size of sensor_cfg is 60 bytes.
So, we propose not to define a temporary variable.

Comment thread common/dev/adm1278.c
return 0;
}

uint8_t adm1278_read(uint8_t sensor_num, int *reading)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably want to check to make sure sensor_num is within the allowed range

0 <= sensor_num < SENSOR_NUM_MAX ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have fixed this and do the forced update.
The sensor_num is unsigned type so only judge if it's less than MAX_NUM_SENSORS.
Please review it. Thanks.

Comment thread common/dev/adm1278.c
{
snr_cfg *cfg = &sensor_config[sensor_config_index_map[sensor_num]];
float val = 0;
if (!sensor_config[sensor_config_index_map[sensor_num]].init_args) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably want to check to make sure sensor_num is within the allowed range

0 <= sensor_num < SENSOR_NUM_MAX ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have fixed this and do the forced update.
The sensor_num is unsigned type so only judge if it's less than MAX_NUM_SENSORS.
Please review it. Thanks.

Comment thread common/dev/ast_adc.c Outdated
return false;
}

int err, retval;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we don't need to use 2 different variables here. Can we just use 1 of them for adc_channel_setup and adc_read

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have fixed this and do the forced update.
Please review it. Thanks.

Comment thread common/dev/tmp75.c

msg.bus = cfg->port;
msg.target_addr = cfg->target_addr;
msg.bus = sensor_config[sensor_config_index_map[sensor_num]].port;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sensor_config[sensor_config_index_map[sensor_num]] a temp variable to make code more readable

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stack memory is limited to BIC.
The size of sensor_cfg is 60 bytes.
So, we propose not to define a temporary variable.

Comment thread common/dev/tps53689.c
#include "pmbus.h"
#include "util_pmbus.h"

uint8_t tps53689_read(uint8_t sensor_num, int *reading)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure sensor_num is in valid range

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have fixed this and do the forced update.
The sensor_num is unsigned type so only judge if it's less than MAX_NUM_SENSORS.
Please review it. Thanks.

Comment thread common/dev/tps53689.c
I2C_MSG msg;
memset(sval, 0, sizeof(sensor_val));

msg.bus = sensor_config[sensor_config_index_map[sensor_num]].port;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sensor_config[sensor_config_index_map[sensor_num]] a temporary variable

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stack memory is limited to BIC.
The size of sensor_cfg is 60 bytes.
So, we propose not to define a temporary variable.

Comment thread common/dev/xdpe15284.c
#include "util_pmbus.h"
#include "pmbus.h"

uint8_t xdpe15284_read(uint8_t sensor_num, int *reading)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure sensor_num is in valid range

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have fixed this and do the forced update.
The sensor_num is unsigned type so only judge if it's less than MAX_NUM_SENSORS.
Please review it. Thanks.

Comment thread common/lib/util_pmbus.c
return ret;
}

bool get_exponent_from_vout_mode(uint8_t sensor_num, float *exponent)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check exponent is not NULL and that sensor_num is within valid range

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have fixed this and do the forced update.
Please review it. Thanks.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@DelphineChiu has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@DelphineChiu has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@DelphineChiu has updated the pull request. You must reimport the pull request before landing.

Summary:
- Support MP5990 sensor device

Test Plan:
1. Build code: pass
2. [MPS] Check GPIOA7 and the MP5990 configure register(38h and 46h)
3. [MPS] Get MP5990 sensor reading: pass
4. [ADI] Get ADM1278 sensor reading: pass

Log:
1. Class type: class-1, 1ou present status: false, 2ou present status: true, board revision: EVT3(EFUSE)
root@bmc-oob:/root# bic-util slot1 --get_gpio|grep "HSC_SET_EN_R"
7 HSC_SET_EN_R: 1
root@bmc-oob:/root# bic-util slot1 0x18 0x52 0x5 0x16 0x2 0x38
BF 01
root@bmc-oob:/root# bic-util slot1 0x18 0x52 0x5 0x16 0x2 0x46
46 00
root@bmc-oob:/root# sensor-util slot1|grep HSC
HSC Temp                     (0xE) :   25.00 C     | (ok)
HSC Input Vol                (0x29) :   12.31 Volts | (ok)
HSC Output Cur               (0x30) :    0.25 Amps  | (ok)
HSC Input Pwr                (0x39) :    0.00 Watts | (ok)

2. Class type: class-1, 1ou present status: false, 2ou present status: false, board revision: EVT3(EFUSE)
root@bmc-oob:/root# bic-util slot1 --get_gpio|grep "HSC_SET_EN_R"
7 HSC_SET_EN_R: 0
root@bmc-oob:/root# bic-util slot1 0x18 0x52 0x5 0x16 0x2 0x46
28 00
root@bmc-oob:/root# bic-util slot1 0x18 0x52 0x5 0x16 0x2 0x38
04 01
root@bmc-oob:/root# sensor-util slot1|grep HSC
HSC Temp                     (0xE) :   25.00 C     | (ok)
HSC Input Vol                (0x29) :   12.44 Volts | (ok)
HSC Output Cur               (0x30) :    0.25 Amps  | (ok)
HSC Input Pwr                (0x39) :    0.00 Watts | (ok)

3. Class type: class-1, 1ou present status: false, 2ou present status:false, board revision: POC
root@bmc-oob:/root# sensor-util slot3|grep HSC
HSC Temp                     (0xE) :   27.62 C     | (ok)
HSC Input Vol                (0x29) :   12.00 Volts | (ok)
HSC Output Cur               (0x30) :   10.52 Amps  | (ok)
HSC Input Pwr                (0x39) :  129.35 Watts | (ok)
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@DelphineChiu has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@GoldenBug has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot pushed a commit that referenced this pull request Apr 19, 2022
… sensor reading (#229)

Summary:
- common: Phase in new sensor reading structure with README file
- fby3.5: cl: Support MP5990 sensor reading

Pull Request resolved: #229

Reviewed By: garnermic

Differential Revision: D35679332

Pulled By: GoldenBug

fbshipit-source-id: 6f645fa4fe561a217483f8b57d073c83ca861bf0
facebook-github-bot pushed a commit that referenced this pull request Apr 19, 2022
Summary:
fby3.5: cl: Fixing warning messages

- K_WORK_DELAYABLE_DEFINE needs a callback function with the function parameter type of "struct k_work *".
- util_spi.c had a missing header that needed to be included as well as an improperly formatted print statement.
- Mark card_type_1ou that is currently unused in Yv3.5 CL as unused to silence compiler warnings.
- Initialized status in fall through case.

Dependency: #229

Pull Request resolved: #230

Test Plan: - Build code: Pass

Reviewed By: zhdaniel12

Differential Revision: D35679334

Pulled By: GoldenBug

fbshipit-source-id: 02c91f11c6f6131f215be6cd43e5e47003bfcfe2
@DelphineChiu

Copy link
Copy Markdown
Author

close the PR since the codes have been merged

facebook-github-bot pushed a commit that referenced this pull request Apr 26, 2022
… sensor reading (#229)

Summary:
- common: Phase in new sensor reading structure with README file
- fby3.5: cl: Support MP5990 sensor reading

Pull Request resolved: #229

Reviewed By: garnermic

Differential Revision: D35941602

Pulled By: GoldenBug

fbshipit-source-id: d8ecba9eaea9ba0a2aabac644ecd563f471cf73d
facebook-github-bot pushed a commit that referenced this pull request Apr 26, 2022
Summary:
fby3.5: cl: Fixing warning messages

- K_WORK_DELAYABLE_DEFINE needs a callback function with the function parameter type of "struct k_work *".
- util_spi.c had a missing header that needed to be included as well as an improperly formatted print statement.
- Mark card_type_1ou that is currently unused in Yv3.5 CL as unused to silence compiler warnings.
- Initialized status in fall through case.

Dependency: #229

Pull Request resolved: #230

Test Plan: - Build code: Pass

Reviewed By: garnermic

Differential Revision: D35941585

Pulled By: GoldenBug

fbshipit-source-id: b6a4753658952a940f93df7cf319e656afedaaa4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

4 participants