Date: Wed, 15 Jan 2020 10:50:20 +0100 From: Hans Bentum <jwbentum44@gmail.com> To: freebsd-arm@freebsd.org Subject: How to get pin to mode 6 on beagle bone black Message-ID: <CAH4pBpP2oC-8Vjm5AFMuQopZ-6DvQG_suX5yknv6nYTkLe8yPQ@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
Hello, I tried several things to put pin 8_16 into mode 6 for usage by the PRU for high speed IO. Up to now without any luck. I am using FreeBSD 12.1 Question: how can I put a pin on beagle bone black to mode 6? I did the following: To get full speed IO signals I would like to use the enhanced GPIO on the PRU. To do this a device tree overlay is needed. I found a nice example on the internet. https://nilshoel.home.blog/ In this example pin P8.16 is set to input mode 6. /dts-v1/; /plugin/; / { compatible =3D "ti,beaglebone", "ti,beaglebone-black", "ti,beaglebone-green= "; // identification part-number =3D "PRU-UIO-EXAMPLE-PINS"; version =3D "00A0"; fragment@0 { target =3D <&am33xx_pinmux>; __overlay__ { example_pins: pinmux_pru_pru_pins { pinctrl-single,pins =3D < 0x38 0x26 /* Pin 8_16 in gpmc_ad14 Mode 6 */ >; }; }; }; fragment@1 { target-path=3D"<&pruss>"; __overlay__ { pinctrl-names =3D "default"; pinctrl-0 =3D <&example_pins>; status =3D "okay"; }; }; }; The file (egpio.dtso) is converted by dtc =E2=80=93I dts =E2=80=93O dtb =E2=80=93o /boot/dtb/overlays/egpio.dtbo = egpio.dtso The egpio.dtbo is added in the file loader.conf to the line fdt_overlays=3D"am335x-boneblack-pruss.dtbo,egpio.dtbo" am335x-boneblack-pruss.dtbo is to enable the pruss /dts-v1/; /plugin/; / { compatible =3D "ti,am335x-bone-black", "ti,am335x-bone", "ti,am33xx"; fragment@0 { target-path=3D"/"; __overlay__ { ocp { #address-cells =3D <1>; #size-cells =3D <1>; pruss@4a300000 { status =3D "okay"; compatible =3D "ti,pruss-v2"; ti,deassert-hard-reset =3D "pruss", "pruss"; reg =3D <0x4a300000 0x080000>; ti,pintc-offset =3D <0x20000>; interrupt-parent =3D <&intc>; interrupts =3D <20 21 22 23 24 25 26 27>; }; }; }; }; }; In the PRU(0) I start a little test program which sets a userled to on when the pin is sampled high and sets the userled to off when the pin is sampled low. The pin should be in mode 6 to be able to read the high value. If I use some timer construction in the pru assembly program bellow the leds are blinking so the pru is up and running. # cat rtu_w.p .origin 0 .entrypoint START #define GPIO0 0x44E07000 #define GPIO1 0x4804c000 #define GPIO2 0x481AC000 #define GPIO3 0x481AE000 #define GPIO_CLEARDATAOUT 0x190 #define GPIO_SETDATAOUT 0x194 #define LED_USER 1<<24 #define CONST_PRUCFG C4 #define CTPPR_0 0x24028 #define CTPPR_1 0x2402C .macro ST32 .mparam src,dst SBBO src,dst,#0x00,4 .endm START:LBCO r0, CONST_PRUCFG, 4, 4 CLR r0, r0, SBCO r0, CONST_PRUCFG, 4, 4 MOV r0, 0x00000100 MOV r1, CTPPR_0 ST32 r0, r1 MOV r0, 0x00100000 MOV r1, CTPPR_1 ST32 r0, r1 NO_CMD:QBBC L1, r31.t14 // Quick Branch to L1 if Bit is Clear CALL LED_USER_LANE_1_ON QBA NO_CMD L1: CALL LED_USER_LANE_1_OFF QBA NO_CMD LED_USER_LANE_1_ON: MOV r2, LED_USER MOV r3, GPIO1 | GPIO_SETDATAOUT SBBO r2, r3, 0, 4 RET LED_USER_LANE_1_OFF: MOV r2, LED_USER MOV r3, GPIO1 | GPIO_CLEARDATAOUT SBBO r2, r3, 0, 4 RET Makefile pru =3D rtu_w LIB_PATH =3D . LIBRARIES =3D pthread INCLUDES =3D -I. ${LIB_PATH} INCLUDES =3D -I/home/freebsd/iws EXTRA_DEFINE =3D CCCFLAGS =3D $(EXTRA_DEFINE) CC =3D clang CFLAGS =3D $(EXTRA_DEFINE) PASM =3D pasm all : $(clean) $(pru) pru : $(pru) $(pru) : $(pru:%=3D%.p) rm -rf *.o *.bin $(project) core *~ $(PASM) -V3 -b $@.p clean: rm -rf *.o *.bin $(project) core *~ compile wtih: #make Run on pru:(and give the pin signals) # pructl =E2=80=93t ti =E2=80=93p 0 =E2=80=93e rtu_w.bin I also tried to set the pinmux using the pru but no luck (as expected). https://vadl.github.io/beagleboneblack/2016/07/29/setting-up-bbb-gpio #define P8_16 0x44E10838 MOV r2, 0x26 // val MOV r0, P8_16 // address SBBO r2, r0, 0, 4 // store For low speed setting or reading pin like #include <libgpio.h> gself.m_gpio2 =3D gpio_open(2); gpio_pin_input (gself.m_gpio2, 22); gpio_close(gself.m_gpio2); works very well. Regards, Hans Bentum
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAH4pBpP2oC-8Vjm5AFMuQopZ-6DvQG_suX5yknv6nYTkLe8yPQ>