int qspi_flash_loadimage(struct image_info *image) { int ret; at91_qspi_hw_init(); qspi_init(AT91C_QSPI_CLK, SPI_MODE3); qspi_flash_read_jedec_id(); ret = qspi_flash_enable_quad_mode(0x01); if (ret) return -1; dbg_info("QSPI Flash: Switch to Quad SPI mode\n"); dbg_info("QSPI Flash: Copy %d bytes from %d to %d\n", image->length, image->offset, image->dest); ret = qspi_flash_read_image(image); if (ret) return -1; ret = qspi_flash_enable_quad_mode(0); if (ret) return -1; dbg_info("QSPI Flash: Switch to Extended SPI mode\n"); return 0; }
// Inits the LED matrix void led_init() { MCF_GPIO_PTHPAR &= ~MCF_GPIO_PTHPAR_PTHPAR6(3); // GPIO TH pin 6 for GPIO function, LEDM_STR MCF_GPIO_PTHPAR &= ~MCF_GPIO_PTHPAR_PTHPAR7(3); // GPIO TH pin 7 for GPIO function, LEDM_OE MCF_GPIO_DDRTH |= MCF_GPIO_DDRTH_DDRTH6 | MCF_GPIO_DDRTH_DDRTH7; // OE high. Disables outputs MCF_GPIO_SETTH |= MCF_GPIO_SETTH_SETTH7; // Initialize QSPI to transfer at 5000kbps with a delay of 0 (default) qspi_init(5000, 0); }
STATIC int qspi_ioctl(void *self_in, uint32_t cmd) { (void)self_in; switch (cmd) { case MP_QSPI_IOCTL_INIT: qspi_init(); break; case MP_QSPI_IOCTL_BUS_RELEASE: // Switch to memory-map mode when bus is idle qspi_memory_map(); break; } return 0; // success }