0

Please, could someone help me, I am trying to use the module (max3421-hcb) with the raspberry pi 3, but I really don't know how to load this module, with the parameters, like wich GPIO will act as INT or the speed (clock).

I have compiled the kernel 4.14 with the config CONFIG_USB_MAX3421_HCD=m, so I have the module max3421-hcb.ko, but it seen not be working.

I am using the USB/SPI Shield from sparkfun but even when I load the module using modprobe max3421-hcb I don't get any message in the syslog or dmesg that indicates that the kernel is recognizing the max3421.

I have followed this example: mcp2515-can0-overlay.dts and goted this file:

/dts-v1/;
/plugin/;

/ {
compatible = "brcm,bcm2835", "brcm,bcm2836", "brcm,bcm2708", "brcm,bcm2709";
/* disable spi-dev for spi0.0 */
fragment@0 {
    target = <&spi0>;
    __overlay__ {
        status = "okay";
    };
};

fragment@1 {
target = <&spidev0>;
__overlay__ {
    status = "disabled";
};
};

/* the interrupt pin of the usb-controller */
fragment@2 {
    target = <&gpio>;
    __overlay__ {
        usb0_pins: usb0_pins {
            brcm,pins = <25>;
            brcm,function = <0>; /* input */
        };
    };
};

/* the clock/oscillator of the usb-controller */
fragment@3 {
    target-path = "/clocks";
    __overlay__ {
        /* external oscillator of max3421 on SPI0.0 */
        usb0_osc: usb0_osc {
            compatible = "fixed-clock";
            #clock-cells = <0>;
            clock-frequency  = <25000000>;
        };
    };
};

/* the spi config of the usb-controller itself binding everything together */
fragment@4 {
    target = <&spi0>;
    __overlay__ {
        /* needed to avoid dtc warning */
        #address-cells = <1>;
        #size-cells = <0>;
        usb@0 {
            compatible = "maxim,max3421";
            reg = <0>;
            maxim,vbus-en-pin = <3 1>;
            spi-max-frequency = <25000000>;
            interrupt-parent = <&gpio>;
            interrupts = <25 8>;
            clocks = <&usb0_osc>;
        };
    };
};
__overrides__ {
    oscillator = <&usb0_osc>,"clock-frequency:0";
    spimaxfrequency = <&usb0>,"spi-max-frequency:0";
    interrupt = <&usb0_pins>,"brcm,pins:0",<&usb0>,"interrupts:0";
    };
};

I'm using this setup to try make MAX3421E work:

  • Raspberry Pi 3
  • Raspbian GNU/Linux 9
  • Kernel Linux raspberrypi 4.15.17-v7+
    • With MAX3421-HCB compile as module
    • spi0-max3421e.dtbo inside /boot/overlay
    • Line dtoverlay=spi0-max3421e in /boot/config.txt

Printout of command raspi-gpio get 25,8,10,9,11

GPIO 8: level=1 fsel=4 alt=0 func=SPI0_CE0_N
GPIO 9: level=0 fsel=4 alt=0 func=SPI0_MISO
GPIO 10: level=0 fsel=4 alt=0 func=SPI0_MOSI
GPIO 11: level=0 fsel=4 alt=0 func=SPI0_SCLK
GPIO 25: level=1 fsel=0 func=INPUT;

Sparkfun SPI USB Arduino Shield

D7 (RESET) - connected to 5Vdc
D8 (GPX) - not connected
D9 (INT) - connected to BCM25 (Pin 22)
D10 (SS) - connected to BCM8 (Pin 24)
D11 (MOSI) - connected to BCM10 (Pin 19)
D12 (MISO) - connected to BCM9 (Pin 21)
D13 (SCK) - connected to BCM11 (Pin 23)
VIN - connected to Raspberry Pi Pin 2

On boot the module max3421-hcb do not is load automatically, I believe that it should be, because of dtoverlay=spi0-max3421e

Even with sudo modeprobe max3421-hcb:

root@raspberrypi:~# lsmod
Module Size Used by
max3421_hcd 20480 0
spidev 16384 0

I get 0 messages inside syslog or dmesg

When I was using the version 4.14 of the kernel I alter the file max3421-hcb.c to be like the one in 4.15 kernel! Now I'm using a full 4.15.y kernel, but no result either.

