Skip to content
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

Add driver for MAX42500 #2659

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

kentlibe
Copy link

@kentlibe kentlibe commented Dec 1, 2024

PR Description

  • This adds new driver for the MAX42500 Industrial Power System Monitor Family, along with corresponding device tree bindings.
  • Datasheet MAX42500
  • Tested in RPI4 with MAX42500_EVKIT_P1.

PR Type

  • Bug fix (a change that fixes an issue)
  • New feature (a change that adds new functionality)
  • Breaking change (a change that affects other repos or cause CIs to fail)

PR Checklist

  • I have conducted a self-review of my own code changes
  • I have tested the changes on the relevant hardware
  • I have updated the documentation outside this repo accordingly (if there is the case)

@nunojsa
Copy link
Collaborator

nunojsa commented Dec 2, 2024

Is this still WIP? As it stands it's not really ready for reviewing... Please make sure to address CI complains and to re-organize your commits. Merge commits don't really make sense (rebase your dev branch) and please run git lon --oneline <DIR_YOU'RE_CHANGING> so you can the git log style for that subsystem. Then, please follow the same style. Also note that a commit as Cleanup MAX42500 Linux driver. is not fine. You need to explain what you're actually cleaning and why...

@kentlibe kentlibe force-pushed the dev/max42500 branch 3 times, most recently from a3dad5b to a6008ba Compare December 10, 2024 07:49
@kentlibe kentlibe changed the title Add driver support for MAX42500 Add driver for MAX42500 Dec 10, 2024
@kentlibe kentlibe force-pushed the dev/max42500 branch 2 times, most recently from de38b83 to 3f0942b Compare December 10, 2024 22:09
Add documentation for devicetree bindings for MAX42500

Signed-off-by: Kent Libetario <[email protected]>
The MAX42500 is a SoC power-system monitor with up to seven voltage
monitor inputs that will be SIL 3-Certified. Each input has programmable
OV/UV thresholds of between 2.5% and 10% with ±1.3% accuracy over the full
temperature range. Two of the inputs have a separate remote ground-sense
input and support DVS through the integrated I2C interface.

The MAX42500 contains a programmable flexible power sequence recorder
(FPSR). This recorder stores power-up and power-down timestamps separately,
and supports on/off and sleep/standby power sequences. The MAX42500 also
contains a programmable challenge/response watchdog, which is accessible
through the I2C interface, along with a configurable RESET output.

Signed-off-by: Kent Libetario <[email protected]>
Add entry for the MAX42500 driver

Signed-off-by: Kent Libetario <[email protected]>
@kentlibe
Copy link
Author

v2

  • ready for review
  • address CI complaints
  • address style issues
  • re-organize commits
  • rebase dev branch

Copy link
Contributor

@kister-jimenez kister-jimenez left a comment

Choose a reason for hiding this comment

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

First review attempt.

I think you need to do some adjustments in you formatting especially the tabs to make the code more readable. I have commented some of them, but I see a lot needs to be adjusted.

- adi,max42500

reg:
description: I2C address of slave device.
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for description for the I2C address.

Comment on lines +23 to +24
minimum: 0x28
maximum: 0x2B
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is needed.

Comment on lines +30 to +31
#define MAX42500_REG_CONFIG1 0x01
#define MAX42500_REG_CONFIG2 0x02
Copy link
Contributor

Choose a reason for hiding this comment

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

You can add more tabs to align this.

#define MAX42500_REG_RSTMAP 0x04
#define MAX42500_REG_STATOV 0x05
#define MAX42500_REG_STATUV 0x06
#define MAX42500_REG_STATOFF 0x07
Copy link
Contributor

Choose a reason for hiding this comment

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

you can add more tabs to align this.

Comment on lines +51 to +52
#define MAX42500_REG_FPSSTAT1 0x16
#define MAX42500_REG_FPSCFG1 0x17
Copy link
Contributor

Choose a reason for hiding this comment

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

you can add more tabs to align these.

*/
static int max42500_set_nominal_voltage(struct max42500_state *st,
enum max42500_vm_input vm_in,
u8 voltage)
Copy link
Contributor

Choose a reason for hiding this comment

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

check your tabs

Comment on lines +409 to +412
MAX42500_REG_OVUV1 + vm_in,
GENMASK(7, 4),
FIELD_PREP(GENMASK(7, 4),
thresh));
Copy link
Contributor

Choose a reason for hiding this comment

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

check your tabs

* @return 0 in case of success, negative error code otherwise.
*/
static int max42500_get_comp_status(struct max42500_state *st,
u8 vm_in, u8 *status)
Copy link
Contributor

Choose a reason for hiding this comment

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

check your tabs

}

st->nominal_volt[vm_in] = voltage;
return max42500_reg_write(st, reg_addr, voltage);
Copy link
Contributor

Choose a reason for hiding this comment

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

add a new line before this return for better readability.

Comment on lines +967 to +988
HWMON_CHANNEL_INFO(chip,
HWMON_C_IN_RESET_HISTORY | HWMON_C_CURR_RESET_HISTORY |
HWMON_C_TEMP_RESET_HISTORY | HWMON_C_POWER_RESET_HISTORY |
HWMON_C_REGISTER_TZ | HWMON_C_UPDATE_INTERVAL | HWMON_C_ALARMS,
HWMON_C_IN_RESET_HISTORY | HWMON_C_CURR_RESET_HISTORY,
HWMON_C_IN_RESET_HISTORY | HWMON_C_CURR_RESET_HISTORY,
HWMON_C_IN_RESET_HISTORY | HWMON_C_CURR_RESET_HISTORY,
HWMON_C_IN_RESET_HISTORY | HWMON_C_CURR_RESET_HISTORY,
HWMON_C_IN_RESET_HISTORY | HWMON_C_CURR_RESET_HISTORY,
HWMON_C_IN_RESET_HISTORY | HWMON_C_CURR_RESET_HISTORY),
HWMON_CHANNEL_INFO(in,
HWMON_I_LABEL | HWMON_I_INPUT | HWMON_I_LOWEST | HWMON_I_MIN |
HWMON_I_HIGHEST | HWMON_I_MAX,
HWMON_I_LABEL | HWMON_I_INPUT | HWMON_I_LOWEST | HWMON_I_MIN |
HWMON_I_HIGHEST | HWMON_I_MAX,
HWMON_I_LABEL | HWMON_I_INPUT | HWMON_I_LOWEST | HWMON_I_MIN,
HWMON_I_LABEL | HWMON_I_INPUT | HWMON_I_LOWEST | HWMON_I_MIN,
HWMON_I_LABEL | HWMON_I_INPUT | HWMON_I_LOWEST | HWMON_I_MIN,
HWMON_I_LABEL, HWMON_I_LABEL, HWMON_I_LABEL, HWMON_I_LABEL,
HWMON_I_LABEL, HWMON_I_LABEL, HWMON_I_LABEL, HWMON_I_LABEL,
HWMON_I_LABEL, HWMON_I_LABEL, HWMON_I_LABEL, HWMON_I_LABEL,
HWMON_I_LABEL, HWMON_I_LABEL, HWMON_I_LABEL, HWMON_I_LABEL),
Copy link
Contributor

Choose a reason for hiding this comment

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

can you double check the channels? I think there is a mismatch in the count.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants