MOD-ENC28J60 and Linux (Debian/GNU)

Started by leo, December 03, 2012, 05:43:03 PM

Previous topic - Next topic

vinifr

Dont worry, this happens when I use my spi_sunxi.c version. with the original version works perfectly.

http://dl.dropbox.com/u/22273442/A13/spi_sunxi.c

huppyuy

you guys are so cool!! It make me cry!! :'(

huppyuy

I use your V3 patch in linux-sunxi-3.4.Kernel version is 3.4.90.
And I changed <mach/sys_config.h> to <plat/sys.config.h> because file is missing.
I also changed ndo_set_multicast_list to ndo_set_rx_mode because of the changing of kernel source.

When I am using ,I can dhclient but there are lots of logs like "drivers/spi/spi_sunxi.c(L583) unknow dma direction = 0".
Is that matters?

vinifr

#78
I think this patch is no longer necessary, spi_sunxi driver have already support to communication full duplex.

Did you test mod-enc28j60 without patch?

jo

Quote from: vinifr on August 11, 2014, 04:42:32 PM
I think this patch is no longer necessary, spi_sunxi driver have already support to communication full duplex.

Did you test mod-enc28j60 without patch?

I've tested mod-enc28j60 without the patch with an A13 board, but it doesn't work.


[spi_devices]
spi_dev_num = 1

[spi_board0]
modalias = "enc28j60"
max_speed_hz = 12000000
chip_select = 0
bus_num = 2
mode = 0
irq_gpio = 2
full_duplex = 0

[gpio_para]
gpio_used = 1
gpio_num = 14
gpio_pin_1 = port:PB03<1><default><default><default>
; PB04 is used in section [spi_board0]
gpio_pin_2 = port:PB04<6><default><default><default>
gpio_pin_3 = port:PB10<1><default><default><default>
...



[    0.137417] [spi]: 0          enc28j60         12000000         0        0    0x0
[    3.207358] enc28j60 spi2.0: enc28j60 Ethernet driver 1.01 loaded
[    3.212264] enc28j60 spi2.0: enc28j60 enc28j60 spi_irq param load successfully.
[    3.212293] enc28j60 spi2.0: enc28j60 enc28j60_probe, gpio_addr = 0xf1c20800.
[    3.212308] enc28j60 spi2.0: enc28j60 enc28j60_probe, 1710: gpio_int_info, port = 2, port_num = 4.
[    3.212318] enc28j60 spi2.0: enc28j60 ENC28J60 interrupt configuration
[    3.215980] net eth0: enc28j60 driver registered
[    3.494509] register rtw_netdev_ops to netdev_ops
[    8.141056] net eth0: link down
[    8.141098] net eth0: normal mode
[    8.141111] net eth0: normal mode
[    8.141149] net eth0: multicast mode


But it doesn't detects the cable.


# ip l l eth0
3: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT qlen 1000
    link/ether 00:1e:4e:06:00:ee brd ff:ff:ff:ff:ff:ff

vinifr

#80
hi Jo,

You have to configure [spi_board0] and [spi2] too:
spi2_para]
spi_used = 1
spi_cs_bitmap = 3
spi_cs0 = port:PE00<4><default><default><default>
spi_cs1 = port:PB10<2><default><default><default>
spi_sclk = port:PE01<4><default><default><default>
spi_mosi = port:PE02<4><default><default><default>
spi_miso = port:PE03<4><default><default><default>

[spi_board0]
modalias = "enc28j60"
max_speed_hz = 20000000
chip_select = 0
bus_num = 2
mode = 0
spi_irq = port:PB04<6><default><default><default>
And change csi_used = 1 to csi_used = 0

If all work well, you shold see:

[    0.190000] [spi]: sw spi init !!
[    0.190000] [spi]: sw spi init fetch spi0 uning configuration failed
[    0.190000] [spi]: Found 1 spi devices in config files
[    0.190000] [spi]: boards num modalias         max_spd_hz       bus_num  cs   mode
[    0.190000] [spi]: 0          enc28j60         10000000         2        0    0x0   
[    0.190000] [spi]: bus num = 2, spi used = 3
[    0.190000] [spi]: source = sdram_pll_p, src_clk = 408000000, mclk 102000000
[    0.190000] [spi]: allwinners SoC SPI Driver loaded for Bus SPI-2 with 1 Slaves attached
[    0.190000] [spi]: [spi-2]: driver probe succeed, base dc8aa000, irq 12, dma_id 2!
[    2.870000] enc28j60 spi2.0: enc28j60 Ethernet driver 1.01 loaded
[    3.070000] enc28j60 spi2.0: enc28j60 enc28j60 spi_irq param load successfully.
[    3.070000] enc28j60 spi2.0: enc28j60 enc28j60_probe, gpio_addr = 0xdc92a800.
[    3.250000] enc28j60 spi2.0: enc28j60 enc28j60_probe, 1713: gpio_int_info, port = 2, port_num = 4.
[    3.310000] enc28j60 spi2.0: enc28j60 ENC28J60 interrupt configuration
[    3.310000] enc28j60 spi2.0: enc28j60 driver registered

[   19.790000] net eth0: link down
[   19.790000] net eth0: normal mode
[   19.790000] net eth0: normal mode
[   19.810000] net eth0: multicast mode
[  136.130000] net eth1: link up - Half duplex

if this message show up, net eth1: link up - Half duplex, means works!

jo

Quote from: vinifr on December 03, 2014, 01:27:06 AM

