OMAP: DMA: HWMOD and convert into platform driver
Subsystems (5)
cover OMAP: DMA: HWMOD and convert into platform driver
This patch series is to convert existing OMAP DMA library into platform driver for all the OMAP1 and OMAP2 plus processors as per alignment with Benoit, Paul and Kevin.
The platform device model for OMAP2 plus will makes use of hwmod data base and it is based on the reference branch:
git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm.git
Branch: pm-wip/hwmods-omap4
commit f1c79ab452ed9cf7b5ff6488335c1ddf15d5c92a
Author: Benoit Cousson <[email protected]>
OMAP4: hwmod: Enable omap_hwmod build for OMAP4
The proposal is to:
1. Convert DMA library into platform driver in hwmod way
2. Clean up API's to remove cpu_is_xxxx checks.
3. Make use of DMA engine(See Documentation/crypto/async-tx-api.txt)
This series is going to cover 1 & 2 and 3 will be taken up once these changes becomes stable and thoroughly tested on all omap boards.
The API's are cleaned up to remove cpu_is_xxxx checks and code is moved to corresponding respective mach-omap folders.
Basic tests are performed with this patch series on OMAP3630(Zoom3) board. All other major defconfigs are build tested. OMAP4 boot seems to be broken on above branch for both MMC and ethernet.
List of TODO's:
1. To perform more tests on OMAP4 once the branch is bootable.
2. OMAP2 boot and basic dma tests
It will be helpful is some one tests and provides feedback on OMAP1 and OMAP2 boards since I don't have OMAP1 board.
Manjunatha GK (10):
OMAP2420: DMA: HWMOD: Add hwmod data structures
OMAP2430: DMA: HWMOD: Add hwmod data structures
OMAP3: DMA: HWMOD: Add hwmod data structures
OMAP4: DMA: HWMOD: update OMAP4 data base
OMAP1: DMA: Introduce DMA driver as platform driver OMAP2/3/4: DMA: HWMOD: Device registration OMAP2/3/4: DMA: Move chain API's to mach-omap2
OMAP: DMA: Move IRQ handlers to mach-omap
OMAP: DMA: API's Clean up
OMAP: DMA: Cleanup DMA library and enable DMA platform driver
arch/arm/mach-omap1/Makefile | 2 +- arch/arm/mach-omap1/dma.c | 595 +++++++++ arch/arm/mach-omap1/include/mach/dma.h | 80 ++ arch/arm/mach-omap2/Makefile | 2 +- arch/arm/mach-omap2/dma.c | 1268 ++++++++++++++++++ arch/arm/mach-omap2/include/mach/dma.h | 103 ++ arch/arm/mach-omap2/omap_hwmod_2420_data.c | 95 ++- arch/arm/mach-omap2/omap_hwmod_2430_data.c | 93 ++- arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | 90 ++ arch/arm/mach-omap2/omap_hwmod_44xx_data.c | 21 +- arch/arm/plat-omap/dma.c | 1968 ++++++---------------------- arch/arm/plat-omap/include/plat/dma.h | 438 +++---- 12 files changed, 2920 insertions(+), 1835 deletions(-) create mode 100644 arch/arm/mach-omap1/dma.c create mode 100644 arch/arm/mach-omap1/include/mach/dma.h create mode 100644 arch/arm/mach-omap2/dma.c create mode 100644 arch/arm/mach-omap2/include/mach/dma.h
RFC PATCH 1/10 OMAP2420: DMA: HWMOD: Add hwmod data structures
This patch adds OMAP2420 DMA hwmod structures.
--- arch/arm/mach-omap2/omap_hwmod_2420_data.c | 95 +++++++++++++++++++++++++++- 1 files changed, 93 insertions(+), 2 deletions(-)
arch/arm/mach-omap2/omap_hwmod_2420_data.c +93 -2
@@ -16,6 +16,9 @@#include <plat/cpu.h> #include <plat/dma.h> +#include <mach/irqs.h> +#include <mach/dma.h> +#include "omap_hwmod_common_data.h" #include "prm-regbits-24xx.h"
@@ -32,6 +35,7 @@static struct omap_hwmod omap2420_mpu_hwmod;static struct omap_hwmod omap2420_l3_main_hwmod;static struct omap_hwmod omap2420_l4_core_hwmod; +static struct omap_hwmod omap2420_dma_system_hwmod;/* L3 -> L4_CORE interface */ static struct omap_hwmod_ocp_if omap2420_l3_main__l4_core = {
@@ -136,11 +140,100 @@ static struct omap_hwmod omap2420_mpu_hwmod = { .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP2420), }; +static struct omap_hwmod_class_sysconfig omap2420_dma_sysc = { + .rev_offs =0x0000 , + .sysc_offs =0x002c , + .syss_offs =0x0028 , + .sysc_flags = (SYSC_HAS_SIDLEMODE |SYSC_HAS_SOFTRESET | +SYSC_HAS_MIDLEMODE |SYSC_HAS_CLOCKACTIVITY | +SYSC_HAS_EMUFREE |SYSC_HAS_AUTOIDLE ), + .idlemodes = (SIDLE_FORCE |SIDLE_NO |SIDLE_SMART | +MSTANDBY_FORCE |MSTANDBY_NO |MSTANDBY_SMART ), + .sysc_fields = &omap_hwmod_sysc_type1, +}; + +static struct omap_hwmod_class omap2420_dma_hwmod_class = { + .name ="dma" , + .sysc = &omap2420_dma_sysc, +}; + +/* system dma */ + +/* dma attributes */ +static struct omap_dma_dev_attr dma_dev_attr = { + .dma_dev_attr =DMA_LINKED_LCH |GLOBAL_PRIORITY | +IS_CSSA_32 |IS_CDSA_32 , + .dma_lch_count =OMAP_DMA4_LOGICAL_DMA_CH_COUNT , +}; + +static struct omap_hwmod_irq_info omap2420_dma_system_irqs[] = { + { .name ="dma_0" , .irq =INT_24XX_SDMA_IRQ0 }, + { .name ="dma_1" , .irq =INT_24XX_SDMA_IRQ1 }, + { .name ="dma_2" , .irq =INT_24XX_SDMA_IRQ2 }, + { .name ="dma_3" , .irq =INT_24XX_SDMA_IRQ3 }, +}; + +static struct omap_hwmod_addr_space omap2420_dma_system_addrs[] = { + { + .pa_start =0x48056000 , + .pa_end =0x4a0560ff , + .flags =ADDR_TYPE_RT + }, +}; + +/* dma_system -> L3 */ +static struct omap_hwmod_ocp_if omap2420_dma_system__l3 = { + .master = &omap2420_dma_system_hwmod, + .slave = &omap2420_l3_main_hwmod, + .clk ="l3_div_ck" , + .user =OCP_USER_MPU |OCP_USER_SDMA , +}; + +/* dma_system master ports */ +static struct omap_hwmod_ocp_if *omap2420_dma_system_masters[] = { + &omap2420_dma_system__l3, +}; + +/* l4_cfg -> dma_system */ +static struct omap_hwmod_ocp_if omap2420_l4_core__dma_system = { + .master = &omap2420_l4_core_hwmod, + .slave = &omap2420_dma_system_hwmod, + .clk ="l4_div_ck" , + .addr = omap2420_dma_system_addrs, + .addr_cnt =ARRAY_SIZE (omap2420_dma_system_addrs), + .user =OCP_USER_MPU |OCP_USER_SDMA , +}; + +/* dma_system slave ports */ +static struct omap_hwmod_ocp_if *omap2420_dma_system_slaves[] = { + &omap2420_l4_core__dma_system, +}; + +static struct omap_hwmod omap2420_dma_system_hwmod = { + .name ="dma" , + .class = &omap2420_dma_hwmod_class, + .mpu_irqs = omap2420_dma_system_irqs, + .mpu_irqs_cnt =ARRAY_SIZE (omap2420_dma_system_irqs), + .main_clk ="l3_div_ck" , + .prcm = { + .omap2 = { +/* .clkctrl_reg = NULL, */ + }, + }, + .slaves = omap2420_dma_system_slaves, + .slaves_cnt =ARRAY_SIZE (omap2420_dma_system_slaves), + .masters = omap2420_dma_system_masters, + .masters_cnt =ARRAY_SIZE (omap2420_dma_system_masters), + .dev_attr = &dma_dev_attr, + .omap_chip =OMAP_CHIP_INIT (CHIP_IS_OMAP2420 ), +}; +static __initdata struct omap_hwmod *omap2420_hwmods[] = { &omap2420_l3_main_hwmod, &omap2420_l4_core_hwmod, &omap2420_l4_wkup_hwmod, &omap2420_mpu_hwmod, + &omap2420_dma_system_hwmod,NULL , };
@@ -148,5 +241,3 @@ int __init omap2420_hwmod_init(void) {return omap_hwmod_init (omap2420_hwmods); } - -
Signature · 1 line
1.7.0.4
RFC PATCH 2/10 OMAP2430: DMA: HWMOD: Add hwmod data structures
In reply to Manjunatha GKThis patch adds OMAP2430 DMA hwmod structures.
--- arch/arm/mach-omap2/omap_hwmod_2430_data.c | 93 +++++++++++++++++++++++++++- 1 files changed, 92 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/omap_hwmod_2430_data.c +92 -1
@@ -12,10 +12,12 @@* XXX these should be marked initdata for multi-OMAP kernels */ #include <plat/omap_hwmod.h> -#include <mach/irqs.h> #include <plat/cpu.h> #include <plat/dma.h> +#include <mach/irqs.h> +#include <mach/dma.h> +#include "omap_hwmod_common_data.h" #include "prm-regbits-24xx.h"
@@ -32,6 +34,7 @@static struct omap_hwmod omap2430_mpu_hwmod;static struct omap_hwmod omap2430_l3_main_hwmod;static struct omap_hwmod omap2430_l4_core_hwmod; +static struct omap_hwmod omap2430_dma_system_hwmod;/* L3 -> L4_CORE interface */ static struct omap_hwmod_ocp_if omap2430_l3_main__l4_core = {
@@ -137,12 +140,100 @@ static struct omap_hwmod omap2430_mpu_hwmod = { .masters_cnt = ARRAY_SIZE(omap2430_mpu_masters), .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP2430), }; +static struct omap_hwmod_class_sysconfig omap2430_dma_sysc = { + .rev_offs =0x0000 , + .sysc_offs =0x002c , + .syss_offs =0x0028 , + .sysc_flags = (SYSC_HAS_SIDLEMODE |SYSC_HAS_SOFTRESET | +SYSC_HAS_MIDLEMODE |SYSC_HAS_CLOCKACTIVITY | +SYSC_HAS_EMUFREE |SYSC_HAS_AUTOIDLE ), + .idlemodes = (SIDLE_FORCE |SIDLE_NO |SIDLE_SMART | +MSTANDBY_FORCE |MSTANDBY_NO |MSTANDBY_SMART ), + .sysc_fields = &omap_hwmod_sysc_type1, +}; + +static struct omap_hwmod_class omap2430_dma_hwmod_class = { + .name ="dma" , + .sysc = &omap2430_dma_sysc, +}; + +/* dma_system */ + +/* dma attributes */ +static struct omap_dma_dev_attr dma_dev_attr = { + .dma_dev_attr =DMA_LINKED_LCH |GLOBAL_PRIORITY | +IS_CSSA_32 |IS_CDSA_32 , + .dma_lch_count =OMAP_DMA4_LOGICAL_DMA_CH_COUNT , +}; + +static struct omap_hwmod_irq_info omap2430_dma_system_irqs[] = { + { .name ="dma_0" , .irq =INT_24XX_SDMA_IRQ0 }, + { .name ="dma_1" , .irq =INT_24XX_SDMA_IRQ1 }, + { .name ="dma_2" , .irq =INT_24XX_SDMA_IRQ2 }, + { .name ="dma_3" , .irq =INT_24XX_SDMA_IRQ3 }, +}; + +static struct omap_hwmod_addr_space omap2430_dma_system_addrs[] = { + { + .pa_start =0x48056000 , + .pa_end =0x4a0560ff , + .flags =ADDR_TYPE_RT + }, +}; + +/* dma_system -> L3 */ +static struct omap_hwmod_ocp_if omap2430_dma_system__l3 = { + .master = &omap2430_dma_system_hwmod, + .slave = &omap2430_l3_main_hwmod, + .clk ="l3_div_ck" , + .user =OCP_USER_MPU |OCP_USER_SDMA , +}; + +/* dma_system master ports */ +static struct omap_hwmod_ocp_if *omap2430_dma_system_masters[] = { + &omap2430_dma_system__l3, +}; + +/* l4_cfg -> dma_system */ +static struct omap_hwmod_ocp_if omap2430_l4_core__dma_system = { + .master = &omap2430_l4_core_hwmod, + .slave = &omap2430_dma_system_hwmod, + .clk ="l4_div_ck" , + .addr = omap2430_dma_system_addrs, + .addr_cnt =ARRAY_SIZE (omap2430_dma_system_addrs), + .user =OCP_USER_MPU |OCP_USER_SDMA , +}; + +/* dma_system slave ports */ +static struct omap_hwmod_ocp_if *omap2430_dma_system_slaves[] = { + &omap2430_l4_core__dma_system, +}; + +static struct omap_hwmod omap2430_dma_system_hwmod = { + .name ="dma" , + .class = &omap2430_dma_hwmod_class, + .mpu_irqs = omap2430_dma_system_irqs, + .mpu_irqs_cnt =ARRAY_SIZE (omap2430_dma_system_irqs), + .main_clk ="l3_div_ck" , + .prcm = { + .omap2 = { +/*.clkctrl_reg = NULL, */ + }, + }, + .slaves = omap2430_dma_system_slaves, + .slaves_cnt =ARRAY_SIZE (omap2430_dma_system_slaves), + .masters = omap2430_dma_system_masters, + .masters_cnt =ARRAY_SIZE (omap2430_dma_system_masters), + .dev_attr = &dma_dev_attr, + .omap_chip =OMAP_CHIP_INIT (CHIP_IS_OMAP2430 ), +};static __initdata struct omap_hwmod *omap2430_hwmods[] = { &omap2430_l3_main_hwmod, &omap2430_l4_core_hwmod, &omap2430_l4_wkup_hwmod, &omap2430_mpu_hwmod, + &omap2430_dma_system_hwmod,NULL , };
Signature · 1 line
1.7.0.4
RFC PATCH 3/10 OMAP3: DMA: HWMOD: Add hwmod data structures
In reply to Manjunatha GKThis patch adds OMAP3 DMA hwmod structures.
--- arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | 90 ++++++++++++++++++++++++++++ 1 files changed, 90 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/omap_hwmod_3xxx_data.c +90 -0
@@ -17,6 +17,7 @@#include <mach/irqs.h> #include <plat/cpu.h> #include <plat/dma.h> +#include <mach/dma.h> #include "omap_hwmod_common_data.h"
@@ -36,6 +37,7 @@ static struct omap_hwmod omap3xxx_iva_hwmod;static struct omap_hwmod omap3xxx_l3_main_hwmod;static struct omap_hwmod omap3xxx_l4_core_hwmod;static struct omap_hwmod omap3xxx_l4_per_hwmod; +static struct omap_hwmod omap3xxx_dma_system_hwmod;/* L3 -> L4_CORE interface */ static struct omap_hwmod_ocp_if omap3xxx_l3_main__l4_core = {
@@ -69,6 +71,14 @@ static struct omap_hwmod_ocp_if *omap3xxx_l3_main_masters[] = { &omap3xxx_l3_main__l4_per, }; +/* dma_system -> L3 */ +static struct omap_hwmod_ocp_if omap3xxx_dma_system__l3 = { + .master = &omap3xxx_dma_system_hwmod, + .slave = &omap3xxx_l3_main_hwmod, + .clk ="l3_div_ck" , + .user =OCP_USER_MPU |OCP_USER_SDMA , +}; +/* L3 */ static struct omap_hwmod omap3xxx_l3_main_hwmod = { .name ="l3_main" ,
@@ -197,6 +207,85 @@ static struct omap_hwmod omap3xxx_iva_hwmod = { .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430) }; +/* dma attributes */ +static struct omap_dma_dev_attr dma_dev_attr = { + .dma_dev_attr =DMA_LINKED_LCH |GLOBAL_PRIORITY | +IS_CSSA_32 |IS_CDSA_32 , + .dma_lch_count =OMAP_DMA4_LOGICAL_DMA_CH_COUNT , +}; + +static struct omap_hwmod_class_sysconfig omap3xxx_dma_sysc = { + .rev_offs =0x0000 , + .sysc_offs =0x002c , + .syss_offs =0x0028 , + .sysc_flags = (SYSC_HAS_SIDLEMODE |SYSC_HAS_SOFTRESET | +SYSC_HAS_MIDLEMODE |SYSC_HAS_CLOCKACTIVITY | +SYSC_HAS_EMUFREE |SYSC_HAS_AUTOIDLE ), + .idlemodes = (SIDLE_FORCE |SIDLE_NO |SIDLE_SMART | +MSTANDBY_FORCE |MSTANDBY_NO |MSTANDBY_SMART ), + .sysc_fields = &omap_hwmod_sysc_type1, +}; + +static struct omap_hwmod_class omap3xxx_dma_hwmod_class = { + .name ="dma" , + .sysc = &omap3xxx_dma_sysc, +}; + +/* dma_system */ +static struct omap_hwmod_irq_info omap3xxx_dma_system_irqs[] = { + { .name ="dma_0" , .irq =INT_24XX_SDMA_IRQ0 }, + { .name ="dma_1" , .irq =INT_24XX_SDMA_IRQ1 }, + { .name ="dma_2" , .irq =INT_24XX_SDMA_IRQ2 }, + { .name ="dma_3" , .irq =INT_24XX_SDMA_IRQ3 }, +}; + +static struct omap_hwmod_addr_space omap3xxx_dma_system_addrs[] = { + { + .pa_start =0x48056000 , + .pa_end =0x4a0560ff , + .flags =ADDR_TYPE_RT + }, +}; + +/* dma_system master ports */ +static struct omap_hwmod_ocp_if *omap3xxx_dma_system_masters[] = { + &omap3xxx_dma_system__l3, +}; + +/* l4_cfg -> dma_system */ +static struct omap_hwmod_ocp_if omap3xxx_l4_core__dma_system = { + .master = &omap3xxx_l4_core_hwmod, + .slave = &omap3xxx_dma_system_hwmod, + .clk ="l4_div_ck" , + .addr = omap3xxx_dma_system_addrs, + .addr_cnt =ARRAY_SIZE (omap3xxx_dma_system_addrs), + .user =OCP_USER_MPU |OCP_USER_SDMA , +}; + +/* dma_system slave ports */ +static struct omap_hwmod_ocp_if *omap3xxx_dma_system_slaves[] = { + &omap3xxx_l4_core__dma_system, +}; + +static struct omap_hwmod omap3xxx_dma_system_hwmod = { + .name ="dma" , + .class = &omap3xxx_dma_hwmod_class, + .mpu_irqs = omap3xxx_dma_system_irqs, + .mpu_irqs_cnt =ARRAY_SIZE (omap3xxx_dma_system_irqs), + .main_clk ="l3_div_ck" , + .prcm = { + .omap2 = { +/* .clkctrl_reg = NULL, */ + }, + }, + .slaves = omap3xxx_dma_system_slaves, + .slaves_cnt =ARRAY_SIZE (omap3xxx_dma_system_slaves), + .masters = omap3xxx_dma_system_masters, + .masters_cnt =ARRAY_SIZE (omap3xxx_dma_system_masters), + .dev_attr = &dma_dev_attr, + .omap_chip =OMAP_CHIP_INIT (CHIP_IS_OMAP3430 ), +}; +static __initdata struct omap_hwmod *omap3xxx_hwmods[] = { &omap3xxx_l3_main_hwmod, &omap3xxx_l4_core_hwmod,
@@ -204,6 +293,7 @@ static __initdata struct omap_hwmod *omap3xxx_hwmods[] = { &omap3xxx_l4_wkup_hwmod, &omap3xxx_mpu_hwmod, &omap3xxx_iva_hwmod, + &omap3xxx_dma_system_hwmod, NULL, };
Signature · 1 line
1.7.0.4
RFC PATCH 4/10 OMAP4: DMA: HWMOD: update OMAP4 data base
In reply to Manjunatha GKThe OMAP4 hwmod data base is updated with DMA controller attributes.
Also, irq name are changed from 0 to dma_0, 1->dma_1 ... in order provide meaningful name to irq names.
--- arch/arm/mach-omap2/omap_hwmod_44xx_data.c | 21 ++++++++++++++++----- 1 files changed, 16 insertions(+), 5 deletions(-)
arch/arm/mach-omap2/omap_hwmod_44xx_data.c +16 -5
@@ -22,6 +22,9 @@#include <plat/omap_hwmod.h> #include <plat/cpu.h> +#include <plat/dma.h> + +#include <mach/dma.h> #include "omap_hwmod_common_data.h"
@@ -750,12 +753,19 @@ static struct omap_hwmod_class omap44xx_dma_hwmod_class = { .sysc = &omap44xx_dma_sysc, }; +/* dma attributes */ +static struct omap_dma_dev_attr dma_dev_attr = { + .dma_dev_attr =DMA_LINKED_LCH |GLOBAL_PRIORITY | +IS_CSSA_32 |IS_CDSA_32 , + .dma_lch_count =OMAP_DMA4_LOGICAL_DMA_CH_COUNT , +}; +/* dma_system */ static struct omap_hwmod_irq_info omap44xx_dma_system_irqs[] = { - { .name ="0" , .irq =12 +OMAP44XX_IRQ_GIC_START }, - { .name ="1" , .irq =13 +OMAP44XX_IRQ_GIC_START }, - { .name ="2" , .irq =14 +OMAP44XX_IRQ_GIC_START }, - { .name ="3" , .irq =15 +OMAP44XX_IRQ_GIC_START }, + { .name ="dma_0" , .irq =12 +OMAP44XX_IRQ_GIC_START }, + { .name ="dma_1" , .irq =13 +OMAP44XX_IRQ_GIC_START }, + { .name ="dma_2" , .irq =14 +OMAP44XX_IRQ_GIC_START }, + { .name ="dma_3" , .irq =15 +OMAP44XX_IRQ_GIC_START }, };static struct omap_hwmod_addr_space omap44xx_dma_system_addrs[] = {
@@ -801,6 +811,7 @@ static struct omap_hwmod omap44xx_dma_system_hwmod = { .slaves_cnt = ARRAY_SIZE(omap44xx_dma_system_slaves), .masters = omap44xx_dma_system_masters, .masters_cnt = ARRAY_SIZE(omap44xx_dma_system_masters), + .dev_attr = &dma_dev_attr, .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP4430), };
@@ -4789,7 +4800,7 @@ static __initdata struct omap_hwmod *omap44xx_hwmods[] = {/* counter class */ &omap44xx_counter_32k_hwmod,/* dma class */ -/* &omap44xx_dma_system_hwmod, */ + &omap44xx_dma_system_hwmod,/* dmic class */ /* &omap44xx_dmic_hwmod, */ /* dsp class */
Signature · 1 line
1.7.0.4
RFC PATCH 5/10 OMAP1: DMA: Introduce DMA driver as platform driver
In reply to Manjunatha GKThis patch introduces OMAP1 DMA driver as platform device and adds support for registering through platform device layer.
--- arch/arm/mach-omap1/dma.c | 271 ++++++++++++++++++++++++++++++++ arch/arm/mach-omap1/include/mach/dma.h | 80 ++++++++++ arch/arm/plat-omap/include/plat/dma.h | 118 ++++++++++++++ 3 files changed, 469 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-omap1/dma.c create mode 100644 arch/arm/mach-omap1/include/mach/dma.h
arch/arm/mach-omap1/dma.c new file +271 -0
@@ -0,0 +1,271 @@ +/* +* dma.c - OMAP1/OMAP7xx-specific DMA code +* +* Copyright (C) 2010 Texas Instruments, Inc. +* +* Author: +* Manjunatha GK <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#include <linux/err.h> +#include <linux/slab.h> +#include <linux/pm_runtime.h> +#include <linux/io.h> +#include <linux/module.h> +#include <linux/init.h> +#include <linux/sched.h> +#include <linux/spinlock.h> +#include <linux/errno.h> +#include <linux/interrupt.h> +#include <linux/irq.h> + +#include <mach/dma.h> + +#include <plat/irqs.h> +#include <plat/dma.h> +#include <plat/tc.h> + +#define OMAP_FUNC_MUX_ARM_BASE (0xfffe1000 + 0xec) + +#define omap1_dma_read (reg) __raw_readw(dma_base + reg) +#define omap1_dma_write (val, reg) __raw_writew(val, dma_base + reg) + +static struct resource res[]__initdata = { + [0 ] = { + .start =OMAP1_DMA_BASE , + .end =OMAP1_DMA_BASE +SZ_2K -1 , + .flags =IORESOURCE_MEM , + }, + [1 ] = { + .name ="system_dma_0" , + .start =INT_DMA_CH0_6 , + .flags =IORESOURCE_IRQ , + }, + [2 ] = { + .name ="system_dma_1" , + .start =INT_DMA_CH1_7 , + .flags =IORESOURCE_IRQ , + }, + [3 ] = { + .name ="system_dma_2" , + .start =INT_DMA_CH2_8 , + .flags =IORESOURCE_IRQ , + }, + [4 ] = { + .name ="system_dma_3" , + .start =INT_DMA_CH3 , + .flags =IORESOURCE_IRQ , + }, + [5 ] = { + .name ="system_dma_4" , + .start =INT_DMA_CH4 , + .flags =IORESOURCE_IRQ , + }, + [6 ] = { + .name ="system_dma_5" , + .start =INT_DMA_CH5 , + .flags =IORESOURCE_IRQ , + }, + [7 ] = { + .name ="system_dma_6" , + .start =INT_DMA_LCD , + .flags =IORESOURCE_IRQ , + }, +/* irq's for omap16xx and omap7xx */ + [8 ] = { + .name ="system_dma_7" , + .start =53 +IH2_BASE , + .flags =IORESOURCE_IRQ , + }, + [9 ] = { + .name ="system_dma_8" , + .start =54 +IH2_BASE , + .flags =IORESOURCE_IRQ , + }, + [10 ] = { + .name ="system_dma_9" , + .start =55 +IH2_BASE , + .flags =IORESOURCE_IRQ , + }, + [11 ] = { + .name ="system_dma_10" , + .start =56 +IH2_BASE , + .flags =IORESOURCE_IRQ , + }, + [12 ] = { + .name ="system_dma_11" , + .start =57 +IH2_BASE , + .flags =IORESOURCE_IRQ , + }, + [13 ] = { + .name ="system_dma_12" , + .start =58 +IH2_BASE , + .flags =IORESOURCE_IRQ , + }, + [14 ] = { + .name ="system_dma_13" , + .start =59 +IH2_BASE , + .flags =IORESOURCE_IRQ , + }, + [15 ] = { + .name ="system_dma_14" , + .start =60 +IH2_BASE , + .flags =IORESOURCE_IRQ , + }, + [16 ] = { + .name ="system_dma_15" , + .start =61 +IH2_BASE , + .flags =IORESOURCE_IRQ , + }, + [17 ] = { + .name ="system_dma_16" , + .start =62 +IH2_BASE , + .flags =IORESOURCE_IRQ , + }, +}; + +static struct omap_dma_reg_offset dma_reg_offset[] = { + { + .lch_base =OMAP1_DMA_CH_BASE , + .gcr =OMAP1_DMA_GCR , + .gscr =OMAP1_DMA_GSCR , + .grst =OMAP1_DMA_GRST , + .hw_id =OMAP1_DMA_HW_ID , + .ch_specific = { + .cssa_l =OMAP1_DMA_CSSA_L , + .cssa_u =OMAP1_DMA_CSSA_U , + .cdsa_l =OMAP1_DMA_CDSA_L , + .cdsa_u =OMAP1_DMA_CDSA_U , + .lch_ctrl =OMAP1_DMA_LCH_CTRL , + .color_l =OMAP1_DMA_COLOR_L , + .color_u =OMAP1_DMA_COLOR_U , + .ccr2 =OMAP1_DMA_CCR2 , + }, + .common_ch = { + .csdp =OMAP1_DMA_CSDP , + .ccr =OMAP1_DMA_CCR , + .csei =OMAP1_DMA_CSEI , + .csfi =OMAP1_DMA_CSFI , + .cdei =OMAP1_DMA_CDEI , + .cdfi =OMAP1_DMA_CDFI , + .clnk_ctrl =OMAP1_DMA_CLNK_CTRL , + .cpc =OMAP1_DMA_CPC , + .cdac =OMAP1_DMA_CDAC , + .cicr =OMAP1_DMA_CICR , + }, + .reg_caps = { + .caps_0u =OMAP1_DMA_CAPS_0_U , + .caps_0l =OMAP1_DMA_CAPS_0_L , + .caps_1u =OMAP1_DMA_CAPS_1_U , + .caps_1l =OMAP1_DMA_CAPS_1_L , + .caps_2 =OMAP1_DMA_CAPS_2 , + .caps_3 =OMAP1_DMA_CAPS_3 , + .caps_4 =OMAP1_DMA_CAPS_4 , + }, + }, +}; +struct omap_dma_reg_offset *r = (struct omap_dma_reg_offset *)&dma_reg_offset; + + +static struct omap_dma_lch *omap1_dma_chan; +static void __iomem *dma_base; +static int enable_1510_mode; + +static int __init omap1_system_dma_init (void ) +{ +struct platform_device *pdev; +struct omap_system_dma_plat_info *pdata; +struct omap_dma_dev_attr *d; +int ret; + + pdev =platform_device_alloc ("system_dma" ,0 ); +if (!pdev) { +pr_err ("%s: Unable to device alloc for dma\n" , + __func__); +return -ENOMEM ; + } + + ret =platform_device_add_resources (pdev, res,ARRAY_SIZE (res)); +if (ret) { +pr_err ("%s: Unable to add resources for %s%d\n" , + __func__, pdev->name, pdev->id); + goto exit_device_put; + } + + pdata =kzalloc (sizeof (struct omap_system_dma_plat_info ),GFP_KERNEL ); +if (!pdata) { +pr_err ("%s: Unable to allocate pdata for %s\n" , + __func__, pdev->name); + ret = -ENOMEM ; + goto exit_device_put; + } + + d = pdata->dma_attr; + +/* Valid attributes for omap1 plus processors */ + d->dma_dev_attr =0 ; + +if (cpu_is_omap15xx ()) + d->dma_dev_attr = enable_1510_mode =ENABLE_1510_MODE ; + + d->dma_dev_attr |=SRC_PORT ; + d->dma_dev_attr |=DST_PORT ; + d->dma_dev_attr |=SRC_INDEX ; + d->dma_dev_attr |=DST_INDEX ; + d->dma_dev_attr |=IS_BURST_ONLY4 ; + d->dma_dev_attr |=CLEAR_CSR_ON_READ ; + d->dma_dev_attr |=IS_WORD_16 ; + + d->dma_lch_count =OMAP1_LOGICAL_DMA_CH_COUNT ; + + pdata->omap_dma_base = (void __iomem *)res[0 ].start; + pdata->dma_reg_offset = r; + + pdata->dma_handle_ch = omap1_dma_handle_ch; + pdata->clear_lch_regs = clear_lch_regs; + pdata->clear_ccr_csr = clear_ccr_csr; + pdata->sync_device_set = sync_device_set; + pdata->dma_running = dma_running; + pdata->dma_irq_register = dma_irq_register; + pdata->set_prio_lch = set_prio_lch; + pdata->enable_lnk = enable_lnk; + pdata->disable_lnk = disable_lnk; + pdata->enable_channel_irq = omap_enable_channel_irq; + pdata->disable_channel_irq =NULL ; + pdata->set_dma_write_mode =NULL ; + pdata->disable_irq_lch =NULL ; + pdata->enable_irq_lch =NULL ; + + dma_base = pdata->omap_dma_base; + +/* Errata handling for all omap1 plus processors */ + pdata->errata =0 ; + +if (cpu_class_is_omap1 () && !cpu_is_omap15xx ()) + pdata->errata |=OMAP3_3_ERRATUM ; + + ret =platform_device_add_data (pdev, pdata,sizeof (*pdata)); +if (ret) { +pr_err ("%s: Unable to add resources for %s%d\n" , + __func__, pdev->name, pdev->id); + goto exit_release_pdata; + } + ret =platform_device_add (pdev); +if (ret) { +pr_err ("%s: Unable to add resources for %s%d\n" , + __func__, pdev->name, pdev->id); + goto exit_release_pdata; + } + +exit_release_pdata: +kfree (pdata); +exit_device_put: +platform_device_put (pdev); + +return ret; +} +arch_initcall (omap1_system_dma_init);
arch/arm/mach-omap1/include/mach/dma.h new file +80 -0
80 lines not on this page · raw message
arch/arm/plat-omap/include/plat/dma.h +118 -0
136 lines not on this page · raw message
Signature · 1 line
1.7.0.4
RFC PATCH 6/10 OMAP2/3/4: DMA: HWMOD: Device registration
In reply to Manjunatha GKThis patch converts omap2/3/4 dma driver into platform devices through using omap hwmod, omap device and runtime pm frameworks.
--- arch/arm/mach-omap2/dma.c | 200 ++++++++++++++++++++++++++++++++ arch/arm/mach-omap2/include/mach/dma.h | 76 ++++++++++++ 2 files changed, 276 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-omap2/dma.c create mode 100644 arch/arm/mach-omap2/include/mach/dma.h
arch/arm/mach-omap2/dma.c new file +200 -0
@@ -0,0 +1,200 @@ +/* +* dma.c - OMAP2 specific DMA code +* +* Copyright (C) 2010 Texas Instruments, Inc. +* +* Author: +* Manjunatha GK <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#include <linux/err.h> +#include <linux/slab.h> +#include <linux/pm_runtime.h> +#include <linux/io.h> +#include <linux/module.h> +#include <linux/init.h> +#include <linux/sched.h> +#include <linux/spinlock.h> +#include <linux/errno.h> +#include <linux/interrupt.h> +#include <linux/irq.h> + +#include <mach/dma.h> + +#include <plat/irqs.h> +#include <plat/omap_hwmod.h> +#include <plat/omap_device.h> +#include <plat/dma.h> + +struct omap_device_pm_latency omap2_dma_latency[] = { + { + .deactivate_func = omap_device_idle_hwmods, + .activate_func = omap_device_enable_hwmods, + .flags =OMAP_DEVICE_LATENCY_AUTO_ADJUST , + }, +}; + +struct omap_dma_reg_offset dma_reg_offset[] = { + { + .lch_base =OMAP_DMA4_CH_BASE , + .gcr =OMAP_DMA4_GCR , + .ocp_sysconfig =OMAP_DMA4_OCP_SYSCONFIG , + .rev =OMAP_DMA4_REVISION , + .common_ch = { + .csdp =OMAP_DMA4_CSDP , + .ccr =OMAP_DMA4_CCR , + .cicr =OMAP_DMA4_CICR , + .csr =OMAP_DMA4_CSR , + .csfi =OMAP_DMA4_CSFI , + .csei =OMAP_DMA4_CSEI , + .cdac =OMAP_DMA4_CDAC , + .cdei =OMAP_DMA4_CDEI , + .cdfi =OMAP_DMA4_CDFI , + .clnk_ctrl =OMAP_DMA4_CLNK_CTRL , + .cen =OMAP_DMA4_CEN , + .cfn =OMAP_DMA4_CFN , + }, + .ch_specific = { + .cssa =OMAP_DMA4_CSSA , + .cdsa =OMAP_DMA4_CDSA , + }, + .irqreg = { + .irq_status_l0 =OMAP_DMA4_IRQSTATUS_L0 , + .irq_enable_l0 =OMAP_DMA4_IRQENABLE_L0 , + }, + + .reg_caps = { + .caps_0 =OMAP_DMA4_CAPS_0 , + }, + }, +}; +struct omap_dma_reg_offset *r = (struct omap_dma_reg_offset *)&dma_reg_offset; + +struct omap_dma_dev_attr *d; + +static struct omap_system_dma_plat_info *omap2_pdata; +static void __iomem *dma_base; +static struct dma_link_info *dma_linked_lch; +static u32 dma_chan_count; + +/* One time initializations */ +static int __init omap2_system_dma_init_dev (struct omap_hwmod *oh,void *user) +{ +struct omap_device *od; +struct omap_system_dma_plat_info *pdata; +struct resource *mem; +char *name ="dma" ; + + pdata =kzalloc (sizeof (struct omap_system_dma_plat_info ),GFP_KERNEL ); +if (!pdata) { +pr_err ("%s: Unable to allocate pdata for %s:%s\n" , + __func__, name, oh->name); +return -ENOMEM ; + } + + + pdata->dma_attr = (struct omap_dma_dev_attr *)oh->dev_attr; + + pdata->dma_reg_offset = r; + + pdata->disable_irq_lch = disable_irq_lch; + pdata->enable_irq_lch = enable_irq_lch; + pdata->dma_handle_ch = omap2_dma_handle_ch; + pdata->clear_lch_regs =NULL ; + pdata->dma_running = dma_running; + pdata->set_prio_lch = set_prio_lch; + pdata->dma_irq_register = dma_irq_register; + pdata->enable_lnk = omap_enable_lnk; + pdata->disable_lnk = omap_disable_lnk; + pdata->enable_channel_irq = omap_enable_channel_irq; + pdata->disable_channel_irq = omap_disable_channel_irq; + pdata->clear_ccr_csr =NULL ; + pdata->sync_device_set =NULL ; + +/* Handling Errata's for all OMAP2PLUS processors */ + pdata->errata =0 ; + +if (cpu_is_omap242x () || + (cpu_is_omap243x () &&omap_type () <=OMAP2430_REV_ES1_0 )) + pdata->errata =DMA_CHAINING_ERRATA ; + +/* +* Errata: On ES2.0 BUFFERING disable must be set. +* This will always fail on ES1.0 +*/ +if (cpu_is_omap24xx ()) + pdata->errata |=DMA_BUFF_DISABLE_ERRATA ; + +/* +* Errata: OMAP2: sDMA Channel is not disabled +* after a transaction error. So we explicitely +* disable the channel +*/ +if (cpu_class_is_omap2 ()) + pdata->errata |=DMA_CH_DISABLE_ERRATA ; + +/* Errata: OMAP3 : +* A bug in ROM code leaves IRQ status for channels 0 and 1 uncleared +* after secure sram context save and restore. Hence we need to +* manually clear those IRQs to avoid spurious interrupts. This +* affects only secure devices. +*/ +if (cpu_is_omap34xx () && (omap_type () !=OMAP2_DEVICE_TYPE_GP )) + pdata->errata |=DMA_IRQ_STATUS_ERRATA ; + +/* Errata3.3: Applicable for all omap2 plus */ + pdata->errata |=OMAP3_3_ERRATUM ; + + od =omap_device_build (name,0 , oh, pdata,sizeof (*pdata), + omap2_dma_latency,ARRAY_SIZE (omap2_dma_latency),0 ); + +if (IS_ERR (od)) { +pr_err ("%s: Cant build omap_device for %s:%s.\n" , + __func__, name, oh->name); +kfree (pdata); +return 0 ; + } + + mem =platform_get_resource (&od->pdev,IORESOURCE_MEM ,0 ); +if (!mem) { +dev_err (&od->pdev.dev,"%s: no mem resource\n" , __func__); +return -EINVAL ; + } + + dma_base =ioremap (mem->start,resource_size (mem)); +if (!dma_base) { +dev_err (&od->pdev.dev,"%s: ioremap fail\n" , __func__); +return -ENOMEM ; + } + +/* Get DMA device attributes from hwmod data base */ + d = (struct omap_dma_dev_attr *)oh->dev_attr; + + dma_linked_lch =kzalloc (sizeof (struct dma_link_info ) * + d->dma_lch_count,GFP_KERNEL ); +if (!dma_linked_lch) { +int ret; + ret = -ENOMEM ; +kfree (pdata); +return ret; + } + omap2_pdata = pdata; + +pm_runtime_enable (&(od->pdev.dev)); +return 0 ; +} + +static int __init omap2_system_dma_init (void ) +{ +int ret; + + ret =omap_hwmod_for_each_by_class ("dma" , + omap2_system_dma_init_dev,NULL ); + +return ret; +} +arch_initcall (omap2_system_dma_init);
arch/arm/mach-omap2/include/mach/dma.h new file +76 -0
76 lines not on this page · raw message
Signature · 1 line
1.7.0.4
RFC PATCH 7/10 OMAP2/3/4: DMA: Move chain API's to mach-omap2
In reply to Manjunatha GKThe DMA chaining feature is supported from omap2 plus processors and not supported in omap1. Moving DMA chain API's to mach-omap2.
Note: Existing DMA chain API's in plat-omap will be cleaned up in another patch. This make sure that build is not broken with individual patches.
--- arch/arm/mach-omap2/dma.c | 663 ++++++++++++++++++++++++++++++++ arch/arm/mach-omap2/include/mach/dma.h | 27 ++ 2 files changed, 690 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/dma.c +663 -0
@@ -30,6 +30,59 @@#include <plat/omap_device.h> #include <plat/dma.h> +#define omap2_dma_read (reg) __raw_readl(dma_base + reg) +#define omap2_dma_write (val, reg) __raw_writel(val, dma_base + reg) + +enum {DMA_CH_ALLOC_DONE ,DMA_CH_PARAMS_SET_DONE ,DMA_CH_STARTED , +DMA_CH_QUEUED ,DMA_CH_NOTSTARTED ,DMA_CH_PAUSED ,DMA_CH_LINK_ENABLED +}; + +enum {DMA_CHAIN_STARTED ,DMA_CHAIN_NOTSTARTED }; + +/* Chain handling macros */ +#define OMAP_DMA_CHAIN_QINIT (chain_id) \ + do { \ + dma_linked_lch[chain_id].q_head = \ + dma_linked_lch[chain_id].q_tail = \ + dma_linked_lch[chain_id].q_count = 0; \ + } while (0) +#define OMAP_DMA_CHAIN_QFULL (chain_id) \ + (dma_linked_lch[chain_id].no_of_lchs_linked == \ + dma_linked_lch[chain_id].q_count) +#define OMAP_DMA_CHAIN_QLAST (chain_id) \ + do { \ + ((dma_linked_lch[chain_id].no_of_lchs_linked-1) == \ + dma_linked_lch[chain_id].q_count) \ + } while (0) +#define OMAP_DMA_CHAIN_QEMPTY (chain_id) \ + (0 == dma_linked_lch[chain_id].q_count) +#define __OMAP_DMA_CHAIN_INCQ (end) \ + ((end) = ((end)+1) % dma_linked_lch[chain_id].no_of_lchs_linked) +#define OMAP_DMA_CHAIN_INCQHEAD (chain_id) \ + do { \ + __OMAP_DMA_CHAIN_INCQ(dma_linked_lch[chain_id].q_head); \ + dma_linked_lch[chain_id].q_count--; \ + } while (0) + +#define OMAP_DMA_CHAIN_INCQTAIL (chain_id) \ + do { \ + __OMAP_DMA_CHAIN_INCQ(dma_linked_lch[chain_id].q_tail); \ + dma_linked_lch[chain_id].q_count++; \ + } while (0) + +struct dma_link_info { +int *linked_dmach_q; +int no_of_lchs_linked; + +int q_count; +int q_tail; +int q_head; + +int chain_state; +int chain_mode; + +}; +struct omap_device_pm_latency omap2_dma_latency[] = { { .deactivate_func = omap_device_idle_hwmods,
@@ -81,6 +134,616 @@ static void __iomem *dma_base;static struct dma_link_info *dma_linked_lch;static u32 dma_chan_count; +/* Create chain of DMA channesls */ +static void create_dma_lch_chain (int lch_head,int lch_queue) +{ +u32 reg, ch_reg_base, l; + +/* Check if this is the first link in chain */ +if (dma_chan[lch_head].next_linked_ch ==-1 ) { + dma_chan[lch_head].next_linked_ch = lch_queue; + dma_chan[lch_head].prev_linked_ch = lch_queue; + dma_chan[lch_queue].next_linked_ch = lch_head; + dma_chan[lch_queue].prev_linked_ch = lch_head; + } + +/* a link exists, link the new channel in circular chain */ +else { + dma_chan[lch_queue].next_linked_ch = + dma_chan[lch_head].next_linked_ch; + dma_chan[lch_queue].prev_linked_ch = lch_head; + dma_chan[lch_head].next_linked_ch = lch_queue; + dma_chan[dma_chan[lch_queue].next_linked_ch]. + prev_linked_ch = lch_queue; + } + + ch_reg_base = r->lch_base * lch_head; + reg = ch_reg_base + r->common_ch.clnk_ctrl; + l =omap2_dma_read (reg); + l &= ~(0x1f ); + l |= lch_queue; +omap2_dma_write (l, reg); + + ch_reg_base = r->lch_base * lch_queue; + reg = ch_reg_base + r->common_ch.clnk_ctrl; + l =omap2_dma_read (reg); + l &= ~(0x1f ); + l |= (dma_chan[lch_queue].next_linked_ch); +omap2_dma_write (l, reg); +} + +/** +* @brief omap_request_dma_chain : Request a chain of DMA channels +* +* @param dev_id - Device id using the dma channel +* @param dev_name - Device name +* @param callback - Call back function +* @chain_id - +* @no_of_chans - Number of channels requested +* @chain_mode - Dynamic or static chaining : OMAP_DMA_STATIC_CHAIN +* OMAP_DMA_DYNAMIC_CHAIN +* @params - Channel parameters +* +* @return - Success : 0 +* Failure: -EINVAL/-ENOMEM +*/ +int omap_request_dma_chain (int dev_id,const char *dev_name, +void (*callback) (int lch,u16 ch_status, +void *data), +int *chain_id,int no_of_chans,int chain_mode, +struct omap_dma_channel_params params) +{ +int *channels; +int i, err; + +/* Is the chain mode valid ? */ +if (chain_mode !=OMAP_DMA_STATIC_CHAIN + && chain_mode !=OMAP_DMA_DYNAMIC_CHAIN ) { +printk (KERN_ERR "Invalid chain mode requested\n" ); +return -EINVAL ; + } + +if (unlikely ((no_of_chans <1 + || no_of_chans > d->dma_lch_count))) { +printk (KERN_ERR "Invalid Number of channels requested\n" ); +return -EINVAL ; + } + +/* +* Allocate a queue to maintain the status of the channels +* in the chain +*/ + channels =kmalloc (sizeof (*channels) * no_of_chans,GFP_KERNEL ); +if (channels ==NULL ) { +printk (KERN_ERR "omap_dma: No memory for channel queue\n" ); +return -ENOMEM ; + } + +/* request and reserve DMA channels for the chain */ +for (i =0 ; i < no_of_chans; i++) { + err =omap_request_dma (dev_id, dev_name, + callback,NULL , &channels[i]); +if (err <0 ) { +int j; +for (j =0 ; j < i; j++) +omap_free_dma (channels[j]); +kfree (channels); +printk (KERN_ERR "omap_dma: Request failed %d\n" , err); +return err; + } + dma_chan[channels[i]].prev_linked_ch =-1 ; + dma_chan[channels[i]].state =DMA_CH_NOTSTARTED ; + +/* +* Allowing client drivers to set common parameters now, +* so that later only relevant (src_start, dest_start +* and element count) can be set +*/ +omap_set_dma_params (channels[i], ¶ms); + } + + *chain_id = channels[0 ]; + dma_linked_lch[*chain_id].linked_dmach_q = channels; + dma_linked_lch[*chain_id].chain_mode = chain_mode; + dma_linked_lch[*chain_id].chain_state =DMA_CHAIN_NOTSTARTED ; + dma_linked_lch[*chain_id].no_of_lchs_linked = no_of_chans; + +for (i =0 ; i < no_of_chans; i++) + dma_chan[channels[i]].chain_id = *chain_id; + +/* Reset the Queue pointers */ +OMAP_DMA_CHAIN_QINIT (*chain_id); + +/* Set up the chain */ +if (no_of_chans ==1 ) +create_dma_lch_chain (channels[0 ], channels[0 ]); +else { +for (i =0 ; i < (no_of_chans -1 ); i++) +create_dma_lch_chain (channels[i], channels[i +1 ]); + } + +return 0 ; +} +EXPORT_SYMBOL (omap_request_dma_chain); + +/** +* @brief omap_modify_dma_chain_param : Modify the chain's params - Modify the +* params after setting it. Dont do this while dma is running!! +* +* @param chain_id - Chained logical channel id. +* @param params +* +* @return - Success : 0 +* Failure : -EINVAL +*/ +int omap_modify_dma_chain_params (int chain_id, +struct omap_dma_channel_params params) +{ +int *channels; +u32 i; + +/* Check for input params */ +if (unlikely ((chain_id <0 + || chain_id >= d->dma_lch_count))) { +printk (KERN_ERR "Invalid chain id\n" ); +return -EINVAL ; + } + +/* Check if the chain exists */ +if (dma_linked_lch[chain_id].linked_dmach_q ==NULL ) { +printk (KERN_ERR "Chain doesn't exists\n" ); +return -EINVAL ; + } + channels = dma_linked_lch[chain_id].linked_dmach_q; + +for (i =0 ; i < dma_linked_lch[chain_id].no_of_lchs_linked; i++) { +/* +* Allowing client drivers to set common parameters now, +* so that later only relevant (src_start, dest_start +* and element count) can be set +*/ +omap_set_dma_params (channels[i], ¶ms); + } + +return 0 ; +} +EXPORT_SYMBOL (omap_modify_dma_chain_params); + +/** +* @brief omap_free_dma_chain - Free all the logical channels in a chain. +* +* @param chain_id +* +* @return - Success : 0 +* Failure : -EINVAL +*/ +int omap_free_dma_chain (int chain_id) +{ +int *channels; +u32 i; + +/* Check for input params */ +if (unlikely ((chain_id <0 || chain_id >= d->dma_lch_count))) { +printk (KERN_ERR "Invalid chain id\n" ); +return -EINVAL ; + } + +/* Check if the chain exists */ +if (dma_linked_lch[chain_id].linked_dmach_q ==NULL ) { +printk (KERN_ERR "Chain doesn't exists\n" ); +return -EINVAL ; + } + + channels = dma_linked_lch[chain_id].linked_dmach_q; +for (i =0 ; i < dma_linked_lch[chain_id].no_of_lchs_linked; i++) { + dma_chan[channels[i]].next_linked_ch =-1 ; + dma_chan[channels[i]].prev_linked_ch =-1 ; + dma_chan[channels[i]].chain_id =-1 ; + dma_chan[channels[i]].state =DMA_CH_NOTSTARTED ; +omap_free_dma (channels[i]); + } + +kfree (channels); + + dma_linked_lch[chain_id].linked_dmach_q =NULL ; + dma_linked_lch[chain_id].chain_mode =-1 ; + dma_linked_lch[chain_id].chain_state =-1 ; + +return 0 ; +} +EXPORT_SYMBOL (omap_free_dma_chain); + +/** +* @brief omap_dma_chain_status - Check if the chain is in +* active / inactive state. +* @param chain_id +* +* @return - Success : OMAP_DMA_CHAIN_ACTIVE/OMAP_DMA_CHAIN_INACTIVE +* Failure : -EINVAL +*/ +int omap_dma_chain_status (int chain_id) +{ + +/* Check for input params */ +if (unlikely ((chain_id <0 || chain_id >= d->dma_lch_count))) { +printk (KERN_ERR "Invalid chain id\n" ); +return -EINVAL ; + } + +/* Check if the chain exists */ +if (dma_linked_lch[chain_id].linked_dmach_q ==NULL ) { +printk (KERN_ERR "Chain doesn't exists\n" ); +return -EINVAL ; + } +pr_debug ("CHAINID=%d, qcnt=%d\n" , chain_id, + dma_linked_lch[chain_id].q_count); + +if (OMAP_DMA_CHAIN_QEMPTY (chain_id)) +return OMAP_DMA_CHAIN_INACTIVE ; + +return OMAP_DMA_CHAIN_ACTIVE ; +} +EXPORT_SYMBOL (omap_dma_chain_status); + +/** +* @brief omap_dma_chain_a_transfer - Get a free channel from a chain, +* set the params and start the transfer. +* +* @param chain_id +* @param src_start - buffer start address +* @param dest_start - Dest address +* @param elem_count +* @param frame_count +* @param callbk_data - channel callback parameter data. +* +* @return - Success : 0 +* Failure: -EINVAL/-EBUSY +*/ +int omap_dma_chain_a_transfer (int chain_id,int src_start,int dest_start, +int elem_count,int frame_count,void *callbk_data) +{ +int *channels; +u32 reg, ch_reg_base, l, lch; +int start_dma =0 ; + +/* +* if buffer size is less than 1 then there is +* no use of starting the chain +*/ +if (elem_count <1 ) { +printk (KERN_ERR "Invalid buffer size\n" ); +return -EINVAL ; + } + +/* Check for input params */ +if (unlikely ((chain_id <0 + || chain_id >= d->dma_lch_count))) { +printk (KERN_ERR "Invalid chain id\n" ); +return -EINVAL ; + } + +/* Check if the chain exists */ +if (dma_linked_lch[chain_id].linked_dmach_q ==NULL ) { +printk (KERN_ERR "Chain doesn't exist\n" ); +return -EINVAL ; + } + +/* Check if all the channels in chain are in use */ +if (OMAP_DMA_CHAIN_QFULL (chain_id)) +return -EBUSY ; + +/* Frame count may be negative in case of indexed transfers */ + channels = dma_linked_lch[chain_id].linked_dmach_q; + +/* Get a free channel */ + lch = channels[dma_linked_lch[chain_id].q_tail]; + +/* Store the callback data */ + dma_chan[lch].data = callbk_data; + +/* Increment the q_tail */ +OMAP_DMA_CHAIN_INCQTAIL (chain_id); + + ch_reg_base = r->lch_base * lch; +/* Set the params to the free channel */ +if (src_start !=0 ) { + reg = ch_reg_base + r->ch_specific.cssa; +omap2_dma_write (src_start, reg); + } +if (dest_start !=0 ) { + reg = ch_reg_base + r->ch_specific.cdsa; +omap2_dma_write (src_start, reg); + } + +/* Write the buffer size */ + reg = ch_reg_base + r->common_ch.cen; +omap2_dma_write (elem_count, reg); + reg = ch_reg_base + r->common_ch.cfn; +omap2_dma_write (frame_count, reg); + +/* +* If the chain is dynamically linked, +* then we may have to start the chain if its not active +*/ +if (dma_linked_lch[chain_id].chain_mode ==OMAP_DMA_DYNAMIC_CHAIN ) { + +/* +* In Dynamic chain, if the chain is not started, +* queue the channel +*/ +if (dma_linked_lch[chain_id].chain_state == +DMA_CHAIN_NOTSTARTED ) { +/* Enable the link in previous channel */ +if (dma_chan[dma_chan[lch].prev_linked_ch].state == +DMA_CH_QUEUED ) +omap_enable_lnk (dma_chan[lch].prev_linked_ch); + dma_chan[lch].state =DMA_CH_QUEUED ; + } + +/* +* Chain is already started, make sure its active, +* if not then start the chain +*/ +else { + start_dma =1 ; + +if (dma_chan[dma_chan[lch].prev_linked_ch].state == +DMA_CH_STARTED ) { + ch_reg_base = r->lch_base * + dma_chan[lch].prev_linked_ch; + +omap_enable_lnk (dma_chan[lch].prev_linked_ch); + dma_chan[lch].state =DMA_CH_QUEUED ; + start_dma =0 ; + reg = ch_reg_base + r->common_ch.ccr; +if (0 == ((1 <<7 ) &omap2_dma_read (reg))) { +omap_disable_lnk (dma_chan[lch]. + prev_linked_ch); +pr_debug ("\n prev ch is stopped\n" ); + start_dma =1 ; + } + } + +else if (dma_chan[dma_chan[lch].prev_linked_ch].state + ==DMA_CH_QUEUED ) { +omap_enable_lnk (dma_chan[lch].prev_linked_ch); + dma_chan[lch].state =DMA_CH_QUEUED ; + start_dma =0 ; + } +omap_enable_channel_irq (lch); + ch_reg_base = r->lch_base * lch; + reg = ch_reg_base + r->common_ch.ccr; + l =omap2_dma_read (reg); + +if ((0 == (l & (1 <<24 )))) + l &= ~(1 <<25 ); +else + l |= (1 <<25 ); +if (start_dma ==1 ) { +if (0 == (l & (1 <<7 ))) { + l |= (1 <<7 ); + dma_chan[lch].state =DMA_CH_STARTED ; +pr_debug ("starting %d\n" , lch); +omap2_dma_write (l, reg); + }else + start_dma =0 ; + }else { +if (0 == (l & (1 <<7 ))) +omap2_dma_write (l, reg); + } + dma_chan[lch].flags |=OMAP_DMA_ACTIVE ; + } + } + +return 0 ; +} +EXPORT_SYMBOL (omap_dma_chain_a_transfer); + +/** +* @brief omap_start_dma_chain_transfers - Start the chain +* +* @param chain_id +* +* @return - Success : 0 +* Failure : -EINVAL/-EBUSY +*/ +int omap_start_dma_chain_transfers (int chain_id) +{ +int *channels; +u32 reg, ch_reg_base, l, i; + +if (unlikely ((chain_id <0 || chain_id >= d->dma_lch_count))) { +printk (KERN_ERR "Invalid chain id\n" ); +return -EINVAL ; + } + + channels = dma_linked_lch[chain_id].linked_dmach_q; + +if (dma_linked_lch[channels[0 ]].chain_state ==DMA_CHAIN_STARTED ) { +printk (KERN_ERR "Chain is already started\n" ); +return -EBUSY ; + } + +if (dma_linked_lch[chain_id].chain_mode ==OMAP_DMA_STATIC_CHAIN ) { +for (i =0 ; i < dma_linked_lch[chain_id].no_of_lchs_linked; + i++) { +omap_enable_lnk (channels[i]); +omap_enable_channel_irq (channels[i]); + } + }else { +omap_enable_channel_irq (channels[0 ]); + } + + ch_reg_base = r->lch_base * channels[0 ]; + reg = ch_reg_base + r->common_ch.ccr; + l =omap2_dma_read (reg); + l |= (1 <<7 ); + dma_linked_lch[chain_id].chain_state =DMA_CHAIN_STARTED ; + dma_chan[channels[0 ]].state =DMA_CH_STARTED ; + +if ((0 == (l & (1 <<24 )))) + l &= ~(1 <<25 ); +else + l |= (1 <<25 ); +omap2_dma_write (l, reg); + + dma_chan[channels[0 ]].flags |=OMAP_DMA_ACTIVE ; + +return 0 ; +} +EXPORT_SYMBOL (omap_start_dma_chain_transfers); + + +/** +* @brief omap_stop_dma_chain_transfers - Stop the dma transfer of a chain. +* +* @param chain_id +* +* @return - Success : 0 +* Failure : EINVAL +*/ +int omap_stop_dma_chain_transfers (int chain_id) +{ +/* Check for input params */ +if (unlikely ((chain_id <0 || + chain_id >= d->dma_lch_count))) { +printk (KERN_ERR "Invalid chain id\n" ); +return -EINVAL ; + } + +/* Check if the chain exists */ +if (dma_linked_lch[chain_id].linked_dmach_q ==NULL ) { +printk (KERN_ERR "Chain doesn't exists\n" ); +return -EINVAL ; + } + +if (omap2_pdata->errata &DMA_SYSCONFIG_ERRATA ) +dma_ocpsysconfig_errata (chain_id); + +return 0 ; +} +EXPORT_SYMBOL (omap_stop_dma_chain_transfers); + +/* Get the index of the ongoing DMA in chain */ +/** +* @brief omap_get_dma_chain_index - Get the element and frame index +* of the ongoing DMA in chain +* +* @param chain_id +* @param ei - Element index +* @param fi - Frame index +* +* @return - Success : 0 +* Failure : -EINVAL +*/ +int omap_get_dma_chain_index (int chain_id,int *ei,int *fi) +{ +int lch; +int *channels; +u32 reg; + +/* Check for input params */ +if (unlikely ((chain_id <0 || + chain_id >= d->dma_lch_count))) { +printk (KERN_ERR "Invalid chain id\n" ); +return -EINVAL ; + } + +/* Check if the chain exists */ +if (dma_linked_lch[chain_id].linked_dmach_q ==NULL ) { +printk (KERN_ERR "Chain doesn't exists\n" ); +return -EINVAL ; + } +if ((!ei) || (!fi)) +return -EINVAL ; + + channels = dma_linked_lch[chain_id].linked_dmach_q; + +/* Get the current channel */ + lch = channels[dma_linked_lch[chain_id].q_head]; + + reg = (r->lch_base * lch) + r->ch_specific.ccen; + *ei =omap2_dma_read (reg); + reg = (r->lch_base * lch) + r->ch_specific.ccfn; + *fi =omap2_dma_read (reg); + +return 0 ; +} +EXPORT_SYMBOL (omap_get_dma_chain_index); + +/** +* @brief omap_get_dma_chain_dst_pos - Get the destination position of the +* ongoing DMA in chain +* +* @param chain_id +* +* @return - Success : Destination position +* Failure : -EINVAL +*/ +int omap_get_dma_chain_dst_pos (int chain_id) +{ +int lch; +int *channels; +u32 reg; + +/* Check for input params */ +if (unlikely ((chain_id <0 || chain_id >= d->dma_lch_count))) { +printk (KERN_ERR "Invalid chain id\n" ); +return -EINVAL ; + } + +/* Check if the chain exists */ +if (dma_linked_lch[chain_id].linked_dmach_q ==NULL ) { +printk (KERN_ERR "Chain doesn't exists\n" ); +return -EINVAL ; + } + + channels = dma_linked_lch[chain_id].linked_dmach_q; + +/* Get the current channel */ + lch = channels[dma_linked_lch[chain_id].q_head]; + reg = (r->lch_base * lch) + r->common_ch.cdac; + +return omap2_dma_read (reg); +} +EXPORT_SYMBOL (omap_get_dma_chain_dst_pos); + +/** +* @brief omap_get_dma_chain_src_pos - Get the source position +* of the ongoing DMA in chain +* @param chain_id +* +* @return - Success : Destination position +* Failure : -EINVAL +*/ +int omap_get_dma_chain_src_pos (int chain_id) +{ +int lch; +int *channels; +u32 reg; + +/* Check for input params */ +if (unlikely ((chain_id <0 || chain_id >= d->dma_lch_count))) { +printk (KERN_ERR "Invalid chain id\n" ); +return -EINVAL ; + } + +/* Check if the chain exists */ +if (dma_linked_lch[chain_id].linked_dmach_q ==NULL ) { +printk (KERN_ERR "Chain doesn't exists\n" ); +return -EINVAL ; + } + + channels = dma_linked_lch[chain_id].linked_dmach_q; + +/* Get the current channel */ + lch = channels[dma_linked_lch[chain_id].q_head]; + reg = (r->lch_base * lch) + r->common_ch.csac; + +return omap2_dma_read (reg); +} +EXPORT_SYMBOL (omap_get_dma_chain_src_pos); +/* One time initializations */ static int __init omap2_system_dma_init_dev (struct omap_hwmod *oh,void *user) {
arch/arm/mach-omap2/include/mach/dma.h +27 -0
@@ -73,4 +73,31 @@#define OMAP_DMA4_CNDP (0xd4)#define OMAP_DMA4_CCDN (0xd8) +/* Chaining modes*/ +#define OMAP_DMA_STATIC_CHAIN 0x1 +#define OMAP_DMA_DYNAMIC_CHAIN 0x2 +#define OMAP_DMA_CHAIN_ACTIVE 0x1 +#define OMAP_DMA_CHAIN_INACTIVE 0x0 + +/* Chaining APIs */ +extern int omap_request_dma_chain (int dev_id,const char *dev_name, +void (*callback) (int lch,u16 ch_status, +void *data), +int *chain_id,int no_of_chans, +int chain_mode, +struct omap_dma_channel_params params); +extern int omap_free_dma_chain (int chain_id); +extern int omap_dma_chain_a_transfer (int chain_id,int src_start, +int dest_start,int elem_count, +int frame_count,void *callbk_data); +extern int omap_start_dma_chain_transfers (int chain_id); +extern int omap_stop_dma_chain_transfers (int chain_id); +extern int omap_get_dma_chain_index (int chain_id,int *ei,int *fi); +extern int omap_get_dma_chain_dst_pos (int chain_id); +extern int omap_get_dma_chain_src_pos (int chain_id); + +extern int omap_modify_dma_chain_params (int chain_id, +struct omap_dma_channel_params params); +extern int omap_dma_chain_status (int chain_id); +#endif /* __ASM_ARCH_OMAP2_DMA_H */
Signature · 1 line
1.7.0.4
RFC PATCH 8/10 OMAP: DMA: Move IRQ handlers to mach-omap
In reply to Manjunatha GKThe DMA IRQ handling is completely differnet between omap1 and omap2 plus processors hence the IRQ handlers are moved to respective dma.c in mach-omap directories.
--- arch/arm/mach-omap1/dma.c | 71 +++++++++++++++++++++++++++++ arch/arm/mach-omap2/dma.c | 111 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 182 insertions(+), 0 deletions(-)
arch/arm/mach-omap1/dma.c +71 -0
@@ -175,6 +175,77 @@ static struct omap_dma_lch *omap1_dma_chan;static void __iomem *dma_base;static int enable_1510_mode; +static int omap1_dma_handle_ch (int ch) +{ +u32 csr; +u32 reg, ch_reg_base; + + ch_reg_base = r->lch_base * ch; + +if (enable_1510_mode && ch >=6 ) { + csr = omap1_dma_chan[ch].saved_csr; + omap1_dma_chan[ch].saved_csr =0 ; + }else { + reg = ch_reg_base + r->common_ch.csr; + csr =omap1_dma_read (reg); + } +if (enable_1510_mode && ch <=2 && (csr >>7 ) !=0 ) { + omap1_dma_chan[ch +6 ].saved_csr = csr >>7 ; + csr &=0x7f ; + } +if ((csr &0x3f ) ==0 ) +return 0 ; +if (unlikely (omap1_dma_chan[ch].dev_id ==-1 )) { +printk (KERN_WARNING "Spurious interrupt from DMA channel " +"%d (CSR %04x)\n" , ch, csr); +return 0 ; + } +if (unlikely (csr &OMAP1_DMA_TOUT_IRQ )) +printk (KERN_WARNING "DMA timeout with device %d\n" , + omap1_dma_chan[ch].dev_id); +if (unlikely (csr &OMAP_DMA_DROP_IRQ )) +printk (KERN_WARNING "DMA synchronization event drop occurred " +"with device %d\n" , omap1_dma_chan[ch].dev_id); +if (likely (csr &OMAP_DMA_BLOCK_IRQ )) + omap1_dma_chan[ch].flags &= ~OMAP_DMA_ACTIVE ; + +if (likely (omap1_dma_chan[ch].callback !=NULL )) + omap1_dma_chan[ch].callback (ch, csr, omap1_dma_chan[ch].data); + +return 1 ; +} + +static irqreturn_t omap_dma_irq_handler (int irq,void *dev_id) +{ +int ch = ((int ) dev_id) -1 ; +int handled =0 ; + +for (;;) { +int handled_now =0 ; + + handled_now +=omap1_dma_handle_ch (ch); + +if (enable_1510_mode && + omap1_dma_chan[ch +6 ].saved_csr) + handled_now +=omap1_dma_handle_ch (ch +6 ); + +if (!handled_now) +break ; + handled += handled_now; + } +return handled ?IRQ_HANDLED :IRQ_NONE ; +} + +static int dma_irq_register (int dma_irq,int irq_count, +void __iomem *omap_dma_base,struct omap_dma_lch *dma_chan) +{ +int ret =request_irq (dma_irq, omap_dma_irq_handler,0 ,"DMA" , + (void *) (irq_count+1 )); + dma_base = omap_dma_base; + omap1_dma_chan = dma_chan; +return ret; +} +static int __init omap1_system_dma_init (void ) {struct platform_device *pdev;
arch/arm/mach-omap2/dma.c +111 -0
117 lines not on this page · raw message
Signature · 1 line
1.7.0.4
RFC PATCH 9/10 OMAP: DMA: API's Clean up
In reply to Manjunatha GKThis patch will clean up API's in plat-omap dma library
The API's are cleaned up for eliminating cpu_is_xxxx
checks and machine specific API/code is moved to corresponding mach-omap directories.
Note: The code in plat-omap dma library will be removed in another patch. This is to avoid build break.
--- arch/arm/mach-omap1/dma.c | 253 ++++++++++++++++++++++++++++++++++++++ arch/arm/mach-omap2/dma.c | 296 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 548 insertions(+), 1 deletions(-)
arch/arm/mach-omap1/dma.c +253 -0
@@ -170,11 +170,149 @@ static struct omap_dma_reg_offset dma_reg_offset[] = { };struct omap_dma_reg_offset *r = (struct omap_dma_reg_offset *)&dma_reg_offset; +static inline void enable_lnk (int lch); +static inline void disable_lnk (int lch); +static inline void omap_enable_channel_irq (int lch); +static irqreturn_t omap_dma_irq_handler (int irq,void *dev_id);static struct omap_dma_lch *omap1_dma_chan;static void __iomem *dma_base;static int enable_1510_mode; +static inline int get_gdma_dev (int req) +{ +u32 reg =OMAP_FUNC_MUX_ARM_BASE + ((req -1 ) /5 ) *4 ; +int shift = ((req -1 ) %5 ) *6 ; + +return ((omap_readl (reg) >> shift) &0x3f ) +1 ; +} + +static inline void set_gdma_dev (int req,int dev) +{ +u32 reg =OMAP_FUNC_MUX_ARM_BASE + ((req -1 ) /5 ) *4 ; +int shift = ((req -1 ) %5 ) *6 ; +u32 l; + + l =omap_readl (reg); + l &= ~(0x3f << shift); + l |= (dev -1 ) << shift; +omap_writel (l, reg); +} + +static void sync_device_set (int dev_id,int free_ch) +{ +u32 reg; + + reg = (r->lch_base * free_ch) + r->common_ch.ccr; +if (cpu_is_omap16xx ()) { +/* If the sync device is set, configure it dynamically. */ +if (dev_id !=0 ) { +set_gdma_dev (free_ch +1 , dev_id); + dev_id = free_ch +1 ; + } +/* +* Disable the 1510 compatibility mode and set the sync device +* id. +*/ +omap1_dma_write (dev_id | (1 <<10 ), reg); + }else if (cpu_is_omap7xx () ||cpu_is_omap15xx ()) { +omap1_dma_write (dev_id, reg); + } +} + +static inline void omap_enable_channel_irq (int lch) +{ +u32 reg; + +/* Clear CSR */ + reg = (r->lch_base * lch) + r->common_ch.csr; +omap1_dma_read (reg); + +/* Enable some nice interrupts. */ + reg = (r->lch_base * lch) + r->common_ch.cicr; +omap1_dma_write (omap1_dma_chan[lch].enabled_irqs, reg); +} + +static inline void enable_lnk (int lch) +{ +u32 reg, l; + + reg = (r->lch_base * lch) + r->common_ch.clnk_ctrl; + l =omap1_dma_read (reg); + +if (omap1_dma_chan[lch].next_linked_ch !=-1 ) + l = omap1_dma_chan[lch].next_linked_ch | (1 <<15 ); + +/* Set the ENABLE_LNK bits */ +if (omap1_dma_chan[lch].next_lch !=-1 ) + l = omap1_dma_chan[lch].next_lch | (1 <<15 ); + +omap1_dma_write (l, reg); +} + +static inline void disable_lnk (int lch) +{ +u32 reg, l; + + reg = (r->lch_base * lch) + r->common_ch.clnk_ctrl; + l =omap1_dma_read (reg); + +/* Clear CSR */ + reg = (r->lch_base * lch) + r->common_ch.cicr; +omap1_dma_write (0 , reg); + +/* Clear the ENABLE_LNK bit */ + l &= ~(1 <<15 ); + + reg = (r->lch_base * lch) + r->common_ch.clnk_ctrl; +omap1_dma_write (l, reg); + omap1_dma_chan[lch].flags &= ~OMAP_DMA_ACTIVE ; +} + +static void clear_lch_regs (int lch) +{ +int reg_count; +u32 ch_reg_base, reg; + + ch_reg_base = r->lch_base * lch; + +for (reg_count =0 ; reg_count <0x2c ; reg_count +=2 ) { + reg = ch_reg_base + reg_count; +omap1_dma_write (0 , reg); + } +} + +static void clear_ccr_csr (int lch) +{ +u32 reg; +int l; + + reg = (r->lch_base * lch) + r->common_ch.ccr; + l =omap1_dma_read (reg); + l &= ~OMAP_DMA_CCR_EN ; +omap1_dma_write (l, reg); + +/* Clear pending interrupts */ + reg = r->lch_base + r->common_ch.csr; +omap1_dma_read (reg); +} + +static int set_prio_lch (int lch,unsigned char read_prio, +unsigned char write_prio) +{ +u32 l =0 ; + l |= ((read_prio &0x1 ) <<6 ); +return l; +} + +static int dma_running (int dma_chan_count) +{ +if (omap_lcd_dma_running ()) +return 1 ; + +return 0 ; +} +static int omap1_dma_handle_ch (int ch) {u32 csr;
@@ -246,6 +384,121 @@ static int dma_irq_register(int dma_irq, int irq_count,return ret; } +void omap_set_dma_priority (int lch,int dst_port,int priority) +{ +unsigned long reg; +u32 l; + +switch (dst_port) { +case OMAP_DMA_PORT_OCP_T1 :/* FFFECC00 */ + reg =OMAP_TC_OCPT1_PRIOR ; +break ; +case OMAP_DMA_PORT_OCP_T2 :/* FFFECCD0 */ + reg =OMAP_TC_OCPT2_PRIOR ; +break ; +case OMAP_DMA_PORT_EMIFF :/* FFFECC08 */ + reg =OMAP_TC_EMIFF_PRIOR ; +break ; +case OMAP_DMA_PORT_EMIFS :/* FFFECC04 */ + reg =OMAP_TC_EMIFS_PRIOR ; +break ; +default : +BUG (); +return ; + } + l =omap_readl (reg); + l &= ~(0xf <<8 ); + l |= (priority &0xf ) <<8 ; +omap_writel (l, reg); +} +EXPORT_SYMBOL (omap_set_dma_priority); + +void omap_set_dma_transfer_params (int lch,int data_type,int elem_count, +int frame_count,int sync_mode, +int dma_trigger,int src_or_dst_synch) +{ +u32 reg, l; +u16 ccr; + + reg = (r->lch_base * lch) + r->common_ch.csdp; + l =omap1_dma_read (reg); + l &= ~0x03 ; + l |= data_type; +omap1_dma_write (l, reg); + + reg = (r->lch_base * lch) + r->common_ch.ccr; + ccr =omap1_dma_read (reg); + ccr &= ~(1 <<5 ); +if (sync_mode ==OMAP_DMA_SYNC_FRAME ) + ccr |=1 <<5 ; +omap1_dma_write (ccr, reg); + + reg = (r->lch_base * lch) + r->ch_specific.ccr2; + ccr =omap1_dma_read (reg); + ccr &= ~(1 <<2 ); +if (sync_mode ==OMAP_DMA_SYNC_BLOCK ) + ccr |=1 <<2 ; +omap1_dma_write (ccr, reg); +} +EXPORT_SYMBOL (omap_set_dma_transfer_params); + +void set_dma_color_mode (int lch, +enum omap_dma_color_mode mode,u32 color) +{ +u32 reg; +u16 w; + +BUG_ON (enable_1510_mode); + + reg = (r->lch_base * lch) + r->ch_specific.ccr2; + w =omap1_dma_read (reg); + w &= ~0x03 ; + +switch (mode) { +case OMAP_DMA_CONSTANT_FILL : + w |=0x01 ; +break ; +case OMAP_DMA_TRANSPARENT_COPY : + w |=0x02 ; +break ; +case OMAP_DMA_COLOR_DIS : +break ; +default : +BUG (); + } +omap1_dma_write (w, reg); + + reg = (r->lch_base * lch) + r->ch_specific.lch_ctrl; + w =omap1_dma_read (reg); + w &= ~0x0f ; +/* Default is channel type 2D */ +if (mode) { + reg = (r->lch_base * lch) + r->ch_specific.color_l; +omap1_dma_write ((u16 )color, reg); + reg = (r->lch_base * lch) + r->ch_specific.color_u; +omap1_dma_write ((u16 )color >>16 , reg); + w |=1 ;/* Channel type G */ + } + reg = (r->lch_base * lch) + r->ch_specific.lch_ctrl; +omap1_dma_write (w, reg); +} +EXPORT_SYMBOL (set_dma_color_mode); + +void omap_set_dma_channel_mode (int lch,enum omap_dma_channel_mode mode) +{ +u32 reg; + +if (!enable_1510_mode) { +u32 l; + reg = (r->lch_base * lch) + r->ch_specific.lch_ctrl; + l =omap1_dma_read (reg); + l &= ~0x7 ; + l |= mode; +omap1_dma_write (l, reg); + } +} +EXPORT_SYMBOL (omap_set_dma_channel_mode); +static int __init omap1_system_dma_init (void ) {struct platform_device *pdev;
arch/arm/mach-omap2/dma.c +295 -1
318 lines not on this page · raw message
Signature · 1 line
1.7.0.4
RFC PATCH 10/10 OMAP: DMA: Cleanup DMA library and enable DMA platform driver
In reply to Manjunatha GKThis patch will cleanup DMA library in plat-omap and converts the the same into platform driver and makes use of hwmod database and structures for DMA configuration. As a part of platform driver conversion and hwmod support, the API's are cleaned up so that cpu_is_xxxx checks are eliminated and corresponding API/source code is moved to machine specific directories.
--- arch/arm/mach-omap1/Makefile | 2 +- arch/arm/mach-omap2/Makefile | 2 +- arch/arm/plat-omap/dma.c | 1968 +++++++-------------------------- arch/arm/plat-omap/include/plat/dma.h | 320 ++---- 4 files changed, 465 insertions(+), 1827 deletions(-)
arch/arm/mach-omap1/Makefile +1 -1
@@ -3,7 +3,7 @@ # # Common support -obj-y := io.o id.o sram.o irq.o mux.o flash.o serial.o devices.o +obj-y := io.o id.o sram.o irq.o mux.o flash.o serial.o devices.o dma.o obj-y += clock.o clock_data.o opp_data.o obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
arch/arm/mach-omap2/Makefile +1 -1
@@ -3,7 +3,7 @@ # # Common support -obj-y := id.o io.o control.o mux.o devices.o serial.o gpmc.o timer-gp.o +obj-y := id.o io.o control.o mux.o devices.o serial.o gpmc.o timer-gp.o dma.o omap-2-3-common = irq.o sdrc.o hwmod-common = omap_hwmod.o \
arch/arm/plat-omap/dma.c +379 -1589
2,379 lines not on this page · raw message
arch/arm/plat-omap/include/plat/dma.h +84 -236
346 lines not on this page · raw message
Signature · 1 line
1.7.0.4