cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Participant
Participant
248 Views
Registered: ‎04-21-2020

Device tree and GPIO mapping(Could not get #gpio cells)

Hi All, 

              I am in the process of converting the bare metal application to linux driver implementation.

In Baremetal I see the GPIO has a base address of 

#define XPAR_CONTROL_PATH_GPIO_AXI_REG_X08_0_S00_AXI_BASEADDR 0x43C20000

I am mapping to the deivce tree in this way  in System_user.dtsi

label = "encoder_position";
gpios = <&control_path_GPIO_axi_reg_x08_0 8 0 GPIO_ACTIVE_HIGH>;

 

&control_path_GPIO_axi_reg_x08_0 {
gpio-line-names =
/* lines 0-3, unnamed */
"", "", "", "",
/* lines 4 -7 */
"", "", "", "",
/* lines 8 -11 */
"encoder_position", "", "", "",
/* lines 11 -15 */
"", "", "", "";
};

I see the GPIO defined in Pl.dtsi

control_path_GPIO_axi_reg_x08_0: axi_reg_x08@43c20000 {
clock-names = "s00_axi_aclk";
clocks = <&clkc 15>;
compatible = "xlnx,axi-reg-x08-1.3";

When I try to read the GPIO in the device driver I end up with the following error

OF: /rotary1: could not get #gpio-cells ffor /amba_pl/axi_reg_x08@43c20000

 

 

 

 

 

 

 

 

 

 

0 Kudos
2 Replies
Highlighted
Participant
Participant
201 Views
Registered: ‎04-21-2020

My Investigation.

I assumed that the below mentioned address is a GPIO Pin address. In zc7c02

this address is memory mapped address from (AXIO_Memory mapped ).

#define  XPAR_CONTROL_PATH_GPIO_AXI_REG_X08_0_S00_AXI_BASEADDR 0x43C20000

Instead of looking in to the GPIO controller a normal physical memory allocation is enough to handle the same. 

Still it is assumption. Yet to test it. Will update it as the results come up.

 

 

0 Kudos
Highlighted
Voyager
Voyager
133 Views
Registered: ‎08-02-2019

Hi @thenumberdevil ,

I'm also using ZC702.

As you mentioned in your post, GPIO is initially defined in pl.dtsi, if you do not need to change it, it is enough, you do not need to add it again into user.dtsi

In Petalinux you can reach your GPIO like that:

if you want to use GPIO with interrups, I strongly recommends to you, using uio drivers("/dev/uio0"). Otherwise you can reach it over "/dev/mem".

In my example code you can find both of the ways.

#define COMM_AXI_GPIO_0_BASEADDR 0x41200000

#ifdef UIO_DRIVER_ENABLED
char *uiod = "/dev/uio0";

*fd = open(uiod, O_RDWR);
if (*fd < 1) {
printf("Invalid UIO device file:%s.\n", uiod);
return MAP_FAILED;
}

#else // //UIO driver not enabled!!!
char *uiod = "/dev/mem";
*fd = open(uiod, O_RDWR|O_SYNC);
if (*fd < 0) {
fprintf(stderr, "open(/dev/mem) failed (%d)\n", errno);
return MAP_FAILED;
}

#endif

mm_gpio_register_buffer = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, COMM_AXI_GPIO_0_BASEADDR);
if (mm_gpio_register_buffer == MAP_FAILED) {
printf("Mmap register_operations_buffer failure.\n");
return MAP_FAILED;
}

Regards,

Saban

 

If it is helpful, you should give KUDO...

<--- If reply is helpful, please feel free to give Kudos, and close if it answers your question --->
0 Kudos