aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Bailon <abailon@baylibre.com>2017-02-15 08:56:35 -0500
committerVinod Koul <vinod.koul@intel.com>2017-03-07 03:08:25 -0500
commit5e46fe98ab658eab817398abd895908854bb4c43 (patch)
tree9b15e7485f4b5221e2a008fe8cc33aed5f8360fd
parent2d535b2629bfdf30c972ea394669bd146f752091 (diff)
dmaengine: cppi41: init_sched(): Get number of channels from DT
Despite the driver is already using DT to get the number of channels, init_sched() is using an hardcoded value to get it. Use DT to get the number of channels. Signed-off-by: Alexandre Bailon <abailon@baylibre.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
-rw-r--r--drivers/dma/cppi41.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index 676228ff71de..54337cd0afcc 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c
@@ -139,6 +139,8 @@ struct cppi41_dd {
139 struct chan_queues td_queue; 139 struct chan_queues td_queue;
140 u16 first_completion_queue; 140 u16 first_completion_queue;
141 u16 qmgr_num_pend; 141 u16 qmgr_num_pend;
142 u32 n_chans;
143 u8 platform;
142 144
143 struct list_head pending; /* Pending queued transfers */ 145 struct list_head pending; /* Pending queued transfers */
144 spinlock_t lock; /* Lock for pending list */ 146 spinlock_t lock; /* Lock for pending list */
@@ -742,13 +744,8 @@ static int cppi41_add_chans(struct device *dev, struct cppi41_dd *cdd)
742{ 744{
743 struct cppi41_channel *cchan; 745 struct cppi41_channel *cchan;
744 int i; 746 int i;
745 int ret; 747 u32 n_chans = cdd->n_chans;
746 u32 n_chans;
747 748
748 ret = of_property_read_u32(dev->of_node, "#dma-channels",
749 &n_chans);
750 if (ret)
751 return ret;
752 /* 749 /*
753 * The channels can only be used as TX or as RX. So we add twice 750 * The channels can only be used as TX or as RX. So we add twice
754 * that much dma channels because USB can only do RX or TX. 751 * that much dma channels because USB can only do RX or TX.
@@ -862,7 +859,7 @@ static void init_sched(struct cppi41_dd *cdd)
862 859
863 word = 0; 860 word = 0;
864 cppi_writel(0, cdd->sched_mem + DMA_SCHED_CTRL); 861 cppi_writel(0, cdd->sched_mem + DMA_SCHED_CTRL);
865 for (ch = 0; ch < 15 * 2; ch += 2) { 862 for (ch = 0; ch < cdd->n_chans; ch += 2) {
866 863
867 reg = SCHED_ENTRY0_CHAN(ch); 864 reg = SCHED_ENTRY0_CHAN(ch);
868 reg |= SCHED_ENTRY1_CHAN(ch) | SCHED_ENTRY1_IS_RX; 865 reg |= SCHED_ENTRY1_CHAN(ch) | SCHED_ENTRY1_IS_RX;
@@ -872,7 +869,7 @@ static void init_sched(struct cppi41_dd *cdd)
872 cppi_writel(reg, cdd->sched_mem + DMA_SCHED_WORD(word)); 869 cppi_writel(reg, cdd->sched_mem + DMA_SCHED_WORD(word));
873 word++; 870 word++;
874 } 871 }
875 reg = 15 * 2 * 2 - 1; 872 reg = cdd->n_chans * 2 - 1;
876 reg |= DMA_SCHED_CTRL_EN; 873 reg |= DMA_SCHED_CTRL_EN;
877 cppi_writel(reg, cdd->sched_mem + DMA_SCHED_CTRL); 874 cppi_writel(reg, cdd->sched_mem + DMA_SCHED_CTRL);
878} 875}
@@ -897,6 +894,7 @@ static int init_cppi41(struct device *dev, struct cppi41_dd *cdd)
897 894
898 cppi_writel(cdd->td_queue.submit, cdd->ctrl_mem + DMA_TDFDQ); 895 cppi_writel(cdd->td_queue.submit, cdd->ctrl_mem + DMA_TDFDQ);
899 init_sched(cdd); 896 init_sched(cdd);
897
900 return 0; 898 return 0;
901err_td: 899err_td:
902 deinit_cppi41(dev, cdd); 900 deinit_cppi41(dev, cdd);
@@ -1058,6 +1056,11 @@ static int cppi41_dma_probe(struct platform_device *pdev)
1058 cdd->qmgr_num_pend = glue_info->qmgr_num_pend; 1056 cdd->qmgr_num_pend = glue_info->qmgr_num_pend;
1059 cdd->first_completion_queue = glue_info->first_completion_queue; 1057 cdd->first_completion_queue = glue_info->first_completion_queue;
1060 1058
1059 ret = of_property_read_u32(dev->of_node,
1060 "#dma-channels", &cdd->n_chans);
1061 if (ret)
1062 goto err_get_n_chans;
1063
1061 ret = init_cppi41(dev, cdd); 1064 ret = init_cppi41(dev, cdd);
1062 if (ret) 1065 if (ret)
1063 goto err_init_cppi; 1066 goto err_init_cppi;
@@ -1100,6 +1103,7 @@ err_chans:
1100 deinit_cppi41(dev, cdd); 1103 deinit_cppi41(dev, cdd);
1101err_init_cppi: 1104err_init_cppi:
1102 pm_runtime_dont_use_autosuspend(dev); 1105 pm_runtime_dont_use_autosuspend(dev);
1106err_get_n_chans:
1103err_get_sync: 1107err_get_sync:
1104 pm_runtime_put_sync(dev); 1108 pm_runtime_put_sync(dev);
1105 pm_runtime_disable(dev); 1109 pm_runtime_disable(dev);