thermal: rockchip: rk3368: ajust tsadc's data path according request of qos
[firefly-linux-kernel-4.4.55.git] / drivers / scsi / aacraid / comminit.c
index b4b6088fcb332b2ace109dd4cae98a11fd8a13b4..26d38b1a45ab9b7a4a3cb43065a2d3aa21db733d 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/spinlock.h>
 #include <linux/slab.h>
 #include <linux/blkdev.h>
+#include <linux/delay.h>
 #include <linux/completion.h>
 #include <linux/mm.h>
 #include <scsi/scsi_host.h>
@@ -47,6 +48,24 @@ struct aac_common aac_config = {
        .irq_mod = 1
 };
 
+static inline int aac_is_msix_mode(struct aac_dev *dev)
+{
+       u32 status = 0;
+
+       if (dev->pdev->device == PMC_DEVICE_S6 ||
+               dev->pdev->device == PMC_DEVICE_S7 ||
+               dev->pdev->device == PMC_DEVICE_S8) {
+               status = src_readl(dev, MUnit.OMR);
+       }
+       return (status & AAC_INT_MODE_MSIX);
+}
+
+static inline void aac_change_to_intx(struct aac_dev *dev)
+{
+       aac_src_access_devreg(dev, AAC_DISABLE_MSIX);
+       aac_src_access_devreg(dev, AAC_ENABLE_INTX);
+}
+
 static int aac_alloc_comm(struct aac_dev *dev, void **commaddr, unsigned long commsize, unsigned long commalign)
 {
        unsigned char *base;
@@ -338,7 +357,7 @@ static int aac_comm_init(struct aac_dev * dev)
 
 void aac_define_int_mode(struct aac_dev *dev)
 {
-       int i, msi_count;
+       int i, msi_count, min_msix;
 
        msi_count = i = 0;
        /* max. vectors from GET_COMM_PREFERRED_SETTINGS */
@@ -366,22 +385,14 @@ void aac_define_int_mode(struct aac_dev *dev)
 
        if (msi_count > 1 &&
            pci_find_capability(dev->pdev, PCI_CAP_ID_MSIX)) {
-               i = pci_enable_msix(dev->pdev,
+               min_msix = 2;
+               i = pci_enable_msix_range(dev->pdev,
                                    dev->msixentry,
+                                   min_msix,
                                    msi_count);
-                /* Check how many MSIX vectors are allocated */
-               if (i >= 0) {
+               if (i > 0) {
                        dev->msi_enabled = 1;
-                       if (i) {
-                               msi_count = i;
-                               if (pci_enable_msix(dev->pdev,
-                                   dev->msixentry,
-                                   msi_count)) {
-                                       dev->msi_enabled = 0;
-                                       printk(KERN_ERR "%s%d: MSIX not supported!! Will try MSI 0x%x.\n",
-                                                       dev->name, dev->id, i);
-                               }
-                       }
+                       msi_count = i;
                } else {
                        dev->msi_enabled = 0;
                        printk(KERN_ERR "%s%d: MSIX not supported!! Will try MSI 0x%x.\n",
@@ -433,6 +444,15 @@ struct aac_dev *aac_init_adapter(struct aac_dev *dev)
        dev->comm_interface = AAC_COMM_PRODUCER;
        dev->raw_io_interface = dev->raw_io_64 = 0;
 
+
+       /*
+        * Enable INTX mode, if not done already Enabled
+        */
+       if (aac_is_msix_mode(dev)) {
+               aac_change_to_intx(dev);
+               dev_info(&dev->pdev->dev, "Changed firmware to INTX mode");
+       }
+
        if ((!aac_adapter_sync_cmd(dev, GET_ADAPTER_PROPERTIES,
                0, 0, 0, 0, 0, 0,
                status+0, status+1, status+2, status+3, NULL)) &&