diff mbox series

[01/10] mmc: sdhci: Add quirk SDHCI_QUIRK2_SET_BUS_VOLTAGE

Message ID 20200306103857.23962-2-nsaenzjulienne@suse.de
State New
Headers show
Series Raspberry Pi vmmc regulator support | expand

Commit Message

Nicolas Saenz Julienne March 6, 2020, 10:38 a.m. UTC
Adds quirk for controllers whose bus power select register has to be set
even when powering SD cards from a regulator.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---
 drivers/mmc/host/sdhci.c | 5 +++++
 drivers/mmc/host/sdhci.h | 2 ++
 2 files changed, 7 insertions(+)

Comments

Adrian Hunter March 6, 2020, 12:34 p.m. UTC | #1
On 6/03/20 12:38 pm, Nicolas Saenz Julienne wrote:
> Adds quirk for controllers whose bus power select register has to be set
> even when powering SD cards from a regulator.
> 
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> ---
>  drivers/mmc/host/sdhci.c | 5 +++++
>  drivers/mmc/host/sdhci.h | 2 ++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index c59566363a42..c7fd87447457 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -1920,6 +1920,11 @@ static void sdhci_set_power_reg(struct sdhci_host *host, unsigned char mode,
>  
>  	mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
>  
> +	if (host->quirks2 & SDHCI_QUIRK2_SET_BUS_VOLTAGE) {

We don't really want to replace callbacks by quirks.

Replace sdhci_milbeaut_set_power() etc by a common fn in sdhci.c if you want.

> +		sdhci_set_power_noreg(host, mode, vdd);
> +		return;
> +	}
> +
>  	if (mode != MMC_POWER_OFF)
>  		sdhci_writeb(host, SDHCI_POWER_ON, SDHCI_POWER_CONTROL);
>  	else
> diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
> index cac2d97782e6..9531a4e5b148 100644
> --- a/drivers/mmc/host/sdhci.h
> +++ b/drivers/mmc/host/sdhci.h
> @@ -484,6 +484,8 @@ struct sdhci_host {
>   * block count.
>   */
>  #define SDHCI_QUIRK2_USE_32BIT_BLK_CNT			(1<<18)
> +/* Set bus voltage even when powering from an external regulator */
> +#define SDHCI_QUIRK2_SET_BUS_VOLTAGE			(1<<19)
>  
>  	int irq;		/* Device IRQ */
>  	void __iomem *ioaddr;	/* Mapped address */
>
Nicolas Saenz Julienne March 6, 2020, 12:40 p.m. UTC | #2
On Fri, 2020-03-06 at 14:34 +0200, Adrian Hunter wrote:
> On 6/03/20 12:38 pm, Nicolas Saenz Julienne wrote:
> > Adds quirk for controllers whose bus power select register has to be set
> > even when powering SD cards from a regulator.
> > 
> > Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> > ---
> >  drivers/mmc/host/sdhci.c | 5 +++++
> >  drivers/mmc/host/sdhci.h | 2 ++
> >  2 files changed, 7 insertions(+)
> > 
> > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> > index c59566363a42..c7fd87447457 100644
> > --- a/drivers/mmc/host/sdhci.c
> > +++ b/drivers/mmc/host/sdhci.c
> > @@ -1920,6 +1920,11 @@ static void sdhci_set_power_reg(struct sdhci_host
> > *host, unsigned char mode,
> >  
> >  	mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
> >  
> > +	if (host->quirks2 & SDHCI_QUIRK2_SET_BUS_VOLTAGE) {
> 
> We don't really want to replace callbacks by quirks.
> 
> Replace sdhci_milbeaut_set_power() etc by a common fn in sdhci.c if you want.

Ok, fair enough.

Regards,
Nicolas

> 
> > +		sdhci_set_power_noreg(host, mode, vdd);
> > +		return;
> > +	}
> > +
> >  	if (mode != MMC_POWER_OFF)
> >  		sdhci_writeb(host, SDHCI_POWER_ON, SDHCI_POWER_CONTROL);
> >  	else
> > diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
> > index cac2d97782e6..9531a4e5b148 100644
> > --- a/drivers/mmc/host/sdhci.h
> > +++ b/drivers/mmc/host/sdhci.h
> > @@ -484,6 +484,8 @@ struct sdhci_host {
> >   * block count.
> >   */
> >  #define SDHCI_QUIRK2_USE_32BIT_BLK_CNT			(1<<18)
> > +/* Set bus voltage even when powering from an external regulator */
> > +#define SDHCI_QUIRK2_SET_BUS_VOLTAGE			(1<<19)
> >  
> >  	int irq;		/* Device IRQ */
> >  	void __iomem *ioaddr;	/* Mapped address */
> >
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index c59566363a42..c7fd87447457 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1920,6 +1920,11 @@  static void sdhci_set_power_reg(struct sdhci_host *host, unsigned char mode,
 
 	mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
 
+	if (host->quirks2 & SDHCI_QUIRK2_SET_BUS_VOLTAGE) {
+		sdhci_set_power_noreg(host, mode, vdd);
+		return;
+	}
+
 	if (mode != MMC_POWER_OFF)
 		sdhci_writeb(host, SDHCI_POWER_ON, SDHCI_POWER_CONTROL);
 	else
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index cac2d97782e6..9531a4e5b148 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -484,6 +484,8 @@  struct sdhci_host {
  * block count.
  */
 #define SDHCI_QUIRK2_USE_32BIT_BLK_CNT			(1<<18)
+/* Set bus voltage even when powering from an external regulator */
+#define SDHCI_QUIRK2_SET_BUS_VOLTAGE			(1<<19)
 
 	int irq;		/* Device IRQ */
 	void __iomem *ioaddr;	/* Mapped address */