Skip to contentSkip to conversation

davinci: spi: replace existing SPI driver

PATCH Brian Niebuhr 3 participants 8 messages Jun 14, 2010 – Jun 16, 2010 11 messages not in the archive SPI

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): 004201cb0878$eaff2ac0$c0fd8040$@[email protected]

#2 lore raw
Quoted 11 lines
Quoted 1 line

I have compiled with the davinci_all_defconfig, but I don't

have EVMs

Quoted 2 lines

for the other davinci platforms to test with.

I was testing this series on OMAP-L137, OMAP-L138 and DM365 EVMs and I found that on all these EVMS, Interrupt mode has problems. Driver works
fine in DMA and POLL modes. Some problems which I had observed with the
old driver are gone now.

Do you have any idea what errors you're seeing in interrupt mode? I went and retested interrupt mode with several devices on my custom board and it still appeared to be working fine. It may be an interaction with code outside the driver because I'm running the identical driver code but I'm not running the latest kernel from the davinci git repository. I'm trying to figure out if I can get my DA850 EVM back into a state where I can debug this. Thanks for any hints you can give!

A message that is not in the archive (sent off-list or not yet received): BA34378D1528D04CB3C865B8BAB2472B024CC7-mqUZVEcnZosHtCCSzi1I5PfQPhDVBs+grNQQ6b5fDX0@public.gmane.org

#4 lore raw

Hi,

Quoted 12 lines · Brian Niebuhr
Quoted 11 lines
Quoted 1 line

I have compiled with the davinci_all_defconfig, but I don't

have EVMs

Quoted 2 lines

for the other davinci platforms to test with.

I was testing this series on OMAP-L137, OMAP-L138 and DM365 EVMs and I found that on all these EVMS, Interrupt mode has problems. Driver works
fine in DMA and POLL modes. Some problems which I had observed with the
old driver are gone now.

Quoted 8 lines

Do you have any idea what errors you're seeing in interrupt mode? I went and retested interrupt mode with several devices on my custom board and it still appeared to be working fine. It may be an interaction with code outside the driver because I'm running the identical driver code but I'm not running the latest kernel from the davinci git repository. I'm trying to figure out if I can get my DA850 EVM back into a state where I can debug this. Thanks for any hints you can give!

You may be knowing that on OMAP-L138 EVM, we have M25P64 Flash on SPI. When the driver is configured in Interrupt mode, kernel booting just hangs. I noticed that the SPI probe function is not coming out of spi_bitbang_start() call.

Thanks,
Sudhakar

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo

#5 lore raw
In reply to a message not in the archive

Hi,

Quoted 12 lines · Brian Niebuhr
Quoted 11 lines
Quoted 1 line

I have compiled with the davinci_all_defconfig, but I don't

have EVMs

Quoted 2 lines

for the other davinci platforms to test with.

I was testing this series on OMAP-L137, OMAP-L138 and DM365 EVMs and I found that on all these EVMS, Interrupt mode has problems. Driver works
fine in DMA and POLL modes. Some problems which I had observed with the
old driver are gone now.

Quoted 8 lines

Do you have any idea what errors you're seeing in interrupt mode? I went and retested interrupt mode with several devices on my custom board and it still appeared to be working fine. It may be an interaction with code outside the driver because I'm running the identical driver code but I'm not running the latest kernel from the davinci git repository. I'm trying to figure out if I can get my DA850 EVM back into a state where I can debug this. Thanks for any hints you can give!

You may be knowing that on OMAP-L138 EVM, we have M25P64 Flash on SPI. When the driver is configured in Interrupt mode, kernel booting just hangs. I noticed that the SPI probe function is not coming out of spi_bitbang_start() call.

Thanks,
Sudhakar

A message that is not in the archive (sent off-list or not yet received): 012801cb0c7a$4e1f5210$ea5df630$@[email protected]

#7 lore raw

