GPIO access problem with R-Car Starter Kit Pro

Jump to: navigation, search
Revision as of 22 April 2020 at 09:49.
The text of a comment was removed. [diff]

Using R-Car Starterkit Pro, we are now developing a bear metal software which boots directly from ATF. However, we made slight modifications to ATF.

We added the modifications described below when we built the software, where the program will boot in EL2 mode, instead of booting from ATF. Namely, we added modifications to plat/renesas/rcar/

225:# Process RCAR_BL33_EXECUTION_EL flag
227:RCAR_BL33_EXECUTION_EL := 0      <--- We changed the value "0" to "1"
229:$(eval $(call add_define,RCAR_BL33_EXECUTION_EL))

Using the conditions described above, we made codes below.

#define PFC_BASE		(0xE6060000U)

#define PFC_PMMR		(PFC_BASE + 0x0000U)
#define PFC_GPSR6		(PFC_BASE + 0x0118U)
#define GPIO_INOUTSEL6		(GPIO_BASE + 0x5404U)

static inline uint32_t mmio_read_32(uintptr_t addr)
	return *(volatile uint32_t*)addr;

static inline void mmio_clrbits_32(uintptr_t addr, uint32_t clear)
	mmio_write_32(addr, mmio_read_32(addr) & ~clear);

static inline void mmio_setbits_32(uintptr_t addr, uint32_t set)
	mmio_write_32(addr, mmio_read_32(addr) | set);

int main(void)
	UINT32_T reg;

	reg = mmio_read_32(PFC_PMMR);
	mmio_clrbits_32(PFC_PMMR, (UINT32_T)(1<<11|1<<12|1<<13));
	reg = mmio_read_32(PFC_PMMR);

	reg = mmio_read_32(PFC_GPSR6);
	mmio_clrbits_32(PFC_GPSR6, (UINT32_T)(1<<11|1<<12|1<<13));
	reg = mmio_read_32(PFC_GPSR6);
	reg = mmio_read_32(PFC_PMMR);

	reg = mmio_read_32(GPIO_INOUTSEL6);
	mmio_setbits_32(GPIO_INOUTSEL6, (UINT32_T)(1<<11|1<<12|1<<13));
	reg = mmio_read_32(GPIO_INOUTSEL6);

	return 0;

This code processes GPIO resister settings. mmio_setbits_32() sets parameter values to GPIO resister. mmio_read_32() reads out GPIO resister values both pre- and post- GPIO resister settings. We got value "0x00013880" readout when we boot from ATF of Yocto ver. 2.12. However, we got value "0x00000000" when we boot from ATF of Yocto ver. 3.9.0. It seems GPIO settings are not properly set when we boot from ATF of Yocto ver. 3.9.0.

We wonder if there are any changes made to accessing methods of GPIO setting resister between Yocto ver. 2.12. and ver. 3.9.0.? Further, how we can properly make GPIO settings in ATF of Yocto ver. 3.9.0.?

    00:53, 2 April 2020


    I noticed that you use old version BSP.

    Yocto v3.21.0 is latest BSP.

    So, could you update BSP to v3.21.0 from v3.9.0.

    It may fix this issue.

      00:13, 3 April 2020

      Thank you for the reply.
      I also tried Yocto v3.21.0.
      But I was unable to access GPIO.

        17:05, 6 April 2020


        In generally, we should keep to a correct order of register settings to work correctly.

        It is possible to mistake the order, so please try to reverse the order of PFC/GPIO setting.

        Sorry, I cannot test it because I don't have verification environment for bare metal application ...

          01:34, 8 April 2020

          I tried reversing the order of the PFC and GPIO settings and the results were the same.

            02:49, 10 April 2020


            I think gpio module is initialized in ATF until v2.12.0 at least.

            But, for any reasons, it maybe removed.

            So, it may work to add to initialize any register (it is clock of modules? , or switch of module?) to your program.

            Is it possible to investigate how to initialize gpio module?

              19:05, 16 April 2020

              I think it will take some time, but I'll investigate how to initialize.

                02:45, 22 April 2020
                  02:47, 22 April 2020