From nobody Wed Nov 27 14:24:02 2024 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD10A18EFE0; Wed, 9 Oct 2024 12:02:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.61.82.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728475352; cv=none; b=VLMufbFqKOcApvdNUNwhk2jU3t5M7j922c3uZQ3fmqVuX1UoskTWW0fDaUJ89I3rqS884FNJ5KXnA9UMr6z0Uy4w2cCJiOY6L7yyN6uQ7zDR6ffG6Xd9vz0Aa1DqQU6QOMNSGLOPMYy2Uwf/RsDDeFb/s81yKftx4c/238XdNmU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728475352; c=relaxed/simple; bh=6GdlL5Wfq8/4wpgPsyms1wfVz96ThYcMWpw0l9Ra2ck=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bQmhbnXoldfgpOAA+vAkU0/xgLAtz3itu+fuK3tEUncHFLNY9qQwm0+bQ2qw2934/1MlCPeYlGg6K1wsdAe65Dfu64/a3STfmQt0NI6hI6vO0xUWtV7psOHJvlhmguWrFjwzIqbL+pMhZVUqm+Thwx2rjY7e1T2UU2LqmF27dSk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=Lg14CeFI; arc=none smtp.client-ip=210.61.82.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="Lg14CeFI" X-UUID: 56fd46e4863611ef8b96093e013ec31c-20241009 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=7YzPJAWP95B0jGQ2AUBIa9Ta/s3/XIJGKmwxWM/ChhY=; b=Lg14CeFIKbSgXmtkdAfv59NLOZY7w0L1LDodsWSOV4BIb1jNCe+alu002zPU50gQBqDNtQiY+E2ar1FLtH20rNRuVQTMlfugDNfTlE3ODnjA2HT5RHlrHVmS2Dec9YbNx9H2qRAIwoz3C2lBFS6JlEVVT7/FeAdyUAK+PFyA2ik=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.41,REQID:373e78b8-971a-45c4-980e-cf34e54dfb49,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:6dc6a47,CLOUDID:46178a26-5902-4533-af4f-d0904aa89b3c,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES :1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_ULN X-UUID: 56fd46e4863611ef8b96093e013ec31c-20241009 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1071562824; Wed, 09 Oct 2024 20:02:21 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Wed, 9 Oct 2024 20:02:20 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Wed, 9 Oct 2024 20:02:19 +0800 From: Andy-ld Lu To: , , , , , CC: , , , , , Andy-ld Lu Subject: [PATCH v3 1/3] mmc: mtk-sd: Add support for MT8196 Date: Wed, 9 Oct 2024 20:01:24 +0800 Message-ID: <20241009120203.14913-2-andy-ld.lu@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241009120203.14913-1-andy-ld.lu@mediatek.com> References: <20241009120203.14913-1-andy-ld.lu@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Mediatek SoC MT8196 features a new design for tx/rx path. The new tx path incorporates register settings that are closely associated with bus timing. And the difference between new rx path and older versions is the usage of distinct register bits when setting the data sampling edge as part of the tuning process. For the changes mentioned in relation to the MT8196, the new compatible string 'mediatek,mt8196-mmc' is introduced. This is to accommodate different settings and workflows specific to the MT8196. Signed-off-by: Andy-ld Lu Reviewed-by: AngeloGioacchino Del Regno --- drivers/mmc/host/mtk-sd.c | 143 +++++++++++++++++++++++++++++++++----- 1 file changed, 124 insertions(+), 19 deletions(-) diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c index 1efe434391af..fa4ac9f113bd 100644 --- a/drivers/mmc/host/mtk-sd.c +++ b/drivers/mmc/host/mtk-sd.c @@ -66,6 +66,7 @@ #define SDC_RESP3 0x4c #define SDC_BLK_NUM 0x50 #define SDC_ADV_CFG0 0x64 +#define MSDC_NEW_RX_CFG 0x68 #define EMMC_IOCON 0x7c #define SDC_ACMD_RESP 0x80 #define DMA_SA_H4BIT 0x8c @@ -92,6 +93,7 @@ #define EMMC_TOP_CONTROL 0x00 #define EMMC_TOP_CMD 0x04 #define EMMC50_PAD_DS_TUNE 0x0c +#define LOOP_TEST_CONTROL 0x30 =20 /*------------------------------------------------------------------------= --*/ /* Register Mask = */ @@ -203,9 +205,13 @@ #define SDC_STS_CMDBUSY BIT(1) /* RW */ #define SDC_STS_SWR_COMPL BIT(31) /* RW */ =20 -#define SDC_DAT1_IRQ_TRIGGER BIT(19) /* RW */ /* SDC_ADV_CFG0 mask */ +#define SDC_DAT1_IRQ_TRIGGER BIT(19) /* RW */ #define SDC_RX_ENHANCE_EN BIT(20) /* RW */ +#define SDC_NEW_TX_EN BIT(31) /* RW */ + +/* MSDC_NEW_RX_CFG mask */ +#define MSDC_NEW_RX_PATH_SEL BIT(0) /* RW */ =20 /* DMA_SA_H4BIT mask */ #define DMA_ADDR_HIGH_4BIT GENMASK(3, 0) /* RW */ @@ -227,6 +233,7 @@ =20 /* MSDC_PATCH_BIT mask */ #define MSDC_PATCH_BIT_ODDSUPP BIT(1) /* RW */ +#define MSDC_PATCH_BIT_RD_DAT_SEL BIT(3) /* RW */ #define MSDC_INT_DAT_LATCH_CK_SEL GENMASK(9, 7) #define MSDC_CKGEN_MSDC_DLY_SEL GENMASK(14, 10) #define MSDC_PATCH_BIT_IODSSEL BIT(16) /* RW */ @@ -248,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_CFGCRCSTSEDGE BIT(25) /* RW */ #define MSDC_PB2_CRCSTSENSEL GENMASK(31, 29) /* RW */ =20 #define MSDC_PAD_TUNE_DATWRDLY GENMASK(4, 0) /* RW */ @@ -312,6 +320,12 @@ #define PAD_DS_DLY1 GENMASK(14, 10) /* RW */ #define PAD_DS_DLY3 GENMASK(4, 0) /* RW */ =20 +/* LOOP_TEST_CONTROL mask */ +#define TEST_LOOP_DSCLK_MUX_SEL BIT(0) /* RW */ +#define TEST_LOOP_LATCH_MUX_SEL BIT(1) /* RW */ +#define LOOP_EN_SEL_CLK BIT(20) /* RW */ +#define TEST_HS400_CMD_LOOP_MUX_SEL BIT(31) /* RW */ + #define REQ_CMD_EIO BIT(0) #define REQ_CMD_TMO BIT(1) #define REQ_DAT_ERR BIT(2) @@ -392,6 +406,7 @@ struct msdc_save_para { u32 emmc_top_control; u32 emmc_top_cmd; u32 emmc50_pad_ds_tune; + u32 loop_test_control; }; =20 struct mtk_mmc_compatible { @@ -406,6 +421,8 @@ struct mtk_mmc_compatible { bool enhance_rx; bool support_64g; bool use_internal_cd; + bool support_new_tx; + bool support_new_rx; }; =20 struct msdc_tune_para { @@ -623,6 +640,21 @@ static const struct mtk_mmc_compatible mt8516_compat = =3D { .stop_clk_fix =3D true, }; =20 +static const struct mtk_mmc_compatible mt8196_compat =3D { + .clk_div_bits =3D 12, + .recheck_sdio_irq =3D false, + .hs400_tune =3D false, + .pad_tune_reg =3D MSDC_PAD_TUNE0, + .async_fifo =3D true, + .data_tune =3D true, + .busy_check =3D true, + .stop_clk_fix =3D true, + .enhance_rx =3D true, + .support_64g =3D true, + .support_new_tx =3D true, + .support_new_rx =3D true, +}; + static const struct of_device_id msdc_of_ids[] =3D { { .compatible =3D "mediatek,mt2701-mmc", .data =3D &mt2701_compat}, { .compatible =3D "mediatek,mt2712-mmc", .data =3D &mt2712_compat}, @@ -634,6 +666,7 @@ static const struct of_device_id msdc_of_ids[] =3D { { .compatible =3D "mediatek,mt8135-mmc", .data =3D &mt8135_compat}, { .compatible =3D "mediatek,mt8173-mmc", .data =3D &mt8173_compat}, { .compatible =3D "mediatek,mt8183-mmc", .data =3D &mt8183_compat}, + { .compatible =3D "mediatek,mt8196-mmc", .data =3D &mt8196_compat}, { .compatible =3D "mediatek,mt8516-mmc", .data =3D &mt8516_compat}, =20 {} @@ -874,6 +907,41 @@ static int msdc_ungate_clock(struct msdc_host *host) (val & MSDC_CFG_CKSTB), 1, 20000); } =20 +static void msdc_new_tx_setting(struct msdc_host *host) +{ + if (!host->top_base) + return; + + sdr_set_bits(host->top_base + LOOP_TEST_CONTROL, + TEST_LOOP_DSCLK_MUX_SEL); + sdr_set_bits(host->top_base + LOOP_TEST_CONTROL, + TEST_LOOP_LATCH_MUX_SEL); + sdr_clr_bits(host->top_base + LOOP_TEST_CONTROL, + TEST_HS400_CMD_LOOP_MUX_SEL); + + switch (host->timing) { + case MMC_TIMING_LEGACY: + case MMC_TIMING_MMC_HS: + case MMC_TIMING_SD_HS: + case MMC_TIMING_UHS_SDR12: + case MMC_TIMING_UHS_SDR25: + case MMC_TIMING_UHS_DDR50: + case MMC_TIMING_MMC_DDR52: + sdr_clr_bits(host->top_base + LOOP_TEST_CONTROL, + LOOP_EN_SEL_CLK); + break; + case MMC_TIMING_UHS_SDR50: + case MMC_TIMING_UHS_SDR104: + case MMC_TIMING_MMC_HS200: + case MMC_TIMING_MMC_HS400: + sdr_set_bits(host->top_base + LOOP_TEST_CONTROL, + LOOP_EN_SEL_CLK); + break; + default: + break; + } +} + static void msdc_set_mclk(struct msdc_host *host, unsigned char timing, u3= 2 hz) { struct mmc_host *mmc =3D mmc_from_priv(host); @@ -883,6 +951,7 @@ static void msdc_set_mclk(struct msdc_host *host, unsig= ned char timing, u32 hz) u32 sclk; u32 tune_reg =3D host->dev_comp->pad_tune_reg; u32 val; + bool timing_changed; =20 if (!hz) { dev_dbg(host->dev, "set mclk to 0\n"); @@ -892,6 +961,11 @@ static void msdc_set_mclk(struct msdc_host *host, unsi= gned char timing, u32 hz) return; } =20 + if (host->timing !=3D timing) + timing_changed =3D true; + else + timing_changed =3D false; + flags =3D readl(host->base + MSDC_INTEN); sdr_clr_bits(host->base + MSDC_INTEN, flags); if (host->dev_comp->clk_div_bits =3D=3D 8) @@ -998,6 +1072,9 @@ static void msdc_set_mclk(struct msdc_host *host, unsi= gned char timing, u32 hz) sdr_set_field(host->base + tune_reg, MSDC_PAD_TUNE_CMDRRDLY, host->hs400_cmd_int_delay); + if (host->dev_comp->support_new_tx && timing_changed) + msdc_new_tx_setting(host); + dev_dbg(host->dev, "sclk: %d, timing: %d\n", mmc->actual_clock, timing); } @@ -1729,6 +1806,17 @@ static void msdc_init_hw(struct msdc_host *host) reset_control_deassert(host->reset); } =20 + /* New tx/rx enable bit need to be 0->1 for hardware check */ + if (host->dev_comp->support_new_tx) { + sdr_clr_bits(host->base + SDC_ADV_CFG0, SDC_NEW_TX_EN); + sdr_set_bits(host->base + SDC_ADV_CFG0, SDC_NEW_TX_EN); + msdc_new_tx_setting(host); + } + if (host->dev_comp->support_new_rx) { + sdr_clr_bits(host->base + MSDC_NEW_RX_CFG, MSDC_NEW_RX_PATH_SEL); + sdr_set_bits(host->base + MSDC_NEW_RX_CFG, MSDC_NEW_RX_PATH_SEL); + } + /* Configure to MMC/SD mode, clock free running */ sdr_set_bits(host->base + MSDC_CFG, MSDC_CFG_MODE | MSDC_CFG_CKPDN); =20 @@ -2080,6 +2168,19 @@ static inline void msdc_set_data_delay(struct msdc_h= ost *host, u32 value) } } =20 +static inline void msdc_set_data_sample_edge(struct msdc_host *host, bool = rising) +{ + u32 value =3D rising ? 0 : 1; + + if (host->dev_comp->support_new_rx) { + sdr_set_field(host->base + MSDC_PATCH_BIT, MSDC_PATCH_BIT_RD_DAT_SEL, va= lue); + sdr_set_field(host->base + MSDC_PATCH_BIT2, MSDC_PB2_CFGCRCSTSEDGE, valu= e); + } else { + sdr_set_field(host->base + MSDC_IOCON, MSDC_IOCON_DSPL, value); + sdr_set_field(host->base + MSDC_IOCON, MSDC_IOCON_W_DSPL, value); + } +} + static int msdc_tune_response(struct mmc_host *mmc, u32 opcode) { struct msdc_host *host =3D mmc_priv(mmc); @@ -2235,8 +2336,7 @@ static int msdc_tune_data(struct mmc_host *mmc, u32 o= pcode) =20 sdr_set_field(host->base + MSDC_PATCH_BIT, MSDC_INT_DAT_LATCH_CK_SEL, host->latch_ck); - sdr_clr_bits(host->base + MSDC_IOCON, MSDC_IOCON_DSPL); - sdr_clr_bits(host->base + MSDC_IOCON, MSDC_IOCON_W_DSPL); + msdc_set_data_sample_edge(host, true); for (i =3D 0; i < host->tuning_step; i++) { msdc_set_data_delay(host, i); ret =3D mmc_send_tuning(mmc, opcode, NULL); @@ -2249,8 +2349,7 @@ static int msdc_tune_data(struct mmc_host *mmc, u32 o= pcode) (final_rise_delay.start =3D=3D 0 && final_rise_delay.maxlen >=3D 4)) goto skip_fall; =20 - sdr_set_bits(host->base + MSDC_IOCON, MSDC_IOCON_DSPL); - sdr_set_bits(host->base + MSDC_IOCON, MSDC_IOCON_W_DSPL); + msdc_set_data_sample_edge(host, false); for (i =3D 0; i < host->tuning_step; i++) { msdc_set_data_delay(host, i); ret =3D mmc_send_tuning(mmc, opcode, NULL); @@ -2262,12 +2361,10 @@ static int msdc_tune_data(struct mmc_host *mmc, u32= opcode) skip_fall: final_maxlen =3D max(final_rise_delay.maxlen, final_fall_delay.maxlen); if (final_maxlen =3D=3D final_rise_delay.maxlen) { - sdr_clr_bits(host->base + MSDC_IOCON, MSDC_IOCON_DSPL); - sdr_clr_bits(host->base + MSDC_IOCON, MSDC_IOCON_W_DSPL); + msdc_set_data_sample_edge(host, true); final_delay =3D final_rise_delay.final_phase; } else { - sdr_set_bits(host->base + MSDC_IOCON, MSDC_IOCON_DSPL); - sdr_set_bits(host->base + MSDC_IOCON, MSDC_IOCON_W_DSPL); + msdc_set_data_sample_edge(host, false); final_delay =3D final_fall_delay.final_phase; } msdc_set_data_delay(host, final_delay); @@ -2292,8 +2389,7 @@ static int msdc_tune_together(struct mmc_host *mmc, u= 32 opcode) host->latch_ck); =20 sdr_clr_bits(host->base + MSDC_IOCON, MSDC_IOCON_RSPL); - sdr_clr_bits(host->base + MSDC_IOCON, - MSDC_IOCON_DSPL | MSDC_IOCON_W_DSPL); + msdc_set_data_sample_edge(host, true); for (i =3D 0; i < host->tuning_step; i++) { msdc_set_cmd_delay(host, i); msdc_set_data_delay(host, i); @@ -2308,8 +2404,7 @@ static int msdc_tune_together(struct mmc_host *mmc, u= 32 opcode) goto skip_fall; =20 sdr_set_bits(host->base + MSDC_IOCON, MSDC_IOCON_RSPL); - sdr_set_bits(host->base + MSDC_IOCON, - MSDC_IOCON_DSPL | MSDC_IOCON_W_DSPL); + msdc_set_data_sample_edge(host, false); for (i =3D 0; i < host->tuning_step; i++) { msdc_set_cmd_delay(host, i); msdc_set_data_delay(host, i); @@ -2323,13 +2418,11 @@ static int msdc_tune_together(struct mmc_host *mmc,= u32 opcode) final_maxlen =3D max(final_rise_delay.maxlen, final_fall_delay.maxlen); if (final_maxlen =3D=3D final_rise_delay.maxlen) { sdr_clr_bits(host->base + MSDC_IOCON, MSDC_IOCON_RSPL); - sdr_clr_bits(host->base + MSDC_IOCON, - MSDC_IOCON_DSPL | MSDC_IOCON_W_DSPL); + msdc_set_data_sample_edge(host, true); final_delay =3D final_rise_delay.final_phase; } else { sdr_set_bits(host->base + MSDC_IOCON, MSDC_IOCON_RSPL); - sdr_set_bits(host->base + MSDC_IOCON, - MSDC_IOCON_DSPL | MSDC_IOCON_W_DSPL); + msdc_set_data_sample_edge(host, false); final_delay =3D final_fall_delay.final_phase; } =20 @@ -2349,8 +2442,7 @@ static int msdc_execute_tuning(struct mmc_host *mmc, = u32 opcode) if (host->dev_comp->data_tune && host->dev_comp->async_fifo) { ret =3D msdc_tune_together(mmc, opcode); if (host->hs400_mode) { - sdr_clr_bits(host->base + MSDC_IOCON, - MSDC_IOCON_DSPL | MSDC_IOCON_W_DSPL); + msdc_set_data_sample_edge(host, true); msdc_set_data_delay(host, 0); } goto tune_done; @@ -3013,6 +3105,8 @@ static void msdc_save_reg(struct msdc_host *host) readl(host->top_base + EMMC_TOP_CMD); host->save_para.emmc50_pad_ds_tune =3D readl(host->top_base + EMMC50_PAD_DS_TUNE); + host->save_para.loop_test_control =3D + readl(host->top_base + LOOP_TEST_CONTROL); } else { host->save_para.pad_tune =3D readl(host->base + tune_reg); } @@ -3023,6 +3117,15 @@ static void msdc_restore_reg(struct msdc_host *host) struct mmc_host *mmc =3D mmc_from_priv(host); u32 tune_reg =3D host->dev_comp->pad_tune_reg; =20 + if (host->dev_comp->support_new_tx) { + sdr_clr_bits(host->base + SDC_ADV_CFG0, SDC_NEW_TX_EN); + sdr_set_bits(host->base + SDC_ADV_CFG0, SDC_NEW_TX_EN); + } + if (host->dev_comp->support_new_rx) { + sdr_clr_bits(host->base + MSDC_NEW_RX_CFG, MSDC_NEW_RX_PATH_SEL); + sdr_set_bits(host->base + MSDC_NEW_RX_CFG, MSDC_NEW_RX_PATH_SEL); + } + writel(host->save_para.msdc_cfg, host->base + MSDC_CFG); writel(host->save_para.iocon, host->base + MSDC_IOCON); writel(host->save_para.sdc_cfg, host->base + SDC_CFG); @@ -3041,6 +3144,8 @@ static void msdc_restore_reg(struct msdc_host *host) host->top_base + EMMC_TOP_CMD); writel(host->save_para.emmc50_pad_ds_tune, host->top_base + EMMC50_PAD_DS_TUNE); + writel(host->save_para.loop_test_control, + host->top_base + LOOP_TEST_CONTROL); } else { writel(host->save_para.pad_tune, host->base + tune_reg); } --=20 2.46.0 From nobody Wed Nov 27 14:24:02 2024 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 994EA193419; Wed, 9 Oct 2024 12:02:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.61.82.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728475359; cv=none; b=UlAv2yw81n7J+CA5JWTRu+E/nfb0SJdQ+y5Gre0/nghifbgS+m3W3n1DoO4drL+4gIIenOqyPX4mzNSmJj7nB3GvPDmYt4DIFe7qdW2UcY0+B9I/ryt74J0Y1TUXjOccxm0wopWvOsauW65ySPyWM0gnzOTFJHiIALfh3jqPcW0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728475359; c=relaxed/simple; bh=dTDPMLoZorrqylWtp+YQ9hnQ5Pl0DFCJLiIGDQaWHao=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=n2FWqamC4YxuAeadeL/+KSarRaZoSIVeWAboUMNzyJXrmjfdPKmGk2YnwwgsqS89QScY7EWe2JWfjx2G77Hx2XHHTO2kCP2QXEnu1zqNdF8PEolTp56ZDopsOvCUkZxKeTBhRpFiQKd3Zw9PsenZDBd8u16wbpk70GBCWVUhBCU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=L/OOugeE; arc=none smtp.client-ip=210.61.82.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="L/OOugeE" X-UUID: 5dc2fcee863611ef8b96093e013ec31c-20241009 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=cCFgt0IrDJ3aytJWYF5ZrJUB8rR7Z0oxk791XYevk+s=; b=L/OOugeExjg8c9x5haP+r9RffuxJm7ib3Afc92VAOhc1KtZxM9eT9ihRBLXqc93zqB/NqBjQ/c8QeKeDFo932E8raInz4VLO5I1v1KqSYr5nSLjrH9GmK3kANfkC9OqzrpHNInJKL88ypjuznQFUvjamltmLfxzUxihOfWMnbAw=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.41,REQID:6706dc4e-0100-4516-b6b5-f5ecd70db56c,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:6dc6a47,CLOUDID:a2178a26-5902-4533-af4f-d0904aa89b3c,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES :1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_ULN X-UUID: 5dc2fcee863611ef8b96093e013ec31c-20241009 Received: from mtkmbs09n2.mediatek.inc [(172.21.101.94)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 890033064; Wed, 09 Oct 2024 20:02:33 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Wed, 9 Oct 2024 20:02:31 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Wed, 9 Oct 2024 20:02:31 +0800 From: Andy-ld Lu To: , , , , , CC: , , , , , Andy-ld Lu Subject: [PATCH v3 2/3] mmc: mtk-sd: Add two settings in platdata Date: Wed, 9 Oct 2024 20:01:25 +0800 Message-ID: <20241009120203.14913-3-andy-ld.lu@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241009120203.14913-1-andy-ld.lu@mediatek.com> References: <20241009120203.14913-1-andy-ld.lu@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- 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 */ =20 @@ -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 = =3D { .data_tune =3D true, .busy_check =3D true, .stop_clk_fix =3D true, + .stop_dly_sel =3D 3, .enhance_rx =3D true, .support_64g =3D true, }; @@ -534,6 +538,7 @@ static const struct mtk_mmc_compatible mt6779_compat = =3D { .data_tune =3D true, .busy_check =3D true, .stop_clk_fix =3D true, + .stop_dly_sel =3D 3, .enhance_rx =3D true, .support_64g =3D true, }; @@ -573,6 +578,7 @@ static const struct mtk_mmc_compatible mt7622_compat = =3D { .data_tune =3D true, .busy_check =3D true, .stop_clk_fix =3D true, + .stop_dly_sel =3D 3, .enhance_rx =3D true, .support_64g =3D false, }; @@ -586,6 +592,7 @@ static const struct mtk_mmc_compatible mt7986_compat = =3D { .data_tune =3D true, .busy_check =3D true, .stop_clk_fix =3D true, + .stop_dly_sel =3D 3, .enhance_rx =3D true, .support_64g =3D true, }; @@ -625,6 +632,7 @@ static const struct mtk_mmc_compatible mt8183_compat = =3D { .data_tune =3D true, .busy_check =3D true, .stop_clk_fix =3D true, + .stop_dly_sel =3D 3, .enhance_rx =3D true, .support_64g =3D true, }; @@ -638,6 +646,7 @@ static const struct mtk_mmc_compatible mt8516_compat = =3D { .data_tune =3D true, .busy_check =3D true, .stop_clk_fix =3D true, + .stop_dly_sel =3D 3, }; =20 static const struct mtk_mmc_compatible mt8196_compat =3D { @@ -649,6 +658,8 @@ static const struct mtk_mmc_compatible mt8196_compat = =3D { .data_tune =3D true, .busy_check =3D true, .stop_clk_fix =3D true, + .stop_dly_sel =3D 1, + .pop_en_cnt =3D 2, .enhance_rx =3D true, .support_64g =3D true, .support_new_tx =3D 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); =20 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, --=20 2.46.0 From nobody Wed Nov 27 14:24:02 2024 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1DA84192B89; Wed, 9 Oct 2024 12:02:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728475367; cv=none; b=QBWtFJIJTgIzsmWF4rqwP2n74nXUvuGuwoCFivR85ANT38tfYCc+Am3bYl+9cjs0+DdWn6WqTE6vRZh/nULsXEkmDreEWzcmxIKXtPmp70PQpeSExoijxiiXHk9HPGip7MMsrpp3NDgS3uU2TK9tfI8Q6ui6nqsSIFgoqP1ba+k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728475367; c=relaxed/simple; bh=5eJ5itnq5Pqo2kCd+48EfVWhNr9i4pzZ8iS7x/qcYKc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CXiFg39mfpCjRXMDImLyMCmbPHnpl2YfijnX2IVa2BSe+vvBeCDajyXQ62KoERqten9J0vdRYEfq2Mm3fhBztTrM/1KoIw9LyAnxMKw94mwPv5mZVYU3bvU4AmJQGj4q2Atx30p6ZnuyT9EQtNYgymBzcUj7eB6Pi5XdU4NCMC0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=J2yN2wWv; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="J2yN2wWv" X-UUID: 6127667c863611ef88ecadb115cee93b-20241009 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=0HZS/yt81yGM8+lk4cRjFAiTKAwgRjPBEqGkttJks2E=; b=J2yN2wWvcJj7fWAxi2uQ0GiJfEaN2dMt3RLgzcpdlUPDgYiVjPu9w3EAobvyGA36vEM5+64Ww0bQA4h8mg1gXAmq/oIOjSzDePIz/RYrZ7snXL/QqgNvnRRXCiGK57JV/dXTFAmCf7IgwTG8zuy3PBrrxfk/lrrMTneDVafzuo8=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.41,REQID:7ccae316-1702-40d6-b998-af3b96d4bb48,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:6dc6a47,CLOUDID:ebc6fe64-444a-4b47-a99a-591ade3b04b2,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES :1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_ULN X-UUID: 6127667c863611ef88ecadb115cee93b-20241009 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1072874375; Wed, 09 Oct 2024 20:02:38 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Wed, 9 Oct 2024 20:02:37 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Wed, 9 Oct 2024 20:02:36 +0800 From: Andy-ld Lu To: , , , , , CC: , , , , , Andy-ld Lu , Krzysztof Kozlowski Subject: [PATCH v3 3/3] dt-bindings: mmc: mtk-sd: Add support for MT8196 Date: Wed, 9 Oct 2024 20:01:26 +0800 Message-ID: <20241009120203.14913-4-andy-ld.lu@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241009120203.14913-1-andy-ld.lu@mediatek.com> References: <20241009120203.14913-1-andy-ld.lu@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Extend the devicetree bindings to include the MT8196 mmc controller, new tx/rx would be supported from MT8196, and the register settings of STOP_DLY_SEL and POP_EN_CNT would also be variant. Signed-off-by: Andy-ld Lu Acked-by: Krzysztof Kozlowski Reviewed-by: AngeloGioacchino Del Regno --- Documentation/devicetree/bindings/mmc/mtk-sd.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/mmc/mtk-sd.yaml b/Documentat= ion/devicetree/bindings/mmc/mtk-sd.yaml index c532ec92d2d9..9281a0326891 100644 --- a/Documentation/devicetree/bindings/mmc/mtk-sd.yaml +++ b/Documentation/devicetree/bindings/mmc/mtk-sd.yaml @@ -24,6 +24,7 @@ properties: - mediatek,mt8135-mmc - mediatek,mt8173-mmc - mediatek,mt8183-mmc + - mediatek,mt8196-mmc - mediatek,mt8516-mmc - items: - const: mediatek,mt7623-mmc @@ -190,6 +191,7 @@ allOf: - mediatek,mt8186-mmc - mediatek,mt8188-mmc - mediatek,mt8195-mmc + - mediatek,mt8196-mmc - mediatek,mt8516-mmc then: properties: --=20 2.46.0