View Single Post
Old 11-18-2012, 11:11 AM   #8
h1uke
Zealot
h1uke can do the Funky Gibbon.h1uke can do the Funky Gibbon.h1uke can do the Funky Gibbon.h1uke can do the Funky Gibbon.h1uke can do the Funky Gibbon.h1uke can do the Funky Gibbon.h1uke can do the Funky Gibbon.h1uke can do the Funky Gibbon.h1uke can do the Funky Gibbon.h1uke can do the Funky Gibbon.h1uke can do the Funky Gibbon.
 
Posts: 121
Karma: 82565
Join Date: Aug 2010
Location: Maryland, USA
Device: dxg, k3w,k4nt,kpw
Quote:
Originally Posted by geekmaster View Post
That "factory cable" at your first link is just a homebrew microUSB cable, with the addition of a 1K resistor on the ID pin. Does the PW support that? It would be great if this can be done with such a cable.
u-boot/ imx50_yoshi.c says (CONFIG_BIST, CONFIG_CMD_PMIC and CONFIG_CMD_IDME are defined):

Spoiler:
Code:
inline int check_boot_mode(void) 
{
	char boot_mode[20];
	char boot_cmd[20];

#ifdef CONFIG_BIST
	setenv("bootdelay", "-1");
#endif

#if defined(CONFIG_CMD_IDME)
	if (idme_get_var("bootmode", boot_mode, 20)) 
#endif
	{
	    return -1;
	}

	boot_cmd[0] = 0;

	if (!strncmp(boot_mode, "diags", 5)) {
	    printf ("BOOTMODE OVERRIDE: DIAGS\n");
	    strcpy(boot_cmd, "run bootcmd_diags");
	} else if (!strncmp(boot_mode, "fastboot", 8)) {
	    printf ("BOOTMODE OVERRIDE: FASTBOOT\n");
	    strcpy(boot_cmd, "run bootcmd_fastboot");
	} else if (!strncmp(boot_mode, "factory", 7)) {
#if defined(CONFIG_PMIC)
	    if (pmic_charging()) {
		char *cmd = (char *) CONFIG_BISTCMD_LOCATION;		
		/* Ignore any bist commands */
		cmd[0] = 0;

		printf ("BOOTMODE OVERRIDE OVERRIDE: DIAGS\n");

#if defined(CONFIG_CMD_IDME)
		/* Update bootmode idme var */
		idme_update_var("bootmode", "diags");
#endif
		/* Set the bootcmd to diags and boot immediately */
		setenv("bootcmd", "run bootcmd_diags");
		setenv("bootdelay", "0");
		
		return 0;

	    }
#endif	//CONFIG_PMIC
	    printf ("BOOTMODE OVERRIDE: FACTORY\n");
	    strcpy(boot_cmd, "run bootcmd_factory");
	} else if (!strncmp(boot_mode, "reset", 7)) {
	    printf ("BOOTMODE OVERRIDE: RESET\n");
	    strcpy(boot_cmd, "bist reset");
	} else if (!strncmp(boot_mode, "main", 4)) {
	    /* clear bootargs */
	    setenv("bootargs", "\0");

	    /* set bootcmd back to default */
	    sprintf(boot_cmd, "bootm 0x%x", CONFIG_MMC_BOOTFLASH_ADDR);
	    return 0;
	} else {
	    return 0;
	}
	
	setenv("bootcmd", boot_cmd);

	return 0;
}


i.e. the diag mode is forced if pmic_charging() returns nonzero:

Spoiler:
Code:
int pmic_charging(void)
{
    int ret;
    unsigned sense_0 = 0;

    /* Detect if a cable is inserted */
    ret = pmic_read_reg(MC34708_REG_INT_SENSE0, &sense_0);
    if (!ret)
	return 0;

    DBG("snse: 0x%x\n\n", sense_0);

    return ((sense_0 & INT0_USBDETS) != 0);
}


and this, in turns, is based in INT0_USBDETS which, according to the datasheet reflects
the voltage applied to the ID pin (#4)

Quote:
Originally Posted by geekmaster View Post
Some "host mode" adapter cables already have such a jumper. It could be interesting to see if one of those can be used.
as far as I know, the host mode cables have this ID wire grounded.
h1uke is offline   Reply With Quote