From: 黄涛 Date: Tue, 28 Feb 2012 09:10:11 +0000 (+0800) Subject: rk30: refactor i2s init code X-Git-Tag: firefly_0821_release~9595^2~113 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=cd9328e5c912f0ec38348c3f5de1bffcb2757558;p=firefly-linux-kernel-4.4.55.git rk30: refactor i2s init code --- diff --git a/arch/arm/mach-rk30/board-rk30-sdk.c b/arch/arm/mach-rk30/board-rk30-sdk.c index ab88fafa6fb8..b4500d553388 100755 --- a/arch/arm/mach-rk30/board-rk30-sdk.c +++ b/arch/arm/mach-rk30/board-rk30-sdk.c @@ -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 diff --git a/arch/arm/mach-rk30/devices.c b/arch/arm/mach-rk30/devices.c index b155da00c16b..dc608b7aee2b 100755 --- a/arch/arm/mach-rk30/devices.c +++ b/arch/arm/mach-rk30/devices.c @@ -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; } diff --git a/arch/arm/mach-rk30/include/mach/board.h b/arch/arm/mach-rk30/include/mach/board.h index 640c0abe5327..07d71ef0ee1c 100755 --- a/arch/arm/mach-rk30/include/mach/board.h +++ b/arch/arm/mach-rk30/include/mach/board.h @@ -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