There are modified register settings for STOP_DLY_SEL and POP_EN_CNT,
with two new fields added to the compatibility structure to reflect
the modifications.
For legacy SoCs, also add the original value of 'stop_dly_sel' to the
platdata, for unified code setting.
Signed-off-by: Andy-ld Lu <andy-ld.lu@mediatek.com>
---
drivers/mmc/host/mtk-sd.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
index fa4ac9f113bd..4c239a4cf8d9 100644
--- a/drivers/mmc/host/mtk-sd.c
+++ b/drivers/mmc/host/mtk-sd.c
@@ -255,6 +255,7 @@
#define MSDC_PB2_SUPPORT_64G BIT(1) /* RW */
#define MSDC_PB2_RESPWAIT GENMASK(3, 2) /* RW */
#define MSDC_PB2_RESPSTSENSEL GENMASK(18, 16) /* RW */
+#define MSDC_PB2_POP_EN_CNT GENMASK(23, 20) /* RW */
#define MSDC_PB2_CFGCRCSTSEDGE BIT(25) /* RW */
#define MSDC_PB2_CRCSTSENSEL GENMASK(31, 29) /* RW */
@@ -418,6 +419,8 @@ struct mtk_mmc_compatible {
bool data_tune;
bool busy_check;
bool stop_clk_fix;
+ u8 stop_dly_sel;
+ u8 pop_en_cnt;
bool enhance_rx;
bool support_64g;
bool use_internal_cd;
@@ -521,6 +524,7 @@ static const struct mtk_mmc_compatible mt2712_compat = {
.data_tune = true,
.busy_check = true,
.stop_clk_fix = true,
+ .stop_dly_sel = 3,
.enhance_rx = true,
.support_64g = true,
};
@@ -534,6 +538,7 @@ static const struct mtk_mmc_compatible mt6779_compat = {
.data_tune = true,
.busy_check = true,
.stop_clk_fix = true,
+ .stop_dly_sel = 3,
.enhance_rx = true,
.support_64g = true,
};
@@ -573,6 +578,7 @@ static const struct mtk_mmc_compatible mt7622_compat = {
.data_tune = true,
.busy_check = true,
.stop_clk_fix = true,
+ .stop_dly_sel = 3,
.enhance_rx = true,
.support_64g = false,
};
@@ -586,6 +592,7 @@ static const struct mtk_mmc_compatible mt7986_compat = {
.data_tune = true,
.busy_check = true,
.stop_clk_fix = true,
+ .stop_dly_sel = 3,
.enhance_rx = true,
.support_64g = true,
};
@@ -625,6 +632,7 @@ static const struct mtk_mmc_compatible mt8183_compat = {
.data_tune = true,
.busy_check = true,
.stop_clk_fix = true,
+ .stop_dly_sel = 3,
.enhance_rx = true,
.support_64g = true,
};
@@ -638,6 +646,7 @@ static const struct mtk_mmc_compatible mt8516_compat = {
.data_tune = true,
.busy_check = true,
.stop_clk_fix = true,
+ .stop_dly_sel = 3,
};
static const struct mtk_mmc_compatible mt8196_compat = {
@@ -649,6 +658,8 @@ static const struct mtk_mmc_compatible mt8196_compat = {
.data_tune = true,
.busy_check = true,
.stop_clk_fix = true,
+ .stop_dly_sel = 1,
+ .pop_en_cnt = 2,
.enhance_rx = true,
.support_64g = true,
.support_new_tx = true,
@@ -1855,8 +1866,16 @@ static void msdc_init_hw(struct msdc_host *host)
sdr_set_bits(host->base + EMMC50_CFG0, EMMC50_CFG_CFCSTS_SEL);
if (host->dev_comp->stop_clk_fix) {
- sdr_set_field(host->base + MSDC_PATCH_BIT1,
- MSDC_PATCH_BIT1_STOP_DLY, 3);
+ if (host->dev_comp->stop_dly_sel)
+ sdr_set_field(host->base + MSDC_PATCH_BIT1,
+ MSDC_PATCH_BIT1_STOP_DLY,
+ host->dev_comp->stop_dly_sel);
+
+ if (host->dev_comp->pop_en_cnt)
+ sdr_set_field(host->base + MSDC_PATCH_BIT2,
+ MSDC_PB2_POP_EN_CNT,
+ host->dev_comp->pop_en_cnt);
+
sdr_clr_bits(host->base + SDC_FIFO_CFG,
SDC_FIFO_CFG_WRVALIDSEL);
sdr_clr_bits(host->base + SDC_FIFO_CFG,
--
2.46.0
Il 09/10/24 14:01, Andy-ld Lu ha scritto: > There are modified register settings for STOP_DLY_SEL and POP_EN_CNT, > with two new fields added to the compatibility structure to reflect > the modifications. > > For legacy SoCs, also add the original value of 'stop_dly_sel' to the > platdata, for unified code setting. > mmc: mtk-sd: Add stop_dly_sel and pop_en_cnt to platform data that's a better title; then, in the commit description, you should describe why stop_dly_sel/pop_en_cnt is overridden (so, why some SoCs need a different value for those registers). Also, this commit should come *before* adding support for MT8196: you first add the two settings in platdata explaining that this is also done in preparation for adding support for the SD/MMC controller found in MT8196, then you add the acutal MT8196 support. For this commit, anyway, the code itself looks good. Cheers, Angelo
On Thu, 2024-10-10 at 14:18 +0200, AngeloGioacchino Del Regno wrote: > Il 09/10/24 14:01, Andy-ld Lu ha scritto: > > There are modified register settings for STOP_DLY_SEL and > > POP_EN_CNT, > > with two new fields added to the compatibility structure to reflect > > the modifications. > > > > For legacy SoCs, also add the original value of 'stop_dly_sel' to > > the > > platdata, for unified code setting. > > > > mmc: mtk-sd: Add stop_dly_sel and pop_en_cnt to platform data > > that's a better title; then, in the commit description, you should > describe > why stop_dly_sel/pop_en_cnt is overridden (so, why some SoCs need a > different > value for those registers). > > Also, this commit should come *before* adding support for MT8196: you > first > add the two settings in platdata explaining that this is also done in > preparation for adding support for the SD/MMC controller found in > MT8196, > then you add the acutal MT8196 support. > > For this commit, anyway, the code itself looks good. > > Cheers, > Angelo Thanks for your suggestion, I will follow your comment in next change. > >
© 2016 - 2024 Red Hat, Inc.