aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-davinci/dma.c65
1 files changed, 33 insertions, 32 deletions
diff --git a/arch/arm/mach-davinci/dma.c b/arch/arm/mach-davinci/dma.c
index b097592a862e..4ff1f939e07b 100644
--- a/arch/arm/mach-davinci/dma.c
+++ b/arch/arm/mach-davinci/dma.c
@@ -509,21 +509,21 @@ static irqreturn_t dma_tc1err_handler(int irq, void *data)
509 return IRQ_HANDLED; 509 return IRQ_HANDLED;
510} 510}
511 511
512static int reserve_contiguous_params(int ctlr, unsigned int id, 512static int reserve_contiguous_slots(int ctlr, unsigned int id,
513 unsigned int num_params, 513 unsigned int num_slots,
514 unsigned int start_param) 514 unsigned int start_slot)
515{ 515{
516 int i, j; 516 int i, j;
517 unsigned int count = num_params; 517 unsigned int count = num_slots;
518 int stop_param = start_param; 518 int stop_slot = start_slot;
519 DECLARE_BITMAP(tmp_inuse, EDMA_MAX_PARAMENTRY); 519 DECLARE_BITMAP(tmp_inuse, EDMA_MAX_PARAMENTRY);
520 520
521 for (i = start_param; i < edma_info[ctlr]->num_slots; ++i) { 521 for (i = start_slot; i < edma_info[ctlr]->num_slots; ++i) {
522 j = EDMA_CHAN_SLOT(i); 522 j = EDMA_CHAN_SLOT(i);
523 if (!test_and_set_bit(j, edma_info[ctlr]->edma_inuse)) { 523 if (!test_and_set_bit(j, edma_info[ctlr]->edma_inuse)) {
524 /* Record our current beginning slot */ 524 /* Record our current beginning slot */
525 if (count == num_params) 525 if (count == num_slots)
526 stop_param = i; 526 stop_slot = i;
527 527
528 count--; 528 count--;
529 set_bit(j, tmp_inuse); 529 set_bit(j, tmp_inuse);
@@ -534,34 +534,34 @@ static int reserve_contiguous_params(int ctlr, unsigned int id,
534 clear_bit(j, tmp_inuse); 534 clear_bit(j, tmp_inuse);
535 535
536 if (id == EDMA_CONT_PARAMS_FIXED_EXACT) { 536 if (id == EDMA_CONT_PARAMS_FIXED_EXACT) {
537 stop_param = i; 537 stop_slot = i;
538 break; 538 break;
539 } else 539 } else
540 count = num_params; 540 count = num_slots;
541 } 541 }
542 } 542 }
543 543
544 /* 544 /*
545 * We have to clear any bits that we set 545 * We have to clear any bits that we set
546 * if we run out parameter RAMs, i.e we do find a set 546 * if we run out parameter RAM slots, i.e we do find a set
547 * of contiguous parameter RAMs but do not find the exact number 547 * of contiguous parameter RAM slots but do not find the exact number
548 * requested as we may reach the total number of parameter RAMs 548 * requested as we may reach the total number of parameter RAM slots
549 */ 549 */
550 if (i == edma_info[ctlr]->num_slots) 550 if (i == edma_info[ctlr]->num_slots)
551 stop_param = i; 551 stop_slot = i;
552 552
553 for (j = start_param; j < stop_param; j++) 553 for (j = start_slot; j < stop_slot; j++)
554 if (test_bit(j, tmp_inuse)) 554 if (test_bit(j, tmp_inuse))
555 clear_bit(j, edma_info[ctlr]->edma_inuse); 555 clear_bit(j, edma_info[ctlr]->edma_inuse);
556 556
557 if (count) 557 if (count)
558 return -EBUSY; 558 return -EBUSY;
559 559
560 for (j = i - num_params + 1; j <= i; ++j) 560 for (j = i - num_slots + 1; j <= i; ++j)
561 memcpy_toio(edmacc_regs_base[ctlr] + PARM_OFFSET(j), 561 memcpy_toio(edmacc_regs_base[ctlr] + PARM_OFFSET(j),
562 &dummy_paramset, PARM_SIZE); 562 &dummy_paramset, PARM_SIZE);
563 563
564 return EDMA_CTLR_CHAN(ctlr, i - num_params + 1); 564 return EDMA_CTLR_CHAN(ctlr, i - num_slots + 1);
565} 565}
566 566
567/*-----------------------------------------------------------------------*/ 567/*-----------------------------------------------------------------------*/
@@ -759,26 +759,27 @@ EXPORT_SYMBOL(edma_free_slot);
759/** 759/**
760 * edma_alloc_cont_slots- alloc contiguous parameter RAM slots 760 * edma_alloc_cont_slots- alloc contiguous parameter RAM slots
761 * The API will return the starting point of a set of 761 * The API will return the starting point of a set of
762 * contiguous PARAM's that have been requested 762 * contiguous parameter RAM slots that have been requested
763 * 763 *
764 * @id: can only be EDMA_CONT_PARAMS_ANY or EDMA_CONT_PARAMS_FIXED_EXACT 764 * @id: can only be EDMA_CONT_PARAMS_ANY or EDMA_CONT_PARAMS_FIXED_EXACT
765 * or EDMA_CONT_PARAMS_FIXED_NOT_EXACT 765 * or EDMA_CONT_PARAMS_FIXED_NOT_EXACT
766 * @count: number of contiguous Paramter RAM's 766 * @count: number of contiguous Paramter RAM slots
767 * @param - the start value of Parameter RAM that should be passed if id 767 * @slot - the start value of Parameter RAM slot that should be passed if id
768 * is EDMA_CONT_PARAMS_FIXED_EXACT or EDMA_CONT_PARAMS_FIXED_NOT_EXACT 768 * is EDMA_CONT_PARAMS_FIXED_EXACT or EDMA_CONT_PARAMS_FIXED_NOT_EXACT
769 * 769 *
770 * If id is EDMA_CONT_PARAMS_ANY then the API starts looking for a set of 770 * If id is EDMA_CONT_PARAMS_ANY then the API starts looking for a set of
771 * contiguous Parameter RAMs from parameter RAM 64 in the case of DaVinci SOCs 771 * contiguous Parameter RAM slots from parameter RAM 64 in the case of
772 * and 32 in the case of Primus 772 * DaVinci SOCs and 32 in the case of DA8xx SOCs.
773 * 773 *
774 * If id is EDMA_CONT_PARAMS_FIXED_EXACT then the API starts looking for a 774 * If id is EDMA_CONT_PARAMS_FIXED_EXACT then the API starts looking for a
775 * set of contiguous parameter RAMs from the "param" that is passed as an 775 * set of contiguous parameter RAM slots from the "slot" that is passed as an
776 * argument to the API. 776 * argument to the API.
777 * 777 *
778 * If id is EDMA_CONT_PARAMS_FIXED_NOT_EXACT then the API initially tries 778 * If id is EDMA_CONT_PARAMS_FIXED_NOT_EXACT then the API initially tries
779 * starts looking for a set of contiguous parameter RAMs from the "param" 779 * starts looking for a set of contiguous parameter RAMs from the "slot"
780 * that is passed as an argument to the API. On failure the API will try to 780 * that is passed as an argument to the API. On failure the API will try to
781 * find a set of contiguous Parameter RAMs in the remaining Parameter RAMs 781 * find a set of contiguous Parameter RAM slots from the remaining Parameter
782 * RAM slots
782 */ 783 */
783int edma_alloc_cont_slots(unsigned ctlr, unsigned int id, int slot, int count) 784int edma_alloc_cont_slots(unsigned ctlr, unsigned int id, int slot, int count)
784{ 785{
@@ -793,7 +794,7 @@ int edma_alloc_cont_slots(unsigned ctlr, unsigned int id, int slot, int count)
793 return -EINVAL; 794 return -EINVAL;
794 795
795 /* 796 /*
796 * The number of parameter RAMs requested cannot be less than 1 797 * The number of parameter RAM slots requested cannot be less than 1
797 * and cannot be more than the number of slots minus the number of 798 * and cannot be more than the number of slots minus the number of
798 * channels 799 * channels
799 */ 800 */
@@ -803,11 +804,11 @@ int edma_alloc_cont_slots(unsigned ctlr, unsigned int id, int slot, int count)
803 804
804 switch (id) { 805 switch (id) {
805 case EDMA_CONT_PARAMS_ANY: 806 case EDMA_CONT_PARAMS_ANY:
806 return reserve_contiguous_params(ctlr, id, count, 807 return reserve_contiguous_slots(ctlr, id, count,
807 edma_info[ctlr]->num_channels); 808 edma_info[ctlr]->num_channels);
808 case EDMA_CONT_PARAMS_FIXED_EXACT: 809 case EDMA_CONT_PARAMS_FIXED_EXACT:
809 case EDMA_CONT_PARAMS_FIXED_NOT_EXACT: 810 case EDMA_CONT_PARAMS_FIXED_NOT_EXACT:
810 return reserve_contiguous_params(ctlr, id, count, slot); 811 return reserve_contiguous_slots(ctlr, id, count, slot);
811 default: 812 default:
812 return -EINVAL; 813 return -EINVAL;
813 } 814 }
@@ -816,14 +817,14 @@ int edma_alloc_cont_slots(unsigned ctlr, unsigned int id, int slot, int count)
816EXPORT_SYMBOL(edma_alloc_cont_slots); 817EXPORT_SYMBOL(edma_alloc_cont_slots);
817 818
818/** 819/**
819 * edma_free_cont_slots - deallocate DMA parameter RAMs 820 * edma_free_cont_slots - deallocate DMA parameter RAM slots
820 * @slot: first parameter RAM of a set of parameter RAMs to be freed 821 * @slot: first parameter RAM of a set of parameter RAM slots to be freed
821 * @count: the number of contiguous parameter RAMs to be freed 822 * @count: the number of contiguous parameter RAM slots to be freed
822 * 823 *
823 * This deallocates the parameter RAM slots allocated by 824 * This deallocates the parameter RAM slots allocated by
824 * edma_alloc_cont_slots. 825 * edma_alloc_cont_slots.
825 * Callers/applications need to keep track of sets of contiguous 826 * Callers/applications need to keep track of sets of contiguous
826 * parameter RAMs that have been allocated using the edma_alloc_cont_slots 827 * parameter RAM slots that have been allocated using the edma_alloc_cont_slots
827 * API. 828 * API.
828 * Callers are responsible for ensuring the slots are inactive, and will 829 * Callers are responsible for ensuring the slots are inactive, and will
829 * not be activated. 830 * not be activated.