OpenWrt Forum Archive

Topic: OpenWrt CC 15.05 Linux kernel 3.18 - MTK7621A gpio

The content of this topic has been archived on 26 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi All,

I have compiled openwrt CC 15.05 for MT7621A. I can login using console, see web server on LAN.

now I wan to use GPIO#6 as a reset configuration to default pin. for that I need to use this pin as a input
button.
I trace source to get

build_dir/target-mipsel_1004kc+dsp_uClibc-0.9.33.2/linux-ramips_mt7621/linux-3.18.21/arch/mips/ralink/mt7621.c

where gpio are configured. This is yet now clear but I found I can control gpio#10 using sys/class/gpio as a output
but gpio#6 as a input do not read value after button press.

gpio#6 is multi function pin UART3 CTS3_N/GPIO and need to be configured in GPIO MODE register.

I want to make sure it is gpio and not UART3 pin but sys get gpio6, but still I just want to make sure it is gpio pin.

in ralink/mt7621.c

static struct rt2880_pmx_group mt7621_pinmux_data[] = {
        GRP("uart1", uart1_grp, 1, MT7621_GPIO_MODE_UART1),
        GRP("i2c", i2c_grp, 1, MT7621_GPIO_MODE_I2C),
        GRP("uart3", uart2_grp, 1, MT7621_GPIO_MODE_UART2),
        GRP("uart2", uart3_grp, 1, MT7621_GPIO_MODE_UART3),
        GRP("jtag", jtag_grp, 1, MT7621_GPIO_MODE_JTAG),
        GRP_G("wdt", wdt_grp, MT7621_GPIO_MODE_WDT_MASK,
                MT7621_GPIO_MODE_WDT_GPIO, MT7621_GPIO_MODE_WDT_SHIFT),
        GRP_G("pcie", pcie_rst_grp, MT7621_GPIO_MODE_PCIE_MASK,
                MT7621_GPIO_MODE_PCIE_GPIO, MT7621_GPIO_MODE_PCIE_SHIFT),
        GRP("mdio", mdio_grp, 1, MT7621_GPIO_MODE_MDIO),
        GRP("rgmii2", rgmii2_grp, 1, MT7621_GPIO_MODE_RGMII2),
        GRP_G("spi", spi_grp, MT7621_GPIO_MODE_SPI_MASK,
                MT7621_GPIO_MODE_SPI_GPIO, MT7621_GPIO_MODE_SPI_SHIFT),
        GRP_G("sdhci", sdhci_grp, MT7621_GPIO_MODE_SDHCI_MASK,
                MT7621_GPIO_MODE_SDHCI_GPIO, MT7621_GPIO_MODE_SDHCI_SHIFT),
        GRP("rgmii1", rgmii1_grp, 1, MT7621_GPIO_MODE_RGMII1),
        { 0 }
};

here

GRP("uart3", uart2_grp, 1, MT7621_GPIO_MODE_UART2),
GRP("uart2", uart3_grp, 1, MT7621_GPIO_MODE_UART3),

above is bit confusing or is it bug that urt2 is mixed with uar3 ??????

I want to disable UART3 and expect gpio#6 will be gpio only as it is gpio after reset by default.

Is there any good link or info about gpio for CC version ??
any hint will be appreciated!!
Thanks in advance !

To know others, I could make gpio#6 work.
it was hardware issue.

But my modification is comment uart2, uart3 and create new group which is gpio. My check on device console got that this pins are already in gpio mode and not in uart as device tree (dts) files declare it as a gpio but that is bit confusing so I explicitly declared it as a gpio group.

set push button in dts.

uart3, uart2 as above is confusing as both group mixed with name so it seems like it is typooooo!

I tested events of push button using:

root@OpenWrt:/# thd --dump /dev/input/event0
root@OpenWrt:/# cat /dev/input/event0 | hexdump

it works smile

The discussion might have continued from here.