sergs Posted April 10, 2019 Share Posted April 10, 2019 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. Link to comment Share on other sites More sharing options...
5kft Posted April 10, 2019 Share Posted April 10, 2019 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 Link to comment Share on other sites More sharing options...
martinayotte Posted April 10, 2019 Share Posted April 10, 2019 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 ... Link to comment Share on other sites More sharing options...
5kft Posted April 10, 2019 Share Posted April 10, 2019 1 hour ago, martinayotte said: Maybe that could becomes use as default for Armbian U-Boot ... Would you mind doing a PR for that ? Indeed, I actually committed it to Armbian last year, so it's already in the tree (.../patch/u-boot/u-boot-sunxi/enable-r_pio-gpio-access-h3-h5.patch) - see https://github.com/armbian/build/commit/c3f02be362aa216f2d3ee011916f9a18baf58291 Link to comment Share on other sites More sharing options...
martinayotte Posted April 10, 2019 Share Posted April 10, 2019 2 minutes ago, 5kft said: Indeed, I actually committed it to Armbian last year, so it's already in the tree Ah ! Ok ! That is good to know ... Thanks ! Link to comment Share on other sites More sharing options...
sergs Posted April 11, 2019 Author Share Posted April 11, 2019 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! Link to comment Share on other sites More sharing options...
5kft Posted April 11, 2019 Share Posted April 11, 2019 7 hours ago, sergs said: Thanks a lot, it works! Awesome!! Link to comment Share on other sites More sharing options...
Recommended Posts