[spi_board0]
modalias = "enc28j60"
max_speed_hz = 20000000
chip_select = 0
bus_num = 2
mode = 0
spi_irq = port:PB04<6><default><default><default>
And change csi_used = 1 to csi_used = 0

[/code]
if this message show up, net eth1: link up - Half duplex, means works!

My spi2_para section looks like yours. So, this is fine. But I'm trying to get the interface working without the patch as you've said on August 11, 2014. I've took the branch sunxi-3.4 from the sunxi repository and tried to get it working. But it doesn't.

With the patched enc28j60 driver it works. Hence, the hardware is but. But there has to be something else missing in the code. At least, I found that using IRQF_TRIGGER_FALLING makes the interface detects the cable and gets set up. But I can't send/receive data. I get the kernel message drivers/spi/spi_sunxi.c(L583) unknow dma direction = 0, but I don't know where DMA gets configured or disabled.

vinifr

#82
hi,

There may be a conflict between the patch and new sunxi_spi.c. I'm not sure. :-[

Quotebut I don't know where DMA gets configured or disabled.

Configure the kernel using:
make ARCH=arm menuconfig
https://www.youtube.com/watch?v=ilDhOzmkORY

jo

Quote from: vinifr on December 05, 2014, 01:57:46 AM
hi,

There may be a conflict between the patch and new sunxi_spi.c. I'm not sure. :-[

Quotebut I don't know where DMA gets configured or disabled.

Configure the kernel using:
make ARCH=arm menuconfig
https://www.youtube.com/watch?v=ilDhOzmkORY

Yes, there's a conflict, because both want to use the same interrupt, but the patched enc28j60 uses TRIGGER_FAILING and sunxi_spi doesn't not, which makes the IRQ unsharable.

Isn't there anything in the script.fex to adapt for DMA?

jo

For the record, I could prevent the message drivers/spi/spi_sunxi.c(L583) unknow dma direction = 0 by removing the kernel option CONFIG_SPI_SUNXI_NDMA. The network works fine (with patched enc28j60).

vinifr

Good!  ;D
QuoteIsn't there anything in the script.fex to adapt for DMA?
There is not nothing in script.fex about DMA. As you said, removing kernel option CONFIG_SPI_SUNXI_NDMA is a solution.

We could also adapt the patch to work with DMA.

jo

Quote from: vinifr on December 06, 2014, 09:03:38 PM
Good!  ;D
QuoteIsn't there anything in the script.fex to adapt for DMA?
There is not nothing in script.fex about DMA. As you said, removing kernel option CONFIG_SPI_SUNXI_NDMA is a solution.

We could also adapt the patch to work with DMA.

As far as I understand the description of the kernel option, this doesn't remove DMA, but switches to a different form of DMA: DDMA => NDMA.

This selects SPI DMA mode with DMA transfer
Y select NDMA mode and N select DDMA mode


In the meantime, I saw that disabling this option causes these warnings:

[spi]: drivers/spi/spi_sunxi.c(L1025) cpu tx data time out!
[spi]: drivers/spi/spi_sunxi.c(L1025) cpu tx data time out!
------------[ cut here ]------------
WARNING: at net/sched/sch_generic.c:256 dev_watchdog+0x2c4/0x2d0()
NETDEV WATCHDOG: eth0 (enc28j60): transmit queue 0 timed out
Modules linked in: 8192cu(O) mali_drm mali disp_ump ump sun4i_ts enc28j60 [last unloaded: 8192cu]
[<c0012ac8>] (unwind_backtrace+0x0/0xec) from [<c00277ec>] (warn_slowpath_common+0x54/0x64)
[<c00277ec>] (warn_slowpath_common+0x54/0x64) from [<c002782c>] (warn_slowpath_fmt+0x30/0x40)
[<c002782c>] (warn_slowpath_fmt+0x30/0x40) from [<c02eefc4>] (dev_watchdog+0x2c4/0x2d0)
[<c02eefc4>] (dev_watchdog+0x2c4/0x2d0) from [<c0032c24>] (run_timer_softirq+0xec/0x27c)
[<c0032c24>] (run_timer_softirq+0xec/0x27c) from [<c002d2a0>] (__do_softirq+0xa4/0x134)
[<c002d2a0>] (__do_softirq+0xa4/0x134) from [<c002d730>] (irq_exit+0x60/0x64)
[<c002d730>] (irq_exit+0x60/0x64) from [<c000e8f8>] (handle_IRQ+0x3c/0x84)
[<c000e8f8>] (handle_IRQ+0x3c/0x84) from [<c000db34>] (__irq_svc+0x34/0x118)
[<c000db34>] (__irq_svc+0x34/0x118) from [<c000ea7c>] (default_idle+0x2c/0x30)
[<c000ea7c>] (default_idle+0x2c/0x30) from [<c000ecd4>] (cpu_idle+0x80/0xc4)
[<c000ecd4>] (cpu_idle+0x80/0xc4) from [<c045977c>] (start_kernel+0x2ac/0x2b8)
---[ end trace e6000e6a48c09caa ]---


They happen much more seldom than unknow dma direction = 0, but they don't sound fine, too.

Do you have any idea how to get rid of one or both of these messages? Is it difficult to get NDMA support?

vinifr

Sorry, my knowledge about DMA is scarce.  :-[

Mr.D

Hi Guys ,

Did You manage to get this thing finally working well ?

Regards

vinifr

Hi Mr.D,

You should try mainline sunxi kernel: https://linux-sunxi.org/Mainline_Kernel_Howto I'm pretty sure that using mainline kernel works!