Add rtc support for rn5t618 mfd
v4 cover Add rtc support for rn5t618 mfd
In the variant RC5T619 the mfd has an RTC. This patchset adds support for it. To do so it adds the missing register defines in rn5t618.h and general irq handling for that.
It seems that the irq definitions are the same except missing RTC but due to missing ability to test that I do not add them here.
The rtc driver itself is based on
https://github.com/kobolabs/Kobo-Reader/blob/master/hw/imx6sll-clara/kernel.tar.bz2
but heavily reworked.
It was tested on the Kobo Clara HD.
Changes in v4:
- use macros for IRQ definitions
- merge rn5t618-core.c and rn5t618-irq.c
Changes in v3:
- alignment cleanup
- output cleanup, remove useless toggling of alarm flag in rtc probe
- updated bindings description, so patch 1/5 becomes 2/6 and so on
Changes in v2:
- no dead code in irq code
- various improvements and cleanups in rtc driver itself
Andreas Kemnade (5):
dt-bindings: mfd: rn5t618: Document optional property interrupts
mfd: rn5t618: add IRQ support
mfd: rn5t618: add RTC related registers
mfd: rn5t618: add more subdevices
rtc: rc5t619: add ricoh rc5t619 RTC driver
Documentation/devicetree/bindings/mfd/rn5t618.txt | 4 + drivers/mfd/Kconfig | 1 + drivers/mfd/rn5t618.c | 106 +++++- drivers/rtc/Kconfig | 10 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-rc5t619.c | 444 ++++++++++++++++++++++ include/linux/mfd/rn5t618.h | 26 ++ 7 files changed, 590 insertions(+), 2 deletions(-) create mode 100644 drivers/rtc/rtc-rc5t619.c
Signature · 1 line
2.11.0
PATCH v4 1/5 dt-bindings: mfd: rn5t618: Document optional property interrupts
These chips use interrupts for various things like RTC alarm.
---
Changes in v4: add refernce to interrupt binding
documentation
Documentation/devicetree/bindings/mfd/rn5t618.txt | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/mfd/rn5t618.txt +4 -0
@@ -15,6 +15,8 @@ Required properties: - reg: the I2C slave address of the device Optional properties: + - interrupts: interrupt mapping for IRQ + See Documentation/devicetree/bindings/interrupt-controller/interrupts.txt - system-power-controller: See Documentation/devicetree/bindings/power/power-controller.txt
@@ -32,6 +34,8 @@ Example: pmic@32 { compatible = "ricoh,rn5t618"; reg = <0x32>; + interrupt-parent = <&gpio5>; + interrupts = <11 IRQ_TYPE_EDGE_FALLING>; system-power-controller; regulators {
Signature · 1 line
2.11.0
Re: [PATCH v4 1/5] dt-bindings: mfd: rn5t618: Document optional property interrupts
Quoted 8 lines · Andreas Kemnade
These chips use interrupts for various things like RTC alarm.
Signed-off-by Andreas Kemnade <[email protected]>---
Changes in v4: add refernce to interrupt binding
documentationDocumentation/devicetree/bindings/mfd/rn5t618.txt | 4 ++++ 1 file changed, 4 insertions(+)
For my own reference:
Signature · 4 lines
Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v4 1/5] dt-bindings: mfd: rn5t618: Document optional property interrupts
In reply to Andreas KemnadeQuoted 9 lines · Andreas Kemnade
These chips use interrupts for various things like RTC alarm.
Signed-off-by Andreas Kemnade <[email protected]>---
Changes in v4: add refernce to interrupt binding
documentationDocumentation/devicetree/bindings/mfd/rn5t618.txt | 4 ++++ 1 file changed, 4 insertions(+)
PATCH v4 2/5 mfd: rn5t618: add IRQ support
In reply to Andreas KemnadeThis adds support for IRQ handling in the RC5T619 which is required for properly implementing subdevices like RTC.
For now only definitions for the variant RC5T619 are included.
---
Changes in v4:
merge rn5t618-irq.c into rn5t618.c
use macros for IRQ table
Changes in v3:
alignment cleanup
Changes in v2:
- no dead code, did some more testing and thinking for that
- remove extra empty lines
drivers/mfd/Kconfig | 1 + drivers/mfd/rn5t618.c | 88 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/rn5t618.h | 15 ++++++++ 3 files changed, 104 insertions(+)
drivers/mfd/Kconfig +1 -0
@@ -1057,6 +1057,7 @@ config MFD_RN5T618 depends on OF select MFD_CORE select REGMAP_I2C + select REGMAP_IRQ help Say yes here to add support for the Ricoh RN5T567, RN5T618, RC5T619 PMIC.
drivers/mfd/rn5t618.c +88 -0
130 lines not on this page · raw message
include/linux/mfd/rn5t618.h +15 -0
@@ -242,9 +242,24 @@ enum { RC5T619, }; +/* RN5T618 IRQ definitions */ +enum { +RN5T618_IRQ_SYS =0 , +RN5T618_IRQ_DCDC , +RN5T618_IRQ_RTC , +RN5T618_IRQ_ADC , +RN5T618_IRQ_GPIO , +RN5T618_IRQ_CHG , +RN5T618_NR_IRQS , +}; +struct rn5t618 {struct regmap *regmap; +struct device *dev;long variant; + +int irq; +struct regmap_irq_chip_data *irq_data; };#endif /* __LINUX_MFD_RN5T618_H */
Signature · 1 line
2.11.0
Re: [PATCH v4 2/5] mfd: rn5t618: add IRQ support
Quoted 63 lines · Andreas Kemnade
This adds support for IRQ handling in the RC5T619 which is required for properly implementing subdevices like RTC.
For now only definitions for the variant RC5T619 are included.Signed-off-by Andreas Kemnade <[email protected]>---
Changes in v4:
mergern5t618-irq.cintorn5t618.c
use macros for IRQ tableChanges in v3:
alignment cleanupChanges in v2:
- no dead code, did some more testing and thinking for that
- remove extra empty linesdrivers/mfd/Kconfig | 1 + drivers/mfd/rn5t618.c | 88 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/rn5t618.h | 15 ++++++++ 3 files changed, 104 insertions(+)drivers/mfd/Kconfig +1
-0@@ -1057,6 +1057,7 @@ config MFD_RN5T618 depends on OF select MFD_CORE select REGMAP_I2C + select REGMAP_IRQ help Say yes here to add support for the Ricoh RN5T567, RN5T618, RC5T619 PMIC.drivers/mfd/rn5t618.c +15
-0@@ -8,6 +8,8 @@#include <linux/delay.h> #include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/irq.h> #include <linux/mfd/core.h> #include <linux/mfd/rn5t618.h> #include <linux/module.h> @@ -45,9 +47,63 @@ static const struct regmap_config rn5t618_regmap_config = { .cache_type = REGCACHE_RBTREE, }; +static const struct regmap_irq rc5t619_irqs[] = { +REGMAP_IRQ_REG (RN5T618_IRQ_SYS ,0 ,BIT (0 )), +REGMAP_IRQ_REG (RN5T618_IRQ_DCDC ,0 ,BIT (1 )), +REGMAP_IRQ_REG (RN5T618_IRQ_RTC ,0 ,BIT (2 )), +REGMAP_IRQ_REG (RN5T618_IRQ_ADC ,0 ,BIT (3 )), +REGMAP_IRQ_REG (RN5T618_IRQ_GPIO ,0 ,BIT (4 )), +REGMAP_IRQ_REG (RN5T618_IRQ_CHG ,0 ,BIT (6 )), +}; + +static const struct regmap_irq_chip rc5t619_irq_chip = { + .name ="rc5t619" , + .irqs = rc5t619_irqs, + .num_irqs =ARRAY_SIZE (rc5t619_irqs),
drivers/mfd/rn5t618.c static const struct regmap_config rn5t618_regmap_config = { · line 72
Quoted 10 lines
drivers/mfd/rn5t618.c +7
-0+ .num_regs = 1, + .status_base = RN5T618_INTMON, + .mask_base = RN5T618_INTEN, + .mask_invert = true, +}; +static struct rn5t618 *rn5t618_pm_power_off;static struct notifier_block rn5t618_restart_handler; +int rn5t618_irq_init (struct rn5t618 *rn5t618)
Static?
Signature · 4 lines
Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v4 2/5] mfd: rn5t618: add IRQ support
Quoted 74 lines · On Mon, 16 Dec 2019 15:27:15 +0000 Lee Jones <[email protected]> wrote:
Quoted 72 lines · Andreas Kemnade
This adds support for IRQ handling in the RC5T619 which is required for properly implementing subdevices like RTC.
For now only definitions for the variant RC5T619 are included.Signed-off-by Andreas Kemnade <[email protected]>---
Changes in v4:
mergern5t618-irq.cintorn5t618.c
use macros for IRQ tableChanges in v3:
alignment cleanupChanges in v2:
- no dead code, did some more testing and thinking for that
- remove extra empty linesdrivers/mfd/Kconfig | 1 + drivers/mfd/rn5t618.c | 88 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/rn5t618.h | 15 ++++++++ 3 files changed, 104 insertions(+)drivers/mfd/Kconfig +1
-0@@ -1057,6 +1057,7 @@ config MFD_RN5T618 depends on OF select MFD_CORE select REGMAP_I2C + select REGMAP_IRQ help Say yes here to add support for the Ricoh RN5T567, RN5T618, RC5T619 PMIC.drivers/mfd/rn5t618.c +21
-0@@ -8,6 +8,8 @@#include <linux/delay.h> #include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/irq.h> #include <linux/mfd/core.h> #include <linux/mfd/rn5t618.h> #include <linux/module.h> @@ -45,9 +47,63 @@ static const struct regmap_config rn5t618_regmap_config = { .cache_type = REGCACHE_RBTREE, }; +static const struct regmap_irq rc5t619_irqs[] = { +REGMAP_IRQ_REG (RN5T618_IRQ_SYS ,0 ,BIT (0 )), +REGMAP_IRQ_REG (RN5T618_IRQ_DCDC ,0 ,BIT (1 )), +REGMAP_IRQ_REG (RN5T618_IRQ_RTC ,0 ,BIT (2 )), +REGMAP_IRQ_REG (RN5T618_IRQ_ADC ,0 ,BIT (3 )), +REGMAP_IRQ_REG (RN5T618_IRQ_GPIO ,0 ,BIT (4 )), +REGMAP_IRQ_REG (RN5T618_IRQ_CHG ,0 ,BIT (6 )), +}; + +static const struct regmap_irq_chip rc5t619_irq_chip = { + .name ="rc5t619" , + .irqs = rc5t619_irqs, + .num_irqs =ARRAY_SIZE (rc5t619_irqs), + .num_regs =1 , + .status_base =RN5T618_INTMON , + .mask_base =RN5T618_INTEN , + .mask_invert = true, +}; +static struct rn5t618 *rn5t618_pm_power_off;static struct notifier_block rn5t618_restart_handler;
Quoted 4 lines
drivers/mfd/rn5t618.c static const struct regmap_config rn5t618_regmap_config = { · line 72
Quoted 1 line
drivers/mfd/rn5t618.c +1
-0+int rn5t618_irq_init (struct rn5t618 *rn5t618)Static?
yes, it should be static since IRQ and core do live in the same file now.
Regards,
Andreas
PATCH v4 3/5 mfd: rn5t618: add RTC related registers
In reply to Andreas KemnadeDefines for some RTC related registers were missing, also they were not included in the volatile register list
---
drivers/mfd/rn5t618.c | 2 ++ include/linux/mfd/rn5t618.h | 11 +++++++++++ 2 files changed, 13 insertions(+)
drivers/mfd/rn5t618.c +2 -0
@@ -33,6 +33,8 @@ static bool rn5t618_volatile_reg(struct device *dev, unsigned int reg)case RN5T618_IR_GPF :case RN5T618_MON_IOIN :case RN5T618_INTMON : + case RN5T618_RTC_CTRL1 ... RN5T618_RTC_CTRL2: + case RN5T618_RTC_SECONDS ... RN5T618_RTC_YEAR:return true;default :return false;
include/linux/mfd/rn5t618.h +11 -0
@@ -139,6 +139,17 @@#define RN5T618_INTPOL 0x9c#define RN5T618_INTEN 0x9d#define RN5T618_INTMON 0x9e + +#define RN5T618_RTC_SECONDS 0xA0 +#define RN5T618_RTC_MDAY 0xA4 +#define RN5T618_RTC_MONTH 0xA5 +#define RN5T618_RTC_YEAR 0xA6 +#define RN5T618_RTC_ADJUST 0xA7 +#define RN5T618_RTC_ALARM_Y_SEC 0xA8 +#define RN5T618_RTC_DAL_MONTH 0xAC +#define RN5T618_RTC_CTRL1 0xAE +#define RN5T618_RTC_CTRL2 0xAF +#define RN5T618_PREVINDAC 0xb0#define RN5T618_BATDAC 0xb1#define RN5T618_CHGCTL1 0xb3
Signature · 1 line
2.11.0
Re: [PATCH v4 3/5] mfd: rn5t618: add RTC related registers
Quoted 9 lines · Andreas Kemnade
Defines for some RTC related registers were missing, also they were not included in the volatile register list
Signed-off-by Andreas Kemnade <[email protected]>---
drivers/mfd/rn5t618.c | 2 ++ include/linux/mfd/rn5t618.h | 11 +++++++++++ 2 files changed, 13 insertions(+)
For my own reference:
Signature · 4 lines
Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH v4 4/5 mfd: rn5t618: add more subdevices
In reply to Andreas KemnadeThe RC5T619 has a RTC which is missing in the
RN5T618. Add it as subdevice to prepare for their implementation
---
Changes in v3:
- alignment cleanup
drivers/mfd/rn5t618.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/mfd/rn5t618.c +14 -2
@@ -22,6 +22,12 @@ static const struct mfd_cell rn5t618_cells[] = { { .name = "rn5t618-wdt" }, }; +static const struct mfd_cell rc5t619_cells[] = { + { .name ="rn5t618-regulator" }, + { .name ="rc5t619-rtc" }, + { .name ="rn5t618-wdt" }, +}; +static bool rn5t618_volatile_reg (struct device *dev,unsigned int reg) {switch (reg) {
@@ -173,8 +179,14 @@ static int rn5t618_i2c_probe(struct i2c_client *i2c,return ret; } - ret =devm_mfd_add_devices (&i2c->dev,-1 , rn5t618_cells, -ARRAY_SIZE (rn5t618_cells),NULL ,0 ,NULL ); +if (priv->variant ==RC5T619 ) + ret =devm_mfd_add_devices (&i2c->dev,-1 , rc5t619_cells, +ARRAY_SIZE (rc5t619_cells), +NULL ,0 ,NULL ); +else + ret =devm_mfd_add_devices (&i2c->dev,-1 , rn5t618_cells, +ARRAY_SIZE (rn5t618_cells), +NULL ,0 ,NULL );if (ret) {dev_err (&i2c->dev,"failed to add sub-devices: %d\n" , ret);return ret;
Signature · 1 line
2.11.0
Re: [PATCH v4 4/5] mfd: rn5t618: add more subdevices
Quoted 28 lines · Andreas Kemnade
The RC5T619 has a RTC which is missing in the
RN5T618. Add it as subdevice to prepare for their implementationSigned-off-by Andreas Kemnade <[email protected]>---
Changes in v3:
- alignment cleanupdrivers/mfd/rn5t618.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)drivers/mfd/rn5t618.c +6
-0@@ -22,6 +22,12 @@ static const struct mfd_cell rn5t618_cells[] = { { .name = "rn5t618-wdt" }, }; +static const struct mfd_cell rc5t619_cells[] = { + { .name ="rn5t618-regulator" }, + { .name ="rc5t619-rtc" }, + { .name ="rn5t618-wdt" }, +}; +static bool rn5t618_volatile_reg (struct device *dev,unsigned int reg) {switch (reg) {
drivers/mfd/rn5t618.c static int rn5t618_i2c_probe(struct i2c_client *i2c, · line 183
Quoted 7 lines
drivers/mfd/rn5t618.c +2
-2@@ -173,8 +179,14 @@ static int rn5t618_i2c_probe(struct i2c_client *i2c,return ret; } - ret =devm_mfd_add_devices (&i2c->dev,-1 , rn5t618_cells, -ARRAY_SIZE (rn5t618_cells),NULL ,0 ,NULL ); +if (priv->variant ==RC5T619 ) + ret = devm_mfd_add_devices(&i2c->dev, -1, rc5t619_cells,
Ref: The "-1", please use this as an opportunity to use the defines.
drivers/mfd/rn5t618.c static int rn5t618_i2c_probe(struct i2c_client *i2c, · line 186
Quoted 3 lines
drivers/mfd/rn5t618.c +3
-0+ARRAY_SIZE (rc5t619_cells), + NULL, 0, NULL); + else
Are you sure it's not possible for 'variant' to be an unsupported device?
Quoted 6 lines
drivers/mfd/rn5t618.c +3
-0+ ret =devm_mfd_add_devices (&i2c->dev,-1 , rn5t618_cells, +ARRAY_SIZE (rn5t618_cells), +NULL ,0 ,NULL );if (ret) {dev_err (&i2c->dev,"failed to add sub-devices: %d\n" , ret);return ret;
Signature · 4 lines
Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v4 4/5] mfd: rn5t618: add more subdevices
Quoted 40 lines · On Mon, 16 Dec 2019 15:31:06 +0000 Lee Jones <[email protected]> wrote:
Quoted 28 lines · Andreas Kemnade
The RC5T619 has a RTC which is missing in the
RN5T618. Add it as subdevice to prepare for their implementationSigned-off-by Andreas Kemnade <[email protected]>---
Changes in v3:
- alignment cleanupdrivers/mfd/rn5t618.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)drivers/mfd/rn5t618.c +6
-0@@ -22,6 +22,12 @@ static const struct mfd_cell rn5t618_cells[] = { { .name = "rn5t618-wdt" }, }; +static const struct mfd_cell rc5t619_cells[] = { + { .name ="rn5t618-regulator" }, + { .name ="rc5t619-rtc" }, + { .name ="rn5t618-wdt" }, +}; +static bool rn5t618_volatile_reg (struct device *dev,unsigned int reg) {switch (reg) {drivers/mfd/rn5t618.c static int rn5t618_i2c_probe(struct i2c_client *i2c, · line 183
Quoted 7 lines
drivers/mfd/rn5t618.c +2
-2@@ -173,8 +179,14 @@ static int rn5t618_i2c_probe(struct i2c_client *i2c,return ret; } - ret =devm_mfd_add_devices (&i2c->dev,-1 , rn5t618_cells, -ARRAY_SIZE (rn5t618_cells),NULL ,0 ,NULL ); +if (priv->variant ==RC5T619 ) + ret = devm_mfd_add_devices(&i2c->dev, -1, rc5t619_cells,Ref: The "-1", please use this as an opportunity to use the defines.
Quoted 7 lines
drivers/mfd/rn5t618.c static int rn5t618_i2c_probe(struct i2c_client *i2c, · line 186
Quoted 3 lines
drivers/mfd/rn5t618.c +3
-0+ARRAY_SIZE (rc5t619_cells), + NULL, 0, NULL); + elseAre you sure it's not possible for 'variant' to be an unsupported device?
Well, does it change the behavior for devices other than the rc5t619? I do not think so. If the mfd driver is bound to unsupported devices, rn5t618_of_match is wrong.
Or do you want separate cell arrays for each of the three variant now to ease future extensions?
Regards,
Andreas
Re: [PATCH v4 4/5] mfd: rn5t618: add more subdevices
Quoted 50 lines · Andreas Kemnade
Quoted 40 lines · On Mon, 16 Dec 2019 15:31:06 +0000 Lee Jones <[email protected]> wrote:
Quoted 28 lines · Andreas Kemnade
The RC5T619 has a RTC which is missing in the
RN5T618. Add it as subdevice to prepare for their implementationSigned-off-by Andreas Kemnade <[email protected]>---
Changes in v3:
- alignment cleanupdrivers/mfd/rn5t618.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)drivers/mfd/rn5t618.c +6
-0@@ -22,6 +22,12 @@ static const struct mfd_cell rn5t618_cells[] = { { .name = "rn5t618-wdt" }, }; +static const struct mfd_cell rc5t619_cells[] = { + { .name ="rn5t618-regulator" }, + { .name ="rc5t619-rtc" }, + { .name ="rn5t618-wdt" }, +}; +static bool rn5t618_volatile_reg (struct device *dev,unsigned int reg) {switch (reg) {drivers/mfd/rn5t618.c static int rn5t618_i2c_probe(struct i2c_client *i2c, · line 183
Quoted 7 lines
drivers/mfd/rn5t618.c +2
-2@@ -173,8 +179,14 @@ static int rn5t618_i2c_probe(struct i2c_client *i2c,return ret; } - ret =devm_mfd_add_devices (&i2c->dev,-1 , rn5t618_cells, -ARRAY_SIZE (rn5t618_cells),NULL ,0 ,NULL ); +if (priv->variant ==RC5T619 ) + ret = devm_mfd_add_devices(&i2c->dev, -1, rc5t619_cells,Ref: The "-1", please use this as an opportunity to use the defines.
Quoted 7 lines
drivers/mfd/rn5t618.c static int rn5t618_i2c_probe(struct i2c_client *i2c, · line 186
Quoted 3 lines
drivers/mfd/rn5t618.c +3
-0+ARRAY_SIZE (rc5t619_cells), + NULL, 0, NULL); + elseAre you sure it's not possible for 'variant' to be an unsupported device?
Quoted 3 lines
Well, does it change the behavior for devices other than the rc5t619? I do not think so. If the mfd driver is bound to unsupported devices,
rn5t618_of_matchis wrong.
Right, and can you catch that?
Quoted 2 lines
Or do you want separate cell arrays for each of the three variant now to ease future extensions?
No need for that, thank you.
Signature · 4 lines
Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v4 4/5] mfd: rn5t618: add more subdevices
Quoted 38 lines · On Tue, 17 Dec 2019 08:01:46 +0000 Lee Jones <[email protected]> wrote:
Quoted 36 lines · Andreas Kemnade
Quoted 33 lines · On Mon, 16 Dec 2019 15:31:06 +0000 Lee Jones <[email protected]> wrote:
Quoted 31 lines · Andreas Kemnade
The RC5T619 has a RTC which is missing in the
RN5T618. Add it as subdevice to prepare for their implementationSigned-off-by Andreas Kemnade <[email protected]>---
Changes in v3:
- alignment cleanupdrivers/mfd/rn5t618.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)drivers/mfd/rn5t618.c +6
-0@@ -22,6 +22,12 @@ static const struct mfd_cell rn5t618_cells[] = { { .name = "rn5t618-wdt" }, }; +static const struct mfd_cell rc5t619_cells[] = { + { .name ="rn5t618-regulator" }, + { .name ="rc5t619-rtc" }, + { .name ="rn5t618-wdt" }, +}; +static bool rn5t618_volatile_reg (struct device *dev,unsigned int reg) {switch (reg) {@@ -173,8 +179,14 @@ static int rn5t618_i2c_probe(struct i2c_client *i2c,return ret; }
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/mfd/rn5t618.c static int rn5t618_i2c_probe(struct i2c_client *i2c, · line 183
Quoted 4 lines
drivers/mfd/rn5t618.c +2
-2- ret =devm_mfd_add_devices (&i2c->dev,-1 , rn5t618_cells, -ARRAY_SIZE (rn5t618_cells),NULL ,0 ,NULL ); +if (priv->variant ==RC5T619 ) + ret = devm_mfd_add_devices(&i2c->dev, -1, rc5t619_cells,Ref: The "-1", please use this as an opportunity to use the defines.
BTW: of course I can clean that up.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/mfd/rn5t618.c static int rn5t618_i2c_probe(struct i2c_client *i2c, · line 186
Quoted 3 lines
drivers/mfd/rn5t618.c +3
-0+ARRAY_SIZE (rc5t619_cells), + NULL, 0, NULL); + elseAre you sure it's not possible for 'variant' to be an unsupported device?
Quoted 6 lines
Quoted 3 lines
Well, does it change the behavior for devices other than the rc5t619? I do not think so. If the mfd driver is bound to unsupported devices,
rn5t618_of_matchis wrong.Right, and can you catch that?
Well, maybe we don't get each other. RC5T619 has an RTC. If I understand the code right, priv->variant is set to RC5T619. if there is compatible = "ricoh,rc5t619" in the device tree. So in that and only in that case I have an extended subdevice list, which includes the RTC subdevice instead of only regulator and wdt. For everything else I do not touch it.
So now you have doubts wether the existing regulator and watchdog subdevice drivers (which I do not touch) works with the other two variants (RN5T618 and RN5T567) and want me to check that again as part of my work to get RTC support for RC5T619 in?
Regards,
Andreas
Re: [PATCH v4 4/5] mfd: rn5t618: add more subdevices
Quoted 61 lines · On Tue, 17 Dec 2019 12:25:26 +0100 Andreas Kemnade <[email protected]> wrote:
Quoted 38 lines · On Tue, 17 Dec 2019 08:01:46 +0000 Lee Jones <[email protected]> wrote:
Quoted 36 lines · Andreas Kemnade
Quoted 33 lines · On Mon, 16 Dec 2019 15:31:06 +0000 Lee Jones <[email protected]> wrote:
Quoted 31 lines · Andreas Kemnade
The RC5T619 has a RTC which is missing in the
RN5T618. Add it as subdevice to prepare for their implementationSigned-off-by Andreas Kemnade <[email protected]>---
Changes in v3:
- alignment cleanupdrivers/mfd/rn5t618.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)drivers/mfd/rn5t618.c +6
-0@@ -22,6 +22,12 @@ static const struct mfd_cell rn5t618_cells[] = { { .name = "rn5t618-wdt" }, }; +static const struct mfd_cell rc5t619_cells[] = { + { .name ="rn5t618-regulator" }, + { .name ="rc5t619-rtc" }, + { .name ="rn5t618-wdt" }, +}; +static bool rn5t618_volatile_reg (struct device *dev,unsigned int reg) {switch (reg) {@@ -173,8 +179,14 @@ static int rn5t618_i2c_probe(struct i2c_client *i2c,return ret; }Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/mfd/rn5t618.c static int rn5t618_i2c_probe(struct i2c_client *i2c, · line 183
Quoted 4 lines
drivers/mfd/rn5t618.c +2
-2- ret =devm_mfd_add_devices (&i2c->dev,-1 , rn5t618_cells, -ARRAY_SIZE (rn5t618_cells),NULL ,0 ,NULL ); +if (priv->variant ==RC5T619 ) + ret = devm_mfd_add_devices(&i2c->dev, -1, rc5t619_cells,Ref: The "-1", please use this as an opportunity to use the defines.
BTW: of course I can clean that up.
Quoted 11 lines
Quoted 10 lines
Quoted 7 lines
drivers/mfd/rn5t618.c static int rn5t618_i2c_probe(struct i2c_client *i2c, · line 186
Quoted 3 lines
drivers/mfd/rn5t618.c +3
-0+ARRAY_SIZE (rc5t619_cells), + NULL, 0, NULL); + elseAre you sure it's not possible for 'variant' to be an unsupported device?
Well, does it change the behavior for devices other than the rc5t619? I do not think so. If the mfd driver is bound to unsupported devices,
rn5t618_of_matchis wrong.
Quoted 9 lines
Quoted 2 lines
Right, and can you catch that?
Well, maybe we don't get each other. RC5T619 has an RTC. If I understand the code right,
priv->variantis set to RC5T619. if there is compatible = "ricoh,rc5t619" in the device tree. So in that and only in that case I have an extended subdevice list, which includes the RTC subdevice instead of only regulator and wdt. For everything else I do not touch it.
Hmm, if the driver might be probed without device tree node, there is:
of_id = of_match_device(rn5t618_of_match, &i2c->dev);
if (!of_id) {
dev_err(&i2c->dev, "Failed to find matching DT ID\n");
return -EINVAL;
}so nothing will be registered at all. So the only reasons I see the driver might be bound to unsupported devices could be:
- a bug in of_match_device()
- nonsense in rn5t618_of_match (I think that are well-thought entries)
Regards,
Andreas
PATCH v4 5/5 rtc: rc5t619: add ricoh rc5t619 RTC driver
In reply to Andreas KemnadeAdd an RTC driver for the RTC device on Ricoh MFD RC5T619, which is implemented as a variant of RN5T618.
rtc-range output:
Testing 2000-02-28 23:59:59.
OK
Testing 2038-01-19 03:14:07.
OK
Testing 2069-12-31 23:59:59.
OK
Testing 2099-12-31 23:59:59.
KO RTC_RD_TIME returned 22 (line 138)
Testing 2100-02-28 23:59:59.
KO RTC_SET_TIME returned 34 (line 122)
Testing 2106-02-07 06:28:15.
KO RTC_SET_TIME returned 34 (line 122)
Testing 2262-04-11 23:47:16.
KO RTC_SET_TIME returned 34 (line 122)
---
Changes in v3:
- further output cleanup
- remove useless toggling of alarm flag in rtc probe
- alignment cleanup
Changes in v2:
- correct subject line
- reset pon flag not at probe but later
- initialize things only on pon
- 12h handling
- ranges
- style cleanup
- less magic values
drivers/rtc/Kconfig | 10 ++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-rc5t619.c | 444 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 455 insertions(+) create mode 100644 drivers/rtc/rtc-rc5t619.c
drivers/rtc/Kconfig +10 -0
@@ -600,6 +600,16 @@ config RTC_DRV_RC5T583 This driver can also be built as a module. If so, the module will be called rtc-rc5t583. +config RTC_DRV_RC5T619 + tristate "RICOH RC5T619 RTC driver" + depends on MFD_RN5T618 + help + If you say yes here you get support for the RTC on the + RICOH RC5T619 chips. + + This driver can also be built as a module. If so, the module + will be called rtc-rc5t619. + config RTC_DRV_S35390A tristate "Seiko Instruments S-35390A" select BITREVERSE
drivers/rtc/Makefile +1 -0
@@ -137,6 +137,7 @@ obj-$(CONFIG_RTC_DRV_PXA) += rtc-pxa.o obj-$(CONFIG_RTC_DRV_R7301) += rtc-r7301.o obj-$(CONFIG_RTC_DRV_R9701) += rtc-r9701.o obj-$(CONFIG_RTC_DRV_RC5T583) += rtc-rc5t583.o +obj-$(CONFIG_RTC_DRV_RC5T619) += rtc-rc5t619.o obj-$(CONFIG_RTC_DRV_RK808) += rtc-rk808.o obj-$(CONFIG_RTC_DRV_RP5C01) += rtc-rp5c01.o obj-$(CONFIG_RTC_DRV_RS5C313) += rtc-rs5c313.o
drivers/rtc/rtc-rc5t619.c new file +444 -0
444 lines not on this page · raw message
Signature · 1 line
2.11.0