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 control GPIO from sysfs

Part Number: AM3352


Tool/software: Linux

Hi,

I am using a custom AM335x board and I am facing issues in controlling some gpios. I have added the GPIOs(GPIO2_27=91 and GPIO2_28=92 in my_gpio2_pins_default entry) to dts file and made sure that the pins are not used anywhere else in the dts file. GPIO 91 and 92 is connected to another module where 91 is pulled down 92 is pulled up internally in the module. When I try to change the status using the above commands, the pin statuses does not change.
I am able to control other gpios in the dts file (not all of them are tested but the one's that I tried out are working). Kindly let me know if I need to do anything else to make it work. The GPIOs 91 and 92 are by default used for SD card interface. I have changed it to work as a GPIO since I dont use SD card interface in my board. Any help would be appreciated.

My dts file is this

/*
 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */
/dts-v1/;

#include "am33xx.dtsi"
#include <dt-bindings/interrupt-controller/irq.h>

/ {
	model = "CALIXTO-AM335X-NXT";
	compatible = "ti,am335x-evm", "ti,am33xx";

	cpus {
		cpu@0 {
			cpu0-supply = <&vdd_mpu_supply>;
		};
	};

	memory {
		device_type = "memory";
		reg = <0x80000000 0x10000000>; /* 256MB */
	};

	vmmcsd_fixed: fixedregulator@1 {
                compatible = "regulator-fixed";
                regulator-name = "vmmcsd-regulator";
                regulator-min-microvolt = <3300000>;
                regulator-max-microvolt = <3300000>;
                enable-active-high;
                regulator-always-on;
        };

        vdd_mpu_supply: fixedregulator@2 {
                compatible = "regulator-fixed";
                regulator-name = "vdd-mpu-regulator";
                regulator-min-microvolt = <1262000>;
                regulator-max-microvolt = <1262000>;
                regulator-boot-on;
                regulator-always-on;
        };

	core_audio_supply: fixedregulator-audiocore {
                compatible = "regulator-fixed";
                regulator-name = "core_audio_supply";
                regulator-min-microvolt = <3300000>;
                regulator-max-microvolt = <3300000>;
                regulator-boot-on;
        };

        io_audio_supply: fixedregulator-audioio {
                compatible = "regulator-fixed";
                regulator-name = "io_audio_supply";
                regulator-min-microvolt = <1800000>;
                regulator-max-microvolt = <1800000>;
                regulator-boot-on;
        };

	leds {
		pinctrl-names = "default", "sleep";
		pinctrl-0 = <&user_leds_default>;
		pinctrl-1 = <&user_leds_sleep>;

		compatible = "gpio-leds";

		led@1 {
			label = "led1";
			gpios = <&gpio3 17 GPIO_ACTIVE_HIGH>;
			linux,default-trigger = "heartbeat";
			default-state = "on";
		};
	};
};

&am33xx_pinmux {
	pinctrl-names = "default";
	pinctrl-0 = <&clkout2_pin>;

	user_leds_default: user_leds_default {
		pinctrl-single,pins = <
			0x19C ( PIN_OUTPUT_PULLDOWN | MUX_MODE7 ) /* mcasp0_ahclkr.gpio3_17 */
		>;
	};

	user_leds_sleep: user_leds_sleep {
		pinctrl-single,pins = <
			0x19C ( PIN_INPUT_PULLDOWN | MUX_MODE7 ) /* mcasp0_ahclkr.gpio3_17 */
		>;
	};

	my_gpio0_pins_default: my_gpio0_pins_default{
		pinctrl-single,pins = <
			0x060 ( PIN_OUTPUT_PULLUP | MUX_MODE7 ) 	/* gpmc_ad11.gpio0_27  */
			0x018 ( PIN_OUTPUT | MUX_MODE7 ) 		/* lcd_data13.gpio0_9 */
			0x01C ( PIN_OUTPUT | MUX_MODE7 ) 		/* lcd_data14.gpio0_10 */
			0x030 ( PIN_INPUT_PULLUP | MUX_MODE7 ) 		/* lcd_data12.gpio0_8 */
		>;

	};

	my_gpio1_pins_default: my_gpio1_pins_default{
		pinctrl-single,pins = <
			0x040 ( PIN_INPUT_PULLUP | MUX_MODE7 ) 		/* gpmc_ad12.gpio1_12 */
			0x008 ( PIN_INPUT_PULLUP | MUX_MODE7 ) 		/* gpmc_ad2.gpio1_2  */
			0x07C ( PIN_OUTPUT | MUX_MODE7 ) 		/* gpmc_csn0.gpio1_29 */
			0x080 ( PIN_OUTPUT | MUX_MODE7 ) 		/* gpmc_csn1.gpio1_30  */
			0x084 ( PIN_OUTPUT | MUX_MODE7 ) 		/* gpmc_csn2.gpio1_31 */
			0x078 ( PIN_OUTPUT | MUX_MODE7 ) 		/* gpmc_be1n.gpio1_28 */
			0x000 ( PIN_OUTPUT | MUX_MODE7 ) 		/* gpmc_ad0.gpio1_0  */
			0x004 ( PIN_OUTPUT | MUX_MODE7 ) 		/* gpmc_ad1.gpio1_1 */
			0x014 ( PIN_OUTPUT | MUX_MODE7 ) 		/* gpmc_ad5.gpio1_5  */
			0x018 ( PIN_OUTPUT | MUX_MODE7 ) 		/* gpmc_ad6.gpio1_6 */
			0x01C ( PIN_OUTPUT | MUX_MODE7 ) 		/* gpmc_ad7.gpio1_7  */
			0x050 ( PIN_INPUT_PULLUP | MUX_MODE7 ) 		/* gpmc_a4.gpio1_20 */
			0x054 ( PIN_INPUT_PULLUP | MUX_MODE7 ) 		/* gpmc_a5.gpio1_21 */
			0x040 ( PIN_INPUT_PULLUP | MUX_MODE7 ) 		/* gpmc_a0.gpio1_16 */
			0x038 ( PIN_INPUT_PULLUP | MUX_MODE7 ) 		/* gpmc_ad14.gpio1_14 */
			0x070 ( PIN_OUTPUT | MUX_MODE7 ) 		/* gpmc_a10.gpio1_26 */
			0x074 ( PIN_OUTPUT | MUX_MODE7 ) 		/* gpmc_a11.gpio1_27 */		
		>;

	};

	my_gpio2_pins_default: my_gpio2_pins_default{
		pinctrl-single,pins = <
                        0x0F8 ( PIN_OUTPUT | MUX_MODE7 )		/* mmc0_dat1.gpio2_28  */
                        0x0F4 ( PIN_OUTPUT | MUX_MODE7 ) 		/* mmc0_dat2.gpio2_27*/
			0x0E8 ( PIN_OUTPUT_PULLDOWN | MUX_MODE7 ) 	/* lcd_pclk.gpio2_24 */
			0x0B4 ( PIN_OUTPUT_PULLDOWN | MUX_MODE7 ) 	/* lcd_data5.gpio2_11 */
			0x0E0 ( PIN_OUTPUT_PULLDOWN | MUX_MODE7 ) 	/* lcd_vsync.gpio2_22*/
			0x0B0 ( PIN_OUTPUT_PULLDOWN | MUX_MODE7 ) 	/* lcd_data4.gpio2_10*/
			0x0AC ( PIN_OUTPUT_PULLDOWN | MUX_MODE7 ) 	/* lcd_data3.gpio2_9*/
			0x0F0 ( PIN_INPUT_PULLUP | MUX_MODE7 ) 		/* mmc0_dat3.gpio2_26 - */
			0x0BC ( PIN_OUTPUT_PULLDOWN | MUX_MODE7 ) 	/* lcd_data7.gpio2_13  */			
			0x098 ( PIN_OUTPUT | MUX_MODE7 ) 		/* gpmc_wen.gpio2_4 */
			0x094 ( PIN_OUTPUT | MUX_MODE7 ) 		/* gpmc_oen_ren.gpio2_3 */
			0x090 ( PIN_OUTPUT | MUX_MODE7 ) 		/* gpmc_advn_ale.gpio2_2 */
			0x09C ( PIN_OUTPUT | MUX_MODE7 ) 		/* gpmc_be0n_cle.gpio2_5*/
			0x0B8 ( PIN_OUTPUT_PULLDOWN | MUX_MODE7 ) 	/* lcd_data6.gpio2_12 */
			0x0A8 ( PIN_OUTPUT_PULLUP | MUX_MODE7 ) 	/* lcd_data2.gpio2_8 */
			0x0E4 ( PIN_OUTPUT_PULLDOWN | MUX_MODE7 ) 	/* lcd_hsync.gpio2_23*/
		>;

	};

	my_gpio3_pins_default: my_gpio3_pins_default{
		pinctrl-single,pins = <
			0x1A4 ( PIN_INPUT_PULLUP | MUX_MODE7 )	 	/* mcasp0_fsr.gpio3_19  */
			0x1A0 ( PIN_INPUT_PULLUP | MUX_MODE7 ) 		/* mcasp0_aclkr.gpio3_18*/
		>;

	}; 

	uart0_pins: pinmux_uart0_pins {
		pinctrl-single,pins = <
			0x170 (PIN_INPUT_PULLUP | MUX_MODE0)	/* uart0_rxd.uart0_rxd */
			0x174 (PIN_OUTPUT_PULLDOWN | MUX_MODE0)	/* uart0_txd.uart0_txd */
		>;
	};

	uart1_pins: pinmux_uart1_pins {
		pinctrl-single,pins = <
			0x178 (PIN_INPUT | MUX_MODE0)			/* uart1_ctsn.uart1_ctsn */
			0x17C (PIN_OUTPUT_PULLDOWN | MUX_MODE0)		/* uart1_rtsn.uart1_rtsn */
			0x180 (PIN_INPUT_PULLUP | MUX_MODE0)		/* uart1_rxd.uart1_rxd */
			0x184 (PIN_OUTPUT_PULLDOWN | MUX_MODE0) 	/* uart1_txd.uart1_txd */
		>;
	};

	
        i2c0_pins: pinmux_i2c0_pins {
               pinctrl-single,pins = <
                       0x188 (PIN_INPUT_PULLUP | MUX_MODE0)    /* i2c0_sda.i2c0_sda */
                       0x18c (PIN_INPUT_PULLUP | MUX_MODE0)    /* i2c0_scl.i2c0_scl */
               >;
        };

        uart4_pins: pinmux_uart4_pins {
               pinctrl-single,pins = <
                       0x168 (PIN_INPUT_PULLUP    | MUX_MODE1)  /* uart0_ctsn.uart4_rxd */
                       0x16C (PIN_OUTPUT_PULLDOWN | MUX_MODE1)  /* uart0_rtsn.uart4_txd */
               >;
        };

        uart3_pins: pinmux_uart3_pins {
               pinctrl-single,pins = <
                       0x160 (PIN_INPUT_PULLUP    | MUX_MODE1)  /* spi0_cs1.uart3_rxd  */
                       0x138 (PIN_OUTPUT_PULLDOWN | MUX_MODE1)  /* mii1_rxd2.uart3_txd */
               >;
        };

        uart5_pins: pinmux_uart5_pins {
               pinctrl-single,pins = <
                       0x0C4 (PIN_INPUT_PULLUP    | MUX_MODE4)  /* lcd_data9.uart5_rxd  */
                       0x0C0 (PIN_OUTPUT_PULLDOWN | MUX_MODE4)  /* lcd_data8.uart5_txd */
               >;
        };

        uart2_pins: pinmux_uart2_pins {
               pinctrl-single,pins = <
                        0x100 (PIN_INPUT_PULLUP | MUX_MODE3)     /* mmc0_clk.mmc0_clk.uart2_rxd */
                        0x104 (PIN_OUTPUT_PULLDOWN | MUX_MODE3)  /* mmc0_cmd.mmc0_cmd.uart2_txd */
		>;
        };

        clkout2_pin: pinmux_clkout2_pin {
                pinctrl-single,pins = <
                        0x1b4 (PIN_OUTPUT_PULLDOWN | MUX_MODE3) /* xdma_event_intr1.clkout2 */
                >;
        };

	emmc_pins: pinmux_emmc_pins {
		pinctrl-single,pins = <
			0x8C (PIN_INPUT_PULLUP | MUX_MODE3) /* gpmc_clk.mmc2_clk */
			0x88 (PIN_INPUT_PULLUP | MUX_MODE3) /* gpmc_csn3.mmc2_cmd */
			0x30 (PIN_INPUT_PULLUP | MUX_MODE3) /* gpmc_ad12.mmc2_dat0 */
			0x34 (PIN_INPUT_PULLUP | MUX_MODE3) /* gpmc_ad13.mmc2_dat1 */
			0x38 (PIN_INPUT_PULLUP | MUX_MODE3) /* gpmc_ad14.mmc2_dat2 */
			0x3C (PIN_INPUT_PULLUP | MUX_MODE3) /* gpmc_ad15.mmc2_dat3 */
		>;
	};

	cpsw_default: cpsw_default {
		pinctrl-single,pins = <
			/* Slave 1 */
			0x10c (PIN_INPUT_PULLDOWN  | MUX_MODE1)  /* mii1_crs.rmii1_crs_dv */
			0x110 (PIN_INPUT_PULLDOWN  | MUX_MODE1)  /* mii1_rxerr.mii1_rxerr */
			0x114 (PIN_OUTPUT_PULLDOWN | MUX_MODE1)  /* mii1_txen.mii1_txen   */
			0x124 (PIN_OUTPUT_PULLDOWN | MUX_MODE1)  /* mii1_txd1.mii1_txd1   */
			0x128 (PIN_OUTPUT_PULLDOWN | MUX_MODE1)  /* mii1_txd0.mii1_txd0   */
			0x13c (PIN_INPUT_PULLDOWN  | MUX_MODE1)  /* mii1_rxd1.mii1_rxd2   */
			0x140 (PIN_INPUT_PULLDOWN  | MUX_MODE1)  /* mii1_rxd0.mii1_rxd0   */
			0x144 (PIN_INPUT_PULLDOWN  | MUX_MODE0)  /* rmii1_refclk.rmii1_refclk */
		>;
	};

	cpsw_sleep: cpsw_sleep {
		pinctrl-single,pins = <
			/* Slave 1 reset value */
			0x10c (PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x110 (PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x114 (PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x124 (PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x128 (PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x13c (PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x140 (PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x144 (PIN_INPUT_PULLDOWN | MUX_MODE7)
		>;
	};

	davinci_mdio_default: davinci_mdio_default {
		pinctrl-single,pins = <
			/* MDIO */
			0x148 (PIN_INPUT_PULLUP  | SLEWCTRL_FAST | MUX_MODE0)	/* mdio_data.mdio_data */
			0x14c (PIN_OUTPUT_PULLUP | MUX_MODE0)			/* mdio_clk.mdio_clk */
		>;
	};

	davinci_mdio_sleep: davinci_mdio_sleep {
		pinctrl-single,pins = <
			/* MDIO reset value */
			0x148 (PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x14c (PIN_INPUT_PULLDOWN | MUX_MODE7)
		>;
	};

	spi0_pins: pinmux_spi0_pins {
		pinctrl-single,pins = <
			0x150 ( PIN_INPUT_PULLUP | MUX_MODE0 ) /* (A17) spi0_sclk.spi0_sclk */
			0x154 ( PIN_INPUT_PULLUP | MUX_MODE0 ) /* (B17) spi0_d0.spi0_d0 */
			0x158 ( PIN_OUTPUT_PULLUP | MUX_MODE0 ) /* (B16) spi0_d1.spi0_d1 */
			0x15c ( PIN_OUTPUT_PULLUP | MUX_MODE0 ) /* (A16) spi0_cs0.spi0_cs0 */
		>;
	};

	ecap0_pins_default: ecap0_pins_default {
		pinctrl-single,pins = <
			0x164 ( PIN_OUTPUT | MUX_MODE0 ) /* (E18) eCAP0_in_PWM0_out.eCAP0_in_PWM0_out */
		>;
	};

	ehrpwm0_pins: pinmux_ehrpwm0_pins {
		pinctrl-single,pins = <
			0x190 ( PIN_OUTPUT | MUX_MODE1 ) /* (U3) mmc0_sdcd.ehrpwm0A */
			0x194 ( PIN_OUTPUT | MUX_MODE1 ) /* (U4) mcasp0_fsx.ehrpwm0B */
		>;
	};

	ehrpwm1_pins: pinmux_ehrpwm1_pins {
		pinctrl-single,pins = <
			0x0C8 ( PIN_OUTPUT | MUX_MODE2 ) /* (U3) lcd_data10.ehrpwm1A */
			0x0CC ( PIN_OUTPUT | MUX_MODE2 ) /* (U4) lcd_data11.ehrpwm1B */
		>;
	};

	ehrpwm2_pins: pinmux_ehrpwm2_pins {
		pinctrl-single,pins = <
			0x0A0 ( PIN_OUTPUT | MUX_MODE3 ) /* (R1) lcd_data0.ehrpwm2A */
			0x0A4 ( PIN_OUTPUT | MUX_MODE3 ) /* (R2) lcd_data1.ehrpwm2B */
		>;
	};
};

&uart0 {
	pinctrl-names = "default";
	pinctrl-0 = <&uart0_pins>;
	status = "okay";
};

&uart1 {
	pinctrl-names = "default";
	pinctrl-0 = <&uart1_pins>;
	status = "okay";
};

&uart2 {
	pinctrl-names = "default";
	pinctrl-0 = <&uart2_pins>;
	status = "okay";
};

&uart3 {
        pinctrl-names = "default";
        pinctrl-0 = <&uart3_pins>;
        status = "okay";
};

&uart4 {
        pinctrl-names = "default";
        pinctrl-0 = <&uart4_pins>;
        status = "okay";
};

&uart5 {
        pinctrl-names = "default";
        pinctrl-0 = <&uart5_pins>;
        status = "okay";
};

&i2c0 {
        pinctrl-names = "default";
        pinctrl-0 = <&i2c0_pins>;
        status = "okay";
        clock-frequency = <400000>;
	
	  tlv320aic3106: tlv320aic3106@18 {
             	compatible = "ti,tlv320aic3106";
             	reg = <0x18>;
             	ai3x-micbias-vg = <1>;
             	status = "okay";

             	/* Regulators */
             	AVDD-supply  = <&core_audio_supply>;
            	IOVDD-supply = <&core_audio_supply>;
             	DRVDD-supply = <&core_audio_supply>;
             	DVDD-supply  = <&io_audio_supply>;
	  };
	
	  pcf8563: pcf8563@51 {
          	compatible = "nxp,pcf8563";
             	reg = <0x51>;
          };
};


&mmc3 {
	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&emmc_pins>;
        vmmc-supply = <&vmmcsd_fixed>;
	bus-width = <4>;
	ti,non-removable;
	dmas = <&edma_xbar 12 0 1
                &edma_xbar 13 0 2>;
        dma-names = "tx", "rx";
};

&tscadc {
        status = "okay";
        tsc {
                ti,wires = <4>;
                ti,x-plate-resistance = <200>;
                ti,coordinate-readouts = <5>;
                ti,wire-config = <0x00 0x11 0x22 0x33>;
        };
        adc {
                ti,adc-channels = <4 5 6 7>;
        };
};

&mac {
	slaves = <1>;
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&cpsw_default>;
	pinctrl-1 = <&cpsw_sleep>;
	status = "okay";
};

&davinci_mdio {
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&davinci_mdio_default>;
	pinctrl-1 = <&davinci_mdio_sleep>;
	status = "okay";
};

&cpsw_emac0 {
	phy_id = <&davinci_mdio>, <0>;
	phy-mode = "rmii";
};

&phy_sel {
	rmii-clock-ext;
};

&rtc {
	system-power-controller;
};

/*
&lcdc {
      status = "okay";
};
*/

&sgx {
      status = "okay";
};

&usb {
      status = "okay";
};

&usb_ctrl_mod {
      status = "okay";
};

&usb0_phy {
     status = "okay";
};

&usb1_phy {
     status = "okay";
};

&usb0 {
     status = "okay";
     dr_mode = "peripheral";
};

&usb1 {
     status = "okay";
     dr_mode = "host";
};

&cppi41dma  {
     status = "okay";
};

/*
 * SPI Flash (1MiB)
 * 0x000000 - 0x01FFFF : SPL (128KiB)
 * 0x020000 - 0x09FFFF : U-Boot (512KiB)
 * 0x0A0000 - 0x0BFFFF : First copy of U-Boot Environment (128KiB)
 * 0x0C0000 - 0x0DFFFF : Second copy of U-Boot Environment (128KiB)
 */
&spi0 {
	pinctrl-names = "default";
	pinctrl-0 = <&spi0_pins>;
	status = "okay";

	flash: s25fl064k@0 {
		 #address-cells = <1>;
		 #size-cells = <1>;
		 compatible = "st,s25fl064k";
		 spi-max-frequency = <25000000>;
		 reg = <0>;


		 partition@0 {
			 label = "u-boot-spl";
			 reg = <0x000000 0x020000>;
		 };


		 partition@1 {
			 label = "u-boot";
			 reg = <0x020000 0x080000>;
		 };

		 partition@2 {
			 label = "env1";
			 reg = <0x0A0000 0x010000>;
		 };

		 partition@3 {
			 label = "env2";
			 reg = <0x0B0000 0x010000>;
		 };

	};
};

&epwmss0 {
	status = "okay";

	ecap0: ecap@48300100 {
		status = "okay";
		pinctrl-names = "default";
		pinctrl-0 = <&ecap0_pins_default>;
	};

	ehrpwm0: ehrpwm@48300200 {
		status = "okay";
		pinctrl-names = "default";
		pinctrl-0 = <&ehrpwm0_pins>;
	};
};

&epwmss1 {
	status = "okay";

	ehrpwm1: ehrpwm@48302200 {
		status = "okay";
		pinctrl-names = "default";
		pinctrl-0 = <&ehrpwm1_pins>;
	};
};


&epwmss2 {
	status = "okay";

	ehrpwm2: ehrpwm@48304200 {
		status = "okay";
		pinctrl-names = "default";
		pinctrl-0 = <&ehrpwm2_pins>;
	};
};

I am trying to control the pins in userspace using



echo 91 > /sys/class/gpio/export
echo 92 > /sys/class/gpio/export

echo out > /sys/class/gpio/gpio91/direction
echo out > /sys/class/gpio/gpio92/direction

echo1 > /sys/class/gpio/gpio91/value
echo 0 > /sys/class/gpio/gpio92/value