dmaengine: edma: predecence bug in GET_NUM_QDMACH()
[firefly-linux-kernel-4.4.55.git] / drivers / dma / edma.c
index 31722d436a42e6f717a7ebc0075d5110076e9d37..0675e268d5777967489bf25b30f5d217290fa441 100644 (file)
 
 /* CCCFG register */
 #define GET_NUM_DMACH(x)       (x & 0x7) /* bits 0-2 */
-#define GET_NUM_QDMACH(x)      (x & 0x70 >> 4) /* bits 4-6 */
+#define GET_NUM_QDMACH(x)      ((x & 0x70) >> 4) /* bits 4-6 */
 #define GET_NUM_PAENTRY(x)     ((x & 0x7000) >> 12) /* bits 12-14 */
 #define GET_NUM_EVQUE(x)       ((x & 0x70000) >> 16) /* bits 16-18 */
 #define GET_NUM_REGN(x)                ((x & 0x300000) >> 20) /* bits 20-21 */
@@ -269,6 +269,11 @@ static const struct of_device_id edma_of_ids[] = {
        {}
 };
 
+static const struct of_device_id edma_tptc_of_ids[] = {
+       { .compatible = "ti,edma3-tptc", },
+       {}
+};
+
 static inline unsigned int edma_read(struct edma_cc *ecc, int offset)
 {
        return (unsigned int)__raw_readl(ecc->base + offset);
@@ -1560,7 +1565,7 @@ static void edma_tc_set_pm_state(struct edma_tc *tc, bool enable)
        struct platform_device *tc_pdev;
        int ret;
 
-       if (!tc)
+       if (!IS_ENABLED(CONFIG_OF) || !tc)
                return;
 
        tc_pdev = of_find_device_by_node(tc->node);
@@ -2399,6 +2404,13 @@ static struct platform_driver edma_driver = {
        },
 };
 
+static struct platform_driver edma_tptc_driver = {
+       .driver = {
+               .name   = "edma3-tptc",
+               .of_match_table = edma_tptc_of_ids,
+       },
+};
+
 bool edma_filter_fn(struct dma_chan *chan, void *param)
 {
        bool match = false;
@@ -2418,6 +2430,12 @@ EXPORT_SYMBOL(edma_filter_fn);
 
 static int edma_init(void)
 {
+       int ret;
+
+       ret = platform_driver_register(&edma_tptc_driver);
+       if (ret)
+               return ret;
+
        return platform_driver_register(&edma_driver);
 }
 subsys_initcall(edma_init);
@@ -2425,6 +2443,7 @@ subsys_initcall(edma_init);
 static void __exit edma_exit(void)
 {
        platform_driver_unregister(&edma_driver);
+       platform_driver_unregister(&edma_tptc_driver);
 }
 module_exit(edma_exit);