Re: [PATCH V2 6/6] mmc: mmci: replace blksz_datactrlXX by get_datactrl_cfg callback

2019-03-08 Thread Ludovic BARRE

hi Russell, Ulf

On 3/7/19 5:46 PM, Russell King - ARM Linux admin wrote:

On Thu, Mar 07, 2019 at 05:39:02PM +0100, Ludovic Barre wrote:

-   if (data->flags & MMC_DATA_READ)
-   datactrl |= MCI_DPSM_DIRECTION;


Given that this is currently an invariant between all, it doesn't make
sense to have a separate public function and combine it into the
get_datactrl_cfg() implementations.  You may as well leave it in place
here, after you call get_datactrl_cfg().


+   datactrl = host->ops->get_datactrl_cfg(host);


Otherwise, I don't see a problem with this, although it would be nice to
avoid the overhead of so many public functions, which could be done by
adding them as inline functions in mmci.h



To combine your comments (above and https://lkml.org/lkml/2019/3/6/318).
I could regroup mmci_dctrl_dir & mmci_dctrl_ddr & mmci_dctrl_sdio in a
common function mmci_dctrl_common and call by:
-Each get_datactrl_cfg variant
-Or in mmci_start_data

What do you prefer ?

Regards,
Ludo


Re: [PATCH V2 6/6] mmc: mmci: replace blksz_datactrlXX by get_datactrl_cfg callback

2019-03-07 Thread Russell King - ARM Linux admin
On Thu, Mar 07, 2019 at 05:39:02PM +0100, Ludovic Barre wrote:
> - if (data->flags & MMC_DATA_READ)
> - datactrl |= MCI_DPSM_DIRECTION;

Given that this is currently an invariant between all, it doesn't make
sense to have a separate public function and combine it into the
get_datactrl_cfg() implementations.  You may as well leave it in place
here, after you call get_datactrl_cfg().

> + datactrl = host->ops->get_datactrl_cfg(host);

Otherwise, I don't see a problem with this, although it would be nice to
avoid the overhead of so many public functions, which could be done by
adding them as inline functions in mmci.h

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up


[PATCH V2 6/6] mmc: mmci: replace blksz_datactrlXX by get_datactrl_cfg callback

2019-03-07 Thread Ludovic Barre
From: Ludovic Barre 

This patch allows to get datactrl configuration specific
at variant. This introduce more flexibility on datactlr
value.

Signed-off-by: Ludovic Barre 
---
 drivers/mmc/host/mmci.c | 31 +--
 drivers/mmc/host/mmci.h |  7 ---
 2 files changed, 1 insertion(+), 37 deletions(-)

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 52f9dbf..dcee78f 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -57,7 +57,6 @@ static struct variant_data variant_arm = {
.cmdreg_srsp= MCI_CPSM_RESPONSE,
.datalength_bits= 16,
.datactrl_blocksz   = 11,
-   .datactrl_dpsm_enable   = MCI_DPSM_ENABLE,
.pwrreg_powerup = MCI_PWR_UP,
.f_max  = 1,
.reversed_irq_handling  = true,
@@ -77,7 +76,6 @@ static struct variant_data variant_arm_extended_fifo = {
.cmdreg_srsp= MCI_CPSM_RESPONSE,
.datalength_bits= 16,
.datactrl_blocksz   = 11,
-   .datactrl_dpsm_enable   = MCI_DPSM_ENABLE,
.pwrreg_powerup = MCI_PWR_UP,
.f_max  = 1,
.mmcimask1  = true,
@@ -97,7 +95,6 @@ static struct variant_data variant_arm_extended_fifo_hwfc = {
.cmdreg_srsp= MCI_CPSM_RESPONSE,
.datalength_bits= 16,
.datactrl_blocksz   = 11,
-   .datactrl_dpsm_enable   = MCI_DPSM_ENABLE,
.pwrreg_powerup = MCI_PWR_UP,
.f_max  = 1,
.mmcimask1  = true,
@@ -118,7 +115,6 @@ static struct variant_data variant_u300 = {
.cmdreg_srsp= MCI_CPSM_RESPONSE,
.datalength_bits= 16,
.datactrl_blocksz   = 11,
-   .datactrl_dpsm_enable   = MCI_DPSM_ENABLE,
.datactrl_mask_sdio = MCI_DPSM_ST_SDIOEN,
.st_sdio= true,
.pwrreg_powerup = MCI_PWR_ON,
@@ -144,7 +140,6 @@ static struct variant_data variant_nomadik = {
.cmdreg_srsp= MCI_CPSM_RESPONSE,
.datalength_bits= 24,
.datactrl_blocksz   = 11,
-   .datactrl_dpsm_enable   = MCI_DPSM_ENABLE,
.datactrl_mask_sdio = MCI_DPSM_ST_SDIOEN,
.st_sdio= true,
.st_clkdiv  = true,
@@ -173,7 +168,6 @@ static struct variant_data variant_ux500 = {
.cmdreg_srsp= MCI_CPSM_RESPONSE,
.datalength_bits= 24,
.datactrl_blocksz   = 11,
-   .datactrl_dpsm_enable   = MCI_DPSM_ENABLE,
.datactrl_mask_sdio = MCI_DPSM_ST_SDIOEN,
.st_sdio= true,
.st_clkdiv  = true,
@@ -207,11 +201,9 @@ static struct variant_data variant_ux500v2 = {
.datactrl_mask_ddrmode  = MCI_DPSM_ST_DDRMODE,
.datalength_bits= 24,
.datactrl_blocksz   = 11,
-   .datactrl_dpsm_enable   = MCI_DPSM_ENABLE,
.datactrl_mask_sdio = MCI_DPSM_ST_SDIOEN,
.st_sdio= true,
.st_clkdiv  = true,
-   .blksz_datactrl16   = true,
.pwrreg_powerup = MCI_PWR_ON,
.f_max  = 1,
.signal_direction   = true,
@@ -242,7 +234,6 @@ static struct variant_data variant_stm32 = {
.irq_pio_mask   = MCI_IRQ_PIO_MASK,
.datalength_bits= 24,
.datactrl_blocksz   = 11,
-   .datactrl_dpsm_enable   = MCI_DPSM_ENABLE,
.datactrl_mask_sdio = MCI_DPSM_ST_SDIOEN,
.st_sdio= true,
.st_clkdiv  = true,
@@ -286,10 +277,8 @@ static struct variant_data variant_qcom = {
.cmdreg_srsp_crc= MCI_CPSM_RESPONSE,
.cmdreg_srsp= MCI_CPSM_RESPONSE,
.data_cmd_enable= MCI_CPSM_QCOM_DATCMD,
-   .blksz_datactrl4= true,
.datalength_bits= 24,
.datactrl_blocksz   = 11,
-   .datactrl_dpsm_enable   = MCI_DPSM_ENABLE,
.pwrreg_powerup = MCI_PWR_UP,
.f_max  = 20800,
.explicit_mclk_control  = true,
@@ -1042,7 +1031,6 @@ static void mmci_start_data(struct mmci_host *host, 
struct mmc_data *data)
unsigned int datactrl, timeout, irqmask;
unsigned long long clks;
void __iomem *base;
-   int blksz_bits;
 
dev_dbg(mmc_dev(host->mmc), "blksz %04x blks %04x flags %08x\n",
data->blksz, data->blocks, data->flags);
@@ -1060,24 +1048,11 @@ static void mmci_start_data(struct mmci_host *host, 
struct mmc_data *data)
writel(timeout, base + MMCIDATATIMER);
writel(host->size, base + MMCIDATALENGTH);
 
-   blksz_bits = ffs(data->blksz) - 1;
-   BUG_ON(1 << blksz_bits != data->blksz);
-
-   if (variant->blksz_datactrl16)
-   datactrl = variant->datactrl_dpsm_enable |