blob: 114f7fd9d9b25a4df1206630195f9fed8dd277e4 [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>
Horatiu Vulturfad0dd82019-05-01 13:16:59 +02009#include <miiphy.h>
Gregory CLEMENTdc253e22018-12-14 16:16:50 +010010
Lars Povlsen90392822018-12-20 09:56:05 +010011enum {
12 BOARD_TYPE_PCB090 = 0xAABBCD00,
13 BOARD_TYPE_PCB091,
14};
15
Gregory CLEMENTdc253e22018-12-14 16:16:50 +010016void board_debug_uart_init(void)
17{
18 /* too early for the pinctrl driver, so configure the UART pins here */
Lars Povlsen90392822018-12-20 09:56:05 +010019 mscc_gpio_set_alternate(30, 1);
20 mscc_gpio_set_alternate(31, 1);
Gregory CLEMENTdc253e22018-12-14 16:16:50 +010021}
22
23int board_early_init_r(void)
24{
25 /* Prepare SPI controller to be used in master mode */
26 writel(0, BASE_CFG + ICPU_SW_MODE);
27
28 /* Address of boot parameters */
29 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE;
Lars Povlsene6ce78c2019-01-02 09:52:24 +010030
31 /* LED setup */
32 if (IS_ENABLED(CONFIG_LED))
33 led_default_state();
34
Horatiu Vulturfad0dd82019-05-01 13:16:59 +020035 return 0;
36}
37
38int board_phy_config(struct phy_device *phydev)
39{
40 phy_write(phydev, 0, 31, 0x10);
41 phy_write(phydev, 0, 18, 0x80A0);
42 while (phy_read(phydev, 0, 18) & 0x8000)
43 ;
44 phy_write(phydev, 0, 31, 0);
Gregory CLEMENTdc253e22018-12-14 16:16:50 +010045 return 0;
46}
Lars Povlsen90392822018-12-20 09:56:05 +010047
48static void do_board_detect(void)
49{
50 u32 chipid = (readl(BASE_DEVCPU_GCB + CHIP_ID) >> 12) & 0xFFFF;
51
52 if (chipid == 0x7428 || chipid == 0x7424)
53 gd->board_type = BOARD_TYPE_PCB091; // Lu10
54 else
55 gd->board_type = BOARD_TYPE_PCB090; // Lu26
56}
57
58#if defined(CONFIG_MULTI_DTB_FIT)
59int board_fit_config_name_match(const char *name)
60{
61 if (gd->board_type == BOARD_TYPE_PCB090 &&
62 strcmp(name, "luton_pcb090") == 0)
63 return 0;
64
65 if (gd->board_type == BOARD_TYPE_PCB091 &&
66 strcmp(name, "luton_pcb091") == 0)
67 return 0;
68
69 return -1;
70}
71#endif
72
73#if defined(CONFIG_DTB_RESELECT)
74int embedded_dtb_select(void)
75{
76 do_board_detect();
77 fdtdec_setup();
78
79 return 0;
80}
81#endif