All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Cc: mazziesaccount@gmail.com, Lee Jones <lee.jones@linaro.org>,
	Alessandro Zummo <a.zummo@towertech.it>,
	linux-kernel@vger.kernel.org, linux-power@fi.rohmeurope.com,
	linux-rtc@vger.kernel.org
Subject: Re: [PATCH v2 16/17] rtc: bd70528: Support RTC on ROHM BD71815
Date: Tue, 19 Jan 2021 22:10:41 +0100	[thread overview]
Message-ID: <20210119211041.GS3666@piout.net> (raw)
In-Reply-To: <948164eb1c3053c3dc31c9b46de92b1c9b7224ae.1611037866.git.matti.vaittinen@fi.rohmeurope.com>

On 19/01/2021 09:31:36+0200, Matti Vaittinen wrote:
> BD71815 contains similar RTC block as BD71828. Only the address offsets
> seem different. Support also BD71815 RTC using rtc-bd70528.
> 
> Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

> ---
> No changes since v1
> 
>  drivers/rtc/Kconfig       |  6 +++---
>  drivers/rtc/rtc-bd70528.c | 45 ++++++++++++++++++++++++++++++++-------
>  2 files changed, 40 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
> index 6123f9f4fbc9..1e48424a4729 100644
> --- a/drivers/rtc/Kconfig
> +++ b/drivers/rtc/Kconfig
> @@ -501,11 +501,11 @@ config RTC_DRV_M41T80_WDT
>  	  watchdog timer in the ST M41T60 and M41T80 RTC chips series.
>  
>  config RTC_DRV_BD70528
> -	tristate "ROHM BD70528 PMIC RTC"
> -	depends on MFD_ROHM_BD70528 && (BD70528_WATCHDOG || !BD70528_WATCHDOG)
> +	tristate "ROHM BD70528, BD71815 and BD71828 PMIC RTC"
> +	depends on MFD_ROHM_BD71828 || MFD_ROHM_BD70528 && (BD70528_WATCHDOG || !BD70528_WATCHDOG)
>  	help
>  	  If you say Y here you will get support for the RTC
> -	  block on ROHM BD70528 and BD71828 Power Management IC.
> +	  block on ROHM BD70528, BD71815 and BD71828 Power Management IC.
>  
>  	  This driver can also be built as a module. If so, the module
>  	  will be called rtc-bd70528.
> diff --git a/drivers/rtc/rtc-bd70528.c b/drivers/rtc/rtc-bd70528.c
> index fb4476bb5ab6..6454afca02a6 100644
> --- a/drivers/rtc/rtc-bd70528.c
> +++ b/drivers/rtc/rtc-bd70528.c
> @@ -6,6 +6,7 @@
>  
>  #include <linux/bcd.h>
>  #include <linux/mfd/rohm-bd70528.h>
> +#include <linux/mfd/rohm-bd71815.h>
>  #include <linux/mfd/rohm-bd71828.h>
>  #include <linux/module.h>
>  #include <linux/of.h>
> @@ -13,6 +14,12 @@
>  #include <linux/regmap.h>
>  #include <linux/rtc.h>
>  
> +/*
> + * On BD71828 and BD71815 the ALM0 MASK is 14 bytes after the ALM0
> + * block start
> + */
> +#define BD718XX_ALM_EN_OFFSET 14
> +
>  /*
>   * We read regs RTC_SEC => RTC_YEAR
>   * this struct is ordered according to chip registers.
> @@ -55,6 +62,7 @@ struct bd70528_rtc {
>  	struct regmap *regmap;
>  	struct device *dev;
>  	u8 reg_time_start;
> +	u8 bd718xx_alm_block_start;
>  	bool has_rtc_timers;
>  };
>  
> @@ -236,8 +244,8 @@ static int bd71828_set_alarm(struct device *dev, struct rtc_wkalrm *a)
>  	struct bd71828_rtc_alm alm;
>  	struct bd70528_rtc *r = dev_get_drvdata(dev);
>  
> -	ret = regmap_bulk_read(r->regmap, BD71828_REG_RTC_ALM_START,
> -			       &alm, sizeof(alm));
> +	ret = regmap_bulk_read(r->regmap, r->bd718xx_alm_block_start, &alm,
> +			       sizeof(alm));
>  	if (ret) {
>  		dev_err(dev, "Failed to read alarm regs\n");
>  		return ret;
> @@ -250,8 +258,8 @@ static int bd71828_set_alarm(struct device *dev, struct rtc_wkalrm *a)
>  	else
>  		alm.alm_mask |= BD70528_MASK_ALM_EN;
>  
> -	ret = regmap_bulk_write(r->regmap, BD71828_REG_RTC_ALM_START,
> -				&alm, sizeof(alm));
> +	ret = regmap_bulk_write(r->regmap, r->bd718xx_alm_block_start, &alm,
> +				sizeof(alm));
>  	if (ret)
>  		dev_err(dev, "Failed to set alarm time\n");
>  
> @@ -311,8 +319,8 @@ static int bd71828_read_alarm(struct device *dev, struct rtc_wkalrm *a)
>  	struct bd71828_rtc_alm alm;
>  	struct bd70528_rtc *r = dev_get_drvdata(dev);
>  
> -	ret = regmap_bulk_read(r->regmap, BD71828_REG_RTC_ALM_START,
> -			       &alm, sizeof(alm));
> +	ret = regmap_bulk_read(r->regmap, r->bd718xx_alm_block_start, &alm,
> +			       sizeof(alm));
>  	if (ret) {
>  		dev_err(dev, "Failed to read alarm regs\n");
>  		return ret;
> @@ -453,8 +461,9 @@ static int bd71828_alm_enable(struct device *dev, unsigned int enabled)
>  	if (!enabled)
>  		enableval = 0;
>  
> -	ret = regmap_update_bits(r->regmap, BD71828_REG_RTC_ALM0_MASK,
> -				 BD70528_MASK_ALM_EN, enableval);
> +	ret = regmap_update_bits(r->regmap, r->bd718xx_alm_block_start +
> +				 BD718XX_ALM_EN_OFFSET, BD70528_MASK_ALM_EN,
> +				 enableval);
>  	if (ret)
>  		dev_err(dev, "Failed to change alarm state\n");
>  
> @@ -524,9 +533,28 @@ static int bd70528_probe(struct platform_device *pdev)
>  		enable_main_irq = true;
>  		rtc_ops = &bd70528_rtc_ops;
>  		break;
> +	case ROHM_CHIP_TYPE_BD71815:
> +		irq_name = "bd71815-rtc-alm-0";
> +		bd_rtc->reg_time_start = BD71815_REG_RTC_START;
> +
> +		/*
> +		 * See also BD718XX_ALM_EN_OFFSET:
> +		 * This works for BD71828 and BD71815 as they have same offset
> +		 * between ALM0 start and ALM0_MASK. If new ICs are to be
> +		 * added this requires proper check as ALM0_MASK is not located
> +		 * at the end of ALM0 block - but after all ALM blocks so if
> +		 * amount of ALMs differ the offset to enable/disable is likely
> +		 * to be incorrect and enable/disable must be given as own
> +		 * reg address here.
> +		 */
> +		bd_rtc->bd718xx_alm_block_start = BD71815_REG_RTC_ALM_START;
> +		hour_reg = BD71815_REG_HOUR;
> +		rtc_ops = &bd71828_rtc_ops;
> +		break;
>  	case ROHM_CHIP_TYPE_BD71828:
>  		irq_name = "bd71828-rtc-alm-0";
>  		bd_rtc->reg_time_start = BD71828_REG_RTC_START;
> +		bd_rtc->bd718xx_alm_block_start = BD71828_REG_RTC_ALM_START;
>  		hour_reg = BD71828_REG_RTC_HOUR;
>  		rtc_ops = &bd71828_rtc_ops;
>  		break;
> @@ -605,6 +633,7 @@ static int bd70528_probe(struct platform_device *pdev)
>  static const struct platform_device_id bd718x7_rtc_id[] = {
>  	{ "bd70528-rtc", ROHM_CHIP_TYPE_BD70528 },
>  	{ "bd71828-rtc", ROHM_CHIP_TYPE_BD71828 },
> +	{ "bd71815-rtc", ROHM_CHIP_TYPE_BD71815 },
>  	{ },
>  };
>  MODULE_DEVICE_TABLE(platform, bd718x7_rtc_id);
> -- 
> 2.25.4
> 
> 
> -- 
> Matti Vaittinen, Linux device drivers
> ROHM Semiconductors, Finland SWDC
> Kiviharjunlenkki 1E
> 90220 OULU
> FINLAND
> 
> ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
> Simon says - in Latin please.
> ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
> Thanks to Simon Glass for the translation =] 

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

  reply	other threads:[~2021-01-19 21:11 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-19  7:13 [PATCH v2 00/17] Support ROHM BD71815 PMIC Matti Vaittinen
2021-01-19  7:14 ` [PATCH v2 01/17] regulator: bd718x7, bd71828, Fix dvs voltage levels Matti Vaittinen
2021-01-19  7:14 ` [PATCH v2 02/17] rtc: bd70528: Do not require parent data Matti Vaittinen
2021-01-19 21:09   ` Alexandre Belloni
2021-01-20  6:37     ` Matti Vaittinen
2021-01-19  7:15 ` [PATCH v2 03/17] clk: BD718x7: Do not depend on parent driver data Matti Vaittinen
2021-01-19  7:15 ` [PATCH v2 04/17] mfd: bd718x7: simplify by cleaning unnecessary device data Matti Vaittinen
2021-01-25 13:56   ` Lee Jones
2021-01-19  7:16 ` [PATCH v2 05/17] dt_bindings: bd71828: Add clock output mode Matti Vaittinen
2021-02-09  2:22   ` Rob Herring
2021-01-19  7:17 ` [PATCH v2 06/17] dt_bindings: regulator: Add ROHM BD71815 PMIC regulators Matti Vaittinen
2021-02-09  2:24   ` Rob Herring
2021-02-09 13:10     ` Vaittinen, Matti
2021-02-09 13:50       ` Rob Herring
2021-01-19  7:21 ` [PATCH v2 07/17] dt_bindings: mfd: Add ROHM BD71815 PMIC Matti Vaittinen
2021-02-09  2:26   ` Rob Herring
2021-01-19  7:21 ` [PATCH v2 08/17] mfd: Add ROHM BD71815 ID Matti Vaittinen
2021-01-25 13:57   ` Lee Jones
2021-01-19  7:22 ` [PATCH v2 09/17] mfd: Support for ROHM BD71815 PMIC core Matti Vaittinen
2021-01-25 14:10   ` Lee Jones
2021-01-25 14:48     ` Matti Vaittinen
2021-01-26  8:29       ` Lee Jones
2021-01-19  7:23 ` [PATCH v2 10/17] gpio: support ROHM BD71815 GPOs Matti Vaittinen
2021-01-19 11:07   ` Bartosz Golaszewski
2021-01-19 13:01     ` Vaittinen, Matti
2021-03-23  9:57     ` Vaittinen, Matti
2021-03-26 14:44       ` Bartosz Golaszewski
2021-01-19  7:25 ` [PATCH v2 11/17] regulator: helpers: Export helper voltage listing Matti Vaittinen
2021-01-19  7:26 ` [PATCH v2 12/17] regulator: rohm-regulator: linear voltage support Matti Vaittinen
2021-01-19  7:27 ` [PATCH v2 13/17] regulator: rohm-regulator: Support SNVS HW state Matti Vaittinen
2021-01-19  7:29 ` [PATCH v2 14/17] regulator: Support ROHM BD71815 regulators Matti Vaittinen
2021-01-19  7:30 ` [PATCH v2 15/17] clk: bd718x7: Add support for clk gate on ROHM BD71815 PMIC Matti Vaittinen
2021-02-12  3:40   ` Stephen Boyd
2021-01-19  7:31 ` [PATCH v2 16/17] rtc: bd70528: Support RTC on ROHM BD71815 Matti Vaittinen
2021-01-19 21:10   ` Alexandre Belloni [this message]
2021-01-19  7:34 ` [PATCH v2 17/17] MAINTAINERS: Add ROHM BD71815AGW Matti Vaittinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210119211041.GS3666@piout.net \
    --to=alexandre.belloni@bootlin.com \
    --cc=a.zummo@towertech.it \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-power@fi.rohmeurope.com \
    --cc=linux-rtc@vger.kernel.org \
    --cc=matti.vaittinen@fi.rohmeurope.com \
    --cc=mazziesaccount@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.