Hi,
Yeah, probably I'm a thread necromancer... But I think I found why (when, how) the official Omega2 image sets AGPIO to digital IO, and which is not done by the original LEDE project.
I did the following trick, and it seems it succeeded: I connect one channel of my scope to one of the GPIOs (GPIO17
) which was ~1.65V by default during boot and changed to 0V at a point in time and I attached the other probe to the TX line.
As it clearly show the next screenshot, the line switched to digital at SD card initialization:
It changes right after the kernel prints MSDC device init.
. So, I searched for it in the kernel source and I found.
Here is the corresponding snippet (it is located in linux-4.9.37/drivers/mmc/host/mtk-mmc/sd.c
static int __init mt_msdc_init(void)
{
int ret;
/* +++ by chhung */
u32 reg;
#if defined (CONFIG_MTD_ANY_RALINK)
extern int ra_check_flash_type(void);
if(ra_check_flash_type() == 2) { /* NAND */
printk("%s: !!!!! SDXC Module Initialize Fail !!!!!", __func__);
return 0;
}
#endif
printk("MTK MSDC device init.\n");
mtk_sd_device.dev.platform_data = &msdclinux-4.9.37/drivers/mmc/host/mtk-mmc/sd.c0_hw;
if (ralink_soc == MT762X_SOC_MT7620A || ralink_soc == MT762X_SOC_MT7621AT) {
//#if defined (CONFIG_RALINK_MT7620) || defined (CONFIG_RALINK_MT7621)
reg = sdr_read32((volatile u32*)(RALINK_SYSCTL_BASE + 0x60)) & ~(0x3<<18);
//#if defined (CONFIG_RALINK_MT7620)
if (ralink_soc == MT762X_SOC_MT7620A)
reg |= 0x1<<18;
//#endif
} else {
//#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;
sdr_write32((volatile u32*)(RALINK_SYSCTL_BASE + 0x3c), reg);
reg = sdr_read32((volatile u32*)(RALINK_SYSCTL_BASE + 0x60)) & ~(0x3<<10);
#if defined (CONFIG_MTK_MMC_EMMC_8BIT)
reg |= 0x3<<26 | 0x3<<28 | 0x3<<30;
msdc0_hw.data_pins = 8,
#endif
//#endif
}
sdr_write32((volatile u32*)(RALINK_SYSCTL_BASE + 0x60), reg);
//platform_device_register(&mtk_sd_device);
/* end of +++ */
ret = platform_driver_register(&mt_msdc_driver);
if (ret) {
printk(KERN_ERR DRV_NAME ": Can't register driver");
return ret;
}
printk(KERN_INFO DRV_NAME ": MediaTek MT6575 MSDC Driver\n");
#if defined (MT6575_SD_DEBUG)
msdc_debug_proc_init();
#endif
return 0;
}
It contains the part which actually do the job:
reg = sdr_read32((volatile u32*)(RALINK_SYSCTL_BASE + 0x3c));
reg |= 0x1e << 16;
sdr_write32((volatile u32*)(RALINK_SYSCTL_BASE + 0x3c), reg);
It sets all the four bits of AGPIO_CFG
(EPHY_GPIO_AIO_EN
, bit 20..17 (GPIO14
, GPIO15
, GPIO16
and GPIO17
)) to 1
- thus enabling them as digital GPIO.
So, it does not happen in any user space utility (like swconfig
), but it happens in the kernel by enabling SD card.
Hope this is still useful for some of you
/sza2