]> rtime.felk.cvut.cz Git - fpga/lx-cpu1/lx-rocon.git/commitdiff
RoCoN: MTD SPI Flash support tested and finished.
authorPavel Pisa <ppisa@pikron.com>
Wed, 22 Apr 2015 18:34:56 +0000 (20:34 +0200)
committerPavel Pisa <ppisa@pikron.com>
Wed, 22 Apr 2015 18:34:56 +0000 (20:34 +0200)
Signed-off-by: Pavel Pisa <ppisa@pikron.com>
sw/app/rocon/appl_tests.c
sw/app/rocon/appl_usb.c

index 30279f6dcdcedf6320b350602919b48fc14835e2..5d525f0ee3eb611fbbd0c155ec237853374808db 100644 (file)
 #include "pxmcc_types.h"
 #include "pxmcc_interface.h"
 
+#ifdef CONFIG_OC_MTD_DRV_SYSLESS
+#include <mtd_spi_drv.h>
+#endif
+
 int cmd_do_test_memusage(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
 {
   void *maxaddr;
@@ -173,7 +177,24 @@ int cmd_do_spimst_blocking(cmd_io_t *cmd_io, const struct cmd_des *des, char *pa
 
 int cmd_do_mtdspitest(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
 {
-  mtd_spi_test();
+  int res;
+  unsigned char id_buff[3];
+
+  res = mtd_spi_read_jedec_id(&mtd_spi_state, id_buff, 3);
+  if (res < 0) {
+    printf("mtd_spi_read_jedec_id returned %d\n", res);
+    return -1;
+  }
+
+  printf("mtd_spi_read_jedec_id 0x%02x 0x%02x 0x%02x \n",
+         id_buff[0], id_buff[1], id_buff[2]);
+
+  res = mtd_spi_set_protect_mode(&mtd_spi_state, 0, 0);
+  if (res < 0) {
+    printf("mtd_spi_set_protect_mode returned %d\n", res);
+    return -1;
+  }
+
   return 0;
 }
 
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));