Monthly Archives: May 2019

VoCore2: Ethernet x5 + SD card mode

MT7628AN has a weird design. Ethernet port 1,2,3,4 must be all on or all off, that means if use you only one of them, rest 15 pins you have to use as ethernet but can not work in GPIO mode or SD card mode.
So how can we have SD card mode also have more than one ethernet port.

There is a hidden register, we find in mediatek SDcard driver, and I also hacked a router to get the pins out, pins can be find at vocore.io/v2.html

Here is the patch:

--- a/drivers/mmc/host/mtk-mmc/sd.c
+++ b/drivers/mmc/host/mtk-mmc/sd.c
@@ -2739,7 +2739,7 @@
     struct msdc_host *host;
     struct msdc_hw *hw;
     int ret, irq;
-	u32 reg;
+	u32 reg, reg1;
 
     printk("MTK MSDC device init.\n");
     mtk_sd_device.dev.platform_data = &msdc0_hw;
@@ -2754,8 +2754,11 @@
 	//#elif defined (CONFIG_RALINK_MT7628)
 		/* TODO: maybe omitted when RAether already toggle AGPIO_CFG */
 		reg = sdr_read32((volatile u32*)(RALINK_SYSCTL_BASE + 0x3c));
-		reg |= 0x1e << 16;
+		reg &= ~(0x1e << 16);
 		sdr_write32((volatile u32*)(RALINK_SYSCTL_BASE + 0x3c), reg);
+		reg = sdr_read32((volatile u32*)(RALINK_SYSCTL_BASE + 0x60)) & ~(0x3<<0) & ~(0x3<<6) & ~(0x3<<10) & ~(0x1<<15) & ~(0x3<<20) & ~(0x3<<24) | (0x1<<0) | (0x1<<6) | (0x1<<10) | (0x1<<15) | (0x1<<20) | (0x1<<24);
+		reg1 = sdr_read32((volatile u32*)(RALINK_SYSCTL_BASE + 0x1340)) | (0x1<<11); //Normal mode(AP mode) , SDXC CLK=PAD_GPIO0=GPIO11, driving = 8mA
+		sdr_write32((volatile u32*)(RALINK_SYSCTL_BASE + 0x1340), reg1);
 
- 		reg = sdr_read32((volatile u32*)(RALINK_SYSCTL_BASE + 0x60)) & ~(0x3<<10);
 #if defined (CONFIG_MTK_MMC_EMMC_8BIT)