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/PROCESSOR-SDK-OMAPL138: Unable to toggle GPIO LED's in Linux

Part Number: PROCESSOR-SDK-OMAPL138
Other Parts Discussed in Thread: OMAP-L138

Tool/software: Linux

Hi,

I want to be able to toggle and set GPIO's on the OMAP-L138 LCDK via Linux. I am running the latest Linux out of the Processor SDK provided.

I have followed the instructions provided in this thread:

and here:

I have modified my arch/arm/mach-davinci/include/mach/mux.h to include

DA850_GPIO0_9,
DA850_GPIO2_12,
DA850_GPIO6_12,

I have modified arch/arm/mach-davinci/da850.c to include for PINMUX

MUX_CFG(DA850, GPIO0_9,		0,	24,	15,	8,	false)
MUX_CFG(DA850, GPIO2_12,	5,	12,	15,	8,	false)
MUX_CFG(DA850, GPIO6_12,	13,	12,	15,	8,	false)

and I have also modified both arch/arm/mach-davinci/board-omapl138-hawk.c and arch/arm/mach-davinci/board-da850-evm.c to include

	/* Configure the LED Pins D7, D6, D5, D4 for LCDK */
	ret = davinci_cfg_reg(DA850_GPIO0_9);
	if (ret)
		pr_warn("%s:GPIO(0,9) mux setup failed\n", __func__);

	ret = davinci_cfg_reg(DA850_GPIO2_12);
	if (ret)
		pr_warn("%s:GPIO(2,12) mux setup failed\n", __func__);

	ret = davinci_cfg_reg(DA850_GPIO6_12);
	if (ret)
		pr_warn("%s:GPIO(6,12) mux setup failed\n", __func__);

	ret = davinci_cfg_reg(DA850_GPIO6_13);
	if (ret)
		pr_warn("%s:GPIO(6,13) mux setup failed\n", __func__);			

However, when I access /sys/class/gpio and export the GPIO's I can't edit their values, they never change.

I am able to change their directions, however i cannot set the values.

I set echo 'out' > direction and it goes through, then when I do echo 1 > value, the value doesn't change.

/sys/kernel/debug/gpio shows the GPIO's that are exported through the sysfs, their directions can change but not the values.

What am I doing wrong here? Or what can I do to be able to toggle the GPIO's through the Linux system. I assumed I pinmuxed them all correctly.

  • Hi Dmitriy,

    The team is notified. They will post their feedback directly here.

    BR
    Tsvetolin Shulev
  • Hi,

    Which Processor SDK Linux version is this?

    Best Regards,
    Yordan
  • Hi Dmitry,

    I this sdk the board files in mach-davinci folder are not used.
    Pinmux is performed in arch/arm/boot/dts/da850.dtsi -> pmx_core: pinmux@14120 {
    and in arch/arm/boot/dts/da850-lcdk.dts -> &pmx_core {

    You should add the gpio pinmux there. Then later in da850-lcdk.dts you should add:
    &gpio0 {
    pinctrl-names = "default";
    pinctrl-0 = <&gpio0_pins>;
    status = "okay";
    } ;
    &gpio2 {
    pinctrl-names = "default";
    pinctrl-0 = <&gpio2_pins>;
    status = "okay";
    };
    &gpio6 {
    pinctrl-names = "default";
    pinctrl-0 = <&gpio6_pins>;
    status = "okay";
    };

    Of course you should also check that there are NO pinmux conflicts (make sure there isn't any other dts node or driver that uses these gpio pins).

    Best Regards,
    Yordan
  • Hey,

    So I receive the following error when building my linux kernel:

    Error: arch/arm/boot/dts/da850-lcdk.dts:199.1-7 Label or path gpio0 not found
    Error: arch/arm/boot/dts/da850-lcdk.dts:205.1-7 Label or path gpio2 not found
    Error: arch/arm/boot/dts/da850-lcdk.dts:211.1-7 Label or path gpio6 not found
    FATAL ERROR: Syntax error parsing input tree
    scripts/Makefile.lib:313: recipe for target 'arch/arm/boot/dts/da850-lcdk.dtb' failed
    make[2]: *** [arch/arm/boot/dts/da850-lcdk.dtb] Error 1
    arch/arm/Makefile:336: recipe for target 'da850-lcdk.dtb' failed
    make[1]: *** [da850-lcdk.dtb] Error 2
    make[1]: *** Waiting for unfinished jobs....
    make[1]: Leaving directory '/home/dmitriy/ti-processor-sdk-linux-omapl138-lcdk-04.03.00.05/board-support/linux-4.9.69+gitAUTOINC+9ce43c71ae-g9ce43c71ae'
    Makefile:313: recipe for target 'linux-dtbs' failed
    make: *** [linux-dtbs] Error 2
    

    I have made those modifications the da850-lcdk.dts

    To &pmx_core I added:

    	gpio0_pins: pinmux_gpio0_pins {
    		pinctrl-single,bits = <
    			/* GP0[9] */
    			0x00 0x08000000  0x0f000000
    		>;
    	};
    
    	gpio2_pins: pinmux_gpio2_pins {
    		pinctrl-single,bits = <
    			/* GP2[12] */
    			0x14 0x00008000  0x0000f000
    		>;
    	};
    
    	gpio6_pins: pinmux_gpio6_pins {
    		pinctrl-single,bits = <
    			/* GP6[12], GP6[13] */
    			0x34 0x00008800  0x0000ff00
    		>;
    	};

    I also added in just the DTS:

    &gpio0 {
    	pinctrl-names = "default";
    	pinctrl-0 = <&gpio0_pins>;
    	status = "okay";
    };
    
    &gpio2 {
    	pinctrl-names = "default";
    	pinctrl-0 = <&gpio2_pins>;
    	status = "okay";
    };
    
    &gpio6 {
    	pinctrl-names = "default";
    	pinctrl-0 = <&gpio6_pins>;
    	status = "okay";
    };

    I'm guessing it's because I haven't added those labels to the da850.dtsi

    The only gpio label in there is this one:

    		gpio: gpio@226000 {
    			compatible = "ti,dm6441-gpio";
    			gpio-controller;
    			#gpio-cells = <2>;
    			reg = <0x226000 0x1000>;
    			interrupts = <42 IRQ_TYPE_EDGE_BOTH
    				43 IRQ_TYPE_EDGE_BOTH 44 IRQ_TYPE_EDGE_BOTH
    				45 IRQ_TYPE_EDGE_BOTH 46 IRQ_TYPE_EDGE_BOTH
    				47 IRQ_TYPE_EDGE_BOTH 48 IRQ_TYPE_EDGE_BOTH
    				49 IRQ_TYPE_EDGE_BOTH 50 IRQ_TYPE_EDGE_BOTH>;
    			ti,ngpio = <144>;
    			ti,davinci-gpio-unbanked = <0>;
    			status = "disabled";
    		};

    I'm not sure how I would extend the da850.dtsi with the gpio0, gpio2, and gpio6 labels.

  • Hi,

    Sorry for the delay. This is my bad. You're getting this error because in da850.dtsi the gpio is defined as:
    gpio: gpio@226000

    And then in da850-lcdk.dts it is enabled like:
    &gpio {
    status = "okay";
    };

    So you just need to figure out the pin number you want to use, pinmux it and make sure it is NOT used in any other dts node.

    Best Regards,
    Yordan