Esempio n. 1
0
int misc_init_r(void)
{
    u32 keys;
    char *s;
    int want_recovery;

    /* we use bus I2C-0 for the on-board eeprom */
    i2c_set_bus_num(0);

    /* setup GPIO directions and initial values */
    gpio_configure();

    /*
     * enforce the start of the recovery system when
     * - the appropriate keys were pressed
     * - "some" external software told us to
     * - a previous installation was aborted or has failed
     */
    want_recovery = 0;
    keys = gpio_querykbd();
    if (gpio_diag)
        printf("GPIO keyboard status [0x%02X]\n", keys);
    if ((keys & GPIOKEY_BITS_RECOVERY) == GPIOKEY_BITS_RECOVERY) {
        printf("detected recovery request (keyboard)\n");
        want_recovery = 1;
    }
    s = getenv("want_recovery");
    if ((s != NULL) && (*s != '\0')) {
        printf("detected recovery request (environment)\n");
        want_recovery = 1;
    }
    s = getenv("install_in_progress");
    if ((s != NULL) && (*s != '\0')) {
        printf("previous installation has not completed\n");
        want_recovery = 1;
    }
    s = getenv("install_failed");
    if ((s != NULL) && (*s != '\0')) {
        printf("previous installation has failed\n");
        want_recovery = 1;
    }
    if (want_recovery) {
        printf("enforced start of the recovery system\n");
        setenv("bootcmd", "run recovery");
    }

    /*
     * boot the recovery system without waiting; boot the
     * production system without waiting by default, only
     * insert a pause (to provide a chance to get a prompt)
     * when GPIO keys were pressed during power on
     */
    if (want_recovery)
        setenv("bootdelay", "0");
    else if (!keys)
        setenv("bootdelay", "0");
    else
        setenv("bootdelay", "2");

    /* get the ethernet MAC from I2C EEPROM */
    mac_read_from_eeprom();

    return 0;
}
Esempio n. 2
0
File: ac14xx.c Progetto: JamesAng/ub
int misc_init_r(void)
{
	u32 keys;
	char *s;
	int want_recovery;

	/* we use bus I2C-0 for the on-board eeprom */
	i2c_set_bus_num(0);

	/* setup GPIO directions and initial values */
	gpio_configure();

	/*
	 * check the GPIO keyboard,
	 * enforced start of the recovery when
	 * - the appropriate keys were pressed
	 * - a previous installation was aborted or has failed
	 * - "some" external software told us to
	 */
	want_recovery = 0;
	keys = gpio_querykbd();
	printf("GPIO keyboard status [0x%08X]\n", keys);
	/* XXX insist in the _exact_ combination? */
	if ((keys & GPIOKEY_BITS_RECOVERY) == GPIOKEY_BITS_RECOVERY) {
		printf("GPIO keyboard requested RECOVERY\n");
		/* XXX TODO
		 * refine the logic to detect the first keypress, and
		 * wait to recheck IF it was the recovery combination?
		 */
		want_recovery = 1;
	}
	s = getenv("install_in_progress");
	if ((s != NULL) && (*s != '\0')) {
		printf("previous installation aborted, running RECOVERY\n");
		want_recovery = 1;
	}
	s = getenv("install_failed");
	if ((s != NULL) && (*s != '\0')) {
		printf("previous installation FAILED, running RECOVERY\n");
		want_recovery = 1;
	}
	s = getenv("want_recovery");
	if ((s != NULL) && (*s != '\0')) {
		printf("running RECOVERY according to the request\n");
		want_recovery = 1;
	}

	if (want_recovery)
		setenv("bootcmd", "run recovery");

	/*
	 * boot the recovery system without waiting; boot the
	 * production system without waiting by default, only
	 * insert a pause (to provide a chance to get a prompt)
	 * when GPIO keys were pressed during power on
	 */
	if (want_recovery)
		setenv("bootdelay", "0");
	else if (!keys)
		setenv("bootdelay", "0");
	else
		setenv("bootdelay", "2");

	/* get the ethernet MAC from I2C EEPROM */
	mac_read_from_eeprom();

	return 0;
}