]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ata: ahci_brcm: Avoid writing to read-only registers
authorDoug Berger <opendmb@gmail.com>
Wed, 21 Jun 2017 23:20:14 +0000 (16:20 -0700)
committerTejun Heo <tj@kernel.org>
Thu, 22 Jun 2017 20:13:00 +0000 (16:13 -0400)
This commit makes use of the AHCI_HFLAG_YES_ALPM flag to prevent
the driver from writing to the read-only Host Capability register.

It also sets the AHCI_HFLAG_NO_WRITE_TO_RO flag to prevent the AHCI
library from writing to read-only registers.

Signed-off-by: Doug Berger <opendmb@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
drivers/ata/ahci_brcm.c

index 6f8a7341fa08a701af61226fab156206b506be20..5936d1679bf3af0e529d36df820e3b8736bfce17 100644 (file)
@@ -39,7 +39,6 @@
  #define PIODATA_ENDIAN_SHIFT                          6
   #define ENDIAN_SWAP_NONE                             0
   #define ENDIAN_SWAP_FULL                             2
- #define OVERRIDE_HWINIT                               BIT(16)
 #define SATA_TOP_CTRL_TP_CTRL                          0x8
 #define SATA_TOP_CTRL_PHY_CTRL                         0xc
  #define SATA_TOP_CTRL_PHY_CTRL_1                      0x0
@@ -126,17 +125,13 @@ static inline void brcm_sata_writereg(u32 val, void __iomem *addr)
 static void brcm_sata_alpm_init(struct ahci_host_priv *hpriv)
 {
        struct brcm_ahci_priv *priv = hpriv->plat_data;
-       u32 bus_ctrl, port_ctrl, host_caps;
+       u32 port_ctrl, host_caps;
        int i;
 
        /* Enable support for ALPM */
-       bus_ctrl = brcm_sata_readreg(priv->top_ctrl +
-                                    SATA_TOP_CTRL_BUS_CTRL);
-       brcm_sata_writereg(bus_ctrl | OVERRIDE_HWINIT,
-                          priv->top_ctrl + SATA_TOP_CTRL_BUS_CTRL);
        host_caps = readl(hpriv->mmio + HOST_CAP);
-       writel(host_caps | HOST_CAP_ALPM, hpriv->mmio);
-       brcm_sata_writereg(bus_ctrl, priv->top_ctrl + SATA_TOP_CTRL_BUS_CTRL);
+       if (!(host_caps & HOST_CAP_ALPM))
+               hpriv->flags |= AHCI_HFLAG_YES_ALPM;
 
        /*
         * Adjust timeout to allow PLL sufficient time to lock while waking
@@ -360,6 +355,7 @@ static int brcm_ahci_probe(struct platform_device *pdev)
 
        if (priv->quirks & BRCM_AHCI_QUIRK_NO_NCQ)
                hpriv->flags |= AHCI_HFLAG_NO_NCQ;
+       hpriv->flags |= AHCI_HFLAG_NO_WRITE_TO_RO;
 
        ret = ahci_platform_init_host(pdev, hpriv, &ahci_brcm_port_info,
                                      &ahci_platform_sht);