RE: [spi-devel-general] [PATCH 0/3] davinci: spi: replace existingSPI driver

Quoted 27 lines · Brian Niebuhr
Quoted 6 lines
Quoted 6 lines
Quoted 1 line

I have compiled with the davinci_all_defconfig, but I don't

have EVMs

Quoted 2 lines

for the other davinci platforms to test with.

I was testing this series on OMAP-L137, OMAP-L138 and

DM365 EVMs and I

Quoted 8 lines
Quoted 5 lines

found that on all these EVMS, Interrupt mode has problems. Driver works
fine in DMA and POLL modes. Some problems which I had observed with the
old driver are gone now.

Do you have any idea what errors you're seeing in interrupt mode? I went and retested interrupt mode with several devices on my

custom board

Quoted 1 line

and it still appeared to be working fine. It may be an

interaction with

Quoted 1 line

code outside the driver because I'm running the identical

driver code

Quoted 1 line

but I'm not running the latest kernel from the davinci git

repository.

Quoted 3 lines

I'm trying to figure out if I can get my DA850 EVM back into a state where I can debug this. Thanks for any hints you can give!

Quoted 7 lines

You may be knowing that on OMAP-L138 EVM, we have M25P64 Flash on SPI. When
the driver is configured in Interrupt mode, kernel booting just hangs. I
noticed that the SPI probe function is not coming out of spi_bitbang_start()
call.

I configured the M25P64 on the DA850 EVM for both DMA and interrupt mode and my kernel still booted correctly. I wonder if your setting for intr_level is correct? For the DA850 it should be set to 1. I'm following up with a response to Nicolas showing the changes I made to the kernel to test this. Can you check if the changes you made match mine?

Thanks,

Brian

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): 004601cb0879$c25b75f0$471261d0$@[email protected]

#11 lore raw

RE: [PATCH 2/3] davinci: spi: add replacement SPI driver

Quoted 9 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/arch/arm/mach-davinci/include/mach/spi.h

Quoted 7 lines

index 910efbf..10c39d8 100644

arch/arm/mach-davinci/include/mach/spi.h +0 -0
@@ -19,26 +19,39 @@
 #ifndef __ARCH_ARM_DAVINCI_SPI_H
 #define __ARCH_ARM_DAVINCI_SPI_H
 
Quoted 12 lines

arch/arm/mach-davinci/include/mach/spi.h line 30

Quoted 10 lines
arch/arm/mach-davinci/include/mach/spi.h +8 -1
+#define SPI_INTERN_CS	0xFF
+
+/* resource flags for IORESOURCE_DMA resources */
+#define IORESOURCE_DMA_RX_CHAN		0x01
+#define IORESOURCE_DMA_TX_CHAN		0x02
+#define IORESOURCE_DMA_EVENT_Q		0x04
+
 enum {
-	SPI_VERSION_1, /* For DM355/DM365/DM6467 */
+	SPI_VERSION_1, /* For DM355/DM365/DM6467*/

Above line in the patch is not required.

Right.

Quoted 14 lines

arch/arm/mach-davinci/include/mach/spi.h line 34

Quoted 4 lines
arch/arm/mach-davinci/include/mach/spi.h +4 -0
+
+	davinci_spi->version = pdata->version;
+
+	davinci_spi->bitbang.flags = SPI_NO_CS | SPI_LSB_FIRST 

| SPI_LOOP;

arch/arm/mach-davinci/include/mach/spi.h line 38

Quoted 4 lines
arch/arm/mach-davinci/include/mach/spi.h +4 -0
+	if (davinci_spi->version == SPI_VERSION_2)
+		davinci_spi->bitbang.flags |= SPI_READY;
+
+	dma_rx_chan = davinci_spi_get_dma_by_flag(pdev, 

IORESOURCE_DMA_RX_CHAN);

arch/arm/mach-davinci/include/mach/spi.h line 39

Quoted 1 line
arch/arm/mach-davinci/include/mach/spi.h +1 -0
+	dma_tx_chan = davinci_spi_get_dma_by_flag(pdev, 

IORESOURCE_DMA_TX_CHAN);

arch/arm/mach-davinci/include/mach/spi.h line 40

Quoted 1 line
arch/arm/mach-davinci/include/mach/spi.h +1 -0
+	dma_eventq  = davinci_spi_get_dma_by_flag(pdev, 

IORESOURCE_DMA_EVENT_Q);

Quoted 8 lines

arch/arm/mach-davinci/include/mach/spi.h line 46

Quoted 6 lines
arch/arm/mach-davinci/include/mach/spi.h +6 -0
+	davinci_spi->dma_channels.dma_rx_channel = -1;
+	davinci_spi->dma_channels.dma_rx_sync_dev = dma_rx_chan;
+	davinci_spi->dma_channels.dma_tx_channel = -1;
+	davinci_spi->dma_channels.dma_tx_sync_dev = dma_tx_chan;
+	davinci_spi->dma_channels.dummy_param_slot = -1;
+	davinci_spi->dma_channels.eventq = dma_eventq;

Can the above configurations be done only in case if DMA mode?

DMA mode is selected on a per-device basis. This initialization is for the controller, so it needs to be prepared to handle DMA if a device uses it. If DMA is not required, no DMA resource need be assigned to the controller.

Quoted 2 lines

Some way of informing the user about the mode in which the driver is working is desirable.

Yes, I'll try to come up with something.

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): 004701cb087a$6cb51470$461f3d50$@[email protected]

