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