Inderpal Singh | a111cd0 | 2012-10-23 17:16:08 +0530 | [diff] [blame] | 1 | /* |
| 2 | * common/cmd_usbd.c |
| 3 | * |
| 4 | * $Id: cmd_usbd.c,v 1.2 2009/01/28 00:11:42 dark0351 Exp $ |
| 5 | * |
| 6 | * (C) Copyright 2007 |
| 7 | * Byungjae Lee, Samsung Erectronics, bjlee@samsung.com. |
| 8 | * - support for S3C2412, S3C2443 and S3C6400 |
| 9 | * |
| 10 | * (C) Copyright SAMSUNG Electronics |
| 11 | * SW.LEE <hitchcar@samsung.com> |
| 12 | * - add USB device fo S3C2440A, S3C24A0A |
| 13 | * |
| 14 | * (C) Copyright 2000 |
| 15 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 16 | * |
| 17 | * See file CREDITS for list of people who contributed to this |
| 18 | * project. |
| 19 | * |
| 20 | * This program is free software; you can redistribute it and/or |
| 21 | * modify it under the terms of the GNU General Public License as |
| 22 | * published by the Free Software Foundation; either version 2 of |
| 23 | * the License, or (at your option) any later version. |
| 24 | */ |
| 25 | |
| 26 | /* |
| 27 | * Memory Functions |
| 28 | * |
| 29 | * Copied from FADS ROM, Dan Malek (dmalek@jlc.net) |
| 30 | */ |
| 31 | |
| 32 | #include <common.h> |
| 33 | #include <command.h> |
| 34 | #include "cpu.h" |
| 35 | |
| 36 | #ifdef CONFIG_S3C_USBD |
| 37 | |
| 38 | //#include <s5pv310.h> |
| 39 | |
| 40 | #if defined(CONFIG_S3C2412) || defined(CONFIG_S3C2442) |
| 41 | #include "../cpu/s3c24xx/usbd-fs.h" |
| 42 | #elif defined(CONFIG_S3C2443) || \ |
| 43 | defined(CONFIG_S3C2450) || \ |
| 44 | defined(CONFIG_S3C2416) |
| 45 | #include "../cpu/s3c24xx/usbd-hs.h" |
| 46 | #elif defined(CONFIG_S3C6400) || \ |
| 47 | defined(CONFIG_S3C6410) || \ |
| 48 | defined(CONFIG_S3C6430) |
| 49 | #include "../cpu/s3c64xx/usbd-otg-hs.h" |
| 50 | #elif defined(CONFIG_S5PC100) |
| 51 | #include "../cpu/s5pc1xx/usbd-otg-hs.h" |
| 52 | #elif defined(CONFIG_S5PC210) || defined(CONFIG_EXYNOS4) |
| 53 | #include "../drivers/usb/gadget/usbd-otg-hs.h" |
| 54 | #elif defined(CONFIG_S5P6440) |
| 55 | #include "../cpu/s5p64xx/usbd-otg-hs.h" |
| 56 | #elif defined(CONFIG_S5P6442) |
| 57 | #include "../cpu/s5p644x/usbd-otg-hs.h" |
| 58 | #else |
| 59 | #error "* CFG_ERROR : you have to setup right Samsung CPU configuration" |
| 60 | #endif |
| 61 | |
| 62 | #undef CMD_USBD_DEBUG |
| 63 | #ifdef CMD_USBD_DEBUG |
| 64 | #define PRINTF(fmt, args...) printf(fmt, ##args) |
| 65 | #else |
| 66 | #define PRINTF(fmt, args...) |
| 67 | #endif |
| 68 | |
| 69 | static const char pszMe[] = "usbd: "; |
| 70 | |
| 71 | int do_usbd_dnw(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 72 | { |
| 73 | |
| 74 | if (argv[0][0] == 'u') { |
| 75 | DNW = 0; |
| 76 | } else { |
| 77 | DNW = 1; |
| 78 | s3c_got_header = 0; |
| 79 | } |
| 80 | |
| 81 | switch (argc) { |
| 82 | case 1: |
| 83 | s3c_usbd_dn_addr = USBD_DOWN_ADDR; /* Default Address */ |
| 84 | break; |
| 85 | case 2: |
| 86 | s3c_usbd_dn_addr = simple_strtoul(argv[1], NULL, 16); |
| 87 | break; |
| 88 | default: |
| 89 | printf("Usage:\n%s\n", cmdtp->usage); |
| 90 | return 1; |
| 91 | } |
| 92 | |
| 93 | s3c_receive_done = 0; |
| 94 | |
| 95 | s3c_usbctl_init(); |
| 96 | s3c_usbc_activate(); |
| 97 | |
| 98 | PRINTF("Download address 0x%08x\n", s3c_usbd_dn_addr); |
| 99 | printf("Now, Waiting for DNW to transmit data\n"); |
| 100 | |
| 101 | while (1) { |
| 102 | if (S3C_USBD_DETECT_IRQ()) { |
| 103 | s3c_udc_int_hndlr(); |
| 104 | S3C_USBD_CLEAR_IRQ(); |
| 105 | } |
| 106 | |
| 107 | if (s3c_receive_done) |
| 108 | break; |
| 109 | |
| 110 | if (serial_tstc()) { |
| 111 | serial_getc(); |
| 112 | break; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | /* when operation is done, usbd must be stopped */ |
| 117 | s3c_usb_stop(); |
| 118 | |
| 119 | return 0; |
| 120 | } |
| 121 | |
| 122 | U_BOOT_CMD( |
| 123 | dnw, 3, 0, do_usbd_dnw, |
| 124 | "dnw - initialize USB device and ready \ |
| 125 | to receive for Windows server (specific)\n", |
| 126 | "[download address]\n" |
| 127 | ); |
| 128 | |
| 129 | #endif /* CONFIG_S3C_USBD */ |