On 03.02.2016 22:47, Laxman Dewangan wrote: > To make RTC block of MAX77686/MAX77802 as independent driver, > move the registration of i2c device, regmap for register access > and irq_chip for interrupt support inside the RTC driver. > Removed the same initialisation from MFD driver. > > Having this change will allow to reuse this driver for different > PMIC/devices from Maxim Semiconductor if they kept same RTC IP on > different PMIC. Some of examples as PMIC MAX77620, MAX20024 where > same RTC IP used and hence driver for these chips will use this > driver only for RTC support. > > Suggested-by: Krzysztof Kozlowski <k.kozlow...@samsung.com> > Signed-off-by: Laxman Dewangan <ldewan...@nvidia.com> > CC: Krzysztof Kozlowski <k.kozlow...@samsung.com> > CC: Javier Martinez Canillas <jav...@osg.samsung.com> > Reviewed-by: Javier Martinez Canillas <jav...@osg.samsung.com> > > --- > Changes from V1: > - Remove changes from Kconfig. > - Maintain all register definition in max77686 private header and remove > the movement to rtc driver. > - Taken care of all comments on V1 from Krzysztof and Javier. > > Changes from V2: > - Taken care of missed sequence for removing the resource. > - Fix the crash when doing unbind by using requested_threaded_irq() > instead of demv_requested_threaded_irq(). > > drivers/mfd/max77686.c | 85 +------------------- > drivers/rtc/rtc-max77686.c | 148 > ++++++++++++++++++++++++++++++----- > include/linux/mfd/max77686-private.h | 3 - > 3 files changed, 130 insertions(+), 106 deletions(-) >
Looks good and works properly (RTC, unbind/rebind, wakealarm again) but... after applying this patch the device cannot suspend to RAM after unbind/rebind. Reproduce path, after booting: $ echo max77686-rtc > /sys/bus/platform/drivers/max77686-rtc/unbind $ echo max77686-rtc > /sys/bus/platform/drivers/max77686-rtc/bind $ rtcwake -d rtc2 -m mem -s 5 -v (or instead of rtcwake: echo mem > /sys/power/state) Proper behaviour: ############################## [ 28.549244] PM: late suspend of devices complete after 2.239 msecs [ 28.556051] PM: noirq suspend of devices complete after 2.078 msecs [ 28.560952] Disabling non-boot CPUs ... [ 28.588392] CPU1: shutdown [ 28.623283] CPU2: shutdown [ 28.653242] CPU3: shutdown Power usage drops. Device wakes up (either from RTC or from manual, e.g. key press) ############################## Behaviour with patch 5/5: [ 67.068586] PM: Syncing filesystems ... done. [ 67.121673] Freezing user space processes ... (elapsed 0.004 seconds) done. [ 67.123457] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done. [ 67.182024] wake enabled for irq 125 [ 67.184315] wake enabled for irq 127 [ 67.187829] wake enabled for irq 147 [ 67.191238] wake enabled for irq 148 [ 67.195178] dwc2 12480000.hsotg: suspending usb gadget g_ether [ 67.200647] dwc2 12480000.hsotg: new device is full-speed [ 67.206036] dwc2 12480000.hsotg: dwc2_hsotg_ep_disable: called for ep0 [ 67.212523] dwc2 12480000.hsotg: dwc2_hsotg_ep_disable: called for ep0 [ 67.221742] PM: suspend of devices complete after 93.132 msecs [ 67.226113] VALIVE_1.0V_AP: No configuration [ 67.230399] VCC_1.8V_AP: No configuration [ 67.234385] VCC_2.8V_AP: No configuration [ 67.238373] VCC_1.8V_IO: No configuration [ 67.243130] CAM_ISP_MIPI_1.2V: No configuration [ 67.249142] NFC_AVDD_1.8V: No configuration [ 67.252661] CAM_SENSOR_CORE_1.2V: No configuration [ 67.256648] CAM_ISP_SEN_IO_1.8V: No configuration [ 67.261311] VT_CAM_1.8V: No configuration [ 67.265323] VDDQ_PRE_1.8V: No configuration [ 67.269488] VTF_2.8V: No configuration [ 67.273219] VMEM_VDD_2.8V: No configuration [ 67.277386] TSP_AVDD_3.3V: No configuration [ 67.281553] TSP_VDD_1.8V: No configuration [ 67.285615] LCD_VCC_3.3V: No configuration [ 67.289712] MOTOR_VCC_3.0V: No configuration [ 67.296266] VMEM_1.2V_AP: No configuration [ 67.298902] VCC_SUB_1.35V: No configuration [ 67.303064] VCC_SUB_2.0V: No configuration [ 67.307142] VMEM_VDDF_3.0V: No configuration [ 67.311377] CAM_ISP_CORE_1.2V: No configuration [ 67.318181] PM: late suspend of devices complete after 2.267 msecs [ 67.325046] PM: noirq suspend of devices complete after 2.137 msecs [ 67.329857] Disabling non-boot CPUs ... No CPU shutdown messages. Power usage not decreased, device does not wake up. I don't know yet what is the cause... At first glance it looks okay... Best regards, Krzysztof