|
55 | 55 | | DWC_CTLL_SMS(_sms)); \ |
56 | 56 | }) |
57 | 57 |
|
58 | | -/* |
59 | | - * This is configuration-dependent and usually a funny size like 4095. |
60 | | - * |
61 | | - * Note that this is a transfer count, i.e. if we transfer 32-bit |
62 | | - * words, we can do 16380 bytes per descriptor. |
63 | | - * |
64 | | - * This parameter is also system-specific. |
65 | | - */ |
66 | | -#define DWC_MAX_COUNT 4095U |
67 | | - |
68 | 58 | /* |
69 | 59 | * Number of descriptors to allocate for each channel. This should be |
70 | 60 | * made configurable somehow; preferably, the clients (at least the |
@@ -672,7 +662,7 @@ dwc_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src, |
672 | 662 |
|
673 | 663 | for (offset = 0; offset < len; offset += xfer_count << src_width) { |
674 | 664 | xfer_count = min_t(size_t, (len - offset) >> src_width, |
675 | | - DWC_MAX_COUNT); |
| 665 | + dwc->block_size); |
676 | 666 |
|
677 | 667 | desc = dwc_desc_get(dwc); |
678 | 668 | if (!desc) |
@@ -773,8 +763,8 @@ dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, |
773 | 763 | desc->lli.sar = mem; |
774 | 764 | desc->lli.dar = reg; |
775 | 765 | desc->lli.ctllo = ctllo | DWC_CTLL_SRC_WIDTH(mem_width); |
776 | | - if ((len >> mem_width) > DWC_MAX_COUNT) { |
777 | | - dlen = DWC_MAX_COUNT << mem_width; |
| 766 | + if ((len >> mem_width) > dwc->block_size) { |
| 767 | + dlen = dwc->block_size << mem_width; |
778 | 768 | mem += dlen; |
779 | 769 | len -= dlen; |
780 | 770 | } else { |
@@ -833,8 +823,8 @@ dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, |
833 | 823 | desc->lli.sar = reg; |
834 | 824 | desc->lli.dar = mem; |
835 | 825 | desc->lli.ctllo = ctllo | DWC_CTLL_DST_WIDTH(mem_width); |
836 | | - if ((len >> reg_width) > DWC_MAX_COUNT) { |
837 | | - dlen = DWC_MAX_COUNT << reg_width; |
| 826 | + if ((len >> reg_width) > dwc->block_size) { |
| 827 | + dlen = dwc->block_size << reg_width; |
838 | 828 | mem += dlen; |
839 | 829 | len -= dlen; |
840 | 830 | } else { |
@@ -1217,7 +1207,7 @@ struct dw_cyclic_desc *dw_dma_cyclic_prep(struct dma_chan *chan, |
1217 | 1207 | periods = buf_len / period_len; |
1218 | 1208 |
|
1219 | 1209 | /* Check for too big/unaligned periods and unaligned DMA buffer. */ |
1220 | | - if (period_len > (DWC_MAX_COUNT << reg_width)) |
| 1210 | + if (period_len > (dwc->block_size << reg_width)) |
1221 | 1211 | goto out_err; |
1222 | 1212 | if (unlikely(period_len & ((1 << reg_width) - 1))) |
1223 | 1213 | goto out_err; |
@@ -1383,6 +1373,7 @@ static int __devinit dw_probe(struct platform_device *pdev) |
1383 | 1373 | bool autocfg; |
1384 | 1374 | unsigned int dw_params; |
1385 | 1375 | unsigned int nr_channels; |
| 1376 | + unsigned int max_blk_size = 0; |
1386 | 1377 | int irq; |
1387 | 1378 | int err; |
1388 | 1379 | int i; |
@@ -1423,6 +1414,10 @@ static int __devinit dw_probe(struct platform_device *pdev) |
1423 | 1414 |
|
1424 | 1415 | dw->regs = regs; |
1425 | 1416 |
|
| 1417 | + /* get hardware configuration parameters */ |
| 1418 | + if (autocfg) |
| 1419 | + max_blk_size = dma_readl(dw, MAX_BLK_SIZE); |
| 1420 | + |
1426 | 1421 | /* Calculate all channel mask before DMA setup */ |
1427 | 1422 | dw->all_chan_mask = (1 << nr_channels) - 1; |
1428 | 1423 |
|
@@ -1468,6 +1463,16 @@ static int __devinit dw_probe(struct platform_device *pdev) |
1468 | 1463 | INIT_LIST_HEAD(&dwc->free_list); |
1469 | 1464 |
|
1470 | 1465 | channel_clear_bit(dw, CH_EN, dwc->mask); |
| 1466 | + |
| 1467 | + /* hardware configuration */ |
| 1468 | + if (autocfg) |
| 1469 | + /* Decode maximum block size for given channel. The |
| 1470 | + * stored 4 bit value represents blocks from 0x00 for 3 |
| 1471 | + * up to 0x0a for 4095. */ |
| 1472 | + dwc->block_size = |
| 1473 | + (4 << ((max_blk_size >> 4 * i) & 0xf)) - 1; |
| 1474 | + else |
| 1475 | + dwc->block_size = pdata->block_size; |
1471 | 1476 | } |
1472 | 1477 |
|
1473 | 1478 | /* Clear all interrupts on all channels. */ |
|
0 commit comments