ENC28J60 irq_gpio error

Started by gunebakan, August 18, 2016, 05:36:59 PM

Previous topic - Next topic

gunebakan

Hi,
I want use enc28j60 ic with A20 som module.I build my circuit like as MOD-ENC28J60 module.I compiled kernel with enc28j60 and sun7i-spi modules.

I get these error.gpio_request return -22 error and enc28j60 chip not found.I think chip not found because of the interrupt error.Anybody can help ?



root@A20-OLinuXino:~# dmesg | grep spi
[    1.673638] [spi-inf] Found 2 spi devices in config files
[    1.685829] [spi-inf] boards num modalias         max_spd_hz       bus_num  cs   mode
[    1.697411] [spi-inf] spi_board0 irq gpio not used
[    1.709143] [spi-inf] 0          spidev           12000000         0        0    0x0   
[    1.721424] gpio_request: gpio-1 (spi_board1) status -22
[    1.728380] [spi-inf] 1          enc28j60         20000000         1        0    0x3   
[    1.741130] [spi-inf] sun7i_spi_probe: spi1 dma type: normal
[    1.750369] [spi-inf] bus num = 1, spi used = 1
[    1.759427] [spi-inf] sun7i_spi_probe: spi1 cs bitmap: 0x1
[    1.773525] [spi-inf] sun7i_spi_set_mclk: spi1 source = sdram_pll_p, src_clk = 384000000, mclk 96000000
[    1.787412] sun7i-spi sun7i-spi.1: registered master spi1
[    1.793173] sun7i-spi sun7i-spi.1: master is unqueued, this is deprecated
[    1.805376] spi spi1.0: setup mode 3, 8 bits/w, 20000000 Hz max --> 0
[    1.809899] sun7i-spi sun7i-spi.1: registered child spi1.0
[    1.818588] [spi-inf] sun7i_spi_probe: reuuimlla's SoC SPI Driver loaded for Bus SPI1 with 2 Slaves at most
[    1.837706] [spi-inf] sun7i_spi_probe: spi1 driver probe succeed, base f00ba000, irq 43, dma_id_rx 25, dma_id_tx 25
[    1.853251] enc28j60 spi1.0: enc28j60 Ethernet driver 1.01 loaded
[    1.865871] enc28j60 spi1.0: enc28j60 chip not found
[    1.875312] enc28j60: probe of spi1.0 failed with error -5


My kernel is:
Linux A20-OLinuXino 3.4.104-gd47d367-dirty #6 SMP PREEMPT Wed Aug 17 19:21:22 EEST 2016 armv7l GNU/Linux

My script.fex file:


[spi1_para]                               
spi_used = 1
spi_cs_bitmap = 1
spi_cs0 = port:PA00<2><default><default><default>
spi_sclk = port:PA01<2><default><default><default>
spi_mosi = port:PA02<2><default><default><default>
spi_miso = port:PA03<2><default><default><default>

[spi_devices]
spi_dev_num = 2

[spi_board0]
modalias = "spidev"
max_speed_hz = 12000000
bus_num = 0
chip_select = 0
mode = 0
full_duplex = 0
manual_cs = 0

[gpio_para]
gpio_used = 1
gpio_num = 1
gpio_pin_1 = port:PB04<5><default><default><default>

[spi_board1]   
modalias = "enc28j60"
max_speed_hz = 20000000
bus_num = 1   
chip_select = 0
mode = 3       
manual_cs = 0 
full_dublex = 0
irq_gpio = 1

gunebakan

I am triying same thing with Linux with new kernel "A20-OLinuXino 4.8.0-rc1-gd735833"

I got this error :
[    0.822100] enc28j60 spi32766.0: enc28j60 Ethernet driver 1.02 loaded
[    0.831704] enc28j60 spi32766.0: enc28j60 chip not found
[    0.837074] enc28j60: probe of spi32766.0 failed with error -5


my device tree is:

spi1: spi@01c06000 {
                        compatible = "allwinner,sun4i-a10-spi";
                        reg = <0x1c06000 0x1000>;
                        interrupts = <0x0 0xb 0x4>;
                        clocks = <0x2 0x15 0x21>;
                        clock-names = "ahb", "mod";
                        dmas = <0x1f 0x1 0x9 0x1f 0x1 0x8>;
                        dma-names = "rx", "tx";
                        pinctrl-names        = "default";
                        pinctrl-0            = <&spi1_pins_a>;
                        status = "okay";
                        #address-cells = <0x1>;
                        #size-cells = <0x0>;

                        eth: enc28j60@0 {
//                              #address-cells = <1>;
//                              #size-cells = <1>;
                                compatible = "microchip,enc28j60";
                                spi-max-frequency = <1000000>;
                                reg = <0>;
                                //interrupt-parent = <&gpio0>;
                                //interrupts = <18 0x01>;
                        };
                };

                        spi1_pins_a: spi1@0 {
                                allwinner,pins = "PI17", "PI18", "PI19";
                                allwinner,function = "spi1";
                                allwinner,drive = <0x0>;
                                allwinner,pull = <0x0>;
                        };

                        spi1_cs0@0 {
                                allwinner,pins = "PI16";
                                allwinner,function = "spi1";
                                allwinner,drive = <0x0>;
                                allwinner,pull = <0x0>;
                        };



Any ideas ?

JohnS

linux-sunxi ML might have help.

John

gunebakan

i tried mainline kernel but i get chip not found error. :(

vinifr

#4
Under mainline, you have to choice a pin with external interrupt capable. For A20 we have PH0-PH21, what are EINT0-EINT21(external interrupts). So, for example, to configure PH21(external interrupt) with enc28j60 connected to the SPI1:

&spi1 {
pinctrl-names = "default";
pinctrl-0 = <&spi1_pins_a>,
    <&spi1_cs0_pins_a>;
status = "okay";

enc28j60: enc28j60@0 {
        compatible = "microchip,enc28j60";
        reg = <0>;
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_irq>;
        interrupt-parent = <&pio>;
        interrupts = <7 21 IRQ_TYPE_EDGE_FALLING>; /*EINT21(PH21)*/
        spi-max-frequency = <10000000>;
    };
};

And inside &pio section:

&pio {
mmc2_pins_nrst: mmc2-rst-pin {
pins = "PC16";
function = "gpio_out";
};

pinctrl_irq: pinctrl_irq@0 {
pins = "PH21";
function = "gpio_in";
};
};

Note that this code should be inserted into .dts board code(i.e. sun7i-a20-olinuxino-lime2.dts), not .dtsi.