usbd: add progress bar protocol
authorMinkyu Kang <mk7.kang@samsung.com>
Fri, 20 Nov 2009 12:05:26 +0000 (21:05 +0900)
committerMinkyu Kang <mk7.kang@samsung.com>
Fri, 20 Nov 2009 12:05:26 +0000 (21:05 +0900)
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
common/cmd_usbd.c
cpu/arm_cortexa8/s5pc1xx/usb_downloader.c
include/usbd.h

index c47a2aa..20d2d36 100644 (file)
@@ -12,7 +12,7 @@
 #include <malloc.h>
 
 /* version of USB Downloader Application */
-#define APP_VERSION    "1.3.2"
+#define APP_VERSION    "1.3.3"
 
 #ifdef CONFIG_CMD_MTDPARTS
 #include <jffs2/load_kernel.h>
@@ -707,10 +707,14 @@ static int process_data(struct usbd_ops *usbd)
                do_reset();
                return 0;
 #endif
+       case COMMAND_PROGRESS:
+               if (usbd->set_progress)
+                       usbd->set_progress(arg);
+               return 1;
 
        default:
                printf("Error: Unknown command -> (%d)\n", (int)cmd);
-               return 0;
+               return 1;
        }
 
        /* Erase and Write to NAND */
index ca29067..1dc2884 100644 (file)
@@ -22,7 +22,9 @@
 #include <common.h>
 #include "usbd.h"
 #include "usb-hs-otg.h"
+#ifdef CONFIG_S5PC1XXFB
 #include <fbutils.h>
+#endif
 
 static char tx_data[8] = "MPL";
 static long tx_len = 4;
@@ -92,9 +94,16 @@ static void usb_init(void)
 
 #ifdef CONFIG_S5PC1XXFB
        fb_printf("Download Start\n");
-       exit_font();
+       draw_progress(40, 0, FONT_WHITE);
 #endif
+}
 
+void usb_stop(void)
+{
+       s5p_usb_stop();
+#ifdef CONFIG_S5PC1XXFB
+       exit_font();
+#endif
 }
 
 /*
@@ -146,6 +155,12 @@ static void usbd_set_mmc_dev(struct usbd_ops *usbd)
 }
 #endif
 
+#ifdef CONFIG_S5PC1XXFB
+static void set_progress(int progress)
+{
+       draw_progress(40, progress, FONT_WHITE);
+}
+#endif
 /*
  * This function is interfaced between
  * USB Device Controller and USB Downloader
@@ -153,7 +168,7 @@ static void usbd_set_mmc_dev(struct usbd_ops *usbd)
 struct usbd_ops *usbd_set_interface(struct usbd_ops *usbd)
 {
        usbd->usb_init = usb_init;
-       usbd->usb_stop = s5p_usb_stop;
+       usbd->usb_stop = usb_stop;
        usbd->send_data = s5p_usb_tx;
        usbd->recv_data = usb_receive_packet;
        usbd->recv_setup = recv_setup;
@@ -162,7 +177,9 @@ struct usbd_ops *usbd_set_interface(struct usbd_ops *usbd)
        usbd->tx_len = tx_len;
        usbd->rx_len = rx_len;
        usbd->ram_addr = CONFIG_SYS_DOWN_ADDR;
-
+#ifdef CONFIG_S5PC1XXFB
+       usbd->set_progress = set_progress;
+#endif
 #ifdef CONFIG_GENERIC_MMC
        usbd_set_mmc_dev(usbd);
 #endif
index 4863238..d7ab712 100644 (file)
@@ -52,6 +52,7 @@ enum {
 #define COMMAND_DOWN_PHONE     220
 #define COMMAND_CHANGE_USB     221
 #endif
+#define COMMAND_PROGRESS       230
 
 /*
  * USB Downloader Operations
@@ -90,6 +91,8 @@ struct usbd_ops {
        ulong mmc_max;
        ulong mmc_blk;
        ulong mmc_total;
+
+       void (*set_progress)(int);
 };
 
 /* This function is interfaced between USB Device Controller and USB Downloader