2010-03-06 06:21:19     Netscope: Trouble with bfin_spi_adc

Document created by Aaronwu Employee on Aug 20, 2013
Version 1Show Document
  • View in full screen mode

2010-03-06 06:21:19     Netscope: Trouble with bfin_spi_adc

Ashish Gupta (INDIA)

Message: 86912   

 

Hi,

 

I am bringing up the network scope app for our BF527 based platform, I am having problems with getting the bfin_spi_adc driver to work first.

 

As soon as add support for the 'bfin_spi_adc ' driver under char drivers in the kernel config and also add the following entries in my platform file:

 

#if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)

// SPI ADC chip

static struct bfin5xx_spi_chip spi_adc_chip_info = {

    .enable_dma = 1,         // use dma transfer with this chip

    .bits_per_word = 16,

};

#endif

 

Also added following entry in: static struct spi_board_info bfin_spi_board_info[ ] __initdata

 

#if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)

    {

        .modalias = "bfin_spi_adc", // Name of spi_driver for this device

        .max_speed_hz = 10000000,     // max spi clock (SCK) speed in HZ

        .bus_num = 0, // Framework bus number

        .chip_select = 3, // Framework chip select.

        .platform_data = NULL, // No spi_driver specific config

        .controller_data = &spi_adc_chip_info,

    },

#endif

 

The build completes successfully but the kernel crashes at boot time. I've attached the complete platform file and the screen dump of the crash. Any ideas what I am doing wrong?

 

platformfile.c

dump.txt

QuoteReplyEditDelete

 

 

2010-03-06 22:34:34     Re: Netscope: Trouble with bfin_spi_adc

Mike Frysinger (UNITED STATES)

Message: 86914   

 

dont enable dma or try 2009R1.1.  crash seems to be in the spi bus driver due to enabling dma.

QuoteReplyEditDelete

 

 

2010-03-16 14:09:59     Re: Netscope: Trouble with bfin_spi_adc

Ashish Gupta (INDIA)

Message: 87278   

 

Hi,

 

I've disabled the dma and kernel crash issue was solved. Next, I tried the ndso application, first without connecting the ADC and it works fine.

 

I can open a web browser on a PC connected in LAN to my platform and see the Netscope application webpage. I am able to configure the settings and I saw the SPICLK being correctly generated (16 cycle bursts) when I hit "Acquire/Multimeter/Show samples" etc.

 

Now when I connect the ADC (MISO, SCK and SPI Slave Select), I only get zeros as the collected data. I checked the MISO line and it remains low during the SPICLK cycles. Then I checked the SPI SLAVE SELECT signal, which should go high in between each sample as the AD7476 conversion cycle starts with negative edge of Slave Select. This was not happening.

 

So the problem is that the slave select is not correctly getting pulsed between each sample acquisition. I also enabled the "cs_change_per_word" option in the following structure of the platform file.

 

#if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)

// SPI ADC chip

static struct bfin5xx_spi_chip spi_adc_chip_info = {

//    .enable_dma = 1,         // use dma transfer with this chip //@@AG

    .enable_dma = 0,

    .bits_per_word = 16,

