Search

Technical Discussion Group Forum

This forum is provided for user discussion. While Beacon EmbeddedWorks support staff and engineers participate, Beacon EmbeddedWorks does not guarantee the accuracy of all information within in the Technical Discussion Group (TDG).

The "Articles" forums provide brief Articles written by Beacon EmbeddedWorks engineers that address the most frequently asked technical questions.

To receive email notifications when updates are posted for a Beacon EmbeddedWorks product download, please subscribe to the TDG Forum of interest.

TDG Forum

PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 31 Oct 2017 05:21 PM by  William Deninger
Mainstream Linux GPIO manipulation
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages
William Deninger
New Member
New Member
Posts:22


--
30 Oct 2017 12:53 PM

    Hello,

    Under Linux 3.0.101, I was able to modify GPIO mode, read and writes by locating the pin mux, exporting, setting pin direction and value.  For instance, under 3.0.101 I could script:

    #locate correct pin

    grep gpio_102 /debug/omap_mux/*

    #check mux setting

    cat /debug/omap_mux/cam_d3
    #modifiy mux for general GPIO

    echo 0x4 > /debug/omap_mux/cam_d3
    #export pin

    echo 102 > /sys/class/gpio/export
    #set pin as output

    echo out > /sys/class/gpio/gpio102/direction
    #Set pin driver level
    echo 0 > /sys/class/gpio/gpio102/value

     

    Under the Mainstream Linux (4.4.y), I found it necessary to first enable the debugfs using

    mount -t debugfs none /sys/kernel/debug/

    However, because of changes in underlying Linux architecture, I'm no longer able to modifiy the GPIO modes.  The /sys/kernel/debug/omap_mux directory contains only an empty directory called board,

    Explicitly, I need to modify GPIO_103 (cam_d4), GPIO_102 (cam_d3), GPIO_96 (cam_xclka), and GPIO_94 (cam_hs) modes as GPIO OUTPUT on the Mainstream Linux to drive some external logic. Note, appropriate SOM hardware R-Packs had already been modified for use under 3.0.101.

    Do you have any suggestions, references or resources that might help me?

    -William 

     

     

     

    Adam Ford
    Advanced Member
    Advanced Member
    Posts:794


    --
    30 Oct 2017 03:28 PM
    William,

    The omap_mux stuff doesn't really exist the same way it used to exist. Previously, the board files would preload a set of pin mux options based on the the chip package. As part of that pre-load it was more easily known which pins corresponded to which GPIO's and which were shared.

    Now, the device tree handles most of that. For GPIO pins that have not been assigned to devices, you can still use the export mechanism to get the GPIO. If you want to do the pin mux, I suggest defining those in the bootloader.

    If you don't have the DM3730 Technical Reference Manual, I would suggest downloading it from TI. I can't share it due to NDA, but you can download it from them.

    What you'll want to do is form the register value for each GPIO.

    For example, if you want the GPIO_103 to be setup as an output, you can look at the technical reference manual for the address for GPIO_103.

    From the TRM, this is going to be the high 16 bits of 0x4800 211c (or you can directly address is at 0x4800211e as a 16-bit word), and you'll want MODE4

    The description of how the registers are set are defined in CONTROL_PADCONF_X.

    If you want to make a GPIO_103 pin mux as mode 4 without anything special, you can write 0x04 to 0x4800211c using devmem

    Once you have done that, you should be able to export the GPIO pins as usual:

    #export gpio to sysfs
    echo 103 > /sys/class/gpio/export

    #set pin as output
    echo out > /sys/class/gpio/gpio103/direction

    #Set pin driver level
    echo 0 > /sys/class/gpio/gpio103/value


    Let me know if that helps.

    adam
    William Deninger
    New Member
    New Member
    Posts:22


    --
    31 Oct 2017 05:21 PM
    Really helped. Thank you.
    You are not authorized to post a reply.