1 1
sergs

Orange Pi Zero U-Boot GPIO access

Recommended Posts

I'm working with an Orange Pi Zero board powered by OpenWRT with U-Boot (2018.11) and kernel (4.14.93).

 

I'm trying to implement a recovery mode by inspecting a state of some button during an u-boot phase. This button is connected to a PL4 GPIO line. When Linux gets loaded it's possible to read a state of this GPIO line, but during an u-boot phase result is the same ( 0 ) regardless of a real state of the button (`gpio input pl4`).

As I got from H2+ datasheet, L port is a dedicated port (bank) with all GPIO lines disabled by default, when I try to change value of a configuration register for this port nothing changes - I read it and see that it's the same.

I used both direct memory access (writel and pointer dereferencing) and indirect access - sunxi_gpio_set_cfgpin(). Also I see, indirectly,  that the GPIO line is disabled by inspection result of a `gpio st` command.

 

. How can I turn on any GPIO line on an L port?

. Do I have to change something to *dts / board.c file(s) to make `gpio input pl4` work properly?

 

Thanks in advance for any help.

Share this post


Link to post
Share on other sites

Indeed by default R_PIO-based GPIOs aren't accessible in u-boot.  I made an Armbian patch last year to enable R_PIO access in the PRCM so that I could read the board revision GPIO PL3 on the NEO2 v1.1 (H5-based).  You can take a look at the change here:  https://github.com/armbian/build/blob/master/patch/u-boot/u-boot-sunxi/enable-r_pio-gpio-access-h3-h5.patch.  I would imagine that you should be able to add the "prcm_apb0_enable(PRCM_APB0_GATE_PIO)" call to your OpenWRT u-boot; after you do this the GPIO commands/function access for PL4 should work (hopefully!).  What's awesome about all of this is how it is basically not documented anywhere :)

 

Share this post


Link to post
Share on other sites
1 hour ago, 5kft said:

I made an Armbian patch last year to enable R_PIO access in the PRCM

Maybe that could becomes use as default for Armbian U-Boot ...

Would you mind doing a PR for that ?

1 hour ago, 5kft said:

What's awesome about all of this is how it is basically not documented anywhere :)

Right ! U-Boot in general is not well documented ...

Share this post


Link to post
Share on other sites
12 hours ago, 5kft said:

Indeed by default R_PIO-based GPIOs aren't accessible in u-boot.  I made an Armbian patch last year to enable R_PIO access in the PRCM so that I could read the board revision GPIO PL3 on the NEO2 v1.1 (H5-based).  You can take a look at the change here:  https://github.com/armbian/build/blob/master/patch/u-boot/u-boot-sunxi/enable-r_pio-gpio-access-h3-h5.patch.  I would imagine that you should be able to add the "prcm_apb0_enable(PRCM_APB0_GATE_PIO)" call to your OpenWRT u-boot; after you do this the GPIO commands/function access for PL4 should work (hopefully!).  What's awesome about all of this is how it is basically not documented anywhere :)

 

Thanks a lot, it works!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
1 1