dma: of-dma: Support to set number of dma mask bit property.
authorSeokju Yoon <sukju.yoon@samsung.com>
Thu, 18 Jun 2015 14:09:12 +0000 (23:09 +0900)
committerTaekki Kim <taekki.kim@samsung.com>
Mon, 14 May 2018 05:42:46 +0000 (14:42 +0900)
Change-Id: I329b65fa71cacddbc1be4df5bc32d142a8598c6d
Signed-off-by: Seokju Yoon <sukju.yoon@samsung.com>
drivers/dma/of-dma.c
drivers/dma/pl330.c
include/linux/of_dma.h

index 91fd395c90c4cf99cd444fdede5d42d08ecb529d..0a459731632f9b2265f2a9705c5e58680e525963 100644 (file)
@@ -227,6 +227,153 @@ static int of_dma_match_channel(struct device_node *np, const char *name,
        return 0;
 }
 
+/**
+ * of_dma_get_mcode_addr - Get the DMA micro code buffer address.
+ * @np:                device node of DMA controller
+ *
+ * Return the physical address.
+ */
+unsigned int of_dma_get_mcode_addr(struct device_node *np)
+{
+       unsigned int addr = 0;
+       const __be32    *prop;
+
+       prop = of_get_property(np, "#dma-mcode-addr", NULL);
+       if (prop)
+               addr = be32_to_cpup(prop);
+
+       return addr;
+}
+EXPORT_SYMBOL_GPL(of_dma_get_mcode_addr);
+
+/**
+ * of_dma_secure_dma_ch- Get the DMA micro code buffer address.
+ * @np:                device node of DMA controller
+ *
+ * Return the physical address.
+ */
+bool of_dma_secure_mode(struct device_node *np)
+{
+       bool ret = 0;
+       const __be32    *prop;
+
+       prop = of_get_property(np, "#dma-secure-mode", NULL);
+       if (prop)
+               ret = be32_to_cpup(prop);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(of_dma_secure_mode);
+
+/**
+ * of_dma_get_arwrapper_address - Get the DMA WAPPER AR address
+ * @np:                device node of DMA controller
+ * @num:       DMA channel thread number
+ *
+ * Return the virtual address.
+ */
+void __iomem *of_dma_get_arwrapper_address(struct device_node *np, unsigned int num)
+{
+       const __be32 *reg_list;
+       unsigned int length, count;
+
+       reg_list = of_get_property(np, "dma-arwrapper", &length);
+       count = (unsigned int)(length / sizeof(unsigned int));
+
+       if (!reg_list || num >= count)
+               return NULL;
+
+       return ioremap(be32_to_cpup(reg_list + num), SZ_32);
+}
+EXPORT_SYMBOL_GPL(of_dma_get_arwrapper_address);
+
+/**
+ * of_dma_get_arwrapper_address - Get the DMA WAPPER AW address
+ * @np:                device node of DMA controller
+ * @num:       DMA channel thread number
+ *
+ * Return the virtual address.
+ */
+void __iomem *of_dma_get_awwrapper_address(struct device_node *np, unsigned int num)
+{
+       const __be32 *reg_list;
+       unsigned int length, count;
+
+       reg_list = of_get_property(np, "dma-awwrapper", &length);
+       count = (unsigned int)(length / sizeof(unsigned int));
+
+       if (!reg_list || num >= count)
+               return NULL;
+
+       return ioremap(be32_to_cpup(reg_list + num), SZ_32);
+}
+EXPORT_SYMBOL_GPL(of_dma_get_awwrapper_address);
+
+/**
+ * of_dma_get_arwrapper_address - Get the DMA WAPPER AR address of DMA instruction
+ * @np:                device node of DMA controller
+ *
+ * Return the virtual address.
+ */
+void __iomem *of_dma_get_instwrapper_address(struct device_node *np)
+{
+       const __be32 *reg_list;
+       int ret = 0;
+
+       reg_list = of_get_property(np, "dma-instwrapper", NULL);
+
+       if (!reg_list)
+               return NULL;
+
+       ret = be32_to_cpup(reg_list);
+       if (!ret)
+               return NULL;
+
+       return ioremap(ret, SZ_32);
+}
+EXPORT_SYMBOL_GPL(of_dma_get_instwrapper_address);
+
+/**
+ * of_dma_get_arwrapper_address - Get the DMA WAPPER availableilable
+ * @np:                device node of DMA controller
+ *
+ */
+bool of_dma_get_wrapper_available(struct device_node *np)
+{
+       const __be32 *reg_list;
+       int ret = 0;
+
+       reg_list = of_get_property(np, "dma-instwrapper", NULL);
+
+       if (!reg_list)
+               return false;
+
+       ret = be32_to_cpup(reg_list);
+       if (ret)
+               return true;
+       else
+               return false;
+}
+EXPORT_SYMBOL_GPL(of_dma_get_wrapper_available);
+
+/**
+ * of_dma_get_arwrapper_address - Get the DMA WAPPER availableilable
+ * @np:                device node of DMA controller
+ *
+ */
+u64 of_dma_get_mask(struct device_node *np, char *name)
+{
+       int bit_cnt = 0;
+
+       of_property_read_u32(np, name, &bit_cnt);
+
+       if (bit_cnt)
+               return ((u64)1 << bit_cnt) - 1;
+       else
+               return -1;
+}
+EXPORT_SYMBOL_GPL(of_dma_get_mask);
+
 /**
  * of_dma_request_slave_channel - Get the DMA slave channel
  * @np:                device node to get DMA request from
index 5f58869727023c963db758817135e083b83ea181..96fe56eb2c2862e050681578e21e3776e5c3e484 100644 (file)
@@ -3050,8 +3050,13 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
                }
        }
 
-       if (adev->dev.of_node)
+       if (adev->dev.of_node){
+               *adev->dev.dma_mask = of_dma_get_mask(adev->dev.of_node,
+                               "dma-mask-bit");
+               adev->dev.coherent_dma_mask = of_dma_get_mask(adev->dev.of_node,
+                               "coherent-mask-bit");
                pl330->wrapper = of_dma_get_wrapper_available(adev->dev.of_node);
+       }
 
        pcfg = &pl330->pcfg;
 
index b90d8ec57c1fb43fcc182b59e3d3267c79c68865..05d3c61148063c5de3e54d7a76282f87365a8d21 100644 (file)
@@ -54,6 +54,13 @@ extern struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
 extern struct dma_chan *of_dma_xlate_by_chan_id(struct of_phandle_args *dma_spec,
                struct of_dma *ofdma);
 
+extern unsigned int of_dma_get_mcode_addr(struct device_node *np);
+extern bool of_dma_secure_mode(struct device_node *np);
+extern void __iomem *of_dma_get_arwrapper_address(struct device_node *np, unsigned int num);
+extern void __iomem *of_dma_get_awwrapper_address(struct device_node *np, unsigned int num);
+extern void __iomem *of_dma_get_instwrapper_address(struct device_node *np);
+extern bool of_dma_get_wrapper_available(struct device_node *np);
+extern u64 of_dma_get_mask(struct device_node *np, char *name);
 #else
 static inline int of_dma_controller_register(struct device_node *np,
                struct dma_chan *(*of_dma_xlate)
@@ -89,6 +96,35 @@ static inline struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_s
        return NULL;
 }
 
+static inline void __iomem *of_dma_get_wrapper_address(struct device_node *np, unsigned int num)
+{
+       return NULL;
+}
+
+static inline void __iomem *of_dma_get_arwrapper_address(struct device_node *np, unsigned int num)
+{
+       return NULL;
+}
+
+static inline void __iomem *of_dma_get_awwrapper_address(struct device_node *np, unsigned int num)
+{
+       return NULL;
+}
+
+static inline void __iomem *of_dma_get_instwrapper_address(struct device_node *np)
+{
+       return NULL;
+}
+
+static inline bool of_dma_get_wrapper_available(struct device_node *np)
+{
+       return NULL;
+}
+
+static u64 of_dma_get_mask(struct device_node *np, char *name)
+{
+       return NULL;
+}
 #define of_dma_xlate_by_chan_id NULL
 
 #endif