aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma/omap-dma.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2013-11-02 15:57:06 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2014-04-03 19:28:02 -0400
commit9043826d88467091543c1d3ab06eb4afeed34789 (patch)
tree303f073eb893b8b1fba78b2c0d4ba1632c13f0c6 /drivers/dma/omap-dma.c
parent3ed4d18f39bcd8cb8d8218c0a5f89a4d81ba8730 (diff)
dmaengine: omap-dma: provide register definitions
Provide our own set of more complete register definitions; this allows us to get rid of the meaningless 1 << n constants scattered throughout this code. Acked-by: Tony Lindgren <tony@atomide.com> Acked-by: Vinod Koul <vinod.koul@intel.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers/dma/omap-dma.c')
-rw-r--r--drivers/dma/omap-dma.c171
1 files changed, 117 insertions, 54 deletions
diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
index 9a9e81907475..6cf66e608338 100644
--- a/drivers/dma/omap-dma.c
+++ b/drivers/dma/omap-dma.c
@@ -57,7 +57,7 @@ struct omap_desc {
57 dma_addr_t dev_addr; 57 dma_addr_t dev_addr;
58 58
59 int16_t fi; /* for OMAP_DMA_SYNC_PACKET */ 59 int16_t fi; /* for OMAP_DMA_SYNC_PACKET */
60 uint8_t es; /* OMAP_DMA_DATA_TYPE_xxx */ 60 uint8_t es; /* CSDP_DATA_TYPE_xxx */
61 uint32_t ccr; /* CCR value */ 61 uint32_t ccr; /* CCR value */
62 uint16_t cicr; /* CICR value */ 62 uint16_t cicr; /* CICR value */
63 uint32_t csdp; /* CSDP value */ 63 uint32_t csdp; /* CSDP value */
@@ -66,10 +66,83 @@ struct omap_desc {
66 struct omap_sg sg[0]; 66 struct omap_sg sg[0];
67}; 67};
68 68
69enum {
70 CCR_FS = BIT(5),
71 CCR_READ_PRIORITY = BIT(6),
72 CCR_ENABLE = BIT(7),
73 CCR_AUTO_INIT = BIT(8), /* OMAP1 only */
74 CCR_REPEAT = BIT(9), /* OMAP1 only */
75 CCR_OMAP31_DISABLE = BIT(10), /* OMAP1 only */
76 CCR_SUSPEND_SENSITIVE = BIT(8), /* OMAP2+ only */
77 CCR_RD_ACTIVE = BIT(9), /* OMAP2+ only */
78 CCR_WR_ACTIVE = BIT(10), /* OMAP2+ only */
79 CCR_SRC_AMODE_CONSTANT = 0 << 12,
80 CCR_SRC_AMODE_POSTINC = 1 << 12,
81 CCR_SRC_AMODE_SGLIDX = 2 << 12,
82 CCR_SRC_AMODE_DBLIDX = 3 << 12,
83 CCR_DST_AMODE_CONSTANT = 0 << 14,
84 CCR_DST_AMODE_POSTINC = 1 << 14,
85 CCR_DST_AMODE_SGLIDX = 2 << 14,
86 CCR_DST_AMODE_DBLIDX = 3 << 14,
87 CCR_CONSTANT_FILL = BIT(16),
88 CCR_TRANSPARENT_COPY = BIT(17),
89 CCR_BS = BIT(18),
90 CCR_SUPERVISOR = BIT(22),
91 CCR_PREFETCH = BIT(23),
92 CCR_TRIGGER_SRC = BIT(24),
93 CCR_BUFFERING_DISABLE = BIT(25),
94 CCR_WRITE_PRIORITY = BIT(26),
95 CCR_SYNC_ELEMENT = 0,
96 CCR_SYNC_FRAME = CCR_FS,
97 CCR_SYNC_BLOCK = CCR_BS,
98 CCR_SYNC_PACKET = CCR_BS | CCR_FS,
99
100 CSDP_DATA_TYPE_8 = 0,
101 CSDP_DATA_TYPE_16 = 1,
102 CSDP_DATA_TYPE_32 = 2,
103 CSDP_SRC_PORT_EMIFF = 0 << 2, /* OMAP1 only */
104 CSDP_SRC_PORT_EMIFS = 1 << 2, /* OMAP1 only */
105 CSDP_SRC_PORT_OCP_T1 = 2 << 2, /* OMAP1 only */
106 CSDP_SRC_PORT_TIPB = 3 << 2, /* OMAP1 only */
107 CSDP_SRC_PORT_OCP_T2 = 4 << 2, /* OMAP1 only */
108 CSDP_SRC_PORT_MPUI = 5 << 2, /* OMAP1 only */
109 CSDP_SRC_PACKED = BIT(6),
110 CSDP_SRC_BURST_1 = 0 << 7,
111 CSDP_SRC_BURST_16 = 1 << 7,
112 CSDP_SRC_BURST_32 = 2 << 7,
113 CSDP_SRC_BURST_64 = 3 << 7,
114 CSDP_DST_PORT_EMIFF = 0 << 9, /* OMAP1 only */
115 CSDP_DST_PORT_EMIFS = 1 << 9, /* OMAP1 only */
116 CSDP_DST_PORT_OCP_T1 = 2 << 9, /* OMAP1 only */
117 CSDP_DST_PORT_TIPB = 3 << 9, /* OMAP1 only */
118 CSDP_DST_PORT_OCP_T2 = 4 << 9, /* OMAP1 only */
119 CSDP_DST_PORT_MPUI = 5 << 9, /* OMAP1 only */
120 CSDP_DST_PACKED = BIT(13),
121 CSDP_DST_BURST_1 = 0 << 14,
122 CSDP_DST_BURST_16 = 1 << 14,
123 CSDP_DST_BURST_32 = 2 << 14,
124 CSDP_DST_BURST_64 = 3 << 14,
125
126 CICR_TOUT_IE = BIT(0), /* OMAP1 only */
127 CICR_DROP_IE = BIT(1),
128 CICR_HALF_IE = BIT(2),
129 CICR_FRAME_IE = BIT(3),
130 CICR_LAST_IE = BIT(4),
131 CICR_BLOCK_IE = BIT(5),
132 CICR_PKT_IE = BIT(7), /* OMAP2+ only */
133 CICR_TRANS_ERR_IE = BIT(8), /* OMAP2+ only */
134 CICR_SUPERVISOR_ERR_IE = BIT(10), /* OMAP2+ only */
135 CICR_MISALIGNED_ERR_IE = BIT(11), /* OMAP2+ only */
136 CICR_DRAIN_IE = BIT(12), /* OMAP2+ only */
137 CICR_SUPER_BLOCK_IE = BIT(14), /* OMAP2+ only */
138
139 CLNK_CTRL_ENABLE_LNK = BIT(15),
140};
141
69static const unsigned es_bytes[] = { 142static const unsigned es_bytes[] = {
70 [OMAP_DMA_DATA_TYPE_S8] = 1, 143 [CSDP_DATA_TYPE_8] = 1,
71 [OMAP_DMA_DATA_TYPE_S16] = 2, 144 [CSDP_DATA_TYPE_16] = 2,
72 [OMAP_DMA_DATA_TYPE_S32] = 4, 145 [CSDP_DATA_TYPE_32] = 4,
73}; 146};
74 147
75static struct of_dma_filter_info omap_dma_info = { 148static struct of_dma_filter_info omap_dma_info = {
@@ -112,7 +185,7 @@ static void omap_dma_start(struct omap_chan *c, struct omap_desc *d)
112 if (dma_omap1()) 185 if (dma_omap1())
113 val &= ~(1 << 14); 186 val &= ~(1 << 14);
114 187
115 val |= c->dma_ch | 1 << 15; 188 val |= c->dma_ch | CLNK_CTRL_ENABLE_LNK;
116 189
117 c->plat->dma_write(val, CLNK_CTRL, c->dma_ch); 190 c->plat->dma_write(val, CLNK_CTRL, c->dma_ch);
118 } else if (od->plat->errata & DMA_ERRATA_PARALLEL_CHANNELS) 191 } else if (od->plat->errata & DMA_ERRATA_PARALLEL_CHANNELS)
@@ -129,8 +202,8 @@ static void omap_dma_start(struct omap_chan *c, struct omap_desc *d)
129 202
130 val = c->plat->dma_read(CCR, c->dma_ch); 203 val = c->plat->dma_read(CCR, c->dma_ch);
131 if (od->plat->errata & DMA_ERRATA_IFRAME_BUFFERING) 204 if (od->plat->errata & DMA_ERRATA_IFRAME_BUFFERING)
132 val |= OMAP_DMA_CCR_BUFFERING_DISABLE; 205 val |= CCR_BUFFERING_DISABLE;
133 val |= OMAP_DMA_CCR_EN; 206 val |= CCR_ENABLE;
134 mb(); 207 mb();
135 c->plat->dma_write(val, CCR, c->dma_ch); 208 c->plat->dma_write(val, CCR, c->dma_ch);
136} 209}
@@ -150,8 +223,7 @@ static void omap_dma_stop(struct omap_chan *c)
150 c->plat->dma_write(~0, CSR, c->dma_ch); 223 c->plat->dma_write(~0, CSR, c->dma_ch);
151 224
152 val = c->plat->dma_read(CCR, c->dma_ch); 225 val = c->plat->dma_read(CCR, c->dma_ch);
153 if (od->plat->errata & DMA_ERRATA_i541 && 226 if (od->plat->errata & DMA_ERRATA_i541 && val & CCR_TRIGGER_SRC) {
154 val & OMAP_DMA_CCR_SEL_SRC_DST_SYNC) {
155 uint32_t sysconfig; 227 uint32_t sysconfig;
156 unsigned i; 228 unsigned i;
157 229
@@ -161,13 +233,13 @@ static void omap_dma_stop(struct omap_chan *c)
161 c->plat->dma_write(val, OCP_SYSCONFIG, c->dma_ch); 233 c->plat->dma_write(val, OCP_SYSCONFIG, c->dma_ch);
162 234
163 val = c->plat->dma_read(CCR, c->dma_ch); 235 val = c->plat->dma_read(CCR, c->dma_ch);
164 val &= ~OMAP_DMA_CCR_EN; 236 val &= ~CCR_ENABLE;
165 c->plat->dma_write(val, CCR, c->dma_ch); 237 c->plat->dma_write(val, CCR, c->dma_ch);
166 238
167 /* Wait for sDMA FIFO to drain */ 239 /* Wait for sDMA FIFO to drain */
168 for (i = 0; ; i++) { 240 for (i = 0; ; i++) {
169 val = c->plat->dma_read(CCR, c->dma_ch); 241 val = c->plat->dma_read(CCR, c->dma_ch);
170 if (!(val & (OMAP_DMA_CCR_RD_ACTIVE | OMAP_DMA_CCR_WR_ACTIVE))) 242 if (!(val & (CCR_RD_ACTIVE | CCR_WR_ACTIVE)))
171 break; 243 break;
172 244
173 if (i > 100) 245 if (i > 100)
@@ -176,14 +248,14 @@ static void omap_dma_stop(struct omap_chan *c)
176 udelay(5); 248 udelay(5);
177 } 249 }
178 250
179 if (val & (OMAP_DMA_CCR_RD_ACTIVE | OMAP_DMA_CCR_WR_ACTIVE)) 251 if (val & (CCR_RD_ACTIVE | CCR_WR_ACTIVE))
180 dev_err(c->vc.chan.device->dev, 252 dev_err(c->vc.chan.device->dev,
181 "DMA drain did not complete on lch %d\n", 253 "DMA drain did not complete on lch %d\n",
182 c->dma_ch); 254 c->dma_ch);
183 255
184 c->plat->dma_write(sysconfig, OCP_SYSCONFIG, c->dma_ch); 256 c->plat->dma_write(sysconfig, OCP_SYSCONFIG, c->dma_ch);
185 } else { 257 } else {
186 val &= ~OMAP_DMA_CCR_EN; 258 val &= ~CCR_ENABLE;
187 c->plat->dma_write(val, CCR, c->dma_ch); 259 c->plat->dma_write(val, CCR, c->dma_ch);
188 } 260 }
189 261
@@ -195,7 +267,7 @@ static void omap_dma_stop(struct omap_chan *c)
195 if (dma_omap1()) 267 if (dma_omap1())
196 val |= 1 << 14; /* set the STOP_LNK bit */ 268 val |= 1 << 14; /* set the STOP_LNK bit */
197 else 269 else
198 val &= ~(1 << 15); /* Clear the ENABLE_LNK bit */ 270 val &= ~CLNK_CTRL_ENABLE_LNK;
199 271
200 c->plat->dma_write(val, CLNK_CTRL, c->dma_ch); 272 c->plat->dma_write(val, CLNK_CTRL, c->dma_ch);
201 } 273 }
@@ -510,13 +582,13 @@ static struct dma_async_tx_descriptor *omap_dma_prep_slave_sg(
510 /* Bus width translates to the element size (ES) */ 582 /* Bus width translates to the element size (ES) */
511 switch (dev_width) { 583 switch (dev_width) {
512 case DMA_SLAVE_BUSWIDTH_1_BYTE: 584 case DMA_SLAVE_BUSWIDTH_1_BYTE:
513 es = OMAP_DMA_DATA_TYPE_S8; 585 es = CSDP_DATA_TYPE_8;
514 break; 586 break;
515 case DMA_SLAVE_BUSWIDTH_2_BYTES: 587 case DMA_SLAVE_BUSWIDTH_2_BYTES:
516 es = OMAP_DMA_DATA_TYPE_S16; 588 es = CSDP_DATA_TYPE_16;
517 break; 589 break;
518 case DMA_SLAVE_BUSWIDTH_4_BYTES: 590 case DMA_SLAVE_BUSWIDTH_4_BYTES:
519 es = OMAP_DMA_DATA_TYPE_S32; 591 es = CSDP_DATA_TYPE_32;
520 break; 592 break;
521 default: /* not reached */ 593 default: /* not reached */
522 return NULL; 594 return NULL;
@@ -531,44 +603,38 @@ static struct dma_async_tx_descriptor *omap_dma_prep_slave_sg(
531 d->dev_addr = dev_addr; 603 d->dev_addr = dev_addr;
532 d->es = es; 604 d->es = es;
533 605
534 d->ccr = 0; 606 d->ccr = CCR_SYNC_FRAME;
535 if (dir == DMA_DEV_TO_MEM) 607 if (dir == DMA_DEV_TO_MEM)
536 d->ccr |= OMAP_DMA_AMODE_POST_INC << 14 | 608 d->ccr |= CCR_DST_AMODE_POSTINC | CCR_SRC_AMODE_CONSTANT;
537 OMAP_DMA_AMODE_CONSTANT << 12;
538 else 609 else
539 d->ccr |= OMAP_DMA_AMODE_CONSTANT << 14 | 610 d->ccr |= CCR_DST_AMODE_CONSTANT | CCR_SRC_AMODE_POSTINC;
540 OMAP_DMA_AMODE_POST_INC << 12;
541 611
542 d->cicr = OMAP_DMA_DROP_IRQ | OMAP_DMA_BLOCK_IRQ; 612 d->cicr = CICR_DROP_IE | CICR_BLOCK_IE;
543 d->csdp = es; 613 d->csdp = es;
544 614
545 if (dma_omap1()) { 615 if (dma_omap1()) {
546 d->ccr |= 1 << 5; /* frame sync */
547 if (__dma_omap16xx(od->plat->dma_attr)) { 616 if (__dma_omap16xx(od->plat->dma_attr)) {
548 d->ccr |= 1 << 10; /* disable 3.0/3.1 compatibility mode */ 617 d->ccr |= CCR_OMAP31_DISABLE;
549 /* Duplicate what plat-omap/dma.c does */ 618 /* Duplicate what plat-omap/dma.c does */
550 d->ccr |= c->dma_ch + 1; 619 d->ccr |= c->dma_ch + 1;
551 } else { 620 } else {
552 d->ccr |= c->dma_sig & 0x1f; 621 d->ccr |= c->dma_sig & 0x1f;
553 } 622 }
554 623
555 d->cicr |= OMAP1_DMA_TOUT_IRQ; 624 d->cicr |= CICR_TOUT_IE;
556 625
557 if (dir == DMA_DEV_TO_MEM) 626 if (dir == DMA_DEV_TO_MEM)
558 d->csdp |= OMAP_DMA_PORT_EMIFF << 9 | 627 d->csdp |= CSDP_DST_PORT_EMIFF | CSDP_SRC_PORT_TIPB;
559 OMAP_DMA_PORT_TIPB << 2;
560 else 628 else
561 d->csdp |= OMAP_DMA_PORT_TIPB << 9 | 629 d->csdp |= CSDP_DST_PORT_TIPB | CSDP_SRC_PORT_EMIFF;
562 OMAP_DMA_PORT_EMIFF << 2;
563 } else { 630 } else {
564 d->ccr |= (c->dma_sig & ~0x1f) << 14; 631 d->ccr |= (c->dma_sig & ~0x1f) << 14;
565 d->ccr |= c->dma_sig & 0x1f; 632 d->ccr |= c->dma_sig & 0x1f;
566 d->ccr |= 1 << 5; /* frame sync */
567 633
568 if (dir == DMA_DEV_TO_MEM) 634 if (dir == DMA_DEV_TO_MEM)
569 d->ccr |= 1 << 24; /* source synch */ 635 d->ccr |= CCR_TRIGGER_SRC;
570 636
571 d->cicr |= OMAP2_DMA_MISALIGNED_ERR_IRQ | OMAP2_DMA_TRANS_ERR_IRQ; 637 d->cicr |= CICR_MISALIGNED_ERR_IE | CICR_TRANS_ERR_IE;
572 } 638 }
573 639
574 /* 640 /*
@@ -623,13 +689,13 @@ static struct dma_async_tx_descriptor *omap_dma_prep_dma_cyclic(
623 /* Bus width translates to the element size (ES) */ 689 /* Bus width translates to the element size (ES) */
624 switch (dev_width) { 690 switch (dev_width) {
625 case DMA_SLAVE_BUSWIDTH_1_BYTE: 691 case DMA_SLAVE_BUSWIDTH_1_BYTE:
626 es = OMAP_DMA_DATA_TYPE_S8; 692 es = CSDP_DATA_TYPE_8;
627 break; 693 break;
628 case DMA_SLAVE_BUSWIDTH_2_BYTES: 694 case DMA_SLAVE_BUSWIDTH_2_BYTES:
629 es = OMAP_DMA_DATA_TYPE_S16; 695 es = CSDP_DATA_TYPE_16;
630 break; 696 break;
631 case DMA_SLAVE_BUSWIDTH_4_BYTES: 697 case DMA_SLAVE_BUSWIDTH_4_BYTES:
632 es = OMAP_DMA_DATA_TYPE_S32; 698 es = CSDP_DATA_TYPE_32;
633 break; 699 break;
634 default: /* not reached */ 700 default: /* not reached */
635 return NULL; 701 return NULL;
@@ -651,51 +717,48 @@ static struct dma_async_tx_descriptor *omap_dma_prep_dma_cyclic(
651 717
652 d->ccr = 0; 718 d->ccr = 0;
653 if (__dma_omap15xx(od->plat->dma_attr)) 719 if (__dma_omap15xx(od->plat->dma_attr))
654 d->ccr = 3 << 8; 720 d->ccr = CCR_AUTO_INIT | CCR_REPEAT;
655 if (dir == DMA_DEV_TO_MEM) 721 if (dir == DMA_DEV_TO_MEM)
656 d->ccr |= OMAP_DMA_AMODE_POST_INC << 14 | 722 d->ccr |= CCR_DST_AMODE_POSTINC | CCR_SRC_AMODE_CONSTANT;
657 OMAP_DMA_AMODE_CONSTANT << 12;
658 else 723 else
659 d->ccr |= OMAP_DMA_AMODE_CONSTANT << 14 | 724 d->ccr |= CCR_DST_AMODE_CONSTANT | CCR_SRC_AMODE_POSTINC;
660 OMAP_DMA_AMODE_POST_INC << 12;
661 725
662 d->cicr = OMAP_DMA_DROP_IRQ; 726 d->cicr = CICR_DROP_IE;
663 if (flags & DMA_PREP_INTERRUPT) 727 if (flags & DMA_PREP_INTERRUPT)
664 d->cicr |= OMAP_DMA_FRAME_IRQ; 728 d->cicr |= CICR_FRAME_IE;
665 729
666 d->csdp = es; 730 d->csdp = es;
667 731
668 if (dma_omap1()) { 732 if (dma_omap1()) {
669 if (__dma_omap16xx(od->plat->dma_attr)) { 733 if (__dma_omap16xx(od->plat->dma_attr)) {
670 d->ccr |= 1 << 10; /* disable 3.0/3.1 compatibility mode */ 734 d->ccr |= CCR_OMAP31_DISABLE;
671 /* Duplicate what plat-omap/dma.c does */ 735 /* Duplicate what plat-omap/dma.c does */
672 d->ccr |= c->dma_ch + 1; 736 d->ccr |= c->dma_ch + 1;
673 } else { 737 } else {
674 d->ccr |= c->dma_sig & 0x1f; 738 d->ccr |= c->dma_sig & 0x1f;
675 } 739 }
676 740
677 d->cicr |= OMAP1_DMA_TOUT_IRQ; 741 d->cicr |= CICR_TOUT_IE;
678 742
679 if (dir == DMA_DEV_TO_MEM) 743 if (dir == DMA_DEV_TO_MEM)
680 d->csdp |= OMAP_DMA_PORT_EMIFF << 9 | 744 d->csdp |= CSDP_DST_PORT_EMIFF | CSDP_SRC_PORT_MPUI;
681 OMAP_DMA_PORT_MPUI << 2;
682 else 745 else
683 d->csdp |= OMAP_DMA_PORT_MPUI << 9 | 746 d->csdp |= CSDP_DST_PORT_MPUI | CSDP_SRC_PORT_EMIFF;
684 OMAP_DMA_PORT_EMIFF << 2;
685 } else { 747 } else {
686 d->ccr |= (c->dma_sig & ~0x1f) << 14; 748 d->ccr |= (c->dma_sig & ~0x1f) << 14;
687 d->ccr |= c->dma_sig & 0x1f; 749 d->ccr |= c->dma_sig & 0x1f;
688 750
689 if (burst) 751 if (burst)
690 d->ccr |= 1 << 18 | 1 << 5; /* packet */ 752 d->ccr |= CCR_SYNC_PACKET;
753 else
754 d->ccr |= CCR_SYNC_ELEMENT;
691 755
692 if (dir == DMA_DEV_TO_MEM) 756 if (dir == DMA_DEV_TO_MEM)
693 d->ccr |= 1 << 24; /* source synch */ 757 d->ccr |= CCR_TRIGGER_SRC;
694 758
695 d->cicr |= OMAP2_DMA_MISALIGNED_ERR_IRQ | OMAP2_DMA_TRANS_ERR_IRQ; 759 d->cicr |= CICR_MISALIGNED_ERR_IE | CICR_TRANS_ERR_IE;
696 760
697 /* src and dst burst mode 16 */ 761 d->csdp |= CSDP_DST_BURST_64 | CSDP_SRC_BURST_64;
698 d->csdp |= 3 << 14 | 3 << 7;
699 } 762 }
700 763
701 c->cyclic = true; 764 c->cyclic = true;