From owner-freebsd-arm@freebsd.org Wed Jan 15 09:50:35 2020 Return-Path: Delivered-To: freebsd-arm@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 11AF2226E1F for ; Wed, 15 Jan 2020 09:50:35 +0000 (UTC) (envelope-from jwbentum44@gmail.com) Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47yMyK6rX6z4JqV for ; Wed, 15 Jan 2020 09:50:33 +0000 (UTC) (envelope-from jwbentum44@gmail.com) Received: by mail-lf1-x141.google.com with SMTP id b15so12196071lfc.4 for ; Wed, 15 Jan 2020 01:50:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=MiIoxNgmHIaRfx6keuC8xTpCimcOtAC1Jz4dRKGeAGM=; b=Z0dxwjwK0V6b0JBAc/rF87HuZOOyueYYBbF8TwQywsjspFZRJ5B5+2SH/bPoJOCguE /+g33/dy5J1Fy/PlPjCCngEGhiGyxLKjFvnpwZmx9+GZqogaGKUuNk/cItacOdhgdPso M2ah7Zl+5SNKPc5L1yvzu/+GCKDUsITtkED0CCNbm2DWhEx2FiNJ1IREj7VGf85s4jvU jm5Q+DFd4iAwNfqkjwsQUA1zZh3IfnfX2P+ty6tG+ZUpWrME22STXgUr8tmn+uT8/Yq+ gwT+tGW3NBluLclC2hhBVdaId8K59cDnlhlncXSDMIPWc72S/Sq3mAs9mjahio/7uwUC KbCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=MiIoxNgmHIaRfx6keuC8xTpCimcOtAC1Jz4dRKGeAGM=; b=p7kx0JXMOJQiZZzwXb55X1hNoKjhNattDrCmFlf4Tx5SRZpviNwqzRXL1x1HhcONEV tZB7hzt6S8wMbtt37mXaAiJLhEVnlrY5gLmjp7/y+kO+nYkaI0Anx7ERK/0PMqsOsK7g iwyYH4FKhMHUDMiezMhHvMX/AAunK1Uq06kdin/xJzq4bkyRopFQPtqCkP5hocqamTjw aKchMgKrtSmleaRUMyEQsCl070+d8Xg9RbxKiI+DBfOJHLFZ84jN6tKyPqzvYcgFBo3j tW/of1TSbhmlSQstcs9Cj+9Tcic/9ZVAew+azgMltcV76XDUZQkLwZW2+UomCBQ9wARl es7Q== X-Gm-Message-State: APjAAAVdextjt8z4aQxe85059JvrUSVnWOkVNRDqoOl2Wck7JL9NE5ga vF1zHm+KpV1TlbWBfA1UMXRiKxAFeVmLGYZYGXD0FmjJ91H41Q== X-Google-Smtp-Source: APXvYqwzRr2I/6I4sBllRZ9jgylxKBna7Xc2M1ZuLQEvfGpTQF03bMxyk4aoo2RqR23SuUbWu0V0HNciubKLgjBFul0= X-Received: by 2002:ac2:58c2:: with SMTP id u2mr4540246lfo.206.1579081831748; Wed, 15 Jan 2020 01:50:31 -0800 (PST) MIME-Version: 1.0 From: Hans Bentum Date: Wed, 15 Jan 2020 10:50:20 +0100 Message-ID: Subject: How to get pin to mode 6 on beagle bone black To: freebsd-arm@freebsd.org X-Rspamd-Queue-Id: 47yMyK6rX6z4JqV X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=Z0dxwjwK; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of jwbentum44@gmail.com designates 2a00:1450:4864:20::141 as permitted sender) smtp.mailfrom=jwbentum44@gmail.com X-Spamd-Result: default: False [-2.90 / 15.00]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; FREEMAIL_FROM(0.00)[gmail.com]; TO_DN_NONE(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; MIME_BASE64_TEXT(0.10)[]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; FROM_EQ_ENVFROM(0.00)[]; IP_SCORE(0.00)[ip: (2.55), ipnet: 2a00:1450::/32(-2.59), asn: 15169(-1.83), country: US(-0.05)]; MIME_TRACE(0.00)[0:+,1:+,2:~]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; SH_EMAIL_ZRD(0.00)[0.0.0.0,0.0.0.1]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com.dwl.dnswl.org : 127.0.5.0]; SH_EMAIL_DBL_DONT_QUERY_IPS(0.00)[0.0.0.1,0.0.0.0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-arm@freebsd.org]; IP_SCORE_FREEMAIL(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[1.4.1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.5.4.1.0.0.a.2.list.dnswl.org : 127.0.5.0]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jan 2020 09:50:35 -0000 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 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