mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Will Newton" <will.newton@gmail.com>
To: "Steven A. Falco" <sfalco@harris.com>
Cc: linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com
Subject: Re: [RFC] Driver for Real Time Clock chip ST M41T65
Date: Tue, 26 Aug 2008 15:00:03 +0100	[thread overview]
Message-ID: <87a5b0800808260700g52cedf59kb07880ae05a104b@mail.gmail.com> (raw)
In-Reply-To: <48B40B68.1040607@harris.com>

On Tue, Aug 26, 2008 at 2:55 PM, Steven A. Falco <sfalco@harris.com> wrote:
> Will Newton wrote:
>> On Mon, Aug 25, 2008 at 6:27 PM, Steven A. Falco <sfalco@harris.com> wrote:
>>> I will be using a Real Time Clock chip, ST M41T65, on a new embedded system.
>>> The chip is quite similar to the M41T8x family, which already has driver
>>> rtc-m41t80.c.
>>>
>>> Would it be more acceptible to generalize rtc-m41t80.c (perhaps renaming it to
>>> rtc-m41txx.c) or would it be better to create a new rtc-m41t6x.c?
>
> Thanks for the feedback.  Here is a respin which addresses your comments.
>
> I'd also like to know if I should submit a new driver or mod the existing
> one.  If I mod the existing one, should it be renamed, should I update the
> Kconfig, existing defconfigs, etc?

I've ccd the rtc-linux list.

> Signed-off-by: Steven A. Falco <sfalco@harris.com>
>
> diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
> index a3e0880..7eb4e05 100644
> --- a/drivers/rtc/rtc-m41t80.c
> +++ b/drivers/rtc/rtc-m41t80.c
> @@ -55,21 +55,27 @@
>  #define M41T80_ALHOUR_HT       (1 << 6)        /* HT: Halt Update Bit */
>  #define M41T80_FLAGS_AF                (1 << 6)        /* AF: Alarm Flag Bit */
>  #define M41T80_FLAGS_BATT_LOW  (1 << 4)        /* BL: Battery Low Bit */
> +#define M41T80_WATCHDOG_RB2    (1 << 7)        /* RB: Watchdog resolution */
> +#define M41T80_WATCHDOG_RB1    (1 << 1)        /* RB: Watchdog resolution */
> +#define M41T80_WATCHDOG_RB0    (1 << 0)        /* RB: Watchdog resolution */
>
> -#define M41T80_FEATURE_HT      (1 << 0)
> -#define M41T80_FEATURE_BL      (1 << 1)
> +#define M41T80_FEATURE_HT      (1 << 0)        /* Halt feature */
> +#define M41T80_FEATURE_BL      (1 << 1)        /* Battery low indicator */
> +#define M41T80_FEATURE_SQ      (1 << 2)        /* Squarewave feature */
> +#define M41T80_FEATURE_WD      (1 << 3)        /* Extra watchdog resolution */
>
>  #define DRV_VERSION "0.05"
>
>  static const struct i2c_device_id m41t80_id[] = {
> -       { "m41t80", 0 },
> -       { "m41t81", M41T80_FEATURE_HT },
> -       { "m41t81s", M41T80_FEATURE_HT | M41T80_FEATURE_BL },
> -       { "m41t82", M41T80_FEATURE_HT | M41T80_FEATURE_BL },
> -       { "m41t83", M41T80_FEATURE_HT | M41T80_FEATURE_BL },
> -       { "m41st84", M41T80_FEATURE_HT | M41T80_FEATURE_BL },
> -       { "m41st85", M41T80_FEATURE_HT | M41T80_FEATURE_BL },
> -       { "m41st87", M41T80_FEATURE_HT | M41T80_FEATURE_BL },
> +       { "m41t65", M41T80_FEATURE_HT | M41T80_FEATURE_WD },
> +       { "m41t80", M41T80_FEATURE_SQ },
> +       { "m41t81", M41T80_FEATURE_HT | M41T80_FEATURE_SQ},
> +       { "m41t81s", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
> +       { "m41t82", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
> +       { "m41t83", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
> +       { "m41st84", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
> +       { "m41st85", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
> +       { "m41st87", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
>        { }
>  };
>  MODULE_DEVICE_TABLE(i2c, m41t80_id);
> @@ -385,8 +391,12 @@ static ssize_t m41t80_sysfs_show_sqwfreq(struct device *dev,
>                                struct device_attribute *attr, char *buf)
>  {
>        struct i2c_client *client = to_i2c_client(dev);
> +       struct m41t80_data *clientdata = i2c_get_clientdata(client);
>        int val;
>
> +       if (!(clientdata->features & M41T80_FEATURE_SQ))
> +               return -EINVAL;
> +
>        val = i2c_smbus_read_byte_data(client, M41T80_REG_SQW);
>        if (val < 0)
>                return -EIO;
> @@ -407,9 +417,13 @@ static ssize_t m41t80_sysfs_set_sqwfreq(struct device *dev,
>                                const char *buf, size_t count)
>  {
>        struct i2c_client *client = to_i2c_client(dev);
> +       struct m41t80_data *clientdata = i2c_get_clientdata(client);
>        int almon, sqw;
>        int val = simple_strtoul(buf, NULL, 0);
>
> +       if (!(clientdata->features & M41T80_FEATURE_SQ))
> +               return -EINVAL;
> +
>        if (val) {
>                if (!is_power_of_2(val))
>                        return -EINVAL;
> @@ -498,6 +512,8 @@ static void wdt_ping(void)
>                        .buf    = i2c_data,
>                },
>        };
> +       struct m41t80_data *clientdata = i2c_get_clientdata(save_client);
> +
>        i2c_data[0] = 0x09;             /* watchdog register */
>
>        if (wdt_margin > 31)
> @@ -508,6 +524,13 @@ static void wdt_ping(void)
>                 */
>                i2c_data[1] = wdt_margin<<2 | 0x82;
>
> +       /*
> +        * M41T65 has three bits for watchdog resolution.  Don't set bit 7, as
> +        * that would be an invalid resolution.
> +        */
> +       if (clientdata->features & M41T80_FEATURE_WD)
> +               i2c_data[1] &= ~M41T80_WATCHDOG_RB2;
> +
>        i2c_transfer(save_client->adapter, msgs1, 1);
>  }
>
>

  reply	other threads:[~2008-08-26 14:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-25 17:27 Steven A. Falco
2008-08-26  8:30 ` Will Newton
2008-08-26 13:55   ` Steven A. Falco
2008-08-26 14:00     ` Will Newton [this message]
2008-08-26 14:13       ` [rtc-linux] " Alessandro Zummo
2008-08-26 14:39         ` Steven A. Falco
2008-08-27 12:35           ` Atsushi Nemoto
2008-08-27 13:32             ` Steven A. Falco
2008-08-27 13:53               ` Atsushi Nemoto
2008-08-27 16:25                 ` Maciej W. Rozycki
2008-08-27 17:22                   ` Steven A. Falco
2008-08-27 19:27                     ` Maciej W. Rozycki
2008-08-27 19:44                     ` Alessandro Zummo
2008-08-26 14:42     ` Maciej W. Rozycki

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=87a5b0800808260700g52cedf59kb07880ae05a104b@mail.gmail.com \
    --to=will.newton@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rtc-linux@googlegroups.com \
    --cc=sfalco@harris.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

all inboxes | Powered by JetHome®