Skip to contentSkip to conversation

mmc: Add Synopsys DesignWare mmc cmdq host driver

PATCH In review Jyan Chou 2 participants 2 messages Jun 30, 2023

Subsystems (3)
lore
Share & tools
lore

Jyan Chou

author
#0 lore raw

PATCH 1/1 mmc: Add Synopsys DesignWare mmc cmdq host driver

The difference between dw_mmc.c and dw_mmc_cqe.c is that we implemrnted cmdq feature, and we found out the difference between distint version of synopsys' data book and user guide.

We add the mmc driver for the Synopsys DesignWare mmc cmdq host controller that can improve performance. Also, we add our Realtek mmc driver that make good use of it.

---
 drivers/mmc/host/cqhci-core.c     |    5 +
 drivers/mmc/host/cqhci.h          |    2 +
 drivers/mmc/host/dw_mmc_cqe-rtk.c | 1343 +++++++++++++++++++++
 drivers/mmc/host/dw_mmc_cqe-rtk.h |  164 +++
 drivers/mmc/host/dw_mmc_cqe.c     | 1821 +++++++++++++++++++++++++++++
 drivers/mmc/host/dw_mmc_cqe.h     |  441 +++++++
 6 files changed, 3776 insertions(+)
 create mode 100644 drivers/mmc/host/dw_mmc_cqe-rtk.c
 create mode 100644 drivers/mmc/host/dw_mmc_cqe-rtk.h
 create mode 100644 drivers/mmc/host/dw_mmc_cqe.c
 create mode 100644 drivers/mmc/host/dw_mmc_cqe.h
drivers/mmc/host/cqhci-core.c +5 -0
index b3d7d6d8d654..f4ddad62632a 100644
@@ -514,6 +514,11 @@ static int cqhci_prep_tran_desc(struct mmc_request *mrq,
 		return sg_count;
 	}
 
