Thanks Jon for the links,

Looking at the Beagleboard blog:
https://beagleboard.org/blog/2018-01-17-building-a-device-tree-overlay-for-your-new-pocketcape-design

I got the Idea that maybe all I need to do is free up some pins, so 
trawling through  
https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm, I found 
BB-SPIDEV1-00A0.dts so using that as my base I came up with the below 
changing to use my pins.

/*
 * Virtual cape for LoRa mPCIe on connector pins P8.19 P9.23 P9.29 P9.30 P9.31 
P2.02
 */

/dts-v1/;
/plugin/;

#include <dt-bindings/board/am335x-bbw-bbb-base.h>
#include <dt-bindings/pinctrl/am33xx.h>

/ {
    compatible = "ti,beaglebone", "ti,beaglebone-black", "ti,beaglebone-green";

    /* identification */
    part-number = "SEEED_SENSECAP_GATEWAY";
    version = "00A0";

    /* state the resources this cape uses */
    exclusive-use =
        /* the pin header uses */
        "P8.19",    /* LoRa Power */
        "P9.23",    /* LoRa Reset */
        "P9.29",    /* LoRa SPI1_D0 */
        "P9.30",    /* LoRa SPI1_D1 */
        "P9.31",    /* LoRa SPI1_SCLK */
        "P2.02",    /* LoRa CS1 */
        /* the hardware ip uses */
        "spi1";

    /*
     * Helper to show loaded overlays under: /proc/device-tree/chosen/overlays/
     */
    fragment@0 {
        target-path="/";
        __overlay__ {

            chosen {
                overlays {
                    SEEED_SENSECAP_GATEWAY-00A0 = __TIMESTAMP__;
                };
            };
        };
    };

    /*
     * Free up the pins used by the cape from the pinmux helpers.
     */
    fragment@1 {
        target = <&ocp>;
        __overlay__ {
            P8_19_pinmux { status = "disabled"; };  /* LoRa Power */
            P9_23_pinmux { status = "disabled"; };  /* LoRa Reset */
            P9_29_pinmux { status = "disabled"; };  /* LoRa SPI1_D0 */
            P9_30_pinmux { status = "disabled"; };  /* LoRa SPI1_D1 */
            P9_31_pinmux { status = "disabled"; };  /* LoRa SPI1_SCLK */
            P2_02_pinmux { status = "disabled"; };  /* Lora CS1 */
        };
    };

    fragment@2 {
        target = <&am33xx_pinmux>;
        __overlay__ {
            /* default state has all gpios released and mode set to uart1 */
            spi1_pins_s0: spi1_pins_s0 {
                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 */
                    0x6c  0x17      /* gpmc_a11.gpio1_27, OUTPUT_PULLUP | MODE7 
*/
                >;
            };
        };
    };

    fragment@3 {
        target = <&spi1>;
        __overlay__ {
            #address-cells = <1>;
            #size-cells = <0>;

            status = "okay";
            pinctrl-names = "default";
            pinctrl-0 = <&spi1_pins_s0>;
            ti,pio-mode; /* disable dma when used as an overlay, dma gets stuck 
at 160 bits... */

            channel@0 {
                #address-cells = <1>;
                #size-cells = <0>;

                compatible = "spidev";
                symlink = "spi/1.0";

                reg = <0>;
                spi-max-frequency = <16000000>;
            };

            channel@1 {
                #address-cells = <1>;
                #size-cells = <0>;

                compatible = "spidev";
                symlink = "spi/1.1";

                reg = <1>;
                spi-max-frequency = <16000000>;
            };
        };
    };
};

This been the first go, this does not compile as I get an syntax error 
'Error: SEEED_SENSECAP_GATEWAY-00A0.dts:8.1-9 syntax error'

While I work through this, I just want to ask will this approach work?

Welcome any help or pointers.

Kind Regards,


On Tuesday, February 9, 2021 at 8:09:38 AM UTC+10 [email protected] wrote:

> Actually, Bootlin has a Device Tree 101 Webinar scheduled for tomorrow.  
> You might find this useful:
>
> https://www.eventbrite.fr/e/webinar-device-tree-101-registration-135964923747?utm_source=eventbrite&utm_medium=email&utm_campaign=event_reminder&utm_term=eventname
>
> They have some free documentation on their site as well.:
> https://bootlin.com/
>
> This is on the Beagleboard page:
>
> https://beagleboard.org/blog/2018-01-17-building-a-device-tree-overlay-for-your-new-pocketcape-design
>
> For the Beaglebone specific stuff, the Derek Molloy book is quite handy. 
> The Second Edition is more relevant to the current kernel implementation. 
>
> https://www.amazon.com/Exploring-BeagleBone-Techniques-Building-Embedded-dp-1119533163/dp/1119533163/ref=dp_ob_title_bk
>
>
> There is a ton of info out there, so others may have their own references.
>
> Cheers,
>
> Jon
>
> On Sun, Feb 7, 2021 at 11:28 AM Yendor <[email protected]> wrote:
>
>> Hi Robert,
>> Been completely new to all this what would be the best why to begin 
>> writing a new *.dtb
>>
>> Regards,
>>
>> On Monday, February 8, 2021 at 1:39:02 AM UTC+10 RobertCNelson wrote:
>>
>>> On Sat, Feb 6, 2021 at 7:22 PM Yendor <[email protected]> wrote: 
>>> > 
>>> > Thanks for the info Robert, would you know how I could reclaim / 
>>> rewrite these pins to act as SPI pins? 
>>> > 
>>> > What would be the best way of doing this? modify 
>>> 'am335x-bonegreen-wireless-uboot-univ.dts' or can we get the boards to load 
>>> a custom default dt config? 
>>>
>>> Honestly, since you have a custom board, i'd just start carving a new 
>>> *.dtb and stop using overlays for other boards.. 
>>>
>>> Regards, 
>>>
>>> -- 
>>> Robert Nelson 
>>> https://rcn-ee.com/ 
>>>
>> -- 
>>
> For more options, visit http://beagleboard.org/discuss
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "BeagleBoard" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/beagleboard/56b31b3d-418a-442a-a750-3bc14832c1c0n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/beagleboard/56b31b3d-418a-442a-a750-3bc14832c1c0n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/8f51ec02-b71e-4b8a-9af9-1b4dd31cd9can%40googlegroups.com.

Reply via email to