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

hwmon: (pmbus/adp1050): Support adp1051 and adp1055 #2629

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

Conversation

actorreno
Copy link

PR Description

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)

Copy link
Collaborator

@nunojsa nunojsa left a comment

Choose a reason for hiding this comment

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

Another hint is to run:

git log --oneline drivers/hwmon/pmbus to look for the style used in that dir for commit titles. The most common seems to be (adapted for your case):

hwmon: (pmbus/adp1050): Support adp1051 and adp1055

@@ -10,16 +10,35 @@ maintainers:
- Radu Sabau <radu.sabau@analog.com>

description: |
The ADP1050 is used to monitor system voltages, currents and temperatures.
The ADP1050, ADP1051, and ADP1055 are used to monitor system voltages,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This does not scale. Instead say "The ADP1050 and similar devices..."

The ADP1050 is used to monitor system voltages, currents and temperatures.
The ADP1050, ADP1051, and ADP1055 are used to monitor system voltages,
currents, power and temperatures.

Through the PMBus interface, the ADP1050 targets isolated power supplies
and has four individual monitors for input/output voltage, input current
and temperature.
Datasheet:
https://www.analog.com/en/products/adp1050.html
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just add here the links to new datasheets


hwmon@70 {
compatible = "adi,adp1050";
compatible = "adi,adp1050", "adi,adp1051";
Copy link
Collaborator

Choose a reason for hiding this comment

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

It does not work like this... If you can fallback to some compatible, that needs to be stated in the bindings which is not.

reg = <0x70>;
vcc-supply = <&vcc>;
status = "okay";
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove the status

compatible = "adi,adp1055";
reg = <0x4b>;
vcc-supply = <&vcc>;
status = "okay";
Copy link
Collaborator

Choose a reason for hiding this comment

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

If it#s only a matter of the address being different, I would not bother in adding another example

| PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT
| PMBUS_HAVE_IIN | PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP,
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also unrelated change. I would drop it (or add it in a different patch)

ADP1050,
ADP1051,
ADP1055,
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Drop the id

{ .compatible = "adi,adp1050"},
{ .compatible = "adi,adp1050", .data = (void *)ADP1050},
{ .compatible = "adi,adp1051", .data = (void *)ADP1051},
{ .compatible = "adi,adp1055", .data = (void *)ADP1055},
Copy link
Collaborator

Choose a reason for hiding this comment

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

pass in directly the pmbus_driver_info structs...

{"adp1050", 0},
{"adp1050", ADP1050},
{"adp1051", ADP1051},
{"adp1055", ADP1055},
Copy link
Collaborator

Choose a reason for hiding this comment

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

return pmbus_do_probe(client, &adp1050_info);
enum ADP1050_type type;

type = (enum ADP1050_type)(uintptr_t)device_get_match_data(&client->dev);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Now you can properly do error checking:

info = device_get_match_data();
if (!info)
    return -ENODEV;

@actorreno actorreno changed the title Added support for ADP1051 and ADP1055 on existing ADP1050 driver hwmon: (pmbus/adp1050): Support adp1051 and adp1055 Oct 25, 2024
@actorreno actorreno force-pushed the dev/adp1050_support branch 2 times, most recently from 39943c4 to 9a7485b Compare October 28, 2024 01:59
@actorreno
Copy link
Author

v2

.yaml:

  • updated description to scale as suggested
  • removed further descriptions and simply attached datasheet links
  • reverted back most of the device tree sample
    (just a lack of understanding on the yaml file, i thought it was a full device tree)
    (no fallback feature intended, but will note just in case)

.rst

  • dropped the small unrelated change

.c

  • dropped the unrelated change, astyle adjusts this each run
  • dopped the ID and directly passed the pmbus structs
  • used the error checking as suggested

@actorreno actorreno requested a review from nunojsa October 31, 2024 01:06
Copy link
Collaborator

@nunojsa nunojsa left a comment

Choose a reason for hiding this comment

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

Fell free to send this upstream...

- enum:
- adi,adp1050
- adi,adp1051
- adi,adp1055
Copy link
Collaborator

Choose a reason for hiding this comment

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

On top of what I've said already, you don't need "items:" in here (as you have things now at least).

return pmbus_do_probe(client, &adp1050_info);
struct pmbus_driver_info *info;

info = (struct pmbus_driver_info *)device_get_match_data(&client->dev);
Copy link
Collaborator

Choose a reason for hiding this comment

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

no need for the cast..

Copy link
Author

@actorreno actorreno Nov 5, 2024

Choose a reason for hiding this comment

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

I added the cast just to remove a warning but yes this can be removed to simplify the code further.

edit: removal of the cast started failing some of the checks. is this ok?

/* 6.1 probe() function still uses the second struct i2c_device_id argument */
static int adp1050_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
return pmbus_do_probe(client, &adp1050_info);
struct pmbus_driver_info *info;
Copy link
Collaborator

Choose a reason for hiding this comment

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

It can be const pmbus_driver_info *info

Copy link
Author

Choose a reason for hiding this comment

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

const pmbus_driver_info *info; returns an error similar to the one below. Will keep the original struct pmbus_driver_info *info;

image

Copy link
Collaborator

Choose a reason for hiding this comment

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

Obviously a typo from me... const struct pmbus_driver_info *info and then no need for the cast

Copy link
Author

Choose a reason for hiding this comment

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

updated the commit but still fails some checks.

a warning remains it seems
image

Add dt-bindings for adp1051 and adp1055 pmbus.
ADP1051: 6 PWM for I/O Voltage, I/O Current, Temperature
ADP1055: 6 PWM for I/O Voltage, I/O Current, Power, Temperature

Signed-off-by: Alexis Torreno <alexisczezar.torreno@analog.com>
@actorreno actorreno force-pushed the dev/adp1050_support branch from 9a7485b to 82c4d40 Compare November 5, 2024 06:41
ADP1051: 6 PWM for I/O Voltage, I/O Current, Temperature
ADP1055: 6 PWM for I/O Voltage, I/O Current, Power, Temperature

Signed-off-by: Alexis Torreno <alexisczezar.torreno@analog.com>
@actorreno actorreno force-pushed the dev/adp1050_support branch from 82c4d40 to 72a535b Compare November 5, 2024 08:29
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.

2 participants