Message ID | 20230331105546.13607-21-victor.shih@genesyslogic.com.tw (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Add support UHS-II for GL9755 | expand |
On 31/03/23 13:55, Victor Shih wrote: > This is a UHS-II version of sdhci's add_host/remove_host operation. > Any sdhci drivers which are capable of handling UHS-II cards must > call those functions instead of the corresponding sdhci's. > > Signed-off-by: Ben Chuang <ben.chuang@genesyslogic.com.tw> > Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> > Signed-off-by: Victor Shih <victor.shih@genesyslogic.com.tw> > --- > drivers/mmc/host/sdhci-uhs2.c | 119 ++++++++++++++++++++++++++++++++++ > drivers/mmc/host/sdhci-uhs2.h | 2 + > drivers/mmc/host/sdhci.c | 7 +- > drivers/mmc/host/sdhci.h | 3 + > 4 files changed, 129 insertions(+), 2 deletions(-) > > diff --git a/drivers/mmc/host/sdhci-uhs2.c b/drivers/mmc/host/sdhci-uhs2.c > index 63f4bfce70b8..610780d425bc 100644 > --- a/drivers/mmc/host/sdhci-uhs2.c > +++ b/drivers/mmc/host/sdhci-uhs2.c > @@ -17,6 +17,7 @@ > #include <linux/ktime.h> > #include <linux/mmc/mmc.h> > #include <linux/mmc/host.h> > +#include <linux/regulator/consumer.h> > > #include "sdhci.h" > #include "sdhci-uhs2.h" > @@ -1004,6 +1005,124 @@ static irqreturn_t sdhci_uhs2_thread_irq(int irq, void *dev_id) > return IRQ_HANDLED; > } > > +/*****************************************************************************\ > + * > + * Device allocation/registration * > + * * > +\*****************************************************************************/ > + > +static int __sdhci_uhs2_add_host_v4(struct sdhci_host *host, u32 caps1) Always returns 0, so change return type to 'void' > +{ > + struct mmc_host *mmc; > + u32 max_current_caps2; > + > + if (host->version < SDHCI_SPEC_400) > + return 0; > + > + mmc = host->mmc; > + > + /* Support UHS2 */ > + if (caps1 & SDHCI_SUPPORT_UHS2) > + mmc->caps2 |= MMC_CAP2_SD_UHS2; > + > + max_current_caps2 = sdhci_readl(host, SDHCI_MAX_CURRENT_1); > + > + if ((caps1 & SDHCI_CAN_VDD2_180) && > + !max_current_caps2 && > + !IS_ERR(mmc->supply.vmmc2)) { > + /* UHS2 - VDD2 */ > + int curr = regulator_get_current_limit(mmc->supply.vmmc2); > + > + if (curr > 0) { > + /* convert to SDHCI_MAX_CURRENT format */ > + curr = curr / 1000; /* convert to mA */ > + curr = curr / SDHCI_MAX_CURRENT_MULTIPLIER; > + curr = min_t(u32, curr, SDHCI_MAX_CURRENT_LIMIT); > + max_current_caps2 = curr; > + } > + } > + > + if (caps1 & SDHCI_CAN_VDD2_180) { > + mmc->ocr_avail_uhs2 |= MMC_VDD_165_195; > + /* > + * UHS2 doesn't require this. Only UHS-I bus needs to set > + * max current. > + */ > + mmc->max_current_180_vdd2 = (max_current_caps2 & > + SDHCI_MAX_CURRENT_VDD2_180_MASK) * > + SDHCI_MAX_CURRENT_MULTIPLIER; max_current_180_vdd2 is not used. Does it have a purpose? > + } else { > + mmc->caps2 &= ~MMC_CAP2_SD_UHS2; > + } > + > + return 0; > +} > + > +static int sdhci_uhs2_host_ops_init(struct sdhci_host *host); > + > +static void __sdhci_uhs2_remove_host(struct sdhci_host *host, int dead) > +{ > + if (!sdhci_uhs2_mode(host)) > + return; > + > + if (!dead) > + sdhci_uhs2_reset(host, SDHCI_UHS2_SW_RESET_FULL); > +} > + > +int sdhci_uhs2_add_host(struct sdhci_host *host) > +{ > + struct mmc_host *mmc = host->mmc; > + int ret; > + > + ret = sdhci_setup_host(host); > + if (ret) > + return ret; > + > + if (host->version >= SDHCI_SPEC_400) { > + ret = __sdhci_uhs2_add_host_v4(host, host->caps1); > + if (ret) > + goto cleanup; > + } > + > + if ((mmc->caps2 & MMC_CAP2_SD_UHS2) && !host->v4_mode) > + /* host doesn't want to enable UHS2 support */ > + /* FIXME: Do we have to do some cleanup here? */ Please do not leave FIXMEs > + mmc->caps2 &= ~MMC_CAP2_SD_UHS2; > + > + /* overwrite ops */ > + if (mmc->caps2 & MMC_CAP2_SD_UHS2) > + sdhci_uhs2_host_ops_init(host); > + > + host->complete_work_fn = sdhci_uhs2_complete_work; > + host->thread_irq_fn = sdhci_uhs2_thread_irq; > + > + /* LED support not implemented for UHS2 */ > + host->quirks |= SDHCI_QUIRK_NO_LED; > + > + ret = __sdhci_add_host(host); > + if (ret) > + goto cleanup2; > + > + return 0; > + > +cleanup2: > + if (host->version >= SDHCI_SPEC_400) > + __sdhci_uhs2_remove_host(host, 0); > +cleanup: > + sdhci_cleanup_host(host); > + > + return ret; > +} > +EXPORT_SYMBOL_GPL(sdhci_uhs2_add_host); > + > +void sdhci_uhs2_remove_host(struct sdhci_host *host, int dead) > +{ > + __sdhci_uhs2_remove_host(host, dead); > + > + sdhci_remove_host(host, dead); > +} > +EXPORT_SYMBOL_GPL(sdhci_uhs2_remove_host); > + > void sdhci_uhs2_request(struct mmc_host *mmc, struct mmc_request *mrq) > { > struct sdhci_host *host = mmc_priv(mmc); > diff --git a/drivers/mmc/host/sdhci-uhs2.h b/drivers/mmc/host/sdhci-uhs2.h > index f733c733c692..5b5b4a8d4f27 100644 > --- a/drivers/mmc/host/sdhci-uhs2.h > +++ b/drivers/mmc/host/sdhci-uhs2.h > @@ -185,5 +185,7 @@ void sdhci_uhs2_clear_set_irqs(struct sdhci_host *host, u32 clear, u32 set); > void sdhci_uhs2_request(struct mmc_host *mmc, struct mmc_request *mrq); > int sdhci_uhs2_request_atomic(struct mmc_host *mmc, struct mmc_request *mrq); > u32 sdhci_uhs2_irq(struct sdhci_host *host, u32 intmask); > +int sdhci_uhs2_add_host(struct sdhci_host *host); > +void sdhci_uhs2_remove_host(struct sdhci_host *host, int dead); > > #endif /* __SDHCI_UHS2_H */ > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c > index b3cf4a26eed5..d976d3a6ff8d 100644 > --- a/drivers/mmc/host/sdhci.c > +++ b/drivers/mmc/host/sdhci.c > @@ -4105,6 +4105,9 @@ struct sdhci_host *sdhci_alloc_host(struct device *dev, > > host->max_timeout_count = 0xE; > > + host->complete_work_fn = sdhci_complete_work; > + host->thread_irq_fn = sdhci_thread_irq; > + > return host; > } > > @@ -4854,7 +4857,7 @@ int __sdhci_add_host(struct sdhci_host *host) > if (!host->complete_wq) > return -ENOMEM; > > - INIT_WORK(&host->complete_work, sdhci_complete_work); > + INIT_WORK(&host->complete_work, host->complete_work_fn); > > timer_setup(&host->timer, sdhci_timeout_timer, 0); > timer_setup(&host->data_timer, sdhci_timeout_data_timer, 0); > @@ -4863,7 +4866,7 @@ int __sdhci_add_host(struct sdhci_host *host) > > sdhci_init(host, 0); > > - ret = request_threaded_irq(host->irq, sdhci_irq, sdhci_thread_irq, > + ret = request_threaded_irq(host->irq, sdhci_irq, host->thread_irq_fn, > IRQF_SHARED, mmc_hostname(mmc), host); > if (ret) { > pr_err("%s: Failed to request IRQ %d: %d\n", > diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h > index 9e9158f811b1..e16267f5a3c0 100644 > --- a/drivers/mmc/host/sdhci.h > +++ b/drivers/mmc/host/sdhci.h > @@ -627,6 +627,9 @@ struct sdhci_host { > struct timer_list timer; /* Timer for timeouts */ > struct timer_list data_timer; /* Timer for data timeouts */ > > + void (*complete_work_fn)(struct work_struct *work); > + irqreturn_t (*thread_irq_fn)(int irq, void *dev_id); > + > #if IS_ENABLED(CONFIG_MMC_SDHCI_EXTERNAL_DMA) > struct dma_chan *rx_chan; > struct dma_chan *tx_chan;
Hi, Adrian On Wed, Apr 12, 2023 at 9:12 PM Adrian Hunter <adrian.hunter@intel.com> wrote: > > On 31/03/23 13:55, Victor Shih wrote: > > This is a UHS-II version of sdhci's add_host/remove_host operation. > > Any sdhci drivers which are capable of handling UHS-II cards must > > call those functions instead of the corresponding sdhci's. > > > > Signed-off-by: Ben Chuang <ben.chuang@genesyslogic.com.tw> > > Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> > > Signed-off-by: Victor Shih <victor.shih@genesyslogic.com.tw> > > --- > > drivers/mmc/host/sdhci-uhs2.c | 119 ++++++++++++++++++++++++++++++++++ > > drivers/mmc/host/sdhci-uhs2.h | 2 + > > drivers/mmc/host/sdhci.c | 7 +- > > drivers/mmc/host/sdhci.h | 3 + > > 4 files changed, 129 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/mmc/host/sdhci-uhs2.c b/drivers/mmc/host/sdhci-uhs2.c > > index 63f4bfce70b8..610780d425bc 100644 > > --- a/drivers/mmc/host/sdhci-uhs2.c > > +++ b/drivers/mmc/host/sdhci-uhs2.c > > @@ -17,6 +17,7 @@ > > #include <linux/ktime.h> > > #include <linux/mmc/mmc.h> > > #include <linux/mmc/host.h> > > +#include <linux/regulator/consumer.h> > > > > #include "sdhci.h" > > #include "sdhci-uhs2.h" > > @@ -1004,6 +1005,124 @@ static irqreturn_t sdhci_uhs2_thread_irq(int irq, void *dev_id) > > return IRQ_HANDLED; > > } > > > > +/*****************************************************************************\ > > + * > > + * Device allocation/registration * > > + * * > > +\*****************************************************************************/ > > + > > +static int __sdhci_uhs2_add_host_v4(struct sdhci_host *host, u32 caps1) > > Always returns 0, so change return type to 'void' > I will update it to the V8 version. > > +{ > > + struct mmc_host *mmc; > > + u32 max_current_caps2; > > + > > + if (host->version < SDHCI_SPEC_400) > > + return 0; > > + > > + mmc = host->mmc; > > + > > + /* Support UHS2 */ > > + if (caps1 & SDHCI_SUPPORT_UHS2) > > + mmc->caps2 |= MMC_CAP2_SD_UHS2; > > + > > + max_current_caps2 = sdhci_readl(host, SDHCI_MAX_CURRENT_1); > > + > > + if ((caps1 & SDHCI_CAN_VDD2_180) && > > + !max_current_caps2 && > > + !IS_ERR(mmc->supply.vmmc2)) { > > + /* UHS2 - VDD2 */ > > + int curr = regulator_get_current_limit(mmc->supply.vmmc2); > > + > > + if (curr > 0) { > > + /* convert to SDHCI_MAX_CURRENT format */ > > + curr = curr / 1000; /* convert to mA */ > > + curr = curr / SDHCI_MAX_CURRENT_MULTIPLIER; > > + curr = min_t(u32, curr, SDHCI_MAX_CURRENT_LIMIT); > > + max_current_caps2 = curr; > > + } > > + } > > + > > + if (caps1 & SDHCI_CAN_VDD2_180) { > > + mmc->ocr_avail_uhs2 |= MMC_VDD_165_195; > > + /* > > + * UHS2 doesn't require this. Only UHS-I bus needs to set > > + * max current. > > + */ > > + mmc->max_current_180_vdd2 = (max_current_caps2 & > > + SDHCI_MAX_CURRENT_VDD2_180_MASK) * > > + SDHCI_MAX_CURRENT_MULTIPLIER; > > max_current_180_vdd2 is not used. Does it have a purpose? > I will update it to the V8 version. > > + } else { > > + mmc->caps2 &= ~MMC_CAP2_SD_UHS2; > > + } > > + > > + return 0; > > +} > > + > > +static int sdhci_uhs2_host_ops_init(struct sdhci_host *host); > > + > > +static void __sdhci_uhs2_remove_host(struct sdhci_host *host, int dead) > > +{ > > + if (!sdhci_uhs2_mode(host)) > > + return; > > + > > + if (!dead) > > + sdhci_uhs2_reset(host, SDHCI_UHS2_SW_RESET_FULL); > > +} > > + > > +int sdhci_uhs2_add_host(struct sdhci_host *host) > > +{ > > + struct mmc_host *mmc = host->mmc; > > + int ret; > > + > > + ret = sdhci_setup_host(host); > > + if (ret) > > + return ret; > > + > > + if (host->version >= SDHCI_SPEC_400) { > > + ret = __sdhci_uhs2_add_host_v4(host, host->caps1); > > + if (ret) > > + goto cleanup; > > + } > > + > > + if ((mmc->caps2 & MMC_CAP2_SD_UHS2) && !host->v4_mode) > > + /* host doesn't want to enable UHS2 support */ > > + /* FIXME: Do we have to do some cleanup here? */ > > Please do not leave FIXMEs > I will update it to the V8 version. > > + mmc->caps2 &= ~MMC_CAP2_SD_UHS2; > > + > > + /* overwrite ops */ > > + if (mmc->caps2 & MMC_CAP2_SD_UHS2) > > + sdhci_uhs2_host_ops_init(host); > > + > > + host->complete_work_fn = sdhci_uhs2_complete_work; > > + host->thread_irq_fn = sdhci_uhs2_thread_irq; > > + > > + /* LED support not implemented for UHS2 */ > > + host->quirks |= SDHCI_QUIRK_NO_LED; > > + > > + ret = __sdhci_add_host(host); > > + if (ret) > > + goto cleanup2; > > + > > + return 0; > > + > > +cleanup2: > > + if (host->version >= SDHCI_SPEC_400) > > + __sdhci_uhs2_remove_host(host, 0); > > +cleanup: > > + sdhci_cleanup_host(host); > > + > > + return ret; > > +} > > +EXPORT_SYMBOL_GPL(sdhci_uhs2_add_host); > > + > > +void sdhci_uhs2_remove_host(struct sdhci_host *host, int dead) > > +{ > > + __sdhci_uhs2_remove_host(host, dead); > > + > > + sdhci_remove_host(host, dead); > > +} > > +EXPORT_SYMBOL_GPL(sdhci_uhs2_remove_host); > > + > > void sdhci_uhs2_request(struct mmc_host *mmc, struct mmc_request *mrq) > > { > > struct sdhci_host *host = mmc_priv(mmc); > > diff --git a/drivers/mmc/host/sdhci-uhs2.h b/drivers/mmc/host/sdhci-uhs2.h > > index f733c733c692..5b5b4a8d4f27 100644 > > --- a/drivers/mmc/host/sdhci-uhs2.h > > +++ b/drivers/mmc/host/sdhci-uhs2.h > > @@ -185,5 +185,7 @@ void sdhci_uhs2_clear_set_irqs(struct sdhci_host *host, u32 clear, u32 set); > > void sdhci_uhs2_request(struct mmc_host *mmc, struct mmc_request *mrq); > > int sdhci_uhs2_request_atomic(struct mmc_host *mmc, struct mmc_request *mrq); > > u32 sdhci_uhs2_irq(struct sdhci_host *host, u32 intmask); > > +int sdhci_uhs2_add_host(struct sdhci_host *host); > > +void sdhci_uhs2_remove_host(struct sdhci_host *host, int dead); > > > > #endif /* __SDHCI_UHS2_H */ > > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c > > index b3cf4a26eed5..d976d3a6ff8d 100644 > > --- a/drivers/mmc/host/sdhci.c > > +++ b/drivers/mmc/host/sdhci.c > > @@ -4105,6 +4105,9 @@ struct sdhci_host *sdhci_alloc_host(struct device *dev, > > > > host->max_timeout_count = 0xE; > > > > + host->complete_work_fn = sdhci_complete_work; > > + host->thread_irq_fn = sdhci_thread_irq; > > + > > return host; > > } > > > > @@ -4854,7 +4857,7 @@ int __sdhci_add_host(struct sdhci_host *host) > > if (!host->complete_wq) > > return -ENOMEM; > > > > - INIT_WORK(&host->complete_work, sdhci_complete_work); > > + INIT_WORK(&host->complete_work, host->complete_work_fn); > > > > timer_setup(&host->timer, sdhci_timeout_timer, 0); > > timer_setup(&host->data_timer, sdhci_timeout_data_timer, 0); > > @@ -4863,7 +4866,7 @@ int __sdhci_add_host(struct sdhci_host *host) > > > > sdhci_init(host, 0); > > > > - ret = request_threaded_irq(host->irq, sdhci_irq, sdhci_thread_irq, > > + ret = request_threaded_irq(host->irq, sdhci_irq, host->thread_irq_fn, > > IRQF_SHARED, mmc_hostname(mmc), host); > > if (ret) { > > pr_err("%s: Failed to request IRQ %d: %d\n", > > diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h > > index 9e9158f811b1..e16267f5a3c0 100644 > > --- a/drivers/mmc/host/sdhci.h > > +++ b/drivers/mmc/host/sdhci.h > > @@ -627,6 +627,9 @@ struct sdhci_host { > > struct timer_list timer; /* Timer for timeouts */ > > struct timer_list data_timer; /* Timer for data timeouts */ > > > > + void (*complete_work_fn)(struct work_struct *work); > > + irqreturn_t (*thread_irq_fn)(int irq, void *dev_id); > > + > > #if IS_ENABLED(CONFIG_MMC_SDHCI_EXTERNAL_DMA) > > struct dma_chan *rx_chan; > > struct dma_chan *tx_chan; > Thanks, Victor Shih
diff --git a/drivers/mmc/host/sdhci-uhs2.c b/drivers/mmc/host/sdhci-uhs2.c index 63f4bfce70b8..610780d425bc 100644 --- a/drivers/mmc/host/sdhci-uhs2.c +++ b/drivers/mmc/host/sdhci-uhs2.c @@ -17,6 +17,7 @@ #include <linux/ktime.h> #include <linux/mmc/mmc.h> #include <linux/mmc/host.h> +#include <linux/regulator/consumer.h> #include "sdhci.h" #include "sdhci-uhs2.h" @@ -1004,6 +1005,124 @@ static irqreturn_t sdhci_uhs2_thread_irq(int irq, void *dev_id) return IRQ_HANDLED; } +/*****************************************************************************\ + * + * Device allocation/registration * + * * +\*****************************************************************************/ + +static int __sdhci_uhs2_add_host_v4(struct sdhci_host *host, u32 caps1) +{ + struct mmc_host *mmc; + u32 max_current_caps2; + + if (host->version < SDHCI_SPEC_400) + return 0; + + mmc = host->mmc; + + /* Support UHS2 */ + if (caps1 & SDHCI_SUPPORT_UHS2) + mmc->caps2 |= MMC_CAP2_SD_UHS2; + + max_current_caps2 = sdhci_readl(host, SDHCI_MAX_CURRENT_1); + + if ((caps1 & SDHCI_CAN_VDD2_180) && + !max_current_caps2 && + !IS_ERR(mmc->supply.vmmc2)) { + /* UHS2 - VDD2 */ + int curr = regulator_get_current_limit(mmc->supply.vmmc2); + + if (curr > 0) { + /* convert to SDHCI_MAX_CURRENT format */ + curr = curr / 1000; /* convert to mA */ + curr = curr / SDHCI_MAX_CURRENT_MULTIPLIER; + curr = min_t(u32, curr, SDHCI_MAX_CURRENT_LIMIT); + max_current_caps2 = curr; + } + } + + if (caps1 & SDHCI_CAN_VDD2_180) { + mmc->ocr_avail_uhs2 |= MMC_VDD_165_195; + /* + * UHS2 doesn't require this. Only UHS-I bus needs to set + * max current. + */ + mmc->max_current_180_vdd2 = (max_current_caps2 & + SDHCI_MAX_CURRENT_VDD2_180_MASK) * + SDHCI_MAX_CURRENT_MULTIPLIER; + } else { + mmc->caps2 &= ~MMC_CAP2_SD_UHS2; + } + + return 0; +} + +static int sdhci_uhs2_host_ops_init(struct sdhci_host *host); + +static void __sdhci_uhs2_remove_host(struct sdhci_host *host, int dead) +{ + if (!sdhci_uhs2_mode(host)) + return; + + if (!dead) + sdhci_uhs2_reset(host, SDHCI_UHS2_SW_RESET_FULL); +} + +int sdhci_uhs2_add_host(struct sdhci_host *host) +{ + struct mmc_host *mmc = host->mmc; + int ret; + + ret = sdhci_setup_host(host); + if (ret) + return ret; + + if (host->version >= SDHCI_SPEC_400) { + ret = __sdhci_uhs2_add_host_v4(host, host->caps1); + if (ret) + goto cleanup; + } + + if ((mmc->caps2 & MMC_CAP2_SD_UHS2) && !host->v4_mode) + /* host doesn't want to enable UHS2 support */ + /* FIXME: Do we have to do some cleanup here? */ + mmc->caps2 &= ~MMC_CAP2_SD_UHS2; + + /* overwrite ops */ + if (mmc->caps2 & MMC_CAP2_SD_UHS2) + sdhci_uhs2_host_ops_init(host); + + host->complete_work_fn = sdhci_uhs2_complete_work; + host->thread_irq_fn = sdhci_uhs2_thread_irq; + + /* LED support not implemented for UHS2 */ + host->quirks |= SDHCI_QUIRK_NO_LED; + + ret = __sdhci_add_host(host); + if (ret) + goto cleanup2; + + return 0; + +cleanup2: + if (host->version >= SDHCI_SPEC_400) + __sdhci_uhs2_remove_host(host, 0); +cleanup: + sdhci_cleanup_host(host); + + return ret; +} +EXPORT_SYMBOL_GPL(sdhci_uhs2_add_host); + +void sdhci_uhs2_remove_host(struct sdhci_host *host, int dead) +{ + __sdhci_uhs2_remove_host(host, dead); + + sdhci_remove_host(host, dead); +} +EXPORT_SYMBOL_GPL(sdhci_uhs2_remove_host); + void sdhci_uhs2_request(struct mmc_host *mmc, struct mmc_request *mrq) { struct sdhci_host *host = mmc_priv(mmc); diff --git a/drivers/mmc/host/sdhci-uhs2.h b/drivers/mmc/host/sdhci-uhs2.h index f733c733c692..5b5b4a8d4f27 100644 --- a/drivers/mmc/host/sdhci-uhs2.h +++ b/drivers/mmc/host/sdhci-uhs2.h @@ -185,5 +185,7 @@ void sdhci_uhs2_clear_set_irqs(struct sdhci_host *host, u32 clear, u32 set); void sdhci_uhs2_request(struct mmc_host *mmc, struct mmc_request *mrq); int sdhci_uhs2_request_atomic(struct mmc_host *mmc, struct mmc_request *mrq); u32 sdhci_uhs2_irq(struct sdhci_host *host, u32 intmask); +int sdhci_uhs2_add_host(struct sdhci_host *host); +void sdhci_uhs2_remove_host(struct sdhci_host *host, int dead); #endif /* __SDHCI_UHS2_H */ diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index b3cf4a26eed5..d976d3a6ff8d 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -4105,6 +4105,9 @@ struct sdhci_host *sdhci_alloc_host(struct device *dev, host->max_timeout_count = 0xE; + host->complete_work_fn = sdhci_complete_work; + host->thread_irq_fn = sdhci_thread_irq; + return host; } @@ -4854,7 +4857,7 @@ int __sdhci_add_host(struct sdhci_host *host) if (!host->complete_wq) return -ENOMEM; - INIT_WORK(&host->complete_work, sdhci_complete_work); + INIT_WORK(&host->complete_work, host->complete_work_fn); timer_setup(&host->timer, sdhci_timeout_timer, 0); timer_setup(&host->data_timer, sdhci_timeout_data_timer, 0); @@ -4863,7 +4866,7 @@ int __sdhci_add_host(struct sdhci_host *host) sdhci_init(host, 0); - ret = request_threaded_irq(host->irq, sdhci_irq, sdhci_thread_irq, + ret = request_threaded_irq(host->irq, sdhci_irq, host->thread_irq_fn, IRQF_SHARED, mmc_hostname(mmc), host); if (ret) { pr_err("%s: Failed to request IRQ %d: %d\n", diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 9e9158f811b1..e16267f5a3c0 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -627,6 +627,9 @@ struct sdhci_host { struct timer_list timer; /* Timer for timeouts */ struct timer_list data_timer; /* Timer for data timeouts */ + void (*complete_work_fn)(struct work_struct *work); + irqreturn_t (*thread_irq_fn)(int irq, void *dev_id); + #if IS_ENABLED(CONFIG_MMC_SDHCI_EXTERNAL_DMA) struct dma_chan *rx_chan; struct dma_chan *tx_chan;