rtc: max77686: move initialisation of rtc regmap, irq chip locally
Subsystems (3)
PATCH v5 6/6 rtc: max77686: move initialisation of rtc regmap, irq chip locally
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.
---
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().
Changes from V3:
- Fix the issue of suspend-resume with unbind/bind by unmapping the virq.
Changes from V4:
- Dispose mapped irq in error path in probe
drivers/mfd/max77686.c | 85 +------------------- drivers/rtc/rtc-max77686.c | 151 ++++++++++++++++++++++++++++++----- include/linux/mfd/max77686-private.h | 3 - 3 files changed, 133 insertions(+), 106 deletions(-)
drivers/mfd/max77686.c +3 -82
@@ -35,8 +35,6 @@#include <linux/err.h> #include <linux/of.h> -#define I2C_ADDR_RTC (0x0C >> 1) -static const struct mfd_cell max77686_devs[] = { { .name ="max77686-pmic" , }, { .name ="max77686-rtc" , },
@@ -116,11 +114,6 @@ static const struct regmap_config max77686_regmap_config = { .val_bits = 8, }; -static const struct regmap_config max77686_rtc_regmap_config = { - .reg_bits =8 , - .val_bits =8 , -}; -static const struct regmap_config max77802_regmap_config = { .reg_bits =8 , .val_bits =8 ,
@@ -156,25 +149,6 @@ static const struct regmap_irq_chip max77686_irq_chip = { .num_irqs = ARRAY_SIZE(max77686_irqs), }; -static const struct regmap_irq max77686_rtc_irqs[] = { -/* RTC interrupts */ - { .reg_offset =0 , .mask =MAX77686_RTCINT_RTC60S_MSK , }, - { .reg_offset =0 , .mask =MAX77686_RTCINT_RTCA1_MSK , }, - { .reg_offset =0 , .mask =MAX77686_RTCINT_RTCA2_MSK , }, - { .reg_offset =0 , .mask =MAX77686_RTCINT_SMPL_MSK , }, - { .reg_offset =0 , .mask =MAX77686_RTCINT_RTC1S_MSK , }, - { .reg_offset =0 , .mask =MAX77686_RTCINT_WTSR_MSK , }, -}; - -static const struct regmap_irq_chip max77686_rtc_irq_chip = { - .name ="max77686-rtc" , - .status_base =MAX77686_RTC_INT , - .mask_base =MAX77686_RTC_INTM , - .num_regs =1 , - .irqs = max77686_rtc_irqs, - .num_irqs =ARRAY_SIZE (max77686_rtc_irqs), -}; -static const struct regmap_irq_chip max77802_irq_chip = { .name ="max77802-pmic" , .status_base =MAX77802_REG_INT1 ,
@@ -184,15 +158,6 @@ static const struct regmap_irq_chip max77802_irq_chip = { .num_irqs = ARRAY_SIZE(max77686_irqs), }; -static const struct regmap_irq_chip max77802_rtc_irq_chip = { - .name ="max77802-rtc" , - .status_base =MAX77802_RTC_INT , - .mask_base =MAX77802_RTC_INTM , - .num_regs =1 , - .irqs = max77686_rtc_irqs,/* same masks as 77686 */ - .num_irqs =ARRAY_SIZE (max77686_rtc_irqs), -}; -static const struct of_device_id max77686_pmic_dt_match[] = { { .compatible ="maxim,max77686" ,
@@ -214,8 +179,6 @@ static int max77686_i2c_probe(struct i2c_client *i2c,int ret =0 ;const struct regmap_config *config;const struct regmap_irq_chip *irq_chip; -const struct regmap_irq_chip *rtc_irq_chip; -struct regmap **rtc_regmap;const struct mfd_cell *cells;int n_devs;
@@ -242,15 +205,11 @@ static int max77686_i2c_probe(struct i2c_client *i2c,if (max77686->type ==TYPE_MAX77686 ) { config = &max77686_regmap_config; irq_chip = &max77686_irq_chip; - rtc_irq_chip = &max77686_rtc_irq_chip; - rtc_regmap = &max77686->rtc_regmap; cells = max77686_devs; n_devs =ARRAY_SIZE (max77686_devs); }else { config = &max77802_regmap_config; irq_chip = &max77802_irq_chip; - rtc_irq_chip = &max77802_rtc_irq_chip; - rtc_regmap = &max77686->regmap; cells = max77802_devs; n_devs =ARRAY_SIZE (max77802_devs); }
@@ -270,59 +229,25 @@ static int max77686_i2c_probe(struct i2c_client *i2c,return -ENODEV ; } -if (max77686->type ==TYPE_MAX77686 ) { - max77686->rtc =i2c_new_dummy (i2c->adapter,I2C_ADDR_RTC ); -if (!max77686->rtc) { -dev_err (max77686->dev, -"Failed to allocate I2C device for RTC\n" ); -return -ENODEV ; - } - - max77686->rtc_regmap = -devm_regmap_init_i2c (max77686->rtc, - &max77686_rtc_regmap_config); -if (IS_ERR (max77686->rtc_regmap)) { - ret =PTR_ERR (max77686->rtc_regmap); -dev_err (max77686->dev, -"failed to allocate RTC regmap: %d\n" , - ret); - goto err_unregister_i2c; - } - } - ret =regmap_add_irq_chip (max77686->regmap, max77686->irq,IRQF_TRIGGER_FALLING |IRQF_ONESHOT |IRQF_SHARED ,0 , irq_chip, &max77686->irq_data); -if (ret) { +if (ret <0 ) {dev_err (&i2c->dev,"failed to add PMIC irq chip: %d\n" , ret); - goto err_unregister_i2c; - } - - ret =regmap_add_irq_chip (*rtc_regmap, max77686->irq, -IRQF_TRIGGER_FALLING |IRQF_ONESHOT | -IRQF_SHARED ,0 , rtc_irq_chip, - &max77686->rtc_irq_data); -if (ret) { -dev_err (&i2c->dev,"failed to add RTC irq chip: %d\n" , ret); - goto err_del_irqc; +return ret; } ret =mfd_add_devices (max77686->dev,-1 , cells, n_devs,NULL ,0 ,NULL );if (ret <0 ) {dev_err (&i2c->dev,"failed to add MFD devices: %d\n" , ret); - goto err_del_rtc_irqc; + goto err_del_irqc; }return 0 ; -err_del_rtc_irqc: -regmap_del_irq_chip (max77686->irq, max77686->rtc_irq_data); err_del_irqc:regmap_del_irq_chip (max77686->irq, max77686->irq_data); -err_unregister_i2c: -if (max77686->type ==TYPE_MAX77686 ) -i2c_unregister_device (max77686->rtc);return ret; }
@@ -333,12 +258,8 @@ static int max77686_i2c_remove(struct i2c_client *i2c)mfd_remove_devices (max77686->dev); -regmap_del_irq_chip (max77686->irq, max77686->rtc_irq_data);regmap_del_irq_chip (max77686->irq, max77686->irq_data); -if (max77686->type ==TYPE_MAX77686 ) -i2c_unregister_device (max77686->rtc); -return 0 ; }
drivers/rtc/rtc-max77686.c +130 -21
244 lines not on this page · raw message
include/linux/mfd/max77686-private.h +0 -3
@@ -437,14 +437,11 @@ enum max77686_irq {struct max77686_dev {struct device *dev;struct i2c_client *i2c;/* 0xcc / PMIC, Battery Control, and FLASH */ -struct i2c_client *rtc;/* slave addr 0x0c */ unsigned long type;struct regmap *regmap;/* regmap for mfd */ -struct regmap *rtc_regmap;/* regmap for rtc */ struct regmap_irq_chip_data *irq_data; -struct regmap_irq_chip_data *rtc_irq_data;int irq;struct mutex irqlock;
Signature · 12 lines
2.1.4 -- -- 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.