aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2015-10-13 13:09:17 -0400
committerVinod Koul <vinod.koul@intel.com>2015-10-30 22:02:19 -0400
commit30cb2639aa5253cf5bc4bd7dc5ea7e61b6887379 (patch)
tree12430d7471aa75a91fa81199ccddf7b4cde7e0e2
parent49dfebebfb6811693a9e883423585f079b5941fa (diff)
dmaengine: dw: don't override platform data with autocfg
Let probe driver decide either it wants to auto configure the driver or have explicitly defined properties. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
-rw-r--r--drivers/dma/dw/core.c57
1 files changed, 27 insertions, 30 deletions
diff --git a/drivers/dma/dw/core.c b/drivers/dma/dw/core.c
index 46859f738fcf..f16d1ed99ba9 100644
--- a/drivers/dma/dw/core.c
+++ b/drivers/dma/dw/core.c
@@ -1499,9 +1499,8 @@ EXPORT_SYMBOL(dw_dma_cyclic_free);
1499int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata) 1499int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata)
1500{ 1500{
1501 struct dw_dma *dw; 1501 struct dw_dma *dw;
1502 bool autocfg; 1502 bool autocfg = false;
1503 unsigned int dw_params; 1503 unsigned int dw_params;
1504 unsigned int nr_channels;
1505 unsigned int max_blk_size = 0; 1504 unsigned int max_blk_size = 0;
1506 int err; 1505 int err;
1507 int i; 1506 int i;
@@ -1515,33 +1514,41 @@ int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata)
1515 1514
1516 pm_runtime_get_sync(chip->dev); 1515 pm_runtime_get_sync(chip->dev);
1517 1516
1518 dw_params = dma_read_byaddr(chip->regs, DW_PARAMS); 1517 if (!pdata) {
1519 autocfg = dw_params >> DW_PARAMS_EN & 0x1; 1518 dw_params = dma_read_byaddr(chip->regs, DW_PARAMS);
1519 dev_dbg(chip->dev, "DW_PARAMS: 0x%08x\n", dw_params);
1520 1520
1521 dev_dbg(chip->dev, "DW_PARAMS: 0x%08x\n", dw_params); 1521 autocfg = dw_params >> DW_PARAMS_EN & 1;
1522 if (!autocfg) {
1523 err = -EINVAL;
1524 goto err_pdata;
1525 }
1522 1526
1523 if (!pdata && autocfg) {
1524 pdata = devm_kzalloc(chip->dev, sizeof(*pdata), GFP_KERNEL); 1527 pdata = devm_kzalloc(chip->dev, sizeof(*pdata), GFP_KERNEL);
1525 if (!pdata) { 1528 if (!pdata) {
1526 err = -ENOMEM; 1529 err = -ENOMEM;
1527 goto err_pdata; 1530 goto err_pdata;
1528 } 1531 }
1529 1532
1533 /* Get hardware configuration parameters */
1534 pdata->nr_channels = (dw_params >> DW_PARAMS_NR_CHAN & 7) + 1;
1535 pdata->nr_masters = (dw_params >> DW_PARAMS_NR_MASTER & 3) + 1;
1536 for (i = 0; i < pdata->nr_masters; i++) {
1537 pdata->data_width[i] =
1538 (dw_params >> DW_PARAMS_DATA_WIDTH(i) & 3) + 2;
1539 }
1540 max_blk_size = dma_readl(dw, MAX_BLK_SIZE);
1541
1530 /* Fill platform data with the default values */ 1542 /* Fill platform data with the default values */
1531 pdata->is_private = true; 1543 pdata->is_private = true;
1532 pdata->chan_allocation_order = CHAN_ALLOCATION_ASCENDING; 1544 pdata->chan_allocation_order = CHAN_ALLOCATION_ASCENDING;
1533 pdata->chan_priority = CHAN_PRIORITY_ASCENDING; 1545 pdata->chan_priority = CHAN_PRIORITY_ASCENDING;
1534 } else if (!pdata || pdata->nr_channels > DW_DMA_MAX_NR_CHANNELS) { 1546 } else if (pdata->nr_channels > DW_DMA_MAX_NR_CHANNELS) {
1535 err = -EINVAL; 1547 err = -EINVAL;
1536 goto err_pdata; 1548 goto err_pdata;
1537 } 1549 }
1538 1550
1539 if (autocfg) 1551 dw->chan = devm_kcalloc(chip->dev, pdata->nr_channels, sizeof(*dw->chan),
1540 nr_channels = (dw_params >> DW_PARAMS_NR_CHAN & 0x7) + 1;
1541 else
1542 nr_channels = pdata->nr_channels;
1543
1544 dw->chan = devm_kcalloc(chip->dev, nr_channels, sizeof(*dw->chan),
1545 GFP_KERNEL); 1552 GFP_KERNEL);
1546 if (!dw->chan) { 1553 if (!dw->chan) {
1547 err = -ENOMEM; 1554 err = -ENOMEM;
@@ -1549,22 +1556,12 @@ int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata)
1549 } 1556 }
1550 1557
1551 /* Get hardware configuration parameters */ 1558 /* Get hardware configuration parameters */
1552 if (autocfg) { 1559 dw->nr_masters = pdata->nr_masters;
1553 max_blk_size = dma_readl(dw, MAX_BLK_SIZE); 1560 for (i = 0; i < dw->nr_masters; i++)
1554 1561 dw->data_width[i] = pdata->data_width[i];
1555 dw->nr_masters = (dw_params >> DW_PARAMS_NR_MASTER & 3) + 1;
1556 for (i = 0; i < dw->nr_masters; i++) {
1557 dw->data_width[i] =
1558 (dw_params >> DW_PARAMS_DATA_WIDTH(i) & 3) + 2;
1559 }
1560 } else {
1561 dw->nr_masters = pdata->nr_masters;
1562 for (i = 0; i < dw->nr_masters; i++)
1563 dw->data_width[i] = pdata->data_width[i];
1564 }
1565 1562
1566 /* Calculate all channel mask before DMA setup */ 1563 /* Calculate all channel mask before DMA setup */
1567 dw->all_chan_mask = (1 << nr_channels) - 1; 1564 dw->all_chan_mask = (1 << pdata->nr_channels) - 1;
1568 1565
1569 /* Force dma off, just in case */ 1566 /* Force dma off, just in case */
1570 dw_dma_off(dw); 1567 dw_dma_off(dw);
@@ -1589,7 +1586,7 @@ int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata)
1589 goto err_pdata; 1586 goto err_pdata;
1590 1587
1591 INIT_LIST_HEAD(&dw->dma.channels); 1588 INIT_LIST_HEAD(&dw->dma.channels);
1592 for (i = 0; i < nr_channels; i++) { 1589 for (i = 0; i < pdata->nr_channels; i++) {
1593 struct dw_dma_chan *dwc = &dw->chan[i]; 1590 struct dw_dma_chan *dwc = &dw->chan[i];
1594 int r = nr_channels - i - 1; 1591 int r = nr_channels - i - 1;
1595 1592
@@ -1603,7 +1600,7 @@ int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata)
1603 1600
1604 /* 7 is highest priority & 0 is lowest. */ 1601 /* 7 is highest priority & 0 is lowest. */
1605 if (pdata->chan_priority == CHAN_PRIORITY_ASCENDING) 1602 if (pdata->chan_priority == CHAN_PRIORITY_ASCENDING)
1606 dwc->priority = r; 1603 dwc->priority = pdata->nr_channels - i - 1;
1607 else 1604 else
1608 dwc->priority = i; 1605 dwc->priority = i;
1609 1606
@@ -1687,7 +1684,7 @@ int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata)
1687 goto err_dma_register; 1684 goto err_dma_register;
1688 1685
1689 dev_info(chip->dev, "DesignWare DMA Controller, %d channels\n", 1686 dev_info(chip->dev, "DesignWare DMA Controller, %d channels\n",
1690 nr_channels); 1687 pdata->nr_channels);
1691 1688
1692 pm_runtime_put_sync_suspend(chip->dev); 1689 pm_runtime_put_sync_suspend(chip->dev);
1693 1690