Commit d2d763fa837e7f1d769fd00bb730c3abc6650667

Authored by Xu Ziyuan
Committed by Simon Glass
1 parent e1efe43c71

rockchip: add fastboot support for rk3036 board

Enable fastboot feature on rk3036, please refer to doc/README.rockchip
for more detailed usage.

Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

Showing 4 changed files with 112 additions and 3 deletions Side-by-side Diff

arch/arm/dts/rk3036-sdk.dts
... ... @@ -41,7 +41,5 @@
41 41  
42 42 &usb_otg {
43 43 status = "okay";
44   -
45   - dr_mode = "host";
46 44 };
board/rockchip/evb_rk3036/evb_rk3036.c
... ... @@ -47,4 +47,50 @@
47 47 dcache_enable();
48 48 }
49 49 #endif
  50 +
  51 +#if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)
  52 +#include <usb.h>
  53 +#include <usb/dwc2_udc.h>
  54 +
  55 +static struct dwc2_plat_otg_data rk3036_otg_data = {
  56 + .rx_fifo_sz = 512,
  57 + .np_tx_fifo_sz = 16,
  58 + .tx_fifo_sz = 128,
  59 +};
  60 +
  61 +int board_usb_init(int index, enum usb_init_type init)
  62 +{
  63 + int node;
  64 + const char *mode;
  65 + bool matched = false;
  66 + const void *blob = gd->fdt_blob;
  67 +
  68 + /* find the usb_otg node */
  69 + node = fdt_node_offset_by_compatible(blob, -1,
  70 + "rockchip,rk3288-usb");
  71 +
  72 + while (node > 0) {
  73 + mode = fdt_getprop(blob, node, "dr_mode", NULL);
  74 + if (mode && strcmp(mode, "otg") == 0) {
  75 + matched = true;
  76 + break;
  77 + }
  78 +
  79 + node = fdt_node_offset_by_compatible(blob, node,
  80 + "rockchip,rk3288-usb");
  81 + }
  82 + if (!matched) {
  83 + debug("Not found usb_otg device\n");
  84 + return -ENODEV;
  85 + }
  86 + rk3036_otg_data.regs_otg = fdtdec_get_addr(blob, node, "reg");
  87 +
  88 + return dwc2_udc_probe(&rk3036_otg_data);
  89 +}
  90 +
  91 +int board_usb_cleanup(int index, enum usb_init_type init)
  92 +{
  93 + return 0;
  94 +}
  95 +#endif
board/rockchip/kylin_rk3036/kylin_rk3036.c
... ... @@ -79,4 +79,50 @@
79 79 dcache_enable();
80 80 }
81 81 #endif
  82 +
  83 +#if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)
  84 +#include <usb.h>
  85 +#include <usb/dwc2_udc.h>
  86 +
  87 +static struct dwc2_plat_otg_data rk3036_otg_data = {
  88 + .rx_fifo_sz = 512,
  89 + .np_tx_fifo_sz = 16,
  90 + .tx_fifo_sz = 128,
  91 +};
  92 +
  93 +int board_usb_init(int index, enum usb_init_type init)
  94 +{
  95 + int node;
  96 + const char *mode;
  97 + bool matched = false;
  98 + const void *blob = gd->fdt_blob;
  99 +
  100 + /* find the usb_otg node */
  101 + node = fdt_node_offset_by_compatible(blob, -1,
  102 + "rockchip,rk3288-usb");
  103 +
  104 + while (node > 0) {
  105 + mode = fdt_getprop(blob, node, "dr_mode", NULL);
  106 + if (mode && strcmp(mode, "otg") == 0) {
  107 + matched = true;
  108 + break;
  109 + }
  110 +
  111 + node = fdt_node_offset_by_compatible(blob, node,
  112 + "rockchip,rk3288-usb");
  113 + }
  114 + if (!matched) {
  115 + debug("Not found usb_otg device\n");
  116 + return -ENODEV;
  117 + }
  118 + rk3036_otg_data.regs_otg = fdtdec_get_addr(blob, node, "reg");
  119 +
  120 + return dwc2_udc_probe(&rk3036_otg_data);
  121 +}
  122 +
  123 +int board_usb_cleanup(int index, enum usb_init_type init)
  124 +{
  125 + return 0;
  126 +}
  127 +#endif
include/configs/rk3036_common.h
... ... @@ -6,7 +6,7 @@
6 6 #ifndef __CONFIG_RK3036_COMMON_H
7 7 #define __CONFIG_RK3036_COMMON_H
8 8  
9   -#define CONFIG_SYS_CACHELINE_SIZE 32
  9 +#define CONFIG_SYS_CACHELINE_SIZE 64
10 10  
11 11 #include <asm/arch/hardware.h>
12 12  
... ... @@ -60,6 +60,25 @@
60 60 #define CONFIG_SF_DEFAULT_SPEED 20000000
61 61  
62 62 #ifndef CONFIG_SPL_BUILD
  63 +/* usb otg */
  64 +#define CONFIG_USB_GADGET
  65 +#define CONFIG_USB_GADGET_DUALSPEED
  66 +#define CONFIG_USB_GADGET_DWC2_OTG
  67 +#define CONFIG_USB_GADGET_VBUS_DRAW 0
  68 +
  69 +/* fastboot */
  70 +#define CONFIG_CMD_FASTBOOT
  71 +#define CONFIG_USB_FUNCTION_FASTBOOT
  72 +#define CONFIG_FASTBOOT_FLASH
  73 +#define CONFIG_FASTBOOT_FLASH_MMC_DEV 0
  74 +#define CONFIG_FASTBOOT_BUF_ADDR CONFIG_SYS_LOAD_ADDR
  75 +#define CONFIG_FASTBOOT_BUF_SIZE 0x08000000
  76 +
  77 +#define CONFIG_USB_GADGET_DOWNLOAD
  78 +#define CONFIG_G_DNL_MANUFACTURER "Rockchip"
  79 +#define CONFIG_G_DNL_VENDOR_NUM 0x2207
  80 +#define CONFIG_G_DNL_PRODUCT_NUM 0x310a
  81 +
63 82 #include <config_distro_defaults.h>
64 83  
65 84 #define ENV_MEM_LAYOUT_SETTINGS \