(2014/10/02 1:31), ttha...@opensource.altera.com wrote:
> +void socfpga_init_ocram_ecc(void)
> +{
> +     struct device_node *np;
> +     const __be32 *prop;
> +     u32 ocr_edac_addr, iram_addr, len;
> +     void __iomem  *mapped_ocr_edac_addr;
> +     size_t size;
> +     struct gen_pool *gp;
> +
> +     np = of_find_compatible_node(NULL, NULL, "altr,ocram-edac");
> +     if (!np) {
> +             pr_err("SOCFPGA: Unable to find altr,ocram-edac in dtb\n");
> +             return;
> +     }
> +
> +     prop = of_get_property(np, "reg", &size);
> +     ocr_edac_addr = be32_to_cpup(prop++);
> +     len = be32_to_cpup(prop);
> +     if (!prop || size < sizeof(*prop)) {
> +             pr_err("SOCFPGA: Unable to find OCRAM ECC mapping in dtb\n");
> +             return;
> +     }
> +
> +     gp = of_get_named_gen_pool(np, "iram", 0);
> +     if (!gp) {
> +             pr_err("SOCFPGA: OCRAM cannot find gen pool\n");
> +             return;
> +     }
> +
> +     np = of_find_compatible_node(NULL, NULL, "mmio-sram");
> +     if (!np) {
> +             pr_err("SOCFPGA: Unable to find mmio-sram in dtb\n");
> +             return;
> +     }
> +     /* Determine the OCRAM address and size */
> +     prop = of_get_property(np, "reg", &size);
> +     iram_addr = be32_to_cpup(prop++);
> +     len = be32_to_cpup(prop);
> +
> +     if (!prop || size < sizeof(*prop)) {
> +             pr_err("SOCFPGA: Unable to find OCRAM mapping in dtb\n");
> +             return;
> +     }
> +
> +     iram_addr = gen_pool_alloc(gp, len);
> +     if (iram_addr == 0) {
> +             pr_err("SOCFPGA: cannot alloc from gen pool\n");
> +             return;
> +     }
> +
> +     memset((void *)iram_addr, 0, len);
> +
> +     mapped_ocr_edac_addr = ioremap(ocr_edac_addr, 4);
> +
> +     gen_pool_free(gp, iram_addr, len);
> +
> +     /* Clear any pending OCRAM ECC interrupts, then enable ECC */
> +     writel(0x18, mapped_ocr_edac_addr);
> +     writel(0x19, mapped_ocr_edac_addr);

Should we better iounmap() here?
It seems no one can use mapped_ocr_edac_addr afterwords.

> +
> +     pr_debug("SOCFPGA: Success Initializing OCRAM\n");
> +}
> +

Thank you,


-- 
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu...@hitachi.com


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to