mmc: sdhci: update check code for cd-broken or nonremovable card
PATCH v2 1/1 mmc: sdhci: update check code for cd-broken or nonremovable card
in function sdhci_request:
1. If quirk SDHCI_QUIRK_BROKEN_CARD_DETECTION is selected, there is no card detection available and polling must be used. Gpio detect must _not_ be supported under this case.
Change the sequence to check SDHCI_QUIRK_BROKEN_CARD_DETECTION first, which make code more clear.
2. nonremovable card should be also assumed always present.
in function sdhci_enable_irq_wakeups:
1. nonremovable card should be also assumed no insert/remove wakeup needed like some sdio cards which is nonremovable and can wakeup host only by card int.
--- drivers/mmc/host/sdhci.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-)
drivers/mmc/host/sdhci.c +16 -14
@@ -1337,19 +1337,20 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) host->mrq = mrq; -/* -* Firstly check card presence from cd-gpio. The return could -* be one of the following possibilities: -* negative: cd-gpio is not available -* zero: cd-gpio is used, and card is removed -* one: cd-gpio is used, and card is present -*/ - present =mmc_gpio_get_cd (host->mmc); -if (present <0 ) { -/* If polling, assume that the card is always present. */ -if (host->quirks &SDHCI_QUIRK_BROKEN_CARD_DETECTION ) - present =1 ; -else +/* If polling/nonremovable, assume that the card is always present. */ +if ((host->quirks &SDHCI_QUIRK_BROKEN_CARD_DETECTION ) || + (host->mmc->caps &MMC_CAP_NONREMOVABLE )) { + present =1 ; + }else { +/* +* Firstly check card presence from cd-gpio. The return could +* be one of the following possibilities: +* negative: cd-gpio is not available +* zero: cd-gpio is used, and card is removed +* one: cd-gpio is used, and card is present +*/ + present =mmc_gpio_get_cd (host->mmc); +if (IS_ERR_VALUE (present)) present =sdhci_readl (host,SDHCI_PRESENT_STATE ) &SDHCI_CARD_PRESENT ; }
@@ -2504,7 +2505,8 @@ void sdhci_enable_irq_wakeups(struct sdhci_host *host) val =sdhci_readb (host,SDHCI_WAKE_UP_CONTROL ); val |= mask ;/* Avoid fake wake up */ -if (host->quirks &SDHCI_QUIRK_BROKEN_CARD_DETECTION ) +if ((host->quirks &SDHCI_QUIRK_BROKEN_CARD_DETECTION ) || + (host->mmc->caps &MMC_CAP_NONREMOVABLE )) val &= ~(SDHCI_WAKE_ON_INSERT |SDHCI_WAKE_ON_REMOVE );sdhci_writeb (host, val,SDHCI_WAKE_UP_CONTROL ); }
Signature · 1 line
1.7.9.5
Quoted 45 lines · Kevin Liu
in function
sdhci_request:
1. If quirkSDHCI_QUIRK_BROKEN_CARD_DETECTIONis selected, there is no card detection available and polling must be used. Gpio detect must _not_ be supported under this case.
Change the sequence to checkSDHCI_QUIRK_BROKEN_CARD_DETECTIONfirst, which make code more clear.
2. nonremovable card should be also assumed always present.in function
sdhci_enable_irq_wakeups:
1. nonremovable card should be also assumed no insert/remove wakeup needed like some sdio cards which is nonremovable and can wakeup host only by card int.Signed-off-by Kevin Liu <[email protected]>---
drivers/mmc/host/sdhci.c| 30 ++++++++++++++++--------------1 file changed, 16 insertions(+), 14 deletions(-)drivers/mmc/host/sdhci.c +6
-13@@ -1337,19 +1337,20 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) host->mrq = mrq; -/* -* Firstly check card presence from cd-gpio. The return could -* be one of the following possibilities: -* negative: cd-gpio is not available -* zero: cd-gpio is used, and card is removed -* one: cd-gpio is used, and card is present -*/ - present =mmc_gpio_get_cd (host->mmc); -if (present <0 ) { -/* If polling, assume that the card is always present. */ -if (host->quirks &SDHCI_QUIRK_BROKEN_CARD_DETECTION ) - present =1 ; -else +/* If polling/nonremovable, assume that the card is always present. */ +if ((host->quirks &SDHCI_QUIRK_BROKEN_CARD_DETECTION ) || + (host->mmc->caps &MMC_CAP_NONREMOVABLE )) { + present =1 ; + }else { +/*
drivers/mmc/host/sdhci.c static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) · line 1355
Quoted 10 lines
drivers/mmc/host/sdhci.c +8
-0+* Firstly check card presence from cd-gpio. The return could +* be one of the following possibilities: +* negative: cd-gpio is not available +* zero: cd-gpio is used, and card is removed +* one: cd-gpio is used, and card is present +*/ + present =mmc_gpio_get_cd (host->mmc); +if (IS_ERR_VALUE (present)) present =sdhci_readl (host,SDHCI_PRESENT_STATE ) &SDHCI_CARD_PRESENT ;
Hi Kevin
does it make sense to move this logic to a more generic function (static inline ?) int sdhci_card_present ()
and encapsulate all the logic there for gpio cd, present state (card is there) etc.
Philip
Quoted 14 lines
drivers/mmc/host/sdhci.c +2
-1}@@ -2504,7 +2505,8 @@ void sdhci_enable_irq_wakeups(struct sdhci_host *host) val =sdhci_readb (host,SDHCI_WAKE_UP_CONTROL ); val |= mask ;/* Avoid fake wake up */ -if (host->quirks &SDHCI_QUIRK_BROKEN_CARD_DETECTION ) +if ((host->quirks &SDHCI_QUIRK_BROKEN_CARD_DETECTION ) || + (host->mmc->caps &MMC_CAP_NONREMOVABLE )) val &= ~(SDHCI_WAKE_ON_INSERT |SDHCI_WAKE_ON_REMOVE );sdhci_writeb (host, val,SDHCI_WAKE_UP_CONTROL ); }Signature · 1 line
1.7.9.5
2013/3/1 Philip Rakity <[email protected]>:
Quoted 61 lines · Kevin Liu
Quoted 46 lines
in function
sdhci_request:
1. If quirkSDHCI_QUIRK_BROKEN_CARD_DETECTIONis selected, there is no card detection available and polling must be used. Gpio detect must _not_ be supported under this case.
Change the sequence to checkSDHCI_QUIRK_BROKEN_CARD_DETECTIONfirst, which make code more clear.
2. nonremovable card should be also assumed always present.in function
sdhci_enable_irq_wakeups:
1. nonremovable card should be also assumed no insert/remove wakeup needed like some sdio cards which is nonremovable and can wakeup host only by card int.Signed-off-by Kevin Liu <[email protected]>---
drivers/mmc/host/sdhci.c| 30 ++++++++++++++++--------------1 file changed, 16 insertions(+), 14 deletions(-)drivers/mmc/host/sdhci.c +6
-13@@ -1337,19 +1337,20 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) host->mrq = mrq; -/* -* Firstly check card presence from cd-gpio. The return could -* be one of the following possibilities: -* negative: cd-gpio is not available -* zero: cd-gpio is used, and card is removed -* one: cd-gpio is used, and card is present -*/ - present =mmc_gpio_get_cd (host->mmc); -if (present <0 ) { -/* If polling, assume that the card is always present. */ -if (host->quirks &SDHCI_QUIRK_BROKEN_CARD_DETECTION ) - present =1 ; -else +/* If polling/nonremovable, assume that the card is always present. */ +if ((host->quirks &SDHCI_QUIRK_BROKEN_CARD_DETECTION ) || + (host->mmc->caps &MMC_CAP_NONREMOVABLE )) { + present =1 ; + }else { +/* drivers/mmc/host/sdhci.c static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) · line 1355
Quoted 10 lines
drivers/mmc/host/sdhci.c +8
-0+* Firstly check card presence from cd-gpio. The return could +* be one of the following possibilities: +* negative: cd-gpio is not available +* zero: cd-gpio is used, and card is removed +* one: cd-gpio is used, and card is present +*/ + present =mmc_gpio_get_cd (host->mmc); +if (IS_ERR_VALUE (present)) present =sdhci_readl (host,SDHCI_PRESENT_STATE ) &SDHCI_CARD_PRESENT ;Hi Kevin
Quoted 7 lines
does it make sense to move this logic to a more generic function (static inline ?) int
sdhci_card_present()and encapsulate all the logic there for gpio cd, present state (card is there) etc.
Philip
Philip,
Good idea...Will call the function "sdhci_do_get_cd" introdunced in my previous patch. Thanks!
Kevin
Quoted 15 lines
Quoted 14 lines
drivers/mmc/host/sdhci.c +2
-2}@@ -2504,7 +2505,8 @@ void sdhci_enable_irq_wakeups(struct sdhci_host *host) val =sdhci_readb (host,SDHCI_WAKE_UP_CONTROL ); val |= mask ;/* Avoid fake wake up */ -if (host->quirks &SDHCI_QUIRK_BROKEN_CARD_DETECTION ) +if ((host->quirks &SDHCI_QUIRK_BROKEN_CARD_DETECTION ) || + (host->mmc->caps &MMC_CAP_NONREMOVABLE )) val &= ~(SDHCI_WAKE_ON_INSERT |SDHCI_WAKE_ON_REMOVE );sdhci_writeb (host, val,SDHCI_WAKE_UP_CONTROL ); } --1.7.9.5
2013/3/1 Kevin Liu <[email protected]>:
Quoted 67 lines
2013/3/1 Philip Rakity <[email protected]>:
Quoted 66 lines · Kevin Liu
Quoted 46 lines
in function
sdhci_request:
1. If quirkSDHCI_QUIRK_BROKEN_CARD_DETECTIONis selected, there is no card detection available and polling must be used. Gpio detect must _not_ be supported under this case.
Change the sequence to checkSDHCI_QUIRK_BROKEN_CARD_DETECTIONfirst, which make code more clear.
2. nonremovable card should be also assumed always present.in function
sdhci_enable_irq_wakeups:
1. nonremovable card should be also assumed no insert/remove wakeup needed like some sdio cards which is nonremovable and can wakeup host only by card int.Signed-off-by Kevin Liu <[email protected]>---
drivers/mmc/host/sdhci.c| 30 ++++++++++++++++--------------1 file changed, 16 insertions(+), 14 deletions(-)drivers/mmc/host/sdhci.c +6
-13@@ -1337,19 +1337,20 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) host->mrq = mrq; -/* -* Firstly check card presence from cd-gpio. The return could -* be one of the following possibilities: -* negative: cd-gpio is not available -* zero: cd-gpio is used, and card is removed -* one: cd-gpio is used, and card is present -*/ - present =mmc_gpio_get_cd (host->mmc); -if (present <0 ) { -/* If polling, assume that the card is always present. */ -if (host->quirks &SDHCI_QUIRK_BROKEN_CARD_DETECTION ) - present =1 ; -else +/* If polling/nonremovable, assume that the card is always present. */ +if ((host->quirks &SDHCI_QUIRK_BROKEN_CARD_DETECTION ) || + (host->mmc->caps &MMC_CAP_NONREMOVABLE )) { + present =1 ; + }else { +/* drivers/mmc/host/sdhci.c static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) · line 1355
Quoted 10 lines
drivers/mmc/host/sdhci.c +8
-0+* Firstly check card presence from cd-gpio. The return could +* be one of the following possibilities: +* negative: cd-gpio is not available +* zero: cd-gpio is used, and card is removed +* one: cd-gpio is used, and card is present +*/ + present =mmc_gpio_get_cd (host->mmc); +if (IS_ERR_VALUE (present)) present =sdhci_readl (host,SDHCI_PRESENT_STATE ) &SDHCI_CARD_PRESENT ;Hi Kevin
does it make sense to move this logic to a more generic function (static inline ?) int
sdhci_card_present()and encapsulate all the logic there for gpio cd, present state (card is there) etc.
Quoted 8 lines
Quoted 2 lines
Philip
Philip,
Good idea...Will call the function "
sdhci_do_get_cd" introdunced in my previous patch. Thanks!
This patch has been updated and added to below patchset. [PATCH 0/3] mmc: core/sdhci: enhance card detect code ([PATCH v3 3/3]
mmc: sdhci: update check code for cd-broken or)
So it can be ignored.
Thanks
Kevin