Best Regards

  • 1
    Raspberry Pi is using overlays. Have you had a look at /boot/overlays/README? – Ingo Apr 18 '18 at 21:00
  • I just updated my question, using the overlay file, can you have any sugestions? – Cezar J. Sant'Anna Jr. Apr 23 '18 at 11:05
  • No sorry, I don´t have any idea. I'm not so familiar with overlays and haven't compiled a kernel for a Raspberry Pi so far. – Ingo Apr 23 '18 at 20:11
0

I have faced the same issue and the problem was the driver in the 4.14 kernel that doesn't support device tree.

I've updated the max3421-hcd.c file with the most recent version (from 4.16) and used a custom DTS file , a bit different from yours, but essentially the same:

/dts-v1/;
/plugin/;

/ {
    compatible = "brcm,bcm2835";
    /* Disable spidev for spi0.1 - release resource */
    fragment@0 {
        target = <&spi0>;
        __overlay__ {
            status = "okay";
            spidev@1{
                status = "disabled";
            };
        };
    };

    /* Set pins used (IRQ) */
    fragment@1 {
        target = <&gpio>;
        __overlay__ {
            max3421_pins: max3421_pins {
                brcm,pins = <6>;        //GPIO6
                brcm,function = <0>;    //Input
            };
        };
    };

    /* Create the MAX3421 node */
    fragment@2 {
        target = <&spi0>;
        __overlay__ {
            //avoid dtc warning 
            #address-cells = <1>;
            #size-cells = <0>;
            max3421: max3421@1 {
                reg = <1>;  //CS 1
                spi-max-frequency = <20000000>;
                compatible = "maxim,max3421";
                pinctrl-names = "default";
                pinctrl-0 = <&max3421_pins>;
                interrupt-parent = <&gpio>;
                interrupts = <6 0x2>;       //GPIO6, high-to-low
                maxim,vbus-en-pin = <1 1>;  //MAX GPOUT1, active high
            };
        };
    };

    __overrides__ {
        spimaxfrequency = <&max3421>,"spi-max-frequency:0";
        interrupt = <&max3421_pins>,"brcm,pins:0",<&max3421>,"interrupts:0";
        vbus-en-pin = <&max3421>,"maxim,vbus-en-pin:0";
        vbus-en-level = <&max3421>,"maxim,vbus-en-pin:4";
    };
};

I noticed that, when nothing appears in dmesg, it is because the driver hasn't been matched when probing. Since I can't comment yet, I can't ask you for more details to help with this issue. But try taking a look at the running device tree (dtc -I fs /proc/device-tree) to verify if the overlay is active. You should see something like this:

spi@7e204000 {
            compatible = "brcm,bcm2835-spi";
            clocks = <0x8 0x14>;
            status = "okay";
            #address-cells = <0x1>;
            interrupts = <0x2 0x16>;
            cs-gpios = <0xe 0x8 0x1 0xe 0x7 0x1>;
            #size-cells = <0x0>;
            dma-names = "tx", "rx";
            phandle = <0x1c>;
            reg = <0x7e204000 0x1000>;
            pinctrl-0 = <0xc 0xd>;
            dmas = <0x9 0x6 0x9 0x7>;
            pinctrl-names = "default";

            spidev@1 {
                compatible = "spidev";
                status = "disabled";
                #address-cells = <0x1>;
                #size-cells = <0x0>;
                phandle = <0x59>;
                reg = <0x1>;
                spi-max-frequency = <0x7735940>;
            };

            max3421@1 {
                maxim,vbus-en-pin = <0x1 0x1>;
                compatible = "maxim,max3421";
                interrupt-parent = <0xe>;
                interrupts = <0x6 0x2>;
                phandle = <0x73>;
                reg = <0x1>;
                pinctrl-0 = <0x72>;
                spi-max-frequency = <0xf4240>;
                pinctrl-names = "default";
            };

            spidev@0 {
                compatible = "spidev";
                #address-cells = <0x1>;
                #size-cells = <0x0>;
                phandle = <0x58>;
                reg = <0x0>;
                spi-max-frequency = <0x7735940>;
            };
        };

Just note that I'm using SPI0.1, and GPIO6 as interrupt, on a RaspberryPi 2

  • I am using the same dts file, but using kernel 4.14, 4.15 and 4.16 in all of then I am getting this messages: [ 350.556370] max3421_handle_irqs: BUSEVENT Bus Resume Done [ 489.629296] INFO: task kworker/0:0:1461 blocked for more than 120 seconds. [ 489.629306] Not tainted 4.15.18-v7+ #1 [ 489.629312] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. – Cezar J. Sant'Anna Jr. Jun 30 '18 at 21:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.