0
votes

I'm trying to get the at86rf230 kernel driver running on a BeagleBone Black to communicate with my radio. I have confirmed that I am able to interact with the device using some userspace SPI code. Here's the fragment of the DTS file I'm working with:

fragment@0 {
    target = <&am33xx_pinmux>;
    __overlay__ {
        spi1_pins_s0: spi1_pins_s0 {
                pinctrl-single,pins = <
                        0x040 0x37      /* DIG2  GPIO_9.15 I_PULLUP | MODE7-GPIO1_16 */
                        0x044 0x17      /* SLPTR GPIO_9.23 O_PULLUP | MODE7-GPIO1_17 */
                        0x1AC 0x17      /* RSTN  GPIO_9.25 O_PULLUP | MODE7-GPIO3_21 */
                        0x1A4 0x37      /* IRQ   GPIO_9.26 I_PULLUP | MODE7-GPIO3_19 */
                        0x190 0x33      /* SCLK mcasp0_aclkx.spi1_sclk, INPUT_PULLUP | MODE3 */
                        0x194 0x33      /* MISO mcasp0_fsx.spi1_d0, INPUT_PULLUP | MODE3 */
                        0x198 0x13      /* MOSI mcasp0_axr0.spi1_d1, OUTPUT_PULLUP | MODE3 */
                        0x19c 0x13      /* SCS0 mcasp0_ahclkr.spi1_cs0, OUTPUT_PULLUP | MODE3 */
                >;
        };
    };
};
fragment@3 {
target = <&spi1>;
    __overlay__ {
        #address-cells = <1>;
        #size-cells = <0>;
        status = "okay";
        pinctrl-names = "default";
        pinctrl-0 = <&spi1_pins_s0>;
        at86rf230@0 {
            spi-max-frequency = <1000000>;
            reg = <0>;
            compatible = "at86rf230";
            interrupts = <19>;
            interrupt-parent = <&gpio3>;
        };
    };
};

On loading the module I get the following error in dmesg:

[  352.668833] at86rf230 spi1.0: no platform_data
[  352.668945] at86rf230: probe of spi1.0 failed with error -22

I am trying to work out the right way to attach platform_data to the SPI overlay. Here's what I'd like to attach:

platform_data {
    rstn   = <&gpio3 21 0>;
    slp_tr = <&gpio1 17 0>;
    dig2   = <&gpio1 16 0>;
};

Unfortunately, just sticking it in as-is doesn't work so well when I use dtc to compile the DTS. I get the following error:

syntax error: properties must precede subnodes
FATAL ERROR: Unable to parse input tree

I feel that I'm ridiculously close to solving this, and I just need a little shove in the right direction ;)

1

1 Answers

1
votes

First of all, the GPIO names in your excerpt are wrong. Accordingly to the latest code in linux-next there are

pdata->rstn = of_get_named_gpio(spi->dev.of_node, "reset-gpio", 0);
pdata->slp_tr = of_get_named_gpio(spi->dev.of_node, "sleep-gpio", 0);

There are only two of them.

Second, you have to adjust the DTS for your exact board. The entire DTS has to be considered as a platform data for all devices found on the board (some supported, some might be not). The section for the specific device should be described as device node.

So, the good start point is to check what is in upstream already exists, namely in arch/arm/boot/dts/am335x-boneblack.dts, don't forget to check included files as well.

And the example for this specific driver is in Documentation/devicetree/bindings/net/ieee802154/at86rf230.txt.