* [PATCH 0/3] mmc: sunxi: Support eMMC DDR modes @ 2016-01-29 17:21 Chen-Yu Tsai 2016-01-29 17:21 ` [PATCH 1/3] mmc: sunxi: Support MMC_DDR52 timing modes Chen-Yu Tsai ` (4 more replies) 0 siblings, 5 replies; 6+ messages in thread From: Chen-Yu Tsai @ 2016-01-29 17:21 UTC (permalink / raw) To: linux-arm-kernel Hi everyone, This was "mmc: sunxi: Support vqmmc regulator and eMMC DDR modes". vqmmc support and DT patches were merged even though it was an RFC series, to my suprise. These are the remaining patches that add eMMC HS-DDR support to sunxi. Patch 1 adds timing delays for MMC_DDR52 mode. Patch 2 adds support for 8 bit eMMC DDR52 mode. Under this mode, the controller must run at twice the card clock, and different timing delays are needed. Patch 3 enables eMMC HS-DDR for sunxi-mmc. Changes since RFC: - Dropped patches that are merged - Dropped "mmc: sunxi: Block signal voltage switching (CMD11)". According to Ulf, the mmc core won't send this command unless the UHS capabilities are set. We don't. - Increased f_max to 52 MHz. Clock rate range for 50 MHz timing delay also increased to match. See patch 1. Regards ChenYu Chen-Yu Tsai (3): mmc: sunxi: Support MMC_DDR52 timing modes mmc: sunxi: Support 8 bit eMMC DDR transfer modes mmc: sunxi: Enable eMMC HS-DDR (MMC_CAP_1_8V_DDR) support drivers/mmc/host/sunxi-mmc.c | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) -- 2.7.0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/3] mmc: sunxi: Support MMC_DDR52 timing modes 2016-01-29 17:21 [PATCH 0/3] mmc: sunxi: Support eMMC DDR modes Chen-Yu Tsai @ 2016-01-29 17:21 ` Chen-Yu Tsai 2016-01-29 17:21 ` [PATCH 2/3] mmc: sunxi: Support 8 bit eMMC DDR transfer modes Chen-Yu Tsai ` (3 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: Chen-Yu Tsai @ 2016-01-29 17:21 UTC (permalink / raw) To: linux-arm-kernel DDR transfer modes include UHS-1 DDR50 and MMC HS-DDR (or MMC_DDR52). Consider MMC_DDR52 when setting clock delays. Since MMC high speed mode goes up to 52 MHz instead of 50 MHz for SD, and this number is visible in the capability macro, increase the clock rate upper limit to 52 MHz. Signed-off-by: Chen-Yu Tsai <wens@csie.org> --- drivers/mmc/host/sunxi-mmc.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c index 765dfb9f77ec..fe6c171fd135 100644 --- a/drivers/mmc/host/sunxi-mmc.c +++ b/drivers/mmc/host/sunxi-mmc.c @@ -686,8 +686,9 @@ static int sunxi_mmc_clk_set_rate(struct sunxi_mmc_host *host, } else if (rate <= 25000000) { oclk_dly = host->clk_delays[SDXC_CLK_25M].output; sclk_dly = host->clk_delays[SDXC_CLK_25M].sample; - } else if (rate <= 50000000) { - if (ios->timing == MMC_TIMING_UHS_DDR50) { + } else if (rate <= 52000000) { + if (ios->timing == MMC_TIMING_UHS_DDR50 || + ios->timing == MMC_TIMING_MMC_DDR52) { oclk_dly = host->clk_delays[SDXC_CLK_50M_DDR].output; sclk_dly = host->clk_delays[SDXC_CLK_50M_DDR].sample; } else { @@ -762,7 +763,8 @@ static void sunxi_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) /* set ddr mode */ rval = mmc_readl(host, REG_GCTRL); - if (ios->timing == MMC_TIMING_UHS_DDR50) + if (ios->timing == MMC_TIMING_UHS_DDR50 || + ios->timing == MMC_TIMING_MMC_DDR52) rval |= SDXC_DDR_MODE; else rval &= ~SDXC_DDR_MODE; @@ -1106,9 +1108,9 @@ static int sunxi_mmc_probe(struct platform_device *pdev) mmc->max_segs = PAGE_SIZE / sizeof(struct sunxi_idma_des); mmc->max_seg_size = (1 << host->idma_des_size_bits); mmc->max_req_size = mmc->max_seg_size * mmc->max_segs; - /* 400kHz ~ 50MHz */ + /* 400kHz ~ 52MHz */ mmc->f_min = 400000; - mmc->f_max = 50000000; + mmc->f_max = 52000000; mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED | MMC_CAP_ERASE | MMC_CAP_SDIO_IRQ; -- 2.7.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] mmc: sunxi: Support 8 bit eMMC DDR transfer modes 2016-01-29 17:21 [PATCH 0/3] mmc: sunxi: Support eMMC DDR modes Chen-Yu Tsai 2016-01-29 17:21 ` [PATCH 1/3] mmc: sunxi: Support MMC_DDR52 timing modes Chen-Yu Tsai @ 2016-01-29 17:21 ` Chen-Yu Tsai 2016-01-29 17:21 ` [PATCH 3/3] mmc: sunxi: Enable eMMC HS-DDR (MMC_CAP_1_8V_DDR) support Chen-Yu Tsai ` (2 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: Chen-Yu Tsai @ 2016-01-29 17:21 UTC (permalink / raw) To: linux-arm-kernel Allwinner's MMC controller needs to run at double the card clock rate for 8 bit DDR transfer modes. Interestingly, this is not needed for 4 bit DDR transfers. Different clock delays are needed for 8 bit eMMC DDR, due to the increased module clock rate. For the A80 though, the same values for 4 bit and 8 bit are shared. The new values for the other SoCs were from A83T user manual's "new timing mode" default values, which describes them in clock phase, rather than delay periods. These values were used without any modification. They may not be correct, but they work. Signed-off-by: Chen-Yu Tsai <wens@csie.org> --- drivers/mmc/host/sunxi-mmc.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c index fe6c171fd135..bb4592696046 100644 --- a/drivers/mmc/host/sunxi-mmc.c +++ b/drivers/mmc/host/sunxi-mmc.c @@ -215,6 +215,7 @@ #define SDXC_CLK_25M 1 #define SDXC_CLK_50M 2 #define SDXC_CLK_50M_DDR 3 +#define SDXC_CLK_50M_DDR_8BIT 4 struct sunxi_mmc_clk_delay { u32 output; @@ -656,11 +657,17 @@ static int sunxi_mmc_clk_set_rate(struct sunxi_mmc_host *host, struct mmc_ios *ios) { u32 rate, oclk_dly, rval, sclk_dly; + u32 clock = ios->clock; int ret; - rate = clk_round_rate(host->clk_mmc, ios->clock); + /* 8 bit DDR requires a higher module clock */ + if (ios->timing == MMC_TIMING_MMC_DDR52 && + ios->bus_width == MMC_BUS_WIDTH_8) + clock <<= 1; + + rate = clk_round_rate(host->clk_mmc, clock); dev_dbg(mmc_dev(host->mmc), "setting clk to %d, rounded %d\n", - ios->clock, rate); + clock, rate); /* setting clock rate */ ret = clk_set_rate(host->clk_mmc, rate); @@ -677,6 +684,12 @@ static int sunxi_mmc_clk_set_rate(struct sunxi_mmc_host *host, /* clear internal divider */ rval = mmc_readl(host, REG_CLKCR); rval &= ~0xff; + /* set internal divider for 8 bit eMMC DDR, so card clock is right */ + if (ios->timing == MMC_TIMING_MMC_DDR52 && + ios->bus_width == MMC_BUS_WIDTH_8) { + rval |= 1; + rate >>= 1; + } mmc_writel(host, REG_CLKCR, rval); /* determine delays */ @@ -687,13 +700,16 @@ static int sunxi_mmc_clk_set_rate(struct sunxi_mmc_host *host, oclk_dly = host->clk_delays[SDXC_CLK_25M].output; sclk_dly = host->clk_delays[SDXC_CLK_25M].sample; } else if (rate <= 52000000) { - if (ios->timing == MMC_TIMING_UHS_DDR50 || - ios->timing == MMC_TIMING_MMC_DDR52) { - oclk_dly = host->clk_delays[SDXC_CLK_50M_DDR].output; - sclk_dly = host->clk_delays[SDXC_CLK_50M_DDR].sample; - } else { + if (ios->timing != MMC_TIMING_UHS_DDR50 && + ios->timing != MMC_TIMING_MMC_DDR52) { oclk_dly = host->clk_delays[SDXC_CLK_50M].output; sclk_dly = host->clk_delays[SDXC_CLK_50M].sample; + } else if (ios->bus_width == MMC_BUS_WIDTH_8) { + oclk_dly = host->clk_delays[SDXC_CLK_50M_DDR_8BIT].output; + sclk_dly = host->clk_delays[SDXC_CLK_50M_DDR_8BIT].sample; + } else { + oclk_dly = host->clk_delays[SDXC_CLK_50M_DDR].output; + sclk_dly = host->clk_delays[SDXC_CLK_50M_DDR].sample; } } else { return -EINVAL; @@ -951,6 +967,8 @@ static const struct sunxi_mmc_clk_delay sunxi_mmc_clk_delays[] = { [SDXC_CLK_25M] = { .output = 180, .sample = 75 }, [SDXC_CLK_50M] = { .output = 90, .sample = 120 }, [SDXC_CLK_50M_DDR] = { .output = 60, .sample = 120 }, + /* Value from A83T "new timing mode". Works but might not be right. */ + [SDXC_CLK_50M_DDR_8BIT] = { .output = 90, .sample = 180 }, }; static const struct sunxi_mmc_clk_delay sun9i_mmc_clk_delays[] = { @@ -958,6 +976,7 @@ static const struct sunxi_mmc_clk_delay sun9i_mmc_clk_delays[] = { [SDXC_CLK_25M] = { .output = 180, .sample = 75 }, [SDXC_CLK_50M] = { .output = 150, .sample = 120 }, [SDXC_CLK_50M_DDR] = { .output = 90, .sample = 120 }, + [SDXC_CLK_50M_DDR_8BIT] = { .output = 90, .sample = 120 }, }; static int sunxi_mmc_resource_request(struct sunxi_mmc_host *host, -- 2.7.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] mmc: sunxi: Enable eMMC HS-DDR (MMC_CAP_1_8V_DDR) support 2016-01-29 17:21 [PATCH 0/3] mmc: sunxi: Support eMMC DDR modes Chen-Yu Tsai 2016-01-29 17:21 ` [PATCH 1/3] mmc: sunxi: Support MMC_DDR52 timing modes Chen-Yu Tsai 2016-01-29 17:21 ` [PATCH 2/3] mmc: sunxi: Support 8 bit eMMC DDR transfer modes Chen-Yu Tsai @ 2016-01-29 17:21 ` Chen-Yu Tsai 2016-01-31 9:40 ` [linux-sunxi] [PATCH 0/3] mmc: sunxi: Support eMMC DDR modes Hans de Goede 2016-02-02 13:11 ` Ulf Hansson 4 siblings, 0 replies; 6+ messages in thread From: Chen-Yu Tsai @ 2016-01-29 17:21 UTC (permalink / raw) To: linux-arm-kernel Now that clock delay settings for 8 bit DDR are correct, and vqmmc support is available, we can enable MMC_CAP_1_8V_DDR support. This enables MMC HS-DDR at up to 52 MHz, even if signal voltage switching is not available. Signed-off-by: Chen-Yu Tsai <wens@csie.org> --- There was discussion about an alternative: setting this capability in the DT to preserve DT backwards compatibility. However just setting it in the DT without the driver updates also breaks it. Furthermore, Maxime's latest "clk: sunxi: Refactor A31 PLL6 so that it can be reused" patch will break DT compatility. Given the above, I see no reason to try and maintain compatibility only to fail. --- drivers/mmc/host/sunxi-mmc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c index bb4592696046..2aee17cd85ae 100644 --- a/drivers/mmc/host/sunxi-mmc.c +++ b/drivers/mmc/host/sunxi-mmc.c @@ -1131,6 +1131,7 @@ static int sunxi_mmc_probe(struct platform_device *pdev) mmc->f_min = 400000; mmc->f_max = 52000000; mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED | + MMC_CAP_1_8V_DDR | MMC_CAP_ERASE | MMC_CAP_SDIO_IRQ; ret = mmc_of_parse(mmc); -- 2.7.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [linux-sunxi] [PATCH 0/3] mmc: sunxi: Support eMMC DDR modes 2016-01-29 17:21 [PATCH 0/3] mmc: sunxi: Support eMMC DDR modes Chen-Yu Tsai ` (2 preceding siblings ...) 2016-01-29 17:21 ` [PATCH 3/3] mmc: sunxi: Enable eMMC HS-DDR (MMC_CAP_1_8V_DDR) support Chen-Yu Tsai @ 2016-01-31 9:40 ` Hans de Goede 2016-02-02 13:11 ` Ulf Hansson 4 siblings, 0 replies; 6+ messages in thread From: Hans de Goede @ 2016-01-31 9:40 UTC (permalink / raw) To: linux-arm-kernel Hi, On 01/29/2016 06:21 PM, Chen-Yu Tsai wrote: > Hi everyone, > > This was "mmc: sunxi: Support vqmmc regulator and eMMC DDR modes". vqmmc > support and DT patches were merged even though it was an RFC series, to > my suprise. > > These are the remaining patches that add eMMC HS-DDR support to sunxi. > > Patch 1 adds timing delays for MMC_DDR52 mode. > > Patch 2 adds support for 8 bit eMMC DDR52 mode. Under this mode, the > controller must run at twice the card clock, and different timing delays > are needed. > > Patch 3 enables eMMC HS-DDR for sunxi-mmc. All 3 patches look good to me: Reviewed-by: Hans de Goede <hdegoede@redhat.com> Regards, Hans ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 0/3] mmc: sunxi: Support eMMC DDR modes 2016-01-29 17:21 [PATCH 0/3] mmc: sunxi: Support eMMC DDR modes Chen-Yu Tsai ` (3 preceding siblings ...) 2016-01-31 9:40 ` [linux-sunxi] [PATCH 0/3] mmc: sunxi: Support eMMC DDR modes Hans de Goede @ 2016-02-02 13:11 ` Ulf Hansson 4 siblings, 0 replies; 6+ messages in thread From: Ulf Hansson @ 2016-02-02 13:11 UTC (permalink / raw) To: linux-arm-kernel On 29 January 2016 at 18:21, Chen-Yu Tsai <wens@csie.org> wrote: > Hi everyone, > > This was "mmc: sunxi: Support vqmmc regulator and eMMC DDR modes". vqmmc > support and DT patches were merged even though it was an RFC series, to > my suprise. > > These are the remaining patches that add eMMC HS-DDR support to sunxi. > > Patch 1 adds timing delays for MMC_DDR52 mode. > > Patch 2 adds support for 8 bit eMMC DDR52 mode. Under this mode, the > controller must run at twice the card clock, and different timing delays > are needed. > > Patch 3 enables eMMC HS-DDR for sunxi-mmc. > > > Changes since RFC: > > - Dropped patches that are merged > > - Dropped "mmc: sunxi: Block signal voltage switching (CMD11)". > According to Ulf, the mmc core won't send this command unless the UHS > capabilities are set. We don't. > > - Increased f_max to 52 MHz. Clock rate range for 50 MHz timing delay > also increased to match. See patch 1. > > > Regards > ChenYu > > > Chen-Yu Tsai (3): > mmc: sunxi: Support MMC_DDR52 timing modes > mmc: sunxi: Support 8 bit eMMC DDR transfer modes > mmc: sunxi: Enable eMMC HS-DDR (MMC_CAP_1_8V_DDR) support > > drivers/mmc/host/sunxi-mmc.c | 42 ++++++++++++++++++++++++++++++++---------- > 1 file changed, 32 insertions(+), 10 deletions(-) > > -- > 2.7.0 > Thanks, applied for next! Kind regards Uffe ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-02-02 13:11 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-01-29 17:21 [PATCH 0/3] mmc: sunxi: Support eMMC DDR modes Chen-Yu Tsai 2016-01-29 17:21 ` [PATCH 1/3] mmc: sunxi: Support MMC_DDR52 timing modes Chen-Yu Tsai 2016-01-29 17:21 ` [PATCH 2/3] mmc: sunxi: Support 8 bit eMMC DDR transfer modes Chen-Yu Tsai 2016-01-29 17:21 ` [PATCH 3/3] mmc: sunxi: Enable eMMC HS-DDR (MMC_CAP_1_8V_DDR) support Chen-Yu Tsai 2016-01-31 9:40 ` [linux-sunxi] [PATCH 0/3] mmc: sunxi: Support eMMC DDR modes Hans de Goede 2016-02-02 13:11 ` Ulf Hansson
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).