diff mbox

[1/3] spi: Add addr_width field to struct spi_message

Message ID 1431269253-22890-1-git-send-email-B48286@freescale.com (mailing list archive)
State New, archived
Headers show

Commit Message

Hou Zhiqiang May 10, 2015, 2:47 p.m. UTC
From: Hou Zhiqiang <B48286@freescale.com>

Make SPI controller can get address width of the SPI device.

Signed-off-by: Hou Zhiqiang <B48286@freescale.com>

Based on git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git.
Tested on T1040RDB and T2080RDB.
---
 include/linux/spi/spi.h | 3 +++
 1 file changed, 3 insertions(+)

Comments

Geert Uytterhoeven May 11, 2015, 7:43 a.m. UTC | #1
On Sun, May 10, 2015 at 4:47 PM, Zhiqiang Hou <B48286@freescale.com> wrote:
> From: Hou Zhiqiang <B48286@freescale.com>
>
> Make SPI controller can get address width of the SPI device.

What does "address wdith" mean? From your other patches, I infer it's either
24 or 32 bit addressing as used by nor-jedec ("m25p80").
Why does the generic spi_message needs to have nor-jedec-specific fields?

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-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mark Brown May 11, 2015, 4:17 p.m. UTC | #2
On Mon, May 11, 2015 at 09:43:21AM +0200, Geert Uytterhoeven wrote:
> On Sun, May 10, 2015 at 4:47 PM, Zhiqiang Hou <B48286@freescale.com> wrote:

> > Make SPI controller can get address width of the SPI device.

> What does "address wdith" mean? From your other patches, I infer it's either
> 24 or 32 bit addressing as used by nor-jedec ("m25p80").
> Why does the generic spi_message needs to have nor-jedec-specific fields?

Indeed, if this is flash specific then it's questionable if the SPI
framework should be involved at all - it's sounding like a controller
that's flash specific and ought to be in the MTD subsystem.
Hou Zhiqiang May 12, 2015, 8:06 a.m. UTC | #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sIG15c2VsZiBhIGhhY2tlci4NCj4gQnV0IHdoZW4gSSdtIHRhbGtp
bmcgdG8gam91cm5hbGlzdHMgSSBqdXN0IHNheSAicHJvZ3JhbW1lciIgb3Igc29tZXRoaW5nDQo+
IGxpa2UgdGhhdC4NCj4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtLSBMaW51cyBU
b3J2YWxkcw0KDQpUaGFua3MsDQpaaGlxaWFuZw0K
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Geert Uytterhoeven May 12, 2015, 8:11 a.m. UTC | #4
Hi Zhiqiang,

On Tue, May 12, 2015 at 10:06 AM, Hou Zhiqiang <B48286@freescale.com> wrote:
>> From: geert.uytterhoeven@gmail.com [mailto:geert.uytterhoeven@gmail.com]
>> On Behalf Of Geert Uytterhoeven
>> Sent: 2015?5?11? 15:43
>> To: Hou Zhiqiang-B48286
>> Cc: linux-spi; Mark Brown; Hu Mingkai-B21284
>> Subject: Re: [PATCH 1/3] spi: Add addr_width field to struct spi_message
>>
>> On Sun, May 10, 2015 at 4:47 PM, Zhiqiang Hou <B48286@freescale.com>
>> wrote:
>> > From: Hou Zhiqiang <B48286@freescale.com>
>> >
>> > Make SPI controller can get address width of the SPI device.
>>
>> What does "address wdith" mean? From your other patches, I infer it's
>> either
>> 24 or 32 bit addressing as used by nor-jedec ("m25p80").
>> Why does the generic spi_message needs to have nor-jedec-specific fields?
>
> Yes, the address width is the address width of spi flash.
> The reason to add this nor-jedec-specific field to spi_message is the eSPI controller
> of Freescale limits the MAX transaction length(TRANLEN) to 0x10000 each transaction, so if the
> data size transferred exceed the TRANLEN, the eSPI controller can only transfer data for
> the first TRANLEN, and need to issue new write/read commands to complete the remainders.
> So, eSPI controller need getting the address width of spi flash, and then calculate the
> new address to initialize the new write/read commands.

Shouldn't this be handled by the m25p80 driver instead?

I see spi_master has a max_dma_len field.

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-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Hou Zhiqiang May 12, 2015, 8:27 a.m. UTC | #5
> -----Original Message-----

> From: geert.uytterhoeven@gmail.com [mailto:geert.uytterhoeven@gmail.com]

> On Behalf Of Geert Uytterhoeven

> Sent: 2015?5?12? 16:12

> To: Hou Zhiqiang-B48286

> Cc: linux-spi; Mark Brown; Hu Mingkai-B21284

> Subject: Re: [PATCH 1/3] spi: Add addr_width field to struct spi_message

> 

> Hi Zhiqiang,

> 

> On Tue, May 12, 2015 at 10:06 AM, Hou Zhiqiang <B48286@freescale.com>

> wrote:

> >> From: geert.uytterhoeven@gmail.com

> >> [mailto:geert.uytterhoeven@gmail.com]

> >> On Behalf Of Geert Uytterhoeven

> >> Sent: 2015?5?11? 15:43

> >> To: Hou Zhiqiang-B48286

