PRU and dts for IO definition in kernel 3.1x ?

Hi,

so trying to get my things up and running, I wrote a program for the PRU in asm to toggle 2 pins and read 4.

In C, I manage to manipulate them because I’m using GPIO.
But in asm… I try to interact with r30 and r31, and nothing really happens…

I"m with kernel 3.15.

Could someone guide me ?
I think I have to add a dts to declare pins and pinmux, but I feel a bit lost on this point.

In case, this is my asm source

#include “pru.h”
#include “pru_macros.hp”

.origin 0
.entrypoint MAIN

MAIN:

/* enable ocp wide accesses */

LBCO r0, CONST_PRUCFG, 4, 4
CLR r0, r0, 4
SBCO r0, CONST_PRUCFG, 4, 4

/* prepared pru to host shared memory */

MOV r0, 0x000000120
MOV r1, CTPPR_0
ST32 r0, r1

MOV r0, 0x00100000
MOV r1, CTPPR_1
ST32 r0, r1

MOV r10, 0
MOV r11, 0
MOV r12, 0
/* main /
LOOP1:
SET r30.t15 /
CLK high /
MOV r10, r31.b0 /
Read in the data */

QBBC CHKSENSOR2, r10.b0.t0 /* if r10.0, set r11.0 /
SET r11, 0
CHKSENSOR2:
QBBC CHKSENSOR3, r10.b0.t1 /
if r10.1, set r11.15 /
SET r11, 15
CHKSENSOR3:
QBBC CHKSENSOR4, r10.b0.t2 /
if r10.2, set r12.0 /
SET r12, 0
CHKSENSOR4:
QBBC ENDCHECK, r10.b0.t3 /
if r10.3, set r12.15 */
SET r12, 15

ENDCHECK:
CLR r30.t15 /* CLK low /
LSL r11, r11, 1
LSL r12, r12, 1
ADD r0, r0, 1
JMP LOOP1
/
store results from r10,r11 into host memory */

SBCO r10, CONST_PRUSHAREDRAM, 0, 8

/* signal cpu we are done (never reached) */

MOV r31.b0, PRU0_ARM_INTERRUPT + 16
HALT

Thanks,

Cedric

Ok finally managed to build a dts using compatible=‘gpio-leds’ for outputs and I now have a 15Mhz output.

I’ll investigate why when I try to use pru code compiled from C, the signal has a weird shape on the scope but using asm, it’s a regular one.

For inputs, I do not know yet if I should use compatible=“gpio-keys” or something else, I did not find anything related to this yet.

Hi,

I have some simple examples of direct reading/writing under 3.8 (setting mode 6, exclusive use etc)…

https://github.com/dresco/pru_examples

Have the device tree definitions have changed for 3.1x? I’ve not yet successfully built my PRU code under the new 3.14 kernel, so perhaps bone-pinmux-helper is no longer an option?

Regards,
Jon

Hi Jon,

Yes under 3.1x some things have changed a bit for dts.
I failed with bone-pinmux-helper when I tried.

It’s still a WIP for me and also a LIP ( learn in progress :slight_smile: )

Regards,

Cedric

The v3.14.x branch here: (1) uses pinmux-helper..

https://github.com/beagleboard/linux/tree/3.14

Regards,

Thanks Robert,
will check that.

Cedric