mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alessandro Zummo <alessandro.zummo@towertech.it>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.arm.linux.org.uk,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Paul Gortmaker <p_gortmaker@yahoo.com>,
	rtc-linux@googlegroups.com
Subject: Re: [PATCH 4/5] [RTC] Add Freescale MC13783 RTC driver
Date: Wed, 12 Aug 2009 11:41:34 +0200	[thread overview]
Message-ID: <20090812114134.421303c4@i1501.lan.towertech.it> (raw)
In-Reply-To: <1249981166-4210-4-git-send-email-s.hauer@pengutronix.de>

On Tue, 11 Aug 2009 10:59:25 +0200
Sascha Hauer <s.hauer@pengutronix.de> wrote:

> This driver provides support for the RTC part integrated into
> the Freescale MC13783 PMIC.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: Paul Gortmaker <p_gortmaker@yahoo.com>
> Cc: Alessandro Zummo <a.zummo@towertech.it>
> Cc: rtc-linux@googlegroups.com


 thanks for your submission, comments below

> ---
>  drivers/rtc/Kconfig       |    6 ++
>  drivers/rtc/Makefile      |    1 +
>  drivers/rtc/rtc-mc13783.c |  141 +++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 148 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/rtc/rtc-mc13783.c
> 
> diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
> index 81adbdb..e4a242f 100644
> --- a/drivers/rtc/Kconfig
> +++ b/drivers/rtc/Kconfig
> @@ -759,4 +759,10 @@ config RTC_DRV_PS3
>  	  This driver can also be built as a module. If so, the module
>  	  will be called rtc-ps3.
>  
> +config RTC_DRV_MC13783
> +	depends on MFD_MC13783
> +	tristate "Freescale MC13783 RTC"
> +	help
> +	  This enables support for the Freescale MC13783 PMIC RTC
> +
>  endif # RTC_CLASS
> diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
> index 3c0f2b2..00bf66d 100644
> --- a/drivers/rtc/Makefile
> +++ b/drivers/rtc/Makefile
> @@ -78,3 +78,4 @@ obj-$(CONFIG_RTC_DRV_WM8350)	+= rtc-wm8350.o
>  obj-$(CONFIG_RTC_DRV_X1205)	+= rtc-x1205.o
>  obj-$(CONFIG_RTC_DRV_PCF50633)	+= rtc-pcf50633.o
>  obj-$(CONFIG_RTC_DRV_PS3)	+= rtc-ps3.o
> +obj-$(CONFIG_RTC_DRV_MC13783)	+= rtc-mc13783.o

 keep in in alphabetic order.

> diff --git a/drivers/rtc/rtc-mc13783.c b/drivers/rtc/rtc-mc13783.c
> new file mode 100644
> index 0000000..d1f1192
> --- /dev/null
> +++ b/drivers/rtc/rtc-mc13783.c
> @@ -0,0 +1,141 @@
> +/*
> + * Real Time Clock driver for Freescale MC13783 PMIC
> + *
> + * (C) 2009 Sascha Hauer, Pengutronix
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> + */
> +
> +#include <linux/mfd/mc13783-private.h>
> +#include <linux/platform_device.h>
> +#include <linux/interrupt.h>
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/ioctl.h>
> +#include <linux/time.h>
> +#include <linux/rtc.h>

 too many includes?

> +
> +struct mc13783_rtc {
> +	struct rtc_device *rtc;
> +	struct mc13783 *mc13783;
> +};
> +
> +static int mc13783_rtc_set_time(struct device *dev, struct rtc_time *tm)

 please implement set_mmss instad of set_time

