static int mv_conf_mbus_windows(struct platform_device *pdev, const struct mbus_dram_target_info *dram) { int i; void __iomem *regs; struct resource *res; if (!dram) { dev_err(&pdev->dev, "no mbus dram info\n"); return -EINVAL; } res = platform_get_resource(pdev, IORESOURCE_MEM, 1); if (!res) { dev_err(&pdev->dev, "cannot get mbus registers\n"); return -EINVAL; } regs = ioremap(res->start, resource_size(res)); if (!regs) { dev_err(&pdev->dev, "cannot map mbus registers\n"); return -ENOMEM; } for (i = 0; i < SDHCI_MAX_WIN_NUM; i++) { writel(0, regs + SDHCI_WINDOW_CTRL(i)); writel(0, regs + SDHCI_WINDOW_BASE(i)); } for (i = 0; i < dram->num_cs; i++) { const struct mbus_dram_window *cs = dram->cs + i; /* Write size, attributes and target id to control register */ writel(((cs->size - 1) & 0xffff0000) | (cs->mbus_attr << 8) | (dram->mbus_dram_target_id << 4) | 1, regs + SDHCI_WINDOW_CTRL(i)); /* Write base address to base register */ writel(cs->base, regs + SDHCI_WINDOW_BASE(i)); } iounmap(regs); return 0; }
static void sdhci_mvebu_mbus_config(void __iomem *base) { const struct mbus_dram_target_info *dram; int i; dram = mvebu_mbus_dram_info(); for (i = 0; i < 4; i++) { writel(0, base + SDHCI_WINDOW_CTRL(i)); writel(0, base + SDHCI_WINDOW_BASE(i)); } for (i = 0; i < dram->num_cs; i++) { const struct mbus_dram_window *cs = dram->cs + i; /* Write size, attributes and target id to control register */ writel(((cs->size - 1) & 0xffff0000) | (cs->mbus_attr << 8) | (dram->mbus_dram_target_id << 4) | 1, base + SDHCI_WINDOW_CTRL(i)); /* Write base address to base register */ writel(cs->base, base + SDHCI_WINDOW_BASE(i)); } }