+	if (cq_host->ops->setup_tran_desc) {
+		cq_host->ops->setup_tran_desc(data, cq_host, desc, sg_count);
+		return 0;
+	}
+
 	desc = get_trans_desc(cq_host, tag);
 
 	for_each_sg(data->sg, sg, sg_count, i) {
drivers/mmc/host/cqhci.h +2 -0
index ba9387ed90eb..a3e56da6189d 100644
@@ -286,6 +286,8 @@ struct cqhci_host_ops {
 				 u64 *data);
 	void (*pre_enable)(struct mmc_host *mmc);
 	void (*post_disable)(struct mmc_host *mmc);
+	void (*setup_tran_desc)(struct mmc_data *data,
+		struct cqhci_host *cq_host, u8 *desc, int sg_count);
 #ifdef CONFIG_MMC_CRYPTO
 	int (*program_key)(struct cqhci_host *cq_host,
 			   const union cqhci_crypto_cfg_entry *cfg, int slot);
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +1343 -0

1,343 lines not on this page · raw message

drivers/mmc/host/dw_mmc_cqe-rtk.h new file +164 -0

164 lines not on this page · raw message

drivers/mmc/host/dw_mmc_cqe.c new file +1821 -0

1,474 lines not on this page · raw message

drivers/mmc/host/dw_mmc_cqe.h new file +441 -0

441 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.40.1

Part of the diff is not shown here. View the raw message.

#1 lore raw
Quoted 95 lines · Jyan Chou

The difference between dw_mmc.c and dw_mmc_cqe.c is that we implemrnted cmdq feature, and we found out the difference between distint version of synopsys' data book and user guide.

We add the mmc driver for the Synopsys DesignWare mmc cmdq host controller that can improve performance. Also, we add our Realtek mmc driver that make good use of it.

---
 drivers/mmc/host/cqhci-core.c     |    5 +
 drivers/mmc/host/cqhci.h          |    2 +
 drivers/mmc/host/dw_mmc_cqe-rtk.c | 1343 +++++++++++++++++++++
 drivers/mmc/host/dw_mmc_cqe-rtk.h |  164 +++
 drivers/mmc/host/dw_mmc_cqe.c     | 1821 +++++++++++++++++++++++++++++
 drivers/mmc/host/dw_mmc_cqe.h     |  441 +++++++
 6 files changed, 3776 insertions(+)
 create mode 100644 drivers/mmc/host/dw_mmc_cqe-rtk.c
 create mode 100644 drivers/mmc/host/dw_mmc_cqe-rtk.h
 create mode 100644 drivers/mmc/host/dw_mmc_cqe.c
 create mode 100644 drivers/mmc/host/dw_mmc_cqe.h
drivers/mmc/host/cqhci-core.c +5 -0
index b3d7d6d8d654..f4ddad62632a 100644
@@ -514,6 +514,11 @@ static int cqhci_prep_tran_desc(struct mmc_request *mrq,
                return sg_count;
        }
 
+       if (cq_host->ops->setup_tran_desc) {
+               cq_host->ops->setup_tran_desc(data, cq_host, desc, sg_count);
+               return 0;
+       }
+
        desc = get_trans_desc(cq_host, tag);
 
        for_each_sg(data->sg, sg, sg_count, i) {
drivers/mmc/host/cqhci.h +2 -0
index ba9387ed90eb..a3e56da6189d 100644
@@ -286,6 +286,8 @@ struct cqhci_host_ops {
                                 u64 *data);
        void (*pre_enable)(struct mmc_host *mmc);
        void (*post_disable)(struct mmc_host *mmc);
+       void (*setup_tran_desc)(struct mmc_data *data,
+               struct cqhci_host *cq_host, u8 *desc, int sg_count);
 #ifdef CONFIG_MMC_CRYPTO
        int (*program_key)(struct cqhci_host *cq_host,
                           const union cqhci_crypto_cfg_entry *cfg, int slot);
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +37 -0
new file mode 100644
index 000000000000..577cb1f1ed70
@@ -0,0 +1,1343 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2023 Realtek Semiconductor Corp.
+ *
+ */
+
+
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/mfd/syscon.h>
+#include <linux/mmc/core.h>
+#include <linux/mmc/host.h>
+#include <linux/mmc/mmc.h>
+#include <linux/module.h>
+#include <linux/nvmem-consumer.h>
+#include <linux/of_address.h>
+#include <linux/pinctrl/consumer.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+
+#include "dw_mmc_cqe.h"
+#include "dw_mmc_cqe-rtk.h"
+
+#define LOWER_BIT_MASK         0x00ffffff
+#define HIGH_BIT_MASK          0xff000000
+
+static void dw_mci_rtk_hs400_complete(struct mmc_host *mmc);
+static int dw_mci_rtk_execute_tuning(struct dw_mci_slot *slot, u32 opcode);
+
+int dw_mci_rtk_write_protect_cmd(struct mmc_host *mmc, u32 args, bool is_wrtie_protect)
+{
+       struct mmc_request mrq = {};
+       struct mmc_command cmd = {};
+       int err = 0;
+
+       if (is_wrtie_protect)

drivers/mmc/host/dw_mmc_cqe-rtk.c line 47

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+               cmd.opcode = MMC_SET_WRITE_PROT;
+       else
+               cmd.opcode = MMC_CLR_WRITE_PROT;
+
+       cmd.arg = args;
+       cmd.flags = MMC_CMD_AC|MMC_RSP_SPI_R1B | MMC_RSP_R1B;
+       mrq.cmd = &cmd;
+       mrq.data = NULL;
+
+       mmc_wait_for_req(mmc, &mrq);

This is not how the mmc subsystem works. Commands and protocol specific things are managed by the core layer.

Please don't abuse the interfaces/APIs from the core. Just looking at a few lines below, I noticed that there are more cases like this in $subject patch, therefore I am stopping the review already at this point. I am simply afraid that I will waste my time on this, sorry.

Next time, if you honestly want me to review this, please do your homework and take care of the above before posting a new version.

[...]

Kind regards
Uffe