From mboxrd@z Thu Jan 1 00:00:00 1970 From: "ernest.zhang" Subject: [PATCH V6 3/3] mmc: sdhci: Add MSI interrupt support for O2 SD host Date: Tue, 26 Jun 2018 23:46:47 +0800 Message-ID: <20180626154647.11623-3-ernest.zhang@bayhubtech.com> References: <20180626154647.11623-1-ernest.zhang@bayhubtech.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: In-Reply-To: <20180626154647.11623-1-ernest.zhang@bayhubtech.com> Sender: linux-kernel-owner@vger.kernel.org To: Adrian Hunter , Ulf Hansson , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: ernest.zhang@bayhubtech.com, chuanjin.pang@bayhubtech.com, mike.li@bayhubtech.com, chevron.li@bayhubtech.com, shirley.her@bayhubtech.com, xiaoguang.yu@bayhubtech.com, bobby.wu@bayhubtech.com List-Id: linux-mmc@vger.kernel.org Add MSI interrupt support if the SD host device can support MSI interrupt. Signed-off-by: ernest.zhang --- Changes in V6: 1. Move change log to correct place. 2. Reduce unneeded pr_info prints. 3. In function sdhci_pci_o2_probe_slot, remove using local variable 'mmc' instead of using 'host->mmc'. 3. Make the msi enable code a sperate function. Changes in V5: 1. Because pci_enable_msi is marked as deprecated and should not be used in new code, use pci_alloc_irq_vectors instead. 2. Remove unneeded CONFIG_PCI_MSI macro check. Changes in V4: Enable MSI interrupt if the MSI capability bit is set in capability register. --- drivers/mmc/host/sdhci-pci-o2micro.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/mmc/host/sdhci-pci-o2micro.c b/drivers/mmc/host/sdhci-pci-o2micro.c index 7747e8b..56bc717 100644 --- a/drivers/mmc/host/sdhci-pci-o2micro.c +++ b/drivers/mmc/host/sdhci-pci-o2micro.c @@ -260,6 +260,29 @@ static void sdhci_pci_o2_fujin2_pci_init(struct sdhci_pci_chip *chip) pci_write_config_dword(chip->pdev, O2_SD_MISC_CTRL4, scratch_32); } +static void sdhci_pci_o2_enable_msi(struct sdhci_pci_chip *chip, + struct sdhci_host *host) +{ + int ret; + + ret = pci_find_capability(chip->pdev, PCI_CAP_ID_MSI); + if (!ret) { + pr_info("%s: unsupport msi, use INTx irq\n", + mmc_hostname(host->mmc)); + return; + } + + ret = pci_alloc_irq_vectors(chip->pdev, 1, 1, + PCI_IRQ_MSI | PCI_IRQ_MSIX); + if (ret < 0) { + pr_err("%s: enable PCI MSI failed, err=%d\n", + mmc_hostname(host->mmc), ret); + return; + } + + host->irq = pci_irq_vector(chip->pdev, 0); +} + int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot) { struct sdhci_pci_chip *chip; @@ -279,6 +302,8 @@ int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot) if (reg & 0x1) host->quirks |= SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12; + sdhci_pci_o2_enable_msi(chip, host); + if (chip->pdev->device == PCI_DEVICE_ID_O2_SEABIRD0) { ret = pci_read_config_dword(chip->pdev, O2_SD_MISC_SETTING, ®); -- 2.7.4