Skip to content

Commit 773e639

Browse files
Chandrakala ChavvaSomasundaram Krishnasamy
authored andcommitted
driver: mmc: octeontx2: Fix tuning for T96 C0
Need to enable and disable emmc clock when updating timing parameters in T96 C0. Change-Id: I8d34918b961d9b466eb2b7465a6fb2610dd6acdc Signed-off-by: Chandrakala Chavva <[email protected]> Reviewed-on: https://sj1git1.cavium.com/21284 Reviewed-by: Chandrakala Chavva <[email protected]> Tested-by: sa_ip-sw-jenkins <[email protected]> Reviewed-on: https://sj1git1.cavium.com/23928 Reviewed-by: Sunil Kovvuri Goutham <[email protected]> Reviewed-on: https://sj1git1.cavium.com/24028 Tested-by: Sunil Kovvuri Goutham <[email protected]> Jira: LINUX-4695 Orabug: 30969935 Signed-off-by: Dave Kleikamp <[email protected]> Reviewed-by: Karl Volz <[email protected]> Signed-off-by: Somasundaram Krishnasamy <[email protected]>
1 parent 5195fee commit 773e639

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

drivers/mmc/host/cavium-thunderx.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void thunder_calibrate_mmc(struct cvm_mmc_host *host)
7272
if (is_mmc_otx2_A0(host) || is_mmc_95xx(host))
7373
writeq(1, host->base + MIO_EMM_DEBUG(host));
7474

75-
if (is_mmc_otx2_A0(host)) {
75+
if (is_mmc_otx2_A0(host) || is_mmc_otx2_C0(host)) {
7676
/*
7777
* Operation of up to 100 MHz may be achieved by skipping the
7878
* steps that establish the tap delays and instead assuming
@@ -150,7 +150,6 @@ void thunder_calibrate_mmc(struct cvm_mmc_host *host)
150150
writeq(emm_switch, host->base + MIO_EMM_SWITCH(host));
151151
writeq(emm_io_ctl, host->base + MIO_EMM_IO_CTL(host));
152152
mdelay(1);
153-
154153
}
155154

156155
/*

drivers/mmc/host/cavium.c

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,46 @@ bool cvm_is_mmc_timing_ddr(struct cvm_mmc_slot *slot)
148148
return false;
149149
}
150150

151+
static void cvm_mmc_clk_config(struct cvm_mmc_host *host, bool flag)
152+
{
153+
u64 emm_debug;
154+
155+
if (!is_mmc_otx2_C0(host))
156+
return;
157+
158+
/* Turn off the clock */
159+
if (flag) {
160+
emm_debug = readq(host->base + MIO_EMM_DEBUG(host));
161+
emm_debug |= MIO_EMM_DEBUG_CLK_DIS;
162+
writeq(emm_debug, host->base + MIO_EMM_DEBUG(host));
163+
udelay(1);
164+
emm_debug = readq(host->base + MIO_EMM_DEBUG(host));
165+
emm_debug |= MIO_EMM_DEBUG_RDSYNC;
166+
writeq(emm_debug, host->base + MIO_EMM_DEBUG(host));
167+
udelay(1);
168+
} else {
169+
/* Turn on the clock */
170+
emm_debug = readq(host->base + MIO_EMM_DEBUG(host));
171+
emm_debug &= MIO_EMM_DEBUG_RDSYNC;
172+
writeq(emm_debug, host->base + MIO_EMM_DEBUG(host));
173+
udelay(1);
174+
emm_debug = readq(host->base + MIO_EMM_DEBUG(host));
175+
emm_debug &= MIO_EMM_DEBUG_CLK_DIS;
176+
writeq(emm_debug, host->base + MIO_EMM_DEBUG(host));
177+
udelay(1);
178+
}
179+
}
180+
151181
static void cvm_mmc_set_timing(struct cvm_mmc_slot *slot)
152182
{
153-
if (is_mmc_8xxx(slot->host))
183+
struct cvm_mmc_host *host = slot->host;
184+
185+
if (is_mmc_8xxx(host))
154186
return;
155187

156-
writeq(slot->taps, slot->host->base + MIO_EMM_TIMING(slot->host));
188+
cvm_mmc_clk_config(host, CLK_OFF);
189+
writeq(slot->taps, host->base + MIO_EMM_TIMING(host));
190+
cvm_mmc_clk_config(host, CLK_ON);
157191
}
158192

159193
static int tout(struct cvm_mmc_slot *slot, int ps, int hint)
@@ -1328,11 +1362,13 @@ static int adjust_tuning(struct mmc_host *mmc, struct adj *adj, u32 opcode)
13281362
/* loop over range+1 to simplify processing */
13291363
for (tap = 0; tap <= MAX_NO_OF_TAPS; tap++, prev_ok = !err) {
13301364
if (tap < MAX_NO_OF_TAPS) {
1365+
cvm_mmc_clk_config(host, CLK_OFF);
13311366
timing = readq(host->base + MIO_EMM_TIMING(host));
13321367
timing &= ~adj->mask;
13331368
timing |= (tap << __bf_shf(adj->mask));
13341369
writeq(timing, host->base + MIO_EMM_TIMING(host));
13351370

1371+
cvm_mmc_clk_config(host, CLK_ON);
13361372
err = adj->test(mmc, NULL, opcode);
13371373

13381374
how[tap] = "-+"[!err];

drivers/mmc/host/cavium.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
#define PS_400 (400)
6060
#define MAX_NO_OF_TAPS 64
6161

62+
/* Macros to enable/disable clks */
63+
#define CLK_ON 0
64+
#define CLK_OFF 1
65+
6266

6367
/* DMA register addresses */
6468
#define MIO_EMM_DMA_FIFO_CFG(x) (0x00 + x->reg_off_dma)
@@ -288,6 +292,8 @@ struct cvm_mmc_cr_mods {
288292
#define MIO_EMM_SWITCH_CLK GENMASK_ULL(31, 0)
289293
#define MIO_EMM_SWITCH_CLK_HI GENMASK_ULL(31, 16)
290294
#define MIO_EMM_SWITCH_CLK_LO GENMASK_ULL(15, 0)
295+
#define MIO_EMM_DEBUG_CLK_DIS BIT_ULL(20)
296+
#define MIO_EMM_DEBUG_RDSYNC BIT_ULL(21)
291297

292298
/* Protoypes */
293299
irqreturn_t cvm_mmc_interrupt(int irq, void *dev_id);

0 commit comments

Comments
 (0)