All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] rtc: ds3232/ds3231: Add support to generate 32KHz output for driver module
@ 2019-07-22  7:56 Chuanhua Han
  2019-07-22 14:00 ` Wolfgang Denk
  0 siblings, 1 reply; 2+ messages in thread
From: Chuanhua Han @ 2019-07-22  7:56 UTC (permalink / raw)
  To: u-boot

This patch add an implementation of the rtc_enable_32khz_output() that
uses the driver model i2c APIs.

Signed-off-by: Chuanhua Han <chuanhua.han@nxp.com>
---
 drivers/rtc/ds3231.c | 17 +++++++++++++++++
 include/rtc.h        |  1 +
 2 files changed, 18 insertions(+)

diff --git a/drivers/rtc/ds3231.c b/drivers/rtc/ds3231.c
index 79b026a..2f7bbc2 100644
--- a/drivers/rtc/ds3231.c
+++ b/drivers/rtc/ds3231.c
@@ -251,6 +251,23 @@ static int ds3231_probe(struct udevice *dev)
 	return 0;
 }
 
+void rtc_enable_32khz_output(void)
+{
+	int ret;
+	struct udevice *dev;
+
+#ifdef CONFIG_DS3231_BUS_NUM
+	ret = i2c_get_chip_for_busnum(CONFIG_DS3231_BUS_NUM,
+				      CONFIG_SYS_I2C_RTC_ADDR, 1, &dev);
+#else
+	ret = i2c_get_chip_for_busnum(0, CONFIG_SYS_I2C_RTC_ADDR, 1, &dev);
+#endif
+	if (!ret)
+		dm_i2c_reg_write(dev, RTC_STAT_REG_ADDR,
+				 RTC_STAT_BIT_BB32KHZ |
+				 RTC_STAT_BIT_EN32KHZ);
+}
+
 static const struct rtc_ops ds3231_rtc_ops = {
 	.get = ds3231_rtc_get,
 	.set = ds3231_rtc_set,
diff --git a/include/rtc.h b/include/rtc.h
index b255bdc..690391e 100644
--- a/include/rtc.h
+++ b/include/rtc.h
@@ -166,6 +166,7 @@ int rtc_read32(struct udevice *dev, unsigned int reg, u32 *valuep);
  */
 int rtc_write32(struct udevice *dev, unsigned int reg, u32 value);
 
+void rtc_enable_32khz_output(void);
 #else
 int rtc_get (struct rtc_time *);
 int rtc_set (struct rtc_time *);
-- 
2.9.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH] rtc: ds3232/ds3231: Add support to generate 32KHz output for driver module
  2019-07-22  7:56 [U-Boot] [PATCH] rtc: ds3232/ds3231: Add support to generate 32KHz output for driver module Chuanhua Han
@ 2019-07-22 14:00 ` Wolfgang Denk
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Denk @ 2019-07-22 14:00 UTC (permalink / raw)
  To: u-boot

Dear Chuanhua Han,

In message <20190722075642.1456-1-chuanhua.han@nxp.com> you wrote:
> This patch add an implementation of the rtc_enable_32khz_output() that
> uses the driver model i2c APIs.
> 
> Signed-off-by: Chuanhua Han <chuanhua.han@nxp.com>
> ---
>  drivers/rtc/ds3231.c | 17 +++++++++++++++++
>  include/rtc.h        |  1 +
>  2 files changed, 18 insertions(+)
> 
> diff --git a/drivers/rtc/ds3231.c b/drivers/rtc/ds3231.c
> index 79b026a..2f7bbc2 100644
> --- a/drivers/rtc/ds3231.c
> +++ b/drivers/rtc/ds3231.c
> @@ -251,6 +251,23 @@ static int ds3231_probe(struct udevice *dev)
>  	return 0;
>  }
>  
> +void rtc_enable_32khz_output(void)
> +{
> +	int ret;
> +	struct udevice *dev;
> +
> +#ifdef CONFIG_DS3231_BUS_NUM
> +	ret = i2c_get_chip_for_busnum(CONFIG_DS3231_BUS_NUM,
> +				      CONFIG_SYS_I2C_RTC_ADDR, 1, &dev);
> +#else
> +	ret = i2c_get_chip_for_busnum(0, CONFIG_SYS_I2C_RTC_ADDR, 1, &dev);
> +#endif
> +	if (!ret)
> +		dm_i2c_reg_write(dev, RTC_STAT_REG_ADDR,
> +				 RTC_STAT_BIT_BB32KHZ |
> +				 RTC_STAT_BIT_EN32KHZ);
> +}
> +

You add this code unconditonally, so it increases code size for all
users.  But I guess only a tiny fraction will ever need this.

Please add some appropiate CONFIG_ option so this code compiles only
in that cases where it is really needed.

Thanks.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Above all else -- sky.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-07-22 14:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-22  7:56 [U-Boot] [PATCH] rtc: ds3232/ds3231: Add support to generate 32KHz output for driver module Chuanhua Han
2019-07-22 14:00 ` Wolfgang Denk

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.