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

RTC: MAX31331: Support and documentation for RTC MAX31331 #2593

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

Conversation

SwaroopPKADI
Copy link

PR Description

  • RTC: MAX31331: Support for MAX31331 and updated the documents.

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.

Note that I'm expecting this to be first upstreamed before merging it in our tree...

Also, make sure you change your commit titles. Run:

  • git log --oneline Documentation/devicetree/bindings
  • git log --oneline drivers/rtc

and use the same style.


reg:
maxItems: 1
description: I2C address of the RTC
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 description


interrupts:
description: |
Alarm1 interrupt line of the RTC.
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

properties:
reg:
items:
- const: 0x68
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think, typically, this comes after required: but I see that you're already making use of allOf: here. Maybe it's acceptable to move it to the end. Not sure, up to you...

@@ -59,7 +82,7 @@ examples:

rtc@68 {
compatible = "adi,max31335";
reg = <0x68>;
reg = <0x69>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't change this. Why going in favor of the new reg? If you really want, add another example for the new device.

ID_MAX31331,
ID_MAX31335,
MAX_RTC_ID_NR
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Make the ids part of chip_desc

Copy link
Author

Choose a reason for hiding this comment

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

The id is a part of max31335_data. chip_desc is being used for the register address mapping between multiple RTCs.

Would making it a part of chip_desc be more useful than keeping it out of it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why doing the below?

max31335->id = max31335->chip - chip;

when the id is already a constant piece of information? Just make it part of that struct and be done with it :)

sizeof(date));
if (ret)
return ret;

tm->tm_sec = bcd2bin(date[0] & 0x7f);
tm->tm_min = bcd2bin(date[1] & 0x7f);
/* Hour is always set to 24Hr format */
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would drop the comment

if (max31335->id == ID_MAX31331)
ret = regmap_read(max31335->regmap, MAX31331_RTC_CONFIG2, &reg);
else
ret = regmap_read(max31335->regmap, MAX31335_RTC_CONFIG2, &reg);
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can make the config register part of your chip_info struct and get rid of the if(). It even looks like you can actually remove the enum...

if (!device_property_present(dev, "#clock-cells")) {
if (max31335->id == ID_MAX31331)
return 0;
else
Copy link
Collaborator

Choose a reason for hiding this comment

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

Redundant else... Why do we return 0 in the other case? Are the bits not part of the register? But I assume we still have an output clock to register?

This is the only case where the id seems to be needed. Not sure what those bits are but maybe you can also have a dedicated boolean in your chip_info to make the decision in here.

int ret;

max31335 = devm_kzalloc(&client->dev, sizeof(*max31335), GFP_KERNEL);
if (!max31335)
return -ENOMEM;

dev_set_drvdata(&client->dev, max31335);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why? Note the call to i2c_set_clientdata(client, max31335);

else
return -ENODEV;

max31335->id = max31335->chip - chip;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use i2c_get_match_data() and check for NULL (return error in that case)

Copy link
Author

Choose a reason for hiding this comment

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

Couldn't find a definition for i2c_get_match_data()

Copy link
Collaborator

Choose a reason for hiding this comment

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

It might be it's yet not supported in our tree. But it is upstream and that what you should use when upstreaming this driver

MAX31331 is an ultra-low-power, I2C Real-Time Clock RTC

Signed-off-by: Swaroop Kukkillaya <Swaroop.PrakashKumar@analog.com>
Add details to use max31331. The main difference between max31331
and max31335 is the I2C Slave Address. Max31331 uses 0x68 where as
max31335 uses 0x69.

Signed-off-by: Swaroop Kukkillaya <Swaroop.PrakashKumar@analog.com>
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.

There are things that I still don't really agree but I would say to send it upstream and see what the maintainers have to say...


reg:
maxItems: 1
items:
- enum: [0x68, 0x69]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I thin you can just keep maxItems. Below you already make it clear the addresses.

I'll also take the opportunity to advise on the commit message. Maintainers are getting more strict about having fallbacks devices. In short fallback is a way for an older kernel (which does not contain the new device driver - in this case max31331) to still be able to use and probe the fallback device (in this case max31335). The reasoning is that we can't still operate the device but just missing some features.

That said, if they are not compatible at all (i.e - we can't fallback into the other device), we need to state why is that in the commit message.

else
return -ENODEV;

max31335->id = max31335->chip - chip;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is still nok IMO. But if you really think it's ok like, I won't argue more :)

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