Gregory CLEMENT | dc253e2 | 2018-12-14 16:16:50 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: (GPL-2.0+ OR MIT) |
| 2 | /* |
| 3 | * Copyright (c) 2018 Microsemi Corporation |
| 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Simon Glass | a7b5130 | 2019-11-14 12:57:46 -0700 | [diff] [blame^] | 7 | #include <init.h> |
Gregory CLEMENT | dc253e2 | 2018-12-14 16:16:50 +0100 | [diff] [blame] | 8 | #include <asm/io.h> |
Lars Povlsen | e6ce78c | 2019-01-02 09:52:24 +0100 | [diff] [blame] | 9 | #include <led.h> |
Horatiu Vultur | fad0dd8 | 2019-05-01 13:16:59 +0200 | [diff] [blame] | 10 | #include <miiphy.h> |
Gregory CLEMENT | dc253e2 | 2018-12-14 16:16:50 +0100 | [diff] [blame] | 11 | |
Lars Povlsen | 9039282 | 2018-12-20 09:56:05 +0100 | [diff] [blame] | 12 | enum { |
| 13 | BOARD_TYPE_PCB090 = 0xAABBCD00, |
| 14 | BOARD_TYPE_PCB091, |
| 15 | }; |
| 16 | |
Gregory CLEMENT | dc253e2 | 2018-12-14 16:16:50 +0100 | [diff] [blame] | 17 | void board_debug_uart_init(void) |
| 18 | { |
| 19 | /* too early for the pinctrl driver, so configure the UART pins here */ |
Lars Povlsen | 9039282 | 2018-12-20 09:56:05 +0100 | [diff] [blame] | 20 | mscc_gpio_set_alternate(30, 1); |
| 21 | mscc_gpio_set_alternate(31, 1); |
Gregory CLEMENT | dc253e2 | 2018-12-14 16:16:50 +0100 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | int 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 Povlsen | e6ce78c | 2019-01-02 09:52:24 +0100 | [diff] [blame] | 31 | |
| 32 | /* LED setup */ |
| 33 | if (IS_ENABLED(CONFIG_LED)) |
| 34 | led_default_state(); |
| 35 | |
Horatiu Vultur | fad0dd8 | 2019-05-01 13:16:59 +0200 | [diff] [blame] | 36 | return 0; |
| 37 | } |
| 38 | |
| 39 | int board_phy_config(struct phy_device *phydev) |
| 40 | { |
| 41 | phy_write(phydev, 0, 31, 0x10); |
| 42 | phy_write(phydev, 0, 18, 0x80A0); |
| 43 | while (phy_read(phydev, 0, 18) & 0x8000) |
| 44 | ; |
| 45 | phy_write(phydev, 0, 31, 0); |
Gregory CLEMENT | dc253e2 | 2018-12-14 16:16:50 +0100 | [diff] [blame] | 46 | return 0; |
| 47 | } |
Lars Povlsen | 9039282 | 2018-12-20 09:56:05 +0100 | [diff] [blame] | 48 | |
| 49 | static void do_board_detect(void) |
| 50 | { |
| 51 | u32 chipid = (readl(BASE_DEVCPU_GCB + CHIP_ID) >> 12) & 0xFFFF; |
| 52 | |
| 53 | if (chipid == 0x7428 || chipid == 0x7424) |
| 54 | gd->board_type = BOARD_TYPE_PCB091; // Lu10 |
| 55 | else |
| 56 | gd->board_type = BOARD_TYPE_PCB090; // Lu26 |
| 57 | } |
| 58 | |
| 59 | #if defined(CONFIG_MULTI_DTB_FIT) |
| 60 | int board_fit_config_name_match(const char *name) |
| 61 | { |
| 62 | if (gd->board_type == BOARD_TYPE_PCB090 && |
| 63 | strcmp(name, "luton_pcb090") == 0) |
| 64 | return 0; |
| 65 | |
| 66 | if (gd->board_type == BOARD_TYPE_PCB091 && |
| 67 | strcmp(name, "luton_pcb091") == 0) |
| 68 | return 0; |
| 69 | |
| 70 | return -1; |
| 71 | } |
| 72 | #endif |
| 73 | |
| 74 | #if defined(CONFIG_DTB_RESELECT) |
| 75 | int embedded_dtb_select(void) |
| 76 | { |
| 77 | do_board_detect(); |
| 78 | fdtdec_setup(); |
| 79 | |
| 80 | return 0; |
| 81 | } |
| 82 | #endif |