mmc: host: sdhci-esdhc-imx: let usr to config the wakeup for gpio cd pin through sysfs
Subsystems (4)
[email protected]
maintainerPATCH 1/1 mmc: host: sdhci-esdhc-imx: let usr to config the wakeup for gpio cd pin through sysfs
From: Haibo Chen <[email protected]>
Currently default enable the gpio cd pin wakeup, this will waste power after system suspend if usr do not need this cd pin wakeup feature. Now let usr to config the wakeup for gpio cd pin through sysfs.
--- drivers/mmc/host/sdhci-esdhc-imx.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +10 -4
@@ -1797,9 +1797,12 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)/* * Setup the wakeup capability here, let user to decide * whether need to enable this wakeup through sysfs interface. +* First check the SDIO device, second check the gpio CD pin. */ -if ((host->mmc->pm_caps &MMC_PM_KEEP_POWER ) && - (host->mmc->pm_caps &MMC_PM_WAKE_SDIO_IRQ )) +if (((host->mmc->pm_caps &MMC_PM_KEEP_POWER ) && + (host->mmc->pm_caps &MMC_PM_WAKE_SDIO_IRQ )) || + ((host->mmc->caps &MMC_CAP_CD_WAKE ) && + host->mmc->slot.cd_irq >=0 ))device_set_wakeup_capable (&pdev->dev, true);pm_runtime_set_active (&pdev->dev);
@@ -1878,7 +1881,8 @@ static int sdhci_esdhc_suspend(struct device *dev)if (ret)return ret; - ret =mmc_gpio_set_cd_wake (host->mmc, true); +if (device_may_wakeup (dev)) + ret =mmc_gpio_set_cd_wake (host->mmc, true);return ret; }
@@ -1901,8 +1905,10 @@ static int sdhci_esdhc_resume(struct device *dev)if (host->mmc->caps2 &MMC_CAP2_CQE ) ret =cqhci_resume (host->mmc); +if (ret) +return ret; -if (!ret) +if (device_may_wakeup (dev)) ret =mmc_gpio_set_cd_wake (host->mmc, false);return ret;
Signature · 1 line
2.34.1
Quoted 20 lines · On Tue, 17 Oct 2023 at 09:26, <[email protected]> wrote:
From: Haibo Chen <[email protected]>
Currently default enable the gpio cd pin wakeup, this will waste power after system suspend if usr do not need this cd pin wakeup feature. Now let usr to config the wakeup for gpio cd pin through sysfs.
Signed-off-by Haibo Chen <[email protected]>--- drivers/mmc/host/sdhci-esdhc-imx.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)drivers/mmc/host/sdhci-esdhc-imx.c +0
-0@@ -1797,9 +1797,12 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)/* * Setup the wakeup capability here, let user to decide
drivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_imx_probe(struct platform_device *pdev) · line 1806
Quoted 10 lines
drivers/mmc/host/sdhci-esdhc-imx.c +5
-2* whether need to enable this wakeup through sysfs interface. +* First check the SDIO device, second check the gpio CD pin. */ -if ((host->mmc->pm_caps &MMC_PM_KEEP_POWER ) && - (host->mmc->pm_caps &MMC_PM_WAKE_SDIO_IRQ )) +if (((host->mmc->pm_caps &MMC_PM_KEEP_POWER ) && + (host->mmc->pm_caps &MMC_PM_WAKE_SDIO_IRQ )) || + ((host->mmc->caps &MMC_CAP_CD_WAKE ) && + host->mmc->slot.cd_irq >=0 ))device_set_wakeup_capable (&pdev->dev, true);
If the wakeup is GPIO based, it doesn't mean that the device is wakeup capable, so this is wrong.
In principle this must be managed through the GPIO irqchip driver instead.
drivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_suspend(struct device *dev) · line 1884
Quoted 8 lines
drivers/mmc/host/sdhci-esdhc-imx.c +1
-1pm_runtime_set_active (&pdev->dev);@@ -1878,7 +1881,8 @@ static int sdhci_esdhc_suspend(struct device *dev)if (ret)return ret; - ret =mmc_gpio_set_cd_wake (host->mmc, true); +if (device_may_wakeup (dev))
As I indicated above. It's not really the device that corresponds to the mmc controller that can wake up the system, but rather the gpio irqchip.
drivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_resume(struct device *dev) · line 1911
Quoted 13 lines
drivers/mmc/host/sdhci-esdhc-imx.c +4
-1+ ret =mmc_gpio_set_cd_wake (host->mmc, true);return ret; }@@ -1901,8 +1905,10 @@ static int sdhci_esdhc_resume(struct device *dev)if (host->mmc->caps2 &MMC_CAP2_CQE ) ret =cqhci_resume (host->mmc); +if (ret) +return ret; -if (!ret) +if (device_may_wakeup (dev))
Ditto.
Quoted 6 lines
drivers/mmc/host/sdhci-esdhc-imx.c +0
-1ret =mmc_gpio_set_cd_wake (host->mmc, false);return ret; --2.34.1
Kind regards
Uffe
Bough Chen
maintainerQuoted 41 lines
-----Original Message-----
From: Ulf Hansson <[email protected]>
Sent: 2023年10月17日 19:35
To: Bough Chen <[email protected]>
Cc: [email protected]; [email protected]; dl-linux-imx <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] mmc: host: sdhci-esdhc-imx: let usr to config the wakeup for gpio cd pin through sysfsdrivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_imx_probe(struct
Quoted 18 lines · On Tue, 17 Oct 2023 at 09:26, <[email protected]> wrote:
From: Haibo Chen <[email protected]>
Currently default enable the gpio cd pin wakeup, this will waste power after system suspend if usr do not need this cd pin wakeup feature. Now let usr to config the wakeup for gpio cd pin through sysfs.
Signed-off-by Haibo Chen <[email protected]>--- drivers/mmc/host/sdhci-esdhc-imx.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)drivers/mmc/host/sdhci-esdhc-imx.c +0
-0@@ -1797,9 +1797,12 @@ static int sdhci_esdhc_imx_probe(struct
platform_device*pdev)drivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
Quoted 7 lines
drivers/mmc/host/sdhci-esdhc-imx.c +1
-2/* * Setup the wakeup capability here, let user to decide * whether need to enable this wakeup through sysfs interface. +* First check the SDIO device, second check the gpio CD pin. */ - if ((host->mmc->pm_caps & MMC_PM_KEEP_POWER) && - (host->mmc->pm_caps &
MMC_PM_WAKE_SDIO_IRQ))drivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_imx_probe(struct · line 1803
Quoted 2 lines
drivers/mmc/host/sdhci-esdhc-imx.c +2
-0+ if (((host->mmc->pm_caps & MMC_PM_KEEP_POWER) && + (host->mmc->pm_caps &
MMC_PM_WAKE_SDIO_IRQ)) ||
Quoted 8 lines
drivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_imx_probe(struct platform_device *pdev) · line 1806
Quoted 3 lines
drivers/mmc/host/sdhci-esdhc-imx.c +2
-0+ ((host->mmc->caps & MMC_CAP_CD_WAKE) && + host->mmc->slot.cd_irq >= 0))device_set_wakeup_capable (&pdev->dev, true);If the wakeup is GPIO based, it doesn't mean that the device is wakeup capable, so this is wrong.
In principle this must be managed through the GPIO irqchip driver instead.
Yes, I know GPIO and USDHC are different device, combine GPIO wakeup to USDHC is not that reasonable. I send this patch because I notice there is similar code in sdhci-pci-core.c, refer to sdhci_pci_suspend_host()
Seems PCI subsystem combine GPIO wakeup to PCI controller.
Anyway, I will try to implement this in GPIO irqchip driver.
Best Regards
Haibo Chen
Quoted 39 lines
drivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_suspend(struct device *dev) · line 1884
Quoted 9 lines
drivers/mmc/host/sdhci-esdhc-imx.c +1
-1pm_runtime_set_active (&pdev->dev);@@ -1878,7 +1881,8 @@ static int sdhci_esdhc_suspend(struct device *dev)if (ret)return ret; - ret =mmc_gpio_set_cd_wake (host->mmc, true); +if (device_may_wakeup (dev))As I indicated above. It's not really the device that corresponds to the mmc controller that can wake up the system, but rather the gpio irqchip.
Quoted 5 lines
drivers/mmc/host/sdhci-esdhc-imx.c +1
-0+ ret =mmc_gpio_set_cd_wake (host->mmc, true);return ret; }drivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_resume(struct device · line 1912
Quoted 9 lines
drivers/mmc/host/sdhci-esdhc-imx.c +3
-1@@ -1901,8 +1905,10 @@ static int sdhci_esdhc_resume(struct device *dev)if (host->mmc->caps2 &MMC_CAP2_CQE ) ret =cqhci_resume (host->mmc); +if (ret) +return ret; -if (!ret) +if (device_may_wakeup (dev))Ditto.
Quoted 6 lines
drivers/mmc/host/sdhci-esdhc-imx.c +0
-0ret =mmc_gpio_set_cd_wake (host->mmc, false);return ret;--
2.34.1Kind regards
Uffe
Quoted 49 lines · Bough Chen
Quoted 49 lines
-----Original Message-----
From: Ulf Hansson <[email protected]>
Sent: 2023年10月17日 19:35
To: Bough Chen <[email protected]>
Cc: [email protected]; [email protected]; dl-linux-imx <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] mmc: host: sdhci-esdhc-imx: let usr to config the wakeup for gpio cd pin through sysfsdrivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_imx_probe(struct
Quoted 18 lines · On Tue, 17 Oct 2023 at 09:26, <[email protected]> wrote:
From: Haibo Chen <[email protected]>
Currently default enable the gpio cd pin wakeup, this will waste power after system suspend if usr do not need this cd pin wakeup feature. Now let usr to config the wakeup for gpio cd pin through sysfs.
Signed-off-by Haibo Chen <[email protected]>--- drivers/mmc/host/sdhci-esdhc-imx.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)drivers/mmc/host/sdhci-esdhc-imx.c +0
-0@@ -1797,9 +1797,12 @@ static int sdhci_esdhc_imx_probe(struct
platform_device*pdev)drivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
Quoted 7 lines
drivers/mmc/host/sdhci-esdhc-imx.c +1
-2/* * Setup the wakeup capability here, let user to decide * whether need to enable this wakeup through sysfs interface. +* First check the SDIO device, second check the gpio CD pin. */ - if ((host->mmc->pm_caps & MMC_PM_KEEP_POWER) && - (host->mmc->pm_caps &
MMC_PM_WAKE_SDIO_IRQ))drivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_imx_probe(struct · line 1803
Quoted 2 lines
drivers/mmc/host/sdhci-esdhc-imx.c +2
-0+ if (((host->mmc->pm_caps & MMC_PM_KEEP_POWER) && + (host->mmc->pm_caps &
MMC_PM_WAKE_SDIO_IRQ)) ||drivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_imx_probe(struct platform_device *pdev) · line 1806
Quoted 3 lines
drivers/mmc/host/sdhci-esdhc-imx.c +2
-0+ ((host->mmc->caps & MMC_CAP_CD_WAKE) && + host->mmc->slot.cd_irq >= 0))device_set_wakeup_capable (&pdev->dev, true);If the wakeup is GPIO based, it doesn't mean that the device is wakeup capable, so this is wrong.
Quoted 6 lines
Quoted 1 line
In principle this must be managed through the GPIO irqchip driver instead.
Yes, I know GPIO and USDHC are different device, combine GPIO wakeup to USDHC is not that reasonable. I send this patch because I notice there is similar code in
sdhci-pci-core.c, refer tosdhci_pci_suspend_host()Seems PCI subsystem combine GPIO wakeup to PCI controller.
Good point! I am not sure that is the correct way to do it either, but maybe it's fine for PCI based devices. Adrian probably knows this better.
The main problem I see with your approach, is that it may prevent a PM domain (genpd), if the USDHC device is attached to one, from being powered-off during system suspend. That would be wrong as the USDHC device doesn't need to stay powered-on to allow a GPIO to be configured as a system wakeup irq.
Quoted 2 lines
Anyway, I will try to implement this in GPIO irqchip driver.
That sounds like the right thing to do.
Although, it does mean that we won't be able to allow userspace to decide on a per GPIO pin/irq basis, if system wakeup should be enabled or disabled. As far as I know, we don't have a solution in place to support that.
[...]
Kind regards
Uffe
Adrian Hunter
maintainerQuoted 52 lines · Ulf Hansson
Quoted 51 lines · Bough Chen
Quoted 50 lines
-----Original Message-----
From: Ulf Hansson <[email protected]>
Sent: 2023年10月17日 19:35
To: Bough Chen <[email protected]>
Cc: [email protected]; [email protected]; dl-linux-imx <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] mmc: host: sdhci-esdhc-imx: let usr to config the wakeup for gpio cd pin through sysfsdrivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_imx_probe(struct
Quoted 18 lines · On Tue, 17 Oct 2023 at 09:26, <[email protected]> wrote:
From: Haibo Chen <[email protected]>
Currently default enable the gpio cd pin wakeup, this will waste power after system suspend if usr do not need this cd pin wakeup feature. Now let usr to config the wakeup for gpio cd pin through sysfs.
Signed-off-by Haibo Chen <[email protected]>--- drivers/mmc/host/sdhci-esdhc-imx.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)drivers/mmc/host/sdhci-esdhc-imx.c +0
-0@@ -1797,9 +1797,12 @@ static int sdhci_esdhc_imx_probe(struct
platform_device*pdev)drivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
Quoted 7 lines
drivers/mmc/host/sdhci-esdhc-imx.c +1
-2/* * Setup the wakeup capability here, let user to decide * whether need to enable this wakeup through sysfs interface. +* First check the SDIO device, second check the gpio CD pin. */ - if ((host->mmc->pm_caps & MMC_PM_KEEP_POWER) && - (host->mmc->pm_caps &
MMC_PM_WAKE_SDIO_IRQ))drivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_imx_probe(struct · line 1803
Quoted 2 lines
drivers/mmc/host/sdhci-esdhc-imx.c +2
-0+ if (((host->mmc->pm_caps & MMC_PM_KEEP_POWER) && + (host->mmc->pm_caps &
MMC_PM_WAKE_SDIO_IRQ)) ||drivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_imx_probe(struct platform_device *pdev) · line 1806
Quoted 3 lines
drivers/mmc/host/sdhci-esdhc-imx.c +2
-0+ ((host->mmc->caps & MMC_CAP_CD_WAKE) && + host->mmc->slot.cd_irq >= 0))device_set_wakeup_capable (&pdev->dev, true);If the wakeup is GPIO based, it doesn't mean that the device is wakeup capable, so this is wrong.
In principle this must be managed through the GPIO irqchip driver instead.
Quoted 8 lines
Quoted 4 lines
Yes, I know GPIO and USDHC are different device, combine GPIO wakeup to USDHC is not that reasonable. I send this patch because I notice there is similar code in
sdhci-pci-core.c, refer tosdhci_pci_suspend_host()Seems PCI subsystem combine GPIO wakeup to PCI controller.
Good point! I am not sure that is the correct way to do it either, but maybe it's fine for PCI based devices. Adrian probably knows this better.
PCI / ACPI layers handle configuration of wakeup signaling, so a device will be put to the appropriate power state. It won't be forced to be "on" by registering a wakeup source.
Quoted 21 lines
The main problem I see with your approach, is that it may prevent a PM domain (genpd), if the USDHC device is attached to one, from being powered-off during system suspend. That would be wrong as the USDHC device doesn't need to stay powered-on to allow a GPIO to be configured as a system wakeup irq.
Quoted 2 lines
Anyway, I will try to implement this in GPIO irqchip driver.
That sounds like the right thing to do.
Although, it does mean that we won't be able to allow userspace to decide on a per GPIO pin/irq basis, if system wakeup should be enabled or disabled. As far as I know, we don't have a solution in place to support that.
[...]
Kind regards
Uffe
Quoted 59 lines · Adrian Hunter
Quoted 57 lines · Ulf Hansson
Quoted 55 lines · Bough Chen
Quoted 42 lines
-----Original Message-----
From: Ulf Hansson <[email protected]>
Sent: 2023年10月17日 19:35
To: Bough Chen <[email protected]>
Cc: [email protected]; [email protected]; dl-linux-imx <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] mmc: host: sdhci-esdhc-imx: let usr to config the wakeup for gpio cd pin through sysfsdrivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_imx_probe(struct
Quoted 18 lines · On Tue, 17 Oct 2023 at 09:26, <[email protected]> wrote:
From: Haibo Chen <[email protected]>
Currently default enable the gpio cd pin wakeup, this will waste power after system suspend if usr do not need this cd pin wakeup feature. Now let usr to config the wakeup for gpio cd pin through sysfs.
Signed-off-by Haibo Chen <[email protected]>--- drivers/mmc/host/sdhci-esdhc-imx.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)drivers/mmc/host/sdhci-esdhc-imx.c +0
-0@@ -1797,9 +1797,12 @@ static int sdhci_esdhc_imx_probe(struct
platform_device*pdev)drivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
Quoted 7 lines
drivers/mmc/host/sdhci-esdhc-imx.c +1
-2/* * Setup the wakeup capability here, let user to decide * whether need to enable this wakeup through sysfs interface. +* First check the SDIO device, second check the gpio CD pin. */ - if ((host->mmc->pm_caps & MMC_PM_KEEP_POWER) && - (host->mmc->pm_caps &
MMC_PM_WAKE_SDIO_IRQ))drivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_imx_probe(struct · line 1803
Quoted 2 lines
drivers/mmc/host/sdhci-esdhc-imx.c +2
-0+ if (((host->mmc->pm_caps & MMC_PM_KEEP_POWER) && + (host->mmc->pm_caps &
MMC_PM_WAKE_SDIO_IRQ)) ||Quoted 8 lines
drivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_imx_probe(struct platform_device *pdev) · line 1806
Quoted 3 lines
drivers/mmc/host/sdhci-esdhc-imx.c +2
-0+ ((host->mmc->caps & MMC_CAP_CD_WAKE) && + host->mmc->slot.cd_irq >= 0))device_set_wakeup_capable (&pdev->dev, true);If the wakeup is GPIO based, it doesn't mean that the device is wakeup capable, so this is wrong.
In principle this must be managed through the GPIO irqchip driver instead.
Yes, I know GPIO and USDHC are different device, combine GPIO wakeup to USDHC is not that reasonable. I send this patch because I notice there is similar code in
sdhci-pci-core.c, refer tosdhci_pci_suspend_host()Seems PCI subsystem combine GPIO wakeup to PCI controller.
Quoted 8 lines
Quoted 3 lines
Good point! I am not sure that is the correct way to do it either, but maybe it's fine for PCI based devices. Adrian probably knows this better.
PCI / ACPI layers handle configuration of wakeup signaling, so a device will be put to the appropriate power state. It won't be forced to be "on" by registering a wakeup source.
Okay, I see.
So you are saying that PCI bus/layers are aware of the GPIO pin/irq being used for wakeup for the device in question?
Kind regards
Uffe
Adrian Hunter
maintainerQuoted 69 lines · Ulf Hansson
Quoted 59 lines · Adrian Hunter
Quoted 57 lines · Ulf Hansson
Quoted 55 lines · Bough Chen
Quoted 42 lines
-----Original Message-----
From: Ulf Hansson <[email protected]>
Sent: 2023年10月17日 19:35
To: Bough Chen <[email protected]>
Cc: [email protected]; [email protected]; dl-linux-imx <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] mmc: host: sdhci-esdhc-imx: let usr to config the wakeup for gpio cd pin through sysfsdrivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_imx_probe(struct
Quoted 18 lines · On Tue, 17 Oct 2023 at 09:26, <[email protected]> wrote:
From: Haibo Chen <[email protected]>
Currently default enable the gpio cd pin wakeup, this will waste power after system suspend if usr do not need this cd pin wakeup feature. Now let usr to config the wakeup for gpio cd pin through sysfs.
Signed-off-by Haibo Chen <[email protected]>--- drivers/mmc/host/sdhci-esdhc-imx.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)drivers/mmc/host/sdhci-esdhc-imx.c +0
-0@@ -1797,9 +1797,12 @@ static int sdhci_esdhc_imx_probe(struct
platform_device*pdev)drivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
Quoted 7 lines
drivers/mmc/host/sdhci-esdhc-imx.c +1
-2/* * Setup the wakeup capability here, let user to decide * whether need to enable this wakeup through sysfs interface. +* First check the SDIO device, second check the gpio CD pin. */ - if ((host->mmc->pm_caps & MMC_PM_KEEP_POWER) && - (host->mmc->pm_caps &
MMC_PM_WAKE_SDIO_IRQ))drivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_imx_probe(struct · line 1803
Quoted 2 lines
drivers/mmc/host/sdhci-esdhc-imx.c +2
-0+ if (((host->mmc->pm_caps & MMC_PM_KEEP_POWER) && + (host->mmc->pm_caps &
MMC_PM_WAKE_SDIO_IRQ)) ||Quoted 8 lines
drivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_imx_probe(struct platform_device *pdev) · line 1806
Quoted 3 lines
drivers/mmc/host/sdhci-esdhc-imx.c +2
-0+ ((host->mmc->caps & MMC_CAP_CD_WAKE) && + host->mmc->slot.cd_irq >= 0))device_set_wakeup_capable (&pdev->dev, true);If the wakeup is GPIO based, it doesn't mean that the device is wakeup capable, so this is wrong.
In principle this must be managed through the GPIO irqchip driver instead.
Yes, I know GPIO and USDHC are different device, combine GPIO wakeup to USDHC is not that reasonable. I send this patch because I notice there is similar code in
sdhci-pci-core.c, refer tosdhci_pci_suspend_host()Seems PCI subsystem combine GPIO wakeup to PCI controller.
Quoted 8 lines
Quoted 3 lines
Good point! I am not sure that is the correct way to do it either, but maybe it's fine for PCI based devices. Adrian probably knows this better.
PCI / ACPI layers handle configuration of wakeup signaling, so a device will be put to the appropriate power state. It won't be forced to be "on" by registering a wakeup source.
Quoted 4 lines
Okay, I see.
So you are saying that PCI bus/layers are aware of the GPIO pin/irq being used for wakeup for the device in question?
No, it is more like PCI / ACPI take care of most things but the wakeup framework provides sysfs wakeup API. We can add that and use it to determine if wakeup is enabled (by the user) to then enable the CD GPIO IRQ wakeup. That way, the sysfs wakeup API is on the correct device, and the user doesn't need to know anything about GPIO.
Quoted 76 lines · Adrian Hunter
Quoted 69 lines · Ulf Hansson
Quoted 59 lines · Adrian Hunter
Quoted 57 lines · Ulf Hansson
Quoted 55 lines · Bough Chen
Quoted 42 lines
-----Original Message-----
From: Ulf Hansson <[email protected]>
Sent: 2023年10月17日 19:35
To: Bough Chen <[email protected]>
Cc: [email protected]; [email protected]; dl-linux-imx <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] mmc: host: sdhci-esdhc-imx: let usr to config the wakeup for gpio cd pin through sysfsdrivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_imx_probe(struct
Quoted 18 lines · On Tue, 17 Oct 2023 at 09:26, <[email protected]> wrote:
From: Haibo Chen <[email protected]>
Currently default enable the gpio cd pin wakeup, this will waste power after system suspend if usr do not need this cd pin wakeup feature. Now let usr to config the wakeup for gpio cd pin through sysfs.
Signed-off-by Haibo Chen <[email protected]>--- drivers/mmc/host/sdhci-esdhc-imx.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)drivers/mmc/host/sdhci-esdhc-imx.c +0
-0@@ -1797,9 +1797,12 @@ static int sdhci_esdhc_imx_probe(struct
platform_device*pdev)drivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_imx_probe(struct · line 1802
Quoted 7 lines
drivers/mmc/host/sdhci-esdhc-imx.c +1
-2/* * Setup the wakeup capability here, let user to decide * whether need to enable this wakeup through sysfs interface. +* First check the SDIO device, second check the gpio CD pin. */ - if ((host->mmc->pm_caps & MMC_PM_KEEP_POWER) && - (host->mmc->pm_caps &
MMC_PM_WAKE_SDIO_IRQ))drivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_imx_probe(struct · line 1803
Quoted 2 lines
drivers/mmc/host/sdhci-esdhc-imx.c +2
-0+ if (((host->mmc->pm_caps & MMC_PM_KEEP_POWER) && + (host->mmc->pm_caps &
MMC_PM_WAKE_SDIO_IRQ)) ||Quoted 8 lines
drivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_imx_probe(struct · line 1806
Quoted 3 lines
drivers/mmc/host/sdhci-esdhc-imx.c +2
-0+ ((host->mmc->caps & MMC_CAP_CD_WAKE) && + host->mmc->slot.cd_irq >= 0))device_set_wakeup_capable (&pdev->dev, true);If the wakeup is GPIO based, it doesn't mean that the device is wakeup capable, so this is wrong.
In principle this must be managed through the GPIO irqchip driver instead.
Yes, I know GPIO and USDHC are different device, combine GPIO wakeup to USDHC is not that reasonable. I send this patch because I notice there is similar code in
sdhci-pci-core.c, refer tosdhci_pci_suspend_host()Seems PCI subsystem combine GPIO wakeup to PCI controller.
Quoted 8 lines
Quoted 3 lines
Good point! I am not sure that is the correct way to do it either, but maybe it's fine for PCI based devices. Adrian probably knows this better.
PCI / ACPI layers handle configuration of wakeup signaling, so a device will be put to the appropriate power state. It won't be forced to be "on" by registering a wakeup source.
Quoted 4 lines
Okay, I see.
So you are saying that PCI bus/layers are aware of the GPIO pin/irq being used for wakeup for the device in question?
Quoted 7 lines
No, it is more like PCI / ACPI take care of most things but the wakeup framework provides sysfs wakeup API. We can add that and use it to determine if wakeup is enabled (by the user) to then enable the CD GPIO IRQ wakeup. That way, the sysfs wakeup API is on the correct device, and the user doesn't need to know anything about GPIO.
Okay, so it's really ACPI that is needed here too. Anyway, thanks for sharing!
Kind regards
Uffe