2008-05-07 11:22:01     SPI not working for Audio EZ-Extender (AD1938) and BF548 EZ-Kit

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

2008-05-07 11:22:01     SPI not working for Audio EZ-Extender (AD1938) and BF548 EZ-Kit

Norbert van Bolhuis (NETHERLANDS)

Message: 55612   

 

I need help getting SPI working with the Audio EZ-Extender daughter board

on a BF548 EZ-Kit.

 

Since there's no uClinux driver for the AD1938 nor for the

BF548 EZ-Kit + AD1[89]xx codec I did the following:

 

I enabled the AD1836 drivers, knowing they should at minimum be able

to read (via) SPI some of the AD1938 registers.

 

I put this into arch/blackfin/mach-bf548/boards/ezkit.c:

#if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)

static struct bfin5xx_spi_chip ad1836_spi_chip_info = {

        .enable_dma = 0,

        .bits_per_word = 16,

};

#endif

#if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)

        {

                .modalias = "ad1836-spi",

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

                .bus_num = 0,

                .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,

                .controller_data = &ad1836_spi_chip_info,

        },

#endif

 

Note that CONFIG_SND_BLACKFIN_SPI_PFBIT=3 (=SPI0SEL3=PE6)

 

On the Audio Extender board I closed jumper JP1.1/2 (select BF537 EZ-Kit SPI

expansion interface pinning).

 

My problem is that SPI isn't working. 0xff is always read (temp=0xffff in snd_ad1836_configure)

 

I wonder if I forget/overlooked something, did anyone get this working ?

 

I tried several other things, such as using spidev user space program to

read (on /dev/spidev0.3) but 0xff is always returned.

 

QuoteReplyEditDelete

 

 

2008-05-08 00:09:15     Re: SPI not working for Audio EZ-Extender (AD1938) and BF548 EZ-Kit

Sonic Zhang (CHINA)

Message: 55620   

 

There is a Linux ad1980 sound driver for BF548 EZ-Kit board.

 

 

QuoteReplyEditDelete

 

 

2008-05-13 04:53:38     Re: SPI not working for Audio EZ-Extender (AD1938) and BF548 EZ-Kit

Norbert van Bolhuis (NETHERLANDS)

Message: 55777   

 

 

The AD1980 doesn't use SPI. The AD1980 registers are manipulated

via SPORT.

 

My problem is that the AD1938 transfers 24-bit SPI words which

the BlackFin SPI driver does not support. Only 8-bit or 16-bit

transfers are supported (this was already pointed out almost one

year ago in this forum).

 

Doing 3 times 8-bit words in a row can be done, but it didn't work

for me since (if SPI_CPHA = 0) the SPI HW toggles SPI_SELECT for

every transferred 8-bit word.

If SPI_CPHA=1 one would be able to control SPI_SELECT with the FLGx

field of (SPI_FLAG register). I tried this, but it didn't work for

the AD1938 either.

 

In the end I manually drive SPI0SEL3 (PE6) by making it a GPIO

(PE6_FER=0). This way SPI0SEL3 stays low (active) and doesn't toggle

during the entire 3x8=24-bit SPI transfer (SPI_CTL=0x5001).

I still use the BlackFin SPI framework/driver though, so I

put this into the BlackFin SPI driver that I'm using.

 

In general it maybe good if the standard BlackFin SPI framework/driver

could add an option to make sure of this behaviour (although I'm not sure

how many SPI controlled chips are out there that don't do 8 or 16 bit

SPI words).

I can make available some patches if need be.

 

 

QuoteReplyEditDelete

 

 

2008-05-13 09:39:16     Re: SPI not working for Audio EZ-Extender (AD1938) and BF548 EZ-Kit

Mike Frysinger (UNITED STATES)

Message: 55781   

 

you already can control the cs behavior ... please consult the documentation:

http://docs.blackfin.uclinux.org/doku.php?id=spi

QuoteReplyEditDelete

 

 

2008-05-14 03:39:49     Re: SPI not working for Audio EZ-Extender (AD1938) and BF548 EZ-Kit

Norbert van Bolhuis (NETHERLANDS)

Message: 55799   

 

The available chip_select "customizations" do not suffice for AD1938 type of

SPI chips.

 

(struct spi_transfer).cs_change allows to deactivate the chip_select after

one SPI transfer of n words (normally it stays active).

 

(struct chip_data).cs_change_per_word allows to activate/deactivate

the chip_select for each transferred word (i.s.o. keeping it active during

the entire transfer of multiple words).

 

However, from "ADSP-BF54x Blackfin® Processor Peripheral Hardware Reference" page 9-47:

If CPHA = 0, the SPI hardware sets the output value and the FLGx

bits are ignored. The SPI protocol requires that the slave select be

deasserted between transferred words. In this case, the SPI hardware

controls the pins.

 

Since only 8 or 16 bit words can be transferred, 3 x 8 bits must be transferred

to "simulate" the 24 bit word the AD1938 requires.

 

My problem is the deassertion (= make chip_select high) between transferred words,

therefore I manually drive the SPI chip_select (SPI0SEL3) to make sure it remains

asserted (low) during the transfer of 3 8-bit words.

Attachments

    Outcomes