Gregory CLEMENT | f8c8ced | 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> |
| 7 | #include <asm/io.h> |
Lars Povlsen | 711f2dc | 2019-01-02 09:52:24 +0100 | [diff] [blame] | 8 | #include <led.h> |
Horatiu Vultur | bd9216e | 2019-05-01 13:16:59 +0200 | [diff] [blame] | 9 | #include <miiphy.h> |
Gregory CLEMENT | f8c8ced | 2018-12-14 16:16:50 +0100 | [diff] [blame] | 10 | |
Lars Povlsen | e9f1492 | 2018-12-20 09:56:05 +0100 | [diff] [blame] | 11 | enum { |
| 12 | BOARD_TYPE_PCB090 = 0xAABBCD00, |
| 13 | BOARD_TYPE_PCB091, |
| 14 | }; |
| 15 | |
Gregory CLEMENT | f8c8ced | 2018-12-14 16:16:50 +0100 | [diff] [blame] | 16 | void board_debug_uart_init(void) |
| 17 | { |
| 18 | /* too early for the pinctrl driver, so configure the UART pins here */ |
Lars Povlsen | e9f1492 | 2018-12-20 09:56:05 +0100 | [diff] [blame] | 19 | mscc_gpio_set_alternate(30, 1); |
| 20 | mscc_gpio_set_alternate(31, 1); |
Gregory CLEMENT | f8c8ced | 2018-12-14 16:16:50 +0100 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | int 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 Povlsen | 711f2dc | 2019-01-02 09:52:24 +0100 | [diff] [blame] | 30 | |
| 31 | /* LED setup */ |
| 32 | if (IS_ENABLED(CONFIG_LED)) |
| 33 | led_default_state(); |
| 34 | |
Gregory CLEMENT | f8c8ced | 2018-12-14 16:16:50 +0100 | [diff] [blame] | 35 | return 0; |
| 36 | } |
Lars Povlsen | e9f1492 | 2018-12-20 09:56:05 +0100 | [diff] [blame] | 37 | |
Horatiu Vultur | bd9216e | 2019-05-01 13:16:59 +0200 | [diff] [blame] | 38 | int 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); |
| 45 | return 0; |
| 46 | } |
| 47 | |
Lars Povlsen | e9f1492 | 2018-12-20 09:56:05 +0100 | [diff] [blame] | 48 | static 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) |
| 59 | int 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) |
| 74 | int embedded_dtb_select(void) |
| 75 | { |
| 76 | do_board_detect(); |
| 77 | fdtdec_setup(); |
| 78 | |
| 79 | return 0; |
| 80 | } |
| 81 | #endif |