diff mbox

[2/3] mmc: tmio-mmc: add support for 32bit data port

Message ID 20160909155238.17852-3-chris.brandt@renesas.com (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Brandt Sept. 9, 2016, 3:52 p.m. UTC
For the r7s72100 SOC, the DATA_PORT register was change to be 32-bits wide.
Therefore a new flag has been created that will allow 32-bit reads/writes
to the DATA_PORT register instead of 16-bit (because 16-bits accesses are
not supported).

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
---
 drivers/mmc/host/tmio_mmc.h     | 12 ++++++++++++
 drivers/mmc/host/tmio_mmc_pio.c | 35 +++++++++++++++++++++++++++++++++++
 include/linux/mfd/tmio.h        |  5 +++++
 3 files changed, 52 insertions(+)

Comments

Sergei Shtylyov Sept. 9, 2016, 5:27 p.m. UTC | #1
Hello.

On 09/09/2016 06:52 PM, Chris Brandt wrote:

> For the r7s72100 SOC, the DATA_PORT register was change to be 32-bits wide.
> Therefore a new flag has been created that will allow 32-bit reads/writes
> to the DATA_PORT register instead of 16-bit (because 16-bits accesses are
> not supported).
>
> Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
[...]
> diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
> index 017a4dc..c38542d 100644
> --- a/drivers/mmc/host/tmio_mmc_pio.c
> +++ b/drivers/mmc/host/tmio_mmc_pio.c
> @@ -439,10 +439,45 @@ static void tmio_mmc_transfer_data(struct tmio_mmc_host *host,
>  {
>  	int is_read = host->data->flags & MMC_DATA_READ;
>  	u8  *buf8;
> +	u32 data;
>
>  	/*
>  	 * Transfer the data
>  	 */
> +	if (host->pdata->flags & TMIO_MMC_32BIT_DATA_PORT) {
> +		if (is_read)
> +			sd_ctrl_read32_rep(host, CTL_SD_DATA_PORT, (u32 *)buf,
> +					   count >> 2);
> +		else
> +			sd_ctrl_write32_rep(host, CTL_SD_DATA_PORT, (u32 *)buf,
> +					    count >> 2);
> +
> +		/* if count was multiple of 4 */
> +		if (!(count & 0x3))
> +			return;
> +
> +		buf8 = (u8 *)(buf + (count >> 2));
> +		count %= 4;
> +
> +		if (is_read) {
> +			sd_ctrl_read32_rep(host, CTL_SD_DATA_PORT, &data, 1);
> +			while (count--) {
> +				*buf8 = data * 0xFF;

    'data & 0xFF', perhaps?

> +				data = data >> 8;
> +				buf8++;
> +			}
> +		} else {
> +			data = *buf8++;
> +			if (count > 1)
> +				data |= (*buf8++ << 8);
> +			if (count > 2)
> +				data |= (*buf8++ << 16);
> +			sd_ctrl_write32_rep(host, CTL_SD_DATA_PORT, &data, 1);
> +		}
> +
> +		return;
> +	}
> +
>  	if (is_read)
>  		sd_ctrl_read16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1);
>  	else

MBR, Sergei

--
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
Chris Brandt Sept. 9, 2016, 6:29 p.m. UTC | #2
On 9/9/2016, Sergei Shtylyov wrote:
> > +		if (is_read) {

> > +			sd_ctrl_read32_rep(host, CTL_SD_DATA_PORT, &data, 1);

> > +			while (count--) {

> > +				*buf8 = data * 0xFF;

> 

>     'data & 0xFF', perhaps?



Wow...how did I miss that????

Thank you.


Chris
Geert Uytterhoeven Sept. 11, 2016, 8:09 a.m. UTC | #3
On Fri, Sep 9, 2016 at 5:52 PM, Chris Brandt <chris.brandt@renesas.com> wrote:
> For the r7s72100 SOC, the DATA_PORT register was change to be 32-bits wide.

changed

> --- a/drivers/mmc/host/tmio_mmc.h
> +++ b/drivers/mmc/host/tmio_mmc.h

> @@ -259,4 +265,10 @@ static inline void sd_ctrl_write32_as_16_and_16(struct tmio_mmc_host *host, int
>         writew(val >> 16, host->ctl + ((addr + 2) << host->bus_shift));
>  }
>
> +static inline void sd_ctrl_write32_rep(struct tmio_mmc_host *host, int addr,
> +               u32 *buf, int count)

const u32 *buf

> +{
> +       writesl(host->ctl + (addr << host->bus_shift), buf, count);
> +}
> +

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
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
Chris Brandt Sept. 11, 2016, 7:50 p.m. UTC | #4
On 9/11/2016, Geert Uytterhoeven wrote:
> > --- a/drivers/mmc/host/tmio_mmc.h

> > +++ b/drivers/mmc/host/tmio_mmc.h

> 

> > @@ -259,4 +265,10 @@ static inline void

> sd_ctrl_write32_as_16_and_16(struct tmio_mmc_host *host, int

> >         writew(val >> 16, host->ctl + ((addr + 2) <<

> > host->bus_shift));  }

> >

> > +static inline void sd_ctrl_write32_rep(struct tmio_mmc_host *host, int

> addr,

> > +               u32 *buf, int count)

> 

> const u32 *buf




So would you say sd_ctrl_write16_rep should also be changed to be 'const u16 *buf'?

Currently it is:
static inline void sd_ctrl_write16_rep(struct tmio_mmc_host *host, int addr,
		u16 *buf, int count)
{
	writesw(host->ctl + (addr << host->bus_shift), buf, count);
}



Chris
Geert Uytterhoeven Sept. 12, 2016, 8:09 a.m. UTC | #5
Hi Chris,

On Sun, Sep 11, 2016 at 9:50 PM, Chris Brandt <Chris.Brandt@renesas.com> wrote:
> On 9/11/2016, Geert Uytterhoeven wrote:
>> > --- a/drivers/mmc/host/tmio_mmc.h
>> > +++ b/drivers/mmc/host/tmio_mmc.h
>>
>> > @@ -259,4 +265,10 @@ static inline void
>> sd_ctrl_write32_as_16_and_16(struct tmio_mmc_host *host, int
>> >         writew(val >> 16, host->ctl + ((addr + 2) <<
>> > host->bus_shift));  }
>> >
>> > +static inline void sd_ctrl_write32_rep(struct tmio_mmc_host *host, int
>> addr,
>> > +               u32 *buf, int count)
>>
>> const u32 *buf
>
> So would you say sd_ctrl_write16_rep should also be changed to be 'const u16 *buf'?
>
> Currently it is:
> static inline void sd_ctrl_write16_rep(struct tmio_mmc_host *host, int addr,
>                 u16 *buf, int count)
> {
>         writesw(host->ctl + (addr << host->bus_shift), buf, count);

Ideally it should become const, too.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
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
Chris Brandt Sept. 12, 2016, 11:56 a.m. UTC | #6
Hi Geert,

On 9/11/12016, Geert Uytterhoeven wrote:
> > So would you say sd_ctrl_write16_rep should also be changed to be 'const

> u16 *buf'?

> >

> > Currently it is:

> > static inline void sd_ctrl_write16_rep(struct tmio_mmc_host *host, int

> addr,

> >                 u16 *buf, int count)

> > {

> >         writesw(host->ctl + (addr << host->bus_shift), buf, count);

> 

> Ideally it should become const, too.


I can add another patch at the end of this series that changes it to match sd_ctrl_write32_rep.


(unless for some reason you think it should be a separate patch that is not associated with this series)


Chris
Geert Uytterhoeven Sept. 12, 2016, noon UTC | #7
Hi Chris,

On Mon, Sep 12, 2016 at 1:56 PM, Chris Brandt <Chris.Brandt@renesas.com> wrote:
> On 9/11/12016, Geert Uytterhoeven wrote:
>> > So would you say sd_ctrl_write16_rep should also be changed to be 'const
>> u16 *buf'?
>> >
>> > Currently it is:
>> > static inline void sd_ctrl_write16_rep(struct tmio_mmc_host *host, int
>> addr,
>> >                 u16 *buf, int count)
>> > {
>> >         writesw(host->ctl + (addr << host->bus_shift), buf, count);
>>
>> Ideally it should become const, too.
>
> I can add another patch at the end of this series that changes it to match sd_ctrl_write32_rep.
>
> (unless for some reason you think it should be a separate patch that is not associated with this series)

Well, it's not really related to this series, so it can be a separate patch.
But including it in this series won't hurt much, I guess.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
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
diff mbox

Patch

diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index ecb99fc..1f9a322 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -237,6 +237,12 @@  static inline u32 sd_ctrl_read16_and_16_as_32(struct tmio_mmc_host *host, int ad
 	       readw(host->ctl + ((addr + 2) << host->bus_shift)) << 16;
 }
 
+static inline void sd_ctrl_read32_rep(struct tmio_mmc_host *host, int addr,
+		u32 *buf, int count)
+{
+	readsl(host->ctl + (addr << host->bus_shift), buf, count);
+}
+
 static inline void sd_ctrl_write16(struct tmio_mmc_host *host, int addr, u16 val)
 {
 	/* If there is a hook and it returns non-zero then there
@@ -259,4 +265,10 @@  static inline void sd_ctrl_write32_as_16_and_16(struct tmio_mmc_host *host, int
 	writew(val >> 16, host->ctl + ((addr + 2) << host->bus_shift));
 }
 
+static inline void sd_ctrl_write32_rep(struct tmio_mmc_host *host, int addr,
+		u32 *buf, int count)
+{
+	writesl(host->ctl + (addr << host->bus_shift), buf, count);
+}
+
 #endif
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 017a4dc..c38542d 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -439,10 +439,45 @@  static void tmio_mmc_transfer_data(struct tmio_mmc_host *host,
 {
 	int is_read = host->data->flags & MMC_DATA_READ;
 	u8  *buf8;
+	u32 data;
 
 	/*
 	 * Transfer the data
 	 */
+	if (host->pdata->flags & TMIO_MMC_32BIT_DATA_PORT) {
+		if (is_read)
+			sd_ctrl_read32_rep(host, CTL_SD_DATA_PORT, (u32 *)buf,
+					   count >> 2);
+		else
+			sd_ctrl_write32_rep(host, CTL_SD_DATA_PORT, (u32 *)buf,
+					    count >> 2);
+
+		/* if count was multiple of 4 */
+		if (!(count & 0x3))
+			return;
+
+		buf8 = (u8 *)(buf + (count >> 2));
+		count %= 4;
+
+		if (is_read) {
+			sd_ctrl_read32_rep(host, CTL_SD_DATA_PORT, &data, 1);
+			while (count--) {
+				*buf8 = data * 0xFF;
+				data = data >> 8;
+				buf8++;
+			}
+		} else {
+			data = *buf8++;
+			if (count > 1)
+				data |= (*buf8++ << 8);
+			if (count > 2)
+				data |= (*buf8++ << 16);
+			sd_ctrl_write32_rep(host, CTL_SD_DATA_PORT, &data, 1);
+		}
+
+		return;
+	}
+
 	if (is_read)
 		sd_ctrl_read16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1);
 	else
diff --git a/include/linux/mfd/tmio.h b/include/linux/mfd/tmio.h
index 3b95dc7..0dbcb7e 100644
--- a/include/linux/mfd/tmio.h
+++ b/include/linux/mfd/tmio.h
@@ -100,6 +100,11 @@ 
 #define TMIO_MMC_SDIO_STATUS_QUIRK	(1 << 8)
 
 /*
+ * Some controllers have a 32-bit wide data port register
+ */
+#define TMIO_MMC_32BIT_DATA_PORT	(1 << 9)
+
+/*
  * Some controllers allows to set SDx actual clock
  */
 #define TMIO_MMC_CLK_ACTUAL		(1 << 10)