sunxi full duplex spi driver

107 views
Skip to first unread message

Gnichi Mohamed

unread,
Oct 23, 2014, 4:46:42 PM10/23/14
to linux...@googlegroups.com
Hello
I can see that there is a half duplex implementation for the SPI controller driver in linux-sunxi.
Is this fixed or it will be fixed?
I tried the patches in https://groups.google.com/forum/#!topic/linux-sunxi/yEmBiaJ3LAI
The cpu timout warning disapeard but it seems that the communication is completely wrong.
I am testing with mcp3008 with no luck at all
Please help

Gnichi Mohamed

unread,
Oct 24, 2014, 4:04:09 AM10/24/14
to linux...@googlegroups.com
I made a cooking of patches in case any one needs it. Mo


513,519d512
< /* keep unused burst */
< void spi_clear_dhb(void *base_addr)
< {
<         u32 reg_val = readl(base_addr + SPI_CTL_REG);
<         reg_val &= ~SPI_CTL_DHB;
<         writel(reg_val, base_addr + SPI_CTL_REG);
< }
591a585
>     aw_spi_sel_dma_type(0, aw_spi->base_addr);
617c611,612
<     spin_unlock_irqrestore(&aw_spi->lock, flags);
---
>     aw_spi_sel_dma_type(0, aw_spi->base_addr);
>     spin_unlock_irqrestore(&aw_spi->lock, flags);
958,960c953,956
<     #else
<                aw_spi_sel_dma_type(1, base_addr);
<     #endif
---
>         aw_spi_sel_dma_type(0, base_addr);
>         #else
>         aw_spi_sel_dma_type(1, base_addr);
>         #endif
1008,1009c1004
<         unsigned int poll_time_rx = 0x7ffff;
<                 unsigned int poll_time_tx = 0xfffff;
---
>         unsigned int poll_time = 0xfffff;
1016,1022c1011
<         aw_spi_start_xfer(base_addr);
<                 if (tx_len) {
<                         while ( aw_spi_query_txfifo(base_addr) && (--poll_time_tx > 0) ); //txFIFO counter
<                         if ( poll_time_tx <= 0 ) {
<                                 spi_wrn("cpu tx data time out!\n");
<                         }
<                 }
---
>         aw_spi_start_xfer(base_addr);
1024c1013
<             while(rx_len && (--poll_time_rx >0)) {
---
>             while(rx_len && (--poll_time >0)) {
1026,1032c1015,1019
<                    if (aw_spi_query_rxfifo(base_addr)) {
<                                         *rx_buf++ =  readb(base_addr + SPI_RXDATA_REG); //fetch data
<                                        --rx_len;
<                                 }
<                                 if ( poll_time_rx <= 0 ) {
<                                         spi_wrn("cpu rx data time out!\n");
<                                }
---
>                 if(aw_spi_query_rxfifo(base_addr)){
>                     *rx_buf++ =  readb(base_addr + SPI_RXDATA_REG);//fetch data
>                     --rx_len;
>                     poll_time = 0xffff;
>                 }
1034c1021,1025
<        
---
>         } else {
>             while(aw_spi_query_txfifo(base_addr)&&(--poll_time > 0) );/* txFIFO counter */
>         }
>         if(poll_time <= 0) {
>             spi_wrn("cpu tx data time out!\n");
1093,1096d1083
<                                     /* full duplex mode */
<                         if (t->rx_buf && t->tx_buf)
<                         spi_clear_dhb(aw_spi->base_addr);
<


Henrik Nordström

unread,
Oct 25, 2014, 4:19:15 AM10/25/14
to linux...@googlegroups.com
Can you please resend this as a unified diff? (diff -u)
> --
> You received this message because you are subscribed to the Google
> Groups "linux-sunxi" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to linux-sunxi...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


Gnichi Mohamed

unread,
Oct 25, 2014, 4:52:00 AM10/25/14
to linux...@googlegroups.com
This is the patch that i gathered from the discussion. I tested it with mcp3008 adc full duplex communication and it works as a charm.


You received this message because you are subscribed to a topic in the Google Groups "linux-sunxi" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/linux-sunxi/RpjSIJNJjTM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to linux-sunxi...@googlegroups.com.
patchspi

Henrik Nordström

unread,
Oct 25, 2014, 12:10:19 PM10/25/14
to linux...@googlegroups.com
Can you please resend the patch as a unified diff (diff -u oldfile
newfile). Patches in ed format is not can not be applied or reviewed.

Henrik Nordström

unread,
Oct 25, 2014, 12:15:54 PM10/25/14
to linux...@googlegroups.com
Ah, sorry! didn't notice the attachment. Thanks!

Regards
Henrik

Gnichi Mohamed

unread,
Oct 25, 2014, 12:18:40 PM10/25/14
to linux...@googlegroups.com

Yes, now with this patch, full duplex communication is possible. There is a need to update the spidev sunxi wiki.

Regards

Henrik Nordström

unread,
Oct 26, 2014, 5:33:25 AM10/26/14
to linux...@googlegroups.com
lör 2014-10-25 klockan 09:51 +0100 skrev Gnichi Mohamed:
> This is the patch that i gathered from the discussion. I tested it
> with mcp3008 adc full duplex communication and it works as a charm.

Do I read the patch correctly that DMA is not supported?

Regards
Henrik


Gnichi Mohamed

unread,
Oct 26, 2014, 6:01:49 AM10/26/14
to linux...@googlegroups.com

Hi Henrik
I really dont know what you are asking about.
All i did is gathering the patch posted in the forum

Reply all
Reply to author
Forward
0 new messages