blob: 807c717e33a470ba5d55f11123ceae5682ce03cf [file] [log] [blame]
Gregory CLEMENTdc253e22018-12-14 16:16:50 +01001// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * Copyright (c) 2018 Microsemi Corporation
4 */
5
6#include <common.h>
7#include <asm/io.h>
Lars Povlsene6ce78c2019-01-02 09:52:24 +01008#include <led.h>
Gregory CLEMENTdc253e22018-12-14 16:16:50 +01009
Gregory CLEMENTdc253e22018-12-14 16:16:50 +010010DECLARE_GLOBAL_DATA_PTR;
11
Lars Povlsen90392822018-12-20 09:56:05 +010012enum {
13 BOARD_TYPE_PCB090 = 0xAABBCD00,
14 BOARD_TYPE_PCB091,
15};
16
Gregory CLEMENTdc253e22018-12-14 16:16:50 +010017void board_debug_uart_init(void)
18{
19 /* too early for the pinctrl driver, so configure the UART pins here */
Lars Povlsen90392822018-12-20 09:56:05 +010020 mscc_gpio_set_alternate(30, 1);
21 mscc_gpio_set_alternate(31, 1);
Gregory CLEMENTdc253e22018-12-14 16:16:50 +010022}
23
24int board_early_init_r(void)
25{
26 /* Prepare SPI controller to be used in master mode */
27 writel(0, BASE_CFG + ICPU_SW_MODE);
28
29 /* Address of boot parameters */
30 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE;
Lars Povlsene6ce78c2019-01-02 09:52:24 +010031
32 /* LED setup */
33 if (IS_ENABLED(CONFIG_LED))
34 led_default_state();
35
Gregory CLEMENTdc253e22018-12-14 16:16:50 +010036 return 0;
37}
Lars Povlsen90392822018-12-20 09:56:05 +010038
39static void do_board_detect(void)
40{
41 u32 chipid = (readl(BASE_DEVCPU_GCB + CHIP_ID) >> 12) & 0xFFFF;
42
43 if (chipid == 0x7428 || chipid == 0x7424)
44 gd->board_type = BOARD_TYPE_PCB091; // Lu10
45 else
46 gd->board_type = BOARD_TYPE_PCB090; // Lu26
47}
48
49#if defined(CONFIG_MULTI_DTB_FIT)
50int board_fit_config_name_match(const char *name)
51{
52 if (gd->board_type == BOARD_TYPE_PCB090 &&
53 strcmp(name, "luton_pcb090") == 0)
54 return 0;
55
56 if (gd->board_type == BOARD_TYPE_PCB091 &&
57 strcmp(name, "luton_pcb091") == 0)
58 return 0;
59
60 return -1;
61}
62#endif
63
64#if defined(CONFIG_DTB_RESELECT)
65int embedded_dtb_select(void)
66{
67 do_board_detect();
68 fdtdec_setup();
69
70 return 0;
71}
72#endif