* [PATCH V3 1/2] mmc: dw_mmc: Convert to mmc_send_tuning()
@ 2014-12-23 16:02 Ulf Hansson
2014-12-23 16:02 ` [PATCH V3 2/2] mmc: core: Make tuning block patterns static Ulf Hansson
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Ulf Hansson @ 2014-12-23 16:02 UTC (permalink / raw)
To: linux-mmc, Ulf Hansson, Chris Ball
Cc: Seungwon Jeon, Jaehoon Chung, Stephen Boyd
Instead of having a local hack taking care of sending the tuning
command and as well to verify the response pattern, let's convert to
the common mmc_send_tuning() API.
This change affects the Exynos variant, since it's the only one which
support the dw_mmc's ->execute_tuning() callback.
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
Changes in v3:
Fix return value from dw_mci_exynos_execute_tuning() according to
comment from Jaehoon Chung.
---
drivers/mmc/host/dw_mmc-exynos.c | 48 +++-------------------------------------
drivers/mmc/host/dw_mmc.c | 22 +-----------------
drivers/mmc/host/dw_mmc.h | 8 +------
3 files changed, 5 insertions(+), 73 deletions(-)
diff --git a/drivers/mmc/host/dw_mmc-exynos.c b/drivers/mmc/host/dw_mmc-exynos.c
index 74eb081..12a5eaa 100644
--- a/drivers/mmc/host/dw_mmc-exynos.c
+++ b/drivers/mmc/host/dw_mmc-exynos.c
@@ -340,64 +340,23 @@ out:
return loc;
}
-static int dw_mci_exynos_execute_tuning(struct dw_mci_slot *slot, u32 opcode,
- struct dw_mci_tuning_data *tuning_data)
+static int dw_mci_exynos_execute_tuning(struct dw_mci_slot *slot)
{
struct dw_mci *host = slot->host;
struct mmc_host *mmc = slot->mmc;
- const u8 *blk_pattern = tuning_data->blk_pattern;
- u8 *blk_test;
- unsigned int blksz = tuning_data->blksz;
u8 start_smpl, smpl, candiates = 0;
s8 found = -1;
int ret = 0;
- blk_test = kmalloc(blksz, GFP_KERNEL);
- if (!blk_test)
- return -ENOMEM;
-
start_smpl = dw_mci_exynos_get_clksmpl(host);
do {
- struct mmc_request mrq = {NULL};
- struct mmc_command cmd = {0};
- struct mmc_command stop = {0};
- struct mmc_data data = {0};
- struct scatterlist sg;
-
- cmd.opcode = opcode;
- cmd.arg = 0;
- cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
-
- stop.opcode = MMC_STOP_TRANSMISSION;
- stop.arg = 0;
- stop.flags = MMC_RSP_R1B | MMC_CMD_AC;
-
- data.blksz = blksz;
- data.blocks = 1;
- data.flags = MMC_DATA_READ;
- data.sg = &sg;
- data.sg_len = 1;
-
- sg_init_one(&sg, blk_test, blksz);
- mrq.cmd = &cmd;
- mrq.stop = &stop;
- mrq.data = &data;
- host->mrq = &mrq;
-
mci_writel(host, TMOUT, ~0);
smpl = dw_mci_exynos_move_next_clksmpl(host);
- mmc_wait_for_req(mmc, &mrq);
+ if (!mmc_send_tuning(mmc))
+ candiates |= (1 << smpl);
- if (!cmd.error && !data.error) {
- if (!memcmp(blk_pattern, blk_test, blksz))
- candiates |= (1 << smpl);
- } else {
- dev_dbg(host->dev,
- "Tuning error: cmd.error:%d, data.error:%d\n",
- cmd.error, data.error);
- }
} while (start_smpl != smpl);
found = dw_mci_exynos_get_best_clksmpl(candiates);
@@ -406,7 +365,6 @@ static int dw_mci_exynos_execute_tuning(struct dw_mci_slot *slot, u32 opcode,
else
ret = -EIO;
- kfree(blk_test);
return ret;
}
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 6e4d864..88dc50f 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -1312,30 +1312,10 @@ static int dw_mci_execute_tuning(struct mmc_host *mmc, u32 opcode)
struct dw_mci_slot *slot = mmc_priv(mmc);
struct dw_mci *host = slot->host;
const struct dw_mci_drv_data *drv_data = host->drv_data;
- struct dw_mci_tuning_data tuning_data;
int err = -ENOSYS;
- if (opcode == MMC_SEND_TUNING_BLOCK_HS200) {
- if (mmc->ios.bus_width == MMC_BUS_WIDTH_8) {
- tuning_data.blk_pattern = tuning_blk_pattern_8bit;
- tuning_data.blksz = sizeof(tuning_blk_pattern_8bit);
- } else if (mmc->ios.bus_width == MMC_BUS_WIDTH_4) {
- tuning_data.blk_pattern = tuning_blk_pattern_4bit;
- tuning_data.blksz = sizeof(tuning_blk_pattern_4bit);
- } else {
- return -EINVAL;
- }
- } else if (opcode == MMC_SEND_TUNING_BLOCK) {
- tuning_data.blk_pattern = tuning_blk_pattern_4bit;
- tuning_data.blksz = sizeof(tuning_blk_pattern_4bit);
- } else {
- dev_err(host->dev,
- "Undefined command(%d) for tuning\n", opcode);
- return -EINVAL;
- }
-
if (drv_data && drv_data->execute_tuning)
- err = drv_data->execute_tuning(slot, opcode, &tuning_data);
+ err = drv_data->execute_tuning(slot);
return err;
}
diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
index d27d4c0..18c4afe 100644
--- a/drivers/mmc/host/dw_mmc.h
+++ b/drivers/mmc/host/dw_mmc.h
@@ -249,11 +249,6 @@ struct dw_mci_slot {
int sdio_id;
};
-struct dw_mci_tuning_data {
- const u8 *blk_pattern;
- unsigned int blksz;
-};
-
/**
* dw_mci driver data - dw-mshc implementation specific driver data.
* @caps: mmc subsystem specified capabilities of the controller(s).
@@ -275,7 +270,6 @@ struct dw_mci_drv_data {
void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
int (*parse_dt)(struct dw_mci *host);
- int (*execute_tuning)(struct dw_mci_slot *slot, u32 opcode,
- struct dw_mci_tuning_data *tuning_data);
+ int (*execute_tuning)(struct dw_mci_slot *slot);
};
#endif /* _DW_MMC_H_ */
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH V3 2/2] mmc: core: Make tuning block patterns static 2014-12-23 16:02 [PATCH V3 1/2] mmc: dw_mmc: Convert to mmc_send_tuning() Ulf Hansson @ 2014-12-23 16:02 ` Ulf Hansson 2014-12-24 1:45 ` Jaehoon Chung 2014-12-24 1:44 ` [PATCH V3 1/2] mmc: dw_mmc: Convert to mmc_send_tuning() Jaehoon Chung 2014-12-24 14:11 ` Alim Akhtar 2 siblings, 1 reply; 5+ messages in thread From: Ulf Hansson @ 2014-12-23 16:02 UTC (permalink / raw) To: linux-mmc, Ulf Hansson, Chris Ball Cc: Seungwon Jeon, Jaehoon Chung, Stephen Boyd Since previous patches removed the need for the tuning block patterns to be exported, let's move them close to the mmc_send_tuning() API. Those are now intended to be used only by the mmc core. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> --- Changes in v3: Added reviewed by tag. --- drivers/mmc/core/mmc.c | 32 -------------------------------- drivers/mmc/core/mmc_ops.c | 30 ++++++++++++++++++++++++++++++ include/linux/mmc/mmc.h | 5 ----- 3 files changed, 30 insertions(+), 37 deletions(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index d854bff..0b8ec87 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1155,38 +1155,6 @@ bus_speed: return err; } -const u8 tuning_blk_pattern_4bit[MMC_TUNING_BLK_PATTERN_4BIT_SIZE] = { - 0xff, 0x0f, 0xff, 0x00, 0xff, 0xcc, 0xc3, 0xcc, - 0xc3, 0x3c, 0xcc, 0xff, 0xfe, 0xff, 0xfe, 0xef, - 0xff, 0xdf, 0xff, 0xdd, 0xff, 0xfb, 0xff, 0xfb, - 0xbf, 0xff, 0x7f, 0xff, 0x77, 0xf7, 0xbd, 0xef, - 0xff, 0xf0, 0xff, 0xf0, 0x0f, 0xfc, 0xcc, 0x3c, - 0xcc, 0x33, 0xcc, 0xcf, 0xff, 0xef, 0xff, 0xee, - 0xff, 0xfd, 0xff, 0xfd, 0xdf, 0xff, 0xbf, 0xff, - 0xbb, 0xff, 0xf7, 0xff, 0xf7, 0x7f, 0x7b, 0xde, -}; -EXPORT_SYMBOL(tuning_blk_pattern_4bit); - -const u8 tuning_blk_pattern_8bit[MMC_TUNING_BLK_PATTERN_8BIT_SIZE] = { - 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, - 0xff, 0xff, 0xcc, 0xcc, 0xcc, 0x33, 0xcc, 0xcc, - 0xcc, 0x33, 0x33, 0xcc, 0xcc, 0xcc, 0xff, 0xff, - 0xff, 0xee, 0xff, 0xff, 0xff, 0xee, 0xee, 0xff, - 0xff, 0xff, 0xdd, 0xff, 0xff, 0xff, 0xdd, 0xdd, - 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff, 0xff, 0xbb, - 0xbb, 0xff, 0xff, 0xff, 0x77, 0xff, 0xff, 0xff, - 0x77, 0x77, 0xff, 0x77, 0xbb, 0xdd, 0xee, 0xff, - 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, - 0x00, 0xff, 0xff, 0xcc, 0xcc, 0xcc, 0x33, 0xcc, - 0xcc, 0xcc, 0x33, 0x33, 0xcc, 0xcc, 0xcc, 0xff, - 0xff, 0xff, 0xee, 0xff, 0xff, 0xff, 0xee, 0xee, - 0xff, 0xff, 0xff, 0xdd, 0xff, 0xff, 0xff, 0xdd, - 0xdd, 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff, 0xff, - 0xbb, 0xbb, 0xff, 0xff, 0xff, 0x77, 0xff, 0xff, - 0xff, 0x77, 0x77, 0xff, 0x77, 0xbb, 0xdd, 0xee, -}; -EXPORT_SYMBOL(tuning_blk_pattern_8bit); - /* * Execute tuning sequence to seek the proper bus operating * conditions for HS200 and HS400, which sends CMD21 to the device. diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 3b044c5..0ea042d 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -23,6 +23,36 @@ #define MMC_OPS_TIMEOUT_MS (10 * 60 * 1000) /* 10 minute timeout */ +static const u8 tuning_blk_pattern_4bit[] = { + 0xff, 0x0f, 0xff, 0x00, 0xff, 0xcc, 0xc3, 0xcc, + 0xc3, 0x3c, 0xcc, 0xff, 0xfe, 0xff, 0xfe, 0xef, + 0xff, 0xdf, 0xff, 0xdd, 0xff, 0xfb, 0xff, 0xfb, + 0xbf, 0xff, 0x7f, 0xff, 0x77, 0xf7, 0xbd, 0xef, + 0xff, 0xf0, 0xff, 0xf0, 0x0f, 0xfc, 0xcc, 0x3c, + 0xcc, 0x33, 0xcc, 0xcf, 0xff, 0xef, 0xff, 0xee, + 0xff, 0xfd, 0xff, 0xfd, 0xdf, 0xff, 0xbf, 0xff, + 0xbb, 0xff, 0xf7, 0xff, 0xf7, 0x7f, 0x7b, 0xde, +}; + +static const u8 tuning_blk_pattern_8bit[] = { + 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, + 0xff, 0xff, 0xcc, 0xcc, 0xcc, 0x33, 0xcc, 0xcc, + 0xcc, 0x33, 0x33, 0xcc, 0xcc, 0xcc, 0xff, 0xff, + 0xff, 0xee, 0xff, 0xff, 0xff, 0xee, 0xee, 0xff, + 0xff, 0xff, 0xdd, 0xff, 0xff, 0xff, 0xdd, 0xdd, + 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff, 0xff, 0xbb, + 0xbb, 0xff, 0xff, 0xff, 0x77, 0xff, 0xff, 0xff, + 0x77, 0x77, 0xff, 0x77, 0xbb, 0xdd, 0xee, 0xff, + 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, + 0x00, 0xff, 0xff, 0xcc, 0xcc, 0xcc, 0x33, 0xcc, + 0xcc, 0xcc, 0x33, 0x33, 0xcc, 0xcc, 0xcc, 0xff, + 0xff, 0xff, 0xee, 0xff, 0xff, 0xff, 0xee, 0xee, + 0xff, 0xff, 0xff, 0xdd, 0xff, 0xff, 0xff, 0xdd, + 0xdd, 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff, 0xff, + 0xbb, 0xbb, 0xff, 0xff, 0xff, 0x77, 0xff, 0xff, + 0xff, 0x77, 0x77, 0xff, 0x77, 0xbb, 0xdd, 0xee, +}; + static inline int __mmc_send_status(struct mmc_card *card, u32 *status, bool ignore_crc) { diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h index 49ad7a9..fb97b5c 100644 --- a/include/linux/mmc/mmc.h +++ b/include/linux/mmc/mmc.h @@ -53,11 +53,6 @@ #define MMC_SEND_TUNING_BLOCK 19 /* adtc R1 */ #define MMC_SEND_TUNING_BLOCK_HS200 21 /* adtc R1 */ -#define MMC_TUNING_BLK_PATTERN_4BIT_SIZE 64 -#define MMC_TUNING_BLK_PATTERN_8BIT_SIZE 128 -extern const u8 tuning_blk_pattern_4bit[MMC_TUNING_BLK_PATTERN_4BIT_SIZE]; -extern const u8 tuning_blk_pattern_8bit[MMC_TUNING_BLK_PATTERN_8BIT_SIZE]; - /* class 3 */ #define MMC_WRITE_DAT_UNTIL_STOP 20 /* adtc [31:0] data addr R1 */ -- 1.9.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH V3 2/2] mmc: core: Make tuning block patterns static 2014-12-23 16:02 ` [PATCH V3 2/2] mmc: core: Make tuning block patterns static Ulf Hansson @ 2014-12-24 1:45 ` Jaehoon Chung 0 siblings, 0 replies; 5+ messages in thread From: Jaehoon Chung @ 2014-12-24 1:45 UTC (permalink / raw) To: Ulf Hansson, linux-mmc, Chris Ball; +Cc: Seungwon Jeon, Stephen Boyd Hi, Ulf. Acked-by: Jaehoon Chung <jh80.chung@samsung.com> Best Regards, Jaehoon Chung On 12/24/2014 01:02 AM, Ulf Hansson wrote: > Since previous patches removed the need for the tuning block patterns > to be exported, let's move them close to the mmc_send_tuning() API. > > Those are now intended to be used only by the mmc core. > > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> > Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> > --- > > Changes in v3: > Added reviewed by tag. > > --- > drivers/mmc/core/mmc.c | 32 -------------------------------- > drivers/mmc/core/mmc_ops.c | 30 ++++++++++++++++++++++++++++++ > include/linux/mmc/mmc.h | 5 ----- > 3 files changed, 30 insertions(+), 37 deletions(-) > > diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c > index d854bff..0b8ec87 100644 > --- a/drivers/mmc/core/mmc.c > +++ b/drivers/mmc/core/mmc.c > @@ -1155,38 +1155,6 @@ bus_speed: > return err; > } > > -const u8 tuning_blk_pattern_4bit[MMC_TUNING_BLK_PATTERN_4BIT_SIZE] = { > - 0xff, 0x0f, 0xff, 0x00, 0xff, 0xcc, 0xc3, 0xcc, > - 0xc3, 0x3c, 0xcc, 0xff, 0xfe, 0xff, 0xfe, 0xef, > - 0xff, 0xdf, 0xff, 0xdd, 0xff, 0xfb, 0xff, 0xfb, > - 0xbf, 0xff, 0x7f, 0xff, 0x77, 0xf7, 0xbd, 0xef, > - 0xff, 0xf0, 0xff, 0xf0, 0x0f, 0xfc, 0xcc, 0x3c, > - 0xcc, 0x33, 0xcc, 0xcf, 0xff, 0xef, 0xff, 0xee, > - 0xff, 0xfd, 0xff, 0xfd, 0xdf, 0xff, 0xbf, 0xff, > - 0xbb, 0xff, 0xf7, 0xff, 0xf7, 0x7f, 0x7b, 0xde, > -}; > -EXPORT_SYMBOL(tuning_blk_pattern_4bit); > - > -const u8 tuning_blk_pattern_8bit[MMC_TUNING_BLK_PATTERN_8BIT_SIZE] = { > - 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, > - 0xff, 0xff, 0xcc, 0xcc, 0xcc, 0x33, 0xcc, 0xcc, > - 0xcc, 0x33, 0x33, 0xcc, 0xcc, 0xcc, 0xff, 0xff, > - 0xff, 0xee, 0xff, 0xff, 0xff, 0xee, 0xee, 0xff, > - 0xff, 0xff, 0xdd, 0xff, 0xff, 0xff, 0xdd, 0xdd, > - 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff, 0xff, 0xbb, > - 0xbb, 0xff, 0xff, 0xff, 0x77, 0xff, 0xff, 0xff, > - 0x77, 0x77, 0xff, 0x77, 0xbb, 0xdd, 0xee, 0xff, > - 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, > - 0x00, 0xff, 0xff, 0xcc, 0xcc, 0xcc, 0x33, 0xcc, > - 0xcc, 0xcc, 0x33, 0x33, 0xcc, 0xcc, 0xcc, 0xff, > - 0xff, 0xff, 0xee, 0xff, 0xff, 0xff, 0xee, 0xee, > - 0xff, 0xff, 0xff, 0xdd, 0xff, 0xff, 0xff, 0xdd, > - 0xdd, 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff, 0xff, > - 0xbb, 0xbb, 0xff, 0xff, 0xff, 0x77, 0xff, 0xff, > - 0xff, 0x77, 0x77, 0xff, 0x77, 0xbb, 0xdd, 0xee, > -}; > -EXPORT_SYMBOL(tuning_blk_pattern_8bit); > - > /* > * Execute tuning sequence to seek the proper bus operating > * conditions for HS200 and HS400, which sends CMD21 to the device. > diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c > index 3b044c5..0ea042d 100644 > --- a/drivers/mmc/core/mmc_ops.c > +++ b/drivers/mmc/core/mmc_ops.c > @@ -23,6 +23,36 @@ > > #define MMC_OPS_TIMEOUT_MS (10 * 60 * 1000) /* 10 minute timeout */ > > +static const u8 tuning_blk_pattern_4bit[] = { > + 0xff, 0x0f, 0xff, 0x00, 0xff, 0xcc, 0xc3, 0xcc, > + 0xc3, 0x3c, 0xcc, 0xff, 0xfe, 0xff, 0xfe, 0xef, > + 0xff, 0xdf, 0xff, 0xdd, 0xff, 0xfb, 0xff, 0xfb, > + 0xbf, 0xff, 0x7f, 0xff, 0x77, 0xf7, 0xbd, 0xef, > + 0xff, 0xf0, 0xff, 0xf0, 0x0f, 0xfc, 0xcc, 0x3c, > + 0xcc, 0x33, 0xcc, 0xcf, 0xff, 0xef, 0xff, 0xee, > + 0xff, 0xfd, 0xff, 0xfd, 0xdf, 0xff, 0xbf, 0xff, > + 0xbb, 0xff, 0xf7, 0xff, 0xf7, 0x7f, 0x7b, 0xde, > +}; > + > +static const u8 tuning_blk_pattern_8bit[] = { > + 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, > + 0xff, 0xff, 0xcc, 0xcc, 0xcc, 0x33, 0xcc, 0xcc, > + 0xcc, 0x33, 0x33, 0xcc, 0xcc, 0xcc, 0xff, 0xff, > + 0xff, 0xee, 0xff, 0xff, 0xff, 0xee, 0xee, 0xff, > + 0xff, 0xff, 0xdd, 0xff, 0xff, 0xff, 0xdd, 0xdd, > + 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff, 0xff, 0xbb, > + 0xbb, 0xff, 0xff, 0xff, 0x77, 0xff, 0xff, 0xff, > + 0x77, 0x77, 0xff, 0x77, 0xbb, 0xdd, 0xee, 0xff, > + 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, > + 0x00, 0xff, 0xff, 0xcc, 0xcc, 0xcc, 0x33, 0xcc, > + 0xcc, 0xcc, 0x33, 0x33, 0xcc, 0xcc, 0xcc, 0xff, > + 0xff, 0xff, 0xee, 0xff, 0xff, 0xff, 0xee, 0xee, > + 0xff, 0xff, 0xff, 0xdd, 0xff, 0xff, 0xff, 0xdd, > + 0xdd, 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff, 0xff, > + 0xbb, 0xbb, 0xff, 0xff, 0xff, 0x77, 0xff, 0xff, > + 0xff, 0x77, 0x77, 0xff, 0x77, 0xbb, 0xdd, 0xee, > +}; > + > static inline int __mmc_send_status(struct mmc_card *card, u32 *status, > bool ignore_crc) > { > diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h > index 49ad7a9..fb97b5c 100644 > --- a/include/linux/mmc/mmc.h > +++ b/include/linux/mmc/mmc.h > @@ -53,11 +53,6 @@ > #define MMC_SEND_TUNING_BLOCK 19 /* adtc R1 */ > #define MMC_SEND_TUNING_BLOCK_HS200 21 /* adtc R1 */ > > -#define MMC_TUNING_BLK_PATTERN_4BIT_SIZE 64 > -#define MMC_TUNING_BLK_PATTERN_8BIT_SIZE 128 > -extern const u8 tuning_blk_pattern_4bit[MMC_TUNING_BLK_PATTERN_4BIT_SIZE]; > -extern const u8 tuning_blk_pattern_8bit[MMC_TUNING_BLK_PATTERN_8BIT_SIZE]; > - > /* class 3 */ > #define MMC_WRITE_DAT_UNTIL_STOP 20 /* adtc [31:0] data addr R1 */ > > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH V3 1/2] mmc: dw_mmc: Convert to mmc_send_tuning() 2014-12-23 16:02 [PATCH V3 1/2] mmc: dw_mmc: Convert to mmc_send_tuning() Ulf Hansson 2014-12-23 16:02 ` [PATCH V3 2/2] mmc: core: Make tuning block patterns static Ulf Hansson @ 2014-12-24 1:44 ` Jaehoon Chung 2014-12-24 14:11 ` Alim Akhtar 2 siblings, 0 replies; 5+ messages in thread From: Jaehoon Chung @ 2014-12-24 1:44 UTC (permalink / raw) To: Ulf Hansson, linux-mmc, Chris Ball; +Cc: Seungwon Jeon, Stephen Boyd Hi, Ulf. Acked-by: Jaehoon Chung <jh80.chung@samsung.com> And if you can apply "[PATCH] mmc: dw_mmc: Generate stop commands for failed tuning requests", plz do it with my-ack. Best Regards, Jaehoon Chung On 12/24/2014 01:02 AM, Ulf Hansson wrote: > Instead of having a local hack taking care of sending the tuning > command and as well to verify the response pattern, let's convert to > the common mmc_send_tuning() API. > > This change affects the Exynos variant, since it's the only one which > support the dw_mmc's ->execute_tuning() callback. > > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> > --- > > Changes in v3: > Fix return value from dw_mci_exynos_execute_tuning() according to > comment from Jaehoon Chung. > > --- > drivers/mmc/host/dw_mmc-exynos.c | 48 +++------------------------------------- > drivers/mmc/host/dw_mmc.c | 22 +----------------- > drivers/mmc/host/dw_mmc.h | 8 +------ > 3 files changed, 5 insertions(+), 73 deletions(-) > > diff --git a/drivers/mmc/host/dw_mmc-exynos.c b/drivers/mmc/host/dw_mmc-exynos.c > index 74eb081..12a5eaa 100644 > --- a/drivers/mmc/host/dw_mmc-exynos.c > +++ b/drivers/mmc/host/dw_mmc-exynos.c > @@ -340,64 +340,23 @@ out: > return loc; > } > > -static int dw_mci_exynos_execute_tuning(struct dw_mci_slot *slot, u32 opcode, > - struct dw_mci_tuning_data *tuning_data) > +static int dw_mci_exynos_execute_tuning(struct dw_mci_slot *slot) > { > struct dw_mci *host = slot->host; > struct mmc_host *mmc = slot->mmc; > - const u8 *blk_pattern = tuning_data->blk_pattern; > - u8 *blk_test; > - unsigned int blksz = tuning_data->blksz; > u8 start_smpl, smpl, candiates = 0; > s8 found = -1; > int ret = 0; > > - blk_test = kmalloc(blksz, GFP_KERNEL); > - if (!blk_test) > - return -ENOMEM; > - > start_smpl = dw_mci_exynos_get_clksmpl(host); > > do { > - struct mmc_request mrq = {NULL}; > - struct mmc_command cmd = {0}; > - struct mmc_command stop = {0}; > - struct mmc_data data = {0}; > - struct scatterlist sg; > - > - cmd.opcode = opcode; > - cmd.arg = 0; > - cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC; > - > - stop.opcode = MMC_STOP_TRANSMISSION; > - stop.arg = 0; > - stop.flags = MMC_RSP_R1B | MMC_CMD_AC; > - > - data.blksz = blksz; > - data.blocks = 1; > - data.flags = MMC_DATA_READ; > - data.sg = &sg; > - data.sg_len = 1; > - > - sg_init_one(&sg, blk_test, blksz); > - mrq.cmd = &cmd; > - mrq.stop = &stop; > - mrq.data = &data; > - host->mrq = &mrq; > - > mci_writel(host, TMOUT, ~0); > smpl = dw_mci_exynos_move_next_clksmpl(host); > > - mmc_wait_for_req(mmc, &mrq); > + if (!mmc_send_tuning(mmc)) > + candiates |= (1 << smpl); > > - if (!cmd.error && !data.error) { > - if (!memcmp(blk_pattern, blk_test, blksz)) > - candiates |= (1 << smpl); > - } else { > - dev_dbg(host->dev, > - "Tuning error: cmd.error:%d, data.error:%d\n", > - cmd.error, data.error); > - } > } while (start_smpl != smpl); > > found = dw_mci_exynos_get_best_clksmpl(candiates); > @@ -406,7 +365,6 @@ static int dw_mci_exynos_execute_tuning(struct dw_mci_slot *slot, u32 opcode, > else > ret = -EIO; > > - kfree(blk_test); > return ret; > } > > diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c > index 6e4d864..88dc50f 100644 > --- a/drivers/mmc/host/dw_mmc.c > +++ b/drivers/mmc/host/dw_mmc.c > @@ -1312,30 +1312,10 @@ static int dw_mci_execute_tuning(struct mmc_host *mmc, u32 opcode) > struct dw_mci_slot *slot = mmc_priv(mmc); > struct dw_mci *host = slot->host; > const struct dw_mci_drv_data *drv_data = host->drv_data; > - struct dw_mci_tuning_data tuning_data; > int err = -ENOSYS; > > - if (opcode == MMC_SEND_TUNING_BLOCK_HS200) { > - if (mmc->ios.bus_width == MMC_BUS_WIDTH_8) { > - tuning_data.blk_pattern = tuning_blk_pattern_8bit; > - tuning_data.blksz = sizeof(tuning_blk_pattern_8bit); > - } else if (mmc->ios.bus_width == MMC_BUS_WIDTH_4) { > - tuning_data.blk_pattern = tuning_blk_pattern_4bit; > - tuning_data.blksz = sizeof(tuning_blk_pattern_4bit); > - } else { > - return -EINVAL; > - } > - } else if (opcode == MMC_SEND_TUNING_BLOCK) { > - tuning_data.blk_pattern = tuning_blk_pattern_4bit; > - tuning_data.blksz = sizeof(tuning_blk_pattern_4bit); > - } else { > - dev_err(host->dev, > - "Undefined command(%d) for tuning\n", opcode); > - return -EINVAL; > - } > - > if (drv_data && drv_data->execute_tuning) > - err = drv_data->execute_tuning(slot, opcode, &tuning_data); > + err = drv_data->execute_tuning(slot); > return err; > } > > diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h > index d27d4c0..18c4afe 100644 > --- a/drivers/mmc/host/dw_mmc.h > +++ b/drivers/mmc/host/dw_mmc.h > @@ -249,11 +249,6 @@ struct dw_mci_slot { > int sdio_id; > }; > > -struct dw_mci_tuning_data { > - const u8 *blk_pattern; > - unsigned int blksz; > -}; > - > /** > * dw_mci driver data - dw-mshc implementation specific driver data. > * @caps: mmc subsystem specified capabilities of the controller(s). > @@ -275,7 +270,6 @@ struct dw_mci_drv_data { > void (*prepare_command)(struct dw_mci *host, u32 *cmdr); > void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios); > int (*parse_dt)(struct dw_mci *host); > - int (*execute_tuning)(struct dw_mci_slot *slot, u32 opcode, > - struct dw_mci_tuning_data *tuning_data); > + int (*execute_tuning)(struct dw_mci_slot *slot); > }; > #endif /* _DW_MMC_H_ */ > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH V3 1/2] mmc: dw_mmc: Convert to mmc_send_tuning() 2014-12-23 16:02 [PATCH V3 1/2] mmc: dw_mmc: Convert to mmc_send_tuning() Ulf Hansson 2014-12-23 16:02 ` [PATCH V3 2/2] mmc: core: Make tuning block patterns static Ulf Hansson 2014-12-24 1:44 ` [PATCH V3 1/2] mmc: dw_mmc: Convert to mmc_send_tuning() Jaehoon Chung @ 2014-12-24 14:11 ` Alim Akhtar 2 siblings, 0 replies; 5+ messages in thread From: Alim Akhtar @ 2014-12-24 14:11 UTC (permalink / raw) To: Ulf Hansson Cc: linux-mmc@vger.kernel.org, Chris Ball, Seungwon Jeon, Jaehoon Chung, Stephen Boyd Hi Ulf, On Tue, Dec 23, 2014 at 9:32 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote: > Instead of having a local hack taking care of sending the tuning > command and as well to verify the response pattern, let's convert to > the common mmc_send_tuning() API. > > This change affects the Exynos variant, since it's the only one which > support the dw_mmc's ->execute_tuning() callback. > > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> > --- > yes, this works fine now, with the other patch which add STOP command, and I don't need to modify DT timing values. So, Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com> Tested on exynos5800-peach-pi board, so Tested-by: Alim Akhtar <alim.akhtar@samsung.com> > Changes in v3: > Fix return value from dw_mci_exynos_execute_tuning() according to > comment from Jaehoon Chung. > > --- > drivers/mmc/host/dw_mmc-exynos.c | 48 +++------------------------------------- > drivers/mmc/host/dw_mmc.c | 22 +----------------- > drivers/mmc/host/dw_mmc.h | 8 +------ > 3 files changed, 5 insertions(+), 73 deletions(-) > > diff --git a/drivers/mmc/host/dw_mmc-exynos.c b/drivers/mmc/host/dw_mmc-exynos.c > index 74eb081..12a5eaa 100644 > --- a/drivers/mmc/host/dw_mmc-exynos.c > +++ b/drivers/mmc/host/dw_mmc-exynos.c > @@ -340,64 +340,23 @@ out: > return loc; > } > > -static int dw_mci_exynos_execute_tuning(struct dw_mci_slot *slot, u32 opcode, > - struct dw_mci_tuning_data *tuning_data) > +static int dw_mci_exynos_execute_tuning(struct dw_mci_slot *slot) > { > struct dw_mci *host = slot->host; > struct mmc_host *mmc = slot->mmc; > - const u8 *blk_pattern = tuning_data->blk_pattern; > - u8 *blk_test; > - unsigned int blksz = tuning_data->blksz; > u8 start_smpl, smpl, candiates = 0; > s8 found = -1; > int ret = 0; > > - blk_test = kmalloc(blksz, GFP_KERNEL); > - if (!blk_test) > - return -ENOMEM; > - > start_smpl = dw_mci_exynos_get_clksmpl(host); > > do { > - struct mmc_request mrq = {NULL}; > - struct mmc_command cmd = {0}; > - struct mmc_command stop = {0}; > - struct mmc_data data = {0}; > - struct scatterlist sg; > - > - cmd.opcode = opcode; > - cmd.arg = 0; > - cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC; > - > - stop.opcode = MMC_STOP_TRANSMISSION; > - stop.arg = 0; > - stop.flags = MMC_RSP_R1B | MMC_CMD_AC; > - > - data.blksz = blksz; > - data.blocks = 1; > - data.flags = MMC_DATA_READ; > - data.sg = &sg; > - data.sg_len = 1; > - > - sg_init_one(&sg, blk_test, blksz); > - mrq.cmd = &cmd; > - mrq.stop = &stop; > - mrq.data = &data; > - host->mrq = &mrq; > - > mci_writel(host, TMOUT, ~0); > smpl = dw_mci_exynos_move_next_clksmpl(host); > > - mmc_wait_for_req(mmc, &mrq); > + if (!mmc_send_tuning(mmc)) > + candiates |= (1 << smpl); > > - if (!cmd.error && !data.error) { > - if (!memcmp(blk_pattern, blk_test, blksz)) > - candiates |= (1 << smpl); > - } else { > - dev_dbg(host->dev, > - "Tuning error: cmd.error:%d, data.error:%d\n", > - cmd.error, data.error); > - } > } while (start_smpl != smpl); > > found = dw_mci_exynos_get_best_clksmpl(candiates); > @@ -406,7 +365,6 @@ static int dw_mci_exynos_execute_tuning(struct dw_mci_slot *slot, u32 opcode, > else > ret = -EIO; > > - kfree(blk_test); > return ret; > } > > diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c > index 6e4d864..88dc50f 100644 > --- a/drivers/mmc/host/dw_mmc.c > +++ b/drivers/mmc/host/dw_mmc.c > @@ -1312,30 +1312,10 @@ static int dw_mci_execute_tuning(struct mmc_host *mmc, u32 opcode) > struct dw_mci_slot *slot = mmc_priv(mmc); > struct dw_mci *host = slot->host; > const struct dw_mci_drv_data *drv_data = host->drv_data; > - struct dw_mci_tuning_data tuning_data; > int err = -ENOSYS; > > - if (opcode == MMC_SEND_TUNING_BLOCK_HS200) { > - if (mmc->ios.bus_width == MMC_BUS_WIDTH_8) { > - tuning_data.blk_pattern = tuning_blk_pattern_8bit; > - tuning_data.blksz = sizeof(tuning_blk_pattern_8bit); > - } else if (mmc->ios.bus_width == MMC_BUS_WIDTH_4) { > - tuning_data.blk_pattern = tuning_blk_pattern_4bit; > - tuning_data.blksz = sizeof(tuning_blk_pattern_4bit); > - } else { > - return -EINVAL; > - } > - } else if (opcode == MMC_SEND_TUNING_BLOCK) { > - tuning_data.blk_pattern = tuning_blk_pattern_4bit; > - tuning_data.blksz = sizeof(tuning_blk_pattern_4bit); > - } else { > - dev_err(host->dev, > - "Undefined command(%d) for tuning\n", opcode); > - return -EINVAL; > - } > - > if (drv_data && drv_data->execute_tuning) > - err = drv_data->execute_tuning(slot, opcode, &tuning_data); > + err = drv_data->execute_tuning(slot); > return err; > } > > diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h > index d27d4c0..18c4afe 100644 > --- a/drivers/mmc/host/dw_mmc.h > +++ b/drivers/mmc/host/dw_mmc.h > @@ -249,11 +249,6 @@ struct dw_mci_slot { > int sdio_id; > }; > > -struct dw_mci_tuning_data { > - const u8 *blk_pattern; > - unsigned int blksz; > -}; > - > /** > * dw_mci driver data - dw-mshc implementation specific driver data. > * @caps: mmc subsystem specified capabilities of the controller(s). > @@ -275,7 +270,6 @@ struct dw_mci_drv_data { > void (*prepare_command)(struct dw_mci *host, u32 *cmdr); > void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios); > int (*parse_dt)(struct dw_mci *host); > - int (*execute_tuning)(struct dw_mci_slot *slot, u32 opcode, > - struct dw_mci_tuning_data *tuning_data); > + int (*execute_tuning)(struct dw_mci_slot *slot); > }; > #endif /* _DW_MMC_H_ */ > -- > 1.9.1 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-mmc" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Regards, Alim ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-12-24 14:12 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-12-23 16:02 [PATCH V3 1/2] mmc: dw_mmc: Convert to mmc_send_tuning() Ulf Hansson 2014-12-23 16:02 ` [PATCH V3 2/2] mmc: core: Make tuning block patterns static Ulf Hansson 2014-12-24 1:45 ` Jaehoon Chung 2014-12-24 1:44 ` [PATCH V3 1/2] mmc: dw_mmc: Convert to mmc_send_tuning() Jaehoon Chung 2014-12-24 14:11 ` Alim Akhtar
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox