/*
- * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2016-2019, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
}
#pragma weak params_early_setup
-void params_early_setup(void *plat_param_from_bl2)
+void params_early_setup(u_register_t plat_param_from_bl2)
{
}
{
static console_16550_t console;
struct rockchip_bl31_params *arg_from_bl2 = (struct rockchip_bl31_params *) arg0;
- void *plat_params_from_bl2 = (void *) arg1;
- params_early_setup(plat_params_from_bl2);
+ params_early_setup(arg1);
#if COREBOOT
if (coreboot_serial.type)
/*
- * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2016-2019, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef PLAT_PARAMS_H
#define PLAT_PARAMS_H
+#include <lib/bl_aux_params/bl_aux_params.h>
#include <stdint.h>
-/*
- * We defined several plat parameter structs for BL2 to pass platform related
- * parameters to Rockchip BL31 platform code. All plat parameters start with
- * a common header, which has a type field to indicate the parameter type, and
- * a next pointer points to next parameter. If the parameter is the last one in
- * the list, next pointer will points to NULL. After the header comes the
- * variable-sized members that describe the parameter. The picture below shows
- * how the parameters are kept in memory.
- *
- * head of list ---> +----------------+ --+
- * | type | |
- * +----------------+ |--> struct bl31_plat_param
- * +----| next | |
- * | +----------------+ --+
- * | | parameter data |
- * | +----------------+
- * |
- * +--> +----------------+ --+
- * | type | |
- * +----------------+ |--> struct bl31_plat_param
- * NULL <---| next | |
- * +----------------+ --+
- * | parameter data |
- * +----------------+
- *
- * Note: The SCTLR_EL3.A bit (Alignment fault check enable) of ARM TF is set,
- * so be sure each parameter struct starts on 64-bit aligned address. If not,
- * alignment fault will occur during accessing its data member.
- */
-
-#define BL31_GPIO_DIR_OUT 0
-#define BL31_GPIO_DIR_IN 1
-
-#define BL31_GPIO_LEVEL_LOW 0
-#define BL31_GPIO_LEVEL_HIGH 1
-
-#define BL31_GPIO_PULL_NONE 0
-#define BL31_GPIO_PULL_UP 1
-#define BL31_GPIO_PULL_DOWN 2
-
/* param type */
-enum {
- PARAM_NONE = 0,
- PARAM_RESET,
- PARAM_POWEROFF,
- PARAM_SUSPEND_GPIO,
- PARAM_SUSPEND_APIO,
- PARAM_COREBOOT_TABLE,
+enum bl_aux_rk_param_type {
+ BL_AUX_PARAM_RK_RESET_GPIO = BL_AUX_PARAM_VENDOR_SPECIFIC_FIRST,
+ BL_AUX_PARAM_RK_POWEROFF_GPIO,
+ BL_AUX_PARAM_RK_SUSPEND_GPIO,
+ BL_AUX_PARAM_RK_SUSPEND_APIO,
};
-struct apio_info {
+struct bl_aux_rk_apio_info {
uint8_t apio1 : 1;
uint8_t apio2 : 1;
uint8_t apio3 : 1;
uint8_t apio5 : 1;
};
-struct gpio_info {
- uint8_t polarity;
- uint8_t direction;
- uint8_t pull_mode;
- uint32_t index;
-};
-
-/* common header for all plat parameter type */
-struct bl31_plat_param {
- uint64_t type;
- void *next;
-};
-
-struct bl31_gpio_param {
- struct bl31_plat_param h;
- struct gpio_info gpio;
-};
-
-struct bl31_apio_param {
- struct bl31_plat_param h;
- struct apio_info apio;
-};
-
-struct bl31_u64_param {
- struct bl31_plat_param h;
- uint64_t value;
+struct bl_aux_param_rk_apio {
+ struct bl_aux_param_header h;
+ struct bl_aux_rk_apio_info apio;
};
#endif /* PLAT_PARAMS_H */
/*
- * Copyright (c) 2014-2016, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2014-2019, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <lib/psci/psci.h>
#include <lib/xlat_tables/xlat_tables.h>
#include <lib/mmio.h>
+#include <plat_params.h>
#define __sramdata __attribute__((section(".sram.data")))
#define __sramconst __attribute__((section(".sram.rodata")))
void plat_delay_timer_init(void);
-void params_early_setup(void *plat_params_from_bl2);
+void params_early_setup(u_register_t plat_params_from_bl2);
void plat_rockchip_gic_driver_init(void);
void plat_rockchip_gic_init(void);
void platform_cpu_warmboot(void);
-struct gpio_info *plat_get_rockchip_gpio_reset(void);
-struct gpio_info *plat_get_rockchip_gpio_poweroff(void);
-struct gpio_info *plat_get_rockchip_suspend_gpio(uint32_t *count);
-struct apio_info *plat_get_rockchip_suspend_apio(void);
+struct bl_aux_gpio_info *plat_get_rockchip_gpio_reset(void);
+struct bl_aux_gpio_info *plat_get_rockchip_gpio_poweroff(void);
+struct bl_aux_gpio_info *plat_get_rockchip_suspend_gpio(uint32_t *count);
+struct bl_aux_rk_apio_info *plat_get_rockchip_suspend_apio(void);
void plat_rockchip_gpio_init(void);
void plat_rockchip_save_gpio(void);
void plat_rockchip_restore_gpio(void);
/*
- * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2016-2019, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <errno.h>
#include <string.h>
+#include <lib/bl_aux_params/bl_aux_params.h>
#include <common/bl_common.h>
#include <common/debug.h>
#include <drivers/console.h>
#include <plat_params.h>
#include <plat_private.h>
-static struct gpio_info param_reset;
-static struct gpio_info param_poweroff;
-static struct bl31_apio_param param_apio;
-static struct gpio_info *rst_gpio;
-static struct gpio_info *poweroff_gpio;
-static struct gpio_info suspend_gpio[10];
+static struct bl_aux_gpio_info rst_gpio;
+static struct bl_aux_gpio_info poweroff_gpio;
+static struct bl_aux_gpio_info suspend_gpio[10];
uint32_t suspend_gpio_cnt;
-static struct apio_info *suspend_apio;
+static struct bl_aux_rk_apio_info suspend_apio;
static uint32_t rk_uart_base = PLAT_RK_UART_BASE;
uint32_t rockchip_get_uart_base(void)
}
#if COREBOOT
-static int dt_process_fdt(void *blob)
+static int dt_process_fdt(u_register_t param_from_bl2)
{
return -ENODEV;
}
rk_uart_base = uart_base;
}
-static int dt_process_fdt(void *blob)
+static int dt_process_fdt(u_register_t param_from_bl2)
{
void *fdt = plat_get_fdt();
int ret;
- ret = fdt_open_into(blob, fdt, 0x10000);
+ ret = fdt_open_into((void *)param_from_bl2, fdt, 0x10000);
if (ret < 0)
return ret;
}
#endif
-struct gpio_info *plat_get_rockchip_gpio_reset(void)
+struct bl_aux_gpio_info *plat_get_rockchip_gpio_reset(void)
{
- return rst_gpio;
+ return &rst_gpio;
}
-struct gpio_info *plat_get_rockchip_gpio_poweroff(void)
+struct bl_aux_gpio_info *plat_get_rockchip_gpio_poweroff(void)
{
- return poweroff_gpio;
+ return &poweroff_gpio;
}
-struct gpio_info *plat_get_rockchip_suspend_gpio(uint32_t *count)
+struct bl_aux_gpio_info *plat_get_rockchip_suspend_gpio(uint32_t *count)
{
*count = suspend_gpio_cnt;
return &suspend_gpio[0];
}
-struct apio_info *plat_get_rockchip_suspend_apio(void)
+struct bl_aux_rk_apio_info *plat_get_rockchip_suspend_apio(void)
{
- return suspend_apio;
+ return &suspend_apio;
}
-void params_early_setup(void *plat_param_from_bl2)
+static bool rk_aux_param_handler(struct bl_aux_param_header *param)
{
- struct bl31_plat_param *bl2_param;
- struct bl31_gpio_param *gpio_param;
+ /* Store platform parameters for later processing if needed. */
+ switch (param->type) {
+ case BL_AUX_PARAM_RK_RESET_GPIO:
+ rst_gpio = ((struct bl_aux_param_gpio *)param)->gpio;
+ return true;
+ case BL_AUX_PARAM_RK_POWEROFF_GPIO:
+ poweroff_gpio = ((struct bl_aux_param_gpio *)param)->gpio;
+ return true;
+ case BL_AUX_PARAM_RK_SUSPEND_GPIO:
+ if (suspend_gpio_cnt >= ARRAY_SIZE(suspend_gpio)) {
+ ERROR("Exceeded the supported suspend GPIO number.\n");
+ return true;
+ }
+ suspend_gpio[suspend_gpio_cnt++] =
+ ((struct bl_aux_param_gpio *)param)->gpio;
+ return true;
+ case BL_AUX_PARAM_RK_SUSPEND_APIO:
+ suspend_apio = ((struct bl_aux_param_rk_apio *)param)->apio;
+ return true;
+ }
+ return false;
+}
+
+void params_early_setup(u_register_t plat_param_from_bl2)
+{
/*
* Test if this is a FDT passed as a platform-specific parameter
* block.
if (!dt_process_fdt(plat_param_from_bl2))
return;
- /* keep plat parameters for later processing if need */
- bl2_param = (struct bl31_plat_param *)plat_param_from_bl2;
- while (bl2_param) {
- switch (bl2_param->type) {
- case PARAM_RESET:
- gpio_param = (struct bl31_gpio_param *)bl2_param;
- memcpy(¶m_reset, &gpio_param->gpio,
- sizeof(struct gpio_info));
- rst_gpio = ¶m_reset;
- break;
- case PARAM_POWEROFF:
- gpio_param = (struct bl31_gpio_param *)bl2_param;
- memcpy(¶m_poweroff, &gpio_param->gpio,
- sizeof(struct gpio_info));
- poweroff_gpio = ¶m_poweroff;
- break;
- case PARAM_SUSPEND_GPIO:
- if (suspend_gpio_cnt >= ARRAY_SIZE(suspend_gpio)) {
- ERROR("exceed support suspend gpio number\n");
- break;
- }
- gpio_param = (struct bl31_gpio_param *)bl2_param;
- memcpy(&suspend_gpio[suspend_gpio_cnt],
- &gpio_param->gpio,
- sizeof(struct gpio_info));
- suspend_gpio_cnt++;
- break;
- case PARAM_SUSPEND_APIO:
- memcpy(¶m_apio, bl2_param,
- sizeof(struct bl31_apio_param));
- suspend_apio = ¶m_apio.apio;
- break;
-#if COREBOOT
- case PARAM_COREBOOT_TABLE:
- coreboot_table_setup((void *)
- ((struct bl31_u64_param *)bl2_param)->value);
- break;
-#endif
- default:
- ERROR("not expected type found %lld\n",
- bl2_param->type);
- break;
- }
- bl2_param = bl2_param->next;
- }
+ bl_aux_params_parse(plat_param_from_bl2, rk_aux_param_handler);
}
}
#pragma weak params_early_setup
-void params_early_setup(void *plat_param_from_bl2)
+void params_early_setup(u_register_t plat_param_from_bl2)
{
}
{
static console_16550_t console;
struct rockchip_bl31_params *arg_from_bl2 = (struct rockchip_bl31_params *) arg0;
- void *plat_params_from_bl2 = (void *) arg1;
- params_early_setup(plat_params_from_bl2);
+ params_early_setup(arg1);
#if COREBOOT
if (coreboot_serial.type)
#
-# Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
+# Copyright (c) 2016-2019, ARM Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
plat/common/plat_gicv2.c \
${RK_PLAT}/common/rockchip_gicv2.c
-PLAT_BL_COMMON_SOURCES := plat/common/aarch32/crash_console_helpers.S \
+PLAT_BL_COMMON_SOURCES := lib/bl_aux_params/bl_aux_params.c \
+ plat/common/aarch32/crash_console_helpers.S \
plat/common/plat_psci_common.c
PLAT_BL_COMMON_SOURCES += lib/xlat_tables/xlat_tables_common.c \
#
-# Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
+# Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
plat/common/plat_gicv2.c \
${RK_PLAT}/common/rockchip_gicv2.c
-PLAT_BL_COMMON_SOURCES := lib/xlat_tables/aarch64/xlat_tables.c \
+PLAT_BL_COMMON_SOURCES := lib/bl_aux_params/bl_aux_params.c \
+ lib/xlat_tables/aarch64/xlat_tables.c \
lib/xlat_tables/xlat_tables_common.c \
plat/common/aarch64/crash_console_helpers.S \
plat/common/plat_psci_common.c
#
-# Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
+# Copyright (c) 2016-2019, ARM Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
plat/common/plat_gicv2.c \
${RK_PLAT}/common/rockchip_gicv2.c
-PLAT_BL_COMMON_SOURCES := lib/xlat_tables/xlat_tables_common.c \
+PLAT_BL_COMMON_SOURCES := lib/bl_aux_params/bl_aux_params.c \
+ lib/xlat_tables/xlat_tables_common.c \
lib/xlat_tables/aarch64/xlat_tables.c \
plat/common/aarch64/crash_console_helpers.S \
plat/common/plat_psci_common.c
/*
- * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2016-2019, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
static void suspend_apio(void)
{
- struct apio_info *suspend_apio;
+ struct bl_aux_rk_apio_info *suspend_apio;
int i;
suspend_apio = plat_get_rockchip_suspend_apio();
static void resume_apio(void)
{
- struct apio_info *suspend_apio;
+ struct bl_aux_rk_apio_info *suspend_apio;
int i;
suspend_apio = plat_get_rockchip_suspend_apio();
static void suspend_gpio(void)
{
- struct gpio_info *suspend_gpio;
+ struct bl_aux_gpio_info *suspend_gpio;
uint32_t count;
int i;
static void resume_gpio(void)
{
- struct gpio_info *suspend_gpio;
+ struct bl_aux_gpio_info *suspend_gpio;
uint32_t count;
int i;
void __dead2 rockchip_soc_soft_reset(void)
{
- struct gpio_info *rst_gpio;
+ struct bl_aux_gpio_info *rst_gpio;
rst_gpio = plat_get_rockchip_gpio_reset();
void __dead2 rockchip_soc_system_off(void)
{
- struct gpio_info *poweroff_gpio;
+ struct bl_aux_gpio_info *poweroff_gpio;
poweroff_gpio = plat_get_rockchip_gpio_poweroff();
/*
- * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2016-2019, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#
-# Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
+# Copyright (c) 2016-2019, ARM Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
plat/common/plat_gicv3.c \
${RK_PLAT}/common/rockchip_gicv3.c
-PLAT_BL_COMMON_SOURCES := lib/xlat_tables/xlat_tables_common.c \
+PLAT_BL_COMMON_SOURCES := lib/bl_aux_params/bl_aux_params.c \
+ lib/xlat_tables/xlat_tables_common.c \
lib/xlat_tables/aarch64/xlat_tables.c \
plat/common/aarch64/crash_console_helpers.S \
plat/common/plat_psci_common.c