[U-Boot] [PATCH 18/35] rockchip: rk3288-phycore: move phycore_init() to its own board file

Wadim Egorov
2019-07-23T10:36:37Z

Hi Kever,

this is fine for me. You can drop the phycore_init() code completely. No
need to carry this around in our board code.
The SOM was redesigned and is equipped with an STM8 connected to the
RK818. The required setup we did before in the SPL is now done by the ST
controller. I know there are only a few SOMs without the STM8 out in the
wild. So if you remove it it will affect only a few people who probably
already have both boards.

Thanks,
Wadim

On 22.07.19 13:59, Kever Yang wrote:
> phycore_init() is use for phycore board only, it should be move back
> to phycore-rk3288.c
>
> Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
> ---
>
> arch/arm/mach-rockchip/rk3288-board-spl.c | 39 ----------------
> arch/arm/mach-rockchip/rk3288/Kconfig | 1 +
> board/phytec/phycore_rk3288/phycore-rk3288.c | 47 ++++++++++++++++++++
> 3 files changed, 48 insertions(+), 39 deletions(-)
>
> diff --git a/arch/arm/mach-rockchip/rk3288-board-spl.c b/arch/arm/mach-rockchip/rk3288-board-spl.c
> index 6db5369a10..13cd86079b 100644
> --- a/arch/arm/mach-rockchip/rk3288-board-spl.c
> +++ b/arch/arm/mach-rockchip/rk3288-board-spl.c
> @@ -25,8 +25,6 @@
> #include <dm/root.h>
> #include <dm/test.h>
> #include <dm/util.h>
> -#include <power/regulator.h>
> -#include <power/rk8xx_pmic.h>
>
> DECLARE_GLOBAL_DATA_PTR;
>
> @@ -81,32 +79,6 @@ fallback:
> return BOOT_DEVICE_MMC1;
> }
>
> -#if !defined(CONFIG_SPL_OF_PLATDATA)
> -static int phycore_init(void)
> -{
> - struct udevice *pmic;
> - int ret;
> -
> - ret = uclass_first_device_err(UCLASS_PMIC, &pmic);
> - if (ret)
> - return ret;
> -
> -#if defined(CONFIG_SPL_POWER_SUPPORT)
> - /* Increase USB input current to 2A */
> - ret = rk818_spl_configure_usb_input_current(pmic, 2000);
> - if (ret)
> - return ret;
> -
> - /* Close charger when USB lower then 3.26V */
> - ret = rk818_spl_configure_usb_chrg_shutdown(pmic, 3260000);
> - if (ret)
> - return ret;
> -#endif
> -
> - return 0;
> -}
> -#endif
> -
> __weak int arch_cpu_init(void)
> {
> return 0;
> @@ -175,17 +147,6 @@ void board_init_f(ulong dummy)
> return;
> }
>
> -#if !defined(CONFIG_SPL_OF_PLATDATA)
> - if (of_machine_is_compatible("phytec,rk3288-phycore-som")) {
> - ret = phycore_init();
> - if (ret) {
> - debug("Failed to set up phycore power settings: %d\n",
> - ret);
> - return;
> - }
> - }
> -#endif
> -
> #if !defined(CONFIG_SUPPORT_TPL)
> debug("\nspl:init dram\n");
> ret = uclass_get_device(UCLASS_RAM, 0, &dev);
> diff --git a/arch/arm/mach-rockchip/rk3288/Kconfig b/arch/arm/mach-rockchip/rk3288/Kconfig
> index 6e3ab1d06b..87d0786ba8 100644
> --- a/arch/arm/mach-rockchip/rk3288/Kconfig
> +++ b/arch/arm/mach-rockchip/rk3288/Kconfig
> @@ -85,6 +85,7 @@ config TARGET_MIQI_RK3288
> config TARGET_PHYCORE_RK3288
> bool "phyCORE-RK3288"
> select BOARD_LATE_INIT
> + select SPL_BOARD_INIT if SPL
> help
> Add basic support for the PCM-947 carrier board, a RK3288 based
> development board made by PHYTEC. This board works in a combination
> diff --git a/board/phytec/phycore_rk3288/phycore-rk3288.c b/board/phytec/phycore_rk3288/phycore-rk3288.c
> index ffe1833b06..fbf1511978 100644
> --- a/board/phytec/phycore_rk3288/phycore-rk3288.c
> +++ b/board/phytec/phycore_rk3288/phycore-rk3288.c
> @@ -8,10 +8,13 @@
> #include <common.h>
> #include <dm.h>
> #include <environment.h>
> +#include <fdtdec.h>
> #include <i2c.h>
> #include <i2c_eeprom.h>
> #include <netdev.h>
> #include "som.h"
> +#include <power/regulator.h>
> +#include <power/rk8xx_pmic.h>
>
> static int valid_rk3288_som(struct rk3288_som *som)
> {
> @@ -68,3 +71,47 @@ int rk_board_late_init(void)
>
> return 0;
> }
> +
> +#ifdef CONFIG_SPL_BUILD
> +#if !defined(CONFIG_SPL_OF_PLATDATA)
> +static int phycore_init(void)
> +{
> + struct udevice *pmic;
> + int ret;
> +
> + ret = uclass_first_device_err(UCLASS_PMIC, &pmic);
> + if (ret)
> + return ret;
> +
> +#if defined(CONFIG_SPL_POWER_SUPPORT)
> + /* Increase USB input current to 2A */
> + ret = rk818_spl_configure_usb_input_current(pmic, 2000);
> + if (ret)
> + return ret;
> +
> + /* Close charger when USB lower then 3.26V */
> + ret = rk818_spl_configure_usb_chrg_shutdown(pmic, 3260000);
> + if (ret)
> + return ret;
> +#endif
> +
> + return 0;
> +}
> +#endif
> +
> +void spl_board_init(void)
> +{
> +#if !defined(CONFIG_SPL_OF_PLATDATA)
> + int ret;
> +
> + if (of_machine_is_compatible("phytec,rk3288-phycore-som")) {
> + ret = phycore_init();
> + if (ret) {
> + debug("Failed to set up phycore power settings: %d\n",
> + ret);
> + return;
> + }
> + }
> +#endif
> +}
> +#endif