Ejemplo n.º 1
0
/*------------------------------------------------------------------------------*/
void df_recovery(AT91PS_DF pDf)
{
#if (AT91C_SPI_PCS_DATAFLASH == AT91C_SPI_PCS1_DATAFLASH)
    /*
     * Configure PIOs 
     */
    const struct pio_desc bp4_pio[] = {
        {"BP4", AT91C_PIN_PA(31), 0, PIO_PULLUP, PIO_INPUT},
        {(char *)0, 0, 0, PIO_DEFAULT, PIO_PERIPH_A},
    };

    /*
     * Configure the PIO controller 
     */
    writel((1 << AT91C_ID_PIOA), PMC_PCER + AT91C_BASE_PMC);
    pio_setup(bp4_pio);

    /*
     * If BP4 is pressed during Boot sequence 
     */
    /*
     * Erase NandFlash block 0
     */
    if (!pio_get_value(AT91C_PIN_PA(31)))
        df_page_erase(pDf, 0);
#endif
}
Ejemplo n.º 2
0
/*------------------------------------------------------------------------------*/
static void nand_recovery(void)
{
    /*
     * Configure PIOs 
     */
    const struct pio_desc bp4_pio[] = {
        {"BP4", AT91C_PIN_PA(31), 0, PIO_PULLUP, PIO_INPUT},
        {(char *)0, 0, 0, PIO_DEFAULT, PIO_PERIPH_A},
    };

    /*
     * Configure the PIO controller 
     */
    writel((1 << AT91C_ID_PIOA), PMC_PCER + AT91C_BASE_PMC);
    pio_setup(bp4_pio);

    /*
     * If BP4 is pressed during Boot sequence 
     */
    /*
     * Erase NandFlash block 0
     */
    if (!pio_get_value(AT91C_PIN_PA(31)))
        AT91F_NandEraseBlock0();
}
Ejemplo n.º 3
0
static inline int read_wire_bit()
{
	return pio_get_value(CONFIG_SYS_ONE_WIRE_PIN);
}
Ejemplo n.º 4
0
int spi_flash_recovery(struct spi_flash *flash)
{
	const struct spi_flash_erase_map *map = &flash->erase_map;
	const struct spi_flash_erase_region *cur_region, *region = NULL;
	const struct spi_flash_erase_command *cur_erase, *erase = NULL;
	int i, ret;

	/*
	 * If Recovery Button is pressed during boot sequence,
	 * erase dataflash page0
	 */
	dbg_info("SF: Press the recovery button (%s) to recovery\n",
		 RECOVERY_BUTTON_NAME);

	if ((pio_get_value(CONFIG_SYS_RECOVERY_BUTTON_PIN)) == 0) {
		dbg_info("SF: The recovery button (%s) has been pressed,\n",
			 RECOVERY_BUTTON_NAME);
		dbg_info("SF: The page 0 is erasing...\n");

		/* Get the erase region for offset 0. */
		for (i = 0; i < map->num_regions; i++) {
			cur_region = &map->regions[i];

			if (!(cur_region->offset & ~SFLASH_CMD_ERASE_MASK)) {
				region = cur_region;
				break;
			}
		}

		if (!region) {
			dbg_info("SF: Can't find erase region for offset 0\n");
			return -1;
		}

		/* Get the smallest erase size of the region. */
		for (i = 0; i < SFLASH_CMD_ERASE_MAX; i++) {
			cur_erase = &map->commands[i];

			if (!(region->offset & (0x1UL << i)))
				continue;

			if (!erase || erase->size > cur_erase->size)
				erase = cur_erase;
		}

		if (!erase) {
			dbg_info("SF: Can't find erase command for offset 0\n");
			return -1;
		}

		/* Erase the smallest sector/block at offset 0. */
		ret = spi_flash_erase(flash, 0, erase->size);
		if (ret) {
			dbg_info("SF: The erasing failed\n");
			return ret;
		}
		dbg_info("SF: The erasing is done\n");

		return 0;
	}

	return -1;
}