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.

Linux/AM3352: Unable to read GPIO input

Part Number: AM3352

Tool/software: Linux

Dear e2e community,
    I have worked in the past with AM3352 GPIO in some custom design without problem.

Now, I have a new custom board based on the AM3352.

I have to read two inputs: GPIO2_28 and GPIO2_29 (balls G15 and G16 of the ZCZ package).

In the device tree I have set the following (the inputs are last two items 0x0F8 and 0x0FC):

other_gpio_default: other_gpio_default {
		pinctrl-single,pins = <
			0x21C (PIN_OUTPUT_PULLUP | MUX_MODE7)	/* usb0_drvvbus.gpio0_18 	*/
			0x090 (PIN_OUTPUT_PULLUP | MUX_MODE7)	/* gpmc_adva_ale REED_0		*/			
			0x17C (PIN_OUTPUT_PULLUP | MUX_MODE7)	/* uart1_rtsn.gpio0_13 REED_1	*/		
			0x234 (PIN_OUTPUT_PULLUP | MUX_MODE7)	/* usb1_drvvbus.gpio3_13 	*/
			0x0F8 (PIN_INPUT | MUX_MODE7)	/* mmc0_dat1.mmc0_dat1 ALARM_1	*/
			0x0FC (PIN_INPUT | MUX_MODE7)	/* mmc0_dat0.mmc0_dat0 ALARM_0	*/
		>;
	};

The GPIO are powered by the 3v3 domain and the measured input voltage is 0.1V when low and 3.25V when high.
This voltage is obtained from a regulator different from the one which powers the CPU GPIO power domain. Obviously they refers to the same ground.

In any case when I try a raw read:
cat /sys/class/gpio/gpio92/value
cat /sys/class/gpio/gpio93/value

   I get always 0 both with 0.1V at the input and with 3.25V.

   I tested the GPIO set as outputs and they work as expected.  Maybe I am forgotting something.

   Thank you in advance for the support.

  • Hi Peregrinus,

    Can you provide me a register dump of GPIO2 module registers? You can use devmem2 tool. Provide me also the values of conf_mmc0_dat0 and conf_mmc0_dat1
    registers.

    Regards,
    Pavel

  • Hi Pavel,

    below a dump of the GPIO2 registers. I try also to read GPIO_DATAIN with low and high value at input but it does not change. I checked on an unpopulated board the connection between the BGA balls G15 and G16 and the 0 ohm resistors where I check the voltage and this is ok.

    50600801	GPIO_REVISION	0x481AC000
    0000001D	GPIO_SYSCONFIG	0x481AC010
    00000000	GPIO_EOI	0x481AC020
    00000000	GPIO_IRQSTATUS_RAW_0	0x481AC024
    00000000	GPIO_IRQSTATUS_RAW_1	0x481AC028
    00000000	GPIO_IRQSTATUS_0	0x481AC02C
    00000000	GPIO_IRQSTATUS_1	0x481AC030
    00000000	GPIO_IRQSTATUS_SET_0	0x481AC034
    00000000	GPIO_IRQSTATUS_SET_1	0x481AC038
    00000000	GPIO_IRQSTATUS_CLR_0	0x481AC03C
    00000000	GPIO_IRQSTATUS_CLR_1	0x481AC040
    00000000	GPIO_IRQWAKEN_0	0x481AC044
    00000000	GPIO_IRQWAKEN_1	0x481AC048
    00000001	GPIO_SYSSTATUS	0x481AC114
    00000002	GPIO_CTRL	0x481AC130
    FFFFFFFB	GPIO_OE	0x481AC134
    00000039	GPIO_DATAIN	0x481AC138
    00000000	GPIO_DATAOUT	0x481AC13C
    00000000	GPIO_LEVELDETECT0	0x481AC140
    00000000	GPIO_LEVELDETECT1	0x481AC144
    00000000	GPIO_RISINGDETECT	0x481AC148
    00000000	GPIO_FALLINGDETECT	0x481AC14C
    00000000	GPIO_DEBOUNCENABLE	0x481AC150
    00000000	GPIO_DEBOUNCINGTIME	0x481AC154
    00000000	GPIO_CLEARDATAOUT	0x481AC190
    00000000	GPIO_SETDATAOUT	0x481AC194

  • Peregrinus,

    GPIO2 registers seems to be correct.

    Provide me also the values of conf_mmc0_dat0 and conf_mmc0_dat1 registers.

    Make sure you are aligned with below GPIO wiki:

    software-dl.ti.com/.../Foundational_Components.html

    Regards,
    Pavel

  • Hi Pavel,

        the conf_mmc0_dat0 and conf_mmc0_dat1 effectively seems to be wrong since both register are set to 0x00000030. I would expect to have a 0x7 for the pin mux.  The device tree section (see my first post) "other_gpio_default" is not referred in other places in the dts file. I read a post in which it was said that, if I want the raw control of the gpio, it is sufficient to add an item as above for the pinmux. But here the pinmux has not been applied.

    So, I set the device tree as follow:

    gpio2_default: gpio2_default {
    		pinctrl-single,pins = <
    			0x0F8 (PIN_INPUT | MUX_MODE7)	/* mmc0_dat1.mmc0_dat1 ALARM_1	*/
    			0x0FC (PIN_INPUT | MUX_MODE7)	/* mmc0_dat0.mmc0_dat0 ALARM_0	*/
    		>;
    	};
    
    [...]
    
    &gpio2 {
    	pinctrl-names = "default";
    	pinctrl-0 = <&gpio2_default>;	
    };

    and now the pinmuxing is fine and I can see the two input bits toggling by reading the GPIO_DATAIN register.

    The problem now is that reading

    cat /sys/class/gpio/gpio93/value
    
    cat /sys/class/gpio/gpio92/value
    
    

    returns always 0.  Are these input available somewhere in the userspace? How have I to set the device tree to set the pin mux and then read these input via the /sys/class/gpio?

    thank you.

  • Peregrunis,

    For proper pinmux in linux DTS file, please refer to AM335x SK files: am33xx.dtsi and am335x-evmsk.dts

    Regarding GPIO sysfs usage, make sure your gpio pin is exported and direction is set properly. Please refer to the below pointers:

    linux-4.x/Documentation/gpio/sysfs.txt

    processors.wiki.ti.com/.../Linux_PSP_GPIO_Driver_Guide

    Regards,
    Pavel