-
Notifications
You must be signed in to change notification settings - Fork 846
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
base: main
Are you sure you want to change the base?
Conversation
8d299ca
to
ad28b9f
Compare
37e49c7
to
9030670
Compare
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.
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 |
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.
no need for description
|
||
interrupts: | ||
description: | | ||
Alarm1 interrupt line of the RTC. |
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.
ditto
properties: | ||
reg: | ||
items: | ||
- const: 0x68 |
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.
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>; |
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.
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 | ||
}; |
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.
Make the ids part of chip_desc
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.
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?
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.
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 :)
drivers/rtc/rtc-max31335.c
Outdated
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 */ |
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.
I would drop the comment
drivers/rtc/rtc-max31335.c
Outdated
if (max31335->id == ID_MAX31331) | ||
ret = regmap_read(max31335->regmap, MAX31331_RTC_CONFIG2, ®); | ||
else | ||
ret = regmap_read(max31335->regmap, MAX31335_RTC_CONFIG2, ®); |
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.
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...
drivers/rtc/rtc-max31335.c
Outdated
if (!device_property_present(dev, "#clock-cells")) { | ||
if (max31335->id == ID_MAX31331) | ||
return 0; | ||
else |
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.
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.
drivers/rtc/rtc-max31335.c
Outdated
int ret; | ||
|
||
max31335 = devm_kzalloc(&client->dev, sizeof(*max31335), GFP_KERNEL); | ||
if (!max31335) | ||
return -ENOMEM; | ||
|
||
dev_set_drvdata(&client->dev, max31335); |
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.
Why? Note the call to i2c_set_clientdata(client, max31335);
else | ||
return -ENODEV; | ||
|
||
max31335->id = max31335->chip - chip; |
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.
Use i2c_get_match_data()
and check for NULL (return error in that case)
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.
Couldn't find a definition for i2c_get_match_data()
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.
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
9030670
to
e697b9b
Compare
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>
e697b9b
to
6f413ca
Compare
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.
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] |
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.
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; |
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.
This is still nok IMO. But if you really think it's ok like, I won't argue more :)
PR Description
PR Type
PR Checklist