linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <k.kozlowski@samsung.com>
To: Javier Martinez Canillas <javier@osg.samsung.com>,
	linux-kernel@vger.kernel.org
Cc: Kukjin Kim <kgene@kernel.org>,
	rtc-linux@googlegroups.com, Chanwoo Choi <cw00.choi@samsung.com>,
	Alexandre Belloni <alexandre.belloni@free-electrons.com>,
	Laxman Dewangan <ldewangan@nvidia.com>,
	linux-samsung-soc@vger.kernel.org
Subject: Re: [PATCH 4/8] rtc: max77686: Add an indirection level to access RTC registers
Date: Thu, 21 Jan 2016 10:05:51 +0900	[thread overview]
Message-ID: <56A02EEF.2060604@samsung.com> (raw)
In-Reply-To: <1453310088-29985-5-git-send-email-javier@osg.samsung.com>

On 21.01.2016 02:14, Javier Martinez Canillas wrote:
> The max77686 driver is generic enough that can be used for other
> Maxim RTC IP blocks but these might not have the same registers
> layout so instead of accessing the registers directly, add a map
> to translate offsets to the real registers addresses for each IP.
> 
> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
> ---
> 
>  drivers/rtc/rtc-max77686.c | 75 +++++++++++++++++++++++++++++++++++++++-------
>  1 file changed, 65 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-max77686.c b/drivers/rtc/rtc-max77686.c
> index 441d163dcbeb..7316e41820c7 100644
> --- a/drivers/rtc/rtc-max77686.c
> +++ b/drivers/rtc/rtc-max77686.c
> @@ -41,6 +41,8 @@
>  #define ALARM_ENABLE_SHIFT		7
>  #define ALARM_ENABLE_MASK		(1 << ALARM_ENABLE_SHIFT)
>  
> +#define REG_RTC_NONE			0xdeadbeef
> +
>  enum {
>  	RTC_SEC = 0,
>  	RTC_MIN,
> @@ -55,6 +57,7 @@ enum {
>  struct rtc_driver_data {
>  	unsigned long		delay;
>  	int			mask;
> +	const unsigned int	*map;
>  };
>  
>  struct max77686_rtc_info {
> @@ -77,9 +80,53 @@ enum MAX77686_RTC_OP {
>  	MAX77686_RTC_READ,
>  };
>  
> +/* These are not registers but just offsets that are mapped to addresses */
> +enum rtc_reg {

enum max77686_rtc_reg_offset?

> +	REG_RTC_CONTROLM = 0,
> +	REG_RTC_CONTROL,
> +	REG_RTC_UPDATE0,
> +	REG_RTC_UPDATE1,
> +	REG_WTSR_SMPL_CNTL,
> +	REG_RTC_SEC,
> +	REG_RTC_MIN,
> +	REG_RTC_HOUR,
> +	REG_RTC_WEEKDAY,
> +	REG_RTC_MONTH,
> +	REG_RTC_YEAR,
> +	REG_RTC_DATE,
> +	REG_ALARM1_SEC,
> +	REG_ALARM1_MIN,
> +	REG_ALARM1_HOUR,
> +	REG_ALARM1_WEEKDAY,
> +	REG_ALARM1_MONTH,
> +	REG_ALARM1_YEAR,
> +	REG_ALARM1_DATE,
> +	REG_ALARM2_SEC,
> +	REG_ALARM2_MIN,
> +	REG_ALARM2_HOUR,
> +	REG_ALARM2_WEEKDAY,
> +	REG_ALARM2_MONTH,
> +	REG_ALARM2_YEAR,
> +	REG_ALARM2_DATE,
> +	REG_RTC_END,
> +};
> +

A short comment what is mapped into what would be appreciated.

> +static const unsigned int max77686_map[REG_RTC_END] = {
> +	MAX77686_RTC_CONTROLM, MAX77686_RTC_CONTROL, MAX77686_RTC_UPDATE0,
> +	REG_RTC_NONE, MAX77686_WTSR_SMPL_CNTL, MAX77686_RTC_SEC,
> +	MAX77686_RTC_MIN, MAX77686_RTC_HOUR, MAX77686_RTC_WEEKDAY,
> +	MAX77686_RTC_MONTH, MAX77686_RTC_YEAR, MAX77686_RTC_DATE,
> +	MAX77686_ALARM1_SEC, MAX77686_ALARM1_MIN, MAX77686_ALARM1_HOUR,
> +	MAX77686_ALARM1_WEEKDAY, MAX77686_ALARM1_MONTH, MAX77686_ALARM1_YEAR,
> +	MAX77686_ALARM1_DATE, MAX77686_ALARM2_SEC, MAX77686_ALARM2_MIN,
> +	MAX77686_ALARM2_HOUR, MAX77686_ALARM2_WEEKDAY, MAX77686_ALARM2_MONTH,
> +	MAX77686_ALARM2_YEAR, MAX77686_ALARM2_DATE,
> +};

It is difficult to check for mistakes here. I would prefer direct mapping:
	[REG_RTC_CONTROLM] = MAX77686_RTC_CONTROLM,
	....


Rest looks good but I did not check the correctness of mapping above.

BR,
Krzysztof

  reply	other threads:[~2016-01-21  1:05 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-20 17:14 [PATCH 0/8] rtc: max77686: Extend driver and add max77802 support Javier Martinez Canillas
2016-01-20 17:14 ` [PATCH 1/8] rtc: max77686: Use ARRAY_SIZE() instead of current array length Javier Martinez Canillas
2016-01-21  0:35   ` Krzysztof Kozlowski
2016-01-20 17:14 ` [PATCH 2/8] rtc: max77686: Use usleep_range() instead of msleep() Javier Martinez Canillas
2016-01-21  0:37   ` Krzysztof Kozlowski
2016-01-21 14:52     ` Javier Martinez Canillas
2016-01-20 17:14 ` [PATCH 3/8] rtc: max77686: Use a driver data struct instead hard-coded values Javier Martinez Canillas
2016-01-21  0:45   ` Krzysztof Kozlowski
2016-01-21 14:55     ` Javier Martinez Canillas
2016-01-20 17:14 ` [PATCH 4/8] rtc: max77686: Add an indirection level to access RTC registers Javier Martinez Canillas
2016-01-21  1:05   ` Krzysztof Kozlowski [this message]
2016-01-21 14:57     ` Javier Martinez Canillas
2016-01-20 17:14 ` [PATCH 5/8] rtc: max77686: Add max77802 support Javier Martinez Canillas
2016-01-21  1:56   ` Krzysztof Kozlowski
2016-01-21 15:12     ` Javier Martinez Canillas
2016-01-20 17:14 ` [PATCH 6/8] rtc: Remove Maxim 77802 driver Javier Martinez Canillas
2016-01-21  1:57   ` Krzysztof Kozlowski
2016-01-21 15:12     ` Javier Martinez Canillas
2016-01-20 17:14 ` [PATCH 7/8] ARM: exynos_defconfig: Remove MAX77802 RTC Kconfig symbol Javier Martinez Canillas
2016-01-21  1:58   ` Krzysztof Kozlowski
2016-01-21 15:14     ` Javier Martinez Canillas
2016-01-20 17:14 ` [PATCH 8/8] ARM: multi_v7_defconfig: " Javier Martinez Canillas
2016-01-21  1:58   ` Krzysztof Kozlowski
2016-01-21  0:30 ` [PATCH 0/8] rtc: max77686: Extend driver and add max77802 support Alexandre Belloni
2016-01-21  0:34   ` Krzysztof Kozlowski
2016-01-21 14:50     ` Javier Martinez Canillas
2016-01-21  0:48 ` Krzysztof Kozlowski
2016-01-21 15:15   ` Javier Martinez Canillas

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=56A02EEF.2060604@samsung.com \
    --to=k.kozlowski@samsung.com \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=cw00.choi@samsung.com \
    --cc=javier@osg.samsung.com \
    --cc=kgene@kernel.org \
    --cc=ldewangan@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=rtc-linux@googlegroups.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).