    .cs_change_per_word = 1,    //@@AG

 

But I don't get the desired waveform. Attached is waveform sample with yellow signal bring SPI SCK and blue one being SPI Slave Select. This was captured by setting sps = 1000; samples = 1000; no triggering.

 

Note: We've modified the spi_bfin5xx.c (see attached file line#200) driver to allow us to use 3 GPIO pins generate 7 slave select lines using a 3:8 decoder. It has been working fine for AD7879 touchscreen driver, sdcard card driver, and ADI EZ LCD extender driver.

 

Enclosed:

 

1. "tllc6527m.c", our platform file

 

2. "spi_bfin5xx.c" - spi platform driver for blackfin modified to use 3 gpios to generate 7 spi slave selects.

 

3. Waveforms captured depicting SPI Slave select line (blue) mapped with bfin_spi_adc driver and spi sck line (yellow).

 

Any ideas?

 

Regards

 

Ashish

 

 

 

tll6527m.c

spi_bfin5xx.c

ndso_waveforms.zip

QuoteReplyEditDelete

 

 

2010-03-16 15:58:11     Re: Netscope: Trouble with bfin_spi_adc

Michael Hennerich (GERMANY)

Message: 87289    Ashish,

 

Tested the ndso + spi_adc driver last week on the 20091 branch and it was working for me without issues.

I take some time tomorrow to look at your attachments - to see what might be causing your issues.

 

-Michael

QuoteReplyEditDelete

 

 

2010-03-17 10:17:08     Re: Netscope: Trouble with bfin_spi_adc

Michael Hennerich (GERMANY)

Message: 87329    I've tested the bfin_spi_adc driver on trunk and 2009R1.

Using two different platforms BF527-EZKIT and BF537-STAMP.

It works absolutely ok - the crash you are observing in DMA mode - I don't see.

 

I tried to root cause the crash you are observing - and I think it's due to the fact that you use the platform file from a trunk kernel on the 2009R1 kernel.

static struct resource bfin_spi0_resource[] on the 2009R1 release doesn't include the second IORESOURCE_IRQ.

 

Regarding your other issues:

 

It's pretty simple, the SPI ADC depends on SPI_SSEL going inactive between each sample.

It therefore depends on SPI_MODE_0 in DMA mode, because the SPI peripheral itself toggles the SPISSEL.

 

But your modified spi driver doesn't use the Blackfin SPISSEL logic at all.

Therefore SPISSEL doesn't toggle between transfers.

If you need such behavior - you must qualify your multiplexed SSEL with at least one real SPISSEL.

 

 

From your modified driver:

/* Chip select operation functions for cs_change flag */

static void bfin_spi_cs_active(struct driver_data *drv_data, struct chip_data *chip)

{

#ifndef CONFIG_BFIN527_TLL6527M

if (likely(chip->chip_select_num)) {

u16 flag = read_FLAG(drv_data);

 

flag |= chip->flag;

flag &= ~(chip->flag << 8);

 

write_FLAG(drv_data, flag);

} else {

gpio_set_value(chip->cs_gpio, 0);

}

#else

switch (chip->chip_select_num) {

case 1:

gpio_set_value(GPIO_PH10, 0);

gpio_set_value(GPIO_PH9, 0);

gpio_set_value(GPIO_PG1, 1);

break;

case 2:

gpio_set_value(GPIO_PH10, 0);

gpio_set_value(GPIO_PH9, 1);

gpio_set_value(GPIO_PG1, 0);

break;

case 3:

gpio_set_value(GPIO_PH10, 0);

gpio_set_value(GPIO_PH9, 1);

gpio_set_value(GPIO_PG1, 1);

 

 

Tested also the cs_change_per_word option in none-DMA mode using following configuration.

It works too.

 

#if defined(CONFIG_BFIN_SPI_ADC) \

|| defined(CONFIG_BFIN_SPI_ADC_MODULE)

/* SPI ADC chip */

static struct bfin5xx_spi_chip spi_adc_chip_info = {

.enable_dma = 0, /* use dma transfer with this chip*/

.bits_per_word = 16,

.cs_change_per_word = 1,

};

#endif

 

#if defined(CONFIG_BFIN_SPI_ADC) \

|| defined(CONFIG_BFIN_SPI_ADC_MODULE)

{

.modalias = "bfin_spi_adc", /* Name of spi_driver for this device */

.max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */

.bus_num = 0, /* Framework bus number */

.chip_select = 2, /* Framework chip select. */

.platform_data = NULL, /* No spi_driver specific config */

.controller_data = &spi_adc_chip_info,

.mode = SPI_MODE_3,

},

#endif

 

-Michael

QuoteReplyEditDelete

 

 

2010-03-30 07:50:12     Re: Netscope: Trouble with bfin_spi_adc

Ashish Gupta (INDIA)

Message: 87853   

 

Thanks Michael,

 

Well, there are 7 spi peripherals on our board and since BF527 has such a high pin multiplexing we could not reserve real SPISELs. So our hardware depends on the multiplexed Slave selects only. So guess i can't use the DMA mode at all in this case.

 

Currently i am trying to get the non DMA mode with cs_change_per_word setting to work. It is strange why it doesn't work for me. I will investigate further and double check my settings.

 

One more thing, I checked out the trunk version of the spi_bfin5xx.c driver (currently i am using 2009R1 distro). It does not seem to support the cs_change_per_word mechanism.

 

Does that mean that one can't interface to AD7476 like spi devices which need cs deassert - assert between each word transfer without using the DMA mode? Which implies that we must have a real SPISEL otherwise we can't use the latest trunk version.?

QuoteReplyEditDelete

 

 

2010-03-30 15:13:01     Re: Netscope: Trouble with bfin_spi_adc

Robin Getz (UNITED STATES)

Message: 87864   

 

Ashish:

 

Yes - the assumption for that driver is that you are streaming data - you can't do that with DMA and an external (GPIO off a bus expander).

 

-Robin

Outcomes