This series provides MediaTek cqhci implementations as below:
- Add cqhci_host_ops->pre_enable() and cqhci_host_ops->post_disable()
- Implement MediaTek's hook functions
Chun-Hung Wu (2):
mmc: cqhci: add new cqhci_host_ops pre_enable() and post_disable()
mmc: mediatek: add pre_enable() and post_disable() hook function
drivers/mmc/host/cqhci.c | 6 ++++++
drivers/mmc/host/cqhci.h | 2 ++
drivers/mmc/host/mtk-sd.c | 22 ++++++++++++++++++++++
3 files changed, 30 insertions(+)
--
1.7.9.5
Add pre_enable() and post_disable() for cqhci_host_ops.
Add hook functions before cqhci enable and
after cqhci disable for platforms need them.
Signed-off-by: Chun-Hung Wu <[email protected]>
---
drivers/mmc/host/cqhci.c | 6 ++++++
drivers/mmc/host/cqhci.h | 2 ++
2 files changed, 8 insertions(+)
diff --git a/drivers/mmc/host/cqhci.c b/drivers/mmc/host/cqhci.c
index cfa87df..697fe40 100644
--- a/drivers/mmc/host/cqhci.c
+++ b/drivers/mmc/host/cqhci.c
@@ -376,6 +376,9 @@ static void cqhci_off(struct mmc_host *mmc)
else
pr_debug("%s: cqhci: CQE off\n", mmc_hostname(mmc));
+ if (cq_host->ops->post_disable)
+ cq_host->ops->post_disable(mmc);
+
mmc->cqe_on = false;
}
@@ -580,6 +583,9 @@ static int cqhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
__cqhci_enable(cq_host);
if (!mmc->cqe_on) {
+ if (cq_host->ops->pre_enable)
+ cq_host->ops->pre_enable(mmc);
+
cqhci_writel(cq_host, 0, CQHCI_CTL);
mmc->cqe_on = true;
pr_debug("%s: cqhci: CQE on\n", mmc_hostname(mmc));
diff --git a/drivers/mmc/host/cqhci.h b/drivers/mmc/host/cqhci.h
index 4377001..89bf6ad 100644
--- a/drivers/mmc/host/cqhci.h
+++ b/drivers/mmc/host/cqhci.h
@@ -206,6 +206,8 @@ struct cqhci_host_ops {
void (*disable)(struct mmc_host *mmc, bool recovery);
void (*update_dcmd_desc)(struct mmc_host *mmc, struct mmc_request *mrq,
u64 *data);
+ void (*pre_enable)(struct mmc_host *mmc);
+ void (*post_disable)(struct mmc_host *mmc);
};
static inline void cqhci_writel(struct cqhci_host *host, u32 val, int reg)
--
1.7.9.5
CQHCI_ENABLE bit in CQHCI_CFG should be disabled
after msdc_cqe_disable(), and should be enabled before
msdc_ceq_enable() for MTK platform.
Add hook functions for cqhci_host_ops->pre_enable() and
cqhci_host_ops->post_disable().
Signed-off-by: Chun-Hung Wu <[email protected]>
---
drivers/mmc/host/mtk-sd.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
index 4e2583f..f53e11b 100644
--- a/drivers/mmc/host/mtk-sd.c
+++ b/drivers/mmc/host/mtk-sd.c
@@ -2282,6 +2282,26 @@ static void msdc_cqe_disable(struct mmc_host *mmc, bool recovery)
}
}
+static void msdc_cqe_pre_enable(struct mmc_host *mmc)
+{
+ struct cqhci_host *cq_host = mmc->cqe_private;
+ u32 reg;
+
+ reg = cqhci_readl(cq_host, CQHCI_CFG);
+ reg |= CQHCI_ENABLE;
+ cqhci_writel(cq_host, reg, CQHCI_CFG);
+}
+
+static void msdc_cqe_post_disable(struct mmc_host *mmc)
+{
+ struct cqhci_host *cq_host = mmc->cqe_private;
+ u32 reg;
+
+ reg = cqhci_readl(cq_host, CQHCI_CFG);
+ reg &= ~CQHCI_ENABLE;
+ cqhci_writel(cq_host, reg, CQHCI_CFG);
+}
+
static const struct mmc_host_ops mt_msdc_ops = {
.post_req = msdc_post_req,
.pre_req = msdc_pre_req,
@@ -2301,6 +2321,8 @@ static void msdc_cqe_disable(struct mmc_host *mmc, bool recovery)
static const struct cqhci_host_ops msdc_cmdq_ops = {
.enable = msdc_cqe_enable,
.disable = msdc_cqe_disable,
+ .pre_enable = msdc_cqe_pre_enable,
+ .post_disable = msdc_cqe_post_disable,
};
static void msdc_of_property_parse(struct platform_device *pdev,
--
1.7.9.5
On 27/08/20 12:33 pm, Chun-Hung Wu wrote:
> Add pre_enable() and post_disable() for cqhci_host_ops.
> Add hook functions before cqhci enable and
> after cqhci disable for platforms need them.
>
> Signed-off-by: Chun-Hung Wu <[email protected]>
Acked-by: Adrian Hunter <[email protected]>
> ---
> drivers/mmc/host/cqhci.c | 6 ++++++
> drivers/mmc/host/cqhci.h | 2 ++
> 2 files changed, 8 insertions(+)
>
> diff --git a/drivers/mmc/host/cqhci.c b/drivers/mmc/host/cqhci.c
> index cfa87df..697fe40 100644
> --- a/drivers/mmc/host/cqhci.c
> +++ b/drivers/mmc/host/cqhci.c
> @@ -376,6 +376,9 @@ static void cqhci_off(struct mmc_host *mmc)
> else
> pr_debug("%s: cqhci: CQE off\n", mmc_hostname(mmc));
>
> + if (cq_host->ops->post_disable)
> + cq_host->ops->post_disable(mmc);
> +
> mmc->cqe_on = false;
> }
>
> @@ -580,6 +583,9 @@ static int cqhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
> __cqhci_enable(cq_host);
>
> if (!mmc->cqe_on) {
> + if (cq_host->ops->pre_enable)
> + cq_host->ops->pre_enable(mmc);
> +
> cqhci_writel(cq_host, 0, CQHCI_CTL);
> mmc->cqe_on = true;
> pr_debug("%s: cqhci: CQE on\n", mmc_hostname(mmc));
> diff --git a/drivers/mmc/host/cqhci.h b/drivers/mmc/host/cqhci.h
> index 4377001..89bf6ad 100644
> --- a/drivers/mmc/host/cqhci.h
> +++ b/drivers/mmc/host/cqhci.h
> @@ -206,6 +206,8 @@ struct cqhci_host_ops {
> void (*disable)(struct mmc_host *mmc, bool recovery);
> void (*update_dcmd_desc)(struct mmc_host *mmc, struct mmc_request *mrq,
> u64 *data);
> + void (*pre_enable)(struct mmc_host *mmc);
> + void (*post_disable)(struct mmc_host *mmc);
> };
>
> static inline void cqhci_writel(struct cqhci_host *host, u32 val, int reg)
>
On 27/08/20 12:33 pm, Chun-Hung Wu wrote:
> CQHCI_ENABLE bit in CQHCI_CFG should be disabled
> after msdc_cqe_disable(), and should be enabled before
> msdc_ceq_enable() for MTK platform.
> Add hook functions for cqhci_host_ops->pre_enable() and
> cqhci_host_ops->post_disable().
>
> Signed-off-by: Chun-Hung Wu <[email protected]>
Acked-by: Adrian Hunter <[email protected]>
> ---
> drivers/mmc/host/mtk-sd.c | 22 ++++++++++++++++++++++
> 1 file changed, 22 insertions(+)
>
> diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
> index 4e2583f..f53e11b 100644
> --- a/drivers/mmc/host/mtk-sd.c
> +++ b/drivers/mmc/host/mtk-sd.c
> @@ -2282,6 +2282,26 @@ static void msdc_cqe_disable(struct mmc_host *mmc, bool recovery)
> }
> }
>
> +static void msdc_cqe_pre_enable(struct mmc_host *mmc)
> +{
> + struct cqhci_host *cq_host = mmc->cqe_private;
> + u32 reg;
> +
> + reg = cqhci_readl(cq_host, CQHCI_CFG);
> + reg |= CQHCI_ENABLE;
> + cqhci_writel(cq_host, reg, CQHCI_CFG);
> +}
> +
> +static void msdc_cqe_post_disable(struct mmc_host *mmc)
> +{
> + struct cqhci_host *cq_host = mmc->cqe_private;
> + u32 reg;
> +
> + reg = cqhci_readl(cq_host, CQHCI_CFG);
> + reg &= ~CQHCI_ENABLE;
> + cqhci_writel(cq_host, reg, CQHCI_CFG);
> +}
> +
> static const struct mmc_host_ops mt_msdc_ops = {
> .post_req = msdc_post_req,
> .pre_req = msdc_pre_req,
> @@ -2301,6 +2321,8 @@ static void msdc_cqe_disable(struct mmc_host *mmc, bool recovery)
> static const struct cqhci_host_ops msdc_cmdq_ops = {
> .enable = msdc_cqe_enable,
> .disable = msdc_cqe_disable,
> + .pre_enable = msdc_cqe_pre_enable,
> + .post_disable = msdc_cqe_post_disable,
> };
>
> static void msdc_of_property_parse(struct platform_device *pdev,
>
On Thu, 27 Aug 2020 at 11:33, Chun-Hung Wu <[email protected]> wrote:
>
> This series provides MediaTek cqhci implementations as below:
> - Add cqhci_host_ops->pre_enable() and cqhci_host_ops->post_disable()
> - Implement MediaTek's hook functions
>
> Chun-Hung Wu (2):
> mmc: cqhci: add new cqhci_host_ops pre_enable() and post_disable()
> mmc: mediatek: add pre_enable() and post_disable() hook function
>
> drivers/mmc/host/cqhci.c | 6 ++++++
> drivers/mmc/host/cqhci.h | 2 ++
> drivers/mmc/host/mtk-sd.c | 22 ++++++++++++++++++++++
> 3 files changed, 30 insertions(+)
>
> --
> 1.7.9.5
Applied for next, thanks!
Kind regards
Uffe