Port of a Linux commit e44abfed6fcb750d24f4438dc9d5a02eebb5fcac

  The read-only DBI registers can be written only when the "Write to RO
  Registers Using DBI" (DBI_RO_WR_EN) field of MISC_CONTROL_1_OFF is set.

  Add accessors to enable and disable write permission, and use them instead
  of accessing MISC_CONTROL_1_OFF directly.

  Signed-off-by: Hou Zhiqiang <[email protected]>
  Signed-off-by: Bjorn Helgaas <[email protected]>
  Acked-by: Joao Pinto <[email protected]>
  Acked-by: Roy Zang <[email protected]>

Signed-off-by: Andrey Smirnov <[email protected]>
---
 drivers/pci/pcie-designware.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/drivers/pci/pcie-designware.h b/drivers/pci/pcie-designware.h
index 10f64b101..26b1ada94 100644
--- a/drivers/pci/pcie-designware.h
+++ b/drivers/pci/pcie-designware.h
@@ -62,6 +62,9 @@
 #define PCIE_ATU_FUNC(x)               (((x) & 0x7) << 16)
 #define PCIE_ATU_UPPER_TARGET          0x91C
 
+#define PCIE_MISC_CONTROL_1_OFF                0x8BC
+#define PCIE_DBI_RO_WR_EN              (0x1 << 0)
+
 /* PCIe Port Logic registers */
 #define PLR_OFFSET                     0x700
 #define PCIE_PHY_DEBUG_R1              (PLR_OFFSET + 0x2c)
@@ -152,4 +155,27 @@ static inline u32 dw_pcie_readl_dbi(struct dw_pcie *pci, 
u32 reg)
 {
        return  __dw_pcie_readl_dbi(pci, pci->dbi_base, reg, 0x4);
 }
+
+static inline void dw_pcie_dbi_ro_wr_en(struct dw_pcie *pci)
+{
+       u32 reg;
+       u32 val;
+
+       reg = PCIE_MISC_CONTROL_1_OFF;
+       val = dw_pcie_readl_dbi(pci, reg);
+       val |= PCIE_DBI_RO_WR_EN;
+       dw_pcie_writel_dbi(pci, reg, val);
+}
+
+static inline void dw_pcie_dbi_ro_wr_dis(struct dw_pcie *pci)
+{
+       u32 reg;
+       u32 val;
+
+       reg = PCIE_MISC_CONTROL_1_OFF;
+       val = dw_pcie_readl_dbi(pci, reg);
+       val &= ~PCIE_DBI_RO_WR_EN;
+       dw_pcie_writel_dbi(pci, reg, val);
+}
+
 #endif /* _PCIE_DESIGNWARE_H */
-- 
2.19.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to