> >> Cc: linux-spi; Mark Brown; Hu Mingkai-B21284

> >> Subject: Re: [PATCH 1/3] spi: Add addr_width field to struct

> >> spi_message

> >>

> >> On Sun, May 10, 2015 at 4:47 PM, Zhiqiang Hou <B48286@freescale.com>

> >> wrote:

> >> > From: Hou Zhiqiang <B48286@freescale.com>

> >> >

> >> > Make SPI controller can get address width of the SPI device.

> >>

> >> What does "address wdith" mean? From your other patches, I infer it's

> >> either

> >> 24 or 32 bit addressing as used by nor-jedec ("m25p80").

> >> Why does the generic spi_message needs to have nor-jedec-specific

> fields?

> >

> > Yes, the address width is the address width of spi flash.

> > The reason to add this nor-jedec-specific field to spi_message is the

> > eSPI controller of Freescale limits the MAX transaction

> > length(TRANLEN) to 0x10000 each transaction, so if the data size

> > transferred exceed the TRANLEN, the eSPI controller can only transfer

> data for the first TRANLEN, and need to issue new write/read commands to

> complete the remainders.

> > So, eSPI controller need getting the address width of spi flash, and

> > then calculate the new address to initialize the new write/read

> commands.

> 

> Shouldn't this be handled by the m25p80 driver instead?

> 

> I see spi_master has a max_dma_len field.


No, only the eSPI controller need to do this, it caused by the eSPI controller's
feature and other SPI controller have not this TRANLEN limit.
And it has no relation with DMA.
 
> 

> 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
Geert Uytterhoeven May 12, 2015, 8:57 a.m. UTC | #6
Hi Zhiqiang,

On Tue, May 12, 2015 at 10:27 AM, Hou Zhiqiang <B48286@freescale.com> wrote:
>> -----Original Message-----
>> From: geert.uytterhoeven@gmail.com [mailto:geert.uytterhoeven@gmail.com]
>> On Behalf Of Geert Uytterhoeven
>> Sent: 2015?5?12? 16:12
>> To: Hou Zhiqiang-B48286
>> Cc: linux-spi; Mark Brown; Hu Mingkai-B21284
>> Subject: Re: [PATCH 1/3] spi: Add addr_width field to struct spi_message
>>
>> On Tue, May 12, 2015 at 10:06 AM, Hou Zhiqiang <B48286@freescale.com>
>> wrote:
>> >> From: geert.uytterhoeven@gmail.com
>> >> [mailto:geert.uytterhoeven@gmail.com]
>> >> On Behalf Of Geert Uytterhoeven
>> >> Sent: 2015?5?11? 15:43
>> >> To: Hou Zhiqiang-B48286
>> >> Cc: linux-spi; Mark Brown; Hu Mingkai-B21284
>> >> Subject: Re: [PATCH 1/3] spi: Add addr_width field to struct
>> >> spi_message
>> >>
>> >> On Sun, May 10, 2015 at 4:47 PM, Zhiqiang Hou <B48286@freescale.com>
>> >> wrote:
>> >> > From: Hou Zhiqiang <B48286@freescale.com>
>> >> >
>> >> > Make SPI controller can get address width of the SPI device.
>> >>
>> >> What does "address wdith" mean? From your other patches, I infer it's
>> >> either
>> >> 24 or 32 bit addressing as used by nor-jedec ("m25p80").
>> >> Why does the generic spi_message needs to have nor-jedec-specific
>> fields?
>> >
>> > Yes, the address width is the address width of spi flash.
>> > The reason to add this nor-jedec-specific field to spi_message is the
>> > eSPI controller of Freescale limits the MAX transaction
>> > length(TRANLEN) to 0x10000 each transaction, so if the data size
>> > transferred exceed the TRANLEN, the eSPI controller can only transfer
>> data for the first TRANLEN, and need to issue new write/read commands to
>> complete the remainders.
>> > So, eSPI controller need getting the address width of spi flash, and
>> > then calculate the new address to initialize the new write/read
>> commands.
>>
>> Shouldn't this be handled by the m25p80 driver instead?
>>
>> I see spi_master has a max_dma_len field.
>
> No, only the eSPI controller need to do this, it caused by the eSPI controller's
> feature and other SPI controller have not this TRANLEN limit.
> And it has no relation with DMA.

IC.

Still, your doing m25p80-specific handling in your spi master driver.
Worse, you cannot connect any other type of spi device to your spi controller,
right?

So it looks like we need something like i2c_adapter_quirks, where spi masters
can advertise their limitations?

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-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mark Brown May 12, 2015, 10:23 a.m. UTC | #7
On Tue, May 12, 2015 at 10:57:03AM +0200, Geert Uytterhoeven wrote:

> So it looks like we need something like i2c_adapter_quirks, where spi masters
> can advertise their limitations?

We already have some flags for features/limitations (mostly only used by
the core) like _MUST_TX.
diff mbox

Patch

diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index d673072..c9cef2c 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -682,6 +682,9 @@  struct spi_message {
 	unsigned		actual_length;
 	int			status;
 
+	/* deliver the address width of spi device to spi controller */
+	u8			addr_width;
+
 	/* for optional use by whatever driver currently owns the
 	 * spi_message ...  between calls to spi_async and then later
 	 * complete(), that's the spi_master controller driver.