This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux: Has anyone gotten the enc28j60 driver working in the drivers/net/ethernet/microchip directory?

Tool/software: Linux

Hi,

I'm looking for any device tree structures that can help bring this up. Everything I've found on the internet doesn't seem to work for Beaglebone Black. I'm wondering my interrupt pins might not configure correctly. Please refer to the following.

Click Pin     BBB Pin     Signal                Mode    $PINS     ADDR/OFFSET     GPIO NO.

CS                P9.28          SPI1_CS0            3         103            0x99c/19c             113
SCK             P9.31          SPI1_SCLK         3          100            0x990/190            110
MISO            P9.29         SPI1_D0               3          101            0x994/194            111
MOSI            P9.30         SPI1_D1               3          102            0x998/198            112
INT               P9.15          GPIO1_16           7           16              0x840/040            48

am33xx.dts

    ocp: ocp {

...

        spi1: spi@481a0000 {
            compatible = "ti,omap4-mcspi";
            #address-cells = <1>;
            #size-cells = <0>;
            reg = <0x481a0000 0x400>;
            interrupts = <125>;
            ti,spi-num-cs = <2>;
            ti,hwmods = "spi1";
            dmas = <&edma 42 0
                &edma 43 0
                &edma 44 0
                &edma 45 0>;
            dma-names = "tx0", "rx0", "tx1", "rx1";
            status = "disabled";
        };

am335x-bone-common.dtsi

&am33xx_pinmux {
    ...

    spi1_pins: pinmux_spi1_pins {
        pinctrl-single,pins = <
            0x190 0x33    /* mcasp0_aclkx.spi1_sclk, INPUT_PULLUP | MODE3 */
            0x194 0x33    /* mcasp0_fsx.spi1_d0, INPUT_PULLUP | MODE3 */
            0x198 0x13    /* mcasp0_axr0.spi1_d1, OUTPUT_PULLUP | MODE3 */
            0x19c 0x13    /* mcasp0_ahclkr.spi1_cs0, OUTPUT_PULLUP | MODE3 */
        >;
    };

    gpio_pins: pinmux_gpio_pins {
        pinctrl-single,pins = <
            0x040 0x17    /* gpmc_a0.gpio1_16, OUTPUT_PULLUP | MODE7 */
        >;
    };
};

...

&spi1 {
    status = "okay";
    pinctrl-names = "default";
    pinctrl-0 = <&spi1_pins>;

    #address-cells = <1>;
    #size-cells = <0>;

    /* add any spi devices connected here */
    /* note that you can do direct SPI via spidev now */
    spi1_0 {
        #address-cells = <1>;
        #size-cells = <0>;
        compatible = "microchip,enc28j60";
        reg = <0>;
        spi-max-frequency = <20000000>;
        interrupt-parent=<&gpio_pins>;
        interrupts=<48 0x2>; /* falling edge */
        spi-cpol;
        spi-cpha;
    };
};

  • Hi Pavel,

    It works well, if I switch interrupt pin to GPIO1_15 (P8.15). Do you know how I can configure GPIO1_16 (P9.15) instead?

    GPIO1_15 (P8.15)

    &spi1 {

           pinctrl-names = "default";

           pinctrl-0 = <&spi1_pins>;

           status = "okay";

           spidev2: spi@0 {

                   compatible = "microchip,enc28j60";

                   reg = <0>;

                   spi-max-frequency = <24000000>;

                   interrupts = <15 2>;

                   interrupt-parent = <&gpio1>;

           };

    };

    GPIO1_16 (P9.15)

    &spi1 {

           pinctrl-names = "default";

           pinctrl-0 = <&spi1_pins>;

           status = "okay";

           spidev2: spi@0 {

                   compatible = "microchip,enc28j60";

                   reg = <0>;

                   spi-max-frequency = <24000000>;

                   interrupts = <16 2>;

                   interrupt-parent = <&gpio1>;

           };

    };

  • Do you use BBB or custom board?

    Have you check the pinmux? Check registers conf_gpmc_ad15/0x83c and conf_gpmc_a0/0x840. Make sure you have value of 0x7 in [2:0] bits.

    Regards,
    Pavel
  • Yes, I did. However, I don't know why I don't need to have value of 0x7 for GPIO1_15 (P8.15) which still work.
    Even though I add 0x7 for conf_gpmc_a0/0x840, I still cannot use GPIO1_16(P9.15).
    Moreover, what's the register conf_gpmc_ad15/0x83c use for?
  • conf_gpmc_ad15/0x83C is used to select the gpio1_15 signal on the GPMC_AD15 pad (pin U13 for ZCZ package). What value you have in this register in the working case?

    conf_gpmc_a0/0x840 is used to select the gpio1_16 signal on the GPMC_A0 pad (pin R13 for ZCZ package). What value you have in this register in the non-working case?

    Do you use BeagleBoneBlack or custom board?

    Regards,
    Pavel

  • I am using BeagleBoneBlack. My setting value for the register is 0x17.
    I don't use conf_gpmc_ad15/0x83C to select the gpio1_15. The enc28j60 still works for me.
    However, I prefer to use gpio1_16 instead.
  • Chiahsing,

    Let me clarify your use case. You have BeagleBoneBlack base board and you connect your enc28j60 chip to the P8 connector, and it is working fine, is this correct?

    And when you connect your enc28j60 chip to P9 connector, it stop working, is this correct?

    Regards,
    Pavel
  • Pavel,
    Exactly, I try to connect my enc28j60 chip to P9 connector instead of P8.
    Right now, I am trying to figure it out why P8 don't need to have pinmux value. Here is my P8(GPIO1_15) which works well.
    spi1_pins: pinmux_spi1_pins {
    pinctrl-single,pins = <
    0x190 0x33 /* mcasp0_aclkx.spi1_sclk, INPUT_PULLUP | MODE3 */
    0x194 0x33 /* mcasp0_fsx.spi1_d0, INPUT_PULLUP | MODE3 */
    0x198 0x13 /* mcasp0_axr0.spi1_d1, OUTPUT_PULLUP | MODE3 */
    0x19c 0x13 /* mcasp0_ahclkr.spi1_cs0, OUTPUT_PULLUP | MODE3 */
    >;
    };
    &spi1 {
    status = "okay";
    pinctrl-names = "default";
    pinctrl-0 = <&spi1_pins>;

    #address-cells = <1>;
    #size-cells = <0>;

    /* add any spi devices connected here */
    /* note that you can do direct SPI via spidev now */
    spi1_0 {
    compatible = "microchip,enc28j60";
    reg = <0>;
    spi-max-frequency = <12000000>;
    interrupt-parent=<&gpio1>;
    interrupts=<15 0x2>; /* falling edge */
    };
    };
    Thanks,
    Chia-Hsing
  • Chia-Hsing,

    Do you use AM335x TI PSDK? If yes, which version?

    When you connect enc28j60 to P8, which pins exactly you are using there? Seems like you are using SPI1 (cs0, d0, d1, sclk) and INTn (gpio1_15), but do you use also clkout and RESETn? I mean do you map also enc28j60 clkout and RESETn pins to AM335x pins?

    Can you provide me the values of conf_gpmc_ad15/0x44E1083C and conf_gpmc_a0/0x44E10840 registers at user space with devmem2 tool?

    Regards,
    Pavel
  • Pavel,
    No. I am not using TI SDK. I am running on version 4.4.30.
    Yes, I am just using cs0, d0, d1, sclk and gpio1_16 (P9.15) if I switch to gpio1_15 (P8.15), it works well. I would like to know why I can not use P9.15 instead.
    Thank,
    Winston
  • Chiahsing Wu said:
    No. I am not using TI SDK.

    This forum support TI SDK only (Arago linux). Check if you can switch to it, so we can better help you. Other linux distributions (Ubuntu, Debian, etc) are supported in the BeagleBoard community forums.

    Chiahsing Wu said:
    Yes, I am just using cs0, d0, d1, sclk and gpio1_16 (P9.15) if I switch to gpio1_15 (P8.15), it works well. I would like to know why I can not use P9.15 instead

    Check if you have the same pinmux value regarding gpio1_15 and gpio1_16. Explore the GPIO1 module registers, check if interrupt generation is enabled for gpio1_16 (like should be for gpio1_15).

    Regards,
    Pavel