rk30: refactor i2s init code
author黄涛 <huangtao@rock-chips.com>
Tue, 28 Feb 2012 09:10:11 +0000 (17:10 +0800)
committer黄涛 <huangtao@rock-chips.com>
Tue, 28 Feb 2012 09:10:11 +0000 (17:10 +0800)
arch/arm/mach-rk30/board-rk30-sdk.c
arch/arm/mach-rk30/devices.c
arch/arm/mach-rk30/include/mach/board.h

index ab88fafa6fb8ee5d297b0fc80701341a8bafdb23..b4500d5533887d6c5ad52b3b50268d6d944503ad 100755 (executable)
@@ -329,16 +329,6 @@ static struct platform_device *devices[] __initdata = {
 #ifdef CONFIG_FB_ROCKCHIP
        &device_fb,
 #endif
-#ifdef CONFIG_SND_RK29_SOC_I2S_8CH
-       &rk_device_iis0_8ch,
-#endif 
-#ifdef CONFIG_SND_RK29_SOC_I2S_2CH
-       &rk_device_iis1_2ch,
-#endif
-#ifdef CONFIG_SND_RK_SOC_I2S2_2CH
-       &rk_device_iis2_2ch,
-#endif
-
 };
 
 // i2c
index b155da00c16b29a7bc8a5cddcdba9dbbd7d7b86a..dc608b7aee2b4d827329900d8f4c8ac7e0fcc03a 100755 (executable)
@@ -793,103 +793,116 @@ static struct platform_device device_ipp = {
 #endif
 
 #ifdef CONFIG_SND_RK29_SOC_I2S
-static struct resource rk_iis0_8ch_resource[] = {
-        [0] = {
-                .start = RK30_I2S0_8CH_PHYS,
-                .end   = RK30_I2S0_8CH_PHYS + RK30_I2S0_8CH_SIZE - 1,
-                .flags = IORESOURCE_MEM,
-        },
-        [1] = {
-                .start = DMACH_I2S0_8CH_TX,
-                .end   = DMACH_I2S0_8CH_TX,
-                .flags = IORESOURCE_DMA,
-        },
-        [2] = {
-                .start = DMACH_I2S0_8CH_RX,
-                .end   = DMACH_I2S0_8CH_RX,
-                .flags = IORESOURCE_DMA,
-        },
-        [3] = {
-                .start = IRQ_I2S0_8CH,
-                .end   = IRQ_I2S0_8CH,
-                .flags = IORESOURCE_IRQ,        
-        },
-};
-
-struct platform_device rk_device_iis0_8ch = {
-        .name           = "rk29_i2s",
-        .id             = 0,
-        .num_resources  = ARRAY_SIZE(rk_iis0_8ch_resource),
-        .resource       = rk_iis0_8ch_resource,
-};
-
-static struct resource rk_iis1_2ch_resource[] = {
-        [0] = {
-                .start = RK30_I2S1_2CH_PHYS,
-                .end   = RK30_I2S1_2CH_PHYS + RK30_I2S1_2CH_SIZE -1,
-                .flags = IORESOURCE_MEM,
-        },
-        [1] = {
-                .start = DMACH_I2S1_2CH_TX,
-                .end   = DMACH_I2S1_2CH_TX,
-                .flags = IORESOURCE_DMA,
-        },
-        [2] = {
-                .start = DMACH_I2S1_2CH_RX,
-                .end   = DMACH_I2S1_2CH_RX,
-                .flags = IORESOURCE_DMA,
-        },
-        [3] = {
-                .start = IRQ_I2S1_2CH,
-                .end   = IRQ_I2S1_2CH,
-                .flags = IORESOURCE_IRQ,        
-        },
-};
-
-struct platform_device rk_device_iis1_2ch = {
-        .name           = "rk29_i2s",
-        .id             = 1,
-        .num_resources  = ARRAY_SIZE(rk_iis1_2ch_resource),
-        .resource       = rk_iis1_2ch_resource,
-};
-
-static struct resource rk_iis2_2ch_resource[] = {
-        [0] = {
-                .start = RK30_I2S2_2CH_PHYS,
-                .end   = RK30_I2S2_2CH_PHYS + RK30_I2S2_2CH_SIZE -1,
-                .flags = IORESOURCE_MEM,
-        },
-        [1] = {
-                .start = DMACH_I2S2_2CH_TX,
-                .end   = DMACH_I2S2_2CH_TX,
-                .flags = IORESOURCE_DMA,
-        },
-        [2] = {
-                .start = DMACH_I2S2_2CH_RX,
-                .end   = DMACH_I2S2_2CH_RX,
-                .flags = IORESOURCE_DMA,
-        },
-        [3] = {
-                .start = IRQ_I2S2_2CH,
-                .end   = IRQ_I2S2_2CH,
-                .flags = IORESOURCE_IRQ,        
-        },
-};
-
-struct platform_device rk_device_iis2_2ch = {
-        .name           = "rk29_i2s",
-        .id             = 2,
-        .num_resources  = ARRAY_SIZE(rk_iis2_2ch_resource),
-        .resource       = rk_iis2_2ch_resource,
-};
-
-#endif
-
-static struct platform_device rk29_device_pcm = {
+static struct resource resource_iis0_8ch[] = {
+       [0] = {
+               .start  = RK30_I2S0_8CH_PHYS,
+               .end    = RK30_I2S0_8CH_PHYS + RK30_I2S0_8CH_SIZE - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = DMACH_I2S0_8CH_TX,
+               .end    = DMACH_I2S0_8CH_TX,
+               .flags  = IORESOURCE_DMA,
+       },
+       [2] = {
+               .start  = DMACH_I2S0_8CH_RX,
+               .end    = DMACH_I2S0_8CH_RX,
+               .flags  = IORESOURCE_DMA,
+       },
+       [3] = {
+               .start  = IRQ_I2S0_8CH,
+               .end    = IRQ_I2S0_8CH,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device device_iis0_8ch = {
+       .name           = "rk29_i2s",
+       .id             = 0,
+       .num_resources  = ARRAY_SIZE(resource_iis0_8ch),
+       .resource       = resource_iis0_8ch,
+};
+
+static struct resource resource_iis1_2ch[] = {
+       [0] = {
+               .start  = RK30_I2S1_2CH_PHYS,
+               .end    = RK30_I2S1_2CH_PHYS + RK30_I2S1_2CH_SIZE -1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = DMACH_I2S1_2CH_TX,
+               .end    = DMACH_I2S1_2CH_TX,
+               .flags  = IORESOURCE_DMA,
+       },
+       [2] = {
+               .start  = DMACH_I2S1_2CH_RX,
+               .end    = DMACH_I2S1_2CH_RX,
+               .flags  = IORESOURCE_DMA,
+       },
+       [3] = {
+               .start  = IRQ_I2S1_2CH,
+               .end    = IRQ_I2S1_2CH,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device device_iis1_2ch = {
+       .name           = "rk29_i2s",
+       .id             = 1,
+       .num_resources  = ARRAY_SIZE(resource_iis1_2ch),
+       .resource       = resource_iis1_2ch,
+};
+
+static struct resource resource_iis2_2ch[] = {
+       [0] = {
+               .start  = RK30_I2S2_2CH_PHYS,
+               .end    = RK30_I2S2_2CH_PHYS + RK30_I2S2_2CH_SIZE -1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = DMACH_I2S2_2CH_TX,
+               .end    = DMACH_I2S2_2CH_TX,
+               .flags  = IORESOURCE_DMA,
+       },
+       [2] = {
+               .start  = DMACH_I2S2_2CH_RX,
+               .end    = DMACH_I2S2_2CH_RX,
+               .flags  = IORESOURCE_DMA,
+       },
+       [3] = {
+               .start  = IRQ_I2S2_2CH,
+               .end    = IRQ_I2S2_2CH,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device device_iis2_2ch = {
+       .name           = "rk29_i2s",
+       .id             = 2,
+       .num_resources  = ARRAY_SIZE(resource_iis2_2ch),
+       .resource       = resource_iis2_2ch,
+};
+#endif
+
+static struct platform_device device_pcm = {
        .name = "rockchip-audio",
        .id = -1,
 };
 
+static void __init rk30_init_i2s(void)
+{
+#ifdef CONFIG_SND_RK29_SOC_I2S_8CH
+       platform_device_register(&device_iis0_8ch);
+#endif
+#ifdef CONFIG_SND_RK29_SOC_I2S_2CH
+       platform_device_register(&device_iis1_2ch);
+#endif
+#ifdef CONFIG_SND_RK_SOC_I2S2_2CH
+       platform_device_register(&device_iis2_2ch);
+#endif
+       platform_device_register(&device_pcm);
+}
+
 #ifdef CONFIG_KEYS_RK29
 extern struct rk29_keys_platform_data rk29_keys_pdata;
 static struct platform_device device_keys = {
@@ -989,7 +1002,7 @@ static int __init rk30_init_devices(void)
 #ifdef CONFIG_FIQ_DEBUGGER
        rk_serial_debug_init(RK30_UART1_PHYS, IRQ_UART1, IRQ_UART_SIGNAL, -1);
 #endif
-       platform_device_register(&rk29_device_pcm);
+       rk30_init_i2s();
 
         return 0;
 }
index 640c0abe532711ad60e3ec273295184e1fdbc4a7..07d71ef0ee1cc9df5bf96220135dbe6131b48e34 100755 (executable)
@@ -46,9 +46,4 @@ void __init rk30_clock_init(void);
 
 extern struct sys_timer rk30_timer;
 
-
-extern struct platform_device rk_device_iis2_2ch;
-extern struct platform_device rk_device_iis1_2ch;
-extern struct platform_device rk_device_iis0_8ch;
-
 #endif