CHROMIUM: ASoC: max98095: first fragment of DT support
authorOlof Johansson <olofj@chromium.org>
Thu, 19 Jul 2012 19:51:12 +0000 (12:51 -0700)
committerGerrit <chrome-bot@google.com>
Fri, 20 Jul 2012 18:42:48 +0000 (11:42 -0700)
First pieces of DT support for max98095. It will be filled in more as
we move the ASoC for exynos to device tree (and upstreamed when it has
more than just a fragment in there).

BUG=chrome-os-partner:10849
TEST=boot; arecord -r 44100 /tmp/foo ; aplay /tmp/foo

Change-Id: Ib1cece184a26a801caa82b496610bfc98063ca68
Signed-off-by: Olof Johansson <olofj@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27913
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Documentation/devicetree/bindings/sound/max98095.txt [new file with mode: 0644]
sound/soc/codecs/max98095.c

diff --git a/Documentation/devicetree/bindings/sound/max98095.txt b/Documentation/devicetree/bindings/sound/max98095.txt
new file mode 100644 (file)
index 0000000..3a55141
--- /dev/null
@@ -0,0 +1,24 @@
+MAXIM 98095 audio CODEC
+
+Required properties:
+
+  - compatible : "maxim,max98095"
+
+  - reg : the I2C address of the device.
+
+Optional properties:
+
+  - mic-left-digital :  specifies if the left microphone is a DMIC
+                       instead of analog
+  - mic-right-digital : specifies if the right microphone is a DMIC
+                       instead of analog
+
+Example:
+
+codec: max98095@11 {
+       compatible = "maxim,max98095";
+       reg = <0x11>;
+
+       mic-left-digital;
+       mic-righ-digital;
+};
index 0bb511a..46f7573 100644 (file)
@@ -2334,6 +2334,25 @@ static struct snd_soc_codec_driver soc_codec_dev_max98095 = {
        .num_dapm_routes = ARRAY_SIZE(max98095_audio_map),
 };
 
+static struct max98095_pdata *max98095_of_pdata(struct i2c_client *i2c)
+{
+       struct max98095_pdata *pdata;
+       struct device_node *dn = i2c->dev.of_node;
+
+       pdata = devm_kzalloc(&i2c->dev, sizeof(struct max98095_pdata),
+                            GFP_KERNEL);
+       if (!pdata)
+               return NULL;
+
+       if (of_get_property(dn, "mic-left-digital", NULL))
+               pdata->digmic_left_mode = 1;
+
+       if (of_get_property(dn, "mic-right-digital", NULL))
+               pdata->digmic_right_mode = 1;
+
+       return pdata;
+}
+
 static int max98095_i2c_probe(struct i2c_client *i2c,
                             const struct i2c_device_id *id)
 {
@@ -2348,6 +2367,8 @@ static int max98095_i2c_probe(struct i2c_client *i2c,
        max98095->devtype = id->driver_data;
        i2c_set_clientdata(i2c, max98095);
        max98095->pdata = i2c->dev.platform_data;
+       if (!max98095->pdata && i2c->dev.of_node)
+               max98095->pdata = max98095_of_pdata(i2c);
 
        ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_max98095,
                                     max98095_dai, ARRAY_SIZE(max98095_dai));