]> rtime.felk.cvut.cz Git - fpga/lx-cpu1/lx-rocon.git/blobdiff - sw/app/rocon/appl_usb.c
RoCoN: MTD SPI Flash support tested and finished.
[fpga/lx-cpu1/lx-rocon.git] / sw / app / rocon / appl_usb.c
index 38dcd1389767768264de56523af4d499d4824460..1bdc8b009ac7a0977daaec2c238d3b29b31a1aaf 100644 (file)
@@ -226,6 +226,15 @@ int usb_spi_flash_pkt_rd(struct usb_ep_t *ep, int len, int code)
   return USB_COMPLETE_OK;
 }
 
+int usb_spi_flash_mass_erase(int mode)
+{
+#ifdef CONFIG_OC_MTD_DRV_SYSLESS
+  mtd_spi_set_protect_mode(&mtd_spi_state, 0, 0);
+  mtd_spi_chip_erase(&mtd_spi_state, mode, 0);
+#endif /*CONFIG_KEYVAL*/
+  return 0;
+}
+
 static void usb_goto(unsigned address)
 {
 #ifdef CONFIG_KEYVAL
@@ -408,6 +417,12 @@ int appl_usb_vendor(usb_device_t *udev)
       usb_flash_erase((uint32_t)dreq->wValue << 10, dreq->wIndex << 10);
       return 1;
 
+    case USB_VENDOR_MASS_ERASE:
+      usb_send_control_data(udev, NULL, 0);
+      if (dreq->wIndex == 5)
+         usb_spi_flash_mass_erase(dreq->wValue);
+      return 1;
+
     case USB_VENDOR_CALL:
       vendor_call_ret = SWAP(appl_usb_vendor_call(dreq->wIndex, dreq->wValue));
       usb_send_control_data(udev, (unsigned char *) &vendor_call_ret, sizeof(uint16_t));