diff options
author | Marek Vasut <marek.vasut+renesas@gmail.com> | 2021-01-24 20:37:11 +0300 |
---|---|---|
committer | Marek Vasut <marek.vasut+renesas@gmail.com> | 2021-02-21 00:38:28 +0300 |
commit | b169ef17984ff73bee3b4e94844699893971bb8a (patch) | |
tree | 912f4b78546e03aa2e59fa375f96a1f589520877 | |
parent | b9616d8f903c8f4c7eac78adc7a8ff41c3099be3 (diff) | |
download | u-boot-b169ef17984ff73bee3b4e94844699893971bb8a.tar.xz |
pci: renesas: Make map address and mask power of two on Gen3
Both the map address and mask must be power of two per documentation,
adjust the code accordingly.
Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
-rw-r--r-- | drivers/pci/pci-rcar-gen3.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/pci/pci-rcar-gen3.c b/drivers/pci/pci-rcar-gen3.c index cd116a536e..6b08409b85 100644 --- a/drivers/pci/pci-rcar-gen3.c +++ b/drivers/pci/pci-rcar-gen3.c @@ -23,6 +23,7 @@ #include <pci.h> #include <wait_bit.h> #include <linux/bitops.h> +#include <linux/log2.h> #define PCIECAR 0x000010 #define PCIECCTLR 0x000018 @@ -347,10 +348,12 @@ static int rcar_gen3_pcie_probe(struct udevice *dev) if (hose->regions[i].phys_start == 0) continue; - mask = (hose->regions[i].size - 1) & ~0xf; + mask = (roundup_pow_of_two(hose->regions[i].size) - 1) & ~0xf; mask |= LAR_ENABLE; - writel(hose->regions[i].phys_start, priv->regs + PCIEPRAR(0)); - writel(hose->regions[i].phys_start, priv->regs + PCIELAR(0)); + writel(rounddown_pow_of_two(hose->regions[i].phys_start), + priv->regs + PCIEPRAR(0)); + writel(rounddown_pow_of_two(hose->regions[i].phys_start), + priv->regs + PCIELAR(0)); writel(mask, priv->regs + PCIELAMR(0)); break; } |