@@ -96,7 +96,8 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev)
struct sh_mobile_sdhi_info *p = pdev->dev.platform_data;
struct tmio_mmc_host *host;
char clk_name[8];
- int i, irq, ret;
+ int irq, ret, irq_count = 0;
+ irqreturn_t (*f)(int irq, void *devid);
priv = kzalloc(sizeof(struct sh_mobile_sdhi), GFP_KERNEL);
if (priv == NULL) {
@@ -153,27 +154,39 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev)
if (ret < 0)
goto eprobe;
- for (i = 0; i < 3; i++) {
- irq = platform_get_irq(pdev, i);
- if (irq < 0) {
- if (i) {
- continue;
- } else {
- ret = irq;
- goto eirq;
- }
- }
- ret = request_irq(irq, tmio_mmc_irq, 0,
+ /* Allow a single IRQ resource #0 (CARD_DETECT) which will
+ * use tmio_mmc_irq() or;
+ * Allow 2 or 3 IRQ resources in which case SDCARD is required
+ * and specialised ISRs are used.
+ */
+ irq = platform_get_irq(pdev, SH_MOBILE_SDHI_IRQ_SDCARD);
+ if (irq >= 0) {
+ irq_count++;
+ ret = request_irq(irq, tmio_mmc_sdcard_irq, 0,
dev_name(&pdev->dev), host);
- if (ret) {
- while (i--) {
- irq = platform_get_irq(pdev, i);
- if (irq >= 0)
- free_irq(irq, host);
- }
- goto eirq;
- }
+ if (ret)
+ goto eirq_sdcard;
}
+
+ ret = irq = platform_get_irq(pdev, SH_MOBILE_SDHI_IRQ_SDIO);
+ if (irq_count && irq >= 0) {
+ irq_count++;
+ ret = request_irq(irq, tmio_mmc_sdio_irq, 0,
+ dev_name(&pdev->dev), host);
+ if (ret)
+ goto eirq_sdio;
+ } else if (!irq_count)
+ goto eirq_sdio;
+
+ ret = irq = platform_get_irq(pdev, SH_MOBILE_SDHI_IRQ_CARD_DETECT);
+ if (irq >= 0) {
+ f = irq_count ? tmio_mmc_card_detect_irq : tmio_mmc_irq;
+ ret = request_irq(irq, f, 0, dev_name(&pdev->dev), host);
+ if (ret)
+ goto eirq_card_detect;
+ } else if (irq_count < 2)
+ goto eirq_card_detect;
+
dev_info(&pdev->dev, "%s base at 0x%08lx clock rate %u MHz\n",
mmc_hostname(host->mmc), (unsigned long)
(platform_get_resource(pdev,IORESOURCE_MEM, 0)->start),
@@ -181,7 +194,15 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev)
return ret;
-eirq:
+eirq_card_detect:
+ irq = platform_get_irq(pdev, SH_MOBILE_SDHI_IRQ_SDIO);
+ if (irq >= 0)
+ free_irq(irq, host);
+eirq_sdio:
+ irq = platform_get_irq(pdev, SH_MOBILE_SDHI_IRQ_SDCARD);
+ if (irq >= 0)
+ free_irq(irq, host);
+eirq_sdcard:
tmio_mmc_host_remove(host);
eprobe:
clk_disable(priv->clk);
@@ -203,7 +224,7 @@ static int sh_mobile_sdhi_remove(struct platform_device *pdev)
tmio_mmc_host_remove(host);
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < SH_MOBILE_SDHI_IRQ_MAX; i++) {
irq = platform_get_irq(pdev, i);
if (irq >= 0)
free_irq(irq, host);
@@ -3,6 +3,13 @@
#include <linux/types.h>
+enum {
+ SH_MOBILE_SDHI_IRQ_CARD_DETECT = 0,
+ SH_MOBILE_SDHI_IRQ_SDCARD,
+ SH_MOBILE_SDHI_IRQ_SDIO,
+ SH_MOBILE_SDHI_IRQ_MAX
+};
+
struct platform_device;
struct tmio_mmc_data;