How to enable PC14 and PC15 GPIO in at91sam9260 board via Linux board file?

This forum is for users of Microchip MPUs and who are interested in using Linux OS.

Moderator: nferre

octoberskyxx
Posts: 1
Joined: Fri Aug 10, 2018 10:59 am

How to enable PC14 and PC15 GPIO in at91sam9260 board via Linux board file?

Fri Aug 10, 2018 11:27 am

I know its elementary question but I am quite knew to this so please bear with me. I want to enabled the PC14 and PC15 GPIO pins in sam9260 board in my c code. I am quite new to the low level stuff. I am using Linux kernel 3.10.105.

My goal is to read the gpio pins in oscilloscope as output to check the latency during tx and rx.

Code: Select all

PC0..PC31 = GPIO_PIN64-95
Method 1: Using Sysfs. It's simple and elegant approach I will follow this way.

I am aware that I can enable gpio on fly using sysfs and set the value as in or out this work fine to me.

Code: Select all

echo78 > export GPIO
echo789> export GPIO
Method 2 : Enabling GPIO in Linux custom board file I am doing this for my learning purpose to improve my knowledge in low level stuff.

In my board file I set up like this but this is not working. I checked the gpio header it has at91_set_C_periph(), do I need to set this peripheral in my board-myboard.c file to enable GPIO?

I see two files in my mach-91/at91sam92060.c : where gpio banks are initialized and board-myboard.c files that deals with board hardware.

Code: Select all

#include <linux/gpio.h>
static void __init my_board_init(void) {
    /* Setting up PC14 and PC15 only for debuging purpose */
    at91_set_gpio_output(AT91_PIN_PC14, 1);
    at91_set_gpio_output(AT91_PIN_PC15, 1);
}
Thanks for the help.
blue_z
Location: USA
Posts: 1740
Joined: Thu Apr 19, 2007 10:15 pm

Re: How to enable PC14 and PC15 GPIO in at91sam9260 board via Linux board file?

Sat Aug 11, 2018 1:28 am

octoberskyxx wrote:I want to enabled the PC14 and PC15 GPIO pins in sam9260 board in my c code.
...
My goal is to read the gpio pins in oscilloscope as output to check the latency during tx and rx.
That's too vague to elicit a concrete answer.
Is this pin toggling supposed to occur from userspace or in the kernel?
And "tx and rx" of what peripheral?

The GPIO interface through sysfs is for userspace access.
It's a kludge method in place of an actual management by a kernel driver.

octoberskyxx wrote:In my board file I set up like this but this is not working.
A board file is not where a GPIO pin should be "enabled", and that is inadequate code.
The Linux kernel documentation is clear: a device driver can request a GPIO (using gpio_request()), and then either use that GPIO pin in that driver or make that GPIO pin available in the sysfs interface by gpio_export().

Study the Documentation/gpio.txt file in your kernel source.

Regards

Return to “LINUX”

Who is online

Users browsing this forum: No registered users and 2 guests