linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "'Tin Huynh' via rtc-linux" <rtc-linux-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
To: Alessandro Zummo
	<a.zummo-BfzFCNDTiLLj+vYz1yj4TQ@public.gmane.org>,
	Alexandre Belloni
	<alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	rtc-linux-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org,
	Loc Ho <lho-qTEPVZfXA3Y@public.gmane.org>,
	Thang Nguyen <tqnguyen-qTEPVZfXA3Y@public.gmane.org>,
	Phong Vo <pvo-qTEPVZfXA3Y@public.gmane.org>,
	patches <patches-qTEPVZfXA3Y@public.gmane.org>,
	Tin Huynh <tnhuynh-qTEPVZfXA3Y@public.gmane.org>
Subject: Re: [PATCH V1] rtc: ds1307: Add ACPI support
Date: Mon, 5 Dec 2016 14:48:56 +0700	[thread overview]
Message-ID: <CANQ9TuAsLAJQxiW4cHkAJod3LaDsDsFB22Pk1+oQYDRSGooYWw@mail.gmail.com> (raw)
In-Reply-To: <1480474651-13984-1-git-send-email-tnhuynh-qTEPVZfXA3Y@public.gmane.org>

On Wed, Nov 30, 2016 at 9:57 AM, Tin Huynh <tnhuynh-qTEPVZfXA3Y@public.gmane.org> wrote:
>
> This patch enables ACPI support for rtc-ds1307 driver.
>
> Signed-off-by: Tin Huynh <tnhuynh-qTEPVZfXA3Y@public.gmane.org>
> ---
>  drivers/rtc/rtc-ds1307.c |   51 ++++++++++++++++++++++++++++++++++++++-------
>  1 files changed, 43 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
> index 4e31036..2a1a4d3 100644
> --- a/drivers/rtc/rtc-ds1307.c
> +++ b/drivers/rtc/rtc-ds1307.c
> @@ -11,6 +11,7 @@
>   * published by the Free Software Foundation.
>   */
>
> +#include <linux/acpi.h>
>  #include <linux/bcd.h>
>  #include <linux/i2c.h>
>  #include <linux/init.h>
> @@ -191,6 +192,26 @@ static u8 do_trickle_setup_ds1339(struct i2c_client *,
>  };
>  MODULE_DEVICE_TABLE(i2c, ds1307_id);
>
> +#ifdef CONFIG_ACPI
> +static const struct acpi_device_id ds1307_acpi_ids[] = {
> +       { .id = "DS1307", .driver_data = ds_1307 },
> +       { .id = "DS1337", .driver_data = ds_1337 },
> +       { .id = "DS1338", .driver_data = ds_1338 },
> +       { .id = "DS1339", .driver_data = ds_1339 },
> +       { .id = "DS1388", .driver_data = ds_1388 },
> +       { .id = "DS1340", .driver_data = ds_1340 },
> +       { .id = "DS3231", .driver_data = ds_3231 },
> +       { .id = "M41T00", .driver_data = m41t00 },
> +       { .id = "MCP7940X", .driver_data = mcp794xx },
> +       { .id = "MCP7941X", .driver_data = mcp794xx },
> +       { .id = "PT7C4338", .driver_data = ds_1307 },
> +       { .id = "RX8025", .driver_data = rx_8025 },
> +       { .id = "ISL12057", .driver_data = ds_1337 },
> +       { }
> +};
> +MODULE_DEVICE_TABLE(acpi, ds1307_acpi_ids);
> +#endif
> +
>  /*----------------------------------------------------------------------*/
>
>  #define BLOCK_DATA_MAX_TRIES 10
> @@ -874,7 +895,7 @@ static u8 do_trickle_setup_ds1339(struct i2c_client *client,
>         return setup;
>  }
>
> -static void ds1307_trickle_of_init(struct i2c_client *client,
> +static void ds1307_trickle_init(struct i2c_client *client,
>                                    struct chip_desc *chip)
>  {
>         uint32_t ohms = 0;
> @@ -882,9 +903,10 @@ static void ds1307_trickle_of_init(struct i2c_client *client,
>
>         if (!chip->do_trickle_setup)
>                 goto out;
> -       if (of_property_read_u32(client->dev.of_node, "trickle-resistor-ohms" , &ohms))
> +       if (device_property_read_u32(&client->dev, "trickle-resistor-ohms",
> +                                       &ohms))
>                 goto out;
> -       if (of_property_read_bool(client->dev.of_node, "trickle-diode-disable"))
> +       if (device_property_read_bool(&client->dev, "trickle-diode-disable"))
>                 diode = false;
>         chip->trickle_charger_setup = chip->do_trickle_setup(client,
>                                                              ohms, diode);
> @@ -1268,7 +1290,7 @@ static int ds1307_probe(struct i2c_client *client,
>         struct ds1307           *ds1307;
>         int                     err = -ENODEV;
>         int                     tmp, wday;
> -       struct chip_desc        *chip = &chips[id->driver_data];
> +       struct chip_desc        *chip;
>         struct i2c_adapter      *adapter = to_i2c_adapter(client->dev.parent);
>         bool                    want_irq = false;
>         bool                    ds1307_can_wakeup_device = false;
> @@ -1297,11 +1319,23 @@ static int ds1307_probe(struct i2c_client *client,
>         i2c_set_clientdata(client, ds1307);
>
>         ds1307->client  = client;
> -       ds1307->type    = id->driver_data;
> +       if (id) {
> +               chip = &chips[id->driver_data];
> +               ds1307->type = id->driver_data;
> +       } else {
> +               const struct acpi_device_id *acpi_id;
> +
> +               acpi_id = acpi_match_device(ACPI_PTR(ds1307_acpi_ids),
> +                                               &client->dev);
> +               if (!acpi_id)
> +                       return -ENODEV;
> +               chip = &chips[acpi_id->driver_data];
> +               ds1307->type = acpi_id->driver_data;
> +       }
>
> -       if (!pdata && client->dev.of_node)
> -               ds1307_trickle_of_init(client, chip);
> -       else if (pdata && pdata->trickle_charger_setup)
> +       if (!pdata)
> +               ds1307_trickle_init(client, chip);
> +       else if (pdata->trickle_charger_setup)
>                 chip->trickle_charger_setup = pdata->trickle_charger_setup;
>
>         if (chip->trickle_charger_setup && chip->trickle_charger_reg) {
> @@ -1678,6 +1712,7 @@ static int ds1307_remove(struct i2c_client *client)
>  static struct i2c_driver ds1307_driver = {
>         .driver = {
>                 .name   = "rtc-ds1307",
> +               .acpi_match_table = ACPI_PTR(ds1307_acpi_ids),
>         },
>         .probe          = ds1307_probe,
>         .remove         = ds1307_remove,
> --
> 1.7.1
>

Hi ,
Any update for this patch ?
Thank you ,
Tin

-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

  parent reply	other threads:[~2016-12-05  7:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-30  2:57 [PATCH V1] rtc: ds1307: Add ACPI support 'Tin Huynh' via rtc-linux
     [not found] ` <1480474651-13984-1-git-send-email-tnhuynh-qTEPVZfXA3Y@public.gmane.org>
2016-12-05  7:48   ` 'Tin Huynh' via rtc-linux [this message]
2016-12-07 16:16   ` Alexandre Belloni

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=CANQ9TuAsLAJQxiW4cHkAJod3LaDsDsFB22Pk1+oQYDRSGooYWw@mail.gmail.com \
    --to=rtc-linux-/jypxa39uh5tlh3mbocffw@public.gmane.org \
    --cc=a.zummo-BfzFCNDTiLLj+vYz1yj4TQ@public.gmane.org \
    --cc=alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=lho-qTEPVZfXA3Y@public.gmane.org \
    --cc=linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=patches-qTEPVZfXA3Y@public.gmane.org \
    --cc=pvo-qTEPVZfXA3Y@public.gmane.org \
    --cc=tnhuynh-qTEPVZfXA3Y@public.gmane.org \
    --cc=tqnguyen-qTEPVZfXA3Y@public.gmane.org \
    /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).