一、u-Boot升级灯
运行u-Boot程序时LED灯闪烁,找到运行过程中一直在运行的函数在里面进行LED引脚电平的翻转
宏定义
Z:\SunFan\AHD580\pip\na51055_PIP\BSP\u-boot\include\configs\nvt-na51055-evb.h
Z:\SunFan\AHD580\pip\na51055_PIP\BSP\u-boot\drivers\mtd\nvt_flash_spi\nvt_flash_spi_cmd.c
自带led引脚电平设置函数
/* LED function for FW update*/
static void led_set_gpio_high(int operation)
{
u32 gpio_reg;
int ofs = NVT_LED_RED_PIN/32;
int shift = NVT_LED_RED_PIN & 0x1F;
ofs = ofs*0x4;
/*Set gpio as high*/
gpio_reg = INW(IOADDR_GPIO_REG_BASE + 0x20 + ofs);
#if 0
if (gpio_reg & (1 << shift))
RESTORE_GPIO_DIR = 1;
else {
gpio_reg |= (1 << shift);
OUTW(IOADDR_GPIO_REG_BASE + 0x20 + ofs, gpio_reg);
}
#else
gpio_reg |= (1 << shift);
OUTW(IOADDR_GPIO_REG_BASE + 0x20 + ofs, gpio_reg);
#endif
OUTW(IOADDR_GPIO_REG_BASE + 0x40 + ofs, (1 << shift));
//LED BLUE
ofs = NVT_LED_BLUE_PIN/32;
shift = NVT_LED_BLUE_PIN & 0x1F;
ofs = ofs*0x4;
gpio_reg = INW(IOADDR_GPIO_REG_BASE + 0x20 + ofs);
gpio_reg |= (1 << shift);
OUTW(IOADDR_GPIO_REG_BASE + 0x20 + ofs, gpio_reg);
OUTW(IOADDR_GPIO_REG_BASE + 0x40 + ofs, (1 << shift));
#if 0 // do not use delay!!! it will slow down flash erase/program!!!
/*Config duration*/
if (operation)
mdelay(NVT_LED_PROGRAM_DURATION);
else
mdelay(NVT_LED_ERASE_DURATION);
#endif
}
static void led_set_gpio_low(void)
{
//u32 gpio_reg;
int ofs = NVT_LED_RED_PIN/32;
int shift = NVT_LED_RED_PIN & 0x1F;
ofs = ofs*0x4;
/*Set gpio as low*/
OUTW(IOADDR_GPIO_REG_BASE + 0x60 + ofs, (1 << shift));
//LED BLUE
ofs = NVT_LED_BLUE_PIN/32;
shift = NVT_LED_BLUE_PIN & 0x1F;
ofs = ofs*0x4;
OUTW(IOADDR_GPIO_REG_BASE + 0x60 + ofs, (1 << shift));
#if 0
/*Force gpio direction as original config*/
if (!(RESTORE_GPIO_DIR)) {
gpio_reg = INW(IOADDR_GPIO_REG_BASE + 0x20 + ofs);
gpio_reg &= ~(1 << shift);
OUTW(IOADDR_GPIO_REG_BASE + 0x20 + ofs, gpio_reg);
RESTORE_GPIO_DIR = 0;
}
#endif
}
在spiNand_programPage和nand_cmd_erase_block里面进行计数电平翻转