From bb2ce93795be48f414ff223b06ea2533bd2af5ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Pe=C4=8Dovnik?= Date: Fri, 29 Jun 2018 13:48:50 +0000 Subject: [PATCH] Enable ums mode when TinkerBoard is connected to PC. This is needed to flash image directly to eMMC. Removing ethaddr setting since it's deprecated and few other small fixes. --- config/bootenv/rockchip-default.txt | 1 - .../0017-Fix-HDMI-some-issues.patch | 115 ++++++++++ ...mic-enable-LDO2-vcc33_mipi-at-bootup.patch | 70 ++++++ ...mode-when-TinkerBoard-is-connected-t.patch | 206 ++++++++++++++++++ ...-add-10ms-delay-after-re-enable-EMMC.patch | 25 +++ ...-fixed-enter-ums-mode-fail-sometimes.patch | 160 ++++++++++++++ .../0045-modify-UMS-name-of-uboot.patch | 32 +++ ...timeout-when-force-entering-UMS-mode.patch | 146 +++++++++++++ .../200_tinker_uart3_debug.patch | 6 +- 9 files changed, 757 insertions(+), 4 deletions(-) create mode 100644 patch/u-boot/u-boot-rockchip/board_tinkerboard/0017-Fix-HDMI-some-issues.patch create mode 100644 patch/u-boot/u-boot-rockchip/board_tinkerboard/0018-pmic-enable-LDO2-vcc33_mipi-at-bootup.patch create mode 100644 patch/u-boot/u-boot-rockchip/board_tinkerboard/0036-auto-enable-ums-mode-when-TinkerBoard-is-connected-t.patch create mode 100644 patch/u-boot/u-boot-rockchip/board_tinkerboard/0037-add-10ms-delay-after-re-enable-EMMC.patch create mode 100644 patch/u-boot/u-boot-rockchip/board_tinkerboard/0039-fixed-enter-ums-mode-fail-sometimes.patch create mode 100644 patch/u-boot/u-boot-rockchip/board_tinkerboard/0045-modify-UMS-name-of-uboot.patch create mode 100644 patch/u-boot/u-boot-rockchip/board_tinkerboard/0049-added-timeout-when-force-entering-UMS-mode.patch diff --git a/config/bootenv/rockchip-default.txt b/config/bootenv/rockchip-default.txt index af4b3c2e7d..b9bafac335 100644 --- a/config/bootenv/rockchip-default.txt +++ b/config/bootenv/rockchip-default.txt @@ -1,2 +1 @@ verbosity=1 -ethaddr=06:e6:ad:01:68:3c diff --git a/patch/u-boot/u-boot-rockchip/board_tinkerboard/0017-Fix-HDMI-some-issues.patch b/patch/u-boot/u-boot-rockchip/board_tinkerboard/0017-Fix-HDMI-some-issues.patch new file mode 100644 index 0000000000..f697066452 --- /dev/null +++ b/patch/u-boot/u-boot-rockchip/board_tinkerboard/0017-Fix-HDMI-some-issues.patch @@ -0,0 +1,115 @@ +From 550e15099408decc58fb439edcd2e320570b8bf4 Mon Sep 17 00:00:00 2001 +From: jamess_huang +Date: Fri, 11 Aug 2017 17:47:45 +0800 +Subject: [PATCH 17/50] Fix HDMI some issues + +This patch: + use 1080P display_timing when connect 4K HDMI screen. + correct rockchip_mpll_config & rockchip_phy_config .mpixelclock. + add some hdmi-to-vga support + +Change-Id: Ic7faf4dd7ea490051493397058aa5bad1d8788c1 +--- + common/Kconfig | 2 +- + drivers/video/dw_hdmi.c | 8 ++++---- + drivers/video/rockchip/rk_vop.c | 14 ++++++++++++++ + include/dw_hdmi.h | 4 ++-- + 4 files changed, 21 insertions(+), 7 deletions(-) + +diff --git a/common/Kconfig b/common/Kconfig + +index 361346b092..355e816c9d 100644 +--- a/common/Kconfig ++++ b/common/Kconfig +@@ -245,7 +245,7 @@ endmenu + + config BOOTDELAY + int "delay in seconds before automatically booting" +- default 2 ++ default 5 + depends on AUTOBOOT + help + Delay before automatically running bootcmd; +diff --git a/drivers/video/dw_hdmi.c b/drivers/video/dw_hdmi.c +index 6039d676c5..0d7a7c228d 100644 +--- a/drivers/video/dw_hdmi.c ++++ b/drivers/video/dw_hdmi.c +@@ -340,7 +340,7 @@ static int hdmi_phy_configure(struct dw_hdmi *hdmi, u32 mpixelclock) + + hdmi_phy_i2c_write(hdmi, hdmi->mpll_cfg[i].cpce, PHY_OPMODE_PLLCFG); + hdmi_phy_i2c_write(hdmi, hdmi->mpll_cfg[i].gmp, PHY_PLLGMPCTRL); +- hdmi_phy_i2c_write(hdmi, hdmi->mpll_cfg[i].curr, PHY_PLLCURRCTRL); ++ hdmi_phy_i2c_write(hdmi, 0x0000, PHY_PLLCURRCTRL); + + hdmi_phy_i2c_write(hdmi, 0x0000, PHY_PLLPHBYCTRL); + hdmi_phy_i2c_write(hdmi, 0x0006, PHY_PLLCLKBISTPHASE); +@@ -560,8 +560,8 @@ static int hdmi_read_edid(struct dw_hdmi *hdmi, int block, u8 *buff) + u32 n; + + /* set ddc i2c clk which devided from ddc_clk to 100khz */ +- hdmi_write(hdmi, hdmi->i2c_clk_high, HDMI_I2CM_SS_SCL_HCNT_0_ADDR); +- hdmi_write(hdmi, hdmi->i2c_clk_low, HDMI_I2CM_SS_SCL_LCNT_0_ADDR); ++ //hdmi_write(hdmi, hdmi->i2c_clk_high, HDMI_I2CM_SS_SCL_HCNT_0_ADDR); ++ //hdmi_write(hdmi, hdmi->i2c_clk_low, HDMI_I2CM_SS_SCL_LCNT_0_ADDR); + hdmi_mod(hdmi, HDMI_I2CM_DIV, HDMI_I2CM_DIV_FAST_STD_MODE, + HDMI_I2CM_DIV_STD_MODE); + +@@ -663,7 +663,7 @@ int dw_hdmi_phy_wait_for_hpd(struct dw_hdmi *hdmi) + if (hdmi_get_plug_in_status(hdmi)) + return 0; + udelay(100); +- } while (get_timer(start) < 300); ++ } while (get_timer(start) < 5000); + + return -1; + } +diff --git a/drivers/video/rockchip/rk_vop.c b/drivers/video/rockchip/rk_vop.c +index c979049b5b..7bcc3df69b 100644 +--- a/drivers/video/rockchip/rk_vop.c ++++ b/drivers/video/rockchip/rk_vop.c +@@ -277,6 +277,20 @@ static int rk_display_init(struct udevice *dev, ulong fbbase, int ep_node) + return ret; + } + ++ /* Use 1080p display_timing when connect 4K HDMI screen */ ++ if (timing.hactive.typ >= 3840) { ++ timing.pixelclock.typ = 148500000; ++ timing.hactive.typ = 1920; ++ timing.vactive.typ = 1080; ++ timing.hsync_len.typ = 44; ++ timing.hback_porch.typ = 148; ++ timing.vsync_len.typ = 5; ++ timing.vback_porch.typ = 36; ++ timing.hfront_porch.typ = 88; ++ timing.vfront_porch.typ = 4; ++ debug("Use default 1080P settings \n"); ++ } ++ + ret = clk_get_by_index(dev, 1, &clk); + if (!ret) + ret = clk_set_rate(&clk, timing.pixelclock.typ); +diff --git a/include/dw_hdmi.h b/include/dw_hdmi.h +index 902abd4d44..c1f1fbff6a 100644 +--- a/include/dw_hdmi.h ++++ b/include/dw_hdmi.h +@@ -448,7 +448,7 @@ enum { + }; + + struct hdmi_mpll_config { +- u64 mpixelclock; ++ u32 mpixelclock; + /* Mode of Operation and PLL Dividers Control Register */ + u32 cpce; + /* PLL Gmp Control Register */ +@@ -458,7 +458,7 @@ struct hdmi_mpll_config { + }; + + struct hdmi_phy_config { +- u64 mpixelclock; ++ u32 mpixelclock; + u32 sym_ctr; /* clock symbol and transmitter control */ + u32 term; /* transmission termination value */ + u32 vlev_ctr; /* voltage level control */ +-- +2.17.1 + diff --git a/patch/u-boot/u-boot-rockchip/board_tinkerboard/0018-pmic-enable-LDO2-vcc33_mipi-at-bootup.patch b/patch/u-boot/u-boot-rockchip/board_tinkerboard/0018-pmic-enable-LDO2-vcc33_mipi-at-bootup.patch new file mode 100644 index 0000000000..0cce2e0581 --- /dev/null +++ b/patch/u-boot/u-boot-rockchip/board_tinkerboard/0018-pmic-enable-LDO2-vcc33_mipi-at-bootup.patch @@ -0,0 +1,70 @@ +From d0d5938a3f8a524a884c460c5870c0c966daf152 Mon Sep 17 00:00:00 2001 +From: jamess_huang +Date: Fri, 11 Aug 2017 18:10:22 +0800 +Subject: [PATCH 18/50] pmic: enable LDO2 vcc33_mipi at bootup + +power up camera module to prevent i2c-2 SDA pulled low + +Change-Id: I199bef9c8aa4385dbda33117e2ca0c64dc7a13d4 +--- + board/rockchip/tinker_rk3288/tinker-rk3288.c | 38 ++++++++++++++++++++ + 1 file changed, 38 insertions(+) + mode change 100644 => 100755 board/rockchip/tinker_rk3288/tinker-rk3288.c + +diff --git a/board/rockchip/tinker_rk3288/tinker-rk3288.c b/board/rockchip/tinker_rk3288/tinker-rk3288.c +index c2872e7330..5618bd9923 100644 +--- a/board/rockchip/tinker_rk3288/tinker-rk3288.c ++++ b/board/rockchip/tinker_rk3288/tinker-rk3288.c +@@ -8,6 +8,8 @@ + #include + #include + #include ++#include ++ + + static int get_ethaddr_from_eeprom(u8 *addr) + { +@@ -33,3 +35,39 @@ int rk_board_late_init(void) + + return 0; + } ++ ++ ++#ifdef CONFIG_DM_PMIC ++static int rockchip_set_regulator_on(const char *name, uint uv) ++{ ++ struct udevice *dev; ++ int ret; ++ ++ ret = regulator_get_by_platname(name, &dev); ++ if (ret) { ++ debug("%s: Cannot find regulator %s\n", __func__, name); ++ return ret; ++ } ++ ret = regulator_set_value(dev, uv); ++ if (ret) { ++ debug("%s: Cannot set regulator %s\n", __func__, name); ++ return ret; ++ } ++ ret = regulator_set_enable(dev, 1); ++ if (ret) { ++ debug("%s: Cannot enable regulator %s\n", __func__, name); ++ return ret; ++ } ++ ++ return 0; ++} ++ ++int power_init_board(void) ++{ ++ int ret = rockchip_set_regulator_on("vcc33_mipi", 3300000); ++ if (ret) ++ return ret; ++ ++ return 0; ++} ++#endif +\ No newline at end of file +-- +2.17.1 + diff --git a/patch/u-boot/u-boot-rockchip/board_tinkerboard/0036-auto-enable-ums-mode-when-TinkerBoard-is-connected-t.patch b/patch/u-boot/u-boot-rockchip/board_tinkerboard/0036-auto-enable-ums-mode-when-TinkerBoard-is-connected-t.patch new file mode 100644 index 0000000000..9123cd8875 --- /dev/null +++ b/patch/u-boot/u-boot-rockchip/board_tinkerboard/0036-auto-enable-ums-mode-when-TinkerBoard-is-connected-t.patch @@ -0,0 +1,206 @@ +From 11b9e1141895e719e2ad4421f746c4b5359c671b Mon Sep 17 00:00:00 2001 +From: jamess_huang +Date: Thu, 12 Oct 2017 11:47:27 +0800 +Subject: [PATCH 36/50] auto enable ums mode when TinkerBoard is connected to + PC + +Change-Id: Ice3f37906ab1ae0428c1d23867a58c5c720aa8ab +--- + arch/arm/include/asm/arch-rockchip/gpio.h | 22 ++++++++ + arch/arm/mach-rockchip/rk3288-board.c | 62 +++++++++++++++++++++++ + cmd/usb_mass_storage.c | 2 +- + common/autoboot.c | 17 +++++++ + common/board_r.c | 1 + + include/common.h | 1 + + 6 files changed, 104 insertions(+), 1 deletion(-) + +diff --git a/arch/arm/include/asm/arch-rockchip/gpio.h b/arch/arm/include/asm/arch-rockchip/gpio.h +index e39218d0a9..10f4f41e67 100644 +--- a/arch/arm/include/asm/arch-rockchip/gpio.h ++++ b/arch/arm/include/asm/arch-rockchip/gpio.h +@@ -25,4 +25,26 @@ struct rockchip_gpio_regs { + }; + check_member(rockchip_gpio_regs, ls_sync, 0x60); + ++/* ++ * RK3288 IO memory map: ++ * ++ */ ++#define RKIO_GPIO0_PHYS 0xFF750000 ++#define RKIO_GRF_PHYS 0xFF770000 ++#define RKIO_GPIO1_PHYS 0xFF780000 ++#define RKIO_GPIO2_PHYS 0xFF790000 ++#define RKIO_GPIO3_PHYS 0xFF7A0000 ++#define RKIO_GPIO4_PHYS 0xFF7B0000 ++#define RKIO_GPIO5_PHYS 0xFF7C0000 ++#define RKIO_GPIO6_PHYS 0xFF7D0000 ++ ++/* gpio power down/up control */ ++#define GRF_GPIO2A_P 0x150 ++#define GRF_GPIO6A_P 0x190 ++ ++/* gpio input/output control */ ++#define GPIO_SWPORT_DR 0x00 ++#define GPIO_SWPORT_DDR 0x04 ++#define GPIO_EXT_PORT 0x50 ++ + #endif +diff --git a/arch/arm/mach-rockchip/rk3288-board.c b/arch/arm/mach-rockchip/rk3288-board.c +index f1569e62b6..32f70a5920 100644 +--- a/arch/arm/mach-rockchip/rk3288-board.c ++++ b/arch/arm/mach-rockchip/rk3288-board.c +@@ -22,6 +22,19 @@ + + DECLARE_GLOBAL_DATA_PTR; + ++enum project_id { ++ TinkerBoardS = 0, ++ TinkerBoard = 7, ++}; ++ ++enum pcb_id { ++ SR, ++ ER, ++ PR, ++}; ++ ++extern bool force_ums; ++ + __weak int rk_board_late_init(void) + { + return 0; +@@ -91,6 +104,55 @@ int board_late_init(void) + return rk_board_late_init(); + } + ++int check_force_enter_ums_mode(void) ++{ ++ int tmp; ++ enum pcb_id pcbid; ++ enum project_id projectid; ++ ++ // GPIO2_A1/GPIO2_A2/GPIO2_A3 pull up enable ++ // please check TRM V1.2 part1 page 152 ++ tmp = readl(RKIO_GRF_PHYS + GRF_GPIO2A_P); ++ writel((tmp&~(0x03F<<2)) | 0x3F<<(16 + 2) | 0x15<<2, RKIO_GRF_PHYS + GRF_GPIO2A_P); ++ ++ // GPIO2_A1/GPIO2_A2/GPIO2_A3/GPIO2_B0/GPIO2_B1/GPIO2_B2 set to input ++ tmp = readl(RKIO_GPIO2_PHYS + GPIO_SWPORT_DDR); ++ writel(tmp & ~(0x70E), RKIO_GPIO2_PHYS + GPIO_SWPORT_DDR); ++ ++ // GPIO6_A5 pull up/down disable ++ tmp = readl(RKIO_GRF_PHYS + GRF_GPIO6A_P); ++ writel((tmp&~(0x03<<10)) | 0x03<<(16 + 10), RKIO_GRF_PHYS + GRF_GPIO6A_P); ++ ++ // GPIO6_A5 set to input ++ tmp = readl(RKIO_GPIO6_PHYS + GPIO_SWPORT_DDR); ++ writel(tmp & ~(0x20), RKIO_GPIO6_PHYS + GPIO_SWPORT_DDR); ++ ++ mdelay(10); ++ ++ // read GPIO2_A1/GPIO2_A2/GPIO2_A3 value ++ projectid = (readl(RKIO_GPIO2_PHYS + GPIO_EXT_PORT) & 0x0E) >>1; ++ ++ // read GPIO2_B0/GPIO2_B1/GPIO2_B2 value ++ pcbid = (readl(RKIO_GPIO2_PHYS + GPIO_EXT_PORT) & 0x700) >> 8; ++ ++ // only Tinker Board S and the PR stage PCB has this function ++ if(projectid!=TinkerBoard && pcbid >= ER){ ++ printf("PC event = 0x%x\n", readl(RKIO_GPIO6_PHYS + GPIO_EXT_PORT)&0x20); ++ if((readl(RKIO_GPIO6_PHYS + GPIO_EXT_PORT)&0x20)==0x20) { ++ // SDP detected, enable EMMC and unlock usb current limit ++ printf("usb connected to SDP, force enter ums mode\n"); ++ force_ums = true; ++ // unlock usb current limit and re-enable EMMC ++ // set GPIO6_A6, GPIO6_A7 to high ++ tmp = readl(RKIO_GPIO6_PHYS + GPIO_SWPORT_DR); ++ writel(tmp | 0xc0, RKIO_GPIO6_PHYS + GPIO_SWPORT_DR); ++ tmp = readl(RKIO_GPIO6_PHYS + GPIO_SWPORT_DDR); ++ writel(tmp | 0xc0, RKIO_GPIO6_PHYS + GPIO_SWPORT_DDR); ++ } ++ } ++ return 0; ++} ++ + #if !CONFIG_IS_ENABLED(ROCKCHIP_BACK_TO_BROM) + static int veyron_init(void) + { +diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c +index 3353f95c74..cb5260b558 100644 +--- a/cmd/usb_mass_storage.c ++++ b/cmd/usb_mass_storage.c +@@ -133,7 +133,7 @@ cleanup: + return ret; + } + +-static int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag, ++int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag, + int argc, char * const argv[]) + { + const char *usb_controller; +diff --git a/common/autoboot.c b/common/autoboot.c +index c52bad84a4..d63a4d7e79 100644 +--- a/common/autoboot.c ++++ b/common/autoboot.c +@@ -28,6 +28,8 @@ DECLARE_GLOBAL_DATA_PTR; + /* Stored value of bootdelay, used by autoboot_command() */ + static int stored_bootdelay; + ++bool force_ums = false; ++ + #if defined(CONFIG_AUTOBOOT_KEYED) + #if defined(CONFIG_AUTOBOOT_STOP_STR_SHA256) + +@@ -339,10 +341,25 @@ const char *bootdelay_process(void) + return s; + } + ++extern int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); ++ + void autoboot_command(const char *s) + { + debug("### main_loop: bootcmd=\"%s\"\n", s ? s : ""); + ++ if (force_ums) { ++ // force to enter ums mode ++ char *local_args[4]; ++ char str1[]="ums", str2[]="1", str3[]="mmc", str4[]="0"; ++ ++ local_args[0]=str1; ++ local_args[1]=str2; ++ local_args[2]=str3; ++ local_args[3]=str4; ++ do_usb_mass_storage(NULL, 0, 4, local_args); ++ return; ++ } ++ + if (stored_bootdelay != -1 && s && !abortboot(stored_bootdelay)) { + #if defined(CONFIG_AUTOBOOT_KEYED) && !defined(CONFIG_AUTOBOOT_KEYED_CTRLC) + int prev = disable_ctrlc(1); /* disable Control C checking */ +diff --git a/common/board_r.c b/common/board_r.c +index ecca1edb04..77b3a05693 100644 +--- a/common/board_r.c ++++ b/common/board_r.c +@@ -800,6 +800,7 @@ static init_fnc_t init_sequence_r[] = { + #ifdef CONFIG_CMD_ONENAND + initr_onenand, + #endif ++ check_force_enter_ums_mode, + #ifdef CONFIG_MMC + initr_mmc, + #endif +diff --git a/include/common.h b/include/common.h +index 751665f8a4..13a6e563c3 100644 +--- a/include/common.h ++++ b/include/common.h +@@ -418,6 +418,7 @@ extern ssize_t spi_write (uchar *, int, uchar *, int); + int board_early_init_f (void); + int board_fix_fdt (void *rw_fdt_blob); /* manipulate the U-Boot fdt before its relocation */ + int board_late_init (void); ++int check_force_enter_ums_mode (void); + int board_postclk_init (void); /* after clocks/timebase, before env/serial */ + int board_early_init_r (void); + void board_poweroff (void); +-- +2.17.1 + diff --git a/patch/u-boot/u-boot-rockchip/board_tinkerboard/0037-add-10ms-delay-after-re-enable-EMMC.patch b/patch/u-boot/u-boot-rockchip/board_tinkerboard/0037-add-10ms-delay-after-re-enable-EMMC.patch new file mode 100644 index 0000000000..eb89c38e30 --- /dev/null +++ b/patch/u-boot/u-boot-rockchip/board_tinkerboard/0037-add-10ms-delay-after-re-enable-EMMC.patch @@ -0,0 +1,25 @@ +From b41031b54e5d4355d2f27f7297b72c030f435167 Mon Sep 17 00:00:00 2001 +From: jamess_huang +Date: Tue, 17 Oct 2017 14:38:28 +0800 +Subject: [PATCH 37/50] add 10ms delay after re-enable EMMC + +Change-Id: I022d050be22c5436822cb2057e70b17d88e65d7a +--- + arch/arm/mach-rockchip/rk3288-board.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/arch/arm/mach-rockchip/rk3288-board.c b/arch/arm/mach-rockchip/rk3288-board.c +index 32f70a5920..07f4125780 100644 +--- a/arch/arm/mach-rockchip/rk3288-board.c ++++ b/arch/arm/mach-rockchip/rk3288-board.c +@@ -136,6 +136,7 @@ int check_force_enter_ums_mode(void) + writel(tmp | 0xc0, RKIO_GPIO6_PHYS + GPIO_SWPORT_DR); + tmp = readl(RKIO_GPIO6_PHYS + GPIO_SWPORT_DDR); + writel(tmp | 0xc0, RKIO_GPIO6_PHYS + GPIO_SWPORT_DDR); ++ mdelay(10); + } + } + return 0; +-- +2.17.1 + diff --git a/patch/u-boot/u-boot-rockchip/board_tinkerboard/0039-fixed-enter-ums-mode-fail-sometimes.patch b/patch/u-boot/u-boot-rockchip/board_tinkerboard/0039-fixed-enter-ums-mode-fail-sometimes.patch new file mode 100644 index 0000000000..9bfcf0e165 --- /dev/null +++ b/patch/u-boot/u-boot-rockchip/board_tinkerboard/0039-fixed-enter-ums-mode-fail-sometimes.patch @@ -0,0 +1,160 @@ +From eff570086cca1c909725dc71b26b84f5bfd2b7a9 Mon Sep 17 00:00:00 2001 +From: jamess_huang +Date: Fri, 27 Oct 2017 16:09:06 +0800 +Subject: [PATCH 39/50] fixed enter ums mode fail sometimes + +Change-Id: I9e40cb0d8d5873588f7bf9b844e036071d13ff16 +--- + arch/arm/mach-rockchip/rk3288-board-spl.c | 22 +++++++ + arch/arm/mach-rockchip/rk3288-board.c | 70 +++++++++++++++++++---- + 2 files changed, 80 insertions(+), 12 deletions(-) + +diff --git a/arch/arm/mach-rockchip/rk3288-board-spl.c b/arch/arm/mach-rockchip/rk3288-board-spl.c +index a0d0ce2ff4..5f7ff2dc49 100644 +--- a/arch/arm/mach-rockchip/rk3288-board-spl.c ++++ b/arch/arm/mach-rockchip/rk3288-board-spl.c +@@ -185,6 +185,27 @@ static int phycore_init(void) + } + #endif + ++/* ++* ++* usb current limit : GPIO6_A6 (H:unlock, L:lock) ++* ++*/ ++void usb_current_limit_ctrl(bool unlock_current) ++{ ++ int tmp; ++ ++#include ++ ++ tmp = readl(RKIO_GPIO6_PHYS + GPIO_SWPORT_DR); ++ if(unlock_current == true) ++ writel(tmp | 0x40, RKIO_GPIO6_PHYS + GPIO_SWPORT_DR); ++ else ++ writel(tmp & ~0x40, RKIO_GPIO6_PHYS + GPIO_SWPORT_DR); ++ ++ tmp = readl(RKIO_GPIO6_PHYS + GPIO_SWPORT_DDR); ++ writel(tmp | 0x40, RKIO_GPIO6_PHYS + GPIO_SWPORT_DDR); ++} ++ + void board_init_f(ulong dummy) + { + struct udevice *pinctrl; +@@ -213,6 +234,7 @@ void board_init_f(ulong dummy) + */ + debug_uart_init(); + debug("\nspl:debug uart enabled in %s\n", __func__); ++ usb_current_limit_ctrl(true); + ret = spl_early_init(); + if (ret) { + debug("spl_early_init() failed: %d\n", ret); +diff --git a/arch/arm/mach-rockchip/rk3288-board.c b/arch/arm/mach-rockchip/rk3288-board.c +index 07f4125780..f73520925b 100644 +--- a/arch/arm/mach-rockchip/rk3288-board.c ++++ b/arch/arm/mach-rockchip/rk3288-board.c +@@ -92,18 +92,67 @@ int board_late_init(void) + return rk_board_late_init(); + } + ++/* ++* ++* usb current limit : GPIO6_A6 (H:unlock, L:lock) ++* ++*/ ++void usb_current_limit_ctrl(bool unlock_current) ++{ ++ int tmp; ++ ++ tmp = readl(RKIO_GPIO6_PHYS + GPIO_SWPORT_DR); ++ if(unlock_current == true) ++ writel(tmp | 0x40, RKIO_GPIO6_PHYS + GPIO_SWPORT_DR); ++ else ++ writel(tmp & ~0x40, RKIO_GPIO6_PHYS + GPIO_SWPORT_DR); ++ ++ tmp = readl(RKIO_GPIO6_PHYS + GPIO_SWPORT_DDR); ++ writel(tmp | 0x40, RKIO_GPIO6_PHYS + GPIO_SWPORT_DDR); ++} ++ ++/* ++* ++* eMMC maskrom mode : GPIO6_A7 (H:disable maskrom, L:enable maskrom) ++* ++*/ ++void rk3288_maskrom_ctrl(bool enable_emmc) ++{ ++ int tmp; ++ ++ tmp = readl(RKIO_GPIO6_PHYS + GPIO_SWPORT_DR); ++ if(enable_emmc == true) ++ writel(tmp | 0x80, RKIO_GPIO6_PHYS + GPIO_SWPORT_DR); ++ else ++ writel(tmp & ~0x80, RKIO_GPIO6_PHYS + GPIO_SWPORT_DR); ++ ++ tmp = readl(RKIO_GPIO6_PHYS + GPIO_SWPORT_DDR); ++ writel(tmp | 0x80, RKIO_GPIO6_PHYS + GPIO_SWPORT_DDR); ++ mdelay(10); ++} ++ ++/* ++* ++* project id : GPIO2_A3 GPIO2_A2 GPIO2_A1 ++* pcb id : GPIO2_B2 GPIO2_B1 GPIO2_B0 ++* SDP/CDP : GPIO6_A5 (H:SDP, L:CDP) ++* usb current limit : GPIO6_A6 (H:unlock, L:lock) ++* eMMC maskrom mode : GPIO6_A7 (H:disable maskrom, L:enable maskrom) ++* ++* Please check TRM V1.2 part1 page 152 for the following register settings ++* ++*/ + int check_force_enter_ums_mode(void) + { + int tmp; + enum pcb_id pcbid; + enum project_id projectid; + +- // GPIO2_A1/GPIO2_A2/GPIO2_A3 pull up enable +- // please check TRM V1.2 part1 page 152 ++ // GPIO2_A3/GPIO2_A2/GPIO2_A1 pull up enable + tmp = readl(RKIO_GRF_PHYS + GRF_GPIO2A_P); + writel((tmp&~(0x03F<<2)) | 0x3F<<(16 + 2) | 0x15<<2, RKIO_GRF_PHYS + GRF_GPIO2A_P); + +- // GPIO2_A1/GPIO2_A2/GPIO2_A3/GPIO2_B0/GPIO2_B1/GPIO2_B2 set to input ++ // GPIO2_A3/GPIO2_A2/GPIO2_A1/GPIO2_B2/GPIO2_B1/GPIO2_B0 set to input + tmp = readl(RKIO_GPIO2_PHYS + GPIO_SWPORT_DDR); + writel(tmp & ~(0x70E), RKIO_GPIO2_PHYS + GPIO_SWPORT_DDR); + +@@ -117,10 +166,10 @@ int check_force_enter_ums_mode(void) + + mdelay(10); + +- // read GPIO2_A1/GPIO2_A2/GPIO2_A3 value ++ // read GPIO2_A3/GPIO2_A2/GPIO2_A1 value + projectid = (readl(RKIO_GPIO2_PHYS + GPIO_EXT_PORT) & 0x0E) >>1; + +- // read GPIO2_B0/GPIO2_B1/GPIO2_B2 value ++ // read GPIO2_B2/GPIO2_B1/GPIO2_B0 value + pcbid = (readl(RKIO_GPIO2_PHYS + GPIO_EXT_PORT) & 0x700) >> 8; + + // only Tinker Board S and the PR stage PCB has this function +@@ -130,13 +179,10 @@ int check_force_enter_ums_mode(void) + // SDP detected, enable EMMC and unlock usb current limit + printf("usb connected to SDP, force enter ums mode\n"); + force_ums = true; +- // unlock usb current limit and re-enable EMMC +- // set GPIO6_A6, GPIO6_A7 to high +- tmp = readl(RKIO_GPIO6_PHYS + GPIO_SWPORT_DR); +- writel(tmp | 0xc0, RKIO_GPIO6_PHYS + GPIO_SWPORT_DR); +- tmp = readl(RKIO_GPIO6_PHYS + GPIO_SWPORT_DDR); +- writel(tmp | 0xc0, RKIO_GPIO6_PHYS + GPIO_SWPORT_DDR); +- mdelay(10); ++ rk3288_maskrom_ctrl(true); ++ usb_current_limit_ctrl(true); ++ } else { ++ usb_current_limit_ctrl(false); + } + } + return 0; +-- +2.17.1 + diff --git a/patch/u-boot/u-boot-rockchip/board_tinkerboard/0045-modify-UMS-name-of-uboot.patch b/patch/u-boot/u-boot-rockchip/board_tinkerboard/0045-modify-UMS-name-of-uboot.patch new file mode 100644 index 0000000000..f270ccd5f6 --- /dev/null +++ b/patch/u-boot/u-boot-rockchip/board_tinkerboard/0045-modify-UMS-name-of-uboot.patch @@ -0,0 +1,32 @@ +From f5ada57f6298f3485e1fc6250ca2ab3be28862bb Mon Sep 17 00:00:00 2001 +From: scorpio_chang +Date: Thu, 1 Feb 2018 09:46:47 +0800 +Subject: [PATCH 45/50] modify UMS name of uboot +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Change-Id: Ibab54e15374db3c3c88460d2c3180e9787e4c426 +Reviewed-on: https://tp-biosrd-v02/gerrit/82114 +Reviewed-by: Jamess Huang(黃以民) +Tested-by: Jamess Huang(黃以民) +--- + cmd/usb_mass_storage.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c +index cb5260b558..4c3da13115 100644 +--- a/cmd/usb_mass_storage.c ++++ b/cmd/usb_mass_storage.c +@@ -108,7 +108,7 @@ static int ums_init(const char *devtype, const char *devnums_part_str) + name = malloc(UMS_NAME_LEN); + if (!name) + goto cleanup; +- snprintf(name, UMS_NAME_LEN, "UMS disk %d", ums_count); ++ snprintf(name, UMS_NAME_LEN, "Armbian UMS disk %d", ums_count); + ums[ums_count].name = name; + ums[ums_count].block_dev = *block_dev; + +-- +2.17.1 + diff --git a/patch/u-boot/u-boot-rockchip/board_tinkerboard/0049-added-timeout-when-force-entering-UMS-mode.patch b/patch/u-boot/u-boot-rockchip/board_tinkerboard/0049-added-timeout-when-force-entering-UMS-mode.patch new file mode 100644 index 0000000000..98b8370ba7 --- /dev/null +++ b/patch/u-boot/u-boot-rockchip/board_tinkerboard/0049-added-timeout-when-force-entering-UMS-mode.patch @@ -0,0 +1,146 @@ +From 7ffd3d083ac59f2b40ebea5b10334c541a5c6311 Mon Sep 17 00:00:00 2001 +From: jamess_huang +Date: Thu, 22 Feb 2018 15:28:45 +0800 +Subject: [PATCH 49/50] added timeout when force entering UMS mode +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Change-Id: I971d105a86628fa4282d1d801e05fabebf0b6569 +Reviewed-on: https://tp-biosrd-v02/gerrit/82232 +Reviewed-by: Jamess Huang(黃以民) +Tested-by: Jamess Huang(黃以民) +--- + arch/arm/mach-rockchip/rk3288-board.c | 4 +++- + cmd/usb_mass_storage.c | 4 ++++ + common/autoboot.c | 8 ++++++-- + drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c | 1 + + drivers/usb/gadget/f_mass_storage.c | 10 +++++++++- + include/linux/usb/gadget.h | 3 +++ + 6 files changed, 26 insertions(+), 4 deletions(-) + +diff --git a/arch/arm/mach-rockchip/rk3288-board.c b/arch/arm/mach-rockchip/rk3288-board.c +index f73520925b..1e40429af9 100644 +--- a/arch/arm/mach-rockchip/rk3288-board.c ++++ b/arch/arm/mach-rockchip/rk3288-board.c +@@ -101,6 +101,7 @@ void usb_current_limit_ctrl(bool unlock_current) + { + int tmp; + ++ printf("%s: unlock_current = %d\n", __func__, unlock_current); + tmp = readl(RKIO_GPIO6_PHYS + GPIO_SWPORT_DR); + if(unlock_current == true) + writel(tmp | 0x40, RKIO_GPIO6_PHYS + GPIO_SWPORT_DR); +@@ -120,6 +121,7 @@ void rk3288_maskrom_ctrl(bool enable_emmc) + { + int tmp; + ++ printf("%s: enable_emmc = %d\n", __func__, enable_emmc); + tmp = readl(RKIO_GPIO6_PHYS + GPIO_SWPORT_DR); + if(enable_emmc == true) + writel(tmp | 0x80, RKIO_GPIO6_PHYS + GPIO_SWPORT_DR); +diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c +index 4c3da13115..806b2e3dc0 100644 +--- a/cmd/usb_mass_storage.c ++++ b/cmd/usb_mass_storage.c +@@ -215,6 +215,10 @@ int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag, + usb_gadget_handle_interrupts(controller_index); + + rc = fsg_main_thread(NULL); ++ ++ if (rc == -ETIMEDOUT) { ++ goto cleanup_register; ++ } + if (rc) { + /* Check I/O error */ + if (rc == -EIO) +diff --git a/common/autoboot.c b/common/autoboot.c +index d63a4d7e79..81b6579f7c 100644 +--- a/common/autoboot.c ++++ b/common/autoboot.c +@@ -29,6 +29,7 @@ DECLARE_GLOBAL_DATA_PTR; + static int stored_bootdelay; + + bool force_ums = false; ++bool getdescriptor = false; + + #if defined(CONFIG_AUTOBOOT_KEYED) + #if defined(CONFIG_AUTOBOOT_STOP_STR_SHA256) +@@ -356,8 +357,11 @@ void autoboot_command(const char *s) + local_args[1]=str2; + local_args[2]=str3; + local_args[3]=str4; +- do_usb_mass_storage(NULL, 0, 4, local_args); +- return; ++ ++ if (do_usb_mass_storage(NULL, 0, 4, local_args) == -ETIMEDOUT) { ++ rk3288_maskrom_ctrl(false); ++ usb_current_limit_ctrl(false); ++ } + } + + if (stored_bootdelay != -1 && s && !abortboot(stored_bootdelay)) { +diff --git a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c +index 0d6d2fba8a..b9277b8b0a 100644 +--- a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c ++++ b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c +@@ -1368,6 +1368,7 @@ static void dwc2_ep0_setup(struct dwc2_udc *dev) + debug_cond(DEBUG_SETUP != 0, + "%s: *** USB_REQ_GET_DESCRIPTOR\n", + __func__); ++ getdescriptor = true; + break; + + case USB_REQ_SET_INTERFACE: +diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c +index 1ecb92ac6b..aad8fa4951 100644 +--- a/drivers/usb/gadget/f_mass_storage.c ++++ b/drivers/usb/gadget/f_mass_storage.c +@@ -666,7 +666,7 @@ static void busy_indicator(void) + static int sleep_thread(struct fsg_common *common) + { + int rc = 0; +- int i = 0, k = 0; ++ int i = 0, k = 0, j = 0; + + /* Wait until a signal arrives or we are woken up */ + for (;;) { +@@ -677,6 +677,7 @@ static int sleep_thread(struct fsg_common *common) + busy_indicator(); + i = 0; + k++; ++ j++; + } + + if (k == 10) { +@@ -691,6 +692,13 @@ static int sleep_thread(struct fsg_common *common) + k = 0; + } + ++ if (j == 300) { //about 3 seconds ++ if(force_ums && !getdescriptor) { ++ printf("wait for usb get descriptor cmd timeout\n"); ++ return -ETIMEDOUT; ++ } ++ } ++ + usb_gadget_handle_interrupts(0); + } + common->thread_wakeup_needed = 0; +diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h +index b824f13477..305cc56b04 100644 +--- a/include/linux/usb/gadget.h ++++ b/include/linux/usb/gadget.h +@@ -24,6 +24,9 @@ + + struct usb_ep; + ++extern bool force_ums; ++extern bool getdescriptor; ++ + /** + * struct usb_request - describes one i/o request + * @buf: Buffer used for data. Always provide this; some controllers +-- +2.17.1 + diff --git a/patch/u-boot/u-boot-rockchip/board_tinkerboard/200_tinker_uart3_debug.patch b/patch/u-boot/u-boot-rockchip/board_tinkerboard/200_tinker_uart3_debug.patch index a81cef11d7..b924e362de 100644 --- a/patch/u-boot/u-boot-rockchip/board_tinkerboard/200_tinker_uart3_debug.patch +++ b/patch/u-boot/u-boot-rockchip/board_tinkerboard/200_tinker_uart3_debug.patch @@ -11,7 +11,7 @@ Change-Id: Ie54fdd4cfc0a76dc7d9e94488ea11b576cf0171d 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/arch/arm/dts/rk3288-tinker.dts b/arch/arm/dts/rk3288-tinker.dts -index 4efba50e48..6193288949 100755 +index 4efba50e48..6193288949 100644 --- a/arch/arm/dts/rk3288-tinker.dts +++ b/arch/arm/dts/rk3288-tinker.dts @@ -12,7 +12,7 @@ @@ -33,7 +33,7 @@ index 4efba50e48..6193288949 100755 reg-shift = <2>; }; diff --git a/arch/arm/mach-rockchip/rk3288-board-spl.c b/arch/arm/mach-rockchip/rk3288-board-spl.c -index a0d0ce2ff4..797bc3eb56 100755 +index a0d0ce2ff4..797bc3eb56 100644 --- a/arch/arm/mach-rockchip/rk3288-board-spl.c +++ b/arch/arm/mach-rockchip/rk3288-board-spl.c @@ -198,10 +198,12 @@ void board_init_f(ulong dummy) @@ -54,7 +54,7 @@ index a0d0ce2ff4..797bc3eb56 100755 * Debug UART can be used from here if required: * diff --git a/configs/tinker-rk3288_defconfig b/configs/tinker-rk3288_defconfig -index 0b095b9571..89394f5cfd 100755 +index 0b095b9571..89394f5cfd 100644 --- a/configs/tinker-rk3288_defconfig +++ b/configs/tinker-rk3288_defconfig @@ -59,7 +59,7 @@ CONFIG_REGULATOR_RK8XX=y