在Amlogic Meson G12A平台上为ENG28J60芯片编写设备树(DTS)覆盖

发布于 2025-01-18 05:55:26 字数 3127 浏览 4 评论 0原文

我需要编写一个 .dts 覆盖文件,以便在 Radxa Zero(即 Amlogic Meson G12A<)上使用 Microchip enc28j60 /code> 平台通过 SPI。我使用的内核是 来自 radxa 的​​ 5.10

从完全不知道我在做什么开始,我最终得到了以下覆盖:

/dts-v1/;
/plugin/;

#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/gpio/meson-g12a-gpio.h>

&spicc1 {
    // spicc1 defined in meson-g12-common.dtsi

    // See meson-g12a-spi-spidev.dts
    pinctrl-0 = <&spicc1_pins &spicc1_ss0_pins>;
    pinctrl-names = "default";
    // handled by `param_spidev_spi_bus` and meson-fixup.scr-cmd for the spi-spidev overlay
    status = "okay";

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

    eth1: enc28j60@0 {
        compatible = "microchip,enc28j60";
        reg = <0>;  /* for spi, this defines the chipselect */
        /**
         * gpio_int has interrupts-cells = <2>
         *
         * How does this distinguish between e.g. GPIOAO_4 on the first chip and GPIOZ_4 on the second ?!
         */
        interrupt-parent = <&gpio_intc>;
        interrupts = <GPIOX_8 IRQ_TYPE_EDGE_FALLING>;

        // causes "enc28j60 spi1.0: there is not valid maps for state default"
        pinctrl-0 = <&enc28j60_int_pin>;
        pinctrl-names = "default";

        spi-max-frequency = <12000000>;
        status = "okay";
        debug = <1>;
    };
};

// See meson-g12-common.dtsi
// I think what happens here is that we define this pin as the interrupt pin (something must
// tell the chip that we want this pin to receive interrupts) and then "interrupts" in &eth1
// actually uses it
&periphs_pinctrl {
    enc28j60_int_pin: enc28j60_int_pin@0 {
        amlogic,pins = <&gpio GPIOX_8>;
        amlogic,function = <0>; /* in */
        amlogic,pull = <IRQ_TYPE_NONE>;
    };
};

// Not entirely sure this is correct, but I haven't found any other way to do this
// and this compiles
/ {
    __overrides__ {
        irq   = <&eth1>, "interrupts:0", <&enc28j60_int_pin>, "brcm,pins:0";
        speed = <&eth1>, "spi-max-frequency:0";
    };
};

不幸的是,我努力的结果仍然是一个无法运行的 enc28j60 驱动程序:

[    3.882872] enc28j60 spi1.0: there is not valid maps for state default
[    3.884022] enc28j60 spi1.0: Ethernet driver 1.02 loaded
[    3.896540] enc28j60 spi1.0: chip not found
[    3.896686] enc28j60: probe of spi1.0 failed with error -5

我已经记录了整个过程并且Radxa 的​​进展(或缺乏)社区论坛

我需要取得进展的是信息(但我很乐意接受所有问题的答案;)):

  1. 如何将内核和驱动程序置于调试模式,以便我可以看到 比上面输出的 dmesg 更详细的信息。
  2. 如何验证我尝试使用中断引脚执行的操作是否正确 并有意义。 (我在其他平台找到了类似的例子 [tegra, brcm],但对于介子芯片,pinctrl 似乎是 完全作为内核驱动程序代码的一部分完成,而不是作为设备 树)。

I need to write a .dts overlay file to use a Microchip enc28j60 on a Radxa Zero, which is an Amlogic Meson G12A platform via SPI. The kernel I'm using is 5.10 from radxa.

Starting from having absolutely no idea what I was doing, I have ended up with the following overlay:

/dts-v1/;
/plugin/;

#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/gpio/meson-g12a-gpio.h>

&spicc1 {
    // spicc1 defined in meson-g12-common.dtsi

    // See meson-g12a-spi-spidev.dts
    pinctrl-0 = <&spicc1_pins &spicc1_ss0_pins>;
    pinctrl-names = "default";
    // handled by `param_spidev_spi_bus` and meson-fixup.scr-cmd for the spi-spidev overlay
    status = "okay";

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

    eth1: enc28j60@0 {
        compatible = "microchip,enc28j60";
        reg = <0>;  /* for spi, this defines the chipselect */
        /**
         * gpio_int has interrupts-cells = <2>
         *
         * How does this distinguish between e.g. GPIOAO_4 on the first chip and GPIOZ_4 on the second ?!
         */
        interrupt-parent = <&gpio_intc>;
        interrupts = <GPIOX_8 IRQ_TYPE_EDGE_FALLING>;

        // causes "enc28j60 spi1.0: there is not valid maps for state default"
        pinctrl-0 = <&enc28j60_int_pin>;
        pinctrl-names = "default";

        spi-max-frequency = <12000000>;
        status = "okay";
        debug = <1>;
    };
};

// See meson-g12-common.dtsi
// I think what happens here is that we define this pin as the interrupt pin (something must
// tell the chip that we want this pin to receive interrupts) and then "interrupts" in ð1
// actually uses it
&periphs_pinctrl {
    enc28j60_int_pin: enc28j60_int_pin@0 {
        amlogic,pins = <&gpio GPIOX_8>;
        amlogic,function = <0>; /* in */
        amlogic,pull = <IRQ_TYPE_NONE>;
    };
};

// Not entirely sure this is correct, but I haven't found any other way to do this
// and this compiles
/ {
    __overrides__ {
        irq   = <ð1>, "interrupts:0", <&enc28j60_int_pin>, "brcm,pins:0";
        speed = <ð1>, "spi-max-frequency:0";
    };
};

The result of my efforts, unfortunately is still a non-functioning enc28j60 driver:

[    3.882872] enc28j60 spi1.0: there is not valid maps for state default
[    3.884022] enc28j60 spi1.0: Ethernet driver 1.02 loaded
[    3.896540] enc28j60 spi1.0: chip not found
[    3.896686] enc28j60: probe of spi1.0 failed with error -5

I have documented the entire process and progress (or lack thereof) on the Radxa Community Forums.

What I would need to progress are either information (but I'll gladly accept answers to all of the questions ;)):

  1. How to put the kernel and driver into debug mode so that I can see
    more detailed information than what dmesg is outputting above.
  2. How to verify what I am trying to do with the interrupt pin is correct
    and making sense. (I have found similar examples for other platforms
    [tegra, brcm], but for the meson chips, pinctrl seems to be
    entirely done as part of the kernel driver code, not as a device
    tree).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文