Add ENC28J60 to custom WP7607 board


#1

I’m trying to add a ENC28J60 to a wp7607 custom board connected over SPI. I have added the driver to the defcon.

I have also added a sub-node for the enc28j60 to the mdm9607-wp76xx.dtsi starting on row 272

before

&spi_1 {
	status = "ok";
};

After

&spi_1 {
	status = "ok";
	

	enc28j60: ethernet@0 {
		#address-cells = <1>;
		#size-cells = <1>;
		compatible = "microchip,enc28j60";
		spi-max-frequency = <20000000>;
		reg = <0>;
		interrupt-parent = <&WHAT_SHOULD_BE_HERE?>;
		interrupts = <AND_HERE?>;
	};
};

When building and flashing without interrupt-parent and interrupt my dmesg contains

[    1.008694] enc28j60 spi1.0: enc28j60 Ethernet driver 1.01 loaded
[    1.010180] modprobe (121) used greatest stack depth: 6424 bytes left
[    1.012350] enc28j60 spi1.0: enc28j60 chip not found
[    1.012385] enc28j60: probe of spi1.0 failed with error -5

Found this on google https://www.kernel.org/doc/Documentation/devicetree/bindings/net/microchip%2Cenc28j60.txt where it says I need interrupt-parent and interrupt for the driver to get interrupts properly.

I can’t find any examples or documentation on how to specify this. Any help is appreciated.


#2

Hi,

How is ENC28J60 is powered and wired to WP7607?

  • Which WP7607 pin do you have selected for the interrupt?
  • Are you powering the ENC28J60 via a regulator controlled by one WP7606 GPIO pin?
  • Are you managing the reset pin of ENC28J60 via a GPIO?

Could you share schematics (only the parts related to WP76 and ENC28J60 should be enough)?

Also, ENC28J60 driver in kernel 3.18 is not compatible with device tree (required match table for device tree support is missing).
Support has been added with the following commit:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=2dd355a007e44960ec049c75920ddb6778fec9ee
Do you have backported kernel driver code (enc28j60.c) from a newer kernel?

BR
Jay


#3

hi,

I solved it. I used the driver included in the kernel. Mostly i had HW issues. I added a subnode in the tlmm_pinmux node for interrupt and reset pin:

&soc{ 
	tlmm_pinmux: pinctrl@1000000 {
		enc28j60_int_default: enc28j60_int_default {
			mux {
				pins = "gpio76";
				function = "gpio";
			};
			config {
				pins = "gpio76";
				drive-strength = <16>; /* in mA */
				bias-pull-up;
			};
		};

		enc28j60_rst_default: enc28j60_rst_default {
			mux {
				pins = "gpio58";
				function = "gpio";
			};
			config {
				pins = "gpio58";
				drive-strength = <16>; /* in mA */
				output-high;
			};
		};
	};
};	

Then added to spi_1 node:

&spi_1 {
 	status = "ok";
	eth0: enc28j60@0 {
		#address-cells = <1>;
		#size-cells = <1>;
		compatible = "microchip,enc28j60";
		spi-max-frequency = <5000000>;
		reg = <0>;
		interrupt-parent = <&tlmm_pinmux>;
		interrupts = <76 2>; /*IRQ_TYPE_EDGE_FALLING*/
		pinctrl-names = "enc28j60_int_default";
		pinctrl-0 = <&enc28j60_int_default>;
		enc28j60,duplex_mode=<1>;
	};
 };

Added my own flag for full_duplex mode in the driver (enc28j60,duplex_mode) as the driver starts in half_duplex and there is no way to configure this (wierd?).

I however had troubles with the boot configuration of the reset pin. It should be set to output high but at boot it was set low which made the enc28j60 be in constant reset. I think i have it configured now to boot as output high, but I needed to configure it with at+wiocfg=8,4,1,1 i think. I don’t understand this, maybe the at configuration overrides DTS config at boot or something?

The gpio numberings are the qualcomm pin numbers which don’t corresponds to wp7607 pin numbers. found it in this forum post GPIO Interrupts on WP7702 Module

This should at least be documented somewhere more clearly.

the device tree incompatibility you mentioned does not seem to matter.


#4

Hi,

You’re right, the documentation for Linux customization (especially MDM kernel/BSP details) is quite poor.

For GPIO numbers matching (Sierra WP7xxx versus Qualcomm MDM9xxx), you can extract the structure from source code by using this command line at the root of your “yocto” folder:

awk 'BEGIN { in_struct=0; } /^.*ext_gpio_wp\[\]=.*/ { in_struct=1; } /^};/ && in_struct { print; in_struct=0; } in_struct == 1 { print; }' kernel/drivers/gpio/gpiolib-sysfs.c

Result obtained from WP76xx release 10.1.1 (SWI9X07Y_02.18.06.00):

WP76xx MDM9607
2 38
4 30
7 16
8 58
13 76
21 8
22 9
23 10
24 11
25 51
28 45
29 46
30 47
31 48
32 77
33 78
35 37
42 79

BR
Jay


Set default state of gpio at boot WP76