rk2928: acodec: move audio codec platform device registration to board file to config...
authorZheng Yang <zhengyang@rock-chips.com>
Tue, 21 Aug 2012 01:50:46 +0000 (09:50 +0800)
committerZheng Yang <zhengyang@rock-chips.com>
Tue, 21 Aug 2012 01:50:46 +0000 (09:50 +0800)
arch/arm/mach-rk2928/board-rk2928-a720.c
arch/arm/mach-rk2928/board-rk2928-sdk.c
arch/arm/mach-rk2928/devices.c
sound/soc/codecs/rk2928_codec.c

index 0bc1895fc61b7baa76352b07dd64914b62c143cf..9ee25c2815776da6228124ac6f31212410c685d5 100755 (executable)
@@ -436,6 +436,28 @@ struct rk29_sdmmc_platform_data default_sdmmc0_data = {
 };
 #endif // CONFIG_SDMMC0_RK29
 
+#ifdef CONFIG_SND_SOC_RK2928
+static struct resource resources_acodec[] = {
+       {
+               .start  = RK2928_ACODEC_PHYS,
+               .end    = RK2928_ACODEC_PHYS + RK2928_ACODEC_SIZE - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .start  = RK2928_PIN1_PA0,
+               .end    = RK2928_PIN1_PA0,
+               .flags  = IORESOURCE_IO,
+       },
+};
+
+static struct platform_device device_acodec = {
+       .name   = "rk2928-codec",
+       .id             = -1,
+       .num_resources  = ARRAY_SIZE(resources_acodec),
+       .resource       = resources_acodec,
+};
+#endif
+
 static struct platform_device *devices[] __initdata = {
 #ifdef CONFIG_BACKLIGHT_RK29_BL
        &rk29_device_backlight,
@@ -446,6 +468,9 @@ static struct platform_device *devices[] __initdata = {
 #ifdef CONFIG_ION
        &device_ion,
 #endif
+#ifdef CONFIG_SND_SOC_RK2928
+       &device_acodec,
+#endif
 };
 //i2c
 #ifdef CONFIG_I2C0_RK30
index 0eb8250559919f0db0f616a2a387f9092b5f879e..0e743011f20f8b5c51a3b2bc4aa8da0d3c6b70fd 100755 (executable)
@@ -636,6 +636,28 @@ static struct platform_device device_rfkill_rk = {
 };
 #endif
 
+#ifdef CONFIG_SND_SOC_RK2928
+static struct resource resources_acodec[] = {
+       {
+               .start  = RK2928_ACODEC_PHYS,
+               .end    = RK2928_ACODEC_PHYS + RK2928_ACODEC_SIZE - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .start  = RK2928_PIN3_PD4,
+               .end    = RK2928_PIN3_PD4,
+               .flags  = IORESOURCE_IO,
+       },
+};
+
+static struct platform_device device_acodec = {
+       .name   = "rk2928-codec",
+       .id             = -1,
+       .num_resources  = ARRAY_SIZE(resources_acodec),
+       .resource       = resources_acodec,
+};
+#endif
+
 static struct platform_device *devices[] __initdata = {
 #ifdef CONFIG_BACKLIGHT_RK29_BL
        &rk29_device_backlight,
@@ -652,6 +674,9 @@ static struct platform_device *devices[] __initdata = {
 #ifdef CONFIG_RFKILL_RK
        &device_rfkill_rk,
 #endif
+#ifdef CONFIG_SND_SOC_RK2928
+       &device_acodec,
+#endif
 };
 //i2c
 #ifdef CONFIG_I2C0_RK30
index 9be98c671c93b1c867d82ceeaf0473a455430a74..c5eab43b1f3f7ae42c404f7ecb876c584fe576ad 100755 (executable)
@@ -786,23 +786,6 @@ static void __init rk2928_init_sdmmc(void)
 #endif
 }
 
-#ifdef CONFIG_SND_SOC_RK2928
-static struct resource resources_acodec[] = {
-       {
-               .start  = RK2928_ACODEC_PHYS,
-               .end    = RK2928_ACODEC_PHYS + RK2928_ACODEC_SIZE - 1,
-               .flags  = IORESOURCE_MEM,
-       },
-};
-
-static struct platform_device device_acodec = {
-       .name   = "rk2928-codec",
-       .id             = -1,
-       .num_resources  = ARRAY_SIZE(resources_acodec),
-       .resource       = resources_acodec,
-};
-#endif
-
 static struct resource resource_arm_pmu = {
        .start          = IRQ_ARM_PMU,
        .end            = IRQ_ARM_PMU,
@@ -848,9 +831,6 @@ static int __init rk2928_init_devices(void)
        rk_serial_debug_init(DEBUG_UART_BASE, IRQ_DEBUG_UART, IRQ_UART_SIGNAL, -1);
 #endif
        rk2928_init_i2s();
-#ifdef CONFIG_SND_SOC_RK2928
-       platform_device_register(&device_acodec);
-#endif
 #ifdef CONFIG_HDMI_RK2928
        platform_device_register(&device_hdmi);
 #endif
index 54a75a2ec61c05eef81b52eeb203de68ee56d9eb..a31276077b7dd1752a2979af34f3dbf9177393a7 100755 (executable)
@@ -41,8 +41,6 @@
 
 #include "rk2928_codec.h"
 
-#define SPK_CTL        RK2928_PIN1_PA0
-
 static struct rk2928_codec_data {
        struct device   *dev;
        int                     regbase;
@@ -50,6 +48,7 @@ static struct rk2928_codec_data {
        int                             regsize_phy;
        int                             mute;
        int                             hdmi_enable;
+       int                             spkctl;
 } rk2928_data;
 
 static const struct snd_soc_dapm_widget rk2928_dapm_widgets[] = {
@@ -149,8 +148,8 @@ static int rk2928_audio_trigger(struct snd_pcm_substream *substream, int cmd,
                                if(!rk2928_data.hdmi_enable)
                                        rk2928_write(codec, CODEC_REG_DAC_MUTE, v_MUTE_DAC(0));
                                rk2928_data.mute = 0;
-                               if(SPK_CTL != INVALID_GPIO) {
-                                       gpio_direction_output(SPK_CTL, GPIO_HIGH);
+                               if(rk2928_data.spkctl != INVALID_GPIO) {
+                                       gpio_direction_output(rk2928_data.spkctl, GPIO_HIGH);
                                }
                        }
                        else {
@@ -163,8 +162,8 @@ static int rk2928_audio_trigger(struct snd_pcm_substream *substream, int cmd,
                case SNDRV_PCM_TRIGGER_SUSPEND:
                case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
                        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-                               if(SPK_CTL != INVALID_GPIO) {
-                                       gpio_direction_output(SPK_CTL, GPIO_LOW);
+                               if(rk2928_data.spkctl != INVALID_GPIO) {
+                                       gpio_direction_output(rk2928_data.spkctl, GPIO_LOW);
                                }
                                rk2928_write(codec, CODEC_REG_DAC_MUTE, v_MUTE_DAC(1));
                                rk2928_data.mute = 1;
@@ -246,17 +245,27 @@ static int rk2928_probe(struct snd_soc_codec *codec)
                ret = -ENXIO;
                goto err1;
        }
-       // Select SDI input from internal audio codec
-       writel(0x04000400, RK2928_GRF_BASE + GRF_SOC_CON0);
        
-       if(SPK_CTL != INVALID_GPIO) {
-               ret = gpio_request(SPK_CTL, NULL);
+       res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+       if(!res) {
+               rk2928_data.spkctl = INVALID_GPIO;
+       }
+       else {
+               rk2928_data.spkctl = res->start;
+       }
+       
+       if(rk2928_data.spkctl != INVALID_GPIO) {
+               ret = gpio_request(rk2928_data.spkctl, NULL);
                if (ret != 0) {
-                       gpio_free(SPK_CTL);
+                       gpio_free(rk2928_data.spkctl);
                }
                else
-                       gpio_direction_output(SPK_CTL, GPIO_LOW);
+                       gpio_direction_output(rk2928_data.spkctl, GPIO_LOW);
        }
+       
+       // Select SDI input from internal audio codec
+       writel(0x04000400, RK2928_GRF_BASE + GRF_SOC_CON0);
+       
        // Mute and Power off codec
        rk2928_write(codec, CODEC_REG_DAC_MUTE, v_MUTE_DAC(1));
        rk2928_set_bias_level(codec, SND_SOC_BIAS_OFF);