#14 lore raw

RE: [PATCH 3/3] davinci: spi: modify platform data for updated SPIdriver

Quoted 19 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/arch/arm/mach-davinci/dm365.c

arch/arm/mach-davinci/dm365.c static u64 dm365_spi0_dma_mask =

Quoted 4 lines

index a146849..0bd9f93 100644

arch/arm/mach-davinci/dm365.c +0 -0
@@ -625,12 +625,6 @@ static u64 dm365_spi0_dma_mask = 

DMA_BIT_MASK(32);

arch/arm/mach-davinci/dm365.c static u64 dm365_spi0_dma_mask = · line 631

Quoted 7 lines
arch/arm/mach-davinci/dm365.c +0 -4
 static struct davinci_spi_platform_data dm365_spi0_pdata = {
 	.version 	= SPI_VERSION_1,
 	.num_chipselect = 2,
-	.clk_internal	= 1,
-	.cs_hold	= 1,
-	.intr_level	= 0,
-	.poll_mode	= 1,	/* 0 -> interrupt mode 1-> 

polling mode */

Quoted 4 lines
arch/arm/mach-davinci/dm365.c +0 -2
-	.c2tdelay	= 0,
-	.t2cdelay	= 0,
 };
 
Quoted 9 lines

arch/arm/mach-davinci/dm365.c static u64 dm365_spi0_dma_mask = · line 630

