2020-01-28 09:09:10

by Ludovic Barre

[permalink] [raw]
Subject: [PATCH V2 0/9] mmc: mmci: sdmmc: add sdr104 support

To support the sdr104 mode, sdmmc variant needs:
-Hardware delay block support for sdmmc variant
with tuning procedure
-Voltage switch callbacks
-sdmmc revision 2.0

V2:
-regroup host->mmc_ops & mmc->ops assignment
-add timeout define
-rename prep_volt_switch to pre_sig_volt_switch
-rename volt_switch to post_sig_volt_switch
-add 'why' comment for "mmc: mmci: add volt_switch callbacks"

Ludovic Barre (9):
mmc: mmci: sdmmc: replace sg_dma_xxx macros
mmc: mmci: sdmmc: rename sdmmc_priv struct to sdmmc_idma
mmc: mmci: add a reference at mmc_host_ops in mmci struct
mmc: mmci: add private pointer for variant
dt-bindings: mmc: mmci: add delay block base register for sdmmc
mmc: mmci: sdmmc: add execute tuning with delay block
mmc: mmci: add volt_switch callbacks
mmc: mmci: sdmmc: add voltage switch functions
mmc: mmci: add sdmmc variant revision 2.0

.../devicetree/bindings/mmc/mmci.txt | 2 +
drivers/mmc/host/mmci.c | 42 +++-
drivers/mmc/host/mmci.h | 8 +
drivers/mmc/host/mmci_stm32_sdmmc.c | 204 +++++++++++++++++-
4 files changed, 248 insertions(+), 8 deletions(-)

--
2.17.1


2020-01-28 09:09:34

by Ludovic Barre

[permalink] [raw]
Subject: [PATCH V2 7/9] mmc: mmci: add volt_switch callbacks

A variant may need to define some actions before and after
a voltage switch.

This patch adds 2 voltage switch callbacks in mmci_host_ops:
-pre_sig_volt_switch allows to prepare voltage switch before to
sent the SD_SWITCH_VOLTAGE command (cmd11).
-post_sig_volt_switch callback allows to define specific action after
regulator set voltage.

Signed-off-by: Ludovic Barre <[email protected]>
---
drivers/mmc/host/mmci.c | 8 ++++++++
drivers/mmc/host/mmci.h | 2 ++
2 files changed, 10 insertions(+)

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index d0a041c9e6cd..24e630183ed4 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -22,6 +22,7 @@
#include <linux/mmc/pm.h>
#include <linux/mmc/host.h>
#include <linux/mmc/card.h>
+#include <linux/mmc/sd.h>
#include <linux/mmc/slot-gpio.h>
#include <linux/amba/bus.h>
#include <linux/clk.h>
@@ -1217,6 +1218,9 @@ mmci_start_command(struct mmci_host *host, struct mmc_command *cmd, u32 c)
writel_relaxed(clks, host->base + MMCIDATATIMER);
}

+ if (host->ops->pre_sig_volt_switch && cmd->opcode == SD_SWITCH_VOLTAGE)
+ host->ops->pre_sig_volt_switch(host);
+
if (/*interrupt*/0)
c |= MCI_CPSM_INTERRUPT;

@@ -1830,6 +1834,7 @@ static int mmci_get_cd(struct mmc_host *mmc)

static int mmci_sig_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios)
{
+ struct mmci_host *host = mmc_priv(mmc);
int ret = 0;

if (!IS_ERR(mmc->supply.vqmmc)) {
@@ -1849,6 +1854,9 @@ static int mmci_sig_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios)
break;
}

