Dear 1. SPI_REG、SPIPC0 are defined myself. like below #define SPI_BASE_ADDR IO_ADDRESS(DAVINCI_SPI_BASE) #define SPI_REG(reg) (*((volatile unsigned long *)(SPI_BASE_ADDR + (reg))))
#define SPIGCR0 0x00 2. This is an actual linux char driver. I just wrote a simple driver to control a simple device. Best Regards, Sean On Dec 19, 2007 12:55 AM, Joshua Hintze <[EMAIL PROTECTED]> wrote: > Sean, > > > > Thanks for sending this. One thing that I'm not really sure of is the > macros or functions SPI_REG. Where were these defined? Also the registers > SPIPC0 and others. Did you define all of these yourself? > > > > Also this might seem like a stupid question but is this an actual linux > character driver or is this code that you wrote in code composer studio for > the DSP? > > > > Thanks, I plan on getting something going and giving back to the community > since I tried searching the archives and I could not find anything other > than other peoples questions. > > > > Josh > > > > *From:* Sean [mailto:[EMAIL PROTECTED] > *Sent:* Tuesday, December 18, 2007 1:34 AM > *To:* Joshua Hintze; davinci-linux-open-source@linux.davincidsp.com > *Subject:* Re: SPI on Davinci. > > > > Dear Joshua > > OK, I give you a simple program segment. > > You need to see the document about SPI of DM644x. > ========================================== > // -------------------------------- > // Reset SPI > // -------------------------------- > control=0x00000000; > SPI_REG(SPIGCR0)=control; > mdelay(1); > control=0x00000001; > SPI_REG(SPIGCR0)=control; > > // -------------------------------- > // Enable SPI CLK & Master > // -------------------------------- > control=0x00000003; > SPI_REG(SPIGCR1)=control; > > // -------------------------------- > // Enable pins : DI、DO、CLK、EN0 > // -------------------------------- > control=0x00000FFF; > SPI_REG(SPIPC0)=control; > > /* -------------------------------- > // Set data format in SPIFMT0 > // SHIFTDIR in bit 20 set to 1 : LSB > // POLARITY and PHASE in bit 17, 16 set to 0, 1 > // PRESCALE in bit 15-8 set to 0, SPI_CLK = SYSCLK5 / (Prescale + > 1) > // CHARLEN in bit 4-0 set to 08 : 8 bit > -------------------------------- */ > control=0x0012FF08; > SPI_REG(SPIFMT0)=control; > > // -------------------------------- > // Set data format for used -> SPIFMT0 > // -------------------------------- > control=0x00000000 | 0x00 << 24; > SPI_REG(SPIDAT1)=control; > > // -------------------------------- > // Set hold time and setup time > // -------------------------------- > control=0x0000 | 0x03 << 16 | 0x02 << 24; > SPI_REG(SPIDELAY)=control; > > // -------------------------------- > // Out of reset for SPI > // -------------------------------- > control=0x00000001; > SPI_REG(SPIGCR0)=control; > > // -------------------------------- > // Set Chip Select Default > // CSHOLD -> 1 -> hold SPI_EN0 state -> bit 28 > // CSNR -> 3 -> disable all > // -------------------------------- > control=SPI_REG(SPIDAT1); > control|=0x3 << 16; > SPI_REG(SPIDAT1)=control; > > // -------------------------------- > // Enable for transforing > // -------------------------------- > control=SPI_REG(SPIGCR1); > control=control | 1 << 24; // enable SPIENA > SPI_REG(SPIGCR1)=control; > > ============================================= > Send data > > control=csnr << 16 | cshold << 28; > control|=buf; > SPI_REG(SPIDAT1)=control; > > Read data > control=SPI_REG(SPIBUF); > MSG("SPIBUF = %08X",control); > if(control & (1 << 31)) > MSG("!! No Data received "); > else{ > while(1){ > control=SPI_REG(SPIBUF); > if(control & (1 << 29)) > continue; > else > break; > MSG("wait for data receive ..."); > } > MSG("receive data : %04X", (control & 0xFFFF)); > } > ================================ > > just for reference. > If it has any questions, please let me know , and help me to fix them. > > Best Regards, > Sean > > On Dec 18, 2007 11:52 AM, Joshua Hintze <[EMAIL PROTECTED]> wrote: > > Thanks Sean, > > > > Do you still have the code that I might take a look at? > > > > Josh > > > > > On Dec 17, 2007, at 8:45 PM, Sean < [EMAIL PROTECTED]> wrote: > > Dear > > I write the SPI driver by myself. Just to write the corresponding > registers. > There is no interface driver about SPI, I felt so sad too. > > Best Regards, > Sean > > On Dec 18, 2007 2:09 AM, Joshua Hintze < [EMAIL PROTECTED]> wrote: > > Since nobody answered yet, I'm curious has anybody done SPI interfacing on > the Davinci? > > > > Thanks, > > > > Josh > > > > > > > --------------------------------------------------------------------------------------- > > Hey guys, > > > > Have any of you interfaced to the SPI port on the Davinci 6446. I got the > i2c working pretty easy using the i2c-dev character driver but there is no > such thing as spidev until linux kernel 2.6.22. > > > > > > So I'm wondering how others are doing it. Are you writing your own kernel > drivers or is there still a way to do it from user space? > > > > Thanks in advance, > > > > Josh > > > _______________________________________________ > Davinci-linux-open-source mailing list > Davinci-linux-open-source@linux.davincidsp.com > http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source > > > > >
_______________________________________________ Davinci-linux-open-source mailing list Davinci-linux-open-source@linux.davincidsp.com http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source