mmc: sdhci: Add MSI interrupt support for O2 SD host
PATCH v5 3/3 mmc: sdhci: Add MSI interrupt support for O2 SD host
Add MSI interrupt support if the SD host device can support MSI interrupt.
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.
Changes in V3:
None. This patch is add in V4.
Changes in V2:
None. This patch is add in V4.
Changes in V1:
None. This patch is add in V4.
--- drivers/mmc/host/sdhci-pci-o2micro.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci-pci-o2micro.c +27 -3
@@ -358,11 +358,13 @@ int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot) {struct sdhci_pci_chip *chip;struct sdhci_host *host; +struct mmc_host *mmc;u32 reg;int ret; chip = slot->chip; host = slot->host; + mmc = host->mmc;switch (chip->pdev->device) {case PCI_DEVICE_ID_O2_SDS0 :case PCI_DEVICE_ID_O2_SEABIRD0 :
@@ -373,6 +375,28 @@ int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot)if (reg &0x1 ) host->quirks |=SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12 ; +if (pci_find_capability (chip->pdev,PCI_CAP_ID_MSI )) { + ret =pci_alloc_irq_vectors (chip->pdev,1 ,1 , +PCI_IRQ_MSI |PCI_IRQ_MSIX ); +if (ret ==1 ) { + ret =pci_irq_vector (chip->pdev,0 ); +if (ret >=0 ) { + host->irq = ret; +pr_info ("%s: use MSI irq, irq=%d\n" , +mmc_hostname (mmc), host->irq); + }else { +pr_err ("%s: failed to get device irq, err=%d\n" , +mmc_hostname (mmc), ret); + } + }else { +pr_err ("%s: enable PCI MSI failed, err=%d\n" , +mmc_hostname (mmc), ret); + } + }else { +pr_info ("%s: unsupport msi, use INTx irq\n" , +mmc_hostname (mmc)); + } +if (chip->pdev->device ==PCI_DEVICE_ID_O2_SEABIRD0 ) { ret =pci_read_config_dword (chip->pdev,O2_SD_MISC_SETTING , ®);
@@ -380,11 +404,11 @@ int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot)return -EIO ;if (reg & (1 <<4 )) {pr_info ("%s: emmc 1.8v flag is set, force 1.8v signaling voltage\n" , -mmc_hostname (host->mmc)); +mmc_hostname (mmc)); host->flags &= ~SDHCI_SIGNALING_330 ; host->flags |=SDHCI_SIGNALING_180 ; - host->mmc->caps2 |=MMC_CAP2_NO_SD ; - host->mmc->caps2 |=MMC_CAP2_NO_SDIO ; + mmc->caps2 |=MMC_CAP2_NO_SD ; + mmc->caps2 |=MMC_CAP2_NO_SDIO ; } }
Signature · 1 line
2.7.4
Adrian Hunter
maintainerQuoted 3 lines · ernest.zhang
Add MSI interrupt support if the SD host device can support MSI interrupt.
Changes in V5:
The change log goes below the --- line or in a separate cover email.
Quoted 55 lines
1. Because
pci_enable_msiis marked as deprecated and should not be used in new code, usepci_alloc_irq_vectorsinstead.
2. Remove unneededCONFIG_PCI_MSImacro checkChanges in V4:
Enable MSI interrupt if the MSI capability bit is set in capability register.Changes in V3:
None. This patch is add in V4.Changes in V2:
None. This patch is add in V4.Changes in V1:
None. This patch is add in V4.Signed-off-by ernest.zhang <[email protected]>--- drivers/mmc/host/sdhci-pci-o2micro.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-)drivers/mmc/host/sdhci-pci-o2micro.c +13
-0@@ -358,11 +358,13 @@ int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot) {struct sdhci_pci_chip *chip;struct sdhci_host *host; +struct mmc_host *mmc;u32 reg;int ret; chip = slot->chip; host = slot->host; + mmc = host->mmc;switch (chip->pdev->device) {case PCI_DEVICE_ID_O2_SDS0 :case PCI_DEVICE_ID_O2_SEABIRD0 :@@ -373,6 +375,28 @@ int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot)if (reg &0x1 ) host->quirks |=SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12 ; +if (pci_find_capability (chip->pdev,PCI_CAP_ID_MSI )) { + ret =pci_alloc_irq_vectors (chip->pdev,1 ,1 , +PCI_IRQ_MSI |PCI_IRQ_MSIX ); +if (ret ==1 ) { + ret =pci_irq_vector (chip->pdev,0 ); +if (ret >=0 ) { + host->irq = ret; +pr_info ("%s: use MSI irq, irq=%d\n" , +mmc_hostname (mmc), host->irq); + }else { + pr_err("%s: failed to get device irq, err=%d\n",
drivers/mmc/host/sdhci-pci-o2micro.c int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot) · line 398
Quoted 10 lines
drivers/mmc/host/sdhci-pci-o2micro.c +10
-0+ mmc_hostname(mmc), ret); + } + }else { +pr_err ("%s: enable PCI MSI failed, err=%d\n" , +mmc_hostname (mmc), ret); + } + }else { +pr_info ("%s: unsupport msi, use INTx irq\n" , +mmc_hostname (mmc)); + }
There seem to be more prints here than you really need. Please reduce them and make this a separate function.
drivers/mmc/host/sdhci-pci-o2micro.c int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot) · line 407
Quoted 10 lines
drivers/mmc/host/sdhci-pci-o2micro.c +2
-1+if (chip->pdev->device ==PCI_DEVICE_ID_O2_SEABIRD0 ) { ret =pci_read_config_dword (chip->pdev,O2_SD_MISC_SETTING , ®);@@ -380,11 +404,11 @@ int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot)return -EIO ;if (reg & (1 <<4 )) {pr_info ("%s: emmc 1.8v flag is set, force 1.8v signaling voltage\n" , -mmc_hostname (host->mmc)); +mmc_hostname (mmc));
The change from using 'host->mmc' to using local variable 'mmc' needs to be a separate patch.
drivers/mmc/host/sdhci-pci-o2micro.c int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot) · line 411
Quoted 6 lines
drivers/mmc/host/sdhci-pci-o2micro.c +2
-2host->flags &= ~SDHCI_SIGNALING_330 ; host->flags |=SDHCI_SIGNALING_180 ; - host->mmc->caps2 |=MMC_CAP2_NO_SD ; - host->mmc->caps2 |=MMC_CAP2_NO_SDIO ; + mmc->caps2 |=MMC_CAP2_NO_SD ; + mmc->caps2 |=MMC_CAP2_NO_SDIO ;
Ditto
Quoted 4 lines
drivers/mmc/host/sdhci-pci-o2micro.c +0
-0} }