X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fflash%2Flpc3180_nand_controller.c;h=de6d4e2bf8f7fccc62f439ae381e493e3c3b4b23;hb=5b352c9e79b5174b95adc52db7a65ef67b7da2c3;hp=06048085b5823d080227885955c296914bb429a6;hpb=95e13054cafeeb13163d85822e4202e12007e1a7;p=fw%2Fopenocd diff --git a/src/flash/lpc3180_nand_controller.c b/src/flash/lpc3180_nand_controller.c index 06048085b..de6d4e2bf 100644 --- a/src/flash/lpc3180_nand_controller.c +++ b/src/flash/lpc3180_nand_controller.c @@ -28,12 +28,12 @@ static int lpc3180_nand_device_command(struct command_context_s *cmd_ctx, char * static int lpc3180_register_commands(struct command_context_s *cmd_ctx); static int lpc3180_init(struct nand_device_s *device); static int lpc3180_reset(struct nand_device_s *device); -static int lpc3180_command(struct nand_device_s *device, u8 command); -static int lpc3180_address(struct nand_device_s *device, u8 address); -static int lpc3180_write_data(struct nand_device_s *device, u16 data); +static int lpc3180_command(struct nand_device_s *device, uint8_t command); +static int lpc3180_address(struct nand_device_s *device, uint8_t address); +static int lpc3180_write_data(struct nand_device_s *device, uint16_t data); static int lpc3180_read_data(struct nand_device_s *device, void *data); -static int lpc3180_write_page(struct nand_device_s *device, u32 page, u8 *data, u32 data_size, u8 *oob, u32 oob_size); -static int lpc3180_read_page(struct nand_device_s *device, u32 page, u8 *data, u32 data_size, u8 *oob, u32 oob_size); +static int lpc3180_write_page(struct nand_device_s *device, uint32_t page, uint8_t *data, uint32_t data_size, uint8_t *oob, uint32_t oob_size); +static int lpc3180_read_page(struct nand_device_s *device, uint32_t page, uint8_t *data, uint32_t data_size, uint8_t *oob, uint32_t oob_size); static int lpc3180_controller_ready(struct nand_device_s *device, int timeout); static int lpc3180_nand_ready(struct nand_device_s *device, int timeout); @@ -100,7 +100,7 @@ static int lpc3180_register_commands(struct command_context_s *cmd_ctx) return ERROR_OK; } -static int lpc3180_pll(int fclkin, u32 pll_ctrl) +static int lpc3180_pll(int fclkin, uint32_t pll_ctrl) { int bypass = (pll_ctrl & 0x8000) >> 15; int direct = (pll_ctrl & 0x4000) >> 14; @@ -131,7 +131,7 @@ static int lpc3180_pll(int fclkin, u32 pll_ctrl) static float lpc3180_cycle_time(lpc3180_nand_controller_t *lpc3180_info) { target_t *target = lpc3180_info->target; - u32 sysclk_ctrl, pwr_ctrl, hclkdiv_ctrl, hclkpll_ctrl; + uint32_t sysclk_ctrl, pwr_ctrl, hclkdiv_ctrl, hclkpll_ctrl; int sysclk; int hclk; int hclk_pll; @@ -231,7 +231,7 @@ static int lpc3180_init(struct nand_device_s *device) if (lpc3180_info->selected_controller == LPC3180_MLC_CONTROLLER) { - u32 mlc_icr_value = 0x0; + uint32_t mlc_icr_value = 0x0; float cycle; int twp, twh, trp, treh, trhz, trbwb, tcea; @@ -350,7 +350,7 @@ static int lpc3180_reset(struct nand_device_s *device) return ERROR_OK; } -static int lpc3180_command(struct nand_device_s *device, u8 command) +static int lpc3180_command(struct nand_device_s *device, uint8_t command) { lpc3180_nand_controller_t *lpc3180_info = device->controller_priv; target_t *target = lpc3180_info->target; @@ -380,7 +380,7 @@ static int lpc3180_command(struct nand_device_s *device, u8 command) return ERROR_OK; } -static int lpc3180_address(struct nand_device_s *device, u8 address) +static int lpc3180_address(struct nand_device_s *device, uint8_t address) { lpc3180_nand_controller_t *lpc3180_info = device->controller_priv; target_t *target = lpc3180_info->target; @@ -410,7 +410,7 @@ static int lpc3180_address(struct nand_device_s *device, u8 address) return ERROR_OK; } -static int lpc3180_write_data(struct nand_device_s *device, u16 data) +static int lpc3180_write_data(struct nand_device_s *device, uint16_t data) { lpc3180_nand_controller_t *lpc3180_info = device->controller_priv; target_t *target = lpc3180_info->target; @@ -461,12 +461,12 @@ static int lpc3180_read_data(struct nand_device_s *device, void *data) /* data = MLC_DATA, use sized access */ if (device->bus_width == 8) { - u8 *data8 = data; + uint8_t *data8 = data; target_read_u8(target, 0x200b0000, data8); } else if (device->bus_width == 16) { - u16 *data16 = data; + uint16_t *data16 = data; target_read_u16(target, 0x200b0000, data16); } else @@ -477,19 +477,19 @@ static int lpc3180_read_data(struct nand_device_s *device, void *data) } else if (lpc3180_info->selected_controller == LPC3180_SLC_CONTROLLER) { - u32 data32; + uint32_t data32; /* data = SLC_DATA, must use 32-bit access */ target_read_u32(target, 0x20020000, &data32); if (device->bus_width == 8) { - u8 *data8 = data; + uint8_t *data8 = data; *data8 = data32 & 0xff; } else if (device->bus_width == 16) { - u16 *data16 = data; + uint16_t *data16 = data; *data16 = data32 & 0xffff; } else @@ -502,12 +502,12 @@ static int lpc3180_read_data(struct nand_device_s *device, void *data) return ERROR_OK; } -static int lpc3180_write_page(struct nand_device_s *device, u32 page, u8 *data, u32 data_size, u8 *oob, u32 oob_size) +static int lpc3180_write_page(struct nand_device_s *device, uint32_t page, uint8_t *data, uint32_t data_size, uint8_t *oob, uint32_t oob_size) { lpc3180_nand_controller_t *lpc3180_info = device->controller_priv; target_t *target = lpc3180_info->target; int retval; - u8 status; + uint8_t status; if (target->state != TARGET_HALTED) { @@ -522,8 +522,8 @@ static int lpc3180_write_page(struct nand_device_s *device, u32 page, u8 *data, } else if (lpc3180_info->selected_controller == LPC3180_MLC_CONTROLLER) { - u8 *page_buffer; - u8 *oob_buffer; + uint8_t *page_buffer; + uint8_t *oob_buffer; int quarter, num_quarters; if (!data && oob) @@ -538,7 +538,7 @@ static int lpc3180_write_page(struct nand_device_s *device, u32 page, u8 *data, return ERROR_NAND_OPERATION_NOT_SUPPORTED; } - if (data_size > (u32)device->page_size) + if (data_size > (uint32_t)device->page_size) { LOG_ERROR("data size exceeds page size"); return ERROR_NAND_OPERATION_NOT_SUPPORTED; @@ -641,7 +641,7 @@ static int lpc3180_write_page(struct nand_device_s *device, u32 page, u8 *data, return ERROR_OK; } -static int lpc3180_read_page(struct nand_device_s *device, u32 page, u8 *data, u32 data_size, u8 *oob, u32 oob_size) +static int lpc3180_read_page(struct nand_device_s *device, uint32_t page, uint8_t *data, uint32_t data_size, uint8_t *oob, uint32_t oob_size) { lpc3180_nand_controller_t *lpc3180_info = device->controller_priv; target_t *target = lpc3180_info->target; @@ -659,11 +659,11 @@ static int lpc3180_read_page(struct nand_device_s *device, u32 page, u8 *data, u } else if (lpc3180_info->selected_controller == LPC3180_MLC_CONTROLLER) { - u8 *page_buffer; - u8 *oob_buffer; - u32 page_bytes_done = 0; - u32 oob_bytes_done = 0; - u32 mlc_isr; + uint8_t *page_buffer; + uint8_t *oob_buffer; + uint32_t page_bytes_done = 0; + uint32_t oob_bytes_done = 0; + uint32_t mlc_isr; #if 0 if (oob && (oob_size > 6)) @@ -673,7 +673,7 @@ static int lpc3180_read_page(struct nand_device_s *device, u32 page, u8 *data, u } #endif - if (data_size > (u32)device->page_size) + if (data_size > (uint32_t)device->page_size) { LOG_ERROR("data size exceeds page size"); return ERROR_NAND_OPERATION_NOT_SUPPORTED; @@ -733,7 +733,7 @@ static int lpc3180_read_page(struct nand_device_s *device, u32 page, u8 *data, u target_write_u32(target, 0x200b8000, NAND_CMD_READSTART); } - while (page_bytes_done < (u32)device->page_size) + while (page_bytes_done < (uint32_t)device->page_size) { /* MLC_ECC_AUTO_DEC_REG = dummy */ target_write_u32(target, 0x200b8014, 0xaa55aa55); @@ -750,11 +750,11 @@ static int lpc3180_read_page(struct nand_device_s *device, u32 page, u8 *data, u { if (mlc_isr & 0x40) { - LOG_ERROR("uncorrectable error detected: 0x%2.2x", mlc_isr); + LOG_ERROR("uncorrectable error detected: 0x%2.2x", (unsigned)mlc_isr); return ERROR_NAND_OPERATION_FAILED; } - LOG_WARNING("%i symbol error detected and corrected", ((mlc_isr & 0x30) >> 4) + 1); + LOG_WARNING("%i symbol error detected and corrected", ((int)(((mlc_isr & 0x30) >> 4) + 1))); } if (data) @@ -792,7 +792,7 @@ static int lpc3180_controller_ready(struct nand_device_s *device, int timeout) { lpc3180_nand_controller_t *lpc3180_info = device->controller_priv; target_t *target = lpc3180_info->target; - u8 status = 0x0; + uint8_t status = 0x0; if (target->state != TARGET_HALTED) { @@ -837,7 +837,7 @@ static int lpc3180_nand_ready(struct nand_device_s *device, int timeout) { if (lpc3180_info->selected_controller == LPC3180_MLC_CONTROLLER) { - u8 status = 0x0; + uint8_t status = 0x0; /* Read MLC_ISR, wait for NAND flash device to become ready */ target_read_u8(target, 0x200b8048, &status); @@ -847,7 +847,7 @@ static int lpc3180_nand_ready(struct nand_device_s *device, int timeout) } else if (lpc3180_info->selected_controller == LPC3180_SLC_CONTROLLER) { - u32 status = 0x0; + uint32_t status = 0x0; /* Read SLC_STAT and check READY bit */ target_read_u32(target, 0x20020018, &status);