|
|
|
@ -23,7 +23,7 @@ Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
|
|
|
|
|
#define PAD_DS_TUNE 0x188
|
|
|
|
|
#define PAD_CMD_TUNE 0x18c
|
|
|
|
|
#define EMMC50_CFG0 0x208
|
|
|
|
|
@@ -301,6 +302,7 @@ struct msdc_save_para {
|
|
|
|
|
@@ -303,6 +304,7 @@ struct msdc_save_para {
|
|
|
|
|
struct mtk_mmc_compatible {
|
|
|
|
|
u8 clk_div_bits;
|
|
|
|
|
bool hs400_tune; /* only used for MT8173 */
|
|
|
|
@ -31,7 +31,7 @@ Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct msdc_tune_para {
|
|
|
|
|
@@ -362,21 +364,25 @@ struct msdc_host {
|
|
|
|
|
@@ -364,21 +366,25 @@ struct msdc_host {
|
|
|
|
|
static const struct mtk_mmc_compatible mt8135_compat = {
|
|
|
|
|
.clk_div_bits = 8,
|
|
|
|
|
.hs400_tune = false,
|
|
|
|
@ -57,7 +57,7 @@ Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const struct of_device_id msdc_of_ids[] = {
|
|
|
|
|
@@ -581,6 +587,7 @@ static void msdc_set_mclk(struct msdc_ho
|
|
|
|
|
@@ -583,6 +589,7 @@ static void msdc_set_mclk(struct msdc_ho
|
|
|
|
|
u32 flags;
|
|
|
|
|
u32 div;
|
|
|
|
|
u32 sclk;
|
|
|
|
@ -65,7 +65,7 @@ Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
|
|
|
|
|
|
|
|
|
|
if (!hz) {
|
|
|
|
|
dev_dbg(host->dev, "set mclk to 0\n");
|
|
|
|
|
@@ -663,10 +670,10 @@ static void msdc_set_mclk(struct msdc_ho
|
|
|
|
|
@@ -665,10 +672,10 @@ static void msdc_set_mclk(struct msdc_ho
|
|
|
|
|
*/
|
|
|
|
|
if (host->sclk <= 52000000) {
|
|
|
|
|
writel(host->def_tune_para.iocon, host->base + MSDC_IOCON);
|
|
|
|
@ -78,7 +78,7 @@ Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
|
|
|
|
|
writel(host->saved_tune_para.pad_cmd_tune,
|
|
|
|
|
host->base + PAD_CMD_TUNE);
|
|
|
|
|
}
|
|
|
|
|
@@ -1224,6 +1231,7 @@ static irqreturn_t msdc_irq(int irq, voi
|
|
|
|
|
@@ -1226,6 +1233,7 @@ static irqreturn_t msdc_irq(int irq, voi
|
|
|
|
|
static void msdc_init_hw(struct msdc_host *host)
|
|
|
|
|
{
|
|
|
|
|
u32 val;
|
|
|
|
@ -86,7 +86,7 @@ Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
|
|
|
|
|
|
|
|
|
|
/* Configure to MMC/SD mode, clock free running */
|
|
|
|
|
sdr_set_bits(host->base + MSDC_CFG, MSDC_CFG_MODE | MSDC_CFG_CKPDN);
|
|
|
|
|
@@ -1239,7 +1247,7 @@ static void msdc_init_hw(struct msdc_hos
|
|
|
|
|
@@ -1241,7 +1249,7 @@ static void msdc_init_hw(struct msdc_hos
|
|
|
|
|
val = readl(host->base + MSDC_INT);
|
|
|
|
|
writel(val, host->base + MSDC_INT);
|
|
|
|
|
|
|
|
|
@ -95,7 +95,7 @@ Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
|
|
|
|
|
writel(0, host->base + MSDC_IOCON);
|
|
|
|
|
sdr_set_field(host->base + MSDC_IOCON, MSDC_IOCON_DDLSEL, 0);
|
|
|
|
|
writel(0x403c0046, host->base + MSDC_PATCH_BIT);
|
|
|
|
|
@@ -1259,7 +1267,7 @@ static void msdc_init_hw(struct msdc_hos
|
|
|
|
|
@@ -1261,7 +1269,7 @@ static void msdc_init_hw(struct msdc_hos
|
|
|
|
|
sdr_set_field(host->base + SDC_CFG, SDC_CFG_DTOC, 3);
|
|
|
|
|
|
|
|
|
|
host->def_tune_para.iocon = readl(host->base + MSDC_IOCON);
|
|
|
|
@ -104,7 +104,7 @@ Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
|
|
|
|
|
dev_dbg(host->dev, "init hardware done!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1402,18 +1410,19 @@ static int msdc_tune_response(struct mmc
|
|
|
|
|
@@ -1404,18 +1412,19 @@ static int msdc_tune_response(struct mmc
|
|
|
|
|
struct msdc_delay_phase internal_delay_phase;
|
|
|
|
|
u8 final_delay, final_maxlen;
|
|
|
|
|
u32 internal_delay = 0;
|
|
|
|
@ -126,7 +126,7 @@ Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
|
|
|
|
|
MSDC_PAD_TUNE_CMDRDLY, i);
|
|
|
|
|
/*
|
|
|
|
|
* Using the same parameters, it may sometimes pass the test,
|
|
|
|
|
@@ -1437,7 +1446,7 @@ static int msdc_tune_response(struct mmc
|
|
|
|
|
@@ -1439,7 +1448,7 @@ static int msdc_tune_response(struct mmc
|
|
|
|
|
|
|
|
|
|
sdr_set_bits(host->base + MSDC_IOCON, MSDC_IOCON_RSPL);
|
|
|
|
|
for (i = 0; i < PAD_DELAY_MAX; i++) {
|
|
|
|
@ -135,7 +135,7 @@ Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
|
|
|
|
|
MSDC_PAD_TUNE_CMDRDLY, i);
|
|
|
|
|
/*
|
|
|
|
|
* Using the same parameters, it may sometimes pass the test,
|
|
|
|
|
@@ -1462,12 +1471,12 @@ skip_fall:
|
|
|
|
|
@@ -1464,12 +1473,12 @@ skip_fall:
|
|
|
|
|
final_maxlen = final_fall_delay.maxlen;
|
|
|
|
|
if (final_maxlen == final_rise_delay.maxlen) {
|
|
|
|
|
sdr_clr_bits(host->base + MSDC_IOCON, MSDC_IOCON_RSPL);
|
|
|
|
@ -150,7 +150,7 @@ Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
|
|
|
|
|
final_fall_delay.final_phase);
|
|
|
|
|
final_delay = final_fall_delay.final_phase;
|
|
|
|
|
}
|
|
|
|
|
@@ -1475,7 +1484,7 @@ skip_fall:
|
|
|
|
|
@@ -1477,7 +1486,7 @@ skip_fall:
|
|
|
|
|
goto skip_internal;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < PAD_DELAY_MAX; i++) {
|
|
|
|
@ -159,7 +159,7 @@ Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
|
|
|
|
|
MSDC_PAD_TUNE_CMDRRDLY, i);
|
|
|
|
|
mmc_send_tuning(mmc, opcode, &cmd_err);
|
|
|
|
|
if (!cmd_err)
|
|
|
|
|
@@ -1483,7 +1492,7 @@ skip_fall:
|
|
|
|
|
@@ -1485,7 +1494,7 @@ skip_fall:
|
|
|
|
|
}
|
|
|
|
|
dev_dbg(host->dev, "Final internal delay: 0x%x\n", internal_delay);
|
|
|
|
|
internal_delay_phase = get_best_delay(host, internal_delay);
|
|
|
|
@ -168,7 +168,7 @@ Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
|
|
|
|
|
internal_delay_phase.final_phase);
|
|
|
|
|
skip_internal:
|
|
|
|
|
dev_dbg(host->dev, "Final cmd pad delay: %x\n", final_delay);
|
|
|
|
|
@@ -1545,12 +1554,13 @@ static int msdc_tune_data(struct mmc_hos
|
|
|
|
|
@@ -1548,12 +1557,13 @@ static int msdc_tune_data(struct mmc_hos
|
|
|
|
|
u32 rise_delay = 0, fall_delay = 0;
|
|
|
|
|
struct msdc_delay_phase final_rise_delay, final_fall_delay = { 0,};
|
|
|
|
|
u8 final_delay, final_maxlen;
|
|
|
|
@ -183,7 +183,7 @@ Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
|
|
|
|
|
MSDC_PAD_TUNE_DATRRDLY, i);
|
|
|
|
|
ret = mmc_send_tuning(mmc, opcode, NULL);
|
|
|
|
|
if (!ret)
|
|
|
|
|
@@ -1565,7 +1575,7 @@ static int msdc_tune_data(struct mmc_hos
|
|
|
|
|
@@ -1568,7 +1578,7 @@ static int msdc_tune_data(struct mmc_hos
|
|
|
|
|
sdr_set_bits(host->base + MSDC_IOCON, MSDC_IOCON_DSPL);
|
|
|
|
|
sdr_set_bits(host->base + MSDC_IOCON, MSDC_IOCON_W_DSPL);
|
|
|
|
|
for (i = 0; i < PAD_DELAY_MAX; i++) {
|
|
|
|
@ -192,7 +192,7 @@ Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
|
|
|
|
|
MSDC_PAD_TUNE_DATRRDLY, i);
|
|
|
|
|
ret = mmc_send_tuning(mmc, opcode, NULL);
|
|
|
|
|
if (!ret)
|
|
|
|
|
@@ -1578,14 +1588,14 @@ skip_fall:
|
|
|
|
|
@@ -1581,14 +1591,14 @@ skip_fall:
|
|
|
|
|
if (final_maxlen == 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);
|
|
|
|
@ -209,7 +209,7 @@ Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
|
|
|
|
|
MSDC_PAD_TUNE_DATRRDLY,
|
|
|
|
|
final_fall_delay.final_phase);
|
|
|
|
|
final_delay = final_fall_delay.final_phase;
|
|
|
|
|
@@ -1599,6 +1609,7 @@ static int msdc_execute_tuning(struct mm
|
|
|
|
|
@@ -1602,6 +1612,7 @@ static int msdc_execute_tuning(struct mm
|
|
|
|
|
{
|
|
|
|
|
struct msdc_host *host = mmc_priv(mmc);
|
|
|
|
|
int ret;
|
|
|
|
@ -217,7 +217,7 @@ Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
|
|
|
|
|
|
|
|
|
|
if (host->hs400_mode &&
|
|
|
|
|
host->dev_comp->hs400_tune)
|
|
|
|
|
@@ -1616,7 +1627,7 @@ static int msdc_execute_tuning(struct mm
|
|
|
|
|
@@ -1619,7 +1630,7 @@ static int msdc_execute_tuning(struct mm
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
host->saved_tune_para.iocon = readl(host->base + MSDC_IOCON);
|
|
|
|
@ -226,7 +226,7 @@ Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
|
|
|
|
|
host->saved_tune_para.pad_cmd_tune = readl(host->base + PAD_CMD_TUNE);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
@@ -1857,10 +1868,12 @@ static int msdc_drv_remove(struct platfo
|
|
|
|
|
@@ -1860,10 +1871,12 @@ static int msdc_drv_remove(struct platfo
|
|
|
|
|
#ifdef CONFIG_PM
|
|
|
|
|
static void msdc_save_reg(struct msdc_host *host)
|
|
|
|
|
{
|
|
|
|
@ -240,7 +240,7 @@ Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
|
|
|
|
|
host->save_para.patch_bit0 = readl(host->base + MSDC_PATCH_BIT);
|
|
|
|
|
host->save_para.patch_bit1 = readl(host->base + MSDC_PATCH_BIT1);
|
|
|
|
|
host->save_para.pad_ds_tune = readl(host->base + PAD_DS_TUNE);
|
|
|
|
|
@@ -1870,10 +1883,12 @@ static void msdc_save_reg(struct msdc_ho
|
|
|
|
|
@@ -1873,10 +1886,12 @@ static void msdc_save_reg(struct msdc_ho
|
|
|
|
|
|
|
|
|
|
static void msdc_restore_reg(struct msdc_host *host)
|
|
|
|
|
{
|
|
|
|
|