+ if (!ret && host->ops && host->ops->post_sig_volt_switch)
+ ret = host->ops->post_sig_volt_switch(host, ios);
+
if (ret)
dev_warn(mmc_dev(mmc), "Voltage switch failed\n");
}
diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
index ddcdfb827996..c3bc0a38d4cb 100644
--- a/drivers/mmc/host/mmci.h
+++ b/drivers/mmc/host/mmci.h
@@ -377,6 +377,8 @@ struct mmci_host_ops {
void (*set_clkreg)(struct mmci_host *host, unsigned int desired);
void (*set_pwrreg)(struct mmci_host *host, unsigned int pwr);
bool (*busy_complete)(struct mmci_host *host, u32 status, u32 err_msk);
+ void (*pre_sig_volt_switch)(struct mmci_host *host);
+ int (*post_sig_volt_switch)(struct mmci_host *host, struct mmc_ios *ios);
};

struct mmci_host {
--
2.17.1

2020-01-28 09:09:41

by Ludovic Barre

[permalink] [raw]
Subject: [PATCH V2 4/9] mmc: mmci: add private pointer for variant

In variant init function, some references may be allocated for
variant specific usage. Add a private void* to mmci_host struct
allows at variant functions to access on this references by
mmci_host structure.

Signed-off-by: Ludovic Barre <[email protected]>
---
drivers/mmc/host/mmci.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
index 55acc0971a44..ddcdfb827996 100644
--- a/drivers/mmc/host/mmci.h
+++ b/drivers/mmc/host/mmci.h
@@ -410,6 +410,7 @@ struct mmci_host {
struct mmc_host_ops *mmc_ops;
struct mmci_host_ops *ops;
struct variant_data *variant;
+ void *variant_priv;
struct pinctrl *pinctrl;
struct pinctrl_state *pins_opendrain;

--
2.17.1

2020-01-28 09:09:55

by Ludovic Barre

[permalink] [raw]
Subject: [PATCH V2 3/9] mmc: mmci: add a reference at mmc_host_ops in mmci struct

The variant init function may need to add a mmc_host_ops,
for example to add the execute_tuning support if this feature
is available.
This patch adds mmc_host_ops pointer in mmci struct.

Signed-off-by: Ludovic Barre <[email protected]>
---
drivers/mmc/host/mmci.c | 4 ++--
drivers/mmc/host/mmci.h | 1 +
2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index e9ffce8d41ea..d0a041c9e6cd 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -1933,6 +1933,8 @@ static int mmci_probe(struct amba_device *dev,

host = mmc_priv(mmc);
host->mmc = mmc;
+ host->mmc_ops = &mmci_ops;
+ mmc->ops = &mmci_ops;

/*
* Some variant (STM32) doesn't have opendrain bit, nevertheless
@@ -2072,8 +2074,6 @@ static int mmci_probe(struct amba_device *dev,
host->stop_abort.arg = 0;
host->stop_abort.flags = MMC_RSP_R1B | MMC_CMD_AC;

- mmc->ops = &mmci_ops;
-
/* We support these PM capabilities. */
mmc->pm_caps |= MMC_PM_KEEP_POWER;

diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
index ea6a0b5779d4..55acc0971a44 100644
--- a/drivers/mmc/host/mmci.h
+++ b/drivers/mmc/host/mmci.h
@@ -407,6 +407,7 @@ struct mmci_host {
u32 mask1_reg;
u8 vqmmc_enabled:1;
struct mmci_platform_data *plat;
+ struct mmc_host_ops *mmc_ops;
struct mmci_host_ops *ops;
struct variant_data *variant;
struct pinctrl *pinctrl;
--
2.17.1

2020-01-28 09:10:02

by Ludovic Barre

[permalink] [raw]
Subject: [PATCH V2 5/9] dt-bindings: mmc: mmci: add delay block base register for sdmmc

To support the sdr104 mode, the sdmmc variant has a
hardware delay block to manage the clock phase when sampling
data received by the card.

This patch adds a second base register (optional) for
sdmmc delay block.

Signed-off-by: Ludovic Barre <[email protected]>
---
Documentation/devicetree/bindings/mmc/mmci.txt | 2 ++
1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/mmc/mmci.txt b/Documentation/devicetree/bindings/mmc/mmci.txt
index 6d3c626e017d..4ec921e4bf34 100644
--- a/Documentation/devicetree/bindings/mmc/mmci.txt
+++ b/Documentation/devicetree/bindings/mmc/mmci.txt
@@ -28,6 +28,8 @@ specific for ux500 variant:
- st,sig-pin-fbclk : feedback clock signal pin used.

specific for sdmmc variant:
+- reg : a second base register may be defined if a delay
+ block is present and used for tuning.
- st,sig-dir : signal direction polarity used for cmd, dat0 dat123.
- st,neg-edge : data & command phase relation, generated on
sd clock falling edge.
--
2.17.1

2020-01-28 09:10:08

by Ludovic Barre

[permalink] [raw]
Subject: [PATCH V2 2/9] mmc: mmci: sdmmc: rename sdmmc_priv struct to sdmmc_idma

This patch renames sdmmc_priv struct to sdmmc_idma
which is assigned to host->dma_priv.

Signed-off-by: Ludovic Barre <[email protected]>
---
drivers/mmc/host/mmci_stm32_sdmmc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/mmci_stm32_sdmmc.c b/drivers/mmc/host/mmci_stm32_sdmmc.c
index 6ccfbbc82c77..df08f6662431 100644
--- a/drivers/mmc/host/mmci_stm32_sdmmc.c
+++ b/drivers/mmc/host/mmci_stm32_sdmmc.c
@@ -20,7 +20,7 @@ struct sdmmc_lli_desc {
u32 idmasize;
};

-struct sdmmc_priv {
+struct sdmmc_idma {
dma_addr_t sg_dma;
void *sg_cpu;
};
@@ -92,7 +92,7 @@ static void sdmmc_idma_unprep_data(struct mmci_host *host,

static int sdmmc_idma_setup(struct mmci_host *host)
{
- struct sdmmc_priv *idma;
+ struct sdmmc_idma *idma;

idma = devm_kzalloc(mmc_dev(host->mmc), sizeof(*idma), GFP_KERNEL);
if (!idma)
@@ -123,7 +123,7 @@ static int sdmmc_idma_setup(struct mmci_host *host)
static int sdmmc_idma_start(struct mmci_host *host, unsigned int *datactrl)

{
- struct sdmmc_priv *idma = host->dma_priv;
+ struct sdmmc_idma *idma = host->dma_priv;
struct sdmmc_lli_desc *desc = (struct sdmmc_lli_desc *)idma->sg_cpu;
struct mmc_data *data = host->data;
struct scatterlist *sg;
--
2.17.1

2020-02-05 17:51:15

by Rob Herring (Arm)

[permalink] [raw]
Subject: Re: [PATCH V2 5/9] dt-bindings: mmc: mmci: add delay block base register for sdmmc

On Tue, 28 Jan 2020 10:06:32 +0100, Ludovic Barre wrote:
> To support the sdr104 mode, the sdmmc variant has a
> hardware delay block to manage the clock phase when sampling
> data received by the card.
>
> This patch adds a second base register (optional) for
> sdmmc delay block.
>
> Signed-off-by: Ludovic Barre <[email protected]>
> ---
> Documentation/devicetree/bindings/mmc/mmci.txt | 2 ++
> 1 file changed, 2 insertions(+)
>

Acked-by: Rob Herring <[email protected]>

2020-02-11 16:46:47

by Ludovic Barre

[permalink] [raw]
Subject: Re: [PATCH V2 0/9] mmc: mmci: sdmmc: add sdr104 support

hi Ulf

Just a "gentleman ping" on this series
https://patchwork.kernel.org/project/linux-mmc/list/?series=234011

Regards
Ludo

Le 1/28/20 à 10:06 AM, Ludovic Barre a écrit :
> To support the sdr104 mode, sdmmc variant needs:
> -Hardware delay block support for sdmmc variant
> with tuning procedure
> -Voltage switch callbacks
> -sdmmc revision 2.0
>
> V2:
> -regroup host->mmc_ops & mmc->ops assignment
> -add timeout define
> -rename prep_volt_switch to pre_sig_volt_switch
> -rename volt_switch to post_sig_volt_switch
> -add 'why' comment for "mmc: mmci: add volt_switch callbacks"
>
> Ludovic Barre (9):
> mmc: mmci: sdmmc: replace sg_dma_xxx macros
> mmc: mmci: sdmmc: rename sdmmc_priv struct to sdmmc_idma
> mmc: mmci: add a reference at mmc_host_ops in mmci struct
> mmc: mmci: add private pointer for variant
> dt-bindings: mmc: mmci: add delay block base register for sdmmc
> mmc: mmci: sdmmc: add execute tuning with delay block
> mmc: mmci: add volt_switch callbacks
> mmc: mmci: sdmmc: add voltage switch functions
> mmc: mmci: add sdmmc variant revision 2.0
>
> .../devicetree/bindings/mmc/mmci.txt | 2 +
> drivers/mmc/host/mmci.c | 42 +++-
> drivers/mmc/host/mmci.h | 8 +
> drivers/mmc/host/mmci_stm32_sdmmc.c | 204 +++++++++++++++++-
> 4 files changed, 248 insertions(+), 8 deletions(-)
>

2020-02-11 17:00:26

by Ulf Hansson

[permalink] [raw]
Subject: Re: [PATCH V2 0/9] mmc: mmci: sdmmc: add sdr104 support

On Tue, 11 Feb 2020 at 15:47, Ludovic BARRE <[email protected]> wrote:
>
> hi Ulf
>
> Just a "gentleman ping" on this series
> https://patchwork.kernel.org/project/linux-mmc/list/?series=234011

I will have a look later this week. The merge window closed yesterday
and normally I don't queue anything but fixes during the merge window.

Anyway, apologize for the delays.

Kind regards
Uffe

>
> Regards
> Ludo
>
> Le 1/28/20 à 10:06 AM, Ludovic Barre a écrit :
> > To support the sdr104 mode, sdmmc variant needs:
> > -Hardware delay block support for sdmmc variant
> > with tuning procedure
> > -Voltage switch callbacks
> > -sdmmc revision 2.0
> >
> > V2:
> > -regroup host->mmc_ops & mmc->ops assignment
> > -add timeout define
> > -rename prep_volt_switch to pre_sig_volt_switch
> > -rename volt_switch to post_sig_volt_switch
> > -add 'why' comment for "mmc: mmci: add volt_switch callbacks"
> >
> > Ludovic Barre (9):
> > mmc: mmci: sdmmc: replace sg_dma_xxx macros
> > mmc: mmci: sdmmc: rename sdmmc_priv struct to sdmmc_idma
> > mmc: mmci: add a reference at mmc_host_ops in mmci struct
> > mmc: mmci: add private pointer for variant
> > dt-bindings: mmc: mmci: add delay block base register for sdmmc
> > mmc: mmci: sdmmc: add execute tuning with delay block
> > mmc: mmci: add volt_switch callbacks
> > mmc: mmci: sdmmc: add voltage switch functions
> > mmc: mmci: add sdmmc variant revision 2.0
> >
> > .../devicetree/bindings/mmc/mmci.txt | 2 +
> > drivers/mmc/host/mmci.c | 42 +++-
> > drivers/mmc/host/mmci.h | 8 +
> > drivers/mmc/host/mmci_stm32_sdmmc.c | 204 +++++++++++++++++-
> > 4 files changed, 248 insertions(+), 8 deletions(-)
> >

2020-02-19 10:29:49

by Ulf Hansson

[permalink] [raw]
Subject: Re: [PATCH V2 0/9] mmc: mmci: sdmmc: add sdr104 support

On Tue, 28 Jan 2020 at 10:06, Ludovic Barre <[email protected]> wrote:
>
> To support the sdr104 mode, sdmmc variant needs:
> -Hardware delay block support for sdmmc variant
> with tuning procedure
> -Voltage switch callbacks
> -sdmmc revision 2.0
>
> V2:
> -regroup host->mmc_ops & mmc->ops assignment
> -add timeout define
> -rename prep_volt_switch to pre_sig_volt_switch
> -rename volt_switch to post_sig_volt_switch
> -add 'why' comment for "mmc: mmci: add volt_switch callbacks"
>
> Ludovic Barre (9):
> mmc: mmci: sdmmc: replace sg_dma_xxx macros
> mmc: mmci: sdmmc: rename sdmmc_priv struct to sdmmc_idma
> mmc: mmci: add a reference at mmc_host_ops in mmci struct
> mmc: mmci: add private pointer for variant
> dt-bindings: mmc: mmci: add delay block base register for sdmmc
> mmc: mmci: sdmmc: add execute tuning with delay block
> mmc: mmci: add volt_switch callbacks
> mmc: mmci: sdmmc: add voltage switch functions
> mmc: mmci: add sdmmc variant revision 2.0
>
> .../devicetree/bindings/mmc/mmci.txt | 2 +
> drivers/mmc/host/mmci.c | 42 +++-
> drivers/mmc/host/mmci.h | 8 +
> drivers/mmc/host/mmci_stm32_sdmmc.c | 204 +++++++++++++++++-
> 4 files changed, 248 insertions(+), 8 deletions(-)
>
> --
> 2.17.1
>

Applied for next, thanks!

I took the liberty to do minor amendments to some of the changelogs,
but in particular I have change some of prefixes for the commit
message headers into "mmc: mmci_sdmmc:".

Please tell, if there is anything that you want me to update.

Kind regards
Uffe

2020-02-24 16:22:06

by Ludovic Barre

[permalink] [raw]
Subject: Re: [PATCH V2 0/9] mmc: mmci: sdmmc: add sdr104 support

hi Ulf

Le 2/19/20 à 11:28 AM, Ulf Hansson a écrit :
> On Tue, 28 Jan 2020 at 10:06, Ludovic Barre <[email protected]> wrote:
>>
>> To support the sdr104 mode, sdmmc variant needs:
>> -Hardware delay block support for sdmmc variant
>> with tuning procedure
>> -Voltage switch callbacks
>> -sdmmc revision 2.0
>>
>> V2:
>> -regroup host->mmc_ops & mmc->ops assignment
>> -add timeout define
>> -rename prep_volt_switch to pre_sig_volt_switch
>> -rename volt_switch to post_sig_volt_switch
>> -add 'why' comment for "mmc: mmci: add volt_switch callbacks"
>>
>> Ludovic Barre (9):
>> mmc: mmci: sdmmc: replace sg_dma_xxx macros
>> mmc: mmci: sdmmc: rename sdmmc_priv struct to sdmmc_idma
>> mmc: mmci: add a reference at mmc_host_ops in mmci struct
>> mmc: mmci: add private pointer for variant
>> dt-bindings: mmc: mmci: add delay block base register for sdmmc
>> mmc: mmci: sdmmc: add execute tuning with delay block
>> mmc: mmci: add volt_switch callbacks
>> mmc: mmci: sdmmc: add voltage switch functions
>> mmc: mmci: add sdmmc variant revision 2.0
>>
>> .../devicetree/bindings/mmc/mmci.txt | 2 +
>> drivers/mmc/host/mmci.c | 42 +++-
>> drivers/mmc/host/mmci.h | 8 +
>> drivers/mmc/host/mmci_stm32_sdmmc.c | 204 +++++++++++++++++-
>> 4 files changed, 248 insertions(+), 8 deletions(-)
>>
>> --
>> 2.17.1
>>
>
> Applied for next, thanks!

thanks Ulf.

>
> I took the liberty to do minor amendments to some of the changelogs,
> but in particular I have change some of prefixes for the commit
> message headers into "mmc: mmci_sdmmc:".

Ok, I use this prefixe for next commit.

>
> Please tell, if there is anything that you want me to update.

I tested your next branch, and it's ok for me.
sdmmc upstream is almost finished, I just some recent fixes to send.

>
> Kind regards
> Uffe
>