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> |
Simon Glass | 4d72caa | 2020-05-10 11:40:01 -0600 | [diff] [blame] | 7 | #include <image.h> |
Simon Glass | 5255932 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 8 | #include <init.h> |
Simon Glass | 401d1c4 | 2020-10-30 21:38:53 -0600 | [diff] [blame^] | 9 | #include <asm/global_data.h> |
Gregory CLEMENT | f8c8ced | 2018-12-14 16:16:50 +0100 | [diff] [blame] | 10 | #include <asm/io.h> |
Lars Povlsen | 711f2dc | 2019-01-02 09:52:24 +0100 | [diff] [blame] | 11 | #include <led.h> |
Horatiu Vultur | bd9216e | 2019-05-01 13:16:59 +0200 | [diff] [blame] | 12 | #include <miiphy.h> |
Gregory CLEMENT | f8c8ced | 2018-12-14 16:16:50 +0100 | [diff] [blame] | 13 | |
Lars Povlsen | e9f1492 | 2018-12-20 09:56:05 +0100 | [diff] [blame] | 14 | enum { |
| 15 | BOARD_TYPE_PCB090 = 0xAABBCD00, |
| 16 | BOARD_TYPE_PCB091, |
| 17 | }; |
| 18 | |
Gregory CLEMENT | f8c8ced | 2018-12-14 16:16:50 +0100 | [diff] [blame] | 19 | void board_debug_uart_init(void) |
| 20 | { |
| 21 | /* too early for the pinctrl driver, so configure the UART pins here */ |
Lars Povlsen | e9f1492 | 2018-12-20 09:56:05 +0100 | [diff] [blame] | 22 | mscc_gpio_set_alternate(30, 1); |
| 23 | mscc_gpio_set_alternate(31, 1); |
Gregory CLEMENT | f8c8ced | 2018-12-14 16:16:50 +0100 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | int board_early_init_r(void) |
| 27 | { |
| 28 | /* Prepare SPI controller to be used in master mode */ |
| 29 | writel(0, BASE_CFG + ICPU_SW_MODE); |
| 30 | |
| 31 | /* Address of boot parameters */ |
| 32 | gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE; |
Lars Povlsen | 711f2dc | 2019-01-02 09:52:24 +0100 | [diff] [blame] | 33 | |
| 34 | /* LED setup */ |
| 35 | if (IS_ENABLED(CONFIG_LED)) |
| 36 | led_default_state(); |
| 37 | |
Gregory CLEMENT | f8c8ced | 2018-12-14 16:16:50 +0100 | [diff] [blame] | 38 | return 0; |
| 39 | } |
Lars Povlsen | e9f1492 | 2018-12-20 09:56:05 +0100 | [diff] [blame] | 40 | |
Horatiu Vultur | bd9216e | 2019-05-01 13:16:59 +0200 | [diff] [blame] | 41 | int board_phy_config(struct phy_device *phydev) |
| 42 | { |
| 43 | phy_write(phydev, 0, 31, 0x10); |
| 44 | phy_write(phydev, 0, 18, 0x80A0); |
| 45 | while (phy_read(phydev, 0, 18) & 0x8000) |
| 46 | ; |
| 47 | phy_write(phydev, 0, 31, 0); |
| 48 | return 0; |
| 49 | } |
| 50 | |
Lars Povlsen | e9f1492 | 2018-12-20 09:56:05 +0100 | [diff] [blame] | 51 | static void do_board_detect(void) |
| 52 | { |
| 53 | u32 chipid = (readl(BASE_DEVCPU_GCB + CHIP_ID) >> 12) & 0xFFFF; |
| 54 | |
| 55 | if (chipid == 0x7428 || chipid == 0x7424) |
| 56 | gd->board_type = BOARD_TYPE_PCB091; // Lu10 |
| 57 | else |
| 58 | gd->board_type = BOARD_TYPE_PCB090; // Lu26 |
| 59 | } |
| 60 | |
| 61 | #if defined(CONFIG_MULTI_DTB_FIT) |
| 62 | int board_fit_config_name_match(const char *name) |
| 63 | { |
| 64 | if (gd->board_type == BOARD_TYPE_PCB090 && |
| 65 | strcmp(name, "luton_pcb090") == 0) |
| 66 | return 0; |
| 67 | |
| 68 | if (gd->board_type == BOARD_TYPE_PCB091 && |
| 69 | strcmp(name, "luton_pcb091") == 0) |
| 70 | return 0; |
| 71 | |
| 72 | return -1; |
| 73 | } |
| 74 | #endif |
| 75 | |
| 76 | #if defined(CONFIG_DTB_RESELECT) |
| 77 | int embedded_dtb_select(void) |
| 78 | { |
| 79 | do_board_detect(); |
| 80 | fdtdec_setup(); |
| 81 | |
| 82 | return 0; |
| 83 | } |
| 84 | #endif |