Quoted 1 line
arch/arm/mach-davinci/dm365.c +0 -0
 static struct resource dm365_spi0_resources[] = {

This patch does not contain modifications to resource structure to 'or' the
IORESOURCE_DMA_RX_CHAN, IORESOURCE_DMA_TX_CHAN and IORESOURCE_DMA_EVENT_Q
flags with IORESOURCE_DMA. I don't think without this modification driver
will work.

You are right - my mistake. I will include that in the next version. I assume you added these flags when you were testing?

A message that is not in the archive (sent off-list or not yet received): [email protected]

#16 lore raw
Quoted 3 lines

Can you please post this series to SPI development list (spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org) CCing the maintainers David Brownell and Grant Likely?

Done

Quoted 20 lines
Quoted 3 lines

INTRODUCTION

I have been working on a custom OMAP-L138 board that has

multiple spi

Quoted 1 line

devices (seven) on one controller. These devices have a

wide range of

Quoted 2 lines

transfer parameters (speed, phase, polarity, internal and gpio chip selects). During my testing I found multiple errors in the

davinci spi

Quoted 3 lines

driver as a result of this complex setup. The primary issues were:

1. There is a race condition due to the SPIBUF read

busy-waits for slow

Quoted 6 lines

devices
2. I found some DMA transfer length errors under some conditions
3. The chip select code caused extra byte transfers (with no chip select active) due to writes to SPIDAT1
4. Several issues prevented using multiple SPI devices, especially the DMA code, as disucussed previously on the davinci list.

Quoted 3 lines

This should be replicated in patch description for patch 1/3 as a record
of why the original driver was removed.

Will do.

Quoted 36 lines
Quoted 1 line

The fixes to these problems were not simple. I ended up

making fairly

Quoted 1 line

large changes to the driver, and those changes are

contained in these

Quoted 5 lines

patches. The full list of changes follows.

CHANGE LIST

1. davinci_spi_chipelect() now performs both activation and

deactivation

Quoted 4 lines

of chip selects. This lets spi_bitbang fully control chip select activation, as intended by the SPI API.
2. Chip select activation does not cause extra writes to the SPI bus
3. Chip select activation does not use SPIDEF for control.

This change

Quoted 7 lines

will also allow for implementation of inverted (active high) chip selects in the future.
4. Added back gpio chip select capability from the old driver
5. Fixed prescale calculation for non-integer fractions of spi clock
6. Allow specification of SPI transfer parameters on a per-device (instead of per-controller) basis
7. Allow specification of polled, interrupt-based, or DMA

operation on

Quoted 3 lines

a per-device basis
8. Allow DMA with when more than one device is connected
9. Combined pio and dma txrx_bufs functions into one since

they share

Quoted 1 line

large parts of their functionality, and to simplify

item (8).

Quoted 7 lines

10. Use only SPIFMT0 to allow more than 4 devices

TESTING

I have tested the driver using a custom SPI stress test on my OMAP-L138-based board with three devices connected. I have tested configurations with all three devices polled, all three

Quoted 6 lines

interrupt-based,

Quoted 1 line

all three DMA, and a mixture.

This should be replicated in patch description for patch 2/3 as a record
of what the new driver provides.

Will do.

Quoted 8 lines
Quoted 1 line

I have compiled with the davinci_all_defconfig, but I don't

have EVMs

Quoted 1 line

for the other davinci platforms to test with.

DM6467, DM365 and OMAP-L137 EVMs have SPI devices as well. We can help test on at least some of those. No need to wait for test results before
posting to SPI list though, it can happen in parallel to the review.

Ok, thanks.

Quoted 7 lines
Quoted 3 lines

SUMMARY

This patch solves a lot of issues that should save a lot of

people time

Quoted 1 line

down the road. Since I posted the original patch I have

had at least 5

Quoted 1 line

people contact me personally to get help applying the patch

Quoted 8 lines

because SPI

Quoted 1 line

was broken on their boards. I have heard back from at

least 2 that the

Quoted 1 line

original patch worked for them.

You can include an Acked-by: from those developers. This will help build
the case for the new driver.

I'll see if I still have the emails.

A message that is not in the archive (sent off-list or not yet received): BA34378D1528D04CB3C865B8BAB2472B024CCA-mqUZVEcnZosHtCCSzi1I5PfQPhDVBs+grNQQ6b5fDX0@public.gmane.org

#18 lore raw
Quoted 5 lines · Brian Niebuhr
Quoted 3 lines

Can you please post this series to SPI development list (spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org) CCing the maintainers David Brownell and Grant Likely?

Done

I had to go looking for these patches. I see that you sent them to spi-devel-general, but you should also cc: maintainers explicitly. Maintainers get a *lot* of email. If you don't cc: me, then the chances are much greater that I won't see your patches in a timely manner. I only saw this one because my name was in the body text which my filters picked up on.

g.

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo