MT7688AN的管脚复用pinmux

主要参考资料 :不用Libmraa一样可以控制GPIO

http://makerpro.cc/2016/04/how-to-control-7688-gpio-without-libmraa/

下载

https://raw.githubusercontent.com/MediaTek-Labs/linkit-smart-7688-feed/master/mtk-linkit/src/pinmux.c

编译

/opt/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mipsel-openwrt-linux-gcc 
-L/opt/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/lib 
-L/opt/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/usr/lib 
pinmux.c 

在LEDE环境

/LEDE/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16/bin/mipsel-openwrt-linux-gcc -L/LEDE/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16/lib -L//LEDE/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16/usr/lib pinmux.c

运行

 ./pinmux get
Group i2c - i2c [gpio] 
Group uart0 - [uart] gpio 
Group uart1 - [uart] gpio 
Group uart2 - [uart] gpio pwm 
Group pwm0 - pwm [gpio] 
Group pwm1 - pwm [gpio] 
Group refclk - refclk [gpio] 
Group spi_s - spi_s [gpio] 
Group spi_cs1 - spi_cs1 [gpio] refclk 
Group i2s - i2s [gpio] pcm 
Group ephy - ephy [gpio] 
Group wled - [wled] gpio 

相关下载
http://labs.mediatek.com/zh-cn/download/AGSSkG38 (OpenWRT SDK For Linux)
http://labs.mediatek.com/zh-cn/download/50WkbgbH (MT7688 DataSheet)

在 LEDE/target/linux/ramips/dts/mt7628an.dtsi 中有

		uartlite: uartlite@c00 {
			compatible = "ns16550a";
			reg = <0xc00 0x100>;

			reg-shift = <2>;
			reg-io-width = <4>;
			no-loopback-test;

			clock-frequency = <40000000>;

			resets = <&rstctrl 12>;
			reset-names = "uartl";

			interrupt-parent = <&intc>;
			interrupts = <20>;

			pinctrl-names = "default";
			pinctrl-0 = <&uart0_pins>;
		};


		uart1: uart1@d00 {
			compatible = "ns16550a";
			reg = <0xd00 0x100>;

			reg-shift = <2>;
			reg-io-width = <4>;
			no-loopback-test;

			clock-frequency = <40000000>;

			resets = <&rstctrl 19>;
			reset-names = "uart1";

			interrupt-parent = <&intc>;
			interrupts = <21>;

			pinctrl-names = "default";
			pinctrl-0 = <&uart1_pins>;

			status = "disabled";
		};

		uart2: uart2@e00 {
			compatible = "ns16550a";
			reg = <0xe00 0x100>;

			reg-shift = <2>;
			reg-io-width = <4>;
			no-loopback-test;

			clock-frequency = <40000000>;

			resets = <&rstctrl 20>;
			reset-names = "uart2";

			interrupt-parent = <&intc>;
			interrupts = <22>;

			pinctrl-names = "default";
			pinctrl-0 = <&uart2_pins>;

			status = "disabled";
		};

初始化

arch/mips/include/asm/mach-ralink/mt7620.h:          #define MT7620_SYSC_BASE		0x10000000
arch/mips/include/asm/mach-ralink/mt7620.h:          #define SYSC_REG_CHIP_NAME0	0x00

void __iomem *sysc = (void __iomem *) KSEG1ADDR(MT7620_SYSC_BASE);  //将寄存器基址 从物理地址 转换成  进程空间的虚拟机制

//读取Chip ID
n0 = __raw_readl(sysc + SYSC_REG_CHIP_NAME0);
n1 = __raw_readl(sysc + SYSC_REG_CHIP_NAME1);


u32 xcfg = __raw_readl(sysc + 0x3C);
xcfg |= 0x0F;      //bit3-0  is2 pad
xcfg |= 0x10;      //bit4    refclko
xcfg |= 0x0f<<17;   //ephy 
__raw_write1(cfg, syc+0x3c);

参考资料:
https://wiki.openwrt.org/doc/devel/add.new.device
https://wiki.openwrt.org/doc/hardware/port.gpio

本文章由作者:佐须之男 整理编辑,原文地址: MT7688AN的管脚复用pinmux
本站的文章和资源来自互联网或者站长的原创,按照 CC BY -NC -SA 3.0 CN协议发布和共享,转载或引用本站文章应遵循相同协议。如果有侵犯版权的资 源请尽快联系站长,我们会在24h内删除有争议的资源。欢迎大家多多交流,期待共同学习进步。

相关推荐