All of lore.kernel.org
 help / color / mirror / Atom feed
From: Timur Tabi <timur@freescale.com>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Alsa-devel@alsa-project.org
Subject: Re: Need help with WM8960
Date: Thu, 13 Sep 2012 10:44:51 -0500	[thread overview]
Message-ID: <5051FF73.2030504@freescale.com> (raw)
In-Reply-To: <5051F0F4.5090205@freescale.com>

Timur Tabi wrote:
> Also, how do I get the platform data to the codec driver?  Do I need to
> create some arch code that reads the device tree properties and parses
> them into a wm8960_data object, and then (somehow) injects that into the
> wm8960 driver?

So, I'm guessing that there is no magical way to inject platform data into
an OF-initialized driver.  What do you think about this patch:

@@ -1029,6 +1030,7 @@ static const struct regmap_config wm8960_regmap = {
 static __devinit int wm8960_i2c_probe(struct i2c_client *i2c,
                                      const struct i2c_device_id *id)
 {
+       struct device_node *np = i2c->dev.of_node;
        struct wm8960_data *pdata = dev_get_platdata(&i2c->dev);
        struct wm8960_priv *wm8960;
        int ret;
@@ -1038,6 +1040,31 @@ static __devinit int wm8960_i2c_probe(struct
i2c_client *i2c,
        if (wm8960 == NULL)
                return -ENOMEM;

+       /*
+        * Are we running on an OF platform?  If so, then parse the device
+        * tree node for properties and create the platform data object
+        * ourselves.
+        */
+       if (np && !pdata) {
+               const __be32 *iprop;
+               int len;
+
+               pdata = devm_kzalloc(&i2c->dev, sizeof(struct wm8960_data),
+                                    GFP_KERNEL);
+               if (!pdata)
+                       return -ENOMEM;
+
+               if (of_find_property(np, "wlf,capless", NULL))
+                       pdata->capless = true;
+
+               iprop = of_get_property(np, "wlf,discharge-resistance", &len);
+               if (iprop && len == sizeof(uint32_t))
+                       pdata->dres = be32_to_cpup(iprop);
+
+               if (of_find_property(np, "wlf,shared-lrclk", NULL))
+                       pdata->shared_lrclk = true;
+
+               i2c->dev.platform_data = pdata;
+       }
+
        wm8960->regmap = regmap_init_i2c(i2c, &wm8960_regmap);
        if (IS_ERR(wm8960->regmap))
                return PTR_ERR(wm8960->regmap);


-- 
Timur Tabi
Linux kernel developer at Freescale

  reply	other threads:[~2012-09-13 15:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-12 23:09 Need help with WM8960 Timur Tabi
2012-09-13  3:13 ` Mark Brown
2012-09-13  3:26   ` Tabi Timur-B04825
2012-09-13  3:31     ` Mark Brown
2012-09-13 14:43   ` Timur Tabi
2012-09-13 15:44     ` Timur Tabi [this message]
2012-09-13 16:29       ` Timur Tabi
2012-09-19  2:59         ` Mark Brown

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=5051FF73.2030504@freescale.com \
    --to=timur@freescale.com \
    --cc=Alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.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 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.