mirror of
https://github.com/armbian/build.git
synced 2025-08-14 15:16:58 +02:00
161 lines
4.7 KiB
Diff
161 lines
4.7 KiB
Diff
From eff570086cca1c909725dc71b26b84f5bfd2b7a9 Mon Sep 17 00:00:00 2001
|
|
From: jamess_huang <Jamess_Huang@asus.com>
|
|
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 <asm/arch/gpio.h>
|
|
+
|
|
+ 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
|
|
|