Skip to content
Snippets Groups Projects
Commit baa3e4de authored by Philip Müller's avatar Philip Müller
Browse files

[pkg-upd] 2021.01-rc3-7

parent 8efadc78
No related branches found
No related tags found
No related merge requests found
Pipeline #6114 passed
From 93ef053e2af9eec9eece77e42b54da3e4675a719 Mon Sep 17 00:00:00 2001
From: Dragan Simic <dragan.simic@gmail.com>
Date: Wed, 22 Dec 2021 10:15:43 +0100
Subject: [PATCH] Configure USB power settings for PinePhone Pro
---
arch/arm/mach-rockchip/rk3399/rk3399.c | 5 ++
.../pinephone-pro-rk3399.c | 50 +++++++++++++++++--
configs/pinephone-pro-rk3399_defconfig | 5 ++
3 files changed, 55 insertions(+), 5 deletions(-)
diff --git a/arch/arm/mach-rockchip/rk3399/rk3399.c b/arch/arm/mach-rockchip/rk3399/rk3399.c
index c6434839..eeb77216 100644
--- a/arch/arm/mach-rockchip/rk3399/rk3399.c
+++ b/arch/arm/mach-rockchip/rk3399/rk3399.c
@@ -245,9 +245,14 @@ void __weak led_setup(void)
{
}
+void __weak power_setup(void)
+{
+}
+
void spl_board_init(void)
{
led_setup();
+ power_setup();
#if defined(SPL_GPIO_SUPPORT)
struct rockchip_cru *cru = rockchip_get_cru();
diff --git a/board/pine64/pinephone-pro-rk3399/pinephone-pro-rk3399.c b/board/pine64/pinephone-pro-rk3399/pinephone-pro-rk3399.c
index d7908461..aa10c11d 100644
--- a/board/pine64/pinephone-pro-rk3399/pinephone-pro-rk3399.c
+++ b/board/pine64/pinephone-pro-rk3399/pinephone-pro-rk3399.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* (C) Copyright 2019 Vasily Khoruzhick <anarsoul@gmail.com>
+ * (C) Copyright 2021 Dragan Simic <dsimic@buserror.io>
*/
#include <common.h>
@@ -12,6 +13,8 @@
#include <asm/arch-rockchip/grf_rk3399.h>
#include <asm/arch-rockchip/hardware.h>
#include <asm/arch-rockchip/misc.h>
+#include <power/regulator.h>
+#include <power/rk8xx_pmic.h>
#define GRF_IO_VSEL_BT565_SHIFT 0
#define PMUGRF_CON0_VSEL_SHIFT 8
@@ -19,10 +22,8 @@
#ifdef CONFIG_MISC_INIT_R
static void setup_iodomain(void)
{
- struct rk3399_grf_regs *grf =
- syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
- struct rk3399_pmugrf_regs *pmugrf =
- syscon_get_first_range(ROCKCHIP_SYSCON_PMUGRF);
+ struct rk3399_grf_regs *grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
+ struct rk3399_pmugrf_regs *pmugrf = syscon_get_first_range(ROCKCHIP_SYSCON_PMUGRF);
/* BT565 is in 1.8v domain */
rk_setreg(&grf->io_vsel, 1 << GRF_IO_VSEL_BT565_SHIFT);
@@ -52,5 +53,44 @@ int misc_init_r(void)
return ret;
}
+#endif /* CONFIG_MISC_INIT_R */
-#endif
+/*
+ * TODO: Change CONFIG_SPL_POWER_SUPPORT to CONFIG_SPL_POWER, to match newer U-Boot versions.
+ * The same applies to CONFIG_SPL_I2C_SUPPORT.
+ */
+
+#if defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_OF_PLATDATA) && defined(CONFIG_SPL_POWER_SUPPORT)
+static int setup_usb_power(void)
+{
+ struct udevice *pmic;
+ int ret;
+
+ ret = uclass_first_device_err(UCLASS_PMIC, &pmic);
+ if (ret)
+ return ret;
+
+ /* increase USB current limit to 2.5 A */
+ ret = rk818_spl_configure_usb_input_current(pmic, 2500);
+ if (ret)
+ return ret;
+
+ /* set USB low voltage threshold to 3.26 V */
+ ret = rk818_spl_configure_usb_chrg_shutdown(pmic, 3260000);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+void power_setup(void)
+{
+ int ret;
+
+ ret = setup_usb_power();
+ if (ret) {
+ debug("Failed to configure USB power settings: %d\n", ret);
+ return;
+ }
+}
+#endif /* CONFIG_SPL_BUILD && !CONFIG_SPL_OF_PLATDATA && CONFIG_SPL_POWER_SUPPORT */
diff --git a/configs/pinephone-pro-rk3399_defconfig b/configs/pinephone-pro-rk3399_defconfig
index ad4b5e0c..80305bf7 100644
--- a/configs/pinephone-pro-rk3399_defconfig
+++ b/configs/pinephone-pro-rk3399_defconfig
@@ -21,6 +21,11 @@ CONFIG_SPL_STACK_R=y
CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000
CONFIG_SPL_MTD_SUPPORT=y
CONFIG_SPL_SPI_LOAD=y
+CONFIG_SPL_I2C_SUPPORT=y
+CONFIG_SPL_POWER_SUPPORT=y
+CONFIG_SPL_GPIO_SUPPORT=y
+CONFIG_SPL_DM=y
+CONFIG_SPL_DM_REGULATOR=y
CONFIG_TPL=y
CONFIG_CMD_BOOTZ=y
CONFIG_CMD_GPIO=y
--
2.33.1
  • Author Owner

    Hmm, for me it doesn't boot yet @dragan-simic

  • fkardame :speech_balloon: @spikerguy ·
    Owner
    U-Boot TPL 2021.01-7 (Dec 22 2021 - 15:56:22)
    Channel 0: LPDDR4, 50MHz
    BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB
    Channel 1: LPDDR4, 50MHz
    BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB
    256B stride
    lpddr4_set_rate: change freq to 400000000 mhz 0, 1
    lpddr4_set_rate: change freq to 800000000 mhz 1, 0
    Trying to boot from BOOTROM
    Returning to boot ROM...
    spl_early_init() failed: -6
    ### ERROR ### Please RESET the board ###

    Boot log on my device. Its an early devkit. @dragan-simic

    Edited by fkardame
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment