#include <env.h>
#include <errno.h>
#include <init.h>
-#include <limits.h>
#include <linux/sizes.h>
#include <lmb.h>
#include <part.h>
#define lmb_alloc(size, addr) \
lmb_alloc_mem(LMB_MEM_ALLOC_ANY, SZ_2M, addr, size, LMB_NONE)
-struct exynos_board_info {
- const char *name;
- const char *chip;
-
- char serial[64];
-
- int (*const match)(struct exynos_board_info *);
- const char *match_model;
- const u8 match_max_rev;
-};
-
/*
* The memory mapping includes all DRAM banks, along with the
* peripheral block, and a sentinel at the end. This is filled in
return bootargs_prop->data;
}
-static int exynos7870_fdt_match(struct exynos_board_info *board_info)
-{
- const char *prev_bl_bootargs;
- int val, ret;
-
- prev_bl_bootargs = exynos_prev_bl_get_bootargs();
- if (!prev_bl_bootargs)
- return -1;
-
- /*
- * Read the cmdline property which stores the
- * bootloader/firmware version. An example value of the option
- * can be: "J600GDXU3ARH5". This can be used to verify the model
- * of the device.
- */
- ret = cmdline_get_arg(prev_bl_bootargs, "androidboot.bootloader", &val);
- if (ret < 0) {
- log_err("%s: unable to find property for bootloader version (%d)\n",
- __func__, ret);
- return -1;
- }
-
- if (strncmp(prev_bl_bootargs + val, board_info->match_model,
- strlen(board_info->match_model)))
- return -1;
-
- /*
- * Read the cmdline property which stores the hardware revision.
- * This is required to allow selecting one of multiple dtbs
- * available of a single device, varying in hardware changes in
- * different revisions.
- */
- ret = cmdline_get_arg(prev_bl_bootargs, "androidboot.revision", &val);
- if (ret < 0)
- ret = cmdline_get_arg(prev_bl_bootargs, "androidboot.hw_rev", &val);
- if (ret < 0) {
- log_err("%s: unable to find property for bootloader revision (%d)\n",
- __func__, ret);
- return -1;
- }
-
- if (strtoul(prev_bl_bootargs + val, NULL, 10) > board_info->match_max_rev)
- return -1;
-
- /*
- * Read the cmdline property which stores the serial number.
- * Store this in the board info struct.
- */
- ret = cmdline_get_arg(prev_bl_bootargs, "androidboot.serialno", &val);
- if (ret > 0)
- strlcpy(board_info->serial, prev_bl_bootargs + val, ret);
-
- return 0;
-}
-
-/*
- * This array is used for matching the models and revisions with the
- * devicetree used by U-Boot. This allows a single U-Boot to work on
- * multiple devices.
- *
- * Entries are kept in lexicographical order of board SoCs, followed by
- * board names.
- */
-static struct exynos_board_info exynos_board_info_match[] = {
- {
- /* Samsung Galaxy A2 Core */
- .name = "a2corelte",
- .chip = "exynos7870",
- .match = exynos7870_fdt_match,
- .match_model = "A260",
- .match_max_rev = U8_MAX,
- }, {
- /* Samsung Galaxy J6 */
- .name = "j6lte",
- .chip = "exynos7870",
- .match = exynos7870_fdt_match,
- .match_model = "J600",
- .match_max_rev = U8_MAX,
- }, {
- /* Samsung Galaxy J7 Prime */
- .name = "on7xelte",
- .chip = "exynos7870",
- .match = exynos7870_fdt_match,
- .match_model = "G610",
- .match_max_rev = U8_MAX,
- },
-};
-
static void exynos_parse_dram_banks(const void *fdt_base)
{
u64 mem_addr, mem_size = 0;
return 0;
}
-int board_fit_config_name_match(const char *name)
-{
- struct exynos_board_info *board_info;
- char buf[128];
- unsigned int i;
- int ret;
-
- /*
- * Iterate over exynos_board_info_match[] to select the
- * appropriate board info struct. If not found, exit.
- */
- for (i = 0; i < ARRAY_SIZE(exynos_board_info_match); i++) {
- board_info = exynos_board_info_match + i;
- snprintf(buf, sizeof(buf), "%s-%s", board_info->chip,
- board_info->name);
-
- if (!strcmp(name, buf))
- break;
- }
- if (i == ARRAY_SIZE(exynos_board_info_match))
- return -1;
-
- /*
- * Execute match logic for the target board. This is separated
- * as the process may be different for multiple boards.
- */
- ret = board_info->match(board_info);
- if (ret)
- return ret;
-
- /*
- * Store the correct board info struct in gd->board_type to
- * allow other functions to access it.
- */
- gd->board_type = (ulong)board_info;
- log_debug("%s: device detected: %s\n", __func__, name);
-
- return 0;
-}
-
int timer_init(void)
{
ofnode timer_node;
int board_early_init_f(void)
{
- const struct exynos_board_info *board_info;
-
- if (!gd->board_type)
- return -ENODATA;
- board_info = (const struct exynos_board_info *)gd->board_type;
-
exynos_parse_dram_banks(gd->fdt_blob);
- /*
- * Some devices have multiple variants based on the amount of
- * memory and internal storage. The lowest bank base has been
- * observed to have the same memory range in all board variants.
- * For variants with more memory, the previous bootloader should
- * overlay the devicetree with the required extra memory ranges.
- */
- exynos_parse_dram_banks((const void *)get_prev_bl_fdt_addr());
return 0;
}