greybus: gb-audio: Add I2C device for rt5647 codec
authorMark A. Greer <mgreer@animalcreek.com>
Thu, 21 May 2015 22:56:59 +0000 (15:56 -0700)
committerGreg Kroah-Hartman <gregkh@google.com>
Sat, 23 May 2015 23:26:41 +0000 (16:26 -0700)
Add the I2C device node for the rt5647 codec.

Eventually, this will be done automatically somewhere
else but for now its done in the audio driver.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/audio.c
drivers/staging/greybus/audio.h

index d4d1eff..1cc7c04 100644 (file)
@@ -4,7 +4,6 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/workqueue.h>
-#include <linux/i2c.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -157,6 +156,9 @@ static int gb_i2s_transmitter_connection_init(struct gb_connection *connection)
        struct gb_snd *snd_dev;
        struct platform_device *codec, *dai;
        struct asoc_simple_card_info *simple_card;
+#if USE_RT5645
+       struct i2c_board_info rt5647_info;
+#endif
        unsigned long flags;
        int ret;
 
@@ -219,6 +221,18 @@ static int gb_i2s_transmitter_connection_init(struct gb_connection *connection)
                goto out_get_ver;
        }
 
+#if USE_RT5645
+       rt5647_info.addr = RT5647_I2C_ADDR;
+       strlcpy(rt5647_info.type, "rt5647", I2C_NAME_SIZE);
+
+       snd_dev->rt5647 = i2c_new_device(i2c_get_adapter(RT5647_I2C_ADAPTER_NR),
+                                        &rt5647_info);
+       if (!snd_dev->rt5647) {
+               pr_err("can't create rt5647 i2c device\n");
+               goto out_get_ver;
+       }
+#endif
+
        return 0;
 
 out_get_ver:
@@ -238,6 +252,10 @@ static void gb_i2s_transmitter_connection_exit(struct gb_connection *connection)
 
        snd_dev = (struct gb_snd *)connection->private;
 
+#if USE_RT5645
+       i2c_unregister_device(snd_dev->rt5647);
+#endif
+
        platform_device_unregister(&snd_dev->card);
        platform_device_unregister(&snd_dev->cpu_dai);
        platform_device_unregister(snd_dev->codec);
index 5095df9..020a8fc 100644 (file)
@@ -4,6 +4,7 @@
 #include <linux/device.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
+#include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <sound/soc.h>
 #include "greybus.h"
@@ -41,6 +42,7 @@ struct gb_snd {
        struct platform_device          cpu_dai;
        struct platform_device          *codec;
        struct asoc_simple_card_info    *simple_card_info;
+       struct i2c_client               *rt5647;
        struct gb_connection            *mgmt_connection;
        struct gb_connection            *i2s_tx_connection;
        struct gb_connection            *i2s_rx_connection;