> +	struct mc13783_rtc *priv = dev_get_drvdata(dev);
> +	unsigned int seconds, days;
> +	unsigned long s1970;
> +
> +	rtc_tm_to_time(tm, &s1970);
> +
> +	seconds = s1970 % 86400;
> +	days = s1970 / 86400;
> +
> +	mc13783_reg_write(priv->mc13783, MC13783_REG_RTC_TIME, seconds);
> +	mc13783_reg_write(priv->mc13783, MC13783_REG_RTC_DAY, days);
> +
> +	return 0;
> +}
> +
> +static int mc13783_rtc_read_time(struct device *dev, struct rtc_time *tm)
> +{
> +	struct mc13783_rtc *priv = dev_get_drvdata(dev);
> +	unsigned int seconds, days1, days2;
> +	unsigned long s1970;
> +
> +	rtc_tm_to_time(tm, &s1970);
> +
> +	do {
> +		mc13783_reg_read(priv->mc13783, MC13783_REG_RTC_TIME, &seconds);
> +		mc13783_reg_read(priv->mc13783, MC13783_REG_RTC_DAY, &days1);
> +		mc13783_reg_read(priv->mc13783, MC13783_REG_RTC_DAY, &days2);
> +	} while (days1 != days2);
> +
> +	s1970 = days1 * 86400 + seconds;
> +
> +	rtc_time_to_tm(s1970, tm);
> +
> +	return 0;

 use rtc_valid_tm

> +}
> +
> +static const struct rtc_class_ops mc13783_rtc_ops = {
> +	.read_time	= mc13783_rtc_read_time,
> +	.set_time	= mc13783_rtc_set_time,
> +};
> +
> +static int mc13783_rtc_probe(struct platform_device *pdev)
> +{
> +	int err;
> +	struct mc13783_rtc *priv;
> +
> +	priv = kzalloc(sizeof *priv, GFP_KERNEL);
> +	if (!priv)
> +		return -ENOMEM;
> +
> +	priv->mc13783 = pdev->dev.platform_data;
> +	platform_set_drvdata(pdev, priv);
> +
> +	priv->rtc = rtc_device_register(pdev->name,
> +			&pdev->dev, &mc13783_rtc_ops, THIS_MODULE);
> +
> +	if (IS_ERR(priv->rtc)) {
> +		err = PTR_ERR(priv->rtc);
> +		goto exit_kfree;
> +	}
> +
> +	return 0;
> +
> +exit_kfree:
> +	kfree(priv);
> +	return err;
> +}
> +
> +static int __exit mc13783_rtc_remove(struct platform_device *pdev)
> +{
> +	struct mc13783_rtc *priv = platform_get_drvdata(pdev);
> +
> +	rtc_device_unregister(priv->rtc);
> +	platform_set_drvdata(pdev, NULL);
> +
> +	kfree(priv);
> +
> +	return 0;
> +}
> +
> +static struct platform_driver mc13783_rtc_driver = {
> +	.probe		 = mc13783_rtc_probe,
> +	.remove		= __exit_p(mc13783_rtc_remove),
> +	.driver = {
> +		.name	= "mc13783-rtc",
> +		.owner	= THIS_MODULE,
> +	},
> +};
> +
> +static int __init mc13783_rtc_init(void)
> +{
> +	return platform_driver_register(&mc13783_rtc_driver);

 can you use platform_driver_probe?

> +}
> +module_init(mc13783_rtc_init);
> +
> +static void __exit mc13783_rtc_exit(void)
> +{
> +	platform_driver_unregister(&mc13783_rtc_driver);
> +}
> +module_exit(mc13783_rtc_exit);
> +
> +
> +MODULE_AUTHOR("Sascha Hauer");

 email here please.

> +MODULE_DESCRIPTION("RTC driver for Freescale MC13783 PMIC");
> +MODULE_LICENSE("GPL");
> -- 
> 1.6.3.3
> 


-- 

 Best regards,

 Alessandro Zummo,
  Tower Technologies - Torino, Italy

  http://www.towertech.it


  parent reply	other threads:[~2009-08-12  9:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1249981166-4210-1-git-send-email-s.hauer@pengutronix.de>
2009-08-11  8:59 ` [PATCH 2/5] [input] add mc13783 touchscreen driver Sascha Hauer
2009-08-11  8:59   ` [PATCH 3/5] [hwmon] add Freescale MC13783 adc driver Sascha Hauer
2009-08-11  8:59     ` [PATCH 4/5] [RTC] Add Freescale MC13783 RTC driver Sascha Hauer
2009-08-11  8:59       ` [PATCH 5/5] [regulator] Add a Freescale MC13783 regulator driver Sascha Hauer
2009-08-12  9:41       ` Alessandro Zummo [this message]
2009-08-12 11:39         ` [PATCH 4/5] [RTC] Add Freescale MC13783 RTC driver Sascha Hauer
2009-08-11  9:07 [RFC] Freescale MC13783 PMIC support Sascha Hauer
2009-08-11  9:07 ` [PATCH 1/5] drivers/mfd: Add Freescale MC13783 driver Sascha Hauer
2009-08-11  9:07   ` [PATCH 2/5] [input] add mc13783 touchscreen driver Sascha Hauer
2009-08-11  9:07     ` [PATCH 3/5] [hwmon] add Freescale MC13783 adc driver Sascha Hauer
2009-08-11  9:07       ` [PATCH 4/5] [RTC] Add Freescale MC13783 RTC driver Sascha Hauer
2009-08-12 15:05 [PATCH V2] Freescale MC13783 PMIC support Sascha Hauer
2009-08-12 15:05 ` [PATCH 1/5] drivers/mfd: Add Freescale MC13783 driver Sascha Hauer
2009-08-12 15:05   ` [PATCH 2/5] [input] add mc13783 touchscreen driver Sascha Hauer
2009-08-12 15:05     ` [PATCH 3/5] [hwmon] add Freescale MC13783 adc driver Sascha Hauer
2009-08-12 15:05       ` [PATCH 4/5] [RTC] Add Freescale MC13783 RTC driver Sascha Hauer

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=20090812114134.421303c4@i1501.lan.towertech.it \
    --to=alessandro.zummo@towertech.it \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=p_gortmaker@yahoo.com \
    --cc=rtc-linux@googlegroups.com \
    --cc=s.hauer@pengutronix.de \
    /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

all inboxes | Powered by JetHome®