Motorola CPCAP PMIC RTC
Subsystems (2)
cover Motorola CPCAP PMIC RTC
Hi,
Here is a driver for the RTC found inside of the
Motorola Droid 4 based on linux-next 2017021.
I tried to set & get the time using hwclock and
used ./tools/testing/selftests/timers/rtctest.c:
$ ./rtctest
RTC Driver Test Example.
Counting 5 update (1/sec) interrupts from reading /dev/rtc0: 1 2 3 4 5 Again, from using select(2) on /dev/rtc: 1 2 3 4 5
Current RTC date/time is 20-2-2017, 07:11:22.
Alarm time now set to 07:11:27.
Waiting 5 seconds for alarm... okay. Alarm rang.
Periodic IRQ rate is 1Hz.
Counting 20 interrupts at:
2Hz: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
4Hz: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
8Hz: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
16Hz: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
32Hz: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
64Hz: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
*** Test complete ***
I did not include a patch for omap4-droid4-xt894.dts, since the CPCAP DT entry has not yet been added. The following DT snippet can be used for testing on droid4:
&cpcap {
cpcap_rtc: rtc {
compatible = "motorola,cpcap-rtc";
interrupt-parent = <&cpcap>;
interrupts = <39 IRQ_TYPE_NONE>, <26 IRQ_TYPE_NONE>;
};
};-- Sebastian
Sebastian Reichel (1):
rtc: cpcap: new rtc driver
.../devicetree/bindings/rtc/cpcap-rtc.txt | 13 + drivers/rtc/Kconfig | 7 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-cpcap.c | 318 +++++++++++++++++++++ 4 files changed, 339 insertions(+) create mode 100644 Documentation/devicetree/bindings/rtc/cpcap-rtc.txt create mode 100644 drivers/rtc/rtc-cpcap.c
Signature · 11 lines
2.11.0 -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
PATCH 1/1 rtc: cpcap: new rtc driver
This driver supports the Motorola CPCAP PMIC found on some of Motorola's mobile phones, such as the Droid 4.
--- .../devicetree/bindings/rtc/cpcap-rtc.txt | 13 + drivers/rtc/Kconfig | 7 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-cpcap.c | 318 +++++++++++++++++++++ 4 files changed, 339 insertions(+) create mode 100644 Documentation/devicetree/bindings/rtc/cpcap-rtc.txt create mode 100644 drivers/rtc/rtc-cpcap.c
Documentation/devicetree/bindings/rtc/cpcap-rtc.txt new file +13 -0
@@ -0,0 +1,13 @@ +Motorola CPCAP PMIC RTC +------------------------------------ + +Requires node properties: +- compatible: should contain "motorola,cpcap-rtc" +- interrupts: An interrupt specifier for alarm and 1 Hz irq + +Example: + +cpcap_rtc: rtc { + compatible = "motorola,cpcap-rtc"; + interrupts = <39 IRQ_TYPE_NONE>, <26 IRQ_TYPE_NONE>; +};
drivers/rtc/Kconfig +7 -0
@@ -1731,6 +1731,13 @@ config RTC_DRV_STM32 This driver can also be built as a module, if so, the module will be called "rtc-stm32". +config RTC_DRV_CPCAP + depends on MFD_CPCAP + tristate "Motorola CPCAP RTC" + help + Say y here for CPCAP rtc found on some Motorola phones + and tablets such as Droid 4. + comment "HID Sensor RTC drivers" config RTC_DRV_HID_SENSOR_TIME
drivers/rtc/Makefile +1 -0
@@ -40,6 +40,7 @@ obj-$(CONFIG_RTC_DRV_BQ32K) += rtc-bq32k.o obj-$(CONFIG_RTC_DRV_BQ4802) += rtc-bq4802.o obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o obj-$(CONFIG_RTC_DRV_COH901331) += rtc-coh901331.o +obj-$(CONFIG_RTC_DRV_CPCAP) += rtc-cpcap.o obj-$(CONFIG_RTC_DRV_DA9052) += rtc-da9052.o obj-$(CONFIG_RTC_DRV_DA9055) += rtc-da9055.o obj-$(CONFIG_RTC_DRV_DA9063) += rtc-da9063.o
drivers/rtc/rtc-cpcap.c new file +318 -0
318 lines not on this page · raw message
Signature · 11 lines
2.11.0 -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
Re: [PATCH 1/1] rtc: cpcap: new rtc driver
Quoted 2 lines · Sebastian Reichel
This driver supports the Motorola CPCAP PMIC found on some of Motorola's mobile phones, such as the Droid 4.
Hey that's cool, works for me for reading and setting date :) Just noticed one thing, see below.
Documentation/devicetree/bindings/rtc/cpcap-rtc.txt line 13
Quoted 10 lines
Documentation/devicetree/bindings/rtc/cpcap-rtc.txt new file +10
-0+Requires node properties: +- compatible: should contain "motorola,cpcap-rtc" +- interrupts: An interrupt specifier for alarm and 1 Hz irq + +Example: + +cpcap_rtc: rtc { + compatible = "motorola,cpcap-rtc"; + interrupts = <39 IRQ_TYPE_NONE>, <26 IRQ_TYPE_NONE>; +};
I tried rtcwake -s 3, but got the following:
rtcwake: cannot open /sys/class/rtc/rtc0/device/power/wakeup:
No such file or directory
rtcwake: /dev/rtc0 not enabled for wakeup events
Then tried adding "wakeup-source" to above but I think the driver needs something, maybe probably just PM ops?
Regards,
Tony
Signature · 8 lines
You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
Re: [PATCH 1/1] rtc: cpcap: new rtc driver
Quoted 20 lines · Tony Lindgren
Quoted 2 lines · Sebastian Reichel
This driver supports the Motorola CPCAP PMIC found on some of Motorola's mobile phones, such as the Droid 4.
Hey that's cool, works for me for reading and setting date :) Just noticed one thing, see below.
Documentation/devicetree/bindings/rtc/cpcap-rtc.txt line 13
Quoted 10 lines
Documentation/devicetree/bindings/rtc/cpcap-rtc.txt new file +10
-0+Requires node properties: +- compatible: should contain "motorola,cpcap-rtc" +- interrupts: An interrupt specifier for alarm and 1 Hz irq + +Example: + +cpcap_rtc: rtc { + compatible = "motorola,cpcap-rtc"; + interrupts = <39 IRQ_TYPE_NONE>, <26 IRQ_TYPE_NONE>; +};I tried rtcwake -s 3, but got the following:
Quoted 7 lines
rtcwake: cannot open
/sys/class/rtc/rtc0/device/power/wakeup:
No such file or directory
rtcwake:/dev/rtc0not enabled for wakeup eventsThen tried adding "wakeup-source" to above but I think the driver needs something, maybe probably just PM ops?
Probably device_init_wakeup(dev, 1) ?
Signature · 13 lines
Alexandre Belloni, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
Re: [PATCH 1/1] rtc: cpcap: new rtc driver
Quoted 25 lines · Alexandre Belloni
Quoted 24 lines · Tony Lindgren
Quoted 2 lines · Sebastian Reichel
This driver supports the Motorola CPCAP PMIC found on some of Motorola's mobile phones, such as the Droid 4.
Hey that's cool, works for me for reading and setting date :) Just noticed one thing, see below.
Documentation/devicetree/bindings/rtc/cpcap-rtc.txt line 13
Quoted 10 lines
Documentation/devicetree/bindings/rtc/cpcap-rtc.txt new file +10
-0+Requires node properties: +- compatible: should contain "motorola,cpcap-rtc" +- interrupts: An interrupt specifier for alarm and 1 Hz irq + +Example: + +cpcap_rtc: rtc { + compatible = "motorola,cpcap-rtc"; + interrupts = <39 IRQ_TYPE_NONE>, <26 IRQ_TYPE_NONE>; +};I tried rtcwake -s 3, but got the following:
rtcwake: cannot open
/sys/class/rtc/rtc0/device/power/wakeup:
No such file or directory
rtcwake:/dev/rtc0not enabled for wakeup events
Quoted 5 lines
Quoted 3 lines
Then tried adding "wakeup-source" to above but I think the driver needs something, maybe probably just PM ops?
Probably
device_init_wakeup(dev, 1)?
That gets us a bit closer but now produces:
rtcwake: write error
Regards,
Tony
Signature · 8 lines
You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
Tony Lindgren
Tested-byRe: [PATCH 1/1] rtc: cpcap: new rtc driver
Quoted 30 lines · Tony Lindgren
Quoted 29 lines · Alexandre Belloni
Quoted 27 lines · Tony Lindgren
Quoted 2 lines · Sebastian Reichel
This driver supports the Motorola CPCAP PMIC found on some of Motorola's mobile phones, such as the Droid 4.
Hey that's cool, works for me for reading and setting date :) Just noticed one thing, see below.
Documentation/devicetree/bindings/rtc/cpcap-rtc.txt line 13
Quoted 10 lines
Documentation/devicetree/bindings/rtc/cpcap-rtc.txt new file +10
-0+Requires node properties: +- compatible: should contain "motorola,cpcap-rtc" +- interrupts: An interrupt specifier for alarm and 1 Hz irq + +Example: + +cpcap_rtc: rtc { + compatible = "motorola,cpcap-rtc"; + interrupts = <39 IRQ_TYPE_NONE>, <26 IRQ_TYPE_NONE>; +};I tried rtcwake -s 3, but got the following:
rtcwake: cannot open
/sys/class/rtc/rtc0/device/power/wakeup:
No such file or directory
rtcwake:/dev/rtc0not enabled for wakeup eventsThen tried adding "wakeup-source" to above but I think the driver needs something, maybe probably just PM ops?
Quoted 5 lines
Quoted 1 line
Probably
device_init_wakeup(dev, 1)?That gets us a bit closer but now produces:
rtcwake: write error
Oh user error.. It needs to be done with:
# rtcwake -s 3 -m mem
And with the addition of device_init_wakeup(dev, 1) to the probe it works for me. So Sebastian, with that change, please feel free to add:
Signature · 8 lines
You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
Re: [PATCH 1/1] rtc: cpcap: new rtc driver
Hi,
Quoted 39 lines · Tony Lindgren
Quoted 30 lines · Tony Lindgren
Quoted 29 lines · Alexandre Belloni
Quoted 27 lines · Tony Lindgren
Quoted 2 lines · Sebastian Reichel
This driver supports the Motorola CPCAP PMIC found on some of Motorola's mobile phones, such as the Droid 4.
Hey that's cool, works for me for reading and setting date :) Just noticed one thing, see below.
Documentation/devicetree/bindings/rtc/cpcap-rtc.txt line 13
Quoted 10 lines
Documentation/devicetree/bindings/rtc/cpcap-rtc.txt new file +10
-0+Requires node properties: +- compatible: should contain "motorola,cpcap-rtc" +- interrupts: An interrupt specifier for alarm and 1 Hz irq + +Example: + +cpcap_rtc: rtc { + compatible = "motorola,cpcap-rtc"; + interrupts = <39 IRQ_TYPE_NONE>, <26 IRQ_TYPE_NONE>; +};I tried rtcwake -s 3, but got the following:
rtcwake: cannot open
/sys/class/rtc/rtc0/device/power/wakeup:
No such file or directory
rtcwake:/dev/rtc0not enabled for wakeup eventsThen tried adding "wakeup-source" to above but I think the driver needs something, maybe probably just PM ops?
Quoted 5 lines
Quoted 1 line
Probably
device_init_wakeup(dev, 1)?That gets us a bit closer but now produces:
rtcwake: write error
Oh user error.. It needs to be done with:
Quoted 7 lines
# rtcwake -s 3 -m memAnd with the addition of
device_init_wakeup(dev, 1)to the probe it works for me. So Sebastian, with that change, please feel free to add:Tested-by Tony Lindgren <[email protected]>
Nice. I actually forgot to mention, that its missing wakeup support for now and now its already done :) I will resend later.
-- Sebastian
Signature · 8 lines
You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
PATCH v2 1/1 rtc: cpcap: new rtc driver
In reply to Sebastian ReichelThis driver supports the Motorola CPCAP PMIC found on some of Motorola's mobile phones, such as the Droid 4.
---
Changes to PATCHv1:
- added device_init_wakeup() at the end of probe
- added Tested-by from Tony
--- .../devicetree/bindings/rtc/cpcap-rtc.txt | 13 + drivers/rtc/Kconfig | 7 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-cpcap.c | 324 +++++++++++++++++++++ 4 files changed, 345 insertions(+) create mode 100644 Documentation/devicetree/bindings/rtc/cpcap-rtc.txt create mode 100644 drivers/rtc/rtc-cpcap.c
Documentation/devicetree/bindings/rtc/cpcap-rtc.txt new file +13 -0
@@ -0,0 +1,13 @@ +Motorola CPCAP PMIC RTC +------------------------------------ + +Requires node properties: +- compatible: should contain "motorola,cpcap-rtc" +- interrupts: An interrupt specifier for alarm and 1 Hz irq + +Example: + +cpcap_rtc: rtc { + compatible = "motorola,cpcap-rtc"; + interrupts = <39 IRQ_TYPE_NONE>, <26 IRQ_TYPE_NONE>; +};
drivers/rtc/Kconfig +7 -0
@@ -1731,6 +1731,13 @@ config RTC_DRV_STM32 This driver can also be built as a module, if so, the module will be called "rtc-stm32". +config RTC_DRV_CPCAP + depends on MFD_CPCAP + tristate "Motorola CPCAP RTC" + help + Say y here for CPCAP rtc found on some Motorola phones + and tablets such as Droid 4. + comment "HID Sensor RTC drivers" config RTC_DRV_HID_SENSOR_TIME
drivers/rtc/Makefile +1 -0
@@ -40,6 +40,7 @@ obj-$(CONFIG_RTC_DRV_BQ32K) += rtc-bq32k.o obj-$(CONFIG_RTC_DRV_BQ4802) += rtc-bq4802.o obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o obj-$(CONFIG_RTC_DRV_COH901331) += rtc-coh901331.o +obj-$(CONFIG_RTC_DRV_CPCAP) += rtc-cpcap.o obj-$(CONFIG_RTC_DRV_DA9052) += rtc-da9052.o obj-$(CONFIG_RTC_DRV_DA9055) += rtc-da9055.o obj-$(CONFIG_RTC_DRV_DA9063) += rtc-da9063.o
drivers/rtc/rtc-cpcap.c new file +324 -0
324 lines not on this page · raw message
Signature · 11 lines
2.11.0 -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
Re: [PATCHv2] rtc: cpcap: new rtc driver
Hi,
The patch has a few checkpatch issues. Some of those should really be fixed. Can you do that?
Else, it is mostly fine, a few comments below.
Quoted 8 lines · Sebastian Reichel
drivers/rtc/rtc-cpcap.c new file +8
-0+static int cpcap_rtc_set_time (struct device *dev,struct rtc_time *tm) +{ +struct cpcap_rtc *rtc; +struct cpcap_time cpcap_tm; +int ret =0 ; + + rtc =dev_get_drvdata (dev); +
drivers/rtc/rtc-cpcap.c line 142
Quoted 10 lines
drivers/rtc/rtc-cpcap.c new file +10
-0+rtc2cpcap_time (&cpcap_tm, tm); + +if (rtc->alarm_enabled) +disable_irq (rtc->alarm_irq); +if (rtc->update_enabled) +disable_irq (rtc->update_irq); + +if (rtc->vendor ==CPCAP_VENDOR_ST ) { +/* The TOD1 and TOD2 registers MUST be written in this order +* for the change to properly set. */
Does this mean there is a race condition?
Quoted 15 lines
drivers/rtc/rtc-cpcap.c new file +15
-0+ ret |=regmap_update_bits (rtc->regmap,CPCAP_REG_TOD1 , +TOD1_MASK , cpcap_tm.tod1); + ret |=regmap_update_bits (rtc->regmap,CPCAP_REG_TOD2 , +TOD2_MASK , cpcap_tm.tod2); + ret |=regmap_update_bits (rtc->regmap,CPCAP_REG_DAY , +DAY_MASK , cpcap_tm.day); + }else { +/* Clearing the upper lower 8 bits of the TOD guarantees that +* the upper half of TOD (TOD2) will not increment for 0xFF RTC +* ticks (255 seconds). During this time we can safely write +* to DAY, TOD2, then TOD1 (in that order) and expect RTC to be +* synchronized to the exact time requested upon the final write +* to TOD1. */ + ret |=regmap_update_bits (rtc->regmap,CPCAP_REG_TOD1 , +TOD1_MASK ,0 );
drivers/rtc/rtc-cpcap.c
Quoted 10 lines
drivers/rtc/rtc-cpcap.c new file +9
-0+ ret |=regmap_update_bits (rtc->regmap,CPCAP_REG_DAY , +DAY_MASK , cpcap_tm.day); + ret |=regmap_update_bits (rtc->regmap,CPCAP_REG_TOD2 , +TOD2_MASK , cpcap_tm.tod2); + ret |=regmap_update_bits (rtc->regmap,CPCAP_REG_TOD1 , +TOD1_MASK , cpcap_tm.tod1); + } + + err =cpcap_get_vendor (dev, rtc->regmap, &rtc->vendor);
I think this means it depends on the mfd tree.
Quoted 7 lines
drivers/rtc/rtc-cpcap.c new file +7
-0+if (err) +return err; + + rtc->alarm_irq=platform_get_irq (pdev,0 ); + err =devm_request_threaded_irq (dev, rtc->alarm_irq,NULL , + cpcap_rtc_alarm_irq,IRQ_NONE , +"rtc_alarm" , rtc);
drivers/rtc/rtc-cpcap.c line 289
Quoted 10 lines
drivers/rtc/rtc-cpcap.c new file +10
-0+if (err) { +dev_err (dev,"Could not request alarm irq: %d\n" , err); +return err; + } +disable_irq (rtc->alarm_irq); + + rtc->update_irq=platform_get_irq (pdev,1 ); + err =devm_request_threaded_irq (dev, rtc->update_irq,NULL , + cpcap_rtc_update_irq,IRQ_NONE , +"rtc_1hz" , rtc);
I don't think this IRQ is actually useful. It doesn't really harm but the tests should pass without it.
drivers/rtc/rtc-cpcap.c line 296
Quoted 7 lines
drivers/rtc/rtc-cpcap.c new file +7
-0+if (err) { +dev_err (dev,"Could not request update irq: %d\n" , err); +return err; + } +disable_irq (rtc->update_irq); + + err =device_init_wakeup (dev,1 );
If you use device_init_wakeup, I think it needs to be called before devm_rtc_device_register() to properly work.
Signature · 13 lines
Alexandre Belloni, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
Re: [PATCHv2] rtc: cpcap: new rtc driver
Hi Alexandre,
Quoted 2 lines · Alexandre Belloni
The patch has a few checkpatch issues. Some of those should really be fixed. Can you do that?
of course.
Quoted 15 lines
Else, it is mostly fine, a few comments below.
Quoted 12 lines · Sebastian Reichel
drivers/rtc/rtc-cpcap.c new file +12
-0+static int cpcap_rtc_set_time (struct device *dev,struct rtc_time *tm) +{ +struct cpcap_rtc *rtc; +struct cpcap_time cpcap_tm; +int ret =0 ; + + rtc =dev_get_drvdata (dev); + +rtc2cpcap_time (&cpcap_tm, tm); + +if (rtc->alarm_enabled) +disable_irq (rtc->alarm_irq);
Quoted 8 lines
drivers/rtc/rtc-cpcap.c line 142
Quoted 6 lines
drivers/rtc/rtc-cpcap.c new file +6
-0+if (rtc->update_enabled) +disable_irq (rtc->update_irq); + +if (rtc->vendor ==CPCAP_VENDOR_ST ) { +/* The TOD1 and TOD2 registers MUST be written in this order +* for the change to properly set. */ Does this mean there is a race condition?
The logic (incl. comments) in this section are from the vendor kernel driver and there is no documentation for CPCAP as far as I know. I don't know if the hardware has logic to prevent a race condition for the cpcap_tm.tod1 == 255 case.
Quoted 24 lines
Quoted 23 lines
drivers/rtc/rtc-cpcap.c new file +23
-0+ ret |=regmap_update_bits (rtc->regmap,CPCAP_REG_TOD1 , +TOD1_MASK , cpcap_tm.tod1); + ret |=regmap_update_bits (rtc->regmap,CPCAP_REG_TOD2 , +TOD2_MASK , cpcap_tm.tod2); + ret |=regmap_update_bits (rtc->regmap,CPCAP_REG_DAY , +DAY_MASK , cpcap_tm.day); + }else { +/* Clearing the upper lower 8 bits of the TOD guarantees that +* the upper half of TOD (TOD2) will not increment for 0xFF RTC +* ticks (255 seconds). During this time we can safely write +* to DAY, TOD2, then TOD1 (in that order) and expect RTC to be +* synchronized to the exact time requested upon the final write +* to TOD1. */ + ret |=regmap_update_bits (rtc->regmap,CPCAP_REG_TOD1 , +TOD1_MASK ,0 ); + ret |=regmap_update_bits (rtc->regmap,CPCAP_REG_DAY , +DAY_MASK , cpcap_tm.day); + ret |=regmap_update_bits (rtc->regmap,CPCAP_REG_TOD2 , +TOD2_MASK , cpcap_tm.tod2); + ret |=regmap_update_bits (rtc->regmap,CPCAP_REG_TOD1 , +TOD1_MASK , cpcap_tm.tod1); + } +
Quoted 2 lines
drivers/rtc/rtc-cpcap.c line 272
Quoted 1 line
drivers/rtc/rtc-cpcap.c new file +1
-0+ err =cpcap_get_vendor (dev, rtc->regmap, &rtc->vendor);I think this means it depends on the mfd tree.
Yes, but cpcap_get_vendor should get into mainline with the 4.11 mfd pull request. So if you base your 4.12 for-next tree on 4.11-rc1 everything should be fine.
Quoted 12 lines
Quoted 12 lines
drivers/rtc/rtc-cpcap.c new file +12
-0+if (err) +return err; + + rtc->alarm_irq=platform_get_irq (pdev,0 ); + err =devm_request_threaded_irq (dev, rtc->alarm_irq,NULL , + cpcap_rtc_alarm_irq,IRQ_NONE , +"rtc_alarm" , rtc); +if (err) { +dev_err (dev,"Could not request alarm irq: %d\n" , err); +return err; + } +disable_irq (rtc->alarm_irq);
Quoted 8 lines
drivers/rtc/rtc-cpcap.c line 289
Quoted 5 lines
drivers/rtc/rtc-cpcap.c new file +5
-0+ + rtc->update_irq=platform_get_irq (pdev,1 ); + err =devm_request_threaded_irq (dev, rtc->update_irq,NULL , + cpcap_rtc_update_irq,IRQ_NONE , +"rtc_1hz" , rtc);I don't think this IRQ is actually useful. It doesn't really harm but the tests should pass without it.
Yes. RTC works perfectly fine with just the alarm irq. It also works perfectly fine with just the 1 Hz irq (except for wakeup).
I would like to keep the irq in the driver, so that it's explicitly disabled. On Droid 4 mainline kernel is booted via kexec from Android (AKA bootloader) and Motorola's Android kernel uses the 1 Hz IRQ for some proprietary "secure clock daemon".
I will add a comment.
Quoted 10 lines
drivers/rtc/rtc-cpcap.c line 296
Quoted 7 lines
drivers/rtc/rtc-cpcap.c new file +7
-0+if (err) { +dev_err (dev,"Could not request update irq: %d\n" , err); +return err; + } +disable_irq (rtc->update_irq); + + err =device_init_wakeup (dev,1 );If you use
device_init_wakeup, I think it needs to be called beforedevm_rtc_device_register()to properly work.
I successfully tested wakeup before sending this. But in case your prefer it to be called before registering the RTC I can move the call accordingly.
-- Sebastian
Signature · 8 lines
You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
Re: [PATCHv2] rtc: cpcap: new rtc driver
Quoted 7 lines · Sebastian Reichel
Quoted 1 line
Does this mean there is a race condition?
The logic (incl. comments) in this section are from the vendor kernel driver and there is no documentation for CPCAP as far as I know. I don't know if the hardware has logic to prevent a race condition for the cpcap_tm.tod1 == 255 case.
That's fine, I was just curious :)
Quoted 7 lines
Quoted 2 lines
drivers/rtc/rtc-cpcap.c line 272
Quoted 1 line
drivers/rtc/rtc-cpcap.c new file +1
-0+ err =cpcap_get_vendor (dev, rtc->regmap, &rtc->vendor);I think this means it depends on the mfd tree.
Yes, but
cpcap_get_vendorshould get into mainline with the 4.11 mfd pull request. So if you base your 4.12 for-next tree on 4.11-rc1 everything should be fine.
OK, I'll take it for 4.12 then
Quoted 24 lines
Quoted 12 lines
Quoted 12 lines
drivers/rtc/rtc-cpcap.c new file +12
-0+if (err) +return err; + + rtc->alarm_irq=platform_get_irq (pdev,0 ); + err =devm_request_threaded_irq (dev, rtc->alarm_irq,NULL , + cpcap_rtc_alarm_irq,IRQ_NONE , +"rtc_alarm" , rtc); +if (err) { +dev_err (dev,"Could not request alarm irq: %d\n" , err); +return err; + } +disable_irq (rtc->alarm_irq);Quoted 8 lines
drivers/rtc/rtc-cpcap.c line 289
Quoted 5 lines
drivers/rtc/rtc-cpcap.c new file +5
-0+ + rtc->update_irq=platform_get_irq (pdev,1 ); + err =devm_request_threaded_irq (dev, rtc->update_irq,NULL , + cpcap_rtc_update_irq,IRQ_NONE , +"rtc_1hz" , rtc);I don't think this IRQ is actually useful. It doesn't really harm but the tests should pass without it.
Yes. RTC works perfectly fine with just the alarm irq. It also works perfectly fine with just the 1 Hz irq (except for wakeup).
Quoted 7 lines
I would like to keep the irq in the driver, so that it's explicitly disabled. On Droid 4 mainline kernel is booted via kexec from Android (AKA bootloader) and Motorola's Android kernel uses the 1 Hz IRQ for some proprietary "secure clock daemon".
I will add a comment.
OK, my plan was to remove all the RTC_UF users. I'll give it more thoughts.
Quoted 11 lines
Quoted 10 lines
drivers/rtc/rtc-cpcap.c line 296
Quoted 7 lines
drivers/rtc/rtc-cpcap.c new file +7
-0+if (err) { +dev_err (dev,"Could not request update irq: %d\n" , err); +return err; + } +disable_irq (rtc->update_irq); + + err =device_init_wakeup (dev,1 );If you use
device_init_wakeup, I think it needs to be called beforedevm_rtc_device_register()to properly work.
Quoted 4 lines
I successfully tested wakeup before sending this. But in case your prefer it to be called before registering the RTC I can move the call accordingly.
Then it is fine where it is.
Signature · 13 lines
Alexandre Belloni, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
PATCH v3 1/2 dt-bindings: Add vendor prefix for Motorola
In reply to Sebastian ReichelMotorola was involved in semiconductor and mobile phone business. The "motrola," prefix is already used by a couple of bindings:
* rtc/rtc-cmos.txt
* mfd/motorola-cpcap.txt
* regulator/cpcap-regulator.txt
Apart from that it is used in the DT file for the Droid 4 mobile phone.
--- Documentation/devicetree/bindings/vendor-prefixes.txt | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
@@ -189,6 +189,7 @@ minix MINIX Technology Ltd. miramems MiraMEMS Sensing Technology Co., Ltd. mitsubishi Mitsubishi Electric Corporation mosaixtech Mosaix Technologies, Inc. +motorola Motorola, Inc. moxa Moxa mpl MPL AG mqmaker mqmaker Inc.
Signature · 11 lines
2.11.0 -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] For more options, visit https://groups.google.com/d/optout.
PATCH v3 2/2 rtc: cpcap: new rtc driver
This driver supports the Motorola CPCAP PMIC found on some of Motorola's mobile phones, such as the Droid 4.
---
Changes since PATCHv2:
- checkpatch fixes
- add comment for update irq
- introduced vendor prefix patch
Changes since PATCHv1:
- added device_init_wakeup() at the end of probe
- added Tested-by from Tony
--- .../devicetree/bindings/rtc/cpcap-rtc.txt | 13 + drivers/rtc/Kconfig | 7 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-cpcap.c | 332 +++++++++++++++++++++ 4 files changed, 353 insertions(+) create mode 100644 Documentation/devicetree/bindings/rtc/cpcap-rtc.txt create mode 100644 drivers/rtc/rtc-cpcap.c
Documentation/devicetree/bindings/rtc/cpcap-rtc.txt new file +13 -0
@@ -0,0 +1,13 @@ +Motorola CPCAP PMIC RTC +------------------------------------ + +Requires node properties: +- compatible: should contain "motorola,cpcap-rtc" +- interrupts: An interrupt specifier for alarm and 1 Hz irq + +Example: + +cpcap_rtc: rtc { + compatible = "motorola,cpcap-rtc"; + interrupts = <39 IRQ_TYPE_NONE>, <26 IRQ_TYPE_NONE>; +};
drivers/rtc/Kconfig +7 -0
@@ -1731,6 +1731,13 @@ config RTC_DRV_STM32 This driver can also be built as a module, if so, the module will be called "rtc-stm32". +config RTC_DRV_CPCAP + depends on MFD_CPCAP + tristate "Motorola CPCAP RTC" + help + Say y here for CPCAP rtc found on some Motorola phones + and tablets such as Droid 4. + comment "HID Sensor RTC drivers" config RTC_DRV_HID_SENSOR_TIME
drivers/rtc/Makefile +1 -0
@@ -40,6 +40,7 @@ obj-$(CONFIG_RTC_DRV_BQ32K) += rtc-bq32k.o obj-$(CONFIG_RTC_DRV_BQ4802) += rtc-bq4802.o obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o obj-$(CONFIG_RTC_DRV_COH901331) += rtc-coh901331.o +obj-$(CONFIG_RTC_DRV_CPCAP) += rtc-cpcap.o obj-$(CONFIG_RTC_DRV_DA9052) += rtc-da9052.o obj-$(CONFIG_RTC_DRV_DA9055) += rtc-da9055.o obj-$(CONFIG_RTC_DRV_DA9063) += rtc-da9063.o
drivers/rtc/rtc-cpcap.c new file +332 -0
332 lines not on this page · raw message
Signature · 11 lines
2.11.0 -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] For more options, visit https://groups.google.com/d/optout.
Rob Herring
maintainerRe: [PATCHv3 2/2] rtc: cpcap: new rtc driver
Quoted 30 lines · Sebastian Reichel
This driver supports the Motorola CPCAP PMIC found on some of Motorola's mobile phones, such as the Droid 4.
Tested-by Tony Lindgren <[email protected]>Signed-off-by Sebastian Reichel <[email protected]>---
Changes since PATCHv2:
- checkpatch fixes
- add comment for update irq
- introduced vendor prefix patch
Changes since PATCHv1:
- addeddevice_init_wakeup()at the end of probe
- added Tested-by from Tony--- .../devicetree/bindings/rtc/cpcap-rtc.txt | 13 + drivers/rtc/Kconfig | 7 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-cpcap.c | 332 +++++++++++++++++++++ 4 files changed, 353 insertions(+) create mode 100644 Documentation/devicetree/bindings/rtc/cpcap-rtc.txt create mode 100644 drivers/rtc/rtc-cpcap.cDocumentation/devicetree/bindings/rtc/cpcap-rtc.txt new file +0
-0
Documentation/devicetree/bindings/rtc/cpcap-rtc.txt line 2
Quoted 2 lines
Documentation/devicetree/bindings/rtc/cpcap-rtc.txt new file +2
-0@@ -0,0 +1,13 @@ +Motorola CPCAP PMIC RTC +------------------------------------
Need to state what this is a child of.
Quoted 11 lines
Documentation/devicetree/bindings/rtc/cpcap-rtc.txt new file +11
-0+ +Requires node properties: +- compatible: should contain "motorola,cpcap-rtc" +- interrupts: An interrupt specifier for alarm and 1 Hz irq + +Example: + +cpcap_rtc: rtc { + compatible = "motorola,cpcap-rtc"; + interrupts = <39 IRQ_TYPE_NONE>, <26 IRQ_TYPE_NONE>; +};
Signature · 8 lines
You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] For more options, visit https://groups.google.com/d/optout.
Re: [PATCHv3 1/2] dt-bindings: Add vendor prefix for Motorola
In reply to Sebastian ReichelQuoted 2 lines · Sebastian Reichel
Motorola was involved in semiconductor and mobile phone business. The "motrola," prefix is already used by a couple of bindings:
typo.
Quoted 5 lines
*
rtc/rtc-cmos.txt
*mfd/motorola-cpcap.txt
*regulator/cpcap-regulator.txt
Quoted 7 lines
Apart from that it is used in the DT file for the Droid 4 mobile phone.
Signed-off-by Sebastian Reichel <[email protected]>--- Documentation/devicetree/bindings/vendor-prefixes.txt | 1 + 1 file changed, 1 insertion(+)
Otherwise,
Signature · 8 lines
You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] For more options, visit https://groups.google.com/d/optout.
PATCH v4 1/2 dt-bindings: Add vendor prefix for Motorola
In reply to Sebastian ReichelMotorola was involved in semiconductor and mobile phone business. The "motorola," prefix is already used by a couple of bindings:
* rtc/rtc-cmos.txt
* mfd/motorola-cpcap.txt
* regulator/cpcap-regulator.txt
Apart from that it is used in the DT file for the Droid 4 mobile phone.
---
Changes since PATCHv3:
- Fix typo
- Add Acked-By from Rob Herring
--- Documentation/devicetree/bindings/vendor-prefixes.txt | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
@@ -190,6 +190,7 @@ minix MINIX Technology Ltd. miramems MiraMEMS Sensing Technology Co., Ltd. mitsubishi Mitsubishi Electric Corporation mosaixtech Mosaix Technologies, Inc. +motorola Motorola, Inc. moxa Moxa mpl MPL AG mqmaker mqmaker Inc.
Signature · 11 lines
2.11.0 -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] For more options, visit https://groups.google.com/d/optout.
PATCH v4 2/2 rtc: cpcap: new rtc driver
This driver supports the Motorola CPCAP PMIC found on some of Motorola's mobile phones, such as the Droid 4.
---
Changes since PATCHv3:
- Modified DT binding document to mention parent device
--- .../devicetree/bindings/rtc/cpcap-rtc.txt | 18 ++ drivers/rtc/Kconfig | 7 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-cpcap.c | 332 +++++++++++++++++++++ 4 files changed, 358 insertions(+) create mode 100644 Documentation/devicetree/bindings/rtc/cpcap-rtc.txt create mode 100644 drivers/rtc/rtc-cpcap.c
Documentation/devicetree/bindings/rtc/cpcap-rtc.txt new file +18 -0
@@ -0,0 +1,18 @@ +Motorola CPCAP PMIC RTC +----------------------- + +This module is part of the CPCAP. For more details about the whole +chip see Documentation/devicetree/bindings/mfd/motorola-cpcap.txt. + +Requires node properties: +- compatible: should contain "motorola,cpcap-rtc" +- interrupts: An interrupt specifier for alarm and 1 Hz irq + +Example: + +&cpcap { + cpcap_rtc: rtc { + compatible = "motorola,cpcap-rtc"; + interrupts = <39 IRQ_TYPE_NONE>, <26 IRQ_TYPE_NONE>; + }; +};
drivers/rtc/Kconfig +7 -0
@@ -1731,6 +1731,13 @@ config RTC_DRV_STM32 This driver can also be built as a module, if so, the module will be called "rtc-stm32". +config RTC_DRV_CPCAP + depends on MFD_CPCAP + tristate "Motorola CPCAP RTC" + help + Say y here for CPCAP rtc found on some Motorola phones + and tablets such as Droid 4. + comment "HID Sensor RTC drivers" config RTC_DRV_HID_SENSOR_TIME
drivers/rtc/Makefile +1 -0
@@ -40,6 +40,7 @@ obj-$(CONFIG_RTC_DRV_BQ32K) += rtc-bq32k.o obj-$(CONFIG_RTC_DRV_BQ4802) += rtc-bq4802.o obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o obj-$(CONFIG_RTC_DRV_COH901331) += rtc-coh901331.o +obj-$(CONFIG_RTC_DRV_CPCAP) += rtc-cpcap.o obj-$(CONFIG_RTC_DRV_DA9052) += rtc-da9052.o obj-$(CONFIG_RTC_DRV_DA9055) += rtc-da9055.o obj-$(CONFIG_RTC_DRV_DA9063) += rtc-da9063.o
drivers/rtc/rtc-cpcap.c new file +332 -0
332 lines not on this page · raw message
Signature · 11 lines
2.11.0 -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] For more options, visit https://groups.google.com/d/optout.
Re: [PATCHv4 2/2] rtc: cpcap: new rtc driver
Quoted 10 lines · Sebastian Reichel
This driver supports the Motorola CPCAP PMIC found on some of Motorola's mobile phones, such as the Droid 4.
Tested-by Tony Lindgren <[email protected]>Signed-off-by Sebastian Reichel <[email protected]>---
Changes since PATCHv3:
- Modified DT binding document to mention parent device--- .../devicetree/bindings/rtc/cpcap-rtc.txt | 18 ++
Quoted 6 lines
drivers/rtc/Kconfig | 7 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-cpcap.c | 332 +++++++++++++++++++++ 4 files changed, 358 insertions(+) create mode 100644 Documentation/devicetree/bindings/rtc/cpcap-rtc.txt create mode 100644 drivers/rtc/rtc-cpcap.c
Signature · 8 lines
You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] For more options, visit https://groups.google.com/d/optout.
Alexandre Belloni
AppliedRe: [PATCHv4 2/2] rtc: cpcap: new rtc driver
In reply to Sebastian ReichelQuoted 8 lines · Sebastian Reichel
This driver supports the Motorola CPCAP PMIC found on some of Motorola's mobile phones, such as the Droid 4.
Tested-by Tony Lindgren <[email protected]>Signed-off-by Sebastian Reichel <[email protected]>---
Changes since PATCHv3:
- Modified DT binding document to mention parent device
Quoted 9 lines
--- .../devicetree/bindings/rtc/cpcap-rtc.txt | 18 ++ drivers/rtc/Kconfig | 7 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-cpcap.c | 332 +++++++++++++++++++++ 4 files changed, 358 insertions(+) create mode 100644 Documentation/devicetree/bindings/rtc/cpcap-rtc.txt create mode 100644 drivers/rtc/rtc-cpcap.c
Applied, thanks.
Signature · 13 lines
Alexandre Belloni, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] For more options, visit https://groups.google.com/d/optout.
Alexandre Belloni
AppliedRe: [PATCHv4 1/2] dt-bindings: Add vendor prefix for Motorola
In reply to Sebastian ReichelQuoted 12 lines · Sebastian Reichel
Motorola was involved in semiconductor and mobile phone business. The "motorola," prefix is already used by a couple of bindings:
*
rtc/rtc-cmos.txt
*mfd/motorola-cpcap.txt
*regulator/cpcap-regulator.txtApart from that it is used in the DT file for the Droid 4 mobile phone.
Acked-by Rob Herring <[email protected]>Signed-off-by Sebastian Reichel <[email protected]>
Quoted 8 lines
---
Changes since PATCHv3:
- Fix typo
- Add Acked-By from Rob Herring--- Documentation/devicetree/bindings/vendor-prefixes.txt | 1 + 1 file changed, 1 insertion(+)
Applied, thanks.
Signature · 13 lines
Alexandre Belloni, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] For more options, visit https://groups.google.com/d/optout.