This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM623: How to use GPIO input in SPL working

Part Number: AM623

Tool/software:

Hello,

I take SDK 09_00_00_03 and I would like to read GPIO input in SPL, spl_mmc_load_image() at common/spl/spl_mmc.c.

I added below code to read GPIO0_64.

int spl_mmc_load_image(struct spl_image_info *spl_image,
		       struct spl_boot_device *bootdev)
{
	#if 1
	unsigned long sw = 0, delay = 1000000;

	writel(0xF4104, 0x60007);
	while (delay--) {}
	sw = readl(0x00600070) & (1 << 0);
	if (sw == 0) {
		puts("*** TypeA Boot\n");
	} else {
		puts("*** TypeB Boot\n");
	}
	#endif

But SPL hung at writel() code.

Refer to other tickets, I think that the GPIO0 module is not running at this timing.

Is there a way to read GPIO pin in this timing?

Or I have to initialize GPIO0, power and clocks, manually?


Thank you

  • Hi,

    I have not tried this myself, but let me look at the register settings in your code and post further comments.

    Regards,
    Aparna

  • Hi,

    Could you explain what is the setting done with writel() ?

    I could not find any register address- 0x60007 in GPIO set of registers

    The next section where you are doing a readl() of the GPIO_IN_DATA45 (GPIO0_64: Bank 4) and finding the status using the bit 0 of this register looks correct to me.

    In theory, reading the status of GPIO register should be possible in SPL stage as well.

    Regards,
    Aparna

  • Hello

    I'm sorrry but I had very very easy mistake.

    My misunderstanding is writel() arguments. In correct, the first is value and next is address but I take it as the first is address and next is value as that code.

    I fix this my misstake and I can read gpio input now.

    I am very glad for your comments, bud sory for my taking your time.

    Thank you