aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarkko Nikula <jhnikula@gmail.com>2009-08-23 05:24:27 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-08-25 05:20:48 -0400
commitd09a2afc9359407114b7062519101f1ee2d05388 (patch)
tree43a4ac61d26e2c760dc2547066cef1b4d076a07f
parent32080af7a612e8c56131d6bdcd268cd9e8b0add1 (diff)
ARM: OMAP: McBSP: Merge two functions into omap_mcbsp_start/_stop
Functionality of functions omap_mcbsp_xmit_enable and omap_mcbsp_recv_enable can be merged into omap_mcbsp_start and omap_mcbsp_stop since API of those omap_mcbsp_start and omap_mcbsp_stop was changed recently allowing to start and stop individually the transmitter and receiver. This cleans up the code in arch/arm/plat-omap/mcbsp.c and in sound/soc/omap/omap-mcbsp.c which was the only user for those removed functions. Signed-off-by: Jarkko Nikula <jhnikula@gmail.com> Acked-by: Eero Nurkkala <ext-eero.nurkkala@nokia.com> Cc: Peter Ujfalusi <peter.ujfalusi@nokia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--arch/arm/plat-omap/include/mach/mcbsp.h2
-rw-r--r--arch/arm/plat-omap/mcbsp.c84
-rw-r--r--sound/soc/omap/omap-mcbsp.c5
3 files changed, 28 insertions, 63 deletions
diff --git a/arch/arm/plat-omap/include/mach/mcbsp.h b/arch/arm/plat-omap/include/mach/mcbsp.h
index 70e950e295e1..63a3f254af7b 100644
--- a/arch/arm/plat-omap/include/mach/mcbsp.h
+++ b/arch/arm/plat-omap/include/mach/mcbsp.h
@@ -436,8 +436,6 @@ int omap_mcbsp_request(unsigned int id);
436void omap_mcbsp_free(unsigned int id); 436void omap_mcbsp_free(unsigned int id);
437void omap_mcbsp_start(unsigned int id, int tx, int rx); 437void omap_mcbsp_start(unsigned int id, int tx, int rx);
438void omap_mcbsp_stop(unsigned int id, int tx, int rx); 438void omap_mcbsp_stop(unsigned int id, int tx, int rx);
439void omap_mcbsp_xmit_enable(unsigned int id, u8 enable);
440void omap_mcbsp_recv_enable(unsigned int id, u8 enable);
441void omap_mcbsp_xmit_word(unsigned int id, u32 word); 439void omap_mcbsp_xmit_word(unsigned int id, u32 word);
442u32 omap_mcbsp_recv_word(unsigned int id); 440u32 omap_mcbsp_recv_word(unsigned int id);
443 441
diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
index ee60ab68251d..8dc7927906f1 100644
--- a/arch/arm/plat-omap/mcbsp.c
+++ b/arch/arm/plat-omap/mcbsp.c
@@ -529,11 +529,13 @@ void omap_mcbsp_start(unsigned int id, int tx, int rx)
529 } 529 }
530 530
531 /* Enable transmitter and receiver */ 531 /* Enable transmitter and receiver */
532 tx &= 1;
532 w = OMAP_MCBSP_READ(io_base, SPCR2); 533 w = OMAP_MCBSP_READ(io_base, SPCR2);
533 OMAP_MCBSP_WRITE(io_base, SPCR2, w | (tx & 1)); 534 OMAP_MCBSP_WRITE(io_base, SPCR2, w | tx);
534 535
536 rx &= 1;
535 w = OMAP_MCBSP_READ(io_base, SPCR1); 537 w = OMAP_MCBSP_READ(io_base, SPCR1);
536 OMAP_MCBSP_WRITE(io_base, SPCR1, w | (rx & 1)); 538 OMAP_MCBSP_WRITE(io_base, SPCR1, w | rx);
537 539
538 /* 540 /*
539 * Worst case: CLKSRG*2 = 8000khz: (1/8000) * 2 * 2 usec 541 * Worst case: CLKSRG*2 = 8000khz: (1/8000) * 2 * 2 usec
@@ -549,6 +551,16 @@ void omap_mcbsp_start(unsigned int id, int tx, int rx)
549 OMAP_MCBSP_WRITE(io_base, SPCR2, w | (1 << 7)); 551 OMAP_MCBSP_WRITE(io_base, SPCR2, w | (1 << 7));
550 } 552 }
551 553
554 if (cpu_is_omap2430() || cpu_is_omap34xx()) {
555 /* Release the transmitter and receiver */
556 w = OMAP_MCBSP_READ(io_base, XCCR);
557 w &= ~(tx ? XDISABLE : 0);
558 OMAP_MCBSP_WRITE(io_base, XCCR, w);
559 w = OMAP_MCBSP_READ(io_base, RCCR);
560 w &= ~(rx ? RDISABLE : 0);
561 OMAP_MCBSP_WRITE(io_base, RCCR, w);
562 }
563
552 /* Dump McBSP Regs */ 564 /* Dump McBSP Regs */
553 omap_mcbsp_dump_reg(id); 565 omap_mcbsp_dump_reg(id);
554} 566}
@@ -570,12 +582,24 @@ void omap_mcbsp_stop(unsigned int id, int tx, int rx)
570 io_base = mcbsp->io_base; 582 io_base = mcbsp->io_base;
571 583
572 /* Reset transmitter */ 584 /* Reset transmitter */
585 tx &= 1;
586 if (cpu_is_omap2430() || cpu_is_omap34xx()) {
587 w = OMAP_MCBSP_READ(io_base, XCCR);
588 w |= (tx ? XDISABLE : 0);
589 OMAP_MCBSP_WRITE(io_base, XCCR, w);
590 }
573 w = OMAP_MCBSP_READ(io_base, SPCR2); 591 w = OMAP_MCBSP_READ(io_base, SPCR2);
574 OMAP_MCBSP_WRITE(io_base, SPCR2, w & ~(tx & 1)); 592 OMAP_MCBSP_WRITE(io_base, SPCR2, w & ~tx);
575 593
576 /* Reset receiver */ 594 /* Reset receiver */
595 rx &= 1;
596 if (cpu_is_omap2430() || cpu_is_omap34xx()) {
597 w = OMAP_MCBSP_READ(io_base, RCCR);
598 w |= (tx ? RDISABLE : 0);
599 OMAP_MCBSP_WRITE(io_base, RCCR, w);
600 }
577 w = OMAP_MCBSP_READ(io_base, SPCR1); 601 w = OMAP_MCBSP_READ(io_base, SPCR1);
578 OMAP_MCBSP_WRITE(io_base, SPCR1, w & ~(rx & 1)); 602 OMAP_MCBSP_WRITE(io_base, SPCR1, w & ~rx);
579 603
580 idle = !((OMAP_MCBSP_READ(io_base, SPCR2) | 604 idle = !((OMAP_MCBSP_READ(io_base, SPCR2) |
581 OMAP_MCBSP_READ(io_base, SPCR1)) & 1); 605 OMAP_MCBSP_READ(io_base, SPCR1)) & 1);
@@ -588,58 +612,6 @@ void omap_mcbsp_stop(unsigned int id, int tx, int rx)
588} 612}
589EXPORT_SYMBOL(omap_mcbsp_stop); 613EXPORT_SYMBOL(omap_mcbsp_stop);
590 614
591void omap_mcbsp_xmit_enable(unsigned int id, u8 enable)
592{
593 struct omap_mcbsp *mcbsp;
594 void __iomem *io_base;
595 u16 w;
596
597 if (!(cpu_is_omap2430() || cpu_is_omap34xx()))
598 return;
599
600 if (!omap_mcbsp_check_valid_id(id)) {
601 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
602 return;
603 }
604
605 mcbsp = id_to_mcbsp_ptr(id);
606 io_base = mcbsp->io_base;
607
608 w = OMAP_MCBSP_READ(io_base, XCCR);
609
610 if (enable)
611 OMAP_MCBSP_WRITE(io_base, XCCR, w & ~(XDISABLE));
612 else
613 OMAP_MCBSP_WRITE(io_base, XCCR, w | XDISABLE);
614}
615EXPORT_SYMBOL(omap_mcbsp_xmit_enable);
616
617void omap_mcbsp_recv_enable(unsigned int id, u8 enable)
618{
619 struct omap_mcbsp *mcbsp;
620 void __iomem *io_base;
621 u16 w;
622
623 if (!(cpu_is_omap2430() || cpu_is_omap34xx()))
624 return;
625
626 if (!omap_mcbsp_check_valid_id(id)) {
627 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
628 return;
629 }
630
631 mcbsp = id_to_mcbsp_ptr(id);
632 io_base = mcbsp->io_base;
633
634 w = OMAP_MCBSP_READ(io_base, RCCR);
635
636 if (enable)
637 OMAP_MCBSP_WRITE(io_base, RCCR, w & ~(RDISABLE));
638 else
639 OMAP_MCBSP_WRITE(io_base, RCCR, w | RDISABLE);
640}
641EXPORT_SYMBOL(omap_mcbsp_recv_enable);
642
643/* polled mcbsp i/o operations */ 615/* polled mcbsp i/o operations */
644int omap_mcbsp_pollwrite(unsigned int id, u16 buf) 616int omap_mcbsp_pollwrite(unsigned int id, u16 buf)
645{ 617{
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index 89e8bce114af..0e173e7e0c3a 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -231,11 +231,6 @@ static int omap_mcbsp_dai_trigger(struct snd_pcm_substream *substream, int cmd,
231 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 231 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
232 mcbsp_data->active++; 232 mcbsp_data->active++;
233 omap_mcbsp_start(mcbsp_data->bus_id, play, !play); 233 omap_mcbsp_start(mcbsp_data->bus_id, play, !play);
234 /* Make sure data transfer is frame synchronized */
235 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
236 omap_mcbsp_xmit_enable(mcbsp_data->bus_id, 1);
237 else
238 omap_mcbsp_recv_enable(mcbsp_data->bus_id, 1);
239 break; 234 break;
240 235
241 case SNDRV_PCM_TRIGGER_STOP: 236 case SNDRV_PCM_TRIGGER_STOP: