Omap upstream patches for post 2.6.26
Subsystems (12)
A message that is not in the archive (sent off-list or not yet received): omap-upstream-2008-06-06-183049
Tony Lindgren
maintainercover Omap upstream patches for post 2.6.26
Hi all,
The following series updates common omap code for timers, DMA, and McBSP. It also cleans up clock and power register acces and prepares things to get omap2 and omap3 support compiled into the same kernel.
This patch series also available via git at:
git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap-2.6.git omap-upstream
Regards,
Tony
-------------------------------------------------------------------
List admin: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm-kernel FAQ: http://www.arm.linux.org.uk/mailinglists/faq.php Etiquette: http://www.arm.linux.org.uk/mailinglists/etiquette.php
Tony Lindgren
maintainerPATCH 1/21 ARM: OMAP: DMTimer: Use posted mode
From: Richard Woodruff <[email protected]>
This patch adds the use of write posting for the timer. Previously, every write could lock the requestor for almost 3x32KHz cycles. This patch only synchronizes before writes and reads instead of after them and it does
it on per register basis. Doing it this way there is some chance to hide some of the sync latency. It also removes some needless reads when non-posted mode is there. With out this fix the read/writes take almost
2% CPU load @500MHz just waiting on tick timer registers.
Also define new 34xx only registers.
arch/arm/plat-omap/dmtimer.c +151 -42
@@ -38,34 +38,113 @@#include <asm/arch/irqs.h> /* register offsets */ -#define OMAP_TIMER_ID_REG 0x00 -#define OMAP_TIMER_OCP_CFG_REG 0x10 -#define OMAP_TIMER_SYS_STAT_REG 0x14 -#define OMAP_TIMER_STAT_REG 0x18 -#define OMAP_TIMER_INT_EN_REG 0x1c -#define OMAP_TIMER_WAKEUP_EN_REG 0x20 -#define OMAP_TIMER_CTRL_REG 0x24 -#define OMAP_TIMER_COUNTER_REG 0x28 -#define OMAP_TIMER_LOAD_REG 0x2c -#define OMAP_TIMER_TRIGGER_REG 0x30 -#define OMAP_TIMER_WRITE_PEND_REG 0x34 -#define OMAP_TIMER_MATCH_REG 0x38 -#define OMAP_TIMER_CAPTURE_REG 0x3c -#define OMAP_TIMER_IF_CTRL_REG 0x40 - -/* timer control reg bits */ -#define OMAP_TIMER_CTRL_GPOCFG (1 << 14) -#define OMAP_TIMER_CTRL_CAPTMODE (1 << 13) -#define OMAP_TIMER_CTRL_PT (1 << 12) -#define OMAP_TIMER_CTRL_TCM_LOWTOHIGH (0x1 << 8) -#define OMAP_TIMER_CTRL_TCM_HIGHTOLOW (0x2 << 8) -#define OMAP_TIMER_CTRL_TCM_BOTHEDGES (0x3 << 8) -#define OMAP_TIMER_CTRL_SCPWM (1 << 7) -#define OMAP_TIMER_CTRL_CE (1 << 6)/* compare enable */ -#define OMAP_TIMER_CTRL_PRE (1 << 5)/* prescaler enable */ -#define OMAP_TIMER_CTRL_PTV_SHIFT 2/* how much to shift the prescaler value */ -#define OMAP_TIMER_CTRL_AR (1 << 1)/* auto-reload enable */ -#define OMAP_TIMER_CTRL_ST (1 << 0)/* start timer */ +#define _OMAP_TIMER_ID_OFFSET 0x00 +#define _OMAP_TIMER_OCP_CFG_OFFSET 0x10 +#define _OMAP_TIMER_SYS_STAT_OFFSET 0x14 +#define _OMAP_TIMER_STAT_OFFSET 0x18 +#define _OMAP_TIMER_INT_EN_OFFSET 0x1c +#define _OMAP_TIMER_WAKEUP_EN_OFFSET 0x20 +#define _OMAP_TIMER_CTRL_OFFSET 0x24 +#define OMAP_TIMER_CTRL_GPOCFG (1 << 14) +#define OMAP_TIMER_CTRL_CAPTMODE (1 << 13) +#define OMAP_TIMER_CTRL_PT (1 << 12) +#define OMAP_TIMER_CTRL_TCM_LOWTOHIGH (0x1 << 8) +#define OMAP_TIMER_CTRL_TCM_HIGHTOLOW (0x2 << 8) +#define OMAP_TIMER_CTRL_TCM_BOTHEDGES (0x3 << 8) +#define OMAP_TIMER_CTRL_SCPWM (1 << 7) +#define OMAP_TIMER_CTRL_CE (1 << 6)/* compare enable */ +#define OMAP_TIMER_CTRL_PRE (1 << 5)/* prescaler enable */ +#define OMAP_TIMER_CTRL_PTV_SHIFT 2/* prescaler value shift */ +#define OMAP_TIMER_CTRL_POSTED (1 << 2) +#define OMAP_TIMER_CTRL_AR (1 << 1)/* auto-reload enable */ +#define OMAP_TIMER_CTRL_ST (1 << 0)/* start timer */ +#define _OMAP_TIMER_COUNTER_OFFSET 0x28 +#define _OMAP_TIMER_LOAD_OFFSET 0x2c +#define _OMAP_TIMER_TRIGGER_OFFSET 0x30 +#define _OMAP_TIMER_WRITE_PEND_OFFSET 0x34 +#define WP_NONE 0/* no write pending bit */ +#define WP_TCLR (1 << 0) +#define WP_TCRR (1 << 1) +#define WP_TLDR (1 << 2) +#define WP_TTGR (1 << 3) +#define WP_TMAR (1 << 4) +#define WP_TPIR (1 << 5) +#define WP_TNIR (1 << 6) +#define WP_TCVR (1 << 7) +#define WP_TOCR (1 << 8) +#define WP_TOWR (1 << 9) +#define _OMAP_TIMER_MATCH_OFFSET 0x38 +#define _OMAP_TIMER_CAPTURE_OFFSET 0x3c +#define _OMAP_TIMER_IF_CTRL_OFFSET 0x40 +#define _OMAP_TIMER_CAPTURE2_OFFSET 0x44/* TCAR2, 34xx only */ +#define _OMAP_TIMER_TICK_POS_OFFSET 0x48/* TPIR, 34xx only */ +#define _OMAP_TIMER_TICK_NEG_OFFSET 0x4c/* TNIR, 34xx only */ +#define _OMAP_TIMER_TICK_COUNT_OFFSET 0x50/* TCVR, 34xx only */ +#define _OMAP_TIMER_TICK_INT_MASK_SET_OFFSET 0x54/* TOCR, 34xx only */ +#define _OMAP_TIMER_TICK_INT_MASK_COUNT_OFFSET 0x58/* TOWR, 34xx only */ + +/* register offsets with the write pending bit encoded */ +#define WPSHIFT 16 + +#define OMAP_TIMER_ID_REG (_OMAP_TIMER_ID_OFFSET \ + | (WP_NONE << WPSHIFT)) + +#define OMAP_TIMER_OCP_CFG_REG (_OMAP_TIMER_OCP_CFG_OFFSET \ + | (WP_NONE << WPSHIFT)) + +#define OMAP_TIMER_SYS_STAT_REG (_OMAP_TIMER_SYS_STAT_OFFSET \ + | (WP_NONE << WPSHIFT)) + +#define OMAP_TIMER_STAT_REG (_OMAP_TIMER_STAT_OFFSET \ + | (WP_NONE << WPSHIFT)) + +#define OMAP_TIMER_INT_EN_REG (_OMAP_TIMER_INT_EN_OFFSET \ + | (WP_NONE << WPSHIFT)) + +#define OMAP_TIMER_WAKEUP_EN_REG (_OMAP_TIMER_WAKEUP_EN_OFFSET \ + | (WP_NONE << WPSHIFT)) + +#define OMAP_TIMER_CTRL_REG (_OMAP_TIMER_CTRL_OFFSET \ + | (WP_TCLR << WPSHIFT)) + +#define OMAP_TIMER_COUNTER_REG (_OMAP_TIMER_COUNTER_OFFSET \ + | (WP_TCRR << WPSHIFT)) + +#define OMAP_TIMER_LOAD_REG (_OMAP_TIMER_LOAD_OFFSET \ + | (WP_TLDR << WPSHIFT)) + +#define OMAP_TIMER_TRIGGER_REG (_OMAP_TIMER_TRIGGER_OFFSET \ + | (WP_TTGR << WPSHIFT)) + +#define OMAP_TIMER_WRITE_PEND_REG (_OMAP_TIMER_WRITE_PEND_OFFSET \ + | (WP_NONE << WPSHIFT)) + +#define OMAP_TIMER_MATCH_REG (_OMAP_TIMER_MATCH_OFFSET \ + | (WP_TMAR << WPSHIFT)) + +#define OMAP_TIMER_CAPTURE_REG (_OMAP_TIMER_CAPTURE_OFFSET \ + | (WP_NONE << WPSHIFT)) + +#define OMAP_TIMER_IF_CTRL_REG (_OMAP_TIMER_IF_CTRL_OFFSET \ + | (WP_NONE << WPSHIFT)) + +#define OMAP_TIMER_CAPTURE2_REG (_OMAP_TIMER_CAPTURE2_OFFSET \ + | (WP_NONE << WPSHIFT)) + +#define OMAP_TIMER_TICK_POS_REG (_OMAP_TIMER_TICK_POS_OFFSET \ + | (WP_TPIR << WPSHIFT)) + +#define OMAP_TIMER_TICK_NEG_REG (_OMAP_TIMER_TICK_NEG_OFFSET \ + | (WP_TNIR << WPSHIFT)) + +#define OMAP_TIMER_TICK_COUNT_REG (_OMAP_TIMER_TICK_COUNT_OFFSET \ + | (WP_TCVR << WPSHIFT)) + +#define OMAP_TIMER_TICK_INT_MASK_SET_REG \ + (_OMAP_TIMER_TICK_INT_MASK_SET_OFFSET | (WP_TOCR << WPSHIFT)) + +#define OMAP_TIMER_TICK_INT_MASK_COUNT_REG \ + (_OMAP_TIMER_TICK_INT_MASK_COUNT_OFFSET | (WP_TOWR << WPSHIFT))struct omap_dm_timer {unsigned long phys_base;
@@ -76,6 +155,7 @@ struct omap_dm_timer {void __iomem *io_base; unsigned reserved:1; unsigned enabled:1; + unsigned posted:1; };#ifdef CONFIG_ARCH_OMAP1
@@ -181,16 +261,34 @@ static struct clk **dm_source_clocks;static spinlock_t dm_timer_lock; -static inline u32 omap_dm_timer_read_reg (struct omap_dm_timer *timer,int reg) +/* +* Reads timer registers in posted and non-posted mode. The posted mode bit +* is encoded in reg. Note that in posted mode write pending bit must be +* checked. Otherwise a read of a non completed write will produce an error. +*/ +static inline u32 omap_dm_timer_read_reg (struct omap_dm_timer *timer,u32 reg) { -return readl (timer->io_base + reg); +if (timer->posted) +while (readl (timer->io_base + (OMAP_TIMER_WRITE_PEND_REG &0xff )) + & (reg >>WPSHIFT )) +cpu_relax (); +return readl (timer->io_base + (reg &0xff )); } -static void omap_dm_timer_write_reg (struct omap_dm_timer *timer,int reg,u32 value) +/* +* Writes timer registers in posted and non-posted mode. The posted mode bit +* is encoded in reg. Note that in posted mode the write pending bit must be +* checked. Otherwise a write on a register which has a pending write will be +* lost. +*/ +static void omap_dm_timer_write_reg (struct omap_dm_timer *timer,u32 reg, +u32 value) { -writel (value, timer->io_base + reg); -while (omap_dm_timer_read_reg (timer,OMAP_TIMER_WRITE_PEND_REG )) - ; +if (timer->posted) +while (readl (timer->io_base + (OMAP_TIMER_WRITE_PEND_REG &0xff )) + & (reg >>WPSHIFT )) +cpu_relax (); +writel (value, timer->io_base + (reg &0xff )); }static void omap_dm_timer_wait_for_reset (struct omap_dm_timer *timer)
@@ -217,17 +315,23 @@ static void omap_dm_timer_reset(struct omap_dm_timer *timer) }omap_dm_timer_set_source (timer,OMAP_TIMER_SRC_32_KHZ ); -/* Set to smart-idle mode */ l =omap_dm_timer_read_reg (timer,OMAP_TIMER_OCP_CFG_REG ); - l |=0x02 <<3 ; - -if (cpu_class_is_omap2 () && timer == &dm_timers[0 ]) { -/* Enable wake-up only for GPT1 on OMAP2 CPUs*/ + l |=0x02 <<3 ;/* Set to smart-idle mode */ + l |=0x2 <<8 ;/* Set clock activity to perserve f-clock on idle */ + +/* +* Enable wake-up only for GPT1 on OMAP2 CPUs. +* FIXME: All timers should have wake-up enabled and clear +* PRCM status. +*/ +if (cpu_class_is_omap2 () && (timer == &dm_timers[0 ])) l |=1 <<2 ; -/* Non-posted mode */ -omap_dm_timer_write_reg (timer,OMAP_TIMER_IF_CTRL_REG ,0 ); - }omap_dm_timer_write_reg (timer,OMAP_TIMER_OCP_CFG_REG , l); + +/* Match hardware reset default of posted mode */ +omap_dm_timer_write_reg (timer,OMAP_TIMER_IF_CTRL_REG , +OMAP_TIMER_CTRL_POSTED ); + timer->posted =1 ; }static void omap_dm_timer_prepare (struct omap_dm_timer *timer)
@@ -434,6 +538,11 @@ void omap_dm_timer_set_load(struct omap_dm_timer *timer, int autoreload, l &= ~OMAP_TIMER_CTRL_AR ;omap_dm_timer_write_reg (timer,OMAP_TIMER_CTRL_REG , l);omap_dm_timer_write_reg (timer,OMAP_TIMER_LOAD_REG , load); + +/* REVISIT: hw feature, ttgr overtaking tldr? */ +while (readl (timer->io_base + (OMAP_TIMER_WRITE_PEND_REG &0xff ))) +cpu_relax (); +omap_dm_timer_write_reg (timer,OMAP_TIMER_TRIGGER_REG ,0 ); }
Tony Lindgren
maintainerPATCH 2/21 ARM: OMAP: DMTimer: Optimize by adding load and start
From: Richard Woodruff <[email protected]>
This patch optimizes the timer load and start sequence. By combining the load and start a needless posted wait can be removed from the system timer execution path.
* Before patch register writes are taking up .078% @ 500MHz during idle.
Address |total |min |max |avr |count|ratio%
old\process\default_idle|7.369s |0.0us|999.902ms|14.477ms|509. |62.661%
ld\Global\cpu_v7_do_idle|4.265s |0.0us|375.786ms|24.374ms|175. |36.270%
(UNKNOWN)|17.503ms|0.us|531.080us|5.119us|3419. |0.148%
r\omap_dm_timer_set_load|8.135ms|0.0us|79.887us|15.065us|540. |0.069% <--
\vmlinux-old\Global\_end|2.023ms|0.0us|4.000us|0.560us|3613. |0.017%
-old\Global\__raw_readsw|1.962ms|0.0us|108.610us|9.167us|214. |0.016%
old\smc91x\smc_interrupt|1.353ms|0.0us|10.212us|2.348us|576. |0.011%
s/namei\__link_path_walk|1.161ms|0.0us|4.310us|0.762us| 1524. |0.009%
\omap_dm_timer_write_reg|1.085ms|0.0us|126.150us|2.153us|504. |0.009% <--* After patch timer functions do not show up in top listings for long captures.
arch/arm/mach-omap2/timer-gp.c +3 -6
@@ -59,8 +59,7 @@ static struct irqaction omap2_gp_timer_irq = {static int omap2_gp_timer_set_next_event (unsigned long cycles,struct clock_event_device *evt) { -omap_dm_timer_set_load (gptimer,0 ,0xffffffff - cycles); -omap_dm_timer_start (gptimer); +omap_dm_timer_set_load_start (gptimer,0 ,0xffffffff - cycles);return 0 ; }
@@ -77,8 +76,7 @@ static void omap2_gp_timer_set_mode(enum clock_event_mode mode, period =clk_get_rate (omap_dm_timer_get_fclk (gptimer)) /HZ ; period -=1 ; -omap_dm_timer_set_load (gptimer,1 ,0xffffffff - period); -omap_dm_timer_start (gptimer); +omap_dm_timer_set_load_start (gptimer,1 ,0xffffffff - period);break ;case CLOCK_EVT_MODE_ONESHOT :break ;
@@ -172,8 +170,7 @@ static void __init omap2_gp_clocksource_init(void) tick_rate =clk_get_rate (omap_dm_timer_get_fclk (gpt)); tick_period = (tick_rate /HZ ) -1 ; -omap_dm_timer_set_load (gpt,1 ,0 ); -omap_dm_timer_start (gpt); +omap_dm_timer_set_load_start (gpt,1 ,0 ); clocksource_gpt.mult =clocksource_khz2mult (tick_rate/1000 , clocksource_gpt.shift);
arch/arm/plat-omap/dmtimer.c +18 -1
@@ -546,6 +546,24 @@ void omap_dm_timer_set_load(struct omap_dm_timer *timer, int autoreload,omap_dm_timer_write_reg (timer,OMAP_TIMER_TRIGGER_REG ,0 ); } +/* Optimized set_load which removes costly spin wait in timer_start */ +void omap_dm_timer_set_load_start (struct omap_dm_timer *timer,int autoreload, +unsigned int load) +{ +u32 l; + + l =omap_dm_timer_read_reg (timer,OMAP_TIMER_CTRL_REG ); +if (autoreload) + l |=OMAP_TIMER_CTRL_AR ; +else + l &= ~OMAP_TIMER_CTRL_AR ; + l |=OMAP_TIMER_CTRL_ST ; + +omap_dm_timer_write_reg (timer,OMAP_TIMER_COUNTER_REG , load); +omap_dm_timer_write_reg (timer,OMAP_TIMER_LOAD_REG , load); +omap_dm_timer_write_reg (timer,OMAP_TIMER_CTRL_REG , l); +} +void omap_dm_timer_set_match (struct omap_dm_timer *timer,int enable,unsigned int match) {
@@ -560,7 +578,6 @@ void omap_dm_timer_set_match(struct omap_dm_timer *timer, int enable,omap_dm_timer_write_reg (timer,OMAP_TIMER_MATCH_REG , match); } -void omap_dm_timer_set_pwm (struct omap_dm_timer *timer,int def_on,int toggle,int trigger) {
include/asm-arm/arch-omap/dmtimer.h +1 -0
@@ -66,6 +66,7 @@ void omap_dm_timer_stop(struct omap_dm_timer *timer);void omap_dm_timer_set_source (struct omap_dm_timer *timer,int source);void omap_dm_timer_set_load (struct omap_dm_timer *timer,int autoreload,unsigned int value); +void omap_dm_timer_set_load_start (struct omap_dm_timer *timer,int autoreload,unsigned int value);void omap_dm_timer_set_match (struct omap_dm_timer *timer,int enable,unsigned int match);void omap_dm_timer_set_pwm (struct omap_dm_timer *timer,int def_on,int toggle,int trigger);void omap_dm_timer_set_prescaler (struct omap_dm_timer *timer,int prescaler);
Tony Lindgren
maintainerPATCH 3/21 ARM: OMAP: Add OMAP3430 base defines
From: Paul Walmsley <[email protected]>
Add symbolic constants for OMAP3430 base addresses; include that file in hardware.h.
include/asm-arm/arch-omap/hardware.h +1 -0
@@ -284,6 +284,7 @@#include "omap1510.h" #include "omap24xx.h" #include "omap16xx.h" +#include "omap34xx.h" #ifndef __ASSEMBLER__
include/asm-arm/arch-omap/omap34xx.h new file +73 -0
73 lines not on this page · raw message
Tony Lindgren
maintainerPATCH 4/21 ARM: OMAP: DMA: Make channels dynamic for multi-boot
Make DMA channels dynamic for multi-boot
arch/arm/plat-omap/dma.c +41 -21
@@ -72,7 +72,6 @@ struct omap_dma_lch {long flags; }; -#ifndef CONFIG_ARCH_OMAP1struct dma_link_info {int *linked_dmach_q;int no_of_lchs_linked;
@@ -86,7 +85,9 @@ struct dma_link_info { }; -static struct dma_link_info dma_linked_lch[OMAP_LOGICAL_DMA_CH_COUNT ]; +static struct dma_link_info *dma_linked_lch; + +#ifndef CONFIG_ARCH_OMAP1 /* Chain handling macros */ #define OMAP_DMA_CHAIN_QINIT (chain_id) \
@@ -119,12 +120,14 @@ static struct dma_link_info dma_linked_lch[OMAP_LOGICAL_DMA_CH_COUNT]; dma_linked_lch[chain_id].q_count++; \ } while (0) #endif + +static int dma_lch_count; static int dma_chan_count; static spinlock_t dma_chan_lock; -static struct omap_dma_lch dma_chan[OMAP_LOGICAL_DMA_CH_COUNT]; +static struct omap_dma_lch *dma_chan; -static const u8 omap1_dma_irq[OMAP_LOGICAL_DMA_CH_COUNT] = { +static const u8 omap1_dma_irq[OMAP1_LOGICAL_DMA_CH_COUNT] = { INT_DMA_CH0_6, INT_DMA_CH1_7, INT_DMA_CH2_8, INT_DMA_CH3, INT_DMA_CH4, INT_DMA_CH5, INT_1610_DMA_CH6, INT_1610_DMA_CH7, INT_1610_DMA_CH8, INT_1610_DMA_CH9, INT_1610_DMA_CH10,
@@ -727,7 +730,7 @@ omap_dma_set_prio_lch(int lch, unsigned char read_prio, {u32 w; -if (unlikely ((lch <0 || lch >=OMAP_LOGICAL_DMA_CH_COUNT ))) { +if (unlikely ((lch <0 || lch >= dma_lch_count))) {printk (KERN_ERR "Invalid channel id\n" );return -EINVAL ; }
@@ -775,7 +778,7 @@ void omap_start_dma(int lch) {if (!omap_dma_in_1510_mode () && dma_chan[lch].next_lch !=-1 ) {int next_lch, cur_lch; -char dma_chan_link_map[OMAP_LOGICAL_DMA_CH_COUNT ]; +char dma_chan_link_map[OMAP_DMA4_LOGICAL_DMA_CH_COUNT ]; dma_chan_link_map[lch] =1 ;/* Set the link register of the first channel */
@@ -819,7 +822,7 @@ void omap_stop_dma(int lch) {if (!omap_dma_in_1510_mode () && dma_chan[lch].next_lch !=-1 ) {int next_lch, cur_lch = lch; -char dma_chan_link_map[OMAP_LOGICAL_DMA_CH_COUNT ]; +char dma_chan_link_map[OMAP_DMA4_LOGICAL_DMA_CH_COUNT ];memset (dma_chan_link_map,0 ,sizeof (dma_chan_link_map)); do {
@@ -1061,7 +1064,7 @@ int omap_request_dma_chain(int dev_id, const char *dev_name, }if (unlikely ((no_of_chans <1 - || no_of_chans >OMAP_LOGICAL_DMA_CH_COUNT ))) { + || no_of_chans > dma_lch_count))) {printk (KERN_ERR "Invalid Number of channels requested\n" );return -EINVAL ; }
@@ -1138,7 +1141,7 @@ int omap_modify_dma_chain_params(int chain_id,/* Check for input params */ if (unlikely ((chain_id <0 - || chain_id >=OMAP_LOGICAL_DMA_CH_COUNT ))) { + || chain_id >= dma_lch_count))) {printk (KERN_ERR "Invalid chain id\n" );return -EINVAL ; }
@@ -1176,7 +1179,7 @@ int omap_free_dma_chain(int chain_id)u32 i;/* Check for input params */ -if (unlikely ((chain_id <0 || chain_id >=OMAP_LOGICAL_DMA_CH_COUNT ))) { +if (unlikely ((chain_id <0 || chain_id >= dma_lch_count))) {printk (KERN_ERR "Invalid chain id\n" );return -EINVAL ; }
@@ -1216,7 +1219,7 @@ EXPORT_SYMBOL(omap_free_dma_chain);int omap_dma_chain_status (int chain_id) {/* Check for input params */ -if (unlikely ((chain_id <0 || chain_id >=OMAP_LOGICAL_DMA_CH_COUNT ))) { +if (unlikely ((chain_id <0 || chain_id >= dma_lch_count))) {printk (KERN_ERR "Invalid chain id\n" );return -EINVAL ; }
@@ -1265,7 +1268,7 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start,/* Check for input params */ if (unlikely ((chain_id <0 - || chain_id >=OMAP_LOGICAL_DMA_CH_COUNT ))) { + || chain_id >= dma_lch_count))) {printk (KERN_ERR "Invalid chain id\n" );return -EINVAL ; }
@@ -1382,7 +1385,7 @@ int omap_start_dma_chain_transfers(int chain_id)int *channels;u32 w, i; -if (unlikely ((chain_id <0 || chain_id >=OMAP_LOGICAL_DMA_CH_COUNT ))) { +if (unlikely ((chain_id <0 || chain_id >= dma_lch_count))) {printk (KERN_ERR "Invalid chain id\n" );return -EINVAL ; }
@@ -1435,7 +1438,7 @@ int omap_stop_dma_chain_transfers(int chain_id)u32 sys_cf;/* Check for input params */ -if (unlikely ((chain_id <0 || chain_id >=OMAP_LOGICAL_DMA_CH_COUNT ))) { +if (unlikely ((chain_id <0 || chain_id >= dma_lch_count))) {printk (KERN_ERR "Invalid chain id\n" );return -EINVAL ; }
@@ -1497,7 +1500,7 @@ int omap_get_dma_chain_index(int chain_id, int *ei, int *fi)int *channels;/* Check for input params */ -if (unlikely ((chain_id <0 || chain_id >=OMAP_LOGICAL_DMA_CH_COUNT ))) { +if (unlikely ((chain_id <0 || chain_id >= dma_lch_count))) {printk (KERN_ERR "Invalid chain id\n" );return -EINVAL ; }
@@ -1537,7 +1540,7 @@ int omap_get_dma_chain_dst_pos(int chain_id)int *channels;/* Check for input params */ -if (unlikely ((chain_id <0 || chain_id >=OMAP_LOGICAL_DMA_CH_COUNT ))) { +if (unlikely ((chain_id <0 || chain_id >= dma_lch_count))) {printk (KERN_ERR "Invalid chain id\n" );return -EINVAL ; }
@@ -1571,7 +1574,7 @@ int omap_get_dma_chain_src_pos(int chain_id)int *channels;/* Check for input params */ -if (unlikely ((chain_id <0 || chain_id >=OMAP_LOGICAL_DMA_CH_COUNT ))) { +if (unlikely ((chain_id <0 || chain_id >= dma_lch_count))) {printk (KERN_ERR "Invalid chain id\n" );return -EINVAL ; }
@@ -1724,7 +1727,7 @@ static irqreturn_t omap2_dma_irq_handler(int irq, void *dev_id)printk (KERN_WARNING "Spurious DMA IRQ\n" );return IRQ_HANDLED ; } -for (i =0 ; i <OMAP_LOGICAL_DMA_CH_COUNT && val !=0 ; i++) { +for (i =0 ; i < dma_lch_count && val !=0 ; i++) {if (val &1 )omap2_dma_handle_ch (i); val >>=1 ;
@@ -2106,6 +2109,25 @@ static int __init omap_init_dma(void) {int ch, r; +if (cpu_class_is_omap1 ()) + dma_lch_count =OMAP1_LOGICAL_DMA_CH_COUNT ; +else + dma_lch_count =OMAP_DMA4_LOGICAL_DMA_CH_COUNT ; + + dma_chan =kzalloc (sizeof (struct omap_dma_lch ) * dma_lch_count, +GFP_KERNEL ); +if (!dma_chan) +return -ENOMEM ; + +if (cpu_class_is_omap2 ()) { + dma_linked_lch =kzalloc (sizeof (struct dma_link_info ) * + dma_lch_count,GFP_KERNEL ); +if (!dma_linked_lch) { +kfree (dma_chan); +return -ENOMEM ; + } + } +if (cpu_is_omap15xx ()) {printk (KERN_INFO "DMA support for OMAP15xx initialized\n" ); dma_chan_count =9 ;
@@ -2142,16 +2164,14 @@ static int __init omap_init_dma(void)u8 revision =omap_readb (OMAP_DMA4_REVISION );printk (KERN_INFO "OMAP DMA hardware revision %d.%d\n" , revision >>4 , revision &0xf ); - dma_chan_count =OMAP_LOGICAL_DMA_CH_COUNT ; + dma_chan_count =OMAP_DMA4_LOGICAL_DMA_CH_COUNT ; }else { dma_chan_count =0 ;return 0 ; } -memset (&lcd_dma,0 ,sizeof (lcd_dma));spin_lock_init (&lcd_dma.lock);spin_lock_init (&dma_chan_lock); -memset (&dma_chan,0 ,sizeof (dma_chan));for (ch =0 ; ch < dma_chan_count; ch++) {omap_clear_dma (ch);
include/asm-arm/arch-omap/dma.h +3 -4
@@ -68,9 +68,10 @@#define OMAP_DMA4_CAPS_3 (OMAP_DMA4_BASE + 0x70)#define OMAP_DMA4_CAPS_4 (OMAP_DMA4_BASE + 0x74) -#ifdef CONFIG_ARCH_OMAP1 +#define OMAP1_LOGICAL_DMA_CH_COUNT 17 +#define OMAP_DMA4_LOGICAL_DMA_CH_COUNT 32/* REVISIT: Is this 32 + 2? */ -#define OMAP_LOGICAL_DMA_CH_COUNT 17 +#ifdef CONFIG_ARCH_OMAP1 /* Common channel specific registers for omap1 */ #define OMAP_DMA_CSDP_REG (n) __REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x00)
@@ -89,8 +90,6 @@#else -#define OMAP_LOGICAL_DMA_CH_COUNT 32/* REVISIT: Is this 32 + 2? */ -/* Common channel specific registers for omap2 */ #define OMAP_DMA_CCR_REG (n) __REG32(OMAP_DMA4_BASE + 0x60 * (n) + 0x80)#define OMAP_DMA_CLNK_CTRL_REG (n) __REG32(OMAP_DMA4_BASE + 0x60 * (n) + 0x84)
Tony Lindgren
maintainerPATCH 5/21 ARM: OMAP: DMA: Remove __REG access
Remove __REG access in DMA code, use dma_read/write instead:
- dynamically set the omap_dma_base based on the omap type
- omap_read/write becomes dma_read/write
- dma channel registers are read with dma_ch_read/write
arch/arm/plat-omap/dma.c +324 -179
@@ -126,6 +126,7 @@ static int dma_chan_count;static spinlock_t dma_chan_lock;static struct omap_dma_lch *dma_chan; +void __iomem *omap_dma_base;static const u8 omap1_dma_irq[OMAP1_LOGICAL_DMA_CH_COUNT ] = {INT_DMA_CH0_6 ,INT_DMA_CH1_7 ,INT_DMA_CH2_8 ,INT_DMA_CH3 ,
@@ -142,6 +143,24 @@ static inline void omap_enable_channel_irq(int lch);#define REVISIT_24XX () printk(KERN_ERR "FIXME: no %s on 24xx\n", \ __func__); +#define dma_read (reg) \ +({ \ + u32 __val; \ + if (cpu_class_is_omap1()) \ + __val = __raw_readw(omap_dma_base + OMAP1_DMA_##reg); \ + else \ + __val = __raw_readl(omap_dma_base + OMAP_DMA4_##reg); \ + __val; \ +}) + +#define dma_write (val, reg) \ +({ \ + if (cpu_class_is_omap1()) \ + __raw_writew((u16)(val), omap_dma_base + OMAP1_DMA_##reg); \ + else \ + __raw_writel((val), omap_dma_base + OMAP_DMA4_##reg); \ +}) +#ifdef CONFIG_ARCH_OMAP15XX /* Returns 1 if the DMA module is in OMAP1510-compatible mode, 0 otherwise */ int omap_dma_in_1510_mode (void )
@@ -176,13 +195,14 @@ static inline void set_gdma_dev(int req, int dev)#define set_gdma_dev (req, dev) do {} while (0)#endif +/* Omap1 only */ static void clear_lch_regs (int lch) {int i; -u32 lch_base =OMAP_DMA_BASE + lch *0x40 ; +void __iomem *lch_base = omap_dma_base +OMAP1_DMA_CH_BASE (lch);for (i =0 ; i <0x2c ; i +=2 ) -omap_writew (0 , lch_base + i); +__raw_writew (0 , lch_base + i); }void omap_set_dma_priority (int lch,int dst_port,int priority)
@@ -215,10 +235,14 @@ void omap_set_dma_priority(int lch, int dst_port, int priority) }if (cpu_class_is_omap2 ()) { +u32 ccr; + + ccr =dma_read (CCR (lch));if (priority) -OMAP_DMA_CCR_REG (lch) |= (1 <<6 ); + ccr |= (1 <<6 );else -OMAP_DMA_CCR_REG (lch) &= ~(1 <<6 ); + ccr &= ~(1 <<6 ); +dma_write (ccr,CCR (lch)); } }
@@ -226,22 +250,33 @@ 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) { - OMAP_DMA_CSDP_REG(lch) &= ~0x03; -OMAP_DMA_CSDP_REG (lch) |= data_type; + u32 l; + + l =dma_read (CSDP (lch)); + l &= ~0x03 ; + l |= data_type; +dma_write (l,CSDP (lch));if (cpu_class_is_omap1 ()) { -OMAP_DMA_CCR_REG (lch) &= ~(1 <<5 ); +u16 ccr; + + ccr =dma_read (CCR (lch)); + ccr &= ~(1 <<5 );if (sync_mode ==OMAP_DMA_SYNC_FRAME ) -OMAP_DMA_CCR_REG (lch) |=1 <<5 ; + ccr |=1 <<5 ; +dma_write (ccr,CCR (lch)); -OMAP1_DMA_CCR2_REG (lch) &= ~(1 <<2 ); + ccr =dma_read (CCR2 (lch)); + ccr &= ~(1 <<2 );if (sync_mode ==OMAP_DMA_SYNC_BLOCK ) -OMAP1_DMA_CCR2_REG (lch) |=1 <<2 ; + ccr |=1 <<2 ; +dma_write (ccr,CCR2 (lch)); }if (cpu_class_is_omap2 () && dma_trigger) { -u32 val =OMAP_DMA_CCR_REG (lch); +u32 val; + val =dma_read (CCR (lch)); val &= ~(3 <<19 );if (dma_trigger >63 ) val |=1 <<20 ;
@@ -266,11 +301,11 @@ void omap_set_dma_transfer_params(int lch, int data_type, int elem_count,else val &= ~(1 <<24 );/* dest synch */ -OMAP_DMA_CCR_REG (lch) = val; +dma_write (val,CCR (lch)); } -OMAP_DMA_CEN_REG (lch) = elem_count; -OMAP_DMA_CFN_REG (lch) = frame_count; +dma_write (elem_count,CEN (lch)); +dma_write (frame_count,CFN (lch)); }void omap_set_dma_color_mode (int lch,enum omap_dma_color_mode mode,u32 color)
@@ -284,7 +319,9 @@ void omap_set_dma_color_mode(int lch, enum omap_dma_color_mode mode, u32 color)return ; } - w =OMAP1_DMA_CCR2_REG (lch) & ~0x03 ; + w =dma_read (CCR2 (lch)); + w &= ~0x03 ; +switch (mode) {case OMAP_DMA_CONSTANT_FILL : w |=0x01 ;
@@ -297,49 +334,81 @@ void omap_set_dma_color_mode(int lch, enum omap_dma_color_mode mode, u32 color)default :BUG (); } -OMAP1_DMA_CCR2_REG (lch) = w; +dma_write (w,CCR2 (lch)); - w =OMAP1_DMA_LCH_CTRL_REG (lch) & ~0x0f ; + w =dma_read (LCH_CTRL (lch)); + w &= ~0x0f ;/* Default is channel type 2D */ if (mode) { -OMAP1_DMA_COLOR_L_REG (lch) = (u16 )color; -OMAP1_DMA_COLOR_U_REG (lch) = (u16)(color >>16 ); +dma_write ((u16 )color,COLOR_L (lch)); +dma_write ((u16)(color >>16 ),COLOR_U (lch)); w |=1 ;/* Channel type G */ } -OMAP1_DMA_LCH_CTRL_REG (lch) = w; +dma_write (w,LCH_CTRL (lch)); }void omap_set_dma_write_mode (int lch,enum omap_dma_write_mode mode) {if (cpu_class_is_omap2 ()) { -OMAP_DMA_CSDP_REG (lch) &= ~(0x3 <<16 ); -OMAP_DMA_CSDP_REG (lch) |= (mode <<16 ); +u32 csdp; + + csdp =dma_read (CSDP (lch)); + csdp &= ~(0x3 <<16 ); + csdp |= (mode <<16 ); +dma_write (csdp,CSDP (lch)); } } +void omap_set_dma_channel_mode (int lch,enum omap_dma_channel_mode mode) +{ +if (cpu_class_is_omap1 () && !cpu_is_omap15xx ()) { +u32 l; + + l =dma_read (LCH_CTRL (lch)); + l &= ~0x7 ; + l |= mode; +dma_write (l,LCH_CTRL (lch)); + } +} +EXPORT_SYMBOL (omap_set_dma_channel_mode); +/* Note that src_port is only for omap1 */ void omap_set_dma_src_params (int lch,int src_port,int src_amode,unsigned long src_start,int src_ei,int src_fi) {if (cpu_class_is_omap1 ()) { -OMAP_DMA_CSDP_REG (lch) &= ~(0x1f <<2 ); -OMAP_DMA_CSDP_REG (lch) |= src_port <<2 ; - } +u16 w; -OMAP_DMA_CCR_REG (lch) &= ~(0x03 <<12 ); -OMAP_DMA_CCR_REG (lch) |= src_amode <<12 ; + w =dma_read (CSDP (lch)); + w &= ~(0x1f <<2 ); + w |= src_port <<2 ; +dma_write (w,CSDP (lch)); -if (cpu_class_is_omap1 ()) { -OMAP1_DMA_CSSA_U_REG (lch) = src_start >>16 ; -OMAP1_DMA_CSSA_L_REG (lch) = src_start; + w =dma_read (CCR (lch)); + w &= ~(0x03 <<12 ); + w |= src_amode <<12 ; +dma_write (w,CCR (lch)); + +dma_write (src_start >>16 ,CSSA_U (lch)); +dma_write ((u16 )src_start,CSSA_L (lch)); + +dma_write (src_ei,CSEI (lch)); +dma_write (src_fi,CSFI (lch)); } -if (cpu_class_is_omap2 ()) -OMAP2_DMA_CSSA_REG (lch) = src_start; +if (cpu_class_is_omap2 ()) { +u32 l; + + l =dma_read (CCR (lch)); + l &= ~(0x03 <<12 ); + l |= src_amode <<12 ; +dma_write (l,CCR (lch)); -OMAP_DMA_CSEI_REG (lch) = src_ei; -OMAP_DMA_CSFI_REG (lch) = src_fi; +dma_write (src_start,CSSA (lch)); +dma_write (src_ei,CSEI (lch)); +dma_write (src_fi,CSFI (lch)); + } }void omap_set_dma_params (int lch,struct omap_dma_channel_params * params)
@@ -366,21 +435,28 @@ void omap_set_dma_src_index(int lch, int eidx, int fidx)REVISIT_24XX ();return ; } -OMAP_DMA_CSEI_REG (lch) = eidx; -OMAP_DMA_CSFI_REG (lch) = fidx; +dma_write (eidx,CSEI (lch)); +dma_write (fidx,CSFI (lch)); }void omap_set_dma_src_data_pack (int lch,int enable) { -OMAP_DMA_CSDP_REG (lch) &= ~(1 <<6 ); +u32 l; + + l =dma_read (CSDP (lch)); + l &= ~(1 <<6 );if (enable) -OMAP_DMA_CSDP_REG (lch) |= (1 <<6 ); + l |= (1 <<6 ); +dma_write (l,CSDP (lch)); }void omap_set_dma_src_burst_mode (int lch,enum omap_dma_burst_mode burst_mode) {unsigned int burst =0 ; -OMAP_DMA_CSDP_REG (lch) &= ~(0x03 <<7 ); +u32 l; + + l =dma_read (CSDP (lch)); + l &= ~(0x03 <<7 );switch (burst_mode) {case OMAP_DMA_DATA_BURST_DIS :
@@ -411,7 +487,9 @@ void omap_set_dma_src_burst_mode(int lch, enum omap_dma_burst_mode burst_mode)default :BUG (); } -OMAP_DMA_CSDP_REG (lch) |= (burst <<7 ); + + l |= (burst <<7 ); +dma_write (l,CSDP (lch)); }/* Note that dest_port is only for OMAP1 */
@@ -419,24 +497,30 @@ void omap_set_dma_dest_params(int lch, int dest_port, int dest_amode,unsigned long dest_start, int dst_ei, int dst_fi) { + u32 l; +if (cpu_class_is_omap1 ()) { - OMAP_DMA_CSDP_REG(lch) &= ~(0x1f << 9); -OMAP_DMA_CSDP_REG (lch) |= dest_port <<9 ; + l =dma_read (CSDP (lch)); + l &= ~(0x1f <<9 ); + l |= dest_port <<9 ; +dma_write (l,CSDP (lch)); } -OMAP_DMA_CCR_REG (lch) &= ~(0x03 <<14 ); -OMAP_DMA_CCR_REG (lch) |= dest_amode <<14 ; + l =dma_read (CCR (lch)); + l &= ~(0x03 <<14 ); + l |= dest_amode <<14 ; +dma_write (l,CCR (lch));if (cpu_class_is_omap1 ()) { -OMAP1_DMA_CDSA_U_REG (lch) = dest_start >>16 ; -OMAP1_DMA_CDSA_L_REG (lch) = dest_start; +dma_write (dest_start >>16 ,CDSA_U (lch)); +dma_write (dest_start,CDSA_L (lch)); }if (cpu_class_is_omap2 ()) -OMAP2_DMA_CDSA_REG (lch) = dest_start; +dma_write (dest_start,CDSA (lch)); -OMAP_DMA_CDEI_REG (lch) = dst_ei; -OMAP_DMA_CDFI_REG (lch) = dst_fi; +dma_write (dst_ei,CDEI (lch)); +dma_write (dst_fi,CDFI (lch)); }void omap_set_dma_dest_index (int lch,int eidx,int fidx)
@@ -445,21 +529,28 @@ void omap_set_dma_dest_index(int lch, int eidx, int fidx)REVISIT_24XX ();return ; } -OMAP_DMA_CDEI_REG (lch) = eidx; -OMAP_DMA_CDFI_REG (lch) = fidx; +dma_write (eidx,CDEI (lch)); +dma_write (fidx,CDFI (lch)); }void omap_set_dma_dest_data_pack (int lch,int enable) { -OMAP_DMA_CSDP_REG (lch) &= ~(1 <<13 ); +u32 l; + + l =dma_read (CSDP (lch)); + l &= ~(1 <<13 );if (enable) -OMAP_DMA_CSDP_REG (lch) |=1 <<13 ; + l |=1 <<13 ; +dma_write (l,CSDP (lch)); }void omap_set_dma_dest_burst_mode (int lch,enum omap_dma_burst_mode burst_mode) {unsigned int burst =0 ; -OMAP_DMA_CSDP_REG (lch) &= ~(0x03 <<14 ); +u32 l; + + l =dma_read (CSDP (lch)); + l &= ~(0x03 <<14 );switch (burst_mode) {case OMAP_DMA_DATA_BURST_DIS :
@@ -489,7 +580,8 @@ void omap_set_dma_dest_burst_mode(int lch, enum omap_dma_burst_mode burst_mode)BUG ();return ; } -OMAP_DMA_CSDP_REG (lch) |= (burst <<14 ); + l |= (burst <<14 ); +dma_write (l,CSDP (lch)); }static inline void omap_enable_channel_irq (int lch)
@@ -498,18 +590,18 @@ static inline void omap_enable_channel_irq(int lch)/* Clear CSR */ if (cpu_class_is_omap1 ()) - status =OMAP_DMA_CSR_REG (lch); + status =dma_read (CSR (lch));else if (cpu_class_is_omap2 ()) -OMAP_DMA_CSR_REG (lch) =OMAP2_DMA_CSR_CLEAR_MASK ; +dma_write (OMAP2_DMA_CSR_CLEAR_MASK ,CSR (lch));/* Enable some nice interrupts. */ -OMAP_DMA_CICR_REG (lch) = dma_chan[lch].enabled_irqs; +dma_write (dma_chan[lch].enabled_irqs,CICR (lch)); }static void omap_disable_channel_irq (int lch) {if (cpu_class_is_omap2 ()) -OMAP_DMA_CICR_REG (lch) =0 ; +dma_write (0 ,CICR (lch)); }void omap_enable_dma_irq (int lch,u16 bits)
@@ -524,36 +616,45 @@ void omap_disable_dma_irq(int lch, u16 bits)static inline void enable_lnk (int lch) { +u32 l; + + l =dma_read (CLNK_CTRL (lch)); +if (cpu_class_is_omap1 ()) -OMAP_DMA_CLNK_CTRL_REG (lch) &= ~(1 <<14 ); + l &= ~(1 <<14 );/* Set the ENABLE_LNK bits */ if (dma_chan[lch].next_lch !=-1 ) -OMAP_DMA_CLNK_CTRL_REG (lch) = - dma_chan[lch].next_lch | (1 <<15 ); + l = dma_chan[lch].next_lch | (1 <<15 );#ifndef CONFIG_ARCH_OMAP1 if (dma_chan[lch].next_linked_ch !=-1 ) -OMAP_DMA_CLNK_CTRL_REG (lch) = - dma_chan[lch].next_linked_ch | (1 <<15 ); + l = dma_chan[lch].next_linked_ch | (1 <<15 );#endif + +dma_write (l,CLNK_CTRL (lch)); }static inline void disable_lnk (int lch) { +u32 l; + + l =dma_read (CLNK_CTRL (lch)); +/* Disable interrupts */ if (cpu_class_is_omap1 ()) { -OMAP_DMA_CICR_REG (lch) =0 ; +dma_write (0 ,CICR (lch));/* Set the STOP_LNK bit */ -OMAP_DMA_CLNK_CTRL_REG (lch) |=1 <<14 ; + l |=1 <<14 ; }if (cpu_class_is_omap2 ()) {omap_disable_channel_irq (lch);/* Clear the ENABLE_LNK bit */ -OMAP_DMA_CLNK_CTRL_REG (lch) &= ~(1 <<15 ); + l &= ~(1 <<15 ); } +dma_write (l,CLNK_CTRL (lch)); dma_chan[lch].flags &= ~OMAP_DMA_ACTIVE ; }
@@ -564,9 +665,9 @@ static inline void omap2_enable_irq_lch(int lch)if (!cpu_class_is_omap2 ())return ; - val =omap_readl (OMAP_DMA4_IRQENABLE_L0 ); + val =dma_read (IRQENABLE_L0 ); val |=1 << lch; -omap_writel (val,OMAP_DMA4_IRQENABLE_L0 ); +dma_write (val,IRQENABLE_L0 ); } int omap_request_dma(int dev_id, const char *dev_name,
@@ -623,9 +724,9 @@ int omap_request_dma(int dev_id, const char *dev_name, }/* Disable the 1510 compatibility mode and set the sync device * id. */ -OMAP_DMA_CCR_REG (free_ch) = dev_id | (1 <<10 ); +dma_write (dev_id | (1 <<10 ),CCR (free_ch)); }else if (cpu_is_omap730 () ||cpu_is_omap15xx ()) { -OMAP_DMA_CCR_REG (free_ch) = dev_id; +dma_write (dev_id,CCR (free_ch)); }if (cpu_class_is_omap2 ()) {
@@ -633,8 +734,8 @@ int omap_request_dma(int dev_id, const char *dev_name,omap_enable_channel_irq (free_ch);/* Clear the CSR register and IRQ status register */ -OMAP_DMA_CSR_REG (free_ch) =OMAP2_DMA_CSR_CLEAR_MASK ; -omap_writel (1 << free_ch,OMAP_DMA4_IRQSTATUS_L0 ); +dma_write (OMAP2_DMA_CSR_CLEAR_MASK ,CSR (free_ch)); +dma_write (1 << free_ch,IRQSTATUS_L0 ); } *dma_ch_out = free_ch;
@@ -660,27 +761,27 @@ void omap_free_dma(int lch)if (cpu_class_is_omap1 ()) {/* Disable all DMA interrupts for the channel. */ -OMAP_DMA_CICR_REG (lch) =0 ; +dma_write (0 ,CICR (lch));/* Make sure the DMA transfer is stopped. */ -OMAP_DMA_CCR_REG (lch) =0 ; +dma_write (0 ,CCR (lch)); }if (cpu_class_is_omap2 ()) {u32 val;/* Disable interrupts */ - val =omap_readl (OMAP_DMA4_IRQENABLE_L0 ); + val =dma_read (IRQENABLE_L0 ); val &= ~(1 << lch); -omap_writel (val,OMAP_DMA4_IRQENABLE_L0 ); +dma_write (val,IRQENABLE_L0 );/* Clear the CSR register and IRQ status register */ -OMAP_DMA_CSR_REG (lch) =OMAP2_DMA_CSR_CLEAR_MASK ; -omap_writel (1 << lch,OMAP_DMA4_IRQSTATUS_L0 ); +dma_write (OMAP2_DMA_CSR_CLEAR_MASK ,CSR (lch)); +dma_write (1 << lch,IRQSTATUS_L0 );/* Disable all DMA interrupts for the channel. */ -OMAP_DMA_CICR_REG (lch) =0 ; +dma_write (0 ,CICR (lch));/* Make sure the DMA transfer is stopped. */ -OMAP_DMA_CCR_REG (lch) =0 ; +dma_write (0 ,CCR (lch));omap_clear_dma (lch); } }
@@ -711,7 +812,7 @@ omap_dma_set_global_params(int arb_rate, int max_fifo_depth, int tparams) reg = (arb_rate &0xff ) <<16 ; reg |= (0xff & max_fifo_depth); -omap_writel (reg,OMAP_DMA4_GCR_REG ); +dma_write (reg,GCR ); }EXPORT_SYMBOL (omap_dma_set_global_params);
@@ -728,20 +829,21 @@ int omap_dma_set_prio_lch(int lch, unsigned char read_prio, unsigned char write_prio) { - u32 w; + u32 l;if (unlikely ((lch <0 || lch >= dma_lch_count))) {printk (KERN_ERR "Invalid channel id\n" );return -EINVAL ; } - w =OMAP_DMA_CCR_REG (lch); - w &= ~((1 <<6 ) | (1 <<26 )); + l =dma_read (CCR (lch)); + l &= ~((1 <<6 ) | (1 <<26 ));if (cpu_is_omap2430 () ||cpu_is_omap34xx ()) - w |= ((read_prio &0x1 ) <<6 ) | ((write_prio &0x1 ) <<26 ); + l |= ((read_prio &0x1 ) <<6 ) | ((write_prio &0x1 ) <<26 );else - w |= ((read_prio &0x1 ) <<6 ); + l |= ((read_prio &0x1 ) <<6 ); + +dma_write (l,CCR (lch)); -OMAP_DMA_CCR_REG (lch) = w;return 0 ; }EXPORT_SYMBOL (omap_dma_set_prio_lch);
@@ -757,18 +859,21 @@ void omap_clear_dma(int lch)local_irq_save (flags);if (cpu_class_is_omap1 ()) { -int status; -OMAP_DMA_CCR_REG (lch) &= ~OMAP_DMA_CCR_EN ; +u32 l; + + l =dma_read (CCR (lch)); + l &= ~OMAP_DMA_CCR_EN ; +dma_write (l,CCR (lch));/* Clear pending interrupts */ - status =OMAP_DMA_CSR_REG (lch); + l =dma_read (CSR (lch)); }if (cpu_class_is_omap2 ()) {int i; -u32 lch_base =OMAP_DMA4_BASE + lch *0x60 +0x80 ; +void __iomem *lch_base = omap_dma_base +OMAP_DMA4_CH_BASE (lch);for (i =0 ; i <0x44 ; i +=4 ) -omap_writel (0 , lch_base + i); +__raw_writel (0 , lch_base + i); }local_irq_restore (flags);
@@ -776,6 +881,8 @@ void omap_clear_dma(int lch)void omap_start_dma (int lch) { +u32 l; +if (!omap_dma_in_1510_mode () && dma_chan[lch].next_lch !=-1 ) {int next_lch, cur_lch;char dma_chan_link_map[OMAP_DMA4_LOGICAL_DMA_CH_COUNT ];
@@ -802,24 +909,28 @@ void omap_start_dma(int lch) }while (next_lch !=-1 ); }else if (cpu_class_is_omap2 ()) {/* Errata: Need to write lch even if not using chaining */ -OMAP_DMA_CLNK_CTRL_REG (lch) = lch; +dma_write (lch,CLNK_CTRL (lch)); }omap_enable_channel_irq (lch); + l =dma_read (CCR (lch)); +/* Errata: On ES2.0 BUFFERING disable must be set. * This will always fail on ES1.0 */ -if (cpu_is_omap24xx ()) { -OMAP_DMA_CCR_REG (lch) |=OMAP_DMA_CCR_EN ; - } +if (cpu_is_omap24xx ()) + l |=OMAP_DMA_CCR_EN ; -OMAP_DMA_CCR_REG (lch) |=OMAP_DMA_CCR_EN ; + l |=OMAP_DMA_CCR_EN ; +dma_write (l,CCR (lch)); dma_chan[lch].flags |=OMAP_DMA_ACTIVE ; }void omap_stop_dma (int lch) { +u32 l; +if (!omap_dma_in_1510_mode () && dma_chan[lch].next_lch !=-1 ) {int next_lch, cur_lch = lch;char dma_chan_link_map[OMAP_DMA4_LOGICAL_DMA_CH_COUNT ];
@@ -843,9 +954,12 @@ void omap_stop_dma(int lch)/* Disable all interrupts on the channel */ if (cpu_class_is_omap1 ()) -OMAP_DMA_CICR_REG (lch) =0 ; +dma_write (0 ,CICR (lch)); + + l =dma_read (CCR (lch)); + l &= ~OMAP_DMA_CCR_EN ; +dma_write (l,CCR (lch)); -OMAP_DMA_CCR_REG (lch) &= ~OMAP_DMA_CCR_EN ; dma_chan[lch].flags &= ~OMAP_DMA_ACTIVE ; }
@@ -887,12 +1001,20 @@ dma_addr_t omap_get_dma_src_pos(int lch) {dma_addr_t offset =0 ; -if (cpu_class_is_omap1 ()) - offset = (dma_addr_t) (OMAP1_DMA_CSSA_L_REG (lch) | - (OMAP1_DMA_CSSA_U_REG (lch) <<16 )); +if (cpu_is_omap15xx ()) + offset =dma_read (CPC (lch)); +else + offset =dma_read (CSAC (lch)); -if (cpu_class_is_omap2 ()) - offset =OMAP_DMA_CSAC_REG (lch); +/* +* omap 3.2/3.3 erratum: sometimes 0 is returned if CSAC/CDAC is +* read before the DMA controller finished disabling the channel. +*/ +if (!cpu_is_omap15xx () && offset ==0 ) + offset =dma_read (CSAC (lch)); + +if (cpu_class_is_omap1 ()) + offset |= (dma_read (CSSA_U (lch)) <<16 );return offset; }
@@ -909,12 +1031,20 @@ dma_addr_t omap_get_dma_dst_pos(int lch) {dma_addr_t offset =0 ; -if (cpu_class_is_omap1 ()) - offset = (dma_addr_t) (OMAP1_DMA_CDSA_L_REG (lch) | - (OMAP1_DMA_CDSA_U_REG (lch) <<16 )); +if (cpu_is_omap15xx ()) + offset =dma_read (CPC (lch)); +else + offset =dma_read (CDAC (lch)); -if (cpu_class_is_omap2 ()) - offset =OMAP_DMA_CDAC_REG (lch); +/* +* omap 3.2/3.3 erratum: sometimes 0 is returned if CSAC/CDAC is +* read before the DMA controller finished disabling the channel. +*/ +if (!cpu_is_omap15xx () && offset ==0 ) + offset =dma_read (CDAC (lch)); + +if (cpu_class_is_omap1 ()) + offset |= (dma_read (CDSA_U (lch)) <<16 );return offset; }
@@ -926,8 +1056,14 @@ dma_addr_t omap_get_dma_dst_pos(int lch)*/ int omap_get_dma_src_addr_counter (int lch) { -return (dma_addr_t )OMAP_DMA_CSAC_REG (lch); +return (dma_addr_t )dma_read (CSAC (lch)); +} + +int omap_get_dma_active_status (int lch) +{ +return (dma_read (CCR (lch)) &OMAP_DMA_CCR_EN ) !=0 ; } +EXPORT_SYMBOL (omap_get_dma_active_status);int omap_dma_running (void ) {
@@ -939,7 +1075,7 @@ int omap_dma_running(void)return 1 ;for (lch =0 ; lch < dma_chan_count; lch++) -if (OMAP_DMA_CCR_REG (lch) &OMAP_DMA_CCR_EN ) +if (dma_read (CCR (lch)) &OMAP_DMA_CCR_EN )return 1 ;return 0 ;
@@ -1001,7 +1137,7 @@ void omap_dma_unlink_lch (int lch_head, int lch_queue)/* Create chain of DMA channesls */ static void create_dma_lch_chain (int lch_head,int lch_queue) { -u32 w; +u32 l;/* Check if this is the first link in chain */ if (dma_chan[lch_head].next_linked_ch ==-1 ) {
@@ -1021,15 +1157,15 @@ static void create_dma_lch_chain(int lch_head, int lch_queue) lch_queue; } - w =OMAP_DMA_CLNK_CTRL_REG (lch_head); - w &= ~(0x1f ); - w |= lch_queue; -OMAP_DMA_CLNK_CTRL_REG (lch_head) = w; + l =dma_read (CLNK_CTRL (lch_head)); + l &= ~(0x1f ); + l |= lch_queue; +dma_write (l,CLNK_CTRL (lch_head)); - w =OMAP_DMA_CLNK_CTRL_REG (lch_queue); - w &= ~(0x1f ); - w |= (dma_chan[lch_queue].next_linked_ch); -OMAP_DMA_CLNK_CTRL_REG (lch_queue) = w; + l =dma_read (CLNK_CTRL (lch_queue)); + l &= ~(0x1f ); + l |= (dma_chan[lch_queue].next_linked_ch); +dma_write (l,CLNK_CTRL (lch_queue)); }/**
@@ -1256,7 +1392,7 @@ 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 w, lch; +u32 l, lch;int start_dma =0 ;/* if buffer size is less than 1 then there is
@@ -1297,13 +1433,13 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start,/* Set the params to the free channel */ if (src_start !=0 ) -OMAP2_DMA_CSSA_REG (lch) = src_start; +dma_write (src_start,CSSA (lch));if (dest_start !=0 ) -OMAP2_DMA_CDSA_REG (lch) = dest_start; +dma_write (dest_start,CDSA (lch));/* Write the buffer size */ -OMAP_DMA_CEN_REG (lch) = elem_count; -OMAP_DMA_CFN_REG (lch) = frame_count; +dma_write (elem_count,CEN (lch)); +dma_write (frame_count,CFN (lch));/* If the chain is dynamically linked, * then we may have to start the chain if its not active */
@@ -1330,8 +1466,8 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start,enable_lnk (dma_chan[lch].prev_linked_ch); dma_chan[lch].state =DMA_CH_QUEUED ; start_dma =0 ; -if (0 == ((1 <<7 ) & (OMAP_DMA_CCR_REG - (dma_chan[lch].prev_linked_ch)))) { +if (0 == ((1 <<7 ) &dma_read ( +CCR (dma_chan[lch].prev_linked_ch)))) {disable_lnk (dma_chan[lch]. prev_linked_ch);pr_debug ("\n prev ch is stopped\n" );
@@ -1347,23 +1483,23 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start, }omap_enable_channel_irq (lch); - w =OMAP_DMA_CCR_REG (lch); + l =dma_read (CCR (lch)); -if ((0 == (w & (1 <<24 )))) - w &= ~(1 <<25 ); +if ((0 == (l & (1 <<24 )))) + l &= ~(1 <<25 );else - w |= (1 <<25 ); + l |= (1 <<25 );if (start_dma ==1 ) { -if (0 == (w & (1 <<7 ))) { - w |= (1 <<7 ); +if (0 == (l & (1 <<7 ))) { + l |= (1 <<7 ); dma_chan[lch].state =DMA_CH_STARTED ;pr_debug ("starting %d\n" , lch); -OMAP_DMA_CCR_REG (lch) = w; +dma_write (l,CCR (lch)); }else start_dma =0 ; }else { -if (0 == (w & (1 <<7 ))) -OMAP_DMA_CCR_REG (lch) = w; +if (0 == (l & (1 <<7 ))) +dma_write (l,CCR (lch)); } dma_chan[lch].flags |=OMAP_DMA_ACTIVE ; }
@@ -1383,7 +1519,7 @@ EXPORT_SYMBOL(omap_dma_chain_a_transfer);int omap_start_dma_chain_transfers (int chain_id) {int *channels; -u32 w, i; +u32 l, i;if (unlikely ((chain_id <0 || chain_id >= dma_lch_count))) {printk (KERN_ERR "Invalid chain id\n" );
@@ -1407,16 +1543,16 @@ int omap_start_dma_chain_transfers(int chain_id)omap_enable_channel_irq (channels[0 ]); } - w =OMAP_DMA_CCR_REG (channels[0 ]); - w |= (1 <<7 ); + l =dma_read (CCR (channels[0 ])); + l |= (1 <<7 ); dma_linked_lch[chain_id].chain_state =DMA_CHAIN_STARTED ; dma_chan[channels[0 ]].state =DMA_CH_STARTED ; -if ((0 == (w & (1 <<24 )))) - w &= ~(1 <<25 ); +if ((0 == (l & (1 <<24 )))) + l &= ~(1 <<25 );else - w |= (1 <<25 ); -OMAP_DMA_CCR_REG (channels[0 ]) = w; + l |= (1 <<25 ); +dma_write (l,CCR (channels[0 ])); dma_chan[channels[0 ]].flags |=OMAP_DMA_ACTIVE ;return 0 ;
@@ -1434,7 +1570,7 @@ EXPORT_SYMBOL(omap_start_dma_chain_transfers);int omap_stop_dma_chain_transfers (int chain_id) {int *channels; -u32 w, i; +u32 l, i;u32 sys_cf;/* Check for input params */
@@ -1453,18 +1589,18 @@ int omap_stop_dma_chain_transfers(int chain_id)/* DMA Errata: * Special programming model needed to disable DMA before end of block */ - sys_cf =omap_readl (OMAP_DMA4_OCP_SYSCONFIG ); - w = sys_cf; + sys_cf =dma_read (OCP_SYSCONFIG ); + l = sys_cf;/* Middle mode reg set no Standby */ - w &= ~((1 <<12 )|(1 <<13 )); -omap_writel (w,OMAP_DMA4_OCP_SYSCONFIG ); + l &= ~((1 <<12 )|(1 <<13 )); +dma_write (l,OCP_SYSCONFIG );for (i =0 ; i < dma_linked_lch[chain_id].no_of_lchs_linked; i++) {/* Stop the Channel transmission */ - w =OMAP_DMA_CCR_REG (channels[i]); - w &= ~(1 <<7 ); -OMAP_DMA_CCR_REG (channels[i]) = w; + l =dma_read (CCR (channels[i])); + l &= ~(1 <<7 ); +dma_write (l,CCR (channels[i]));/* Disable the link in all the channels */ disable_lnk (channels[i]);
@@ -1477,7 +1613,7 @@ int omap_stop_dma_chain_transfers(int chain_id)OMAP_DMA_CHAIN_QINIT (chain_id);/* Errata - put in the old value */ -omap_writel (sys_cf,OMAP_DMA4_OCP_SYSCONFIG ); +dma_write (sys_cf,OCP_SYSCONFIG );return 0 ; }EXPORT_SYMBOL (omap_stop_dma_chain_transfers);
@@ -1518,8 +1654,8 @@ int omap_get_dma_chain_index(int chain_id, int *ei, int *fi)/* Get the current channel */ lch = channels[dma_linked_lch[chain_id].q_head]; - *ei =OMAP2_DMA_CCEN_REG (lch); - *fi =OMAP2_DMA_CCFN_REG (lch); + *ei =dma_read (CCEN (lch)); + *fi =dma_read (CCFN (lch));return 0 ; }
@@ -1556,7 +1692,7 @@ int omap_get_dma_chain_dst_pos(int chain_id)/* Get the current channel */ lch = channels[dma_linked_lch[chain_id].q_head]; -return (OMAP_DMA_CDAC_REG (lch)); +return dma_read (CDAC (lch)); }EXPORT_SYMBOL (omap_get_dma_chain_dst_pos);
@@ -1590,7 +1726,7 @@ int omap_get_dma_chain_src_pos(int chain_id)/* Get the current channel */ lch = channels[dma_linked_lch[chain_id].q_head]; - return (OMAP_DMA_CSAC_REG(lch)); + return dma_read(CSAC(lch)); }EXPORT_SYMBOL (omap_get_dma_chain_src_pos);#endif
@@ -1601,13 +1737,13 @@ EXPORT_SYMBOL(omap_get_dma_chain_src_pos);static int omap1_dma_handle_ch (int ch) { -u16 csr; +u32 csr;if (enable_1510_mode && ch >=6 ) { csr = dma_chan[ch].saved_csr; dma_chan[ch].saved_csr =0 ; }else - csr =OMAP_DMA_CSR_REG (ch); + csr =dma_read (CSR (ch));if (enable_1510_mode && ch <=2 && (csr >>7 ) !=0 ) { dma_chan[ch +6 ].saved_csr = csr >>7 ; csr &=0x7f ;
@@ -1659,12 +1795,12 @@ static irqreturn_t omap1_dma_irq_handler(int irq, void *dev_id)static int omap2_dma_handle_ch (int ch) { -u32 status =OMAP_DMA_CSR_REG (ch); +u32 status =dma_read (CSR (ch));if (!status) {if (printk_ratelimit ())printk (KERN_WARNING "Spurious DMA IRQ for lch %d\n" , ch); -omap_writel (1 << ch,OMAP_DMA4_IRQSTATUS_L0 ); +dma_write (1 << ch,IRQSTATUS_L0 );return 0 ; }if (unlikely (dma_chan[ch].dev_id ==-1 )) {
@@ -1687,14 +1823,14 @@ static int omap2_dma_handle_ch(int ch)printk (KERN_INFO "DMA misaligned error with device %d\n" , dma_chan[ch].dev_id); -OMAP_DMA_CSR_REG (ch) =OMAP2_DMA_CSR_CLEAR_MASK ; -omap_writel (1 << ch,OMAP_DMA4_IRQSTATUS_L0 ); +dma_write (OMAP2_DMA_CSR_CLEAR_MASK ,CSR (ch)); +dma_write (1 << ch,IRQSTATUS_L0 );/* If the ch is not chained then chain_id will be -1 */ if (dma_chan[ch].chain_id !=-1 ) {int chain_id = dma_chan[ch].chain_id; dma_chan[ch].state =DMA_CH_NOTSTARTED ; -if (OMAP_DMA_CLNK_CTRL_REG (ch) & (1 <<15 )) +if (dma_read (CLNK_CTRL (ch)) & (1 <<15 )) dma_chan[dma_chan[ch].next_linked_ch].state =DMA_CH_STARTED ; if (dma_linked_lch[chain_id].chain_mode ==
@@ -1704,13 +1840,13 @@ static int omap2_dma_handle_ch(int ch)if (!OMAP_DMA_CHAIN_QEMPTY (chain_id))OMAP_DMA_CHAIN_INCQHEAD (chain_id); - status =OMAP_DMA_CSR_REG (ch); + status =dma_read (CSR (ch)); }if (likely (dma_chan[ch].callback !=NULL )) dma_chan[ch].callback (ch, status, dma_chan[ch].data); -OMAP_DMA_CSR_REG (ch) = status; +dma_write (status,CSR (ch));return 0 ; }
@@ -1721,7 +1857,7 @@ static irqreturn_t omap2_dma_irq_handler(int irq, void *dev_id)u32 val;int i; - val =omap_readl (OMAP_DMA4_IRQSTATUS_L0 ); + val =dma_read (IRQSTATUS_L0 );if (val ==0 ) {if (printk_ratelimit ())printk (KERN_WARNING "Spurious DMA IRQ\n" );
@@ -2109,10 +2245,19 @@ static int __init omap_init_dma(void) {int ch, r; -if (cpu_class_is_omap1 ()) +if (cpu_class_is_omap1 ()) { + omap_dma_base = (void __iomem *)IO_ADDRESS (OMAP1_DMA_BASE ); dma_lch_count =OMAP1_LOGICAL_DMA_CH_COUNT ; -else + }else if (cpu_is_omap24xx ()) { + omap_dma_base = (void __iomem *)IO_ADDRESS (OMAP24XX_DMA4_BASE ); dma_lch_count =OMAP_DMA4_LOGICAL_DMA_CH_COUNT ; + }else if (cpu_is_omap34xx ()) { + omap_dma_base = (void __iomem *)IO_ADDRESS (OMAP34XX_DMA4_BASE ); + dma_lch_count =OMAP_DMA4_LOGICAL_DMA_CH_COUNT ; + }else { +pr_err ("DMA init failed for unsupported omap\n" ); +return -ENODEV ; + } dma_chan =kzalloc (sizeof (struct omap_dma_lch ) * dma_lch_count,GFP_KERNEL );
@@ -2134,21 +2279,21 @@ static int __init omap_init_dma(void) enable_1510_mode =1 ; }else if (cpu_is_omap16xx () ||cpu_is_omap730 ()) {printk (KERN_INFO "OMAP DMA hardware version %d\n" , -omap_readw (OMAP_DMA_HW_ID )); +dma_read (HW_ID ));printk (KERN_INFO "DMA capabilities: %08x:%08x:%04x:%04x:%04x\n" , - (omap_readw (OMAP_DMA_CAPS_0_U ) <<16 ) | -omap_readw (OMAP_DMA_CAPS_0_L ), - (omap_readw (OMAP_DMA_CAPS_1_U ) <<16 ) | -omap_readw (OMAP_DMA_CAPS_1_L ), -omap_readw (OMAP_DMA_CAPS_2 ),omap_readw (OMAP_DMA_CAPS_3 ), -omap_readw (OMAP_DMA_CAPS_4 )); + (dma_read (CAPS_0_U ) <<16 ) | +dma_read (CAPS_0_L ), + (dma_read (CAPS_1_U ) <<16 ) | +dma_read (CAPS_1_L ), +dma_read (CAPS_2 ),dma_read (CAPS_3 ), +dma_read (CAPS_4 ));if (!enable_1510_mode) {u16 w;/* Disable OMAP 3.0/3.1 compatibility mode. */ - w =omap_readw (OMAP_DMA_GSCR ); + w =dma_read (GSCR ); w |=1 <<3 ; -omap_writew (w,OMAP_DMA_GSCR ); +dma_write (w,GSCR ); dma_chan_count =16 ; }else dma_chan_count =9 ;
@@ -2161,7 +2306,7 @@ static int __init omap_init_dma(void)omap_writew (w,OMAP1610_DMA_LCD_CTRL ); } }else if (cpu_class_is_omap2 ()) { -u8 revision =omap_readb (OMAP_DMA4_REVISION ); +u8 revision =dma_read (REVISION ) &0xff ;printk (KERN_INFO "OMAP DMA hardware revision %d.%d\n" , revision >>4 , revision &0xf ); dma_chan_count =OMAP_DMA4_LOGICAL_DMA_CH_COUNT ;
drivers/usb/gadget/omap_udc.c +6 -36
88 lines not on this page · raw message
include/asm-arm/arch-omap/dma.h +120 -90
245 lines not on this page · raw message
Tony Lindgren
maintainerPATCH 6/21 ARM: OMAP: DMA: Clean-up code
DMA clean-up, mostly checkpatch.pl fixes.
arch/arm/plat-omap/dma.c +132 -123
@@ -1,7 +1,7 @@/* * linux/arch/arm/plat-omap/dma.c * -* Copyright (C) 2003 Nokia Corporation +* Copyright (C) 2003 - 2008 Nokia Corporation * Author: Juha Yrjölä <[email protected]> * DMA channel linking for 1610 by Samuel Ortiz <[email protected]> * Graphics DMA and LCD DMA graphics tranformations
@@ -25,11 +25,11 @@#include <linux/errno.h> #include <linux/interrupt.h> #include <linux/irq.h> +#include <linux/io.h> #include <asm/system.h> #include <asm/hardware.h> #include <asm/dma.h> -#include <asm/io.h> #include <asm/arch/tc.h>
@@ -43,13 +43,13 @@ enum { DMA_CH_ALLOC_DONE, DMA_CH_PARAMS_SET_DONE, DMA_CH_STARTED,enum {DMA_CHAIN_STARTED ,DMA_CHAIN_NOTSTARTED };#endif -#define OMAP_DMA_ACTIVE 0x01 -#define OMAP_DMA_CCR_EN (1 << 7) +#define OMAP_DMA_ACTIVE 0x01 +#define OMAP_DMA_CCR_EN (1 << 7)#define OMAP2_DMA_CSR_CLEAR_MASK 0xffe -#define OMAP_FUNC_MUX_ARM_BASE (0xfffe1000 + 0xec) +#define OMAP_FUNC_MUX_ARM_BASE (0xfffe1000 + 0xec) -static int enable_1510_mode =0 ; +static int enable_1510_mode;struct omap_dma_lch {int next_lch;
@@ -57,7 +57,7 @@ struct omap_dma_lch {u16 saved_csr;u16 enabled_irqs;const char *dev_name; -void (* callback)(int lch,u16 ch_status,void *data); +void (*callback)(int lch,u16 ch_status,void *data);void *data;#ifndef CONFIG_ARCH_OMAP1
@@ -245,6 +245,7 @@ void omap_set_dma_priority(int lch, int dst_port, int priority)dma_write (ccr,CCR (lch)); } } +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,
@@ -307,6 +308,7 @@ void omap_set_dma_transfer_params(int lch, int data_type, int elem_count,dma_write (elem_count,CEN (lch));dma_write (frame_count,CFN (lch)); } +EXPORT_SYMBOL (omap_set_dma_transfer_params);void omap_set_dma_color_mode (int lch,enum omap_dma_color_mode mode,u32 color) {
@@ -346,6 +348,7 @@ void omap_set_dma_color_mode(int lch, enum omap_dma_color_mode mode, u32 color) }dma_write (w,LCH_CTRL (lch)); } +EXPORT_SYMBOL (omap_set_dma_color_mode);void omap_set_dma_write_mode (int lch,enum omap_dma_write_mode mode) {
@@ -358,6 +361,7 @@ void omap_set_dma_write_mode(int lch, enum omap_dma_write_mode mode)dma_write (csdp,CSDP (lch)); } } +EXPORT_SYMBOL (omap_set_dma_write_mode);void omap_set_dma_channel_mode (int lch,enum omap_dma_channel_mode mode) {
@@ -377,6 +381,8 @@ void omap_set_dma_src_params(int lch, int src_port, int src_amode,unsigned long src_start, int src_ei, int src_fi) { + u32 l; +if (cpu_class_is_omap1 ()) {u16 w;
@@ -384,34 +390,27 @@ void omap_set_dma_src_params(int lch, int src_port, int src_amode, w &= ~(0x1f <<2 ); w |= src_port <<2 ;dma_write (w,CSDP (lch)); + } - w =dma_read (CCR (lch)); - w &= ~(0x03 <<12 ); - w |= src_amode <<12 ; -dma_write (w,CCR (lch)); + l =dma_read (CCR (lch)); + l &= ~(0x03 <<12 ); + l |= src_amode <<12 ; +dma_write (l,CCR (lch)); +if (cpu_class_is_omap1 ()) {dma_write (src_start >>16 ,CSSA_U (lch));dma_write ((u16 )src_start,CSSA_L (lch)); - -dma_write (src_ei,CSEI (lch)); -dma_write (src_fi,CSFI (lch)); } -if (cpu_class_is_omap2 ()) { -u32 l; - - l =dma_read (CCR (lch)); - l &= ~(0x03 <<12 ); - l |= src_amode <<12 ; -dma_write (l,CCR (lch)); - +if (cpu_class_is_omap2 ())dma_write (src_start,CSSA (lch)); -dma_write (src_ei,CSEI (lch)); -dma_write (src_fi,CSFI (lch)); - } + +dma_write (src_ei,CSEI (lch)); +dma_write (src_fi,CSFI (lch)); } +EXPORT_SYMBOL (omap_set_dma_src_params); -void omap_set_dma_params (int lch,struct omap_dma_channel_params * params) +void omap_set_dma_params (int lch,struct omap_dma_channel_params *params) { omap_set_dma_transfer_params(lch, params->data_type, params->elem_count, params->frame_count,
@@ -428,16 +427,17 @@ void omap_set_dma_params(int lch, struct omap_dma_channel_params * params)omap_dma_set_prio_lch (lch, params->read_prio, params->write_prio); } +EXPORT_SYMBOL (omap_set_dma_params);void omap_set_dma_src_index (int lch,int eidx,int fidx) { -if (cpu_class_is_omap2 ()) { -REVISIT_24XX (); +if (cpu_class_is_omap2 ())return ; - } +dma_write (eidx,CSEI (lch));dma_write (fidx,CSFI (lch)); } +EXPORT_SYMBOL (omap_set_dma_src_index);void omap_set_dma_src_data_pack (int lch,int enable) {
@@ -449,6 +449,7 @@ void omap_set_dma_src_data_pack(int lch, int enable) l |= (1 <<6 );dma_write (l,CSDP (lch)); } +EXPORT_SYMBOL (omap_set_dma_src_data_pack);void omap_set_dma_src_burst_mode (int lch,enum omap_dma_burst_mode burst_mode) {
@@ -491,6 +492,7 @@ void omap_set_dma_src_burst_mode(int lch, enum omap_dma_burst_mode burst_mode) l |= (burst <<7 );dma_write (l,CSDP (lch)); } +EXPORT_SYMBOL (omap_set_dma_src_burst_mode);/* Note that dest_port is only for OMAP1 */ void omap_set_dma_dest_params(int lch, int dest_port, int dest_amode,
@@ -522,16 +524,17 @@ void omap_set_dma_dest_params(int lch, int dest_port, int dest_amode,dma_write (dst_ei,CDEI (lch));dma_write (dst_fi,CDFI (lch)); } +EXPORT_SYMBOL (omap_set_dma_dest_params);void omap_set_dma_dest_index (int lch,int eidx,int fidx) { -if (cpu_class_is_omap2 ()) { -REVISIT_24XX (); +if (cpu_class_is_omap2 ())return ; - } +dma_write (eidx,CDEI (lch));dma_write (fidx,CDFI (lch)); } +EXPORT_SYMBOL (omap_set_dma_dest_index);void omap_set_dma_dest_data_pack (int lch,int enable) {
@@ -543,6 +546,7 @@ void omap_set_dma_dest_data_pack(int lch, int enable) l |=1 <<13 ;dma_write (l,CSDP (lch)); } +EXPORT_SYMBOL (omap_set_dma_dest_data_pack);void omap_set_dma_dest_burst_mode (int lch,enum omap_dma_burst_mode burst_mode) {
@@ -583,6 +587,7 @@ void omap_set_dma_dest_burst_mode(int lch, enum omap_dma_burst_mode burst_mode) l |= (burst <<14 );dma_write (l,CSDP (lch)); } +EXPORT_SYMBOL (omap_set_dma_dest_burst_mode);static inline void omap_enable_channel_irq (int lch) {
@@ -608,11 +613,13 @@ void omap_enable_dma_irq(int lch, u16 bits) { dma_chan[lch].enabled_irqs |= bits; } +EXPORT_SYMBOL (omap_enable_dma_irq);void omap_disable_dma_irq (int lch,u16 bits) { dma_chan[lch].enabled_irqs &= ~bits; } +EXPORT_SYMBOL (omap_disable_dma_irq);static inline void enable_lnk (int lch) {
@@ -628,8 +635,9 @@ static inline void enable_lnk(int lch) l = dma_chan[lch].next_lch | (1 <<15 );#ifndef CONFIG_ARCH_OMAP1 -if (dma_chan[lch].next_linked_ch !=-1 ) - l = dma_chan[lch].next_linked_ch | (1 <<15 ); +if (cpu_class_is_omap2 ()) +if (dma_chan[lch].next_linked_ch !=-1 ) + l = dma_chan[lch].next_linked_ch | (1 <<15 );#endif dma_write (l,CLNK_CTRL (lch));
@@ -671,7 +679,7 @@ static inline void omap2_enable_irq_lch(int lch) }int omap_request_dma (int dev_id,const char *dev_name, -void (* callback)(int lch,u16 ch_status,void *data), +void (*callback)(int lch,u16 ch_status,void *data),void *data,int *dma_ch_out) {int ch, free_ch =-1 ;
@@ -704,10 +712,14 @@ int omap_request_dma(int dev_id, const char *dev_name, chan->dev_name = dev_name; chan->callback = callback; chan->data = data; +#ifndef CONFIG_ARCH_OMAP1 - chan->chain_id =-1 ; - chan->next_linked_ch =-1 ; +if (cpu_class_is_omap2 ()) { + chan->chain_id =-1 ; + chan->next_linked_ch =-1 ; + }#endif + chan->enabled_irqs =OMAP_DMA_DROP_IRQ |OMAP_DMA_BLOCK_IRQ ;if (cpu_class_is_omap1 ())
@@ -722,8 +734,10 @@ int omap_request_dma(int dev_id, const char *dev_name,set_gdma_dev (free_ch +1 , dev_id); dev_id = free_ch +1 ; } -/* Disable the 1510 compatibility mode and set the sync device -* id. */ +/* +* Disable the 1510 compatibility mode and set the sync device +* id. +*/ dma_write (dev_id | (1 <<10 ),CCR (free_ch)); }else if (cpu_is_omap730 () ||cpu_is_omap15xx ()) {dma_write (dev_id,CCR (free_ch));
@@ -731,7 +745,6 @@ int omap_request_dma(int dev_id, const char *dev_name,if (cpu_class_is_omap2 ()) {omap2_enable_irq_lch (free_ch); -omap_enable_channel_irq (free_ch);/* Clear the CSR register and IRQ status register */ dma_write (OMAP2_DMA_CSR_CLEAR_MASK ,CSR (free_ch));
@@ -742,6 +755,7 @@ int omap_request_dma(int dev_id, const char *dev_name,return 0 ; } +EXPORT_SYMBOL (omap_request_dma);void omap_free_dma (int lch) {
@@ -749,11 +763,12 @@ void omap_free_dma(int lch)spin_lock_irqsave (&dma_chan_lock, flags);if (dma_chan[lch].dev_id ==-1 ) { -printk ("omap_dma: trying to free nonallocated DMA channel %d\n" , +pr_err ("omap_dma: trying to free unallocated DMA channel %d\n" , lch);spin_unlock_irqrestore (&dma_chan_lock, flags);return ; } + dma_chan[lch].dev_id =-1 ; dma_chan[lch].next_lch =-1 ; dma_chan[lch].callback =NULL ;
@@ -785,6 +800,7 @@ void omap_free_dma(int lch)omap_clear_dma (lch); } } +EXPORT_SYMBOL (omap_free_dma);/** * @brief omap_dma_set_global_params : Set global priority settings for dma
@@ -878,6 +894,7 @@ void omap_clear_dma(int lch)local_irq_restore (flags); } +EXPORT_SYMBOL (omap_clear_dma);void omap_start_dma (int lch) {
@@ -916,8 +933,10 @@ void omap_start_dma(int lch) l =dma_read (CCR (lch)); -/* Errata: On ES2.0 BUFFERING disable must be set. -* This will always fail on ES1.0 */ +/* +* Errata: On ES2.0 BUFFERING disable must be set. +* This will always fail on ES1.0 +*/ if (cpu_is_omap24xx ()) l |=OMAP_DMA_CCR_EN ;
@@ -926,6 +945,7 @@ void omap_start_dma(int lch) dma_chan[lch].flags |=OMAP_DMA_ACTIVE ; } +EXPORT_SYMBOL (omap_start_dma);void omap_stop_dma (int lch) {
@@ -962,13 +982,14 @@ void omap_stop_dma(int lch) dma_chan[lch].flags &= ~OMAP_DMA_ACTIVE ; } +EXPORT_SYMBOL (omap_stop_dma);/* * Allows changing the DMA callback function or data. This may be needed if * the driver shares a single DMA channel for multiple dma triggers. */ int omap_set_dma_callback (int lch, -void (* callback)(int lch,u16 ch_status,void *data), +void (*callback)(int lch,u16 ch_status,void *data),void *data) {unsigned long flags;
@@ -988,6 +1009,7 @@ int omap_set_dma_callback(int lch,return 0 ; } +EXPORT_SYMBOL (omap_set_dma_callback);/* * Returns current physical source address for the given DMA channel.
@@ -1018,6 +1040,7 @@ dma_addr_t omap_get_dma_src_pos(int lch)return offset; } +EXPORT_SYMBOL (omap_get_dma_src_pos);/* * Returns current physical destination address for the given DMA channel.
@@ -1048,16 +1071,7 @@ dma_addr_t omap_get_dma_dst_pos(int lch)return offset; } - -/* -* Returns current source transfer counting for the given DMA channel. -* Can be used to monitor the progress of a transfer inside a block. -* It must be called with disabled interrupts. -*/ -int omap_get_dma_src_addr_counter (int lch) -{ -return (dma_addr_t )dma_read (CSAC (lch)); -} +EXPORT_SYMBOL (omap_get_dma_dst_pos);int omap_get_dma_active_status (int lch) {
@@ -1086,7 +1100,7 @@ int omap_dma_running(void)* For this DMA link to start, you still need to start (see omap_start_dma) * the first one. That will fire up the entire queue. */ -void omap_dma_link_lch (int lch_head,int lch_queue) +void omap_dma_link_lch (int lch_head,int lch_queue) {if (omap_dma_in_1510_mode ()) {printk (KERN_ERR "DMA linking is not supported in 1510 mode\n" );
@@ -1103,11 +1117,12 @@ void omap_dma_link_lch (int lch_head, int lch_queue) dma_chan[lch_head].next_lch = lch_queue; } +EXPORT_SYMBOL (omap_dma_link_lch);/* * Once the DMA queue is stopped, we can destroy it. */ -void omap_dma_unlink_lch (int lch_head,int lch_queue) +void omap_dma_unlink_lch (int lch_head,int lch_queue) {if (omap_dma_in_1510_mode ()) {printk (KERN_ERR "DMA linking is not supported in 1510 mode\n" );
@@ -1122,7 +1137,6 @@ void omap_dma_unlink_lch (int lch_head, int lch_queue)dump_stack (); } -if ((dma_chan[lch_head].flags &OMAP_DMA_ACTIVE ) || (dma_chan[lch_head].flags &OMAP_DMA_ACTIVE )) { printk(KERN_ERR "omap_dma: You need to stop the DMA channels "
@@ -1132,6 +1146,9 @@ void omap_dma_unlink_lch (int lch_head, int lch_queue) dma_chan[lch_head].next_lch =-1 ; } +EXPORT_SYMBOL (omap_dma_unlink_lch); + +/*----------------------------------------------------------------------------*/ #ifndef CONFIG_ARCH_OMAP1 /* Create chain of DMA channesls */
@@ -1255,6 +1272,7 @@ int omap_request_dma_chain(int dev_id, const char *dev_name,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);
@@ -1297,6 +1315,7 @@ int omap_modify_dma_chain_params(int chain_id,*/ omap_set_dma_params (channels[i], ¶ms); } +return 0 ; }EXPORT_SYMBOL (omap_modify_dma_chain_params);
@@ -1340,6 +1359,7 @@ int omap_free_dma_chain(int chain_id) 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);
@@ -1370,6 +1390,7 @@ int omap_dma_chain_status(int chain_id)if (OMAP_DMA_CHAIN_QEMPTY (chain_id))return OMAP_DMA_CHAIN_INACTIVE ; +return OMAP_DMA_CHAIN_ACTIVE ; }EXPORT_SYMBOL (omap_dma_chain_status);
@@ -1395,8 +1416,10 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start,u32 l, lch;int start_dma =0 ; -/* if buffer size is less than 1 then there is -* no use of starting the chain */ +/* +* 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 ;
@@ -1441,12 +1464,16 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start,dma_write (elem_count,CEN (lch));dma_write (frame_count,CFN (lch)); -/* If the chain is dynamically linked, -* then we may have to start the chain if its not active */ +/* +* 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 */ +/* +* 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 */
@@ -1456,8 +1483,10 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start, dma_chan[lch].state =DMA_CH_QUEUED ; } -/* Chain is already started, make sure its active, -* if not then start the chain */ +/* +* Chain is already started, make sure its active, +* if not then start the chain +*/ else { start_dma =1 ;
@@ -1504,6 +1533,7 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start, dma_chan[lch].flags |=OMAP_DMA_ACTIVE ; } } +return 0 ; }EXPORT_SYMBOL (omap_dma_chain_a_transfer);
@@ -1555,6 +1585,7 @@ int omap_start_dma_chain_transfers(int chain_id)dma_write (l,CCR (channels[0 ])); dma_chan[channels[0 ]].flags |=OMAP_DMA_ACTIVE ; +return 0 ; }EXPORT_SYMBOL (omap_start_dma_chain_transfers);
@@ -1586,7 +1617,8 @@ int omap_stop_dma_chain_transfers(int chain_id) } channels = dma_linked_lch[chain_id].linked_dmach_q; -/* DMA Errata: +/* +* DMA Errata: * Special programming model needed to disable DMA before end of block */ sys_cf =dma_read (OCP_SYSCONFIG );
@@ -1614,6 +1646,7 @@ int omap_stop_dma_chain_transfers(int chain_id)/* Errata - put in the old value */ dma_write (sys_cf,OCP_SYSCONFIG ); +return 0 ; }EXPORT_SYMBOL (omap_stop_dma_chain_transfers);
@@ -1729,7 +1762,7 @@ int omap_get_dma_chain_src_pos(int chain_id) return dma_read(CSAC(lch)); }EXPORT_SYMBOL (omap_get_dma_chain_src_pos); -#endif +#endif /* ifndef CONFIG_ARCH_OMAP1 */ /*----------------------------------------------------------------------------*/
@@ -1765,6 +1798,7 @@ static int omap1_dma_handle_ch(int ch) dma_chan[ch].flags &= ~OMAP_DMA_ACTIVE ;if (likely (dma_chan[ch].callback !=NULL )) dma_chan[ch].callback (ch, csr, dma_chan[ch].data); +return 1 ; }
@@ -1799,7 +1833,8 @@ static int omap2_dma_handle_ch(int ch)if (!status) {if (printk_ratelimit ()) -printk (KERN_WARNING "Spurious DMA IRQ for lch %d\n" , ch); +printk (KERN_WARNING "Spurious DMA IRQ for lch %d\n" , + ch);dma_write (1 << ch,IRQSTATUS_L0 );return 0 ; }
@@ -1887,7 +1922,7 @@ static struct irqaction omap24xx_dma_irq; static struct lcd_dma_info { spinlock_t lock; int reserved; - void (* callback)(u16 status, void *data); + void (*callback)(u16 status, void *data); void *cb_data; int active;
@@ -1909,6 +1944,7 @@ void omap_set_lcd_dma_b1(unsigned long addr, u16 fb_xres, u16 fb_yres, lcd_dma.xres = fb_xres; lcd_dma.yres = fb_yres; } +EXPORT_SYMBOL (omap_set_lcd_dma_b1);void omap_set_lcd_dma_src_port (int port) {
@@ -1919,12 +1955,13 @@ void omap_set_lcd_dma_ext_controller(int external) { lcd_dma.ext_ctrl = external; } +EXPORT_SYMBOL (omap_set_lcd_dma_ext_controller);void omap_set_lcd_dma_single_transfer (int single) { lcd_dma.single_transfer = single; } - +EXPORT_SYMBOL (omap_set_lcd_dma_single_transfer);void omap_set_lcd_dma_b1_rotation (int rotate) {
@@ -1935,6 +1972,7 @@ void omap_set_lcd_dma_b1_rotation(int rotate) } lcd_dma.rotate = rotate; } +EXPORT_SYMBOL (omap_set_lcd_dma_b1_rotation);void omap_set_lcd_dma_b1_mirror (int mirror) {
@@ -1944,6 +1982,7 @@ void omap_set_lcd_dma_b1_mirror(int mirror) } lcd_dma.mirror = mirror; } +EXPORT_SYMBOL (omap_set_lcd_dma_b1_mirror);void omap_set_lcd_dma_b1_vxres (unsigned long vxres) {
@@ -1954,6 +1993,7 @@ void omap_set_lcd_dma_b1_vxres(unsigned long vxres) } lcd_dma.vxres = vxres; } +EXPORT_SYMBOL (omap_set_lcd_dma_b1_vxres);void omap_set_lcd_dma_b1_scale (unsigned int xscale,unsigned int yscale) {
@@ -1964,6 +2004,7 @@ void omap_set_lcd_dma_b1_scale(unsigned int xscale, unsigned int yscale) lcd_dma.xscale = xscale; lcd_dma.yscale = yscale; } +EXPORT_SYMBOL (omap_set_lcd_dma_b1_scale);static void set_b1_regs (void ) {
@@ -1994,8 +2035,11 @@ static void set_b1_regs(void) xscale = lcd_dma.xscale ? lcd_dma.xscale :1 ; yscale = lcd_dma.yscale ? lcd_dma.yscale :1 ;BUG_ON (vxres < lcd_dma.xres); -#define PIXADDR (x,y) (lcd_dma.addr + ((y) * vxres * yscale + (x) * xscale) * es) + +#define PIXADDR (x, y) (lcd_dma.addr + \ + ((y) * vxres * yscale + (x) * xscale) * es)#define PIXSTEP (sx, sy, dx, dy) (PIXADDR(dx, dy) - PIXADDR(sx, sy) - es + 1) +switch (lcd_dma.rotate) {case 0 :if (!lcd_dma.mirror) {
@@ -2004,8 +2048,8 @@ static void set_b1_regs(void)/* 1510 DMA requires the bottom address to be 2 more * than the actual last memory access location. */ if (omap_dma_in_1510_mode () && - lcd_dma.data_type ==OMAP_DMA_DATA_TYPE_S32 ) - bottom +=2 ; + lcd_dma.data_type ==OMAP_DMA_DATA_TYPE_S32 ) + bottom +=2 ; ei =PIXSTEP (0 ,0 ,1 ,0 ); fi =PIXSTEP (lcd_dma.xres -1 ,0 ,0 ,1 ); }else {
@@ -2132,7 +2176,7 @@ static irqreturn_t lcd_dma_irq_handler(int irq, void *dev_id)return IRQ_HANDLED ; } -int omap_request_lcd_dma (void (* callback)(u16 status,void *data), +int omap_request_lcd_dma (void (*callback)(u16 status,void *data),void *data) {spin_lock_irq (&lcd_dma.lock);
@@ -2158,6 +2202,7 @@ int omap_request_lcd_dma(void (* callback)(u16 status, void *data),return 0 ; } +EXPORT_SYMBOL (omap_request_lcd_dma);void omap_free_lcd_dma (void ) {
@@ -2174,12 +2219,14 @@ void omap_free_lcd_dma(void) lcd_dma.reserved =0 ;spin_unlock (&lcd_dma.lock); } +EXPORT_SYMBOL (omap_free_lcd_dma);void omap_enable_lcd_dma (void ) {u16 w; -/* Set the Enable bit only if an external controller is +/* +* Set the Enable bit only if an external controller is * connected. Otherwise the OMAP internal controller will * start the transfer when it gets enabled. */
@@ -2196,6 +2243,7 @@ void omap_enable_lcd_dma(void) w |=1 <<7 ;omap_writew (w,OMAP1610_DMA_LCD_CCR ); } +EXPORT_SYMBOL (omap_enable_lcd_dma);void omap_setup_lcd_dma (void ) {
@@ -2211,16 +2259,18 @@ void omap_setup_lcd_dma(void)u16 w; w =omap_readw (OMAP1610_DMA_LCD_CCR ); -/* If DMA was already active set the end_prog bit to have +/* +* If DMA was already active set the end_prog bit to have * the programmed register set loaded into the active * register set. */ w |=1 <<11 ;/* End_prog */ if (!lcd_dma.single_transfer) - w |= (3 <<8 );/* Auto_init, repeat */ + w |= (3 <<8 );/* Auto_init, repeat */ omap_writew (w,OMAP1610_DMA_LCD_CCR ); } } +EXPORT_SYMBOL (omap_setup_lcd_dma);void omap_stop_lcd_dma (void ) {
@@ -2238,6 +2288,7 @@ void omap_stop_lcd_dma(void) w &= ~(1 <<8 );omap_writew (w,OMAP1610_DMA_LCD_CTRL ); } +EXPORT_SYMBOL (omap_stop_lcd_dma);/*----------------------------------------------------------------------------*/
@@ -2327,8 +2378,10 @@ static int __init omap_init_dma(void)continue ;if (cpu_class_is_omap1 ()) { -/* request_irq() doesn't like dev_id (ie. ch) being -* zero, so we have to kludge around this. */ +/* +* request_irq() doesn't like dev_id (ie. ch) being +* zero, so we have to kludge around this. +*/ r =request_irq (omap1_dma_irq[ch], omap1_dma_irq_handler,0 ,"DMA" , (void *) (ch +1 ));
@@ -2373,48 +2426,4 @@ static int __init omap_init_dma(void)arch_initcall (omap_init_dma); -EXPORT_SYMBOL (omap_get_dma_src_pos); -EXPORT_SYMBOL (omap_get_dma_dst_pos); -EXPORT_SYMBOL (omap_get_dma_src_addr_counter); -EXPORT_SYMBOL (omap_clear_dma); -EXPORT_SYMBOL (omap_set_dma_priority); -EXPORT_SYMBOL (omap_request_dma); -EXPORT_SYMBOL (omap_free_dma); -EXPORT_SYMBOL (omap_start_dma); -EXPORT_SYMBOL (omap_stop_dma); -EXPORT_SYMBOL (omap_set_dma_callback); -EXPORT_SYMBOL (omap_enable_dma_irq); -EXPORT_SYMBOL (omap_disable_dma_irq); - -EXPORT_SYMBOL (omap_set_dma_transfer_params); -EXPORT_SYMBOL (omap_set_dma_color_mode); -EXPORT_SYMBOL (omap_set_dma_write_mode); - -EXPORT_SYMBOL (omap_set_dma_src_params); -EXPORT_SYMBOL (omap_set_dma_src_index); -EXPORT_SYMBOL (omap_set_dma_src_data_pack); -EXPORT_SYMBOL (omap_set_dma_src_burst_mode); - -EXPORT_SYMBOL (omap_set_dma_dest_params); -EXPORT_SYMBOL (omap_set_dma_dest_index); -EXPORT_SYMBOL (omap_set_dma_dest_data_pack); -EXPORT_SYMBOL (omap_set_dma_dest_burst_mode); - -EXPORT_SYMBOL (omap_set_dma_params); - -EXPORT_SYMBOL (omap_dma_link_lch); -EXPORT_SYMBOL (omap_dma_unlink_lch); - -EXPORT_SYMBOL (omap_request_lcd_dma); -EXPORT_SYMBOL (omap_free_lcd_dma); -EXPORT_SYMBOL (omap_enable_lcd_dma); -EXPORT_SYMBOL (omap_setup_lcd_dma); -EXPORT_SYMBOL (omap_stop_lcd_dma); -EXPORT_SYMBOL (omap_set_lcd_dma_b1); -EXPORT_SYMBOL (omap_set_lcd_dma_single_transfer); -EXPORT_SYMBOL (omap_set_lcd_dma_ext_controller); -EXPORT_SYMBOL (omap_set_lcd_dma_b1_rotation); -EXPORT_SYMBOL (omap_set_lcd_dma_b1_vxres); -EXPORT_SYMBOL (omap_set_lcd_dma_b1_scale); -EXPORT_SYMBOL (omap_set_lcd_dma_b1_mirror);
include/asm-arm/arch-omap/dma.h +103 -58
228 lines not on this page · raw message
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Tony Lindgren
maintainerPATCH 7/21 ARM: OMAP: SRAM: Move sram-fn.S from plat-omap to mach-omap1
This file is omap1 specific.
arch/arm/mach-omap1/Makefile +1 -1
@@ -3,7 +3,7 @@ # # Common support -obj-y := io.o id.o clock.o irq.o mux.o serial.o devices.o +obj-y := io.o id.o sram.o clock.o irq.o mux.o serial.o devices.o obj-$(CONFIG_OMAP_MPU_TIMER) += time.o obj-$(CONFIG_OMAP_32K_TIMER) += timer32k.o
arch/arm/mach-omap1/sram.S new file +57 -0
57 lines not on this page · raw message
arch/arm/plat-omap/Makefile +1 -1
@@ -3,7 +3,7 @@ # # Common support -obj-y := common.o sram.o sram-fn.o clock.o devices.o dma.o mux.o gpio.o \ +obj-y := common.o sram.o clock.o devices.o dma.o mux.o gpio.o \ usb.o fb.o obj-m := obj-n :=
arch/arm/plat-omap/sram-fn.S deleted +0 -57
57 lines not on this page · raw message
Tony Lindgren
maintainerPATCH 8/21 ARM: OMAP: SRAM: Move omap2 sram-fn.S to sram242x.S
This file will get split between sram242x.S and sram243x.S in following patch.
arch/arm/mach-omap2/Makefile +1 -1
@@ -3,7 +3,7 @@ # # Common support -obj-y := irq.o id.o io.o sram-fn.o memory.o control.o prcm.o clock.o mux.o \ +obj-y := irq.o id.o io.o sram242x.o memory.o control.o prcm.o clock.o mux.o \ devices.o serial.o gpmc.o timer-gp.o # Power Management
arch/arm/mach-omap2/sram-fn.S deleted +0 -324
324 lines not on this page · raw message
arch/arm/mach-omap2/sram242x.S new file +324 -0
324 lines not on this page · raw message
Tony Lindgren
maintainerPATCH 9/21 ARM: OMAP: SRAM: Split sram24xx.S into sram242x.S and sram243x.S
Split sram24xx.S into sram242x.S and sram243x.S
arch/arm/mach-omap1/sram.S +3 -3
@@ -18,7 +18,7 @@ /* * Reprograms ULPD and CKCTL. */ -ENTRY(sram_reprogram_clock) +ENTRY(omap1_sram_reprogram_clock) stmfd sp!, {r0 - r12, lr} @ save registers on stack mov r2, #IO_ADDRESS(DPLL_CTL) & 0xff000000
@@ -53,5 +53,5 @@ lock: ldrh r4, [r2], #0 @ read back dpll value out: ldmfd sp!, {r0 - r12, pc} @ restore regs and return -ENTRY(sram_reprogram_clock_sz) - .word . - sram_reprogram_clock +ENTRY(omap1_sram_reprogram_clock_sz) + .word . - omap1_sram_reprogram_clock
arch/arm/mach-omap2/Makefile +5 -1
@@ -3,9 +3,13 @@ # # Common support -obj-y := irq.o id.o io.o sram242x.o memory.o control.o prcm.o clock.o mux.o \ +obj-y := irq.o id.o io.o memory.o control.o prcm.o clock.o mux.o \ devices.o serial.o gpmc.o timer-gp.o +# Functions loaded to SRAM +obj-$(CONFIG_ARCH_OMAP2420) += sram242x.o +obj-$(CONFIG_ARCH_OMAP2430) += sram243x.o + # Power Management obj-$(CONFIG_PM) += pm.o sleep.o
arch/arm/mach-omap2/clock.c +2 -1
@@ -603,7 +603,8 @@ int omap2_clksel_set_rate(struct clk *clk, unsigned long rate) clk->rate = clk->parent->rate / new_div;if (clk->flags &DELAYED_APP &&cpu_is_omap24xx ()) { -__raw_writel (OMAP24XX_VALID_CONFIG ,OMAP24XX_PRCM_CLKCFG_CTRL ); +prm_write_mod_reg (OMAP24XX_VALID_CONFIG , +OMAP24XX_GR_MOD ,OMAP24XX_PRCM_CLKCFG_CTRL_OFFSET );wmb (); }
arch/arm/mach-omap2/prcm-common.h +1 -0
@@ -32,6 +32,7 @@/* Chip-specific module offsets */ +#define OMAP24XX_GR_MOD OCP_MOD#define OMAP24XX_DSP_MOD 0x800#define OMAP2430_MDM_MOD 0xc00
arch/arm/mach-omap2/prm.h +17 -1
@@ -38,13 +38,29 @@* */ +/* Global 24xx registers in GR_MOD (Same as OCP_MOD for 24xx) */ +#define OMAP24XX_PRCM_VOLTCTRL_OFFSET 0x0050 +#define OMAP24XX_PRCM_CLKCFG_CTRL_OFFSET 0x0080 + +/* 242x GR_MOD registers, use these only for assembly code */ +#define OMAP242X_PRCM_VOLTCTRL OMAP2420_PRM_REGADDR(OMAP24XX_GR_MOD, \ + OMAP24XX_PRCM_VOLTCTRL_OFFSET) +#define OMAP242X_PRCM_CLKCFG_CTRL OMAP2420_PRM_REGADDR(OMAP24XX_GR_MOD, \ + OMAP24XX_PRCM_CLKCFG_CTRL_OFFSET) + +/* 243x GR_MOD registers, use these only for assembly code */ +#define OMAP243X_PRCM_VOLTCTRL OMAP2430_PRM_REGADDR(OMAP24XX_GR_MOD, \ + OMAP24XX_PRCM_VOLTCTRL_OFFSET) +#define OMAP243X_PRCM_CLKCFG_CTRL OMAP2430_PRM_REGADDR(OMAP24XX_GR_MOD, \ + OMAP24XX_PRCM_CLKCFG_CTRL_OFFSET) + +/* These will disappear */ #define OMAP24XX_PRCM_REVISION OMAP_PRM_REGADDR(OCP_MOD, 0x0000)#define OMAP24XX_PRCM_SYSCONFIG OMAP_PRM_REGADDR(OCP_MOD, 0x0010)#define OMAP24XX_PRCM_IRQSTATUS_MPU OMAP_PRM_REGADDR(OCP_MOD, 0x0018)#define OMAP24XX_PRCM_IRQENABLE_MPU OMAP_PRM_REGADDR(OCP_MOD, 0x001c) -#define OMAP24XX_PRCM_VOLTCTRL OMAP_PRM_REGADDR(OCP_MOD, 0x0050)#define OMAP24XX_PRCM_VOLTST OMAP_PRM_REGADDR(OCP_MOD, 0x0054)#define OMAP24XX_PRCM_CLKSRC_CTRL OMAP_PRM_REGADDR(OCP_MOD, 0x0060)#define OMAP24XX_PRCM_CLKOUT_CTRL OMAP_PRM_REGADDR(OCP_MOD, 0x0070)
arch/arm/mach-omap2/sram242x.S +51 -54
243 lines not on this page · raw message
arch/arm/mach-omap2/sram243x.S new file +321 -0
321 lines not on this page · raw message
arch/arm/plat-omap/sram.c +176 -35
295 lines not on this page · raw message
include/asm-arm/arch-omap/sram.h +28 -9
@@ -11,6 +11,7 @@#ifndef __ARCH_ARM_OMAP_SRAM_H#define __ARCH_ARM_OMAP_SRAM_H +extern int __init omap_sram_init (void );extern void *omap_sram_push (void * start,unsigned long size);extern void omap_sram_reprogram_clock (u32 dpllctl,u32 ckctl);
@@ -21,17 +22,35 @@ extern void omap2_sram_reprogram_sdrc(u32 perf_level, u32 dll_val,extern u32 omap2_set_prcm (u32 dpll_ctrl_val,u32 sdrc_rfr_val,int bypass);/* Do not use these */ -extern void sram_reprogram_clock (u32 ckctl,u32 dpllctl); -extern unsigned long sram_reprogram_clock_sz; +extern void omap1_sram_reprogram_clock (u32 ckctl,u32 dpllctl); +extern unsigned long omap1_sram_reprogram_clock_sz; -extern void sram_ddr_init (u32 *slow_dll_ctrl,u32 fast_dll_ctrl, -u32 base_cs,u32 force_unlock); -extern unsigned long sram_ddr_init_sz; +extern void omap24xx_sram_reprogram_clock (u32 ckctl,u32 dpllctl); +extern unsigned long omap24xx_sram_reprogram_clock_sz; -extern u32 sram_set_prcm (u32 dpll_ctrl_val,u32 sdrc_rfr_val,int bypass); -extern unsigned long sram_set_prcm_sz; +extern void omap242x_sram_ddr_init (u32 *slow_dll_ctrl,u32 fast_dll_ctrl, +u32 base_cs,u32 force_unlock); +extern unsigned long omap242x_sram_ddr_init_sz; -extern void sram_reprogram_sdrc (u32 perf_level,u32 dll_val,u32 mem_type); -extern unsigned long sram_reprogram_sdrc_sz; +extern u32 omap242x_sram_set_prcm (u32 dpll_ctrl_val,u32 sdrc_rfr_val, +int bypass); +extern unsigned long omap242x_sram_set_prcm_sz; + +extern void omap242x_sram_reprogram_sdrc (u32 perf_level,u32 dll_val, +u32 mem_type); +extern unsigned long omap242x_sram_reprogram_sdrc_sz; + + +extern void omap243x_sram_ddr_init (u32 *slow_dll_ctrl,u32 fast_dll_ctrl, +u32 base_cs,u32 force_unlock); +extern unsigned long omap243x_sram_ddr_init_sz; + +extern u32 omap243x_sram_set_prcm (u32 dpll_ctrl_val,u32 sdrc_rfr_val, +int bypass); +extern unsigned long omap243x_sram_set_prcm_sz; + +extern void omap243x_sram_reprogram_sdrc (u32 perf_level,u32 dll_val, +u32 mem_type); +extern unsigned long omap243x_sram_reprogram_sdrc_sz;#endif
Tony Lindgren
maintainerPATCH 10/21 ARM: OMAP: McBSP: Coding style cleanup on arch/arm/plat-omap/mcbsp.c
From: Eduardo Valentin <[email protected]>
This patch fix lots of warnings and errors reported by scripts/checkpatch.pl on arch/arm/plat-omap/mcbsp.c.
arch/arm/plat-omap/mcbsp.c +103 -95
@@ -21,9 +21,8 @@#include <linux/err.h> #include <linux/clk.h> #include <linux/delay.h> - -#include <asm/io.h> -#include <asm/irq.h> +#include <linux/io.h> +#include <linux/irq.h> #include <asm/arch/dma.h> #include <asm/arch/mux.h>
@@ -61,20 +60,21 @@ struct omap_mcbsp {struct completion tx_dma_completion;struct completion rx_dma_completion; +/* Protect the field .free, while checking if the mcbsp is in use */ spinlock_t lock; };static struct omap_mcbsp mcbsp[OMAP_MAX_MCBSP_COUNT ];#ifdef CONFIG_ARCH_OMAP1 -static struct clk *mcbsp_dsp_ck =0 ; -static struct clk *mcbsp_api_ck =0 ; -static struct clk *mcbsp_dspxor_ck =0 ; +static struct clk *mcbsp_dsp_ck; +static struct clk *mcbsp_api_ck; +static struct clk *mcbsp_dspxor_ck;#endif #ifdef CONFIG_ARCH_OMAP2 -static struct clk *mcbsp1_ick =0 ; -static struct clk *mcbsp1_fck =0 ; -static struct clk *mcbsp2_ick =0 ; -static struct clk *mcbsp2_fck =0 ; +static struct clk *mcbsp1_ick; +static struct clk *mcbsp1_fck; +static struct clk *mcbsp2_ick; +static struct clk *mcbsp2_fck;#endif static void omap_mcbsp_dump_reg (u8 id)
@@ -104,6 +104,7 @@ static irqreturn_t omap_mcbsp_tx_irq_handler(int irq, void *dev_id) OMAP_MCBSP_READ(mcbsp_tx->io_base, SPCR2));complete (&mcbsp_tx->tx_irq_completion); +return IRQ_HANDLED ; }
@@ -115,6 +116,7 @@ static irqreturn_t omap_mcbsp_rx_irq_handler(int irq, void *dev_id) OMAP_MCBSP_READ(mcbsp_rx->io_base, SPCR2));complete (&mcbsp_rx->rx_irq_completion); +return IRQ_HANDLED ; }
@@ -146,19 +148,17 @@ static void omap_mcbsp_rx_dma_callback(int lch, u16 ch_status, void *data)complete (&mcbsp_dma_rx->rx_dma_completion); } -/* * omap_mcbsp_config simply write a config to the * appropriate McBSP. * You either call this function or set the McBSP registers * by yourself before calling omap_mcbsp_start(). */ - -void omap_mcbsp_config (unsigned int id,const struct omap_mcbsp_reg_cfg * config) +void omap_mcbsp_config (unsigned int id,const struct omap_mcbsp_reg_cfg *config) {u32 io_base = mcbsp[id].io_base; -DBG ("OMAP-McBSP: McBSP%d io_base: 0x%8x\n" , id+1 , io_base); +DBG ("OMAP-McBSP: McBSP%d io_base: 0x%8x\n" , id +1 , io_base);/* We write the given config */ OMAP_MCBSP_WRITE (io_base,SPCR2 , config->spcr2);
@@ -173,14 +173,14 @@ void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg * configOMAP_MCBSP_WRITE (io_base,MCR1 , config->mcr1);OMAP_MCBSP_WRITE (io_base,PCR0 , config->pcr0); } - - +EXPORT_SYMBOL (omap_mcbsp_config);static int omap_mcbsp_check (unsigned int id) {if (cpu_is_omap730 ()) {if (id >OMAP_MAX_MCBSP_COUNT -1 ) { -printk (KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n" , id +1 ); +printk (KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n" , + id +1 );return -1 ; }return 0 ;
@@ -188,7 +188,8 @@ static int omap_mcbsp_check(unsigned int id)if (cpu_is_omap15xx () ||cpu_is_omap16xx () ||cpu_is_omap24xx ()) {if (id >OMAP_MAX_MCBSP_COUNT ) { -printk (KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n" , id +1 ); +printk (KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n" , + id +1 );return -1 ; }return 0 ;
@@ -263,7 +264,8 @@ int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type)spin_lock (&mcbsp[id].lock);if (!mcbsp[id].free) { -printk (KERN_ERR "OMAP-McBSP: McBSP%d is currently in use\n" , id +1 ); +printk (KERN_ERR "OMAP-McBSP: McBSP%d is currently in use\n" , + id +1 );spin_unlock (&mcbsp[id].lock);return -EINVAL ; }
@@ -274,6 +276,7 @@ int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type)return 0 ; } +EXPORT_SYMBOL (omap_mcbsp_set_io_type);int omap_mcbsp_request (unsigned int id) {
@@ -305,7 +308,8 @@ int omap_mcbsp_request(unsigned int id)spin_lock (&mcbsp[id].lock);if (!mcbsp[id].free) { -printk (KERN_ERR "OMAP-McBSP: McBSP%d is currently in use\n" , id +1 ); +printk (KERN_ERR "OMAP-McBSP: McBSP%d is currently in use\n" , + id +1 );spin_unlock (&mcbsp[id].lock);return -1 ; }
@@ -315,24 +319,23 @@ int omap_mcbsp_request(unsigned int id)if (mcbsp[id].io_type ==OMAP_MCBSP_IRQ_IO ) {/* We need to get IRQs here */ - err =request_irq (mcbsp[id].tx_irq, omap_mcbsp_tx_irq_handler,0 , -"McBSP" , - (void *) (&mcbsp[id])); + err =request_irq (mcbsp[id].tx_irq, omap_mcbsp_tx_irq_handler, +0 ,"McBSP" , (void *) (&mcbsp[id]));if (err !=0 ) { -printk (KERN_ERR "OMAP-McBSP: Unable to request TX IRQ %d for McBSP%d\n" , - mcbsp[id].tx_irq, mcbsp[id].id); +printk (KERN_ERR "OMAP-McBSP: Unable to " +"request TX IRQ %d for McBSP%d\n" , + mcbsp[id].tx_irq, mcbsp[id].id);return err; }init_completion (&(mcbsp[id].tx_irq_completion)); - - err =request_irq (mcbsp[id].rx_irq, omap_mcbsp_rx_irq_handler,0 , -"McBSP" , - (void *) (&mcbsp[id])); + err =request_irq (mcbsp[id].rx_irq, omap_mcbsp_rx_irq_handler, +0 ,"McBSP" , (void *) (&mcbsp[id]));if (err !=0 ) { -printk (KERN_ERR "OMAP-McBSP: Unable to request RX IRQ %d for McBSP%d\n" , - mcbsp[id].rx_irq, mcbsp[id].id); +printk (KERN_ERR "OMAP-McBSP: Unable to " +"request RX IRQ %d for McBSP%d\n" , + mcbsp[id].rx_irq, mcbsp[id].id);free_irq (mcbsp[id].tx_irq, (void *) (&mcbsp[id]));return err; }
@@ -341,8 +344,8 @@ int omap_mcbsp_request(unsigned int id) }return 0 ; - } +EXPORT_SYMBOL (omap_mcbsp_request);void omap_mcbsp_free (unsigned int id) {
@@ -370,7 +373,8 @@ void omap_mcbsp_free(unsigned int id)spin_lock (&mcbsp[id].lock);if (mcbsp[id].free) { -printk (KERN_ERR "OMAP-McBSP: McBSP%d was not reserved\n" , id +1 ); +printk (KERN_ERR "OMAP-McBSP: McBSP%d was not reserved\n" , + id +1 );spin_unlock (&mcbsp[id].lock);return ; }
@@ -384,6 +388,7 @@ void omap_mcbsp_free(unsigned int id)free_irq (mcbsp[id].tx_irq, (void *) (&mcbsp[id])); } } +EXPORT_SYMBOL (omap_mcbsp_free);/* * Here we start the McBSP, by enabling the sample
@@ -400,8 +405,8 @@ void omap_mcbsp_start(unsigned int id) io_base = mcbsp[id].io_base; - mcbsp[id].rx_word_length = ((OMAP_MCBSP_READ (io_base,RCR1 ) >>5 ) &0x7 ); - mcbsp[id].tx_word_length = ((OMAP_MCBSP_READ (io_base,XCR1 ) >>5 ) &0x7 ); + mcbsp[id].rx_word_length = (OMAP_MCBSP_READ (io_base,RCR1 ) >>5 ) &0x7 ; + mcbsp[id].tx_word_length = (OMAP_MCBSP_READ (io_base,XCR1 ) >>5 ) &0x7 ;/* Start the sample generator */ w =OMAP_MCBSP_READ (io_base,SPCR2 );
@@ -422,8 +427,8 @@ void omap_mcbsp_start(unsigned int id)/* Dump McBSP Regs */ omap_mcbsp_dump_reg (id); - } +EXPORT_SYMBOL (omap_mcbsp_start);void omap_mcbsp_stop (unsigned int id) {
@@ -435,7 +440,7 @@ void omap_mcbsp_stop(unsigned int id) io_base = mcbsp[id].io_base; -/* Reset transmitter */ +/* Reset transmitter */ w =OMAP_MCBSP_READ (io_base,SPCR2 );OMAP_MCBSP_WRITE (io_base,SPCR2 , w & ~(1 ));
@@ -447,7 +452,7 @@ void omap_mcbsp_stop(unsigned int id) w =OMAP_MCBSP_READ (io_base,SPCR2 );OMAP_MCBSP_WRITE (io_base,SPCR2 , w & ~(1 <<6 )); } - +EXPORT_SYMBOL (omap_mcbsp_stop);/* polled mcbsp i/o operations */ int omap_mcbsp_pollwrite (unsigned int id,u16 buf)
@@ -480,10 +485,12 @@ int omap_mcbsp_pollwrite(unsigned int id, u16 buf) } } } +return 0 ; } +EXPORT_SYMBOL (omap_mcbsp_pollwrite); -int omap_mcbsp_pollread (unsigned int id,u16 * buf) +int omap_mcbsp_pollread (unsigned int id,u16 *buf) {u32 base = mcbsp[id].io_base;/* if frame sync error - clear the error */
@@ -513,8 +520,10 @@ int omap_mcbsp_pollread(unsigned int id, u16 * buf) } } *buf =readw (base +OMAP_MCBSP_REG_DRR1 ); +return 0 ; } +EXPORT_SYMBOL (omap_mcbsp_pollread);/* * IRQ based word transmission.
@@ -535,6 +544,7 @@ void omap_mcbsp_xmit_word(unsigned int id, u32 word)OMAP_MCBSP_WRITE (io_base,DXR2 , word >>16 );OMAP_MCBSP_WRITE (io_base,DXR1 , word &0xffff ); } +EXPORT_SYMBOL (omap_mcbsp_xmit_word);u32 omap_mcbsp_recv_word (unsigned int id) {
@@ -555,7 +565,7 @@ u32 omap_mcbsp_recv_word(unsigned int id)return (word_lsb | (word_msb <<16 )); } - +EXPORT_SYMBOL (omap_mcbsp_recv_word);int omap_mcbsp_spi_master_xmit_word_poll (unsigned int id,u32 word) {
@@ -577,7 +587,7 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)udelay (10 );OMAP_MCBSP_WRITE (io_base,SPCR2 , spcr2 |XRST );udelay (10 ); -printk ("McBSP transmitter not ready\n" ); +printk (KERN_ERR "McBSP transmitter not ready\n" );return -EAGAIN ; } }
@@ -597,7 +607,7 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)udelay (10 );OMAP_MCBSP_WRITE (io_base,SPCR1 , spcr1 |RRST );udelay (10 ); -printk ("McBSP receiver not ready\n" ); +printk (KERN_ERR "McBSP receiver not ready\n" );return -EAGAIN ; } }
@@ -609,8 +619,9 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)return 0 ; } +EXPORT_SYMBOL (omap_mcbsp_spi_master_xmit_word_poll); -int omap_mcbsp_spi_master_recv_word_poll (unsigned int id,u32 * word) +int omap_mcbsp_spi_master_recv_word_poll (unsigned int id,u32 *word) {u32 io_base = mcbsp[id].io_base, clock_word =0 ;omap_mcbsp_word_length tx_word_length = mcbsp[id].tx_word_length;
@@ -630,7 +641,7 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word)udelay (10 );OMAP_MCBSP_WRITE (io_base,SPCR2 , spcr2 |XRST );udelay (10 ); -printk ("McBSP transmitter not ready\n" ); +printk (KERN_ERR "McBSP transmitter not ready\n" );return -EAGAIN ; } }
@@ -650,7 +661,7 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word)udelay (10 );OMAP_MCBSP_WRITE (io_base,SPCR1 , spcr1 |RRST );udelay (10 ); -printk ("McBSP receiver not ready\n" ); +printk (KERN_ERR "McBSP receiver not ready\n" );return -EAGAIN ; } }
@@ -664,7 +675,7 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word)return 0 ; } - +EXPORT_SYMBOL (omap_mcbsp_spi_master_recv_word_poll);/* * Simple DMA based buffer rx/tx routines.
@@ -673,7 +684,8 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word)* For anything fancier, you should use your own customized DMA * routines and callbacks. */ -int omap_mcbsp_xmit_buffer (unsigned int id,dma_addr_t buffer,unsigned int length) +int omap_mcbsp_xmit_buffer (unsigned int id,dma_addr_t buffer, +unsigned int length) {int dma_tx_ch;int src_port =0 ;
@@ -683,10 +695,12 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer, unsigned int lengif (omap_mcbsp_check (id) <0 )return -EINVAL ; -if (omap_request_dma (mcbsp[id].dma_tx_sync,"McBSP TX" , omap_mcbsp_tx_dma_callback, - &mcbsp[id], - &dma_tx_ch)) { -printk ("OMAP-McBSP: Unable to request DMA channel for McBSP%d TX. Trying IRQ based TX\n" , id+1 ); +if (omap_request_dma (mcbsp[id].dma_tx_sync,"McBSP TX" , + omap_mcbsp_tx_dma_callback, + &mcbsp[id], + &dma_tx_ch)) { +printk (KERN_ERR "OMAP-McBSP: Unable to request DMA channel for" +" McBSP%d TX. Trying IRQ based TX\n" , id +1 );return -EAGAIN ; } mcbsp[id].dma_tx_lch = dma_tx_ch;
@@ -722,11 +736,13 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer, unsigned int lengomap_start_dma (mcbsp[id].dma_tx_lch);wait_for_completion (&(mcbsp[id].tx_dma_completion)); +return 0 ; } +EXPORT_SYMBOL (omap_mcbsp_xmit_buffer); - -int omap_mcbsp_recv_buffer (unsigned int id,dma_addr_t buffer,unsigned int length) +int omap_mcbsp_recv_buffer (unsigned int id,dma_addr_t buffer, +unsigned int length) {int dma_rx_ch;int src_port =0 ;
@@ -736,10 +752,12 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int lengif (omap_mcbsp_check (id) <0 )return -EINVAL ; -if (omap_request_dma (mcbsp[id].dma_rx_sync,"McBSP RX" , omap_mcbsp_rx_dma_callback, - &mcbsp[id], - &dma_rx_ch)) { -printk ("Unable to request DMA channel for McBSP%d RX. Trying IRQ based RX\n" , id+1 ); +if (omap_request_dma (mcbsp[id].dma_rx_sync,"McBSP RX" , + omap_mcbsp_rx_dma_callback, + &mcbsp[id], + &dma_rx_ch)) { +printk (KERN_ERR "Unable to request DMA channel for McBSP%d RX." +" Trying IRQ based RX\n" , id +1 );return -EAGAIN ; } mcbsp[id].dma_rx_lch = dma_rx_ch;
@@ -756,10 +774,10 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng sync_dev = mcbsp[id].dma_rx_sync;omap_set_dma_transfer_params (mcbsp[id].dma_rx_lch, -OMAP_DMA_DATA_TYPE_S16 , - length >>1 ,1 , -OMAP_DMA_SYNC_ELEMENT , - sync_dev,0 ); +OMAP_DMA_DATA_TYPE_S16 , + length >>1 ,1 , +OMAP_DMA_SYNC_ELEMENT , + sync_dev,0 ); omap_set_dma_src_params(mcbsp[id].dma_rx_lch, src_port,
@@ -768,16 +786,17 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng 0, 0);omap_set_dma_dest_params (mcbsp[id].dma_rx_lch, - dest_port, -OMAP_DMA_AMODE_POST_INC , - buffer, -0 ,0 ); + dest_port, +OMAP_DMA_AMODE_POST_INC , + buffer, +0 ,0 );omap_start_dma (mcbsp[id].dma_rx_lch);wait_for_completion (&(mcbsp[id].rx_dma_completion)); +return 0 ; } - +EXPORT_SYMBOL (omap_mcbsp_recv_buffer);/* * SPI wrapper.
@@ -785,7 +804,8 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng* this wrapper just need an omap_mcbsp_spi_cfg structure as an input. * Once this is done, you can call omap_mcbsp_start(). */ -void omap_mcbsp_set_spi_mode (unsigned int id,const struct omap_mcbsp_spi_cfg * spi_cfg) +void omap_mcbsp_set_spi_mode (unsigned int id, +const struct omap_mcbsp_spi_cfg *spi_cfg) {struct omap_mcbsp_reg_cfg mcbsp_cfg;
@@ -798,7 +818,7 @@ void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg * mcbsp_cfg.rcr1 |= (RWDLEN1 (spi_cfg->word_length) |RFRLEN1 (0 )); mcbsp_cfg.xcr1 |= (XWDLEN1 (spi_cfg->word_length) |XFRLEN1 (0 )); -/* Clock stop mode */ +/* Clock stop mode */ if (spi_cfg->clk_stp_mode ==OMAP_MCBSP_CLK_STP_MODE_NO_DELAY ) mcbsp_cfg.spcr1 |= (1 <<12 );else
@@ -827,13 +847,12 @@ void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg *if (spi_cfg->spi_mode ==OMAP_MCBSP_SPI_MASTER ) { mcbsp_cfg.pcr0 |=CLKXM ; - mcbsp_cfg.srgr1 |=CLKGDV (spi_cfg->clk_div -1 ); + mcbsp_cfg.srgr1 |=CLKGDV (spi_cfg->clk_div -1 ); mcbsp_cfg.pcr0 |=FSXM ; mcbsp_cfg.srgr2 &= ~FSGM ; mcbsp_cfg.xcr2 |=XDATDLY (1 ); mcbsp_cfg.rcr2 |=RDATDLY (1 ); - } -else { + }else { mcbsp_cfg.pcr0 &= ~CLKXM ; mcbsp_cfg.srgr1 |=CLKGDV (1 ); mcbsp_cfg.pcr0 &= ~FSXM ;
@@ -846,7 +865,7 @@ void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg *omap_mcbsp_config (id, &mcbsp_cfg); } - +EXPORT_SYMBOL (omap_mcbsp_set_spi_mode);/* * McBSP1 and McBSP3 are directly mapped on 1610 and 1510.
@@ -935,7 +954,7 @@ static int __init omap_mcbsp_init(void)int mcbsp_count =0 , i;static const struct omap_mcbsp_info *mcbsp_info; -printk ("Initializing OMAP McBSP system\n" ); +printk (KERN_INFO "Initializing OMAP McBSP system\n" );#ifdef CONFIG_ARCH_OMAP1 mcbsp_dsp_ck =clk_get (0 ,"dsp_ck" );
@@ -957,22 +976,26 @@ static int __init omap_mcbsp_init(void)#ifdef CONFIG_ARCH_OMAP2 mcbsp1_ick =clk_get (0 ,"mcbsp1_ick" );if (IS_ERR (mcbsp1_ick)) { -printk (KERN_ERR "mcbsp: could not acquire mcbsp1_ick handle.\n" ); +printk (KERN_ERR "mcbsp: could not acquire " +"mcbsp1_ick handle.\n" );return PTR_ERR (mcbsp1_ick); } mcbsp1_fck =clk_get (0 ,"mcbsp1_fck" );if (IS_ERR (mcbsp1_fck)) { -printk (KERN_ERR "mcbsp: could not acquire mcbsp1_fck handle.\n" ); +printk (KERN_ERR "mcbsp: could not acquire " +"mcbsp1_fck handle.\n" );return PTR_ERR (mcbsp1_fck); } mcbsp2_ick =clk_get (0 ,"mcbsp2_ick" );if (IS_ERR (mcbsp2_ick)) { -printk (KERN_ERR "mcbsp: could not acquire mcbsp2_ick handle.\n" ); +printk (KERN_ERR "mcbsp: could not acquire " +"mcbsp2_ick handle.\n" );return PTR_ERR (mcbsp2_ick); } mcbsp2_fck =clk_get (0 ,"mcbsp2_fck" );if (IS_ERR (mcbsp2_fck)) { -printk (KERN_ERR "mcbsp: could not acquire mcbsp2_fck handle.\n" ); +printk (KERN_ERR "mcbsp: could not acquire " +"mcbsp2_fck handle.\n" );return PTR_ERR (mcbsp2_fck); }#endif
@@ -1006,7 +1029,7 @@ static int __init omap_mcbsp_init(void)if (i >= mcbsp_count) { mcbsp[i].io_base =0 ; mcbsp[i].free =0 ; -continue ; +continue ; } mcbsp[i].id = i +1 ; mcbsp[i].free =1 ;
@@ -1014,7 +1037,8 @@ static int __init omap_mcbsp_init(void) mcbsp[i].dma_rx_lch =-1 ; mcbsp[i].io_base = mcbsp_info[i].virt_base; - mcbsp[i].io_type =OMAP_MCBSP_IRQ_IO ;/* Default I/O is IRQ based */ +/* Default I/O is IRQ based */ + mcbsp[i].io_type =OMAP_MCBSP_IRQ_IO ; mcbsp[i].tx_irq = mcbsp_info[i].tx_irq; mcbsp[i].rx_irq = mcbsp_info[i].rx_irq; mcbsp[i].dma_rx_sync = mcbsp_info[i].dma_rx_sync;
@@ -1026,19 +1050,3 @@ static int __init omap_mcbsp_init(void) }arch_initcall (omap_mcbsp_init); - -EXPORT_SYMBOL (omap_mcbsp_config); -EXPORT_SYMBOL (omap_mcbsp_request); -EXPORT_SYMBOL (omap_mcbsp_set_io_type); -EXPORT_SYMBOL (omap_mcbsp_free); -EXPORT_SYMBOL (omap_mcbsp_start); -EXPORT_SYMBOL (omap_mcbsp_stop); -EXPORT_SYMBOL (omap_mcbsp_pollread); -EXPORT_SYMBOL (omap_mcbsp_pollwrite); -EXPORT_SYMBOL (omap_mcbsp_xmit_word); -EXPORT_SYMBOL (omap_mcbsp_recv_word); -EXPORT_SYMBOL (omap_mcbsp_xmit_buffer); -EXPORT_SYMBOL (omap_mcbsp_recv_buffer); -EXPORT_SYMBOL (omap_mcbsp_spi_master_xmit_word_poll); -EXPORT_SYMBOL (omap_mcbsp_spi_master_recv_word_poll); -EXPORT_SYMBOL (omap_mcbsp_set_spi_mode);
Tony Lindgren
maintainerPATCH 11/21 ARM: OMAP: McBSP: Prepare for splitting into omap1 and omap2 code
From: Eduardo Valentin <[email protected]>
This patch transform mcbsp code to use platform data from arch/arm/plat-omap/devices.c
It also gets ride of ifdefs on mcbsp.c code.
To do it, a platform data structure was defined.
arch/arm/plat-omap/devices.c +45 -0
@@ -24,6 +24,7 @@#include <asm/arch/mux.h> #include <asm/arch/gpio.h> #include <asm/arch/menelaus.h> +#include <asm/arch/mcbsp.h> #if defined(CONFIG_OMAP_DSP ) || defined(CONFIG_OMAP_DSP_MODULE )
@@ -145,6 +146,49 @@ static inline void omap_init_kp(void) {}#endif /*-------------------------------------------------------------------------*/ +#if defined(CONFIG_OMAP_MCBSP ) || defined(CONFIG_OMAP_MCBSP_MODULE ) + +static struct platform_device omap_mcbsp_devices[OMAP_MAX_MCBSP_COUNT ]; +static int mcbsps_configured; + +void omap_mcbsp_register_board_cfg (struct omap_mcbsp_platform_data *config, +int size) +{ +int i; + +if (size >OMAP_MAX_MCBSP_COUNT ) { +printk (KERN_WARNING "Registered too many McBSPs platform_data." +" Using maximum (%d) available.\n" , +OMAP_MAX_MCBSP_COUNT ); + size =OMAP_MAX_MCBSP_COUNT ; + } + +for (i =0 ; i < size; i++) { +struct platform_device *new_mcbsp = &omap_mcbsp_devices[i]; + new_mcbsp->name ="omap-mcbsp" ; + new_mcbsp->id = i +1 ; + new_mcbsp->dev.platform_data = &config[i]; + } + mcbsps_configured = size; +} + +static void __init omap_init_mcbsp (void ) +{ +int i; + +for (i =0 ; i < mcbsps_configured; i++) +platform_device_register (&omap_mcbsp_devices[i]); +} +#else +void omap_mcbsp_register_board_cfg (struct omap_mcbsp_platform_data *config, +int size) +{ } + +static inline void __init omap_init_mcbsp (void ) +{ } +#endif + +/*-------------------------------------------------------------------------*/ #if defined(CONFIG_MMC_OMAP ) || defined(CONFIG_MMC_OMAP_MODULE )
@@ -440,6 +484,7 @@ static int __init omap_init_devices(void)*/ omap_init_dsp ();omap_init_kp (); +omap_init_mcbsp ();omap_init_mmc ();omap_init_uwire ();omap_init_wdt ();
arch/arm/plat-omap/mcbsp.c +253 -409
919 lines not on this page · raw message
include/asm-arm/arch-omap/mcbsp.h +60 -2
93 lines not on this page · raw message
Tony Lindgren
maintainerPATCH 12/21 ARM: OMAP: McBSP: Add support for mcbsp on mach-omap1
From: Eduardo Valentin <[email protected]>
This patch adds support for mach-omap1 based on current mcbsp platform driver.
arch/arm/mach-omap1/Makefile +2 -0
@@ -5,6 +5,8 @@ # Common support obj-y := io.o id.o sram.o clock.o irq.o mux.o serial.o devices.o +obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o + obj-$(CONFIG_OMAP_MPU_TIMER) += time.o obj-$(CONFIG_OMAP_32K_TIMER) += timer32k.o
arch/arm/mach-omap1/mcbsp.c new file +280 -0
280 lines not on this page · raw message
arch/arm/mach-omap2/clock24xx.h +20 -10
@@ -1747,7 +1747,8 @@ static struct clk gpt12_fck = { };static struct clk mcbsp1_ick = { - .name ="mcbsp1_ick" , + .name ="mcbsp_ick" , + .id =1 , .parent = &l4_ck, .flags =CLOCK_IN_OMAP242X |CLOCK_IN_OMAP243X , .enable_reg =OMAP_CM_REGADDR (CORE_MOD ,CM_ICLKEN1 ),
@@ -1756,7 +1757,8 @@ static struct clk mcbsp1_ick = { };static struct clk mcbsp1_fck = { - .name ="mcbsp1_fck" , + .name ="mcbsp_fck" , + .id =1 , .parent = &func_96m_ck, .flags =CLOCK_IN_OMAP242X |CLOCK_IN_OMAP243X , .enable_reg =OMAP_CM_REGADDR (CORE_MOD ,CM_FCLKEN1 ),
@@ -1765,7 +1767,8 @@ static struct clk mcbsp1_fck = { };static struct clk mcbsp2_ick = { - .name ="mcbsp2_ick" , + .name ="mcbsp_ick" , + .id =2 , .parent = &l4_ck, .flags =CLOCK_IN_OMAP242X |CLOCK_IN_OMAP243X , .enable_reg =OMAP_CM_REGADDR (CORE_MOD ,CM_ICLKEN1 ),
@@ -1774,7 +1777,8 @@ static struct clk mcbsp2_ick = { };static struct clk mcbsp2_fck = { - .name ="mcbsp2_fck" , + .name ="mcbsp_fck" , + .id =2 , .parent = &func_96m_ck, .flags =CLOCK_IN_OMAP242X |CLOCK_IN_OMAP243X , .enable_reg =OMAP_CM_REGADDR (CORE_MOD ,CM_FCLKEN1 ),
@@ -1783,7 +1787,8 @@ static struct clk mcbsp2_fck = { };static struct clk mcbsp3_ick = { - .name ="mcbsp3_ick" , + .name ="mcbsp_ick" , + .id =3 , .parent = &l4_ck, .flags =CLOCK_IN_OMAP243X , .enable_reg =OMAP_CM_REGADDR (CORE_MOD ,CM_ICLKEN2 ),
@@ -1792,7 +1797,8 @@ static struct clk mcbsp3_ick = { };static struct clk mcbsp3_fck = { - .name ="mcbsp3_fck" , + .name ="mcbsp_fck" , + .id =3 , .parent = &func_96m_ck, .flags =CLOCK_IN_OMAP243X , .enable_reg =OMAP_CM_REGADDR (CORE_MOD ,OMAP24XX_CM_FCLKEN2 ),
@@ -1801,7 +1807,8 @@ static struct clk mcbsp3_fck = { };static struct clk mcbsp4_ick = { - .name ="mcbsp4_ick" , + .name ="mcbsp_ick" , + .id =4 , .parent = &l4_ck, .flags =CLOCK_IN_OMAP243X , .enable_reg =OMAP_CM_REGADDR (CORE_MOD ,CM_ICLKEN2 ),
@@ -1810,7 +1817,8 @@ static struct clk mcbsp4_ick = { };static struct clk mcbsp4_fck = { - .name ="mcbsp4_fck" , + .name ="mcbsp_fck" , + .id =4 , .parent = &func_96m_ck, .flags =CLOCK_IN_OMAP243X , .enable_reg =OMAP_CM_REGADDR (CORE_MOD ,OMAP24XX_CM_FCLKEN2 ),
@@ -1819,7 +1827,8 @@ static struct clk mcbsp4_fck = { };static struct clk mcbsp5_ick = { - .name ="mcbsp5_ick" , + .name ="mcbsp_ick" , + .id =5 , .parent = &l4_ck, .flags =CLOCK_IN_OMAP243X , .enable_reg =OMAP_CM_REGADDR (CORE_MOD ,CM_ICLKEN2 ),
@@ -1828,7 +1837,8 @@ static struct clk mcbsp5_ick = { };static struct clk mcbsp5_fck = { - .name ="mcbsp5_fck" , + .name ="mcbsp_fck" , + .id =5 , .parent = &func_96m_ck, .flags =CLOCK_IN_OMAP243X , .enable_reg =OMAP_CM_REGADDR (CORE_MOD ,OMAP24XX_CM_FCLKEN2 ),
Tony Lindgren
maintainerPATCH 13/21 ARM: OMAP: McBSP: Add support for mcbsp on mach-omap2
From: Eduardo Valentin <[email protected]>
This patch adds support for mach-omap2 based on current mcbsp platform driver.
arch/arm/mach-omap2/Makefile +2 -0
@@ -6,6 +6,8 @@ obj-y := irq.o id.o io.o memory.o control.o prcm.o clock.o mux.o \ devices.o serial.o gpmc.o timer-gp.o +obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o + # Functions loaded to SRAM obj-$(CONFIG_ARCH_OMAP2420) += sram242x.o obj-$(CONFIG_ARCH_OMAP2430) += sram243x.o
arch/arm/mach-omap2/clock34xx.h +20 -10
@@ -1365,7 +1365,8 @@ static const struct clksel mcbsp_15_clksel[] = { };static struct clk mcbsp5_fck = { - .name ="mcbsp5_fck" , + .name ="mcbsp_fck" , + .id =5 , .init = &omap2_init_clksel_parent, .enable_reg =OMAP_CM_REGADDR (CORE_MOD ,CM_FCLKEN1 ), .enable_bit =OMAP3430_EN_MCBSP5_SHIFT ,
@@ -1377,7 +1378,8 @@ static struct clk mcbsp5_fck = { };static struct clk mcbsp1_fck = { - .name ="mcbsp1_fck" , + .name ="mcbsp_fck" , + .id =1 , .init = &omap2_init_clksel_parent, .enable_reg =OMAP_CM_REGADDR (CORE_MOD ,CM_FCLKEN1 ), .enable_bit =OMAP3430_EN_MCBSP1_SHIFT ,
@@ -1789,7 +1791,8 @@ static struct clk gpt10_ick = { };static struct clk mcbsp5_ick = { - .name ="mcbsp5_ick" , + .name ="mcbsp_ick" , + .id =5 , .parent = &core_l4_ick, .enable_reg =OMAP_CM_REGADDR (CORE_MOD ,CM_ICLKEN1 ), .enable_bit =OMAP3430_EN_MCBSP5_SHIFT ,
@@ -1798,7 +1801,8 @@ static struct clk mcbsp5_ick = { };static struct clk mcbsp1_ick = { - .name ="mcbsp1_ick" , + .name ="mcbsp_ick" , + .id =1 , .parent = &core_l4_ick, .enable_reg =OMAP_CM_REGADDR (CORE_MOD ,CM_ICLKEN1 ), .enable_bit =OMAP3430_EN_MCBSP1_SHIFT ,
@@ -2541,7 +2545,8 @@ static struct clk gpt2_ick = { };static struct clk mcbsp2_ick = { - .name ="mcbsp2_ick" , + .name ="mcbsp_ick" , + .id =2 , .parent = &per_l4_ick, .enable_reg =OMAP_CM_REGADDR (OMAP3430_PER_MOD ,CM_ICLKEN ), .enable_bit =OMAP3430_EN_MCBSP2_SHIFT ,
@@ -2550,7 +2555,8 @@ static struct clk mcbsp2_ick = { };static struct clk mcbsp3_ick = { - .name ="mcbsp3_ick" , + .name ="mcbsp_ick" , + .id =3 , .parent = &per_l4_ick, .enable_reg =OMAP_CM_REGADDR (OMAP3430_PER_MOD ,CM_ICLKEN ), .enable_bit =OMAP3430_EN_MCBSP3_SHIFT ,
@@ -2559,7 +2565,8 @@ static struct clk mcbsp3_ick = { };static struct clk mcbsp4_ick = { - .name ="mcbsp4_ick" , + .name ="mcbsp_ick" , + .id =4 , .parent = &per_l4_ick, .enable_reg =OMAP_CM_REGADDR (OMAP3430_PER_MOD ,CM_ICLKEN ), .enable_bit =OMAP3430_EN_MCBSP4_SHIFT ,
@@ -2574,7 +2581,8 @@ static const struct clksel mcbsp_234_clksel[] = { };static struct clk mcbsp2_fck = { - .name ="mcbsp2_fck" , + .name ="mcbsp_fck" , + .id =2 , .init = &omap2_init_clksel_parent, .enable_reg =OMAP_CM_REGADDR (OMAP3430_PER_MOD ,CM_FCLKEN ), .enable_bit =OMAP3430_EN_MCBSP2_SHIFT ,
@@ -2586,7 +2594,8 @@ static struct clk mcbsp2_fck = { };static struct clk mcbsp3_fck = { - .name ="mcbsp3_fck" , + .name ="mcbsp_fck" , + .id =3 , .init = &omap2_init_clksel_parent, .enable_reg =OMAP_CM_REGADDR (OMAP3430_PER_MOD ,CM_FCLKEN ), .enable_bit =OMAP3430_EN_MCBSP3_SHIFT ,
@@ -2598,7 +2607,8 @@ static struct clk mcbsp3_fck = { };static struct clk mcbsp4_fck = { - .name ="mcbsp4_fck" , + .name ="mcbsp_fck" , + .id =4 , .init = &omap2_init_clksel_parent, .enable_reg =OMAP_CM_REGADDR (OMAP3430_PER_MOD ,CM_FCLKEN ), .enable_bit =OMAP3430_EN_MCBSP4_SHIFT ,
arch/arm/mach-omap2/mcbsp.c new file +208 -0
208 lines not on this page · raw message
Tony Lindgren
maintainerPATCH 14/21 ARM: OMAP: Clean up interrupt lines to fix warnings for multi-omap
If boards with different NR_IRQS are compiled together, tons of compiler warnings are emitted about redefining NR_IRQS.
This patch fixes the problem by adding up NR_IRQS in a common place.
Patch also removes quite a bit of now unnecessary code.
arch/arm/mach-omap1/fpga.c +5 -5
@@ -32,7 +32,7 @@static void fpga_mask_irq (unsigned int irq) { - irq -=OMAP1510_IH_FPGA_BASE ; + irq -=OMAP_FPGA_IRQ_BASE ;if (irq <8 ) __raw_writeb((__raw_readb(OMAP1510_FPGA_IMR_LO)
@@ -65,7 +65,7 @@ static void fpga_ack_irq(unsigned int irq)static void fpga_unmask_irq (unsigned int irq) { - irq -=OMAP1510_IH_FPGA_BASE ; + irq -=OMAP_FPGA_IRQ_BASE ;if (irq <8 ) __raw_writeb((__raw_readb(OMAP1510_FPGA_IMR_LO) | (1 << irq)),
@@ -95,8 +95,8 @@ void innovator_fpga_IRQ_demux(unsigned int irq, struct irq_desc *desc)if (!stat)return ; -for (fpga_irq =OMAP1510_IH_FPGA_BASE ; - (fpga_irq < (OMAP1510_IH_FPGA_BASE +NR_FPGA_IRQS )) && stat; +for (fpga_irq =OMAP_FPGA_IRQ_BASE ; + (fpga_irq <OMAP_FPGA_IRQ_END ) && stat; fpga_irq++, stat >>=1 ) {if (stat &1 ) { d = irq_desc + fpga_irq;
@@ -151,7 +151,7 @@ void omap1510_fpga_init_irq(void)__raw_writeb (0 ,OMAP1510_FPGA_IMR_HI );__raw_writeb (0 ,INNOVATOR_FPGA_IMR2 ); -for (i =OMAP1510_IH_FPGA_BASE ; i < (OMAP1510_IH_FPGA_BASE +NR_FPGA_IRQS ); i++) { +for (i =OMAP_FPGA_IRQ_BASE ; i <OMAP_FPGA_IRQ_END ; i++) {if (i ==OMAP1510_INT_FPGA_TS ) {/*
include/asm-arm/arch-omap/board-2430sdp.h +0 -5
@@ -36,9 +36,4 @@#define TWL4030_IRQNUM INT_24XX_SYS_NIRQ -/* TWL4030 Primary Interrupt Handler (PIH) interrupts */ -#define IH_TWL4030_BASE IH_BOARD_BASE -#define IH_TWL4030_END (IH_TWL4030_BASE+8) -#define NR_IRQS (IH_TWL4030_END) -#endif /* __ASM_ARCH_OMAP_2430SDP_H */
include/asm-arm/arch-omap/board-h3.h +0 -6
@@ -30,12 +30,6 @@/* In OMAP1710 H3 the Ethernet is directly connected to CS1 */ #define OMAP1710_ETHR_START 0x04000300 -#define MAXIRQNUM (IH_BOARD_BASE) -#define MAXFIQNUM MAXIRQNUM -#define MAXSWINUM MAXIRQNUM - -#define NR_IRQS (MAXIRQNUM + 1) -extern void h3_mmc_init (void );extern void h3_mmc_slot_cover_handler (void *arg,int state);
include/asm-arm/arch-omap/board-innovator.h +0 -3
@@ -36,9 +36,6 @@#define OMAP1510P1_EMIFS_PRI_VALUE 0x00#define OMAP1510P1_EMIFF_PRI_VALUE 0x00 -#define NR_FPGA_IRQS 24 -#define NR_IRQS (IH_BOARD_BASE + NR_FPGA_IRQS) -#ifndef __ASSEMBLY__void fpga_write (unsigned char val,int reg);unsigned char fpga_read (int reg);
include/asm-arm/arch-omap/board-perseus2.h +0 -6
@@ -36,10 +36,4 @@#define OMAP_SDRAM_DEVICE D256M_1X16_4B#endif -#define MAXIRQNUM IH_BOARD_BASE -#define MAXFIQNUM MAXIRQNUM -#define MAXSWINUM MAXIRQNUM - -#define NR_IRQS (MAXIRQNUM + 1) -#endif
include/asm-arm/arch-omap/fpga.h +24 -25
54 lines not on this page · raw message
include/asm-arm/arch-omap/irqs.h +35 -9
56 lines not on this page · raw message
Tony Lindgren
maintainerPATCH 15/21 ARM: OMAP: CLKFW: Initial debugfs support for omap clock framework
From: Hiroshi DOYU <[email protected]>
debugfs can provide the infrastructure to trace the dependencies of clock tree hierarchy quite visibly. This patch enables to keep track of clock tree hierarchy and expose their attributes under each clock directry as below:
omap:~# tree -d -L 2 /debug/clock/omap_32k_fck/ /debug/clock/omap_32k_fck/ |-- gpt10_fck |-- gpt11_fck |-- gpt1_fck |-- per_32k_alwon_fck | |-- gpio2_fck | |-- gpio3_fck | |-- gpio4_fck | |-- gpio5_fck | |-- gpio6_fck | `-- wdt3_fck |-- ts_fck `-- wkup_32k_fck |-- gpio1_fck `-- wdt2_fck
14 directories omap:~# tree /debug/clock/omap_32k_fck/gpt10_fck/ /debug/clock/omap_32k_fck/gpt10_fck/ |-- flags |-- rate `-- usecount 0 directories, 3 files
Although, compared with David Brownell's small patch, this may look bit overkilling, I expect that this debugfs can deal with other PRCM complexities at the same time. For example, powerdomain dependencies can be expressed by using symbolic links of these clocks if powerdomain supports dubgfs as well.
arch/arm/plat-omap/clock.c +92 -36
@@ -1,7 +1,7 @@/* * linux/arch/arm/plat-omap/clock.c * -* Copyright (C) 2004 - 2005 Nokia corporation +* Copyright (C) 2004 - 2008 Nokia corporation * Written by Tuukka Tikkanen <[email protected]> * * Modified for omap shared clock framework by Tony Lindgren <[email protected]>
@@ -22,6 +22,7 @@#include <linux/mutex.h> #include <linux/platform_device.h> #include <linux/cpufreq.h> +#include <linux/debugfs.h> #include <asm/io.h>
@@ -33,41 +34,6 @@ static DEFINE_SPINLOCK(clockfw_lock);static struct clk_functions *arch_clock; -#ifdef CONFIG_PM_DEBUG - -static void print_parents (struct clk *clk) -{ -struct clk *p; -int printed =0 ; - -list_for_each_entry (p, &clocks, node) { -if (p->parent == clk && p->usecount) { -if (!clk->usecount && !printed) { -printk ("MISMATCH: %s\n" , clk->name); - printed =1 ; - } -printk ("\t%-15s\n" , p->name); - } - } -} - -void clk_print_usecounts (void ) -{ -unsigned long flags; -struct clk *p; - -spin_lock_irqsave (&clockfw_lock, flags); -list_for_each_entry (p, &clocks, node) { -if (p->usecount) -printk ("%-15s: %d\n" , p->name, p->usecount); -print_parents (p); - - } -spin_unlock_irqrestore (&clockfw_lock, flags); -} - -#endif -/*------------------------------------------------------------------------- * Standard clock functions defined in include/linux/clk.h *-------------------------------------------------------------------------*/
@@ -446,3 +412,93 @@ int __init clk_init(struct clk_functions * custom_clocks)return 0 ; } +#if defined(CONFIG_PM_DEBUG ) && defined(CONFIG_DEBUG_FS ) +/* +* debugfs support to trace clock tree hierarchy and attributes +*/ +static struct dentry *clk_debugfs_root; + +static int clk_debugfs_register_one (struct clk *c) +{ +int err; +struct dentry *d, *child; +struct clk *pa = c->parent; +char s[255 ]; +char *p = s; + + p +=sprintf (p,"%s" , c->name); +if (c->id !=0 ) +sprintf (p,":%d" , c->id); + d =debugfs_create_dir (s, pa ? pa->dent : clk_debugfs_root); +if (IS_ERR (d)) +return PTR_ERR (d); + c->dent = d; + + d =debugfs_create_u8 ("usecount" ,S_IRUGO , c->dent, (u8 *)&c->usecount); +if (IS_ERR (d)) { + err =PTR_ERR (d); + goto err_out; + } + d =debugfs_create_u32 ("rate" ,S_IRUGO , c->dent, (u32 *)&c->rate); +if (IS_ERR (d)) { + err =PTR_ERR (d); + goto err_out; + } + d =debugfs_create_x32 ("flags" ,S_IRUGO , c->dent, (u32 *)&c->flags); +if (IS_ERR (d)) { + err =PTR_ERR (d); + goto err_out; + } +return 0 ; + +err_out: + d = c->dent; +list_for_each_entry (child, &d->d_subdirs, d_u.d_child) +debugfs_remove (child); +debugfs_remove (c->dent); +return err; +} + +static int clk_debugfs_register (struct clk *c) +{ +int err; +struct clk *pa = c->parent; + +if (pa && !pa->dent) { + err =clk_debugfs_register (pa); +if (err) +return err; + } + +if (!c->dent) { + err =clk_debugfs_register_one (c); +if (err) +return err; + } +return 0 ; +} + +static int __init clk_debugfs_init (void ) +{ +struct clk *c; +struct dentry *d; +int err; + + d =debugfs_create_dir ("clock" ,NULL ); +if (IS_ERR (d)) +return PTR_ERR (d); + clk_debugfs_root = d; + +list_for_each_entry (c, &clocks, node) { + err =clk_debugfs_register (c); +if (err) + goto err_out; + } +return 0 ; +err_out: +debugfs_remove (clk_debugfs_root);/* REVISIT: Cleanup correctly */ +return err; +} +late_initcall (clk_debugfs_init); + +#endif /* defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) */
include/asm-arm/arch-omap/clock.h +3 -0
@@ -71,6 +71,9 @@ struct clk {__u8 rate_offset;__u8 src_offset;#endif +#if defined(CONFIG_PM_DEBUG ) && defined(CONFIG_DEBUG_FS ) +struct dentry *dent;/* For visible tree hierarchy */ +#endif };struct cpufreq_frequency_table ;
Tony Lindgren
maintainerPATCH 16/21 ARM: OMAP: Change omap_cf.c and omap_nor.c to use omap_readw/writew instead of __REG
Change omap_cf.c and omap_nor.c to use omap_readw/writew instead of __REG. This is needed for multi-omap in the future.
arch/arm/mach-omap1/board-osk.c +10 -3
@@ -267,13 +267,17 @@ static struct i2c_board_info __initdata osk_i2c_board_info[] = {static void __init osk_init_smc91x (void ) { +u32 l; +if ((gpio_request (0 ,"smc_irq" )) <0 ) {printk ("Error requesting gpio 0 for smc91x irq\n" );return ; }/* Check EMIFS wait states to fix errors with SMC_GET_PKT_HDR */ -EMIFS_CCS (1 ) |=0x3 ; + l =omap_readl (EMIFS_CCS (1 )); + l |=0x3 ; +omap_writel (l,EMIFS_CCS (1 )); }static void __init osk_init_cf (void )
@@ -526,13 +530,16 @@ static void __init osk_mistral_init(void) { }static void __init osk_init (void ) { +u32 l; +/* Workaround for wrong CS3 (NOR flash) timing * There are some U-Boot versions out there which configure * wrong CS3 memory timings. This mainly leads to CRC * or similar errors if you use NOR flash (e.g. with JFFS2) */ -if (EMIFS_CCS (3 ) !=EMIFS_CS3_VAL ) -EMIFS_CCS (3 ) =EMIFS_CS3_VAL ; + l =omap_readl (EMIFS_CCS (3 )); +if (l !=EMIFS_CS3_VAL ) +omap_writel (EMIFS_CS3_VAL ,EMIFS_CCS (3 )); osk_flash_resource.end = osk_flash_resource.start =omap_cs3_phys (); osk_flash_resource.end +=SZ_32M -1 ;
drivers/mtd/maps/omap_nor.c +16 -7
@@ -60,13 +60,22 @@ struct omapflash_info {static void omap_set_vpp (struct map_info *map,int enable) {static int count; - -if (enable) { -if (count++ ==0 ) -OMAP_EMIFS_CONFIG_REG |=OMAP_EMIFS_CONFIG_WP ; - }else { -if (count && (--count ==0 )) -OMAP_EMIFS_CONFIG_REG &= ~OMAP_EMIFS_CONFIG_WP ; +u32 l; + +if (cpu_class_is_omap1 ()) { +if (enable) { +if (count++ ==0 ) { + l =omap_readl (EMIFS_CONFIG ); + l |=OMAP_EMIFS_CONFIG_WP ; +omap_writel (l,EMIFS_CONFIG ); + } + }else { +if (count && (--count ==0 )) { + l =omap_readl (EMIFS_CONFIG ); + l &= ~OMAP_EMIFS_CONFIG_WP ; +omap_writel (l,EMIFS_CONFIG ); + } + } } }
drivers/pcmcia/omap_cf.c +13 -12
@@ -38,19 +38,19 @@#define CF_BASE 0xfffe2800/* status; read after IRQ */ -#define CF_STATUS_REG __REG16(CF_BASE + 0x00) +#define CF_STATUS (CF_BASE + 0x00)# define CF_STATUS_BAD_READ (1 << 2)# define CF_STATUS_BAD_WRITE (1 << 1)# define CF_STATUS_CARD_DETECT (1 << 0)/* which chipselect (CS0..CS3) is used for CF (active low) */ -#define CF_CFG_REG __REG16(CF_BASE + 0x02) +#define CF_CFG (CF_BASE + 0x02)/* card reset */ -#define CF_CONTROL_REG __REG16(CF_BASE + 0x04) +#define CF_CONTROL (CF_BASE + 0x04)# define CF_CONTROL_RESET (1 << 0) -#define omap_cf_present () (!(CF_STATUS_REG & CF_STATUS_CARD_DETECT)) +#define omap_cf_present () (!(omap_readw(CF_STATUS) & CF_STATUS_CARD_DETECT))/*--------------------------------------------------------------------------*/
@@ -139,11 +139,11 @@ omap_cf_set_socket(struct pcmcia_socket *sock, struct socket_state_t *s)return -EINVAL ; } - control =CF_CONTROL_REG ; + control =omap_readw (CF_CONTROL );if (s->flags &SS_RESET ) -CF_CONTROL_REG =CF_CONTROL_RESET ; +omap_writew (CF_CONTROL_RESET ,CF_CONTROL );else -CF_CONTROL_REG =0 ; +omap_writew (0 ,CF_CONTROL );pr_debug ("%s: Vcc %d, io_irq %d, flags %04x csc %04x\n" , driver_name, s->Vcc, s->io_irq, s->flags, s->csc_mask);
@@ -270,7 +270,7 @@ static int __init omap_cf_probe(struct platform_device *pdev)omap_cfg_reg (V10_1610_CF_IREQ );omap_cfg_reg (W10_1610_CF_RESET ); -CF_CFG_REG = ~(1 << seg); +omap_writew (~(1 << seg),CF_CFG );pr_info ("%s: cs%d on irq %d\n" , driver_name, seg, irq);
@@ -279,14 +279,15 @@ static int __init omap_cf_probe(struct platform_device *pdev)* CF/PCMCIA variants... */ pr_debug ("%s: cs%d, previous ccs %08x acs %08x\n" , driver_name, - seg,EMIFS_CCS (seg),EMIFS_ACS (seg)); -EMIFS_CCS (seg) =0x0004a1b3 ;/* synch mode 4 etc */ -EMIFS_ACS (seg) =0x00000000 ;/* OE hold/setup */ + seg,omap_readl (EMIFS_CCS (seg)),omap_readl (EMIFS_ACS (seg))); +omap_writel (0x0004a1b3 ,EMIFS_CCS (seg));/* synch mode 4 etc */ +omap_writel (0x00000000 ,EMIFS_ACS (seg));/* OE hold/setup */ /* CF uses armxor_ck, which is "always" available */ pr_debug ("%s: sts %04x cfg %04x control %04x %s\n" , driver_name, -CF_STATUS_REG ,CF_CFG_REG ,CF_CONTROL_REG , +omap_readw (CF_STATUS ),omap_readw (CF_CFG ), +omap_readw (CF_CONTROL ),omap_cf_present () ?"present" :"(not present)" ); cf->socket.owner =THIS_MODULE ;
include/asm-arm/arch-omap/tc.h +4 -6
@@ -75,16 +75,14 @@#ifndef __ASSEMBLER__/* EMIF Slow Interface Configuration Register */ -#define OMAP_EMIFS_CONFIG_REG __REG32(EMIFS_CONFIG) -#define OMAP_EMIFS_CONFIG_FR (1 << 4)#define OMAP_EMIFS_CONFIG_PDE (1 << 3)#define OMAP_EMIFS_CONFIG_PWD_EN (1 << 2)#define OMAP_EMIFS_CONFIG_BM (1 << 1)#define OMAP_EMIFS_CONFIG_WP (1 << 0) -#define EMIFS_CCS (n) __REG32(EMIFS_CS0_CONFIG + (4 * (n))) -#define EMIFS_ACS (n) __REG32(EMIFS_ACS0 + (4 * (n))) +#define EMIFS_CCS (n) (EMIFS_CS0_CONFIG + (4 * (n))) +#define EMIFS_ACS (n) (EMIFS_ACS0 + (4 * (n)))/* Almost all documentation for chip and board memory maps assumes * BM is clear. Most devel boards have a switch to control booting
@@ -93,13 +91,13 @@*/ static inline u32 omap_cs0_phys (void ) { -return (OMAP_EMIFS_CONFIG_REG &OMAP_EMIFS_CONFIG_BM ) +return (omap_readl (EMIFS_CONFIG ) &OMAP_EMIFS_CONFIG_BM ) ?OMAP_CS3_PHYS :0 ; }static inline u32 omap_cs3_phys (void ) { -return (OMAP_EMIFS_CONFIG_REG &OMAP_EMIFS_CONFIG_BM ) +return (omap_readl (EMIFS_CONFIG ) &OMAP_EMIFS_CONFIG_BM ) ?0 :OMAP_CS3_PHYS ; }
A message that is not in the archive (sent off-list or not yet received): 1212802253-17797-17-git-send-email-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org
PATCH 17/21 ARM: OMAP: USB: Change omap USB code to use omap_read/write instead of __REG
Change omap USB code to use omap_read/write instead of __REG for multi-omap
arch/arm/mach-omap1/board-osk.c +4 -1
@@ -546,7 +546,10 @@ static void __init osk_init(void)platform_add_devices (osk5912_devices,ARRAY_SIZE (osk5912_devices)); omap_board_config = osk_config; omap_board_config_size =ARRAY_SIZE (osk_config); -USB_TRANSCEIVER_CTRL_REG |= (3 <<1 ); + + l =omap_readl (USB_TRANSCEIVER_CTRL ); + l |= (3 <<1 ); +omap_writel (l,USB_TRANSCEIVER_CTRL );/* irq for tps65010 chip */ /* bootloader effectively does: omap_cfg_reg(U19_1610_MPUIO1); */
arch/arm/plat-omap/usb.c +91 -40
262 lines not on this page · raw message
drivers/i2c/chips/isp1301_omap.c +99 -64
481 lines not on this page · raw message
drivers/usb/gadget/omap_udc.c +261 -207
1,188 lines not on this page · raw message
drivers/usb/gadget/omap_udc.h +30 -31
154 lines not on this page · raw message
drivers/usb/host/ohci-omap.c +4 -1
@@ -169,13 +169,16 @@ static void start_hnp(struct ohci_hcd *ohci) {const unsigned port =ohci_to_hcd (ohci)->self.otg_port -1 ;unsigned long flags; +u32 l;otg_start_hnp (ohci->transceiver);local_irq_save (flags); ohci->transceiver->state =OTG_STATE_A_SUSPEND ;writel (RH_PS_PSS , &ohci->regs->roothub.portstatus [port]); -OTG_CTRL_REG &= ~OTG_A_BUSREQ ; + l =omap_readl (OTG_CTRL ); + l &= ~OTG_A_BUSREQ ; +omap_writel (l,OTG_CTRL );local_irq_restore (flags); }
include/asm-arm/arch-omap/usb.h +10 -13
@@ -34,11 +34,8 @@/* * OTG and transceiver registers, for OMAPs starting with ARM926 */ -#define OTG_REG32 (offset) __REG32(OTG_BASE + (offset)) -#define OTG_REG16 (offset) __REG16(OTG_BASE + (offset)) - -#define OTG_REV_REG OTG_REG32(0x00) -#define OTG_SYSCON_1_REG OTG_REG32(0x04) +#define OTG_REV (OTG_BASE + 0x00) +#define OTG_SYSCON_1 (OTG_BASE + 0x04)# define USB2_TRX_MODE (w) (((w)>>24)&0x07)# define USB1_TRX_MODE (w) (((w)>>20)&0x07)# define USB0_TRX_MODE (w) (((w)>>16)&0x07)
@@ -47,7 +44,7 @@# define DEV_IDLE_EN (1 << 13)# define OTG_RESET_DONE (1 << 2)# define OTG_SOFT_RESET (1 << 1) -#define OTG_SYSCON_2_REG OTG_REG32(0x08) +#define OTG_SYSCON_2 (OTG_BASE + 0x08)# define OTG_EN (1 << 31)# define USBX_SYNCHRO (1 << 30)# define OTG_MST16 (1 << 29)
@@ -65,7 +62,7 @@# define HMC_TLLSPEED (1 << 7)# define HMC_TLLATTACH (1 << 6)# define OTG_HMC (w) (((w)>>0)&0x3f) -#define OTG_CTRL_REG OTG_REG32(0x0c) +#define OTG_CTRL (OTG_BASE + 0x0c)# define OTG_USB2_EN (1 << 29)# define OTG_USB2_DP (1 << 28)# define OTG_USB2_DM (1 << 27)
@@ -92,7 +89,7 @@# define OTG_PD_VBUS (1 << 2)# define OTG_PU_VBUS (1 << 1)# define OTG_PU_ID (1 << 0) -#define OTG_IRQ_EN_REG OTG_REG16(0x10) +#define OTG_IRQ_EN (OTG_BASE + 0x10)/* 16-bit */ # define DRIVER_SWITCH (1 << 15)# define A_VBUS_ERR (1 << 13)# define A_REQ_TMROUT (1 << 12)
@@ -102,9 +99,9 @@# define B_SRP_DONE (1 << 8)# define B_SRP_STARTED (1 << 7)# define OPRT_CHG (1 << 0) -#define OTG_IRQ_SRC_REG OTG_REG16(0x14) +#define OTG_IRQ_SRC (OTG_BASE + 0x14)/* 16-bit */ // same bits as in IRQ_EN -#define OTG_OUTCTRL_REG OTG_REG16(0x18) +#define OTG_OUTCTRL (OTG_BASE + 0x18)/* 16-bit */ # define OTGVPD (1 << 14)# define OTGVPU (1 << 13)# define OTGPUID (1 << 12)
@@ -117,13 +114,13 @@# define USB0VDR (1 << 2)# define USB0PDEN (1 << 1)# define USB0PUEN (1 << 0) -#define OTG_TEST_REG OTG_REG16(0x20) -#define OTG_VENDOR_CODE_REG OTG_REG32(0xfc) +#define OTG_TEST (OTG_BASE + 0x20)/* 16-bit */ +#define OTG_VENDOR_CODE (OTG_BASE + 0xfc)/* 16-bit */ /*-------------------------------------------------------------------------*/ /* OMAP1 */ -#define USB_TRANSCEIVER_CTRL_REG __REG32(0xfffe1000 + 0x0064) +#define USB_TRANSCEIVER_CTRL (0xfffe1000 + 0x0064)# define CONF_USB2_UNI_R (1 << 8)# define CONF_USB1_UNI_R (1 << 7)# define CONF_USB_PORT0_R (x) (((x)>>4)&0x7)
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Tony Lindgren
maintainerPATCH 18/21 ARM: OMAP: Remove __REG access for multi-omap
This does not play nicely with multi-omap as it cannot be replaced by a function in io.c for omaps with different IO bases.
include/asm-arm/arch-omap/io.h +0 -23
@@ -183,35 +183,12 @@#define omap_writew (v,a) (*(volatile unsigned short *)IO_ADDRESS(a) = (v))#define omap_writel (v,a) (*(volatile unsigned int *)IO_ADDRESS(a) = (v)) -/* 16 bit uses LDRH/STRH, base +/- offset_8 */ -typedef struct {volatile u16 offset[256 ]; }__regbase16 ; -#define __REGV16 (vaddr) ((__regbase16 *)((vaddr)&~0xff)) \ - ->offset[((vaddr)&0xff)>>1] -#define __REG16 (paddr) __REGV16(io_p2v(paddr)) - -/* 8/32 bit uses LDR/STR, base +/- offset_12 */ -typedef struct {volatile u8 offset[4096 ]; }__regbase8 ; -#define __REGV8 (vaddr) ((__regbase8 *)((vaddr)&~4095)) \ - ->offset[((vaddr)&4095)>>0] -#define __REG8 (paddr) __REGV8(io_p2v(paddr)) - -typedef struct {volatile u32 offset[4096 ]; }__regbase32 ; -#define __REGV32 (vaddr) ((__regbase32 *)((vaddr)&~4095)) \ - ->offset[((vaddr)&4095)>>2] -#define __REG32 (paddr) __REGV32(io_p2v(paddr)) -extern void omap1_map_common_io (void );extern void omap1_init_common_hw (void );extern void omap2_map_common_io (void );extern void omap2_init_common_hw (void ); -#else - -#define __REG8 (paddr) io_p2v(paddr) -#define __REG16 (paddr) io_p2v(paddr) -#define __REG32 (paddr) io_p2v(paddr) -#endif #endif
Tony Lindgren
maintainerPATCH 19/21 ARM: OMAP: Introduce omap_globals and prcm access functions for multi-omap
New struct omap_globals contains the omap processor specific module bases. Use omap_globals to set the various base addresses to make detecting omap chip type simpler.
Also introduce OMAP1_IO_ADDRESS and OMAP2_IO_ADDRESS for future multi-omap patches.
arch/arm/mach-omap2/cm.h +4 -9
@@ -96,15 +96,10 @@/* Clock management domain register get/set */ #ifndef __ASSEMBLER__ -static inline void cm_write_mod_reg (u32 val,s16 module,s16 idx) -{ -__raw_writel (val,OMAP_CM_REGADDR (module, idx)); -} - -static inline u32 cm_read_mod_reg (s16 module,s16 idx) -{ -return __raw_readl (OMAP_CM_REGADDR (module, idx)); -} + +extern u32 cm_read_mod_reg (s16 module,u16 idx); +extern void cm_write_mod_reg (u32 val,s16 module,u16 idx); +#endif /* CM register bits shared between 24XX and 3430 */
arch/arm/mach-omap2/control.c +10 -11
@@ -13,22 +13,21 @@#undef DEBUG#include <linux/kernel.h> +#include <linux/io.h> -#include <asm/io.h> - +#include <asm/arch/common.h> #include <asm/arch/control.h> -static u32 omap2_ctrl_base; +static void __iomem *omap2_ctrl_base; -#define OMAP_CTRL_REGADDR (reg) (void __iomem *)IO_ADDRESS(omap2_ctrl_base \ - + (reg)) +#define OMAP_CTRL_REGADDR (reg) (omap2_ctrl_base + (reg)) -void omap_ctrl_base_set (u32 base) +void __init omap2_set_globals_control (struct omap_globals *omap2_globals) { - omap2_ctrl_base = base; + omap2_ctrl_base = omap2_globals->ctrl; } -u32 omap_ctrl_base_get (void ) +void __iomem *omap_ctrl_base_get (void ) {return omap2_ctrl_base; }
@@ -51,7 +50,7 @@ u32 omap_ctrl_readl(u16 offset)void omap_ctrl_writeb (u8 val,u16 offset) {pr_debug ("omap_ctrl_writeb: writing 0x%0x to 0x%0x\n" , val, - (u32 )OMAP_CTRL_REGADDR (offset)); + (__force u32 )OMAP_CTRL_REGADDR (offset));__raw_writeb (val,OMAP_CTRL_REGADDR (offset)); }
@@ -59,7 +58,7 @@ void omap_ctrl_writeb(u8 val, u16 offset)void omap_ctrl_writew (u16 val,u16 offset) {pr_debug ("omap_ctrl_writew: writing 0x%0x to 0x%0x\n" , val, - (u32 )OMAP_CTRL_REGADDR (offset)); + (__force u32 )OMAP_CTRL_REGADDR (offset));__raw_writew (val,OMAP_CTRL_REGADDR (offset)); }
@@ -67,7 +66,7 @@ void omap_ctrl_writew(u16 val, u16 offset)void omap_ctrl_writel (u32 val,u16 offset) {pr_debug ("omap_ctrl_writel: writing 0x%0x to 0x%0x\n" , val, - (u32 )OMAP_CTRL_REGADDR (offset)); + (__force u32 )OMAP_CTRL_REGADDR (offset));__raw_writel (val,OMAP_CTRL_REGADDR (offset)); }
arch/arm/mach-omap2/memory.c +9 -2
@@ -24,6 +24,7 @@#include <asm/io.h> +#include <asm/arch/common.h> #include <asm/arch/clock.h> #include <asm/arch/sram.h>
@@ -32,8 +33,8 @@#include "memory.h" #include "sdrc.h" -unsigned long omap2_sdrc_base; -unsigned long omap2_sms_base; +void __iomem *omap2_sdrc_base; +void __iomem *omap2_sms_base;static struct memory_timings mem_timings;static u32 curr_perf_level =CORE_CLK_SRC_DPLL_X2 ;
@@ -154,6 +155,12 @@ void omap2_init_memory_params(u32 force_lock_to_unlock_mode) mem_timings.slow_dll_ctrl |= ((1 <<1 ) | (3 <<8 )); } +void __init omap2_set_globals_memory (struct omap_globals *omap2_globals) +{ + omap2_sdrc_base = omap2_globals->sdrc; + omap2_sms_base = omap2_globals->sms; +} +/* turn on smart idle modes for SDRAM scheduler and controller */ void __init omap2_init_memory (void ) {
arch/arm/mach-omap2/mux.c +1 -1
@@ -236,7 +236,7 @@ void __init_or_module omap2_cfg_debug(const struct pin_config *cfg, u8 reg) warn = (orig != reg);if (debug || warn)printk (KERN_WARNING -"MUX: setup %s (0x%08x): 0x%02x -> 0x%02x\n" , +"MUX: setup %s (0x%p): 0x%04x -> 0x%04x\n" , cfg->name,omap_ctrl_base_get () + cfg->mux_reg, orig, reg); }
arch/arm/mach-omap2/prcm.c +54 -1
69 lines not on this page · raw message
arch/arm/mach-omap2/prm.h +2 -10
@@ -166,16 +166,8 @@#ifndef __ASSEMBLER__/* Power/reset management domain register get/set */ - -static inline void prm_write_mod_reg (u32 val,s16 module,s16 idx) -{ -__raw_writel (val,OMAP_PRM_REGADDR (module, idx)); -} - -static inline u32 prm_read_mod_reg (s16 module,s16 idx) -{ -return __raw_readl (OMAP_PRM_REGADDR (module, idx)); -} +extern u32 prm_read_mod_reg (s16 module,u16 idx); +extern void prm_write_mod_reg (u32 val,s16 module,u16 idx);#endif
arch/arm/mach-omap2/sdrc.h +4 -6
@@ -18,13 +18,11 @@#include <asm/arch/sdrc.h> #ifndef __ASSEMBLER__ -extern unsigned long omap2_sdrc_base; -extern unsigned long omap2_sms_base; +extern void __iomem *omap2_sdrc_base; +extern void __iomem *omap2_sms_base; -#define OMAP_SDRC_REGADDR (reg) \ - (void __iomem *)IO_ADDRESS(omap2_sdrc_base + (reg)) -#define OMAP_SMS_REGADDR (reg) \ - (void __iomem *)IO_ADDRESS(omap2_sms_base + (reg)) +#define OMAP_SDRC_REGADDR (reg) (omap2_sdrc_base + (reg)) +#define OMAP_SMS_REGADDR (reg) (omap2_sms_base + (reg))/* SDRC global register get/set */
arch/arm/plat-omap/common.c +50 -9
86 lines not on this page · raw message
include/asm-arm/arch-omap/common.h +15 -0
@@ -47,8 +47,23 @@ static inline int omap_register_i2c_bus(int bus_id, u32 clkrate, }#endif +/* IO bases for various OMAP processors */ +struct omap_globals { +void __iomem *tap;/* Control module ID code */ +void __iomem *sdrc;/* SDRAM Controller */ +void __iomem *sms;/* SDRAM Memory Scheduler */ +void __iomem *ctrl;/* System Control Module */ +void __iomem *prm;/* Power and Reset Management */ +void __iomem *cm;/* Clock Management */ +}; +void omap2_set_globals_242x (void );void omap2_set_globals_243x (void );void omap2_set_globals_343x (void ); +/* These get called from omap2_set_globals_xxxx(), do not call these */ +void omap2_set_globals_memory (struct omap_globals *); +void omap2_set_globals_control (struct omap_globals *); +void omap2_set_globals_prcm (struct omap_globals *); +#endif /* __ARCH_ARM_MACH_OMAP_COMMON_H */
include/asm-arm/arch-omap/control.h +1 -3
@@ -167,8 +167,7 @@#ifndef __ASSEMBLY__#if defined(CONFIG_ARCH_OMAP2 ) || defined(CONFIG_ARCH_OMAP3 ) -extern void omap_ctrl_base_set (u32 base); -extern u32 omap_ctrl_base_get (void ); +extern void __iomem *omap_ctrl_base_get (void );extern u8 omap_ctrl_readb (u16 offset);extern u16 omap_ctrl_readw (u16 offset);extern u32 omap_ctrl_readl (u16 offset);
@@ -176,7 +175,6 @@ extern void omap_ctrl_writeb(u8 val, u16 offset);extern void omap_ctrl_writew (u16 val,u16 offset);extern void omap_ctrl_writel (u32 val,u16 offset);#else -#define omap_ctrl_base_set (x) WARN_ON(1)#define omap_ctrl_base_get () 0#define omap_ctrl_readb (x) 0#define omap_ctrl_readw (x) 0
include/asm-arm/arch-omap/io.h +3 -0
@@ -60,6 +60,7 @@#define IO_SIZE 0x40000#define IO_VIRT (IO_PHYS - IO_OFFSET)#define IO_ADDRESS (pa) ((pa) - IO_OFFSET) +#define OMAP1_IO_ADDRESS (pa) ((pa) - IO_OFFSET)#define io_p2v (pa) ((pa) - IO_OFFSET)#define io_v2p (va) ((va) + IO_OFFSET)
@@ -91,6 +92,7 @@#define IO_OFFSET 0x90000000#define IO_ADDRESS (pa) ((pa) + IO_OFFSET)/* Works for L3 and L4 */ +#define OMAP2_IO_ADDRESS (pa) ((pa) + IO_OFFSET)/* Works for L3 and L4 */ #define io_p2v (pa) ((pa) + IO_OFFSET)/* Works for L3 and L4 */ #define io_v2p (va) ((va) - IO_OFFSET)/* Works for L3 and L4 */
@@ -148,6 +150,7 @@#define IO_OFFSET 0x90000000#define IO_ADDRESS (pa) ((pa) + IO_OFFSET)/* Works for L3 and L4 */ +#define OMAP2_IO_ADDRESS (pa) ((pa) + IO_OFFSET)/* Works for L3 and L4 */ #define io_p2v (pa) ((pa) + IO_OFFSET)/* Works for L3 and L4 */ #define io_v2p (va) ((va) - IO_OFFSET)/* Works for L3 and L4 */
Tony Lindgren
maintainerPATCH 20/21 ARM: OMAP: Turn CM and PRM access into functions
Otherwise compiling in omap2 and omap3 will not work.
arch/arm/mach-omap2/clock.h +1 -0
@@ -42,6 +42,7 @@ long omap2_clksel_round_rate(struct clk *clk, unsigned long target_rate);int omap2_clksel_set_rate (struct clk *clk,unsigned long rate);u32 omap2_get_dpll_rate (struct clk *clk);int omap2_wait_clock_ready (void __iomem *reg,u32 cval,const char *name); +void omap2_clk_prepare_for_reboot (void );extern u8 cpu_mask;
arch/arm/mach-omap2/cm.h +11 -0
@@ -99,6 +99,17 @@extern u32 cm_read_mod_reg (s16 module,u16 idx);extern void cm_write_mod_reg (u32 val,s16 module,u16 idx); +extern u32 cm_rmw_mod_reg_bits (u32 mask,u32 bits,s16 module,s16 idx); + +static inline u32 cm_set_mod_reg_bits (u32 bits,s16 module,s16 idx) +{ +return cm_rmw_mod_reg_bits (bits, bits, module, idx); +} + +static inline u32 cm_clear_mod_reg_bits (u32 bits,s16 module,s16 idx) +{ +return cm_rmw_mod_reg_bits (bits,0x0 , module, idx); +}#endif
arch/arm/mach-omap2/prcm.c +38 -7
73 lines not on this page · raw message
arch/arm/mach-omap2/prm.h +12 -0
@@ -168,6 +168,18 @@/* Power/reset management domain register get/set */ extern u32 prm_read_mod_reg (s16 module,u16 idx);extern void prm_write_mod_reg (u32 val,s16 module,u16 idx); +extern u32 prm_rmw_mod_reg_bits (u32 mask,u32 bits,s16 module,s16 idx); + +/* Read-modify-write bits in a PRM register (by domain) */ +static inline u32 prm_set_mod_reg_bits (u32 bits,s16 module,s16 idx) +{ +return prm_rmw_mod_reg_bits (bits, bits, module, idx); +} + +static inline u32 prm_clear_mod_reg_bits (u32 bits,s16 module,s16 idx) +{ +return prm_rmw_mod_reg_bits (bits,0x0 , module, idx); +}#endif
Tony Lindgren
maintainerPATCH 21/21 ARM: OMAP: Add OMAP chip type structure; clean up mach-omap2/id.c
From: Paul Walmsley <[email protected]>
Add a new OMAP chip identification interface, omap_chip_id. omap_chip_id is a structure which contains one bit for each OMAP2/3 CPU type, and on 3430, ES level. For example, the CHIP_IS_OMAP2420 bit is set in omap_chip at boot on an OMAP2420. On OMAP3430ES2, both CHIP_IS_OMAP3430 and CHIP_IS_OMAP3430ES2 bits are set.
omap_chip is set in mach-omap2/id.c by _set_omap_chip(). Other code should use the omap_chip_is() function to test against omap_chip.
Also, clean up id.c by splitting some code out of omap_check_revision() into its own function, _set_system_rev(); and converting some debug printk()s into pr_debug().
Second revision.
arch/arm/mach-omap2/id.c +168 -27
@@ -17,16 +17,23 @@#include <asm/io.h> -#if defined(CONFIG_ARCH_OMAP2420 ) -#define OMAP24XX_TAP_BASE io_p2v(0x48014000) -#endif +#include <asm/arch/control.h> +#include <asm/arch/cpu.h> -#if defined(CONFIG_ARCH_OMAP2430 ) -#define OMAP24XX_TAP_BASE io_p2v(0x4900A000) +#if defined(CONFIG_ARCH_OMAP2420 ) +#define TAP_BASE io_p2v(0x48014000) +#elif defined(CONFIG_ARCH_OMAP2430 ) +#define TAP_BASE io_p2v(0x4900A000) +#elif defined(CONFIG_ARCH_OMAP34XX ) +#define TAP_BASE io_p2v(0x4830A000)#endif #define OMAP_TAP_IDCODE 0x0204 +#if defined(CONFIG_ARCH_OMAP34XX ) +#define OMAP_TAP_PROD_ID 0x0210 +#else #define OMAP_TAP_PROD_ID 0x0208 +#endif #define OMAP_TAP_DIE_ID_0 0x0218#define OMAP_TAP_DIE_ID_1 0x021C
@@ -56,9 +63,134 @@ static struct omap_id omap_ids[] __initdata = { { .hawkeye = 0xb68a, .dev = 0x0, .type = 0x24300000 }, }; +static struct omap_chip_id omap_chip; + +/** +* omap_chip_is - test whether currently running OMAP matches a chip type +* @oc: omap_chip_t to test against +* +* Test whether the currently-running OMAP chip matches the supplied +* chip type 'oc'. Returns 1 upon a match; 0 upon failure. +*/ +int omap_chip_is (struct omap_chip_id oci) +{ +return (oci.oc & omap_chip.oc) ?1 :0 ; +} +EXPORT_SYMBOL (omap_chip_is); +static u32 __init read_tap_reg (int reg) { -return __raw_readl (OMAP24XX_TAP_BASE + reg); +unsigned int regval =0 ; +u32 cpuid; + +/* Reading the IDCODE register on 3430 ES1 results in a +* data abort as the register is not exposed on the OCP +* Hence reading the Cortex Rev +*/ + cpuid =read_cpuid (CPUID_ID ); + +/* If the processor type is Cortex-A8 and the revision is 0x0 +* it means its Cortex r0p0 which is 3430 ES1 +*/ +if ((((cpuid >>4 ) &0xFFF ) ==0xC08 ) && ((cpuid &0xF ) ==0x0 )) { +switch (reg) { +case OMAP_TAP_IDCODE : regval =0x0B7AE02F ;break ; +/* Making DevType as 0xF in ES1 to differ from ES2 */ +case OMAP_TAP_PROD_ID : regval =0x000F00F0 ;break ; +case OMAP_TAP_DIE_ID_0 : regval =0x01000000 ;break ; +case OMAP_TAP_DIE_ID_1 : regval =0x1012d687 ;break ; +case OMAP_TAP_DIE_ID_2 : regval =0x00000000 ;break ; +case OMAP_TAP_DIE_ID_3 : regval =0x2d2c0000 ;break ; + } + }else + regval =__raw_readl (TAP_BASE + reg); + +return regval; + +} + +/* +* _set_system_rev - set the system_rev global based on current OMAP chip type +* +* Set the system_rev global. This is primarily used by the cpu_is_omapxxxx() +* macros. +*/ +static void __init _set_system_rev (u32 type,u8 rev) +{ +u32 i, ctrl_status; + +/* +* system_rev encoding is as follows +* system_rev & 0xff000000 -> Omap Class (24xx/34xx) +* system_rev & 0xfff00000 -> Omap Sub Class (242x/343x) +* system_rev & 0xffff0000 -> Omap type (2420/2422/2423/2430/3430) +* system_rev & 0x0000f000 -> Silicon revision (ES1, ES2 ) +* system_rev & 0x00000700 -> Device Type ( EMU/HS/GP/BAD ) +* system_rev & 0x000000c0 -> IDCODE revision[6:7] +* system_rev & 0x0000003f -> sys_boot[0:5] +*/ +/* Embedding the ES revision info in type field */ + system_rev = type; +/* Also add IDCODE revision info only two lower bits */ + system_rev |= ((rev &0x3 ) <<6 ); + +/* Add in the device type and sys_boot fields (see above) */ +if (cpu_is_omap24xx ()) { + i =OMAP24XX_CONTROL_STATUS ; + }else if (cpu_is_omap343x ()) { + i =OMAP343X_CONTROL_STATUS ; + }else { +printk (KERN_ERR "id: unknown CPU type\n" ); +BUG (); + } + ctrl_status =omap_ctrl_readl (i); + system_rev |= (ctrl_status & (OMAP2_SYSBOOT_5_MASK | +OMAP2_SYSBOOT_4_MASK | +OMAP2_SYSBOOT_3_MASK | +OMAP2_SYSBOOT_2_MASK | +OMAP2_SYSBOOT_1_MASK | +OMAP2_SYSBOOT_0_MASK )); + system_rev |= (ctrl_status &OMAP2_DEVICETYPE_MASK ); +} + + +/* +* _set_omap_chip - set the omap_chip global based on OMAP chip type +* +* Build the omap_chip bits. This variable is used by powerdomain and +* clockdomain code to indicate whether structures are applicable for +* the current OMAP chip type by ANDing it against a 'platform' bitfield +* in the structure. +*/ +static void __init _set_omap_chip (void ) +{ +if (cpu_is_omap343x ()) { + + omap_chip.oc =CHIP_IS_OMAP3430 ; +if (is_sil_rev_equal_to (OMAP3430_REV_ES1_0 )) + omap_chip.oc |=CHIP_IS_OMAP3430ES1 ; +else if (is_sil_rev_greater_than (OMAP3430_REV_ES1_0 )) + omap_chip.oc |=CHIP_IS_OMAP3430ES2 ; + + }else if (cpu_is_omap243x ()) { + +/* Currently only supports 2430ES2.1 and 2430-all */ + omap_chip.oc |=CHIP_IS_OMAP2430 ; + + }else if (cpu_is_omap242x ()) { + +/* Currently only supports 2420ES2.1.1 and 2420-all */ + omap_chip.oc |=CHIP_IS_OMAP2420 ; + + }else { + +/* Current CPU not supported by this code. */ +printk (KERN_WARNING "OMAP chip type code does not yet support " +"this CPU type.\n" ); +WARN_ON (1 ); + + } + }void __init omap2_check_revision (void )
@@ -76,21 +208,31 @@ void __init omap2_check_revision(void) rev = (idcode >>28 ) &0x0f ; dev_type = (prod_id >>16 ) &0x0f ; -#ifdef DEBUG -printk (KERN_DEBUG "OMAP_TAP_IDCODE 0x%08x REV %i HAWKEYE 0x%04x MANF %03x\n" , - idcode, rev, hawkeye, (idcode >>1 ) &0x7ff ); -printk (KERN_DEBUG "OMAP_TAP_DIE_ID_0: 0x%08x\n" , -read_tap_reg (OMAP_TAP_DIE_ID_0 )); -printk (KERN_DEBUG "OMAP_TAP_DIE_ID_1: 0x%08x DEV_REV: %i\n" , -read_tap_reg (OMAP_TAP_DIE_ID_1 ), - (read_tap_reg (OMAP_TAP_DIE_ID_1 ) >>28 ) &0xf ); -printk (KERN_DEBUG "OMAP_TAP_DIE_ID_2: 0x%08x\n" , -read_tap_reg (OMAP_TAP_DIE_ID_2 )); -printk (KERN_DEBUG "OMAP_TAP_DIE_ID_3: 0x%08x\n" , -read_tap_reg (OMAP_TAP_DIE_ID_3 )); -printk (KERN_DEBUG "OMAP_TAP_PROD_ID_0: 0x%08x DEV_TYPE: %i\n" , - prod_id, dev_type); -#endif +pr_debug ("OMAP_TAP_IDCODE 0x%08x REV %i HAWKEYE 0x%04x MANF %03x\n" , + idcode, rev, hawkeye, (idcode >>1 ) &0x7ff ); +pr_debug ("OMAP_TAP_DIE_ID_0: 0x%08x\n" , +read_tap_reg (OMAP_TAP_DIE_ID_0 )); +pr_debug ("OMAP_TAP_DIE_ID_1: 0x%08x DEV_REV: %i\n" , +read_tap_reg (OMAP_TAP_DIE_ID_1 ), + (read_tap_reg (OMAP_TAP_DIE_ID_1 ) >>28 ) &0xf ); +pr_debug ("OMAP_TAP_DIE_ID_2: 0x%08x\n" , +read_tap_reg (OMAP_TAP_DIE_ID_2 )); +pr_debug ("OMAP_TAP_DIE_ID_3: 0x%08x\n" , +read_tap_reg (OMAP_TAP_DIE_ID_3 )); +pr_debug ("OMAP_TAP_PROD_ID_0: 0x%08x DEV_TYPE: %i\n" , + prod_id, dev_type); + +/* +* Detection for 34xx ES2.0 and above can be done with just +* hawkeye and rev. See TRM 1.5.2 Device Identification. +* Note that rev cannot be used directly as ES1.0 uses value 0. +*/ +if (hawkeye ==0xb7ae ) { + system_rev =0x34300000 | ((1 + rev) <<12 ); +pr_info ("OMAP%04x ES2.%i\n" , system_rev >>16 , rev); +_set_omap_chip (); +return ; + }/* Check hawkeye ids */ for (i =0 ; i <ARRAY_SIZE (omap_ids); i++) {
@@ -114,16 +256,15 @@ void __init omap2_check_revision(void) omap_ids[i].type >> 16); j = i; } - system_rev = omap_ids[j].type; - system_rev |= rev <<8 ; +_set_system_rev (omap_ids[j].type, rev); -/* Add the cpu class info (24xx) */ - system_rev |=0x24 ; +_set_omap_chip ();pr_info ("OMAP%04x" , system_rev >>16 );if ((system_rev >>8 ) &0x0f ) -printk ("%x" , (system_rev >>8 ) &0x0f ); -printk ("\n" ); +pr_info ("ES%x" , (system_rev >>12 ) &0xf ); +pr_info ("\n" ); + }
include/asm-arm/arch-omap/cpu.h +37 -2
@@ -3,7 +3,7 @@* * OMAP cpu type detection * -* Copyright (C) 2004 Nokia Corporation +* Copyright (C) 2004, 2008 Nokia Corporation * * Written by Tony Lindgren <[email protected]> *
@@ -26,6 +26,12 @@#ifndef __ASM_ARCH_OMAP_CPU_H#define __ASM_ARCH_OMAP_CPU_H +struct omap_chip_id { +u8 oc; +}; + +#define OMAP_CHIP_INIT (x) { .oc = x } +extern unsigned int system_rev;#define omap2_cpu_rev () ((system_rev >> 12) & 0x0f)
@@ -345,6 +351,33 @@ IS_OMAP_TYPE(3430, 0x3430)#define OMAP2430_REV_ES1_0 0x24300000#define OMAP3430_REV_ES1_0 0x34300000#define OMAP3430_REV_ES2_0 0x34301000 +#define OMAP3430_REV_ES2_1 0x34302000 +#define OMAP3430_REV_ES2_2 0x34303000 + +/* +* omap_chip bits +* +* CHIP_IS_OMAP{2420,2430,3430} indicate that a particular structure is +* valid on all chips of that type. CHIP_IS_OMAP3430ES{1,2} indicates +* something that is only valid on that particular ES revision. +* +* These bits may be ORed together to indicate structures that are +* available on multiple chip types. +* +* To test whether a particular structure matches the current OMAP chip type, +* use omap_chip_is(). +* +*/ +#define CHIP_IS_OMAP2420 (1 << 0) +#define CHIP_IS_OMAP2430 (1 << 1) +#define CHIP_IS_OMAP3430 (1 << 2) +#define CHIP_IS_OMAP3430ES1 (1 << 3) +#define CHIP_IS_OMAP3430ES2 (1 << 4) + +#define CHIP_IS_OMAP24XX (CHIP_IS_OMAP2420 | CHIP_IS_OMAP2430) + +int omap_chip_is (struct omap_chip_id oci); +/* * Macro to detect device type i.e. EMU/HS/TST/GP/BAD
@@ -362,6 +395,8 @@ IS_OMAP_TYPE(3430, 0x3430)#define is_device_type_gp () (get_device_type() == DEVICE_TYPE_GP)#define is_device_type_bad () (get_device_type() == DEVICE_TYPE_BAD) -#endif +void omap2_check_revision (void ); + +#endif /* defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) */ #endif
Re: [PATCH 21/21] ARM: OMAP: Add OMAP chip type structure; clean up mach-omap2/id.c
Quoted 5 lines · Tony Lindgren
omap_chipis set inmach-omap2/id.cby_set_omap_chip(). Other code should use theomap_chip_is()function to test againstomap_chip.arch/arm/mach-omap2/id.c +2
-0+/** +* omap_chip_is - test whether currently running OMAP matches a chip type
arch/arm/mach-omap2/id.c static struct omap_id omap_ids[] __initdata = { · line 79
Quoted 10 lines
arch/arm/mach-omap2/id.c +10
-0+* @oc: omap_chip_t to test against +* +* Test whether the currently-running OMAP chip matches the supplied +* chip type 'oc'. Returns 1 upon a match; 0 upon failure. +*/ +int omap_chip_is (struct omap_chip_id oci) +{ +return (oci.oc & omap_chip.oc) ?1 :0 ; +} +EXPORT_SYMBOL (omap_chip_is);
I've not seen any use cases for this function, so I don't know how it's intended to be used. However, is it really sensible for this to take a structure rather than just a value?
Paul Walmsley
maintainerRe: [PATCH 21/21] ARM: OMAP: Add OMAP chip type structure; clean up mach-omap2/id.c
Hello Russell,
Quoted 4 lines · Russell King - ARM Linux
Quoted 2 lines · Tony Lindgren
omap_chipis set inmach-omap2/id.cby_set_omap_chip(). Other code should use theomap_chip_is()function to test againstomap_chip.
Quoted 16 lines
arch/arm/mach-omap2/id.c static struct omap_id omap_ids[] __initdata = { · line 79
Quoted 12 lines
arch/arm/mach-omap2/id.c +12
-0+/** +* omap_chip_is - test whether currently running OMAP matches a chip type +* @oc: omap_chip_t to test against +* +* Test whether the currently-running OMAP chip matches the supplied +* chip type 'oc'. Returns 1 upon a match; 0 upon failure. +*/ +int omap_chip_is (struct omap_chip_id oci) +{ +return (oci.oc & omap_chip.oc) ?1 :0 ; +} +EXPORT_SYMBOL (omap_chip_is);I've not seen any use cases for this function, so I don't know how it's intended to be used. However, is it really sensible for this to take a structure rather than just a value?
It was created as a structure so the size of the underlying bitmask can be increased later without patching all of the structure definitions that use it in other code. (Originally it was a typedef.) Here's a basic use case:
struct foo {
...
struct omap_chip_id omap_chip;
};static const struct foo foo_instance_omap2420 = {
...
.omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP2420)
};static const struct foo foo_instance_omap3430 = {
...
.omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
};static const struct foo *foo_instances[] = {
&foo_instance_omap2420,
&foo_instance_omap3430,
NULL
};void fn(void) {
for (p = foo_instances; p; p++) {
if (omap_chip_is(p->omap_chip)
pr_debug("Chip type matches - use this structure");
}- Paul
Re: [PATCH 20/21] ARM: OMAP: Turn CM and PRM access into functions
In reply to Tony LindgrenQuoted 3 lines · Tony Lindgren
Otherwise compiling in omap2 and omap3 will not work.
Signed-off-by Tony Lindgren <[email protected]>
Ok.
Re: [PATCH 19/21] ARM: OMAP: Introduce omap_globals and prcm access functions for multi-omap
In reply to Tony Lindgrenarch/arm/mach-omap2/control.c u32 omap_ctrl_readl(u16 offset) · line 53
Quoted 6 lines · Tony Lindgren
arch/arm/mach-omap2/control.c +1
-1@@ -51,7 +50,7 @@ u32 omap_ctrl_readl(u16 offset)void omap_ctrl_writeb (u8 val,u16 offset) {pr_debug ("omap_ctrl_writeb: writing 0x%0x to 0x%0x\n" , val, - (u32 )OMAP_CTRL_REGADDR (offset)); + (__force u32 )OMAP_CTRL_REGADDR (offset));
Casting to unsigned long avoids the need for __force. __force should be used sparingly. Alternatively, use '%p' to print a pointer.
Apart from that, ok.
Tony Lindgren
maintainerRe: [PATCH 19/21] ARM: OMAP: Introduce omap_globals and prcm access functions for multi-omap
Quoted 11 lines · Russell King - ARM Linux
Review u32 omap_ctrl_readl(u16 offset) · line 53
Quoted 6 lines · Tony Lindgren
(quoted diff) +1
-1@@ -51,7 +50,7 @@ u32 omap_ctrl_readl(u16 offset) void omap_ctrl_writeb(u8 val, u16 offset) { pr_debug("omap_ctrl_writeb: writing 0x%0x to 0x%0x\n", val, - (u32)OMAP_CTRL_REGADDR(offset)); + (__force u32)OMAP_CTRL_REGADDR(offset));Casting to unsigned long avoids the need for
__force.__forceshould be used sparingly. Alternatively, use '%p' to print a pointer.
Quoted 1 line
Apart from that, ok.
I've actually removed the verbose debug lines, those can be patched in as needed. Refreshed patch following.
Tony
Quoted 1 line
From
47953b063138ad8f04ebd988a760aea85a23f753Mon Sep 17 00:00:00 2001
From: Tony Lindgren <[email protected]>
Date: Tue, 17 Jun 2008 10:43:32 +0300
Subject: [PATCH] ARM: OMAP: Introduce omap_globals and prcm access functions for multi-omap
New struct omap_globals contains the omap processor specific module bases. Use omap_globals to set the various base addresses to make detecting omap chip type simpler.
Also introduce OMAP1_IO_ADDRESS and OMAP2_IO_ADDRESS for future multi-omap patches.
arch/arm/mach-omap2/cm.h +4 -9
@@ -96,15 +96,10 @@/* Clock management domain register get/set */ #ifndef __ASSEMBLER__ -static inline void cm_write_mod_reg (u32 val,s16 module,s16 idx) -{ -__raw_writel (val,OMAP_CM_REGADDR (module, idx)); -} - -static inline u32 cm_read_mod_reg (s16 module,s16 idx) -{ -return __raw_readl (OMAP_CM_REGADDR (module, idx)); -} + +extern u32 cm_read_mod_reg (s16 module,u16 idx); +extern void cm_write_mod_reg (u32 val,s16 module,u16 idx); +#endif /* CM register bits shared between 24XX and 3430 */
arch/arm/mach-omap2/control.c +7 -17
@@ -13,22 +13,21 @@#undef DEBUG#include <linux/kernel.h> +#include <linux/io.h> -#include <asm/io.h> - +#include <asm/arch/common.h> #include <asm/arch/control.h> -static u32 omap2_ctrl_base; +static void __iomem *omap2_ctrl_base; -#define OMAP_CTRL_REGADDR (reg) (void __iomem *)IO_ADDRESS(omap2_ctrl_base \ - + (reg)) +#define OMAP_CTRL_REGADDR (reg) (omap2_ctrl_base + (reg)) -void omap_ctrl_base_set (u32 base) +void __init omap2_set_globals_control (struct omap_globals *omap2_globals) { - omap2_ctrl_base = base; + omap2_ctrl_base = omap2_globals->ctrl; } -u32 omap_ctrl_base_get (void ) +void __iomem *omap_ctrl_base_get (void ) {return omap2_ctrl_base; }
@@ -50,25 +49,16 @@ u32 omap_ctrl_readl(u16 offset)void omap_ctrl_writeb (u8 val,u16 offset) { -pr_debug ("omap_ctrl_writeb: writing 0x%0x to 0x%0x\n" , val, - (u32 )OMAP_CTRL_REGADDR (offset)); -__raw_writeb (val,OMAP_CTRL_REGADDR (offset)); }void omap_ctrl_writew (u16 val,u16 offset) { -pr_debug ("omap_ctrl_writew: writing 0x%0x to 0x%0x\n" , val, - (u32 )OMAP_CTRL_REGADDR (offset)); -__raw_writew (val,OMAP_CTRL_REGADDR (offset)); }void omap_ctrl_writel (u32 val,u16 offset) { -pr_debug ("omap_ctrl_writel: writing 0x%0x to 0x%0x\n" , val, - (u32 )OMAP_CTRL_REGADDR (offset)); -__raw_writel (val,OMAP_CTRL_REGADDR (offset)); }
arch/arm/mach-omap2/memory.c +9 -2
@@ -24,6 +24,7 @@#include <asm/io.h> +#include <asm/arch/common.h> #include <asm/arch/clock.h> #include <asm/arch/sram.h>
@@ -32,8 +33,8 @@#include "memory.h" #include "sdrc.h" -unsigned long omap2_sdrc_base; -unsigned long omap2_sms_base; +void __iomem *omap2_sdrc_base; +void __iomem *omap2_sms_base;static struct memory_timings mem_timings;static u32 curr_perf_level =CORE_CLK_SRC_DPLL_X2 ;
@@ -154,6 +155,12 @@ void omap2_init_memory_params(u32 force_lock_to_unlock_mode) mem_timings.slow_dll_ctrl |= ((1 <<1 ) | (3 <<8 )); } +void __init omap2_set_globals_memory (struct omap_globals *omap2_globals) +{ + omap2_sdrc_base = omap2_globals->sdrc; + omap2_sms_base = omap2_globals->sms; +} +/* turn on smart idle modes for SDRAM scheduler and controller */ void __init omap2_init_memory (void ) {
arch/arm/mach-omap2/mux.c +1 -1
@@ -236,7 +236,7 @@ void __init_or_module omap2_cfg_debug(const struct pin_config *cfg, u8 reg) warn = (orig != reg);if (debug || warn)printk (KERN_WARNING -"MUX: setup %s (0x%08x): 0x%02x -> 0x%02x\n" , +"MUX: setup %s (0x%p): 0x%04x -> 0x%04x\n" , cfg->name,omap_ctrl_base_get () + cfg->mux_reg, orig, reg); }
arch/arm/mach-omap2/prcm.c +54 -1
69 lines not on this page · raw message
arch/arm/mach-omap2/prm.h +2 -10
@@ -166,16 +166,8 @@#ifndef __ASSEMBLER__/* Power/reset management domain register get/set */ - -static inline void prm_write_mod_reg (u32 val,s16 module,s16 idx) -{ -__raw_writel (val,OMAP_PRM_REGADDR (module, idx)); -} - -static inline u32 prm_read_mod_reg (s16 module,s16 idx) -{ -return __raw_readl (OMAP_PRM_REGADDR (module, idx)); -} +extern u32 prm_read_mod_reg (s16 module,u16 idx); +extern void prm_write_mod_reg (u32 val,s16 module,u16 idx);#endif
arch/arm/mach-omap2/sdrc.h +4 -6
@@ -18,13 +18,11 @@#include <asm/arch/sdrc.h> #ifndef __ASSEMBLER__ -extern unsigned long omap2_sdrc_base; -extern unsigned long omap2_sms_base; +extern void __iomem *omap2_sdrc_base; +extern void __iomem *omap2_sms_base; -#define OMAP_SDRC_REGADDR (reg) \ - (void __iomem *)IO_ADDRESS(omap2_sdrc_base + (reg)) -#define OMAP_SMS_REGADDR (reg) \ - (void __iomem *)IO_ADDRESS(omap2_sms_base + (reg)) +#define OMAP_SDRC_REGADDR (reg) (omap2_sdrc_base + (reg)) +#define OMAP_SMS_REGADDR (reg) (omap2_sms_base + (reg))/* SDRC global register get/set */
arch/arm/plat-omap/common.c +50 -9
86 lines not on this page · raw message
include/asm-arm/arch-omap/common.h +15 -0
@@ -47,8 +47,23 @@ static inline int omap_register_i2c_bus(int bus_id, u32 clkrate, }#endif +/* IO bases for various OMAP processors */ +struct omap_globals { +void __iomem *tap;/* Control module ID code */ +void __iomem *sdrc;/* SDRAM Controller */ +void __iomem *sms;/* SDRAM Memory Scheduler */ +void __iomem *ctrl;/* System Control Module */ +void __iomem *prm;/* Power and Reset Management */ +void __iomem *cm;/* Clock Management */ +}; +void omap2_set_globals_242x (void );void omap2_set_globals_243x (void );void omap2_set_globals_343x (void ); +/* These get called from omap2_set_globals_xxxx(), do not call these */ +void omap2_set_globals_memory (struct omap_globals *); +void omap2_set_globals_control (struct omap_globals *); +void omap2_set_globals_prcm (struct omap_globals *); +#endif /* __ARCH_ARM_MACH_OMAP_COMMON_H */
include/asm-arm/arch-omap/control.h +1 -3
@@ -167,8 +167,7 @@#ifndef __ASSEMBLY__#if defined(CONFIG_ARCH_OMAP2 ) || defined(CONFIG_ARCH_OMAP3 ) -extern void omap_ctrl_base_set (u32 base); -extern u32 omap_ctrl_base_get (void ); +extern void __iomem *omap_ctrl_base_get (void );extern u8 omap_ctrl_readb (u16 offset);extern u16 omap_ctrl_readw (u16 offset);extern u32 omap_ctrl_readl (u16 offset);
@@ -176,7 +175,6 @@ extern void omap_ctrl_writeb(u8 val, u16 offset);extern void omap_ctrl_writew (u16 val,u16 offset);extern void omap_ctrl_writel (u32 val,u16 offset);#else -#define omap_ctrl_base_set (x) WARN_ON(1)#define omap_ctrl_base_get () 0#define omap_ctrl_readb (x) 0#define omap_ctrl_readw (x) 0
include/asm-arm/arch-omap/io.h +3 -0
@@ -60,6 +60,7 @@#define IO_SIZE 0x40000#define IO_VIRT (IO_PHYS - IO_OFFSET)#define IO_ADDRESS (pa) ((pa) - IO_OFFSET) +#define OMAP1_IO_ADDRESS (pa) ((pa) - IO_OFFSET)#define io_p2v (pa) ((pa) - IO_OFFSET)#define io_v2p (va) ((va) + IO_OFFSET)
@@ -91,6 +92,7 @@#define IO_OFFSET 0x90000000#define IO_ADDRESS (pa) ((pa) + IO_OFFSET)/* Works for L3 and L4 */ +#define OMAP2_IO_ADDRESS (pa) ((pa) + IO_OFFSET)/* Works for L3 and L4 */ #define io_p2v (pa) ((pa) + IO_OFFSET)/* Works for L3 and L4 */ #define io_v2p (va) ((va) - IO_OFFSET)/* Works for L3 and L4 */
@@ -148,6 +150,7 @@#define IO_OFFSET 0x90000000#define IO_ADDRESS (pa) ((pa) + IO_OFFSET)/* Works for L3 and L4 */ +#define OMAP2_IO_ADDRESS (pa) ((pa) + IO_OFFSET)/* Works for L3 and L4 */ #define io_p2v (pa) ((pa) + IO_OFFSET)/* Works for L3 and L4 */ #define io_v2p (va) ((va) - IO_OFFSET)/* Works for L3 and L4 */
Re: [PATCH 19/21] ARM: OMAP: Introduce omap_globals and prcm access functions for multi-omap
Quoted 12 lines · Tony Lindgren
Quoted 11 lines · Russell King - ARM Linux
arch/arm/mach-omap2/control.c u32 omap_ctrl_readl(u16 offset) · line 53
Quoted 6 lines · Tony Lindgren
arch/arm/mach-omap2/control.c +1
-1@@ -51,7 +50,7 @@ u32 omap_ctrl_readl(u16 offset)void omap_ctrl_writeb (u8 val,u16 offset) {pr_debug ("omap_ctrl_writeb: writing 0x%0x to 0x%0x\n" , val, - (u32 )OMAP_CTRL_REGADDR (offset)); + (__force u32 )OMAP_CTRL_REGADDR (offset));Casting to unsigned long avoids the need for
__force.__forceshould be used sparingly. Alternatively, use '%p' to print a pointer.
Quoted 4 lines
Quoted 1 line
Apart from that, ok.
I've actually removed the verbose debug lines, those can be patched in as needed. Refreshed patch following.
Ok.
Re: [PATCH 18/21] ARM: OMAP: Remove __REG access for multi-omap
In reply to Tony LindgrenQuoted 4 lines · Tony Lindgren
This does not play nicely with multi-omap as it cannot be replaced by a function in
io.cfor omaps with different IO bases.Signed-off-by Tony Lindgren <[email protected]>
Ok.
Re: [PATCH 11/21] ARM: OMAP: McBSP: Prepare for splitting into omap1 and omap2 code
In reply to Tony LindgrenQuoted 9 lines · Tony Lindgren
arch/arm/plat-omap/devices.c +9
-0+#if defined(CONFIG_OMAP_MCBSP ) || defined(CONFIG_OMAP_MCBSP_MODULE ) + +static struct platform_device omap_mcbsp_devices[OMAP_MAX_MCBSP_COUNT ]; +static int mcbsps_configured; + +void omap_mcbsp_register_board_cfg (struct omap_mcbsp_platform_data *config, +int size) +{ +int i;
arch/arm/plat-omap/devices.c static inline void omap_init_kp(void) {} · line 167
Quoted 10 lines
arch/arm/plat-omap/devices.c +10
-0+ +if (size >OMAP_MAX_MCBSP_COUNT ) { +printk (KERN_WARNING "Registered too many McBSPs platform_data." +" Using maximum (%d) available.\n" , +OMAP_MAX_MCBSP_COUNT ); + size =OMAP_MAX_MCBSP_COUNT ; + } + +for (i =0 ; i < size; i++) { +struct platform_device *new_mcbsp = &omap_mcbsp_devices[i];
Any reason this can't use the platform_device_alloc() API rather than having a static restriction on the number (coupled with the wastage of space for smaller 'size's ?)
Tony Lindgren
maintainerRe: [PATCH 11/21] ARM: OMAP: McBSP: Prepare for splitting into omap1 and omap2 code
Quoted 16 lines · Russell King - ARM Linux
Quoted 15 lines · Tony Lindgren
arch/arm/plat-omap/devices.c +15
-0+#if defined(CONFIG_OMAP_MCBSP ) || defined(CONFIG_OMAP_MCBSP_MODULE ) + +static struct platform_device omap_mcbsp_devices[OMAP_MAX_MCBSP_COUNT ]; +static int mcbsps_configured; + +void omap_mcbsp_register_board_cfg (struct omap_mcbsp_platform_data *config, +int size) +{ +int i; + +if (size >OMAP_MAX_MCBSP_COUNT ) { +printk (KERN_WARNING "Registered too many McBSPs platform_data." +" Using maximum (%d) available.\n" , +OMAP_MAX_MCBSP_COUNT ); + size =OMAP_MAX_MCBSP_COUNT ;
Quoted 8 lines
arch/arm/plat-omap/devices.c static inline void omap_init_kp(void) {} · line 167
Quoted 4 lines
arch/arm/plat-omap/devices.c +4
-0+ } + +for (i =0 ; i < size; i++) { +struct platform_device *new_mcbsp = &omap_mcbsp_devices[i];Any reason this can't use the
platform_device_alloc()API rather than having a static restriction on the number (coupled with the wastage of space for smaller 'size's ?)
I agree, this should be allocated. Eduardo, any comments?
Tony
Tony Lindgren
maintainerRe: [PATCH 11/21] ARM: OMAP: McBSP: Prepare for splitting into omap1 and omap2 code
Quoted 26 lines · Tony Lindgren
Quoted 16 lines · Russell King - ARM Linux
Quoted 15 lines · Tony Lindgren
(quoted diff) +15
-0+#if defined(CONFIG_OMAP_MCBSP) || defined(CONFIG_OMAP_MCBSP_MODULE) + +static struct platform_device omap_mcbsp_devices[OMAP_MAX_MCBSP_COUNT]; +static int mcbsps_configured; + +void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config, + int size) +{ + int i; + + if (size > OMAP_MAX_MCBSP_COUNT) { + printk(KERN_WARNING "Registered too many McBSPs platform_data." + " Using maximum (%d) available.\n", + OMAP_MAX_MCBSP_COUNT); + size = OMAP_MAX_MCBSP_COUNT;Quoted 8 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ } + + for (i = 0; i < size; i++) { + struct platform_device *new_mcbsp = &omap_mcbsp_devices[i];Any reason this can't use the
platform_device_alloc()API rather than having a static restriction on the number (coupled with the wastage of space for smaller 'size's ?)
Quoted 1 line
I agree, this should be allocated. Eduardo, any comments?
Here's updated patch that uses platform_device_alloc().
Tony
Quoted 1 line
From
53f2999d681669df0645053dc572d97cda69823dMon Sep 17 00:00:00 2001
From: Eduardo Valentin <[email protected]>
Date: Mon, 23 Jun 2008 12:37:30 +0300
Subject: [PATCH] ARM: OMAP: McBSP: Prepare for splitting into omap1 and omap2 code
This patch transform mcbsp code to use platform data from arch/arm/plat-omap/devices.c
It also gets ride of ifdefs on mcbsp.c code.
To do it, a platform data structure was defined.
arch/arm/plat-omap/devices.c +48 -0
@@ -24,6 +24,7 @@#include <asm/arch/mux.h> #include <asm/arch/gpio.h> #include <asm/arch/menelaus.h> +#include <asm/arch/mcbsp.h> #if defined(CONFIG_OMAP_DSP ) || defined(CONFIG_OMAP_DSP_MODULE )
@@ -145,6 +146,53 @@ static inline void omap_init_kp(void) {}#endif /*-------------------------------------------------------------------------*/ +#if defined(CONFIG_OMAP_MCBSP ) || defined(CONFIG_OMAP_MCBSP_MODULE ) + +static struct platform_device **omap_mcbsp_devices; + +void omap_mcbsp_register_board_cfg (struct omap_mcbsp_platform_data *config, +int size) +{ +int i; + +if (size >OMAP_MAX_MCBSP_COUNT ) { +printk (KERN_WARNING "Registered too many McBSPs platform_data." +" Using maximum (%d) available.\n" , +OMAP_MAX_MCBSP_COUNT ); + size =OMAP_MAX_MCBSP_COUNT ; + } + + omap_mcbsp_devices =kzalloc (size *sizeof (struct platform_device *), +GFP_KERNEL ); +if (!omap_mcbsp_devices) { +printk (KERN_ERR "Could not register McBSP devices\n" ); +return ; + } + +for (i =0 ; i < size; i++) { +struct platform_device *new_mcbsp; +int ret; + + new_mcbsp =platform_device_alloc ("omap-mcbsp" , i +1 ); +if (!new_mcbsp) +continue ; + new_mcbsp->dev.platform_data = &config[i]; + ret =platform_device_add (new_mcbsp); +if (ret) { +platform_device_put (new_mcbsp); +continue ; + } + omap_mcbsp_devices[i] = new_mcbsp; + } +} + +#else +void omap_mcbsp_register_board_cfg (struct omap_mcbsp_platform_data *config, +int size) +{ } +#endif + +/*-------------------------------------------------------------------------*/ #if defined(CONFIG_MMC_OMAP ) || defined(CONFIG_MMC_OMAP_MODULE )
arch/arm/plat-omap/mcbsp.c +253 -409
919 lines not on this page · raw message
include/asm-arm/arch-omap/mcbsp.h +60 -2
93 lines not on this page · raw message
Re: [PATCH 11/21] ARM: OMAP: McBSP: Prepare for splitting intoomap1 and omap2 code
Hi,
i was about to send the same patch. it works fine for me. chandra Shekhar
----- Original Message ----- From: "Tony Lindgren" <[email protected]>
To: "Russell King - ARM Linux" <[email protected]>
Cc: <[email protected]>; "Eduardo Valentin" <[email protected]>; <[email protected]>; "Nikula Jarkko (NRC/Helsinki)" <[email protected]>
Sent: Monday, June 23, 2008 3:09 PM
Subject: Re: [PATCH 11/21] ARM: OMAP: McBSP: Prepare for splitting intoomap1 and omap2 code
Quoted 29 lines · Tony Lindgren
Quoted 28 lines · Russell King - ARM Linux
Quoted 26 lines · Tony Lindgren
Quoted 11 lines
arch/arm/plat-omap/devices.c +3
-0+#if defined(CONFIG_OMAP_MCBSP ) || defined(CONFIG_OMAP_MCBSP_MODULE ) + +static struct platform_deviceomap_mcbsp_devices[OMAP_MAX_MCBSP_COUNT];
(quoted diff) +3
-0+static int mcbsps_configured; + +void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data*config,
+ int size)arch/arm/plat-omap/devices.c +2
-0+{ +int i;arch/arm/plat-omap/devices.c static inline void omap_init_kp(void) {}
Quoted 10 lines
arch/arm/plat-omap/devices.c +10
-0+ +if (size >OMAP_MAX_MCBSP_COUNT ) { +printk (KERN_WARNING "Registered too many McBSPs platform_data." +" Using maximum (%d) available.\n" , +OMAP_MAX_MCBSP_COUNT ); + size =OMAP_MAX_MCBSP_COUNT ; + } + +for (i =0 ; i < size; i++) { +struct platform_device *new_mcbsp = &omap_mcbsp_devices[i];Any reason this can't use the
platform_device_alloc()API rather than having a static restriction on the number (coupled with the wastage of space for smaller 'size's ?)
Quoted 6 lines
Quoted 1 line
I agree, this should be allocated. Eduardo, any comments?
Here's updated patch that uses
platform_device_alloc().Tony
--------------------------------------------------------------------------------
Quoted 79 lines
From
53f2999d681669df0645053dc572d97cda69823dMon Sep 17 00:00:00 2001
From: Eduardo Valentin <[email protected]>
Date: Mon, 23 Jun 2008 12:37:30 +0300
Subject: [PATCH] ARM: OMAP: McBSP: Prepare for splitting into omap1 and omap2 codeThis patch transform mcbsp code to use platform data from
arch/arm/plat-omap/devices.cIt also gets ride of ifdefs on
mcbsp.ccode.
To do it, a platform data structure was defined.Signed-off-by Eduardo Valentin <[email protected]>Signed-off-by Tony Lindgren <[email protected]>arch/arm/plat-omap/devices.c +48
-0@@ -24,6 +24,7 @@#include <asm/arch/mux.h> #include <asm/arch/gpio.h> #include <asm/arch/menelaus.h> +#include <asm/arch/mcbsp.h> #if defined(CONFIG_OMAP_DSP ) || defined(CONFIG_OMAP_DSP_MODULE )@@ -145,6 +146,53 @@ static inline void omap_init_kp(void) {}#endif /*-------------------------------------------------------------------------*/ +#if defined(CONFIG_OMAP_MCBSP ) || defined(CONFIG_OMAP_MCBSP_MODULE ) + +static struct platform_device **omap_mcbsp_devices; + +void omap_mcbsp_register_board_cfg (struct omap_mcbsp_platform_data *config, +int size) +{ +int i; + +if (size >OMAP_MAX_MCBSP_COUNT ) { +printk (KERN_WARNING "Registered too many McBSPs platform_data." +" Using maximum (%d) available.\n" , +OMAP_MAX_MCBSP_COUNT ); + size =OMAP_MAX_MCBSP_COUNT ; + } + + omap_mcbsp_devices =kzalloc (size *sizeof (struct platform_device *), +GFP_KERNEL ); +if (!omap_mcbsp_devices) { +printk (KERN_ERR "Could not register McBSP devices\n" ); +return ; + } + +for (i =0 ; i < size; i++) { +struct platform_device *new_mcbsp; +int ret; + + new_mcbsp =platform_device_alloc ("omap-mcbsp" , i +1 ); +if (!new_mcbsp) +continue ; + new_mcbsp->dev.platform_data = &config[i]; + ret =platform_device_add (new_mcbsp); +if (ret) { +platform_device_put (new_mcbsp); +continue ; + } + omap_mcbsp_devices[i] = new_mcbsp; + } +} + +#else +void omap_mcbsp_register_board_cfg (struct omap_mcbsp_platform_data *config, +int size) +{ } +#endif + +/*-------------------------------------------------------------------------*/
Re: [PATCH 10/21] ARM: OMAP: McBSP: Coding style cleanup on arch/arm/plat-omap/mcbsp.c
In reply to Tony LindgrenQuoted 14 lines · Tony Lindgren
From: Eduardo Valentin <[email protected]>
This patch fix lots of warnings and errors reported by
scripts/checkpatch.plonarch/arm/plat-omap/mcbsp.c.Signed-off-by Eduardo Valentin <[email protected]>Acked-by Felipe Balbi <[email protected]>Signed-off-by Tony Lindgren <[email protected]>arch/arm/plat-omap/mcbsp.c +0
-0
arch/arm/plat-omap/mcbsp.c line 25
Quoted 8 lines
arch/arm/plat-omap/mcbsp.c +2
-3@@ -21,9 +21,8 @@#include <linux/err.h> #include <linux/clk.h> #include <linux/delay.h> - -#include <asm/io.h> -#include <asm/irq.h> +#include <linux/io.h> +#include <linux/irq.h>
checkpatch isn't always right. In the case of linux/irq.h vs asm/irq.h they are not equivalent. linux/irq.h is the genirq header file. asm/irq.h is the architecture irq.h file. The two are quite different (unlike the linux/io.h and asm/io.h case.)
Unless you're doing something with static IRQ numbers, you shouldn't need either of these irq.h headers - the one you generally want for drivers is linux/interrupt.h.
Re: [PATCH 10/21] ARM: OMAP: McBSP: Coding style cleanup on arch/arm/plat-omap/mcbsp.c
Quoted 29 lines · Russell King - ARM Linux
Quoted 14 lines · Tony Lindgren
From: Eduardo Valentin <[email protected]>
This patch fix lots of warnings and errors reported by
scripts/checkpatch.plonarch/arm/plat-omap/mcbsp.c.Signed-off-by Eduardo Valentin <[email protected]>Acked-by Felipe Balbi <[email protected]>Signed-off-by Tony Lindgren <[email protected]>arch/arm/plat-omap/mcbsp.c +0
-0arch/arm/plat-omap/mcbsp.c line 25
Quoted 8 lines
arch/arm/plat-omap/mcbsp.c +2
-3@@ -21,9 +21,8 @@#include <linux/err.h> #include <linux/clk.h> #include <linux/delay.h> - -#include <asm/io.h> -#include <asm/irq.h> +#include <linux/io.h> +#include <linux/irq.h> checkpatch isn't always right. In the case of
linux/irq.hvsasm/irq.hthey are not equivalent.linux/irq.his the genirq header file.asm/irq.his the architectureirq.hfile. The two are quite different (unlike thelinux/io.handasm/io.hcase.)
Quoted 3 lines
Unless you're doing something with static IRQ numbers, you shouldn't need either of these
irq.hheaders - the one you generally want for drivers islinux/interrupt.h.
The include for irq.h can be left out. Updated patch below.
Tony
Quoted 1 line
From
b7314ee36cc669c82c34dc9e9d27f4bd67a4620bMon Sep 17 00:00:00 2001
From: Eduardo Valentin <[email protected]>
Date: Mon, 23 Jun 2008 12:01:41 +0300
Subject: [PATCH] ARM: OMAP: McBSP: Coding style cleanup on arch/arm/plat-omap/mcbsp.c
This patch fix lots of warnings and errors reported by scripts/checkpatch.pl on arch/arm/plat-omap/mcbsp.c.
arch/arm/plat-omap/mcbsp.c +102 -95
@@ -21,9 +21,7 @@#include <linux/err.h> #include <linux/clk.h> #include <linux/delay.h> - -#include <asm/io.h> -#include <asm/irq.h> +#include <linux/io.h> #include <asm/arch/dma.h> #include <asm/arch/mux.h>
@@ -61,20 +59,21 @@ struct omap_mcbsp {struct completion tx_dma_completion;struct completion rx_dma_completion; +/* Protect the field .free, while checking if the mcbsp is in use */ spinlock_t lock; };static struct omap_mcbsp mcbsp[OMAP_MAX_MCBSP_COUNT ];#ifdef CONFIG_ARCH_OMAP1 -static struct clk *mcbsp_dsp_ck =0 ; -static struct clk *mcbsp_api_ck =0 ; -static struct clk *mcbsp_dspxor_ck =0 ; +static struct clk *mcbsp_dsp_ck; +static struct clk *mcbsp_api_ck; +static struct clk *mcbsp_dspxor_ck;#endif #ifdef CONFIG_ARCH_OMAP2 -static struct clk *mcbsp1_ick =0 ; -static struct clk *mcbsp1_fck =0 ; -static struct clk *mcbsp2_ick =0 ; -static struct clk *mcbsp2_fck =0 ; +static struct clk *mcbsp1_ick; +static struct clk *mcbsp1_fck; +static struct clk *mcbsp2_ick; +static struct clk *mcbsp2_fck;#endif static void omap_mcbsp_dump_reg (u8 id)
@@ -104,6 +103,7 @@ static irqreturn_t omap_mcbsp_tx_irq_handler(int irq, void *dev_id) OMAP_MCBSP_READ(mcbsp_tx->io_base, SPCR2));complete (&mcbsp_tx->tx_irq_completion); +return IRQ_HANDLED ; }
@@ -115,6 +115,7 @@ static irqreturn_t omap_mcbsp_rx_irq_handler(int irq, void *dev_id) OMAP_MCBSP_READ(mcbsp_rx->io_base, SPCR2));complete (&mcbsp_rx->rx_irq_completion); +return IRQ_HANDLED ; }
@@ -146,19 +147,17 @@ static void omap_mcbsp_rx_dma_callback(int lch, u16 ch_status, void *data)complete (&mcbsp_dma_rx->rx_dma_completion); } -/* * omap_mcbsp_config simply write a config to the * appropriate McBSP. * You either call this function or set the McBSP registers * by yourself before calling omap_mcbsp_start(). */ - -void omap_mcbsp_config (unsigned int id,const struct omap_mcbsp_reg_cfg * config) +void omap_mcbsp_config (unsigned int id,const struct omap_mcbsp_reg_cfg *config) {u32 io_base = mcbsp[id].io_base; -DBG ("OMAP-McBSP: McBSP%d io_base: 0x%8x\n" , id+1 , io_base); +DBG ("OMAP-McBSP: McBSP%d io_base: 0x%8x\n" , id +1 , io_base);/* We write the given config */ OMAP_MCBSP_WRITE (io_base,SPCR2 , config->spcr2);
@@ -173,14 +172,14 @@ void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg * configOMAP_MCBSP_WRITE (io_base,MCR1 , config->mcr1);OMAP_MCBSP_WRITE (io_base,PCR0 , config->pcr0); } - - +EXPORT_SYMBOL (omap_mcbsp_config);static int omap_mcbsp_check (unsigned int id) {if (cpu_is_omap730 ()) {if (id >OMAP_MAX_MCBSP_COUNT -1 ) { -printk (KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n" , id +1 ); +printk (KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n" , + id +1 );return -1 ; }return 0 ;
@@ -188,7 +187,8 @@ static int omap_mcbsp_check(unsigned int id)if (cpu_is_omap15xx () ||cpu_is_omap16xx () ||cpu_is_omap24xx ()) {if (id >OMAP_MAX_MCBSP_COUNT ) { -printk (KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n" , id +1 ); +printk (KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n" , + id +1 );return -1 ; }return 0 ;
@@ -263,7 +263,8 @@ int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type)spin_lock (&mcbsp[id].lock);if (!mcbsp[id].free) { -printk (KERN_ERR "OMAP-McBSP: McBSP%d is currently in use\n" , id +1 ); +printk (KERN_ERR "OMAP-McBSP: McBSP%d is currently in use\n" , + id +1 );spin_unlock (&mcbsp[id].lock);return -EINVAL ; }
@@ -274,6 +275,7 @@ int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type)return 0 ; } +EXPORT_SYMBOL (omap_mcbsp_set_io_type);int omap_mcbsp_request (unsigned int id) {
@@ -305,7 +307,8 @@ int omap_mcbsp_request(unsigned int id)spin_lock (&mcbsp[id].lock);if (!mcbsp[id].free) { -printk (KERN_ERR "OMAP-McBSP: McBSP%d is currently in use\n" , id +1 ); +printk (KERN_ERR "OMAP-McBSP: McBSP%d is currently in use\n" , + id +1 );spin_unlock (&mcbsp[id].lock);return -1 ; }
@@ -315,24 +318,23 @@ int omap_mcbsp_request(unsigned int id)if (mcbsp[id].io_type ==OMAP_MCBSP_IRQ_IO ) {/* We need to get IRQs here */ - err =request_irq (mcbsp[id].tx_irq, omap_mcbsp_tx_irq_handler,0 , -"McBSP" , - (void *) (&mcbsp[id])); + err =request_irq (mcbsp[id].tx_irq, omap_mcbsp_tx_irq_handler, +0 ,"McBSP" , (void *) (&mcbsp[id]));if (err !=0 ) { -printk (KERN_ERR "OMAP-McBSP: Unable to request TX IRQ %d for McBSP%d\n" , - mcbsp[id].tx_irq, mcbsp[id].id); +printk (KERN_ERR "OMAP-McBSP: Unable to " +"request TX IRQ %d for McBSP%d\n" , + mcbsp[id].tx_irq, mcbsp[id].id);return err; }init_completion (&(mcbsp[id].tx_irq_completion)); - - err =request_irq (mcbsp[id].rx_irq, omap_mcbsp_rx_irq_handler,0 , -"McBSP" , - (void *) (&mcbsp[id])); + err =request_irq (mcbsp[id].rx_irq, omap_mcbsp_rx_irq_handler, +0 ,"McBSP" , (void *) (&mcbsp[id]));if (err !=0 ) { -printk (KERN_ERR "OMAP-McBSP: Unable to request RX IRQ %d for McBSP%d\n" , - mcbsp[id].rx_irq, mcbsp[id].id); +printk (KERN_ERR "OMAP-McBSP: Unable to " +"request RX IRQ %d for McBSP%d\n" , + mcbsp[id].rx_irq, mcbsp[id].id);free_irq (mcbsp[id].tx_irq, (void *) (&mcbsp[id]));return err; }
@@ -341,8 +343,8 @@ int omap_mcbsp_request(unsigned int id) }return 0 ; - } +EXPORT_SYMBOL (omap_mcbsp_request);void omap_mcbsp_free (unsigned int id) {
@@ -370,7 +372,8 @@ void omap_mcbsp_free(unsigned int id)spin_lock (&mcbsp[id].lock);if (mcbsp[id].free) { -printk (KERN_ERR "OMAP-McBSP: McBSP%d was not reserved\n" , id +1 ); +printk (KERN_ERR "OMAP-McBSP: McBSP%d was not reserved\n" , + id +1 );spin_unlock (&mcbsp[id].lock);return ; }
@@ -384,6 +387,7 @@ void omap_mcbsp_free(unsigned int id)free_irq (mcbsp[id].tx_irq, (void *) (&mcbsp[id])); } } +EXPORT_SYMBOL (omap_mcbsp_free);/* * Here we start the McBSP, by enabling the sample
@@ -400,8 +404,8 @@ void omap_mcbsp_start(unsigned int id) io_base = mcbsp[id].io_base; - mcbsp[id].rx_word_length = ((OMAP_MCBSP_READ (io_base,RCR1 ) >>5 ) &0x7 ); - mcbsp[id].tx_word_length = ((OMAP_MCBSP_READ (io_base,XCR1 ) >>5 ) &0x7 ); + mcbsp[id].rx_word_length = (OMAP_MCBSP_READ (io_base,RCR1 ) >>5 ) &0x7 ; + mcbsp[id].tx_word_length = (OMAP_MCBSP_READ (io_base,XCR1 ) >>5 ) &0x7 ;/* Start the sample generator */ w =OMAP_MCBSP_READ (io_base,SPCR2 );
@@ -422,8 +426,8 @@ void omap_mcbsp_start(unsigned int id)/* Dump McBSP Regs */ omap_mcbsp_dump_reg (id); - } +EXPORT_SYMBOL (omap_mcbsp_start);void omap_mcbsp_stop (unsigned int id) {
@@ -435,7 +439,7 @@ void omap_mcbsp_stop(unsigned int id) io_base = mcbsp[id].io_base; -/* Reset transmitter */ +/* Reset transmitter */ w =OMAP_MCBSP_READ (io_base,SPCR2 );OMAP_MCBSP_WRITE (io_base,SPCR2 , w & ~(1 ));
@@ -447,7 +451,7 @@ void omap_mcbsp_stop(unsigned int id) w =OMAP_MCBSP_READ (io_base,SPCR2 );OMAP_MCBSP_WRITE (io_base,SPCR2 , w & ~(1 <<6 )); } - +EXPORT_SYMBOL (omap_mcbsp_stop);/* polled mcbsp i/o operations */ int omap_mcbsp_pollwrite (unsigned int id,u16 buf)
@@ -480,10 +484,12 @@ int omap_mcbsp_pollwrite(unsigned int id, u16 buf) } } } +return 0 ; } +EXPORT_SYMBOL (omap_mcbsp_pollwrite); -int omap_mcbsp_pollread (unsigned int id,u16 * buf) +int omap_mcbsp_pollread (unsigned int id,u16 *buf) {u32 base = mcbsp[id].io_base;/* if frame sync error - clear the error */
@@ -513,8 +519,10 @@ int omap_mcbsp_pollread(unsigned int id, u16 * buf) } } *buf =readw (base +OMAP_MCBSP_REG_DRR1 ); +return 0 ; } +EXPORT_SYMBOL (omap_mcbsp_pollread);/* * IRQ based word transmission.
@@ -535,6 +543,7 @@ void omap_mcbsp_xmit_word(unsigned int id, u32 word)OMAP_MCBSP_WRITE (io_base,DXR2 , word >>16 );OMAP_MCBSP_WRITE (io_base,DXR1 , word &0xffff ); } +EXPORT_SYMBOL (omap_mcbsp_xmit_word);u32 omap_mcbsp_recv_word (unsigned int id) {
@@ -555,7 +564,7 @@ u32 omap_mcbsp_recv_word(unsigned int id)return (word_lsb | (word_msb <<16 )); } - +EXPORT_SYMBOL (omap_mcbsp_recv_word);int omap_mcbsp_spi_master_xmit_word_poll (unsigned int id,u32 word) {
@@ -577,7 +586,7 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)udelay (10 );OMAP_MCBSP_WRITE (io_base,SPCR2 , spcr2 |XRST );udelay (10 ); -printk ("McBSP transmitter not ready\n" ); +printk (KERN_ERR "McBSP transmitter not ready\n" );return -EAGAIN ; } }
@@ -597,7 +606,7 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)udelay (10 );OMAP_MCBSP_WRITE (io_base,SPCR1 , spcr1 |RRST );udelay (10 ); -printk ("McBSP receiver not ready\n" ); +printk (KERN_ERR "McBSP receiver not ready\n" );return -EAGAIN ; } }
@@ -609,8 +618,9 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)return 0 ; } +EXPORT_SYMBOL (omap_mcbsp_spi_master_xmit_word_poll); -int omap_mcbsp_spi_master_recv_word_poll (unsigned int id,u32 * word) +int omap_mcbsp_spi_master_recv_word_poll (unsigned int id,u32 *word) {u32 io_base = mcbsp[id].io_base, clock_word =0 ;omap_mcbsp_word_length tx_word_length = mcbsp[id].tx_word_length;
@@ -630,7 +640,7 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word)udelay (10 );OMAP_MCBSP_WRITE (io_base,SPCR2 , spcr2 |XRST );udelay (10 ); -printk ("McBSP transmitter not ready\n" ); +printk (KERN_ERR "McBSP transmitter not ready\n" );return -EAGAIN ; } }
@@ -650,7 +660,7 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word)udelay (10 );OMAP_MCBSP_WRITE (io_base,SPCR1 , spcr1 |RRST );udelay (10 ); -printk ("McBSP receiver not ready\n" ); +printk (KERN_ERR "McBSP receiver not ready\n" );return -EAGAIN ; } }
@@ -664,7 +674,7 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word)return 0 ; } - +EXPORT_SYMBOL (omap_mcbsp_spi_master_recv_word_poll);/* * Simple DMA based buffer rx/tx routines.
@@ -673,7 +683,8 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word)* For anything fancier, you should use your own customized DMA * routines and callbacks. */ -int omap_mcbsp_xmit_buffer (unsigned int id,dma_addr_t buffer,unsigned int length) +int omap_mcbsp_xmit_buffer (unsigned int id,dma_addr_t buffer, +unsigned int length) {int dma_tx_ch;int src_port =0 ;
@@ -683,10 +694,12 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer, unsigned int lengif (omap_mcbsp_check (id) <0 )return -EINVAL ; -if (omap_request_dma (mcbsp[id].dma_tx_sync,"McBSP TX" , omap_mcbsp_tx_dma_callback, - &mcbsp[id], - &dma_tx_ch)) { -printk ("OMAP-McBSP: Unable to request DMA channel for McBSP%d TX. Trying IRQ based TX\n" , id+1 ); +if (omap_request_dma (mcbsp[id].dma_tx_sync,"McBSP TX" , + omap_mcbsp_tx_dma_callback, + &mcbsp[id], + &dma_tx_ch)) { +printk (KERN_ERR "OMAP-McBSP: Unable to request DMA channel for" +" McBSP%d TX. Trying IRQ based TX\n" , id +1 );return -EAGAIN ; } mcbsp[id].dma_tx_lch = dma_tx_ch;
@@ -722,11 +735,13 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer, unsigned int lengomap_start_dma (mcbsp[id].dma_tx_lch);wait_for_completion (&(mcbsp[id].tx_dma_completion)); +return 0 ; } +EXPORT_SYMBOL (omap_mcbsp_xmit_buffer); - -int omap_mcbsp_recv_buffer (unsigned int id,dma_addr_t buffer,unsigned int length) +int omap_mcbsp_recv_buffer (unsigned int id,dma_addr_t buffer, +unsigned int length) {int dma_rx_ch;int src_port =0 ;
@@ -736,10 +751,12 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int lengif (omap_mcbsp_check (id) <0 )return -EINVAL ; -if (omap_request_dma (mcbsp[id].dma_rx_sync,"McBSP RX" , omap_mcbsp_rx_dma_callback, - &mcbsp[id], - &dma_rx_ch)) { -printk ("Unable to request DMA channel for McBSP%d RX. Trying IRQ based RX\n" , id+1 ); +if (omap_request_dma (mcbsp[id].dma_rx_sync,"McBSP RX" , + omap_mcbsp_rx_dma_callback, + &mcbsp[id], + &dma_rx_ch)) { +printk (KERN_ERR "Unable to request DMA channel for McBSP%d RX." +" Trying IRQ based RX\n" , id +1 );return -EAGAIN ; } mcbsp[id].dma_rx_lch = dma_rx_ch;
@@ -756,10 +773,10 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng sync_dev = mcbsp[id].dma_rx_sync;omap_set_dma_transfer_params (mcbsp[id].dma_rx_lch, -OMAP_DMA_DATA_TYPE_S16 , - length >>1 ,1 , -OMAP_DMA_SYNC_ELEMENT , - sync_dev,0 ); +OMAP_DMA_DATA_TYPE_S16 , + length >>1 ,1 , +OMAP_DMA_SYNC_ELEMENT , + sync_dev,0 ); omap_set_dma_src_params(mcbsp[id].dma_rx_lch, src_port,
@@ -768,16 +785,17 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng 0, 0);omap_set_dma_dest_params (mcbsp[id].dma_rx_lch, - dest_port, -OMAP_DMA_AMODE_POST_INC , - buffer, -0 ,0 ); + dest_port, +OMAP_DMA_AMODE_POST_INC , + buffer, +0 ,0 );omap_start_dma (mcbsp[id].dma_rx_lch);wait_for_completion (&(mcbsp[id].rx_dma_completion)); +return 0 ; } - +EXPORT_SYMBOL (omap_mcbsp_recv_buffer);/* * SPI wrapper.
@@ -785,7 +803,8 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng* this wrapper just need an omap_mcbsp_spi_cfg structure as an input. * Once this is done, you can call omap_mcbsp_start(). */ -void omap_mcbsp_set_spi_mode (unsigned int id,const struct omap_mcbsp_spi_cfg * spi_cfg) +void omap_mcbsp_set_spi_mode (unsigned int id, +const struct omap_mcbsp_spi_cfg *spi_cfg) {struct omap_mcbsp_reg_cfg mcbsp_cfg;
@@ -798,7 +817,7 @@ void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg * mcbsp_cfg.rcr1 |= (RWDLEN1 (spi_cfg->word_length) |RFRLEN1 (0 )); mcbsp_cfg.xcr1 |= (XWDLEN1 (spi_cfg->word_length) |XFRLEN1 (0 )); -/* Clock stop mode */ +/* Clock stop mode */ if (spi_cfg->clk_stp_mode ==OMAP_MCBSP_CLK_STP_MODE_NO_DELAY ) mcbsp_cfg.spcr1 |= (1 <<12 );else
@@ -827,13 +846,12 @@ void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg *if (spi_cfg->spi_mode ==OMAP_MCBSP_SPI_MASTER ) { mcbsp_cfg.pcr0 |=CLKXM ; - mcbsp_cfg.srgr1 |=CLKGDV (spi_cfg->clk_div -1 ); + mcbsp_cfg.srgr1 |=CLKGDV (spi_cfg->clk_div -1 ); mcbsp_cfg.pcr0 |=FSXM ; mcbsp_cfg.srgr2 &= ~FSGM ; mcbsp_cfg.xcr2 |=XDATDLY (1 ); mcbsp_cfg.rcr2 |=RDATDLY (1 ); - } -else { + }else { mcbsp_cfg.pcr0 &= ~CLKXM ; mcbsp_cfg.srgr1 |=CLKGDV (1 ); mcbsp_cfg.pcr0 &= ~FSXM ;
@@ -846,7 +864,7 @@ void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg *omap_mcbsp_config (id, &mcbsp_cfg); } - +EXPORT_SYMBOL (omap_mcbsp_set_spi_mode);/* * McBSP1 and McBSP3 are directly mapped on 1610 and 1510.
@@ -935,7 +953,7 @@ static int __init omap_mcbsp_init(void)int mcbsp_count =0 , i;static const struct omap_mcbsp_info *mcbsp_info; -printk ("Initializing OMAP McBSP system\n" ); +printk (KERN_INFO "Initializing OMAP McBSP system\n" );#ifdef CONFIG_ARCH_OMAP1 mcbsp_dsp_ck =clk_get (0 ,"dsp_ck" );
@@ -957,22 +975,26 @@ static int __init omap_mcbsp_init(void)#ifdef CONFIG_ARCH_OMAP2 mcbsp1_ick =clk_get (0 ,"mcbsp1_ick" );if (IS_ERR (mcbsp1_ick)) { -printk (KERN_ERR "mcbsp: could not acquire mcbsp1_ick handle.\n" ); +printk (KERN_ERR "mcbsp: could not acquire " +"mcbsp1_ick handle.\n" );return PTR_ERR (mcbsp1_ick); } mcbsp1_fck =clk_get (0 ,"mcbsp1_fck" );if (IS_ERR (mcbsp1_fck)) { -printk (KERN_ERR "mcbsp: could not acquire mcbsp1_fck handle.\n" ); +printk (KERN_ERR "mcbsp: could not acquire " +"mcbsp1_fck handle.\n" );return PTR_ERR (mcbsp1_fck); } mcbsp2_ick =clk_get (0 ,"mcbsp2_ick" );if (IS_ERR (mcbsp2_ick)) { -printk (KERN_ERR "mcbsp: could not acquire mcbsp2_ick handle.\n" ); +printk (KERN_ERR "mcbsp: could not acquire " +"mcbsp2_ick handle.\n" );return PTR_ERR (mcbsp2_ick); } mcbsp2_fck =clk_get (0 ,"mcbsp2_fck" );if (IS_ERR (mcbsp2_fck)) { -printk (KERN_ERR "mcbsp: could not acquire mcbsp2_fck handle.\n" ); +printk (KERN_ERR "mcbsp: could not acquire " +"mcbsp2_fck handle.\n" );return PTR_ERR (mcbsp2_fck); }#endif
@@ -1006,7 +1028,7 @@ static int __init omap_mcbsp_init(void)if (i >= mcbsp_count) { mcbsp[i].io_base =0 ; mcbsp[i].free =0 ; -continue ; +continue ; } mcbsp[i].id = i +1 ; mcbsp[i].free =1 ;
@@ -1014,7 +1036,8 @@ static int __init omap_mcbsp_init(void) mcbsp[i].dma_rx_lch =-1 ; mcbsp[i].io_base = mcbsp_info[i].virt_base; - mcbsp[i].io_type =OMAP_MCBSP_IRQ_IO ;/* Default I/O is IRQ based */ +/* Default I/O is IRQ based */ + mcbsp[i].io_type =OMAP_MCBSP_IRQ_IO ; mcbsp[i].tx_irq = mcbsp_info[i].tx_irq; mcbsp[i].rx_irq = mcbsp_info[i].rx_irq; mcbsp[i].dma_rx_sync = mcbsp_info[i].dma_rx_sync;
@@ -1026,19 +1049,3 @@ static int __init omap_mcbsp_init(void) }arch_initcall (omap_mcbsp_init); - -EXPORT_SYMBOL (omap_mcbsp_config); -EXPORT_SYMBOL (omap_mcbsp_request); -EXPORT_SYMBOL (omap_mcbsp_set_io_type); -EXPORT_SYMBOL (omap_mcbsp_free); -EXPORT_SYMBOL (omap_mcbsp_start); -EXPORT_SYMBOL (omap_mcbsp_stop); -EXPORT_SYMBOL (omap_mcbsp_pollread); -EXPORT_SYMBOL (omap_mcbsp_pollwrite); -EXPORT_SYMBOL (omap_mcbsp_xmit_word); -EXPORT_SYMBOL (omap_mcbsp_recv_word); -EXPORT_SYMBOL (omap_mcbsp_xmit_buffer); -EXPORT_SYMBOL (omap_mcbsp_recv_buffer); -EXPORT_SYMBOL (omap_mcbsp_spi_master_xmit_word_poll); -EXPORT_SYMBOL (omap_mcbsp_spi_master_recv_word_poll); -EXPORT_SYMBOL (omap_mcbsp_set_spi_mode);
Re: [PATCH 08/21] ARM: OMAP: SRAM: Move omap2 sram-fn.S to sram242x.S
In reply to Tony LindgrenQuoted 4 lines · Tony Lindgren
This file will get split between
sram242x.Sandsram243x.Sin following patch.Signed-off-by Tony Lindgren <[email protected]>
Please use '-M' so git diff detects renames.
Tony Lindgren
maintainerRe: [PATCH 08/21] ARM: OMAP: SRAM: Move omap2 sram-fn.S to sram242x.S
Quoted 7 lines · Russell King - ARM Linux
Quoted 4 lines · Tony Lindgren
This file will get split between
sram242x.Sandsram243x.Sin following patch.Signed-off-by Tony Lindgren <[email protected]>Please use '-M' so git diff detects renames.
Here's the updated patch with diff -M.
Tony
Quoted 1 line
From
6a1b926ac526ffd806057a57b9df8c85d6f5657bMon Sep 17 00:00:00 2001
From: Tony Lindgren <[email protected]>
Date: Tue, 17 Jun 2008 10:29:12 +0300
Subject: [PATCH] ARM: OMAP: SRAM: Move omap2 sram-fn.S to sram242x.S
This file will get split between sram242x.S and sram243x.S in following patch.
arch/arm/mach-omap2/Makefile +1 -1
@@ -3,7 +3,7 @@ # # Common support -obj-y := irq.o id.o io.o sram-fn.o memory.o control.o prcm.o clock.o mux.o \ +obj-y := irq.o id.o io.o sram242x.o memory.o control.o prcm.o clock.o mux.o \ devices.o serial.o gpmc.o timer-gp.o # Power Management
arch/arm/mach-omap2/sram242x.S renamed from arch/arm/mach-omap2/sram-fn.S +0 -0
Re: [PATCH 08/21] ARM: OMAP: SRAM: Move omap2 sram-fn.S to sram242x.S
Quoted 10 lines · Tony Lindgren
Quoted 7 lines · Russell King - ARM Linux
Quoted 4 lines · Tony Lindgren
This file will get split between
sram242x.Sandsram243x.Sin following patch.Signed-off-by Tony Lindgren <[email protected]>Please use '-M' so git diff detects renames.
Here's the updated patch with diff -M.
Ok.
Tony Lindgren
maintainerRe: [PATCH 07/21] ARM: OMAP: SRAM: Move sram-fn.S from plat-omap to mach-omap1
In reply to Tony LindgrenQuoted 1 line · Tony Lindgren
This file is omap1 specific.
Here's this patch updated with diff -M to show rename.
Tony
Quoted 1 line
From
e5d5f0c90ad3f80409901459e32c903a0357b1d8Mon Sep 17 00:00:00 2001
From: Tony Lindgren <[email protected]>
Date: Tue, 17 Jun 2008 10:29:10 +0300
Subject: [PATCH] ARM: OMAP: SRAM: Move sram-fn.S from plat-omap to mach-omap1
This file is omap1 specific.
arch/arm/mach-omap1/Makefile +1 -1
@@ -3,7 +3,7 @@ # # Common support -obj-y := io.o id.o clock.o irq.o mux.o serial.o devices.o +obj-y := io.o id.o sram.o clock.o irq.o mux.o serial.o devices.o obj-$(CONFIG_OMAP_MPU_TIMER) += time.o obj-$(CONFIG_OMAP_32K_TIMER) += timer32k.o
arch/arm/mach-omap1/sram.S renamed from arch/arm/plat-omap/sram-fn.S +0 -0
arch/arm/plat-omap/Makefile +1 -1
@@ -3,7 +3,7 @@ # # Common support -obj-y := common.o sram.o sram-fn.o clock.o devices.o dma.o mux.o gpio.o \ +obj-y := common.o sram.o clock.o devices.o dma.o mux.o gpio.o \ usb.o fb.o obj-m := obj-n :=
Re: [PATCH 07/21] ARM: OMAP: SRAM: Move sram-fn.S from plat-omap to mach-omap1
Quoted 4 lines · Tony Lindgren
Quoted 1 line · Tony Lindgren
This file is omap1 specific.
Here's this patch updated with diff -M to show rename.
Ok.
Re: [PATCH 06/21] ARM: OMAP: DMA: Clean-up code
In reply to Tony Lindgreninclude/asm-arm/arch-omap/dma.h struct omap_dma_channel_params { · line 478
Quoted 8 lines · Tony Lindgren
include/asm-arm/arch-omap/dma.h +2
-2@@ -431,8 +474,8 @@ struct omap_dma_channel_params {extern void omap_set_dma_priority (int lch,int dst_port,int priority);extern int omap_request_dma (int dev_id,const char *dev_name, -void (* callback)(int lch,u16 ch_status,void *data), -void *data,int *dma_ch); +void (*callback)(int lch,u16 ch_status, +void *data),void *data,int *dma_ch);
This is an example where checkpatch is not entirely correct - wrapping the 'callback' type makes it less readable. Just let it flow over column 80, or maybe use:
void (*callback)(int, u16, void *),
since all we actually need there is the type of the callback.
Tony Lindgren
maintainerRe: [PATCH 06/21] ARM: OMAP: DMA: Clean-up code
Quoted 14 lines · Russell King - ARM Linux
Review struct omap_dma_channel_params { · line 478
Quoted 8 lines · Tony Lindgren
(quoted diff) +2
-2@@ -431,8 +474,8 @@ struct omap_dma_channel_params { extern void omap_set_dma_priority(int lch, int dst_port, int priority); extern int omap_request_dma(int dev_id, const char *dev_name, - void (* callback)(int lch, u16 ch_status, void *data), - void *data, int *dma_ch); + void (*callback)(int lch, u16 ch_status, + void *data), void *data, int *dma_ch);This is an example where checkpatch is not entirely correct - wrapping the 'callback' type makes it less readable. Just let it flow over column 80, or maybe use:
Quoted 3 lines
void (*callback)(int, u16, void *),since all we actually need there is the type of the callback.
Looks like this wrapping can be avoided by decreasing the indentation instead. Updated patch following.
Tony
Quoted 1 line
From
a3b3b29797764b0a117d52c8105738f87be18f9aMon Sep 17 00:00:00 2001
From: Tony Lindgren <[email protected]>
Date: Tue, 17 Jun 2008 10:24:57 +0300
Subject: [PATCH] ARM: OMAP: DMA: Clean-up code
DMA clean-up, mostly checkpatch.pl fixes.
arch/arm/plat-omap/dma.c +132 -123
@@ -1,7 +1,7 @@/* * linux/arch/arm/plat-omap/dma.c * -* Copyright (C) 2003 Nokia Corporation +* Copyright (C) 2003 - 2008 Nokia Corporation * Author: Juha Yrjölä <[email protected]> * DMA channel linking for 1610 by Samuel Ortiz <[email protected]> * Graphics DMA and LCD DMA graphics tranformations
@@ -25,11 +25,11 @@#include <linux/errno.h> #include <linux/interrupt.h> #include <linux/irq.h> +#include <linux/io.h> #include <asm/system.h> #include <asm/hardware.h> #include <asm/dma.h> -#include <asm/io.h> #include <asm/arch/tc.h>
@@ -43,13 +43,13 @@ enum { DMA_CH_ALLOC_DONE, DMA_CH_PARAMS_SET_DONE, DMA_CH_STARTED,enum {DMA_CHAIN_STARTED ,DMA_CHAIN_NOTSTARTED };#endif -#define OMAP_DMA_ACTIVE 0x01 -#define OMAP_DMA_CCR_EN (1 << 7) +#define OMAP_DMA_ACTIVE 0x01 +#define OMAP_DMA_CCR_EN (1 << 7)#define OMAP2_DMA_CSR_CLEAR_MASK 0xffe -#define OMAP_FUNC_MUX_ARM_BASE (0xfffe1000 + 0xec) +#define OMAP_FUNC_MUX_ARM_BASE (0xfffe1000 + 0xec) -static int enable_1510_mode =0 ; +static int enable_1510_mode;struct omap_dma_lch {int next_lch;
@@ -57,7 +57,7 @@ struct omap_dma_lch {u16 saved_csr;u16 enabled_irqs;const char *dev_name; -void (* callback)(int lch,u16 ch_status,void *data); +void (*callback)(int lch,u16 ch_status,void *data);void *data;#ifndef CONFIG_ARCH_OMAP1
@@ -245,6 +245,7 @@ void omap_set_dma_priority(int lch, int dst_port, int priority)dma_write (ccr,CCR (lch)); } } +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,
@@ -307,6 +308,7 @@ void omap_set_dma_transfer_params(int lch, int data_type, int elem_count,dma_write (elem_count,CEN (lch));dma_write (frame_count,CFN (lch)); } +EXPORT_SYMBOL (omap_set_dma_transfer_params);void omap_set_dma_color_mode (int lch,enum omap_dma_color_mode mode,u32 color) {
@@ -346,6 +348,7 @@ void omap_set_dma_color_mode(int lch, enum omap_dma_color_mode mode, u32 color) }dma_write (w,LCH_CTRL (lch)); } +EXPORT_SYMBOL (omap_set_dma_color_mode);void omap_set_dma_write_mode (int lch,enum omap_dma_write_mode mode) {
@@ -358,6 +361,7 @@ void omap_set_dma_write_mode(int lch, enum omap_dma_write_mode mode)dma_write (csdp,CSDP (lch)); } } +EXPORT_SYMBOL (omap_set_dma_write_mode);void omap_set_dma_channel_mode (int lch,enum omap_dma_channel_mode mode) {
@@ -377,6 +381,8 @@ void omap_set_dma_src_params(int lch, int src_port, int src_amode,unsigned long src_start, int src_ei, int src_fi) { + u32 l; +if (cpu_class_is_omap1 ()) {u16 w;
@@ -384,34 +390,27 @@ void omap_set_dma_src_params(int lch, int src_port, int src_amode, w &= ~(0x1f <<2 ); w |= src_port <<2 ;dma_write (w,CSDP (lch)); + } - w =dma_read (CCR (lch)); - w &= ~(0x03 <<12 ); - w |= src_amode <<12 ; -dma_write (w,CCR (lch)); + l =dma_read (CCR (lch)); + l &= ~(0x03 <<12 ); + l |= src_amode <<12 ; +dma_write (l,CCR (lch)); +if (cpu_class_is_omap1 ()) {dma_write (src_start >>16 ,CSSA_U (lch));dma_write ((u16 )src_start,CSSA_L (lch)); - -dma_write (src_ei,CSEI (lch)); -dma_write (src_fi,CSFI (lch)); } -if (cpu_class_is_omap2 ()) { -u32 l; - - l =dma_read (CCR (lch)); - l &= ~(0x03 <<12 ); - l |= src_amode <<12 ; -dma_write (l,CCR (lch)); - +if (cpu_class_is_omap2 ())dma_write (src_start,CSSA (lch)); -dma_write (src_ei,CSEI (lch)); -dma_write (src_fi,CSFI (lch)); - } + +dma_write (src_ei,CSEI (lch)); +dma_write (src_fi,CSFI (lch)); } +EXPORT_SYMBOL (omap_set_dma_src_params); -void omap_set_dma_params (int lch,struct omap_dma_channel_params * params) +void omap_set_dma_params (int lch,struct omap_dma_channel_params *params) { omap_set_dma_transfer_params(lch, params->data_type, params->elem_count, params->frame_count,
@@ -428,16 +427,17 @@ void omap_set_dma_params(int lch, struct omap_dma_channel_params * params)omap_dma_set_prio_lch (lch, params->read_prio, params->write_prio); } +EXPORT_SYMBOL (omap_set_dma_params);void omap_set_dma_src_index (int lch,int eidx,int fidx) { -if (cpu_class_is_omap2 ()) { -REVISIT_24XX (); +if (cpu_class_is_omap2 ())return ; - } +dma_write (eidx,CSEI (lch));dma_write (fidx,CSFI (lch)); } +EXPORT_SYMBOL (omap_set_dma_src_index);void omap_set_dma_src_data_pack (int lch,int enable) {
@@ -449,6 +449,7 @@ void omap_set_dma_src_data_pack(int lch, int enable) l |= (1 <<6 );dma_write (l,CSDP (lch)); } +EXPORT_SYMBOL (omap_set_dma_src_data_pack);void omap_set_dma_src_burst_mode (int lch,enum omap_dma_burst_mode burst_mode) {
@@ -491,6 +492,7 @@ void omap_set_dma_src_burst_mode(int lch, enum omap_dma_burst_mode burst_mode) l |= (burst <<7 );dma_write (l,CSDP (lch)); } +EXPORT_SYMBOL (omap_set_dma_src_burst_mode);/* Note that dest_port is only for OMAP1 */ void omap_set_dma_dest_params(int lch, int dest_port, int dest_amode,
@@ -522,16 +524,17 @@ void omap_set_dma_dest_params(int lch, int dest_port, int dest_amode,dma_write (dst_ei,CDEI (lch));dma_write (dst_fi,CDFI (lch)); } +EXPORT_SYMBOL (omap_set_dma_dest_params);void omap_set_dma_dest_index (int lch,int eidx,int fidx) { -if (cpu_class_is_omap2 ()) { -REVISIT_24XX (); +if (cpu_class_is_omap2 ())return ; - } +dma_write (eidx,CDEI (lch));dma_write (fidx,CDFI (lch)); } +EXPORT_SYMBOL (omap_set_dma_dest_index);void omap_set_dma_dest_data_pack (int lch,int enable) {
@@ -543,6 +546,7 @@ void omap_set_dma_dest_data_pack(int lch, int enable) l |=1 <<13 ;dma_write (l,CSDP (lch)); } +EXPORT_SYMBOL (omap_set_dma_dest_data_pack);void omap_set_dma_dest_burst_mode (int lch,enum omap_dma_burst_mode burst_mode) {
@@ -583,6 +587,7 @@ void omap_set_dma_dest_burst_mode(int lch, enum omap_dma_burst_mode burst_mode) l |= (burst <<14 );dma_write (l,CSDP (lch)); } +EXPORT_SYMBOL (omap_set_dma_dest_burst_mode);static inline void omap_enable_channel_irq (int lch) {
@@ -608,11 +613,13 @@ void omap_enable_dma_irq(int lch, u16 bits) { dma_chan[lch].enabled_irqs |= bits; } +EXPORT_SYMBOL (omap_enable_dma_irq);void omap_disable_dma_irq (int lch,u16 bits) { dma_chan[lch].enabled_irqs &= ~bits; } +EXPORT_SYMBOL (omap_disable_dma_irq);static inline void enable_lnk (int lch) {
@@ -628,8 +635,9 @@ static inline void enable_lnk(int lch) l = dma_chan[lch].next_lch | (1 <<15 );#ifndef CONFIG_ARCH_OMAP1 -if (dma_chan[lch].next_linked_ch !=-1 ) - l = dma_chan[lch].next_linked_ch | (1 <<15 ); +if (cpu_class_is_omap2 ()) +if (dma_chan[lch].next_linked_ch !=-1 ) + l = dma_chan[lch].next_linked_ch | (1 <<15 );#endif dma_write (l,CLNK_CTRL (lch));
@@ -671,7 +679,7 @@ static inline void omap2_enable_irq_lch(int lch) }int omap_request_dma (int dev_id,const char *dev_name, -void (* callback)(int lch,u16 ch_status,void *data), +void (*callback)(int lch,u16 ch_status,void *data),void *data,int *dma_ch_out) {int ch, free_ch =-1 ;
@@ -704,10 +712,14 @@ int omap_request_dma(int dev_id, const char *dev_name, chan->dev_name = dev_name; chan->callback = callback; chan->data = data; +#ifndef CONFIG_ARCH_OMAP1 - chan->chain_id =-1 ; - chan->next_linked_ch =-1 ; +if (cpu_class_is_omap2 ()) { + chan->chain_id =-1 ; + chan->next_linked_ch =-1 ; + }#endif + chan->enabled_irqs =OMAP_DMA_DROP_IRQ |OMAP_DMA_BLOCK_IRQ ;if (cpu_class_is_omap1 ())
@@ -722,8 +734,10 @@ int omap_request_dma(int dev_id, const char *dev_name,set_gdma_dev (free_ch +1 , dev_id); dev_id = free_ch +1 ; } -/* Disable the 1510 compatibility mode and set the sync device -* id. */ +/* +* Disable the 1510 compatibility mode and set the sync device +* id. +*/ dma_write (dev_id | (1 <<10 ),CCR (free_ch)); }else if (cpu_is_omap730 () ||cpu_is_omap15xx ()) {dma_write (dev_id,CCR (free_ch));
@@ -731,7 +745,6 @@ int omap_request_dma(int dev_id, const char *dev_name,if (cpu_class_is_omap2 ()) {omap2_enable_irq_lch (free_ch); -omap_enable_channel_irq (free_ch);/* Clear the CSR register and IRQ status register */ dma_write (OMAP2_DMA_CSR_CLEAR_MASK ,CSR (free_ch));
@@ -742,6 +755,7 @@ int omap_request_dma(int dev_id, const char *dev_name,return 0 ; } +EXPORT_SYMBOL (omap_request_dma);void omap_free_dma (int lch) {
@@ -749,11 +763,12 @@ void omap_free_dma(int lch)spin_lock_irqsave (&dma_chan_lock, flags);if (dma_chan[lch].dev_id ==-1 ) { -printk ("omap_dma: trying to free nonallocated DMA channel %d\n" , +pr_err ("omap_dma: trying to free unallocated DMA channel %d\n" , lch);spin_unlock_irqrestore (&dma_chan_lock, flags);return ; } + dma_chan[lch].dev_id =-1 ; dma_chan[lch].next_lch =-1 ; dma_chan[lch].callback =NULL ;
@@ -785,6 +800,7 @@ void omap_free_dma(int lch)omap_clear_dma (lch); } } +EXPORT_SYMBOL (omap_free_dma);/** * @brief omap_dma_set_global_params : Set global priority settings for dma
@@ -878,6 +894,7 @@ void omap_clear_dma(int lch)local_irq_restore (flags); } +EXPORT_SYMBOL (omap_clear_dma);void omap_start_dma (int lch) {
@@ -916,8 +933,10 @@ void omap_start_dma(int lch) l =dma_read (CCR (lch)); -/* Errata: On ES2.0 BUFFERING disable must be set. -* This will always fail on ES1.0 */ +/* +* Errata: On ES2.0 BUFFERING disable must be set. +* This will always fail on ES1.0 +*/ if (cpu_is_omap24xx ()) l |=OMAP_DMA_CCR_EN ;
@@ -926,6 +945,7 @@ void omap_start_dma(int lch) dma_chan[lch].flags |=OMAP_DMA_ACTIVE ; } +EXPORT_SYMBOL (omap_start_dma);void omap_stop_dma (int lch) {
@@ -962,13 +982,14 @@ void omap_stop_dma(int lch) dma_chan[lch].flags &= ~OMAP_DMA_ACTIVE ; } +EXPORT_SYMBOL (omap_stop_dma);/* * Allows changing the DMA callback function or data. This may be needed if * the driver shares a single DMA channel for multiple dma triggers. */ int omap_set_dma_callback (int lch, -void (* callback)(int lch,u16 ch_status,void *data), +void (*callback)(int lch,u16 ch_status,void *data),void *data) {unsigned long flags;
@@ -988,6 +1009,7 @@ int omap_set_dma_callback(int lch,return 0 ; } +EXPORT_SYMBOL (omap_set_dma_callback);/* * Returns current physical source address for the given DMA channel.
@@ -1018,6 +1040,7 @@ dma_addr_t omap_get_dma_src_pos(int lch)return offset; } +EXPORT_SYMBOL (omap_get_dma_src_pos);/* * Returns current physical destination address for the given DMA channel.
@@ -1048,16 +1071,7 @@ dma_addr_t omap_get_dma_dst_pos(int lch)return offset; } - -/* -* Returns current source transfer counting for the given DMA channel. -* Can be used to monitor the progress of a transfer inside a block. -* It must be called with disabled interrupts. -*/ -int omap_get_dma_src_addr_counter (int lch) -{ -return (dma_addr_t )dma_read (CSAC (lch)); -} +EXPORT_SYMBOL (omap_get_dma_dst_pos);int omap_get_dma_active_status (int lch) {
@@ -1086,7 +1100,7 @@ int omap_dma_running(void)* For this DMA link to start, you still need to start (see omap_start_dma) * the first one. That will fire up the entire queue. */ -void omap_dma_link_lch (int lch_head,int lch_queue) +void omap_dma_link_lch (int lch_head,int lch_queue) {if (omap_dma_in_1510_mode ()) {printk (KERN_ERR "DMA linking is not supported in 1510 mode\n" );
@@ -1103,11 +1117,12 @@ void omap_dma_link_lch (int lch_head, int lch_queue) dma_chan[lch_head].next_lch = lch_queue; } +EXPORT_SYMBOL (omap_dma_link_lch);/* * Once the DMA queue is stopped, we can destroy it. */ -void omap_dma_unlink_lch (int lch_head,int lch_queue) +void omap_dma_unlink_lch (int lch_head,int lch_queue) {if (omap_dma_in_1510_mode ()) {printk (KERN_ERR "DMA linking is not supported in 1510 mode\n" );
@@ -1122,7 +1137,6 @@ void omap_dma_unlink_lch (int lch_head, int lch_queue)dump_stack (); } -if ((dma_chan[lch_head].flags &OMAP_DMA_ACTIVE ) || (dma_chan[lch_head].flags &OMAP_DMA_ACTIVE )) { printk(KERN_ERR "omap_dma: You need to stop the DMA channels "
@@ -1132,6 +1146,9 @@ void omap_dma_unlink_lch (int lch_head, int lch_queue) dma_chan[lch_head].next_lch =-1 ; } +EXPORT_SYMBOL (omap_dma_unlink_lch); + +/*----------------------------------------------------------------------------*/ #ifndef CONFIG_ARCH_OMAP1 /* Create chain of DMA channesls */
@@ -1255,6 +1272,7 @@ int omap_request_dma_chain(int dev_id, const char *dev_name,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);
@@ -1297,6 +1315,7 @@ int omap_modify_dma_chain_params(int chain_id,*/ omap_set_dma_params (channels[i], ¶ms); } +return 0 ; }EXPORT_SYMBOL (omap_modify_dma_chain_params);
@@ -1340,6 +1359,7 @@ int omap_free_dma_chain(int chain_id) 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);
@@ -1370,6 +1390,7 @@ int omap_dma_chain_status(int chain_id)if (OMAP_DMA_CHAIN_QEMPTY (chain_id))return OMAP_DMA_CHAIN_INACTIVE ; +return OMAP_DMA_CHAIN_ACTIVE ; }EXPORT_SYMBOL (omap_dma_chain_status);
@@ -1395,8 +1416,10 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start,u32 l, lch;int start_dma =0 ; -/* if buffer size is less than 1 then there is -* no use of starting the chain */ +/* +* 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 ;
@@ -1441,12 +1464,16 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start,dma_write (elem_count,CEN (lch));dma_write (frame_count,CFN (lch)); -/* If the chain is dynamically linked, -* then we may have to start the chain if its not active */ +/* +* 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 */ +/* +* 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 */
@@ -1456,8 +1483,10 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start, dma_chan[lch].state =DMA_CH_QUEUED ; } -/* Chain is already started, make sure its active, -* if not then start the chain */ +/* +* Chain is already started, make sure its active, +* if not then start the chain +*/ else { start_dma =1 ;
@@ -1504,6 +1533,7 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start, dma_chan[lch].flags |=OMAP_DMA_ACTIVE ; } } +return 0 ; }EXPORT_SYMBOL (omap_dma_chain_a_transfer);
@@ -1555,6 +1585,7 @@ int omap_start_dma_chain_transfers(int chain_id)dma_write (l,CCR (channels[0 ])); dma_chan[channels[0 ]].flags |=OMAP_DMA_ACTIVE ; +return 0 ; }EXPORT_SYMBOL (omap_start_dma_chain_transfers);
@@ -1586,7 +1617,8 @@ int omap_stop_dma_chain_transfers(int chain_id) } channels = dma_linked_lch[chain_id].linked_dmach_q; -/* DMA Errata: +/* +* DMA Errata: * Special programming model needed to disable DMA before end of block */ sys_cf =dma_read (OCP_SYSCONFIG );
@@ -1614,6 +1646,7 @@ int omap_stop_dma_chain_transfers(int chain_id)/* Errata - put in the old value */ dma_write (sys_cf,OCP_SYSCONFIG ); +return 0 ; }EXPORT_SYMBOL (omap_stop_dma_chain_transfers);
@@ -1729,7 +1762,7 @@ int omap_get_dma_chain_src_pos(int chain_id) return dma_read(CSAC(lch)); }EXPORT_SYMBOL (omap_get_dma_chain_src_pos); -#endif +#endif /* ifndef CONFIG_ARCH_OMAP1 */ /*----------------------------------------------------------------------------*/
@@ -1765,6 +1798,7 @@ static int omap1_dma_handle_ch(int ch) dma_chan[ch].flags &= ~OMAP_DMA_ACTIVE ;if (likely (dma_chan[ch].callback !=NULL )) dma_chan[ch].callback (ch, csr, dma_chan[ch].data); +return 1 ; }
@@ -1799,7 +1833,8 @@ static int omap2_dma_handle_ch(int ch)if (!status) {if (printk_ratelimit ()) -printk (KERN_WARNING "Spurious DMA IRQ for lch %d\n" , ch); +printk (KERN_WARNING "Spurious DMA IRQ for lch %d\n" , + ch);dma_write (1 << ch,IRQSTATUS_L0 );return 0 ; }
@@ -1887,7 +1922,7 @@ static struct irqaction omap24xx_dma_irq; static struct lcd_dma_info { spinlock_t lock; int reserved; - void (* callback)(u16 status, void *data); + void (*callback)(u16 status, void *data); void *cb_data; int active;
@@ -1909,6 +1944,7 @@ void omap_set_lcd_dma_b1(unsigned long addr, u16 fb_xres, u16 fb_yres, lcd_dma.xres = fb_xres; lcd_dma.yres = fb_yres; } +EXPORT_SYMBOL (omap_set_lcd_dma_b1);void omap_set_lcd_dma_src_port (int port) {
@@ -1919,12 +1955,13 @@ void omap_set_lcd_dma_ext_controller(int external) { lcd_dma.ext_ctrl = external; } +EXPORT_SYMBOL (omap_set_lcd_dma_ext_controller);void omap_set_lcd_dma_single_transfer (int single) { lcd_dma.single_transfer = single; } - +EXPORT_SYMBOL (omap_set_lcd_dma_single_transfer);void omap_set_lcd_dma_b1_rotation (int rotate) {
@@ -1935,6 +1972,7 @@ void omap_set_lcd_dma_b1_rotation(int rotate) } lcd_dma.rotate = rotate; } +EXPORT_SYMBOL (omap_set_lcd_dma_b1_rotation);void omap_set_lcd_dma_b1_mirror (int mirror) {
@@ -1944,6 +1982,7 @@ void omap_set_lcd_dma_b1_mirror(int mirror) } lcd_dma.mirror = mirror; } +EXPORT_SYMBOL (omap_set_lcd_dma_b1_mirror);void omap_set_lcd_dma_b1_vxres (unsigned long vxres) {
@@ -1954,6 +1993,7 @@ void omap_set_lcd_dma_b1_vxres(unsigned long vxres) } lcd_dma.vxres = vxres; } +EXPORT_SYMBOL (omap_set_lcd_dma_b1_vxres);void omap_set_lcd_dma_b1_scale (unsigned int xscale,unsigned int yscale) {
@@ -1964,6 +2004,7 @@ void omap_set_lcd_dma_b1_scale(unsigned int xscale, unsigned int yscale) lcd_dma.xscale = xscale; lcd_dma.yscale = yscale; } +EXPORT_SYMBOL (omap_set_lcd_dma_b1_scale);static void set_b1_regs (void ) {
@@ -1994,8 +2035,11 @@ static void set_b1_regs(void) xscale = lcd_dma.xscale ? lcd_dma.xscale :1 ; yscale = lcd_dma.yscale ? lcd_dma.yscale :1 ;BUG_ON (vxres < lcd_dma.xres); -#define PIXADDR (x,y) (lcd_dma.addr + ((y) * vxres * yscale + (x) * xscale) * es) + +#define PIXADDR (x, y) (lcd_dma.addr + \ + ((y) * vxres * yscale + (x) * xscale) * es)#define PIXSTEP (sx, sy, dx, dy) (PIXADDR(dx, dy) - PIXADDR(sx, sy) - es + 1) +switch (lcd_dma.rotate) {case 0 :if (!lcd_dma.mirror) {
@@ -2004,8 +2048,8 @@ static void set_b1_regs(void)/* 1510 DMA requires the bottom address to be 2 more * than the actual last memory access location. */ if (omap_dma_in_1510_mode () && - lcd_dma.data_type ==OMAP_DMA_DATA_TYPE_S32 ) - bottom +=2 ; + lcd_dma.data_type ==OMAP_DMA_DATA_TYPE_S32 ) + bottom +=2 ; ei =PIXSTEP (0 ,0 ,1 ,0 ); fi =PIXSTEP (lcd_dma.xres -1 ,0 ,0 ,1 ); }else {
@@ -2132,7 +2176,7 @@ static irqreturn_t lcd_dma_irq_handler(int irq, void *dev_id)return IRQ_HANDLED ; } -int omap_request_lcd_dma (void (* callback)(u16 status,void *data), +int omap_request_lcd_dma (void (*callback)(u16 status,void *data),void *data) {spin_lock_irq (&lcd_dma.lock);
@@ -2158,6 +2202,7 @@ int omap_request_lcd_dma(void (* callback)(u16 status, void *data),return 0 ; } +EXPORT_SYMBOL (omap_request_lcd_dma);void omap_free_lcd_dma (void ) {
@@ -2174,12 +2219,14 @@ void omap_free_lcd_dma(void) lcd_dma.reserved =0 ;spin_unlock (&lcd_dma.lock); } +EXPORT_SYMBOL (omap_free_lcd_dma);void omap_enable_lcd_dma (void ) {u16 w; -/* Set the Enable bit only if an external controller is +/* +* Set the Enable bit only if an external controller is * connected. Otherwise the OMAP internal controller will * start the transfer when it gets enabled. */
@@ -2196,6 +2243,7 @@ void omap_enable_lcd_dma(void) w |=1 <<7 ;omap_writew (w,OMAP1610_DMA_LCD_CCR ); } +EXPORT_SYMBOL (omap_enable_lcd_dma);void omap_setup_lcd_dma (void ) {
@@ -2211,16 +2259,18 @@ void omap_setup_lcd_dma(void)u16 w; w =omap_readw (OMAP1610_DMA_LCD_CCR ); -/* If DMA was already active set the end_prog bit to have +/* +* If DMA was already active set the end_prog bit to have * the programmed register set loaded into the active * register set. */ w |=1 <<11 ;/* End_prog */ if (!lcd_dma.single_transfer) - w |= (3 <<8 );/* Auto_init, repeat */ + w |= (3 <<8 );/* Auto_init, repeat */ omap_writew (w,OMAP1610_DMA_LCD_CCR ); } } +EXPORT_SYMBOL (omap_setup_lcd_dma);void omap_stop_lcd_dma (void ) {
@@ -2238,6 +2288,7 @@ void omap_stop_lcd_dma(void) w &= ~(1 <<8 );omap_writew (w,OMAP1610_DMA_LCD_CTRL ); } +EXPORT_SYMBOL (omap_stop_lcd_dma);/*----------------------------------------------------------------------------*/
@@ -2327,8 +2378,10 @@ static int __init omap_init_dma(void)continue ;if (cpu_class_is_omap1 ()) { -/* request_irq() doesn't like dev_id (ie. ch) being -* zero, so we have to kludge around this. */ +/* +* request_irq() doesn't like dev_id (ie. ch) being +* zero, so we have to kludge around this. +*/ r =request_irq (omap1_dma_irq[ch], omap1_dma_irq_handler,0 ,"DMA" , (void *) (ch +1 ));
@@ -2373,48 +2426,4 @@ static int __init omap_init_dma(void)arch_initcall (omap_init_dma); -EXPORT_SYMBOL (omap_get_dma_src_pos); -EXPORT_SYMBOL (omap_get_dma_dst_pos); -EXPORT_SYMBOL (omap_get_dma_src_addr_counter); -EXPORT_SYMBOL (omap_clear_dma); -EXPORT_SYMBOL (omap_set_dma_priority); -EXPORT_SYMBOL (omap_request_dma); -EXPORT_SYMBOL (omap_free_dma); -EXPORT_SYMBOL (omap_start_dma); -EXPORT_SYMBOL (omap_stop_dma); -EXPORT_SYMBOL (omap_set_dma_callback); -EXPORT_SYMBOL (omap_enable_dma_irq); -EXPORT_SYMBOL (omap_disable_dma_irq); - -EXPORT_SYMBOL (omap_set_dma_transfer_params); -EXPORT_SYMBOL (omap_set_dma_color_mode); -EXPORT_SYMBOL (omap_set_dma_write_mode); - -EXPORT_SYMBOL (omap_set_dma_src_params); -EXPORT_SYMBOL (omap_set_dma_src_index); -EXPORT_SYMBOL (omap_set_dma_src_data_pack); -EXPORT_SYMBOL (omap_set_dma_src_burst_mode); - -EXPORT_SYMBOL (omap_set_dma_dest_params); -EXPORT_SYMBOL (omap_set_dma_dest_index); -EXPORT_SYMBOL (omap_set_dma_dest_data_pack); -EXPORT_SYMBOL (omap_set_dma_dest_burst_mode); - -EXPORT_SYMBOL (omap_set_dma_params); - -EXPORT_SYMBOL (omap_dma_link_lch); -EXPORT_SYMBOL (omap_dma_unlink_lch); - -EXPORT_SYMBOL (omap_request_lcd_dma); -EXPORT_SYMBOL (omap_free_lcd_dma); -EXPORT_SYMBOL (omap_enable_lcd_dma); -EXPORT_SYMBOL (omap_setup_lcd_dma); -EXPORT_SYMBOL (omap_stop_lcd_dma); -EXPORT_SYMBOL (omap_set_lcd_dma_b1); -EXPORT_SYMBOL (omap_set_lcd_dma_single_transfer); -EXPORT_SYMBOL (omap_set_lcd_dma_ext_controller); -EXPORT_SYMBOL (omap_set_lcd_dma_b1_rotation); -EXPORT_SYMBOL (omap_set_lcd_dma_b1_vxres); -EXPORT_SYMBOL (omap_set_lcd_dma_b1_scale); -EXPORT_SYMBOL (omap_set_lcd_dma_b1_mirror);
include/asm-arm/arch-omap/dma.h +103 -58
228 lines not on this page · raw message
Re: [PATCH 06/21] ARM: OMAP: DMA: Clean-up code
Quoted 15 lines · Tony Lindgren
Quoted 14 lines · Russell King - ARM Linux
include/asm-arm/arch-omap/dma.h struct omap_dma_channel_params { · line 478
Quoted 8 lines · Tony Lindgren
include/asm-arm/arch-omap/dma.h +2
-2@@ -431,8 +474,8 @@ struct omap_dma_channel_params {extern void omap_set_dma_priority (int lch,int dst_port,int priority);extern int omap_request_dma (int dev_id,const char *dev_name, -void (* callback)(int lch,u16 ch_status,void *data), -void *data,int *dma_ch); +void (*callback)(int lch,u16 ch_status, +void *data),void *data,int *dma_ch);This is an example where checkpatch is not entirely correct - wrapping the 'callback' type makes it less readable. Just let it flow over column 80, or maybe use:
Quoted 6 lines
Quoted 3 lines
void (*callback)(int, u16, void *),since all we actually need there is the type of the callback.
Looks like this wrapping can be avoided by decreasing the indentation instead. Updated patch following.
Ok.
Re: [PATCH 05/21] ARM: OMAP: DMA: Remove __REG access
In reply to Tony LindgrenQuoted 16 lines · Tony Lindgren
Remove
__REGaccess in DMA code, use dma_read/write instead:- dynamically set the
omap_dma_basebased on the omap type- omap_read/write becomes dma_read/write
- dma channel registers are read with dma_ch_read/writeCc David Brownell <[email protected]>Signed-off-by Tony Lindgren <[email protected]>arch/arm/plat-omap/dma.c +0
-0
arch/arm/plat-omap/dma.c static int dma_chan_count; · line 129
Quoted 4 lines
arch/arm/plat-omap/dma.c +1
-0@@ -126,6 +126,7 @@ static int dma_chan_count;static spinlock_t dma_chan_lock;static struct omap_dma_lch *dma_chan; +void __iomem *omap_dma_base;
Shouldn't this be static?
Tony Lindgren
maintainerRe: [PATCH 05/21] ARM: OMAP: DMA: Remove __REG access
Quoted 18 lines · Russell King - ARM Linux
Quoted 17 lines · Tony Lindgren
Remove
__REGaccess in DMA code, use dma_read/write instead:- dynamically set the
omap_dma_basebased on the omap type- omap_read/write becomes dma_read/write
- dma channel registers are read with dma_ch_read/writeCc David Brownell <[email protected]>Signed-off-by Tony Lindgren <[email protected]>arch/arm/plat-omap/dma.c +0
-0@@ -126,6 +126,7 @@ static int dma_chan_count;
Quoted 5 lines
arch/arm/plat-omap/dma.c static int dma_chan_count; · line 129
Quoted 3 lines
arch/arm/plat-omap/dma.c +1
-0static spinlock_t dma_chan_lock;static struct omap_dma_lch *dma_chan; +void __iomem *omap_dma_base;Shouldn't this be static?
Good catch, yes it can be static. Updated patch following.
Tony
Quoted 1 line
From
b4f08a601bfe343db59e7a2b59a4a40d367555ddMon Sep 17 00:00:00 2001
From: Tony Lindgren <[email protected]>
Date: Tue, 17 Jun 2008 10:22:30 +0300
Subject: [PATCH] ARM: OMAP: DMA: Remove __REG access
Remove __REG access in DMA code, use dma_read/write instead:
- dynamically set the omap_dma_base based on the omap type
- omap_read/write becomes dma_read/write
- dma channel registers are read with dma_ch_read/write
arch/arm/plat-omap/dma.c +324 -179
@@ -126,6 +126,7 @@ static int dma_chan_count;static spinlock_t dma_chan_lock;static struct omap_dma_lch *dma_chan; +static void __iomem *omap_dma_base;static const u8 omap1_dma_irq[OMAP1_LOGICAL_DMA_CH_COUNT ] = {INT_DMA_CH0_6 ,INT_DMA_CH1_7 ,INT_DMA_CH2_8 ,INT_DMA_CH3 ,
@@ -142,6 +143,24 @@ static inline void omap_enable_channel_irq(int lch);#define REVISIT_24XX () printk(KERN_ERR "FIXME: no %s on 24xx\n", \ __func__); +#define dma_read (reg) \ +({ \ + u32 __val; \ + if (cpu_class_is_omap1()) \ + __val = __raw_readw(omap_dma_base + OMAP1_DMA_##reg); \ + else \ + __val = __raw_readl(omap_dma_base + OMAP_DMA4_##reg); \ + __val; \ +}) + +#define dma_write (val, reg) \ +({ \ + if (cpu_class_is_omap1()) \ + __raw_writew((u16)(val), omap_dma_base + OMAP1_DMA_##reg); \ + else \ + __raw_writel((val), omap_dma_base + OMAP_DMA4_##reg); \ +}) +#ifdef CONFIG_ARCH_OMAP15XX /* Returns 1 if the DMA module is in OMAP1510-compatible mode, 0 otherwise */ int omap_dma_in_1510_mode (void )
@@ -176,13 +195,14 @@ static inline void set_gdma_dev(int req, int dev)#define set_gdma_dev (req, dev) do {} while (0)#endif +/* Omap1 only */ static void clear_lch_regs (int lch) {int i; -u32 lch_base =OMAP_DMA_BASE + lch *0x40 ; +void __iomem *lch_base = omap_dma_base +OMAP1_DMA_CH_BASE (lch);for (i =0 ; i <0x2c ; i +=2 ) -omap_writew (0 , lch_base + i); +__raw_writew (0 , lch_base + i); }void omap_set_dma_priority (int lch,int dst_port,int priority)
@@ -215,10 +235,14 @@ void omap_set_dma_priority(int lch, int dst_port, int priority) }if (cpu_class_is_omap2 ()) { +u32 ccr; + + ccr =dma_read (CCR (lch));if (priority) -OMAP_DMA_CCR_REG (lch) |= (1 <<6 ); + ccr |= (1 <<6 );else -OMAP_DMA_CCR_REG (lch) &= ~(1 <<6 ); + ccr &= ~(1 <<6 ); +dma_write (ccr,CCR (lch)); } }
@@ -226,22 +250,33 @@ 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) { - OMAP_DMA_CSDP_REG(lch) &= ~0x03; -OMAP_DMA_CSDP_REG (lch) |= data_type; + u32 l; + + l =dma_read (CSDP (lch)); + l &= ~0x03 ; + l |= data_type; +dma_write (l,CSDP (lch));if (cpu_class_is_omap1 ()) { -OMAP_DMA_CCR_REG (lch) &= ~(1 <<5 ); +u16 ccr; + + ccr =dma_read (CCR (lch)); + ccr &= ~(1 <<5 );if (sync_mode ==OMAP_DMA_SYNC_FRAME ) -OMAP_DMA_CCR_REG (lch) |=1 <<5 ; + ccr |=1 <<5 ; +dma_write (ccr,CCR (lch)); -OMAP1_DMA_CCR2_REG (lch) &= ~(1 <<2 ); + ccr =dma_read (CCR2 (lch)); + ccr &= ~(1 <<2 );if (sync_mode ==OMAP_DMA_SYNC_BLOCK ) -OMAP1_DMA_CCR2_REG (lch) |=1 <<2 ; + ccr |=1 <<2 ; +dma_write (ccr,CCR2 (lch)); }if (cpu_class_is_omap2 () && dma_trigger) { -u32 val =OMAP_DMA_CCR_REG (lch); +u32 val; + val =dma_read (CCR (lch)); val &= ~(3 <<19 );if (dma_trigger >63 ) val |=1 <<20 ;
@@ -266,11 +301,11 @@ void omap_set_dma_transfer_params(int lch, int data_type, int elem_count,else val &= ~(1 <<24 );/* dest synch */ -OMAP_DMA_CCR_REG (lch) = val; +dma_write (val,CCR (lch)); } -OMAP_DMA_CEN_REG (lch) = elem_count; -OMAP_DMA_CFN_REG (lch) = frame_count; +dma_write (elem_count,CEN (lch)); +dma_write (frame_count,CFN (lch)); }void omap_set_dma_color_mode (int lch,enum omap_dma_color_mode mode,u32 color)
@@ -284,7 +319,9 @@ void omap_set_dma_color_mode(int lch, enum omap_dma_color_mode mode, u32 color)return ; } - w =OMAP1_DMA_CCR2_REG (lch) & ~0x03 ; + w =dma_read (CCR2 (lch)); + w &= ~0x03 ; +switch (mode) {case OMAP_DMA_CONSTANT_FILL : w |=0x01 ;
@@ -297,49 +334,81 @@ void omap_set_dma_color_mode(int lch, enum omap_dma_color_mode mode, u32 color)default :BUG (); } -OMAP1_DMA_CCR2_REG (lch) = w; +dma_write (w,CCR2 (lch)); - w =OMAP1_DMA_LCH_CTRL_REG (lch) & ~0x0f ; + w =dma_read (LCH_CTRL (lch)); + w &= ~0x0f ;/* Default is channel type 2D */ if (mode) { -OMAP1_DMA_COLOR_L_REG (lch) = (u16 )color; -OMAP1_DMA_COLOR_U_REG (lch) = (u16)(color >>16 ); +dma_write ((u16 )color,COLOR_L (lch)); +dma_write ((u16)(color >>16 ),COLOR_U (lch)); w |=1 ;/* Channel type G */ } -OMAP1_DMA_LCH_CTRL_REG (lch) = w; +dma_write (w,LCH_CTRL (lch)); }void omap_set_dma_write_mode (int lch,enum omap_dma_write_mode mode) {if (cpu_class_is_omap2 ()) { -OMAP_DMA_CSDP_REG (lch) &= ~(0x3 <<16 ); -OMAP_DMA_CSDP_REG (lch) |= (mode <<16 ); +u32 csdp; + + csdp =dma_read (CSDP (lch)); + csdp &= ~(0x3 <<16 ); + csdp |= (mode <<16 ); +dma_write (csdp,CSDP (lch)); } } +void omap_set_dma_channel_mode (int lch,enum omap_dma_channel_mode mode) +{ +if (cpu_class_is_omap1 () && !cpu_is_omap15xx ()) { +u32 l; + + l =dma_read (LCH_CTRL (lch)); + l &= ~0x7 ; + l |= mode; +dma_write (l,LCH_CTRL (lch)); + } +} +EXPORT_SYMBOL (omap_set_dma_channel_mode); +/* Note that src_port is only for omap1 */ void omap_set_dma_src_params (int lch,int src_port,int src_amode,unsigned long src_start,int src_ei,int src_fi) {if (cpu_class_is_omap1 ()) { -OMAP_DMA_CSDP_REG (lch) &= ~(0x1f <<2 ); -OMAP_DMA_CSDP_REG (lch) |= src_port <<2 ; - } +u16 w; -OMAP_DMA_CCR_REG (lch) &= ~(0x03 <<12 ); -OMAP_DMA_CCR_REG (lch) |= src_amode <<12 ; + w =dma_read (CSDP (lch)); + w &= ~(0x1f <<2 ); + w |= src_port <<2 ; +dma_write (w,CSDP (lch)); -if (cpu_class_is_omap1 ()) { -OMAP1_DMA_CSSA_U_REG (lch) = src_start >>16 ; -OMAP1_DMA_CSSA_L_REG (lch) = src_start; + w =dma_read (CCR (lch)); + w &= ~(0x03 <<12 ); + w |= src_amode <<12 ; +dma_write (w,CCR (lch)); + +dma_write (src_start >>16 ,CSSA_U (lch)); +dma_write ((u16 )src_start,CSSA_L (lch)); + +dma_write (src_ei,CSEI (lch)); +dma_write (src_fi,CSFI (lch)); } -if (cpu_class_is_omap2 ()) -OMAP2_DMA_CSSA_REG (lch) = src_start; +if (cpu_class_is_omap2 ()) { +u32 l; + + l =dma_read (CCR (lch)); + l &= ~(0x03 <<12 ); + l |= src_amode <<12 ; +dma_write (l,CCR (lch)); -OMAP_DMA_CSEI_REG (lch) = src_ei; -OMAP_DMA_CSFI_REG (lch) = src_fi; +dma_write (src_start,CSSA (lch)); +dma_write (src_ei,CSEI (lch)); +dma_write (src_fi,CSFI (lch)); + } }void omap_set_dma_params (int lch,struct omap_dma_channel_params * params)
@@ -366,21 +435,28 @@ void omap_set_dma_src_index(int lch, int eidx, int fidx)REVISIT_24XX ();return ; } -OMAP_DMA_CSEI_REG (lch) = eidx; -OMAP_DMA_CSFI_REG (lch) = fidx; +dma_write (eidx,CSEI (lch)); +dma_write (fidx,CSFI (lch)); }void omap_set_dma_src_data_pack (int lch,int enable) { -OMAP_DMA_CSDP_REG (lch) &= ~(1 <<6 ); +u32 l; + + l =dma_read (CSDP (lch)); + l &= ~(1 <<6 );if (enable) -OMAP_DMA_CSDP_REG (lch) |= (1 <<6 ); + l |= (1 <<6 ); +dma_write (l,CSDP (lch)); }void omap_set_dma_src_burst_mode (int lch,enum omap_dma_burst_mode burst_mode) {unsigned int burst =0 ; -OMAP_DMA_CSDP_REG (lch) &= ~(0x03 <<7 ); +u32 l; + + l =dma_read (CSDP (lch)); + l &= ~(0x03 <<7 );switch (burst_mode) {case OMAP_DMA_DATA_BURST_DIS :
@@ -411,7 +487,9 @@ void omap_set_dma_src_burst_mode(int lch, enum omap_dma_burst_mode burst_mode)default :BUG (); } -OMAP_DMA_CSDP_REG (lch) |= (burst <<7 ); + + l |= (burst <<7 ); +dma_write (l,CSDP (lch)); }/* Note that dest_port is only for OMAP1 */
@@ -419,24 +497,30 @@ void omap_set_dma_dest_params(int lch, int dest_port, int dest_amode,unsigned long dest_start, int dst_ei, int dst_fi) { + u32 l; +if (cpu_class_is_omap1 ()) { - OMAP_DMA_CSDP_REG(lch) &= ~(0x1f << 9); -OMAP_DMA_CSDP_REG (lch) |= dest_port <<9 ; + l =dma_read (CSDP (lch)); + l &= ~(0x1f <<9 ); + l |= dest_port <<9 ; +dma_write (l,CSDP (lch)); } -OMAP_DMA_CCR_REG (lch) &= ~(0x03 <<14 ); -OMAP_DMA_CCR_REG (lch) |= dest_amode <<14 ; + l =dma_read (CCR (lch)); + l &= ~(0x03 <<14 ); + l |= dest_amode <<14 ; +dma_write (l,CCR (lch));if (cpu_class_is_omap1 ()) { -OMAP1_DMA_CDSA_U_REG (lch) = dest_start >>16 ; -OMAP1_DMA_CDSA_L_REG (lch) = dest_start; +dma_write (dest_start >>16 ,CDSA_U (lch)); +dma_write (dest_start,CDSA_L (lch)); }if (cpu_class_is_omap2 ()) -OMAP2_DMA_CDSA_REG (lch) = dest_start; +dma_write (dest_start,CDSA (lch)); -OMAP_DMA_CDEI_REG (lch) = dst_ei; -OMAP_DMA_CDFI_REG (lch) = dst_fi; +dma_write (dst_ei,CDEI (lch)); +dma_write (dst_fi,CDFI (lch)); }void omap_set_dma_dest_index (int lch,int eidx,int fidx)
@@ -445,21 +529,28 @@ void omap_set_dma_dest_index(int lch, int eidx, int fidx)REVISIT_24XX ();return ; } -OMAP_DMA_CDEI_REG (lch) = eidx; -OMAP_DMA_CDFI_REG (lch) = fidx; +dma_write (eidx,CDEI (lch)); +dma_write (fidx,CDFI (lch)); }void omap_set_dma_dest_data_pack (int lch,int enable) { -OMAP_DMA_CSDP_REG (lch) &= ~(1 <<13 ); +u32 l; + + l =dma_read (CSDP (lch)); + l &= ~(1 <<13 );if (enable) -OMAP_DMA_CSDP_REG (lch) |=1 <<13 ; + l |=1 <<13 ; +dma_write (l,CSDP (lch)); }void omap_set_dma_dest_burst_mode (int lch,enum omap_dma_burst_mode burst_mode) {unsigned int burst =0 ; -OMAP_DMA_CSDP_REG (lch) &= ~(0x03 <<14 ); +u32 l; + + l =dma_read (CSDP (lch)); + l &= ~(0x03 <<14 );switch (burst_mode) {case OMAP_DMA_DATA_BURST_DIS :
@@ -489,7 +580,8 @@ void omap_set_dma_dest_burst_mode(int lch, enum omap_dma_burst_mode burst_mode)BUG ();return ; } -OMAP_DMA_CSDP_REG (lch) |= (burst <<14 ); + l |= (burst <<14 ); +dma_write (l,CSDP (lch)); }static inline void omap_enable_channel_irq (int lch)
@@ -498,18 +590,18 @@ static inline void omap_enable_channel_irq(int lch)/* Clear CSR */ if (cpu_class_is_omap1 ()) - status =OMAP_DMA_CSR_REG (lch); + status =dma_read (CSR (lch));else if (cpu_class_is_omap2 ()) -OMAP_DMA_CSR_REG (lch) =OMAP2_DMA_CSR_CLEAR_MASK ; +dma_write (OMAP2_DMA_CSR_CLEAR_MASK ,CSR (lch));/* Enable some nice interrupts. */ -OMAP_DMA_CICR_REG (lch) = dma_chan[lch].enabled_irqs; +dma_write (dma_chan[lch].enabled_irqs,CICR (lch)); }static void omap_disable_channel_irq (int lch) {if (cpu_class_is_omap2 ()) -OMAP_DMA_CICR_REG (lch) =0 ; +dma_write (0 ,CICR (lch)); }void omap_enable_dma_irq (int lch,u16 bits)
@@ -524,36 +616,45 @@ void omap_disable_dma_irq(int lch, u16 bits)static inline void enable_lnk (int lch) { +u32 l; + + l =dma_read (CLNK_CTRL (lch)); +if (cpu_class_is_omap1 ()) -OMAP_DMA_CLNK_CTRL_REG (lch) &= ~(1 <<14 ); + l &= ~(1 <<14 );/* Set the ENABLE_LNK bits */ if (dma_chan[lch].next_lch !=-1 ) -OMAP_DMA_CLNK_CTRL_REG (lch) = - dma_chan[lch].next_lch | (1 <<15 ); + l = dma_chan[lch].next_lch | (1 <<15 );#ifndef CONFIG_ARCH_OMAP1 if (dma_chan[lch].next_linked_ch !=-1 ) -OMAP_DMA_CLNK_CTRL_REG (lch) = - dma_chan[lch].next_linked_ch | (1 <<15 ); + l = dma_chan[lch].next_linked_ch | (1 <<15 );#endif + +dma_write (l,CLNK_CTRL (lch)); }static inline void disable_lnk (int lch) { +u32 l; + + l =dma_read (CLNK_CTRL (lch)); +/* Disable interrupts */ if (cpu_class_is_omap1 ()) { -OMAP_DMA_CICR_REG (lch) =0 ; +dma_write (0 ,CICR (lch));/* Set the STOP_LNK bit */ -OMAP_DMA_CLNK_CTRL_REG (lch) |=1 <<14 ; + l |=1 <<14 ; }if (cpu_class_is_omap2 ()) {omap_disable_channel_irq (lch);/* Clear the ENABLE_LNK bit */ -OMAP_DMA_CLNK_CTRL_REG (lch) &= ~(1 <<15 ); + l &= ~(1 <<15 ); } +dma_write (l,CLNK_CTRL (lch)); dma_chan[lch].flags &= ~OMAP_DMA_ACTIVE ; }
@@ -564,9 +665,9 @@ static inline void omap2_enable_irq_lch(int lch)if (!cpu_class_is_omap2 ())return ; - val =omap_readl (OMAP_DMA4_IRQENABLE_L0 ); + val =dma_read (IRQENABLE_L0 ); val |=1 << lch; -omap_writel (val,OMAP_DMA4_IRQENABLE_L0 ); +dma_write (val,IRQENABLE_L0 ); } int omap_request_dma(int dev_id, const char *dev_name,
@@ -623,9 +724,9 @@ int omap_request_dma(int dev_id, const char *dev_name, }/* Disable the 1510 compatibility mode and set the sync device * id. */ -OMAP_DMA_CCR_REG (free_ch) = dev_id | (1 <<10 ); +dma_write (dev_id | (1 <<10 ),CCR (free_ch)); }else if (cpu_is_omap730 () ||cpu_is_omap15xx ()) { -OMAP_DMA_CCR_REG (free_ch) = dev_id; +dma_write (dev_id,CCR (free_ch)); }if (cpu_class_is_omap2 ()) {
@@ -633,8 +734,8 @@ int omap_request_dma(int dev_id, const char *dev_name,omap_enable_channel_irq (free_ch);/* Clear the CSR register and IRQ status register */ -OMAP_DMA_CSR_REG (free_ch) =OMAP2_DMA_CSR_CLEAR_MASK ; -omap_writel (1 << free_ch,OMAP_DMA4_IRQSTATUS_L0 ); +dma_write (OMAP2_DMA_CSR_CLEAR_MASK ,CSR (free_ch)); +dma_write (1 << free_ch,IRQSTATUS_L0 ); } *dma_ch_out = free_ch;
@@ -660,27 +761,27 @@ void omap_free_dma(int lch)if (cpu_class_is_omap1 ()) {/* Disable all DMA interrupts for the channel. */ -OMAP_DMA_CICR_REG (lch) =0 ; +dma_write (0 ,CICR (lch));/* Make sure the DMA transfer is stopped. */ -OMAP_DMA_CCR_REG (lch) =0 ; +dma_write (0 ,CCR (lch)); }if (cpu_class_is_omap2 ()) {u32 val;/* Disable interrupts */ - val =omap_readl (OMAP_DMA4_IRQENABLE_L0 ); + val =dma_read (IRQENABLE_L0 ); val &= ~(1 << lch); -omap_writel (val,OMAP_DMA4_IRQENABLE_L0 ); +dma_write (val,IRQENABLE_L0 );/* Clear the CSR register and IRQ status register */ -OMAP_DMA_CSR_REG (lch) =OMAP2_DMA_CSR_CLEAR_MASK ; -omap_writel (1 << lch,OMAP_DMA4_IRQSTATUS_L0 ); +dma_write (OMAP2_DMA_CSR_CLEAR_MASK ,CSR (lch)); +dma_write (1 << lch,IRQSTATUS_L0 );/* Disable all DMA interrupts for the channel. */ -OMAP_DMA_CICR_REG (lch) =0 ; +dma_write (0 ,CICR (lch));/* Make sure the DMA transfer is stopped. */ -OMAP_DMA_CCR_REG (lch) =0 ; +dma_write (0 ,CCR (lch));omap_clear_dma (lch); } }
@@ -711,7 +812,7 @@ omap_dma_set_global_params(int arb_rate, int max_fifo_depth, int tparams) reg = (arb_rate &0xff ) <<16 ; reg |= (0xff & max_fifo_depth); -omap_writel (reg,OMAP_DMA4_GCR_REG ); +dma_write (reg,GCR ); }EXPORT_SYMBOL (omap_dma_set_global_params);
@@ -728,20 +829,21 @@ int omap_dma_set_prio_lch(int lch, unsigned char read_prio, unsigned char write_prio) { - u32 w; + u32 l;if (unlikely ((lch <0 || lch >= dma_lch_count))) {printk (KERN_ERR "Invalid channel id\n" );return -EINVAL ; } - w =OMAP_DMA_CCR_REG (lch); - w &= ~((1 <<6 ) | (1 <<26 )); + l =dma_read (CCR (lch)); + l &= ~((1 <<6 ) | (1 <<26 ));if (cpu_is_omap2430 () ||cpu_is_omap34xx ()) - w |= ((read_prio &0x1 ) <<6 ) | ((write_prio &0x1 ) <<26 ); + l |= ((read_prio &0x1 ) <<6 ) | ((write_prio &0x1 ) <<26 );else - w |= ((read_prio &0x1 ) <<6 ); + l |= ((read_prio &0x1 ) <<6 ); + +dma_write (l,CCR (lch)); -OMAP_DMA_CCR_REG (lch) = w;return 0 ; }EXPORT_SYMBOL (omap_dma_set_prio_lch);
@@ -757,18 +859,21 @@ void omap_clear_dma(int lch)local_irq_save (flags);if (cpu_class_is_omap1 ()) { -int status; -OMAP_DMA_CCR_REG (lch) &= ~OMAP_DMA_CCR_EN ; +u32 l; + + l =dma_read (CCR (lch)); + l &= ~OMAP_DMA_CCR_EN ; +dma_write (l,CCR (lch));/* Clear pending interrupts */ - status =OMAP_DMA_CSR_REG (lch); + l =dma_read (CSR (lch)); }if (cpu_class_is_omap2 ()) {int i; -u32 lch_base =OMAP_DMA4_BASE + lch *0x60 +0x80 ; +void __iomem *lch_base = omap_dma_base +OMAP_DMA4_CH_BASE (lch);for (i =0 ; i <0x44 ; i +=4 ) -omap_writel (0 , lch_base + i); +__raw_writel (0 , lch_base + i); }local_irq_restore (flags);
@@ -776,6 +881,8 @@ void omap_clear_dma(int lch)void omap_start_dma (int lch) { +u32 l; +if (!omap_dma_in_1510_mode () && dma_chan[lch].next_lch !=-1 ) {int next_lch, cur_lch;char dma_chan_link_map[OMAP_DMA4_LOGICAL_DMA_CH_COUNT ];
@@ -802,24 +909,28 @@ void omap_start_dma(int lch) }while (next_lch !=-1 ); }else if (cpu_class_is_omap2 ()) {/* Errata: Need to write lch even if not using chaining */ -OMAP_DMA_CLNK_CTRL_REG (lch) = lch; +dma_write (lch,CLNK_CTRL (lch)); }omap_enable_channel_irq (lch); + l =dma_read (CCR (lch)); +/* Errata: On ES2.0 BUFFERING disable must be set. * This will always fail on ES1.0 */ -if (cpu_is_omap24xx ()) { -OMAP_DMA_CCR_REG (lch) |=OMAP_DMA_CCR_EN ; - } +if (cpu_is_omap24xx ()) + l |=OMAP_DMA_CCR_EN ; -OMAP_DMA_CCR_REG (lch) |=OMAP_DMA_CCR_EN ; + l |=OMAP_DMA_CCR_EN ; +dma_write (l,CCR (lch)); dma_chan[lch].flags |=OMAP_DMA_ACTIVE ; }void omap_stop_dma (int lch) { +u32 l; +if (!omap_dma_in_1510_mode () && dma_chan[lch].next_lch !=-1 ) {int next_lch, cur_lch = lch;char dma_chan_link_map[OMAP_DMA4_LOGICAL_DMA_CH_COUNT ];
@@ -843,9 +954,12 @@ void omap_stop_dma(int lch)/* Disable all interrupts on the channel */ if (cpu_class_is_omap1 ()) -OMAP_DMA_CICR_REG (lch) =0 ; +dma_write (0 ,CICR (lch)); + + l =dma_read (CCR (lch)); + l &= ~OMAP_DMA_CCR_EN ; +dma_write (l,CCR (lch)); -OMAP_DMA_CCR_REG (lch) &= ~OMAP_DMA_CCR_EN ; dma_chan[lch].flags &= ~OMAP_DMA_ACTIVE ; }
@@ -887,12 +1001,20 @@ dma_addr_t omap_get_dma_src_pos(int lch) {dma_addr_t offset =0 ; -if (cpu_class_is_omap1 ()) - offset = (dma_addr_t) (OMAP1_DMA_CSSA_L_REG (lch) | - (OMAP1_DMA_CSSA_U_REG (lch) <<16 )); +if (cpu_is_omap15xx ()) + offset =dma_read (CPC (lch)); +else + offset =dma_read (CSAC (lch)); -if (cpu_class_is_omap2 ()) - offset =OMAP_DMA_CSAC_REG (lch); +/* +* omap 3.2/3.3 erratum: sometimes 0 is returned if CSAC/CDAC is +* read before the DMA controller finished disabling the channel. +*/ +if (!cpu_is_omap15xx () && offset ==0 ) + offset =dma_read (CSAC (lch)); + +if (cpu_class_is_omap1 ()) + offset |= (dma_read (CSSA_U (lch)) <<16 );return offset; }
@@ -909,12 +1031,20 @@ dma_addr_t omap_get_dma_dst_pos(int lch) {dma_addr_t offset =0 ; -if (cpu_class_is_omap1 ()) - offset = (dma_addr_t) (OMAP1_DMA_CDSA_L_REG (lch) | - (OMAP1_DMA_CDSA_U_REG (lch) <<16 )); +if (cpu_is_omap15xx ()) + offset =dma_read (CPC (lch)); +else + offset =dma_read (CDAC (lch)); -if (cpu_class_is_omap2 ()) - offset =OMAP_DMA_CDAC_REG (lch); +/* +* omap 3.2/3.3 erratum: sometimes 0 is returned if CSAC/CDAC is +* read before the DMA controller finished disabling the channel. +*/ +if (!cpu_is_omap15xx () && offset ==0 ) + offset =dma_read (CDAC (lch)); + +if (cpu_class_is_omap1 ()) + offset |= (dma_read (CDSA_U (lch)) <<16 );return offset; }
@@ -926,8 +1056,14 @@ dma_addr_t omap_get_dma_dst_pos(int lch)*/ int omap_get_dma_src_addr_counter (int lch) { -return (dma_addr_t )OMAP_DMA_CSAC_REG (lch); +return (dma_addr_t )dma_read (CSAC (lch)); +} + +int omap_get_dma_active_status (int lch) +{ +return (dma_read (CCR (lch)) &OMAP_DMA_CCR_EN ) !=0 ; } +EXPORT_SYMBOL (omap_get_dma_active_status);int omap_dma_running (void ) {
@@ -939,7 +1075,7 @@ int omap_dma_running(void)return 1 ;for (lch =0 ; lch < dma_chan_count; lch++) -if (OMAP_DMA_CCR_REG (lch) &OMAP_DMA_CCR_EN ) +if (dma_read (CCR (lch)) &OMAP_DMA_CCR_EN )return 1 ;return 0 ;
@@ -1001,7 +1137,7 @@ void omap_dma_unlink_lch (int lch_head, int lch_queue)/* Create chain of DMA channesls */ static void create_dma_lch_chain (int lch_head,int lch_queue) { -u32 w; +u32 l;/* Check if this is the first link in chain */ if (dma_chan[lch_head].next_linked_ch ==-1 ) {
@@ -1021,15 +1157,15 @@ static void create_dma_lch_chain(int lch_head, int lch_queue) lch_queue; } - w =OMAP_DMA_CLNK_CTRL_REG (lch_head); - w &= ~(0x1f ); - w |= lch_queue; -OMAP_DMA_CLNK_CTRL_REG (lch_head) = w; + l =dma_read (CLNK_CTRL (lch_head)); + l &= ~(0x1f ); + l |= lch_queue; +dma_write (l,CLNK_CTRL (lch_head)); - w =OMAP_DMA_CLNK_CTRL_REG (lch_queue); - w &= ~(0x1f ); - w |= (dma_chan[lch_queue].next_linked_ch); -OMAP_DMA_CLNK_CTRL_REG (lch_queue) = w; + l =dma_read (CLNK_CTRL (lch_queue)); + l &= ~(0x1f ); + l |= (dma_chan[lch_queue].next_linked_ch); +dma_write (l,CLNK_CTRL (lch_queue)); }/**
@@ -1256,7 +1392,7 @@ 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 w, lch; +u32 l, lch;int start_dma =0 ;/* if buffer size is less than 1 then there is
@@ -1297,13 +1433,13 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start,/* Set the params to the free channel */ if (src_start !=0 ) -OMAP2_DMA_CSSA_REG (lch) = src_start; +dma_write (src_start,CSSA (lch));if (dest_start !=0 ) -OMAP2_DMA_CDSA_REG (lch) = dest_start; +dma_write (dest_start,CDSA (lch));/* Write the buffer size */ -OMAP_DMA_CEN_REG (lch) = elem_count; -OMAP_DMA_CFN_REG (lch) = frame_count; +dma_write (elem_count,CEN (lch)); +dma_write (frame_count,CFN (lch));/* If the chain is dynamically linked, * then we may have to start the chain if its not active */
@@ -1330,8 +1466,8 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start,enable_lnk (dma_chan[lch].prev_linked_ch); dma_chan[lch].state =DMA_CH_QUEUED ; start_dma =0 ; -if (0 == ((1 <<7 ) & (OMAP_DMA_CCR_REG - (dma_chan[lch].prev_linked_ch)))) { +if (0 == ((1 <<7 ) &dma_read ( +CCR (dma_chan[lch].prev_linked_ch)))) {disable_lnk (dma_chan[lch]. prev_linked_ch);pr_debug ("\n prev ch is stopped\n" );
@@ -1347,23 +1483,23 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start, }omap_enable_channel_irq (lch); - w =OMAP_DMA_CCR_REG (lch); + l =dma_read (CCR (lch)); -if ((0 == (w & (1 <<24 )))) - w &= ~(1 <<25 ); +if ((0 == (l & (1 <<24 )))) + l &= ~(1 <<25 );else - w |= (1 <<25 ); + l |= (1 <<25 );if (start_dma ==1 ) { -if (0 == (w & (1 <<7 ))) { - w |= (1 <<7 ); +if (0 == (l & (1 <<7 ))) { + l |= (1 <<7 ); dma_chan[lch].state =DMA_CH_STARTED ;pr_debug ("starting %d\n" , lch); -OMAP_DMA_CCR_REG (lch) = w; +dma_write (l,CCR (lch)); }else start_dma =0 ; }else { -if (0 == (w & (1 <<7 ))) -OMAP_DMA_CCR_REG (lch) = w; +if (0 == (l & (1 <<7 ))) +dma_write (l,CCR (lch)); } dma_chan[lch].flags |=OMAP_DMA_ACTIVE ; }
@@ -1383,7 +1519,7 @@ EXPORT_SYMBOL(omap_dma_chain_a_transfer);int omap_start_dma_chain_transfers (int chain_id) {int *channels; -u32 w, i; +u32 l, i;if (unlikely ((chain_id <0 || chain_id >= dma_lch_count))) {printk (KERN_ERR "Invalid chain id\n" );
@@ -1407,16 +1543,16 @@ int omap_start_dma_chain_transfers(int chain_id)omap_enable_channel_irq (channels[0 ]); } - w =OMAP_DMA_CCR_REG (channels[0 ]); - w |= (1 <<7 ); + l =dma_read (CCR (channels[0 ])); + l |= (1 <<7 ); dma_linked_lch[chain_id].chain_state =DMA_CHAIN_STARTED ; dma_chan[channels[0 ]].state =DMA_CH_STARTED ; -if ((0 == (w & (1 <<24 )))) - w &= ~(1 <<25 ); +if ((0 == (l & (1 <<24 )))) + l &= ~(1 <<25 );else - w |= (1 <<25 ); -OMAP_DMA_CCR_REG (channels[0 ]) = w; + l |= (1 <<25 ); +dma_write (l,CCR (channels[0 ])); dma_chan[channels[0 ]].flags |=OMAP_DMA_ACTIVE ;return 0 ;
@@ -1434,7 +1570,7 @@ EXPORT_SYMBOL(omap_start_dma_chain_transfers);int omap_stop_dma_chain_transfers (int chain_id) {int *channels; -u32 w, i; +u32 l, i;u32 sys_cf;/* Check for input params */
@@ -1453,18 +1589,18 @@ int omap_stop_dma_chain_transfers(int chain_id)/* DMA Errata: * Special programming model needed to disable DMA before end of block */ - sys_cf =omap_readl (OMAP_DMA4_OCP_SYSCONFIG ); - w = sys_cf; + sys_cf =dma_read (OCP_SYSCONFIG ); + l = sys_cf;/* Middle mode reg set no Standby */ - w &= ~((1 <<12 )|(1 <<13 )); -omap_writel (w,OMAP_DMA4_OCP_SYSCONFIG ); + l &= ~((1 <<12 )|(1 <<13 )); +dma_write (l,OCP_SYSCONFIG );for (i =0 ; i < dma_linked_lch[chain_id].no_of_lchs_linked; i++) {/* Stop the Channel transmission */ - w =OMAP_DMA_CCR_REG (channels[i]); - w &= ~(1 <<7 ); -OMAP_DMA_CCR_REG (channels[i]) = w; + l =dma_read (CCR (channels[i])); + l &= ~(1 <<7 ); +dma_write (l,CCR (channels[i]));/* Disable the link in all the channels */ disable_lnk (channels[i]);
@@ -1477,7 +1613,7 @@ int omap_stop_dma_chain_transfers(int chain_id)OMAP_DMA_CHAIN_QINIT (chain_id);/* Errata - put in the old value */ -omap_writel (sys_cf,OMAP_DMA4_OCP_SYSCONFIG ); +dma_write (sys_cf,OCP_SYSCONFIG );return 0 ; }EXPORT_SYMBOL (omap_stop_dma_chain_transfers);
@@ -1518,8 +1654,8 @@ int omap_get_dma_chain_index(int chain_id, int *ei, int *fi)/* Get the current channel */ lch = channels[dma_linked_lch[chain_id].q_head]; - *ei =OMAP2_DMA_CCEN_REG (lch); - *fi =OMAP2_DMA_CCFN_REG (lch); + *ei =dma_read (CCEN (lch)); + *fi =dma_read (CCFN (lch));return 0 ; }
@@ -1556,7 +1692,7 @@ int omap_get_dma_chain_dst_pos(int chain_id)/* Get the current channel */ lch = channels[dma_linked_lch[chain_id].q_head]; -return (OMAP_DMA_CDAC_REG (lch)); +return dma_read (CDAC (lch)); }EXPORT_SYMBOL (omap_get_dma_chain_dst_pos);
@@ -1590,7 +1726,7 @@ int omap_get_dma_chain_src_pos(int chain_id)/* Get the current channel */ lch = channels[dma_linked_lch[chain_id].q_head]; - return (OMAP_DMA_CSAC_REG(lch)); + return dma_read(CSAC(lch)); }EXPORT_SYMBOL (omap_get_dma_chain_src_pos);#endif
@@ -1601,13 +1737,13 @@ EXPORT_SYMBOL(omap_get_dma_chain_src_pos);static int omap1_dma_handle_ch (int ch) { -u16 csr; +u32 csr;if (enable_1510_mode && ch >=6 ) { csr = dma_chan[ch].saved_csr; dma_chan[ch].saved_csr =0 ; }else - csr =OMAP_DMA_CSR_REG (ch); + csr =dma_read (CSR (ch));if (enable_1510_mode && ch <=2 && (csr >>7 ) !=0 ) { dma_chan[ch +6 ].saved_csr = csr >>7 ; csr &=0x7f ;
@@ -1659,12 +1795,12 @@ static irqreturn_t omap1_dma_irq_handler(int irq, void *dev_id)static int omap2_dma_handle_ch (int ch) { -u32 status =OMAP_DMA_CSR_REG (ch); +u32 status =dma_read (CSR (ch));if (!status) {if (printk_ratelimit ())printk (KERN_WARNING "Spurious DMA IRQ for lch %d\n" , ch); -omap_writel (1 << ch,OMAP_DMA4_IRQSTATUS_L0 ); +dma_write (1 << ch,IRQSTATUS_L0 );return 0 ; }if (unlikely (dma_chan[ch].dev_id ==-1 )) {
@@ -1687,14 +1823,14 @@ static int omap2_dma_handle_ch(int ch)printk (KERN_INFO "DMA misaligned error with device %d\n" , dma_chan[ch].dev_id); -OMAP_DMA_CSR_REG (ch) =OMAP2_DMA_CSR_CLEAR_MASK ; -omap_writel (1 << ch,OMAP_DMA4_IRQSTATUS_L0 ); +dma_write (OMAP2_DMA_CSR_CLEAR_MASK ,CSR (ch)); +dma_write (1 << ch,IRQSTATUS_L0 );/* If the ch is not chained then chain_id will be -1 */ if (dma_chan[ch].chain_id !=-1 ) {int chain_id = dma_chan[ch].chain_id; dma_chan[ch].state =DMA_CH_NOTSTARTED ; -if (OMAP_DMA_CLNK_CTRL_REG (ch) & (1 <<15 )) +if (dma_read (CLNK_CTRL (ch)) & (1 <<15 )) dma_chan[dma_chan[ch].next_linked_ch].state =DMA_CH_STARTED ; if (dma_linked_lch[chain_id].chain_mode ==
@@ -1704,13 +1840,13 @@ static int omap2_dma_handle_ch(int ch)if (!OMAP_DMA_CHAIN_QEMPTY (chain_id))OMAP_DMA_CHAIN_INCQHEAD (chain_id); - status =OMAP_DMA_CSR_REG (ch); + status =dma_read (CSR (ch)); }if (likely (dma_chan[ch].callback !=NULL )) dma_chan[ch].callback (ch, status, dma_chan[ch].data); -OMAP_DMA_CSR_REG (ch) = status; +dma_write (status,CSR (ch));return 0 ; }
@@ -1721,7 +1857,7 @@ static irqreturn_t omap2_dma_irq_handler(int irq, void *dev_id)u32 val;int i; - val =omap_readl (OMAP_DMA4_IRQSTATUS_L0 ); + val =dma_read (IRQSTATUS_L0 );if (val ==0 ) {if (printk_ratelimit ())printk (KERN_WARNING "Spurious DMA IRQ\n" );
@@ -2109,10 +2245,19 @@ static int __init omap_init_dma(void) {int ch, r; -if (cpu_class_is_omap1 ()) +if (cpu_class_is_omap1 ()) { + omap_dma_base = (void __iomem *)IO_ADDRESS (OMAP1_DMA_BASE ); dma_lch_count =OMAP1_LOGICAL_DMA_CH_COUNT ; -else + }else if (cpu_is_omap24xx ()) { + omap_dma_base = (void __iomem *)IO_ADDRESS (OMAP24XX_DMA4_BASE ); dma_lch_count =OMAP_DMA4_LOGICAL_DMA_CH_COUNT ; + }else if (cpu_is_omap34xx ()) { + omap_dma_base = (void __iomem *)IO_ADDRESS (OMAP34XX_DMA4_BASE ); + dma_lch_count =OMAP_DMA4_LOGICAL_DMA_CH_COUNT ; + }else { +pr_err ("DMA init failed for unsupported omap\n" ); +return -ENODEV ; + } dma_chan =kzalloc (sizeof (struct omap_dma_lch ) * dma_lch_count,GFP_KERNEL );
@@ -2134,21 +2279,21 @@ static int __init omap_init_dma(void) enable_1510_mode =1 ; }else if (cpu_is_omap16xx () ||cpu_is_omap730 ()) {printk (KERN_INFO "OMAP DMA hardware version %d\n" , -omap_readw (OMAP_DMA_HW_ID )); +dma_read (HW_ID ));printk (KERN_INFO "DMA capabilities: %08x:%08x:%04x:%04x:%04x\n" , - (omap_readw (OMAP_DMA_CAPS_0_U ) <<16 ) | -omap_readw (OMAP_DMA_CAPS_0_L ), - (omap_readw (OMAP_DMA_CAPS_1_U ) <<16 ) | -omap_readw (OMAP_DMA_CAPS_1_L ), -omap_readw (OMAP_DMA_CAPS_2 ),omap_readw (OMAP_DMA_CAPS_3 ), -omap_readw (OMAP_DMA_CAPS_4 )); + (dma_read (CAPS_0_U ) <<16 ) | +dma_read (CAPS_0_L ), + (dma_read (CAPS_1_U ) <<16 ) | +dma_read (CAPS_1_L ), +dma_read (CAPS_2 ),dma_read (CAPS_3 ), +dma_read (CAPS_4 ));if (!enable_1510_mode) {u16 w;/* Disable OMAP 3.0/3.1 compatibility mode. */ - w =omap_readw (OMAP_DMA_GSCR ); + w =dma_read (GSCR ); w |=1 <<3 ; -omap_writew (w,OMAP_DMA_GSCR ); +dma_write (w,GSCR ); dma_chan_count =16 ; }else dma_chan_count =9 ;
@@ -2161,7 +2306,7 @@ static int __init omap_init_dma(void)omap_writew (w,OMAP1610_DMA_LCD_CTRL ); } }else if (cpu_class_is_omap2 ()) { -u8 revision =omap_readb (OMAP_DMA4_REVISION ); +u8 revision =dma_read (REVISION ) &0xff ;printk (KERN_INFO "OMAP DMA hardware revision %d.%d\n" , revision >>4 , revision &0xf ); dma_chan_count =OMAP_DMA4_LOGICAL_DMA_CH_COUNT ;
drivers/usb/gadget/omap_udc.c +6 -36
88 lines not on this page · raw message
include/asm-arm/arch-omap/dma.h +120 -90
245 lines not on this page · raw message
Re: [PATCH 05/21] ARM: OMAP: DMA: Remove __REG access
Quoted 1 line · Tony Lindgren
Good catch, yes it can be static. Updated patch following.
Ok.
Re: [PATCH 04/21] ARM: OMAP: DMA: Make channels dynamic for multi-boot
In reply to Tony LindgrenQuoted 3 lines · Tony Lindgren
Make DMA channels dynamic for multi-boot
Signed-off-by Tony Lindgren <[email protected]>
Ok. Not for -rc.
Re: [PATCH 03/21] ARM: OMAP: Add OMAP3430 base defines
In reply to Tony LindgrenQuoted 9 lines · Tony Lindgren
From: Paul Walmsley <[email protected]>
Add symbolic constants for OMAP3430 base addresses; include that file in
hardware.h.Signed-off-by Paul Walmsley <[email protected]>Signed-off-by Tony Lindgren <[email protected]>+#define
IRQ_SIR_IRQ0x0040
Aren't IRQ numbers normally decimal?
Tony Lindgren
maintainerRe: [PATCH 03/21] ARM: OMAP: Add OMAP3430 base defines
Quoted 6 lines · Russell King - ARM Linux
Quoted 5 lines · Tony Lindgren
From: Paul Walmsley <[email protected]>
Add symbolic constants for OMAP3430 base addresses; include that file in
hardware.h.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Paul Walmsley <[email protected]>Signed-off-by Tony Lindgren <[email protected]>+#define
IRQ_SIR_IRQ0x0040Aren't IRQ numbers normally decimal?
Heh, looks like this can actually be left out. It's only used in entry-macro.S, and is the interrupt number register offset. I'll define it locally with a better name in entry-macro.S in a later patch.
Following is the updated revision of this patch.
Tony
Quoted 1 line
From
63a94017b430304c4e81595b648f06c5d062d7eeMon Sep 17 00:00:00 2001
From: Paul Walmsley <[email protected]>
Date: Tue, 17 Jun 2008 09:44:57 +0300
Subject: [PATCH] ARM: OMAP: Add OMAP3430 base defines
Add symbolic constants for OMAP3430 base addresses; include that file in hardware.h.
include/asm-arm/arch-omap/hardware.h +1 -0
@@ -284,6 +284,7 @@#include "omap1510.h" #include "omap24xx.h" #include "omap16xx.h" +#include "omap34xx.h" #ifndef __ASSEMBLER__
include/asm-arm/arch-omap/omap34xx.h new file +72 -0
72 lines not on this page · raw message
Re: [PATCH 02/21] ARM: OMAP: DMTimer: Optimize by adding load and start
In reply to Tony LindgrenQuoted 19 lines · Tony Lindgren
From: Richard Woodruff <[email protected]>
This patch optimizes the timer load and start sequence. By combining the load and start a needless posted wait can be removed from the system timer execution path.
* Before patch register writes are taking up .078% @ 500MHz during idle.
Address |total |min |max |avr |count|ratio% old\process\default_idle|7.369s |0.0us|999.902ms|14.477ms|509. |62.661% ld\Global\cpu_v7_do_idle|4.265s |0.0us|375.786ms|24.374ms|175. |36.270% (UNKNOWN)|17.503ms|0.us|531.080us|5.119us|3419. |0.148% r\omap_dm_timer_set_load|8.135ms|0.0us|79.887us|15.065us|540. |0.069% <-- \vmlinux-old\Global\_end|2.023ms|0.0us|4.000us|0.560us|3613. |0.017% -old\Global\__raw_readsw|1.962ms|0.0us|108.610us|9.167us|214. |0.016% old\smc91x\smc_interrupt|1.353ms|0.0us|10.212us|2.348us|576. |0.011% s/namei\__link_path_walk|1.161ms|0.0us|4.310us|0.762us| 1524. |0.009% \omap_dm_timer_write_reg|1.085ms|0.0us|126.150us|2.153us|504. |0.009% <--
Quoted 1 line
* After patch timer functions do not show up in top listings for long captures.
Ok. Not for -rc.