Commit Graph

7 Commits

Author SHA1 Message Date
Shubhi Garg
c3fdf73467 Revert "Revert "rtc: fix year calculation in max77851 pmic rtc""
This reverts commit 40b9876e2f277472677c22b947da7260cf39626e.

Reason for revert:
Initial change to fix year calculation is correct.
We do not need to blindly add +100 in year value. RTC_YEAR
register can accomodate values from 0..199. Being year base 1900
and valid rtc time being 1970, valid year values are 1970..2099.

Bug 4911320

Change-Id: Ic4183f4d85e4612b6a5a7ab53baf0483b7b6acad
Signed-off-by: Shubhi Garg <shgarg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3283957
Reviewed-by: Evan Wei <evwei@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
2025-07-24 10:19:13 +00:00
Shubhi Garg
fc807ba71e Revert "rtc: fix year calculation in max77851 pmic rtc"
This reverts commit b60b757d9c.

Reason for revert:
rtc_valid_tm api checks year range if it is > 70. While
max77851 RTC_YEAR register provides range from 0 to 199,
add +100 always to fall under valid range.

This fixes rtc read time issue from sysfs.
root@jetson:/home/nvidia# cat /sys/class/rtc/rtc1/time
cat: /sys/class/rtc/rtc1/time: Invalid argument

Bug 4911320

Change-Id: I70b5495bb11f9b0b6dd80e19e626ccdb8d3ac6f6
Signed-off-by: Shubhi Garg <shgarg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3273546
Reviewed-by: Evan Wei <evwei@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
2025-07-24 10:19:12 +00:00
Jon Hunter
f01227d4ea drivers: Drop inline from driver remove wrapper
The driver remove function is a function pointer and therefore, it does
not make sense to define the function as an 'inline'. Update the
coccinelle script and drivers to remove the inline statement.

Bug 4749580

Change-Id: Ia03691b75c4edffe609f27468b911a92a5ddbd68
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3233980
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2025-07-24 10:19:08 +00:00
Jon Hunter
951b2423a8 drivers: Fix platform_driver remove for Linux v6.11
In Linux v6.11, the 'platform_driver' structure 'remove' callback was
updated to return void instead of 'int'. Update all the impacted drivers
as necessary to fix this.

Bug 4749580

Change-Id: I3bb5c549777f7ccad0e3f870373fdd25726ad7ed
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3182878
Reviewed-by: Brad Griffis <bgriffis@nvidia.com>
Tested-by: Brad Griffis <bgriffis@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
2024-08-11 17:20:34 -07:00
Shubhi Garg
b60b757d9c rtc: fix year calculation in max77851 pmic rtc
Add +100 to year only if PMIC does not have separate alarm
enable registers. Since MAX77851 has separate alarm enable register
, MAX77851 RTC supports year calculation from 0..199 so we do not need
to add 100 on reading RTC YEAR register. Currently, default, driver is
adding +100 which is wrong. This change fixes rtc year calculation.

Bug 200749982

Change-Id: Ibaf1d2fb81e59cc21c22d509cf9ffc7b6005916c
Signed-off-by: Shubhi Garg <shgarg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.10/+/2727859
(cherry picked from commit b43364942c67fdf7958a42bfad5fe02725da00e3)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.10/+/2728926
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2947785
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Tested-by: Bitan Biswas <bbiswas@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-09-14 13:25:47 -07:00
Shubhi Garg
5b1a5fc4b6 rtc: fix max77851 pmic rtc hang in set time
When we set time from max77851 pmic RTC, it hangs because
it calls read_time function which locks via mutex twice. System
goes in deadlock state. Reading time is not required during time set
as it is not performing anything thus removing it.

Following logs are seen during hang:
[  242.930292] INFO: task systemd-timedat:1127 blocked for more than 120 seconds.
[  242.937695]       Tainted: G            E     5.10.104-tegra #1
[  242.943743] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[  242.951643] task:systemd-timedat state:D stack:    0 pid: 1127 ppid:     1 flags:0x00000808
[  242.960074] Call trace:
[  242.962618]  __switch_to+0xd0/0x120
[  242.966193]  __schedule+0x404/0xab0
[  242.969709]  schedule+0x78/0x110
[  242.972963]  schedule_preempt_disabled+0x2c/0x50
[  242.977621]  __mutex_lock.isra.0+0x1b4/0x5b0
[  242.981925]  __mutex_lock_slowpath+0x48/0x90
[  242.986226]  mutex_lock+0x74/0x80
[  242.989610]  max77851_rtc_read_time+0x48/0xf0
[  242.994004]  max77851_rtc_set_time+0xd4/0x1a0
[  242.998398]  rtc_set_time+0xac/0x220
[  243.002003]  rtc_dev_ioctl+0x478/0x950
[  243.005805]  __arm64_sys_ioctl+0xac/0xf0
[  243.009773]  el0_svc_common.constprop.0+0x80/0x1d0
[  243.014605]  do_el0_svc+0x38/0xb0
[  243.017950]  el0_svc+0x1c/0x30
[  243.021029]  el0_sync_handler+0xa8/0xb0
[  243.024898]  el0_sync+0x16c/0x180

Bug 200749982

Change-Id: I6f7d88871184bf64a03fa789746a189e0c0aa826
Signed-off-by: Shubhi Garg <shgarg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.10/+/2726550
(cherry picked from commit 129e9c03af0db8857d65e65ea72ce19ae2656b27)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.10/+/2728925
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2947784
Tested-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-09-14 13:25:42 -07:00
Shubhi Garg
da71dfa5a5 rtc: max77851: add max77851 rtc driver
Add max77851 rtc driver into nvidia-oot repo

Fix jammy-src kernel-only build max77851 rtc
in embedded recovery defconfig
 - guard regmap function calls with CONFIG_REGMAP_IRQ
 - guard i2c call with CONFIG_I2C

Bug 200749982

Change-Id: I9bfcbfa7bab42f393c7baa1f3dba78d599ca510a
Signed-off-by: Shubhi Garg <shgarg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.10/+/2595387
Signed-off-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2947783
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-09-14 13:25:37 -07:00