Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Vikas Manocha | 33913c5 | 2014-11-18 10:42:22 -0800 | [diff] [blame] | 2 | /* |
Patrice Chotard | cc55116 | 2017-10-23 09:53:59 +0200 | [diff] [blame] | 3 | * Copyright (C) 2014, STMicroelectronics - All Rights Reserved |
| 4 | * Author(s): Vikas Manocha, <vikas.manocha@st.com> for STMicroelectronics. |
Vikas Manocha | 33913c5 | 2014-11-18 10:42:22 -0800 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Simon Glass | 1ea9789 | 2020-05-10 11:40:00 -0600 | [diff] [blame] | 8 | #include <bootstage.h> |
Simon Glass | 11c89f3 | 2017-05-17 17:18:03 -0600 | [diff] [blame] | 9 | #include <dm.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 10 | #include <init.h> |
Vikas Manocha | 33913c5 | 2014-11-18 10:42:22 -0800 | [diff] [blame] | 11 | #include <miiphy.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 12 | #include <net.h> |
Vikas Manocha | 33913c5 | 2014-11-18 10:42:22 -0800 | [diff] [blame] | 13 | #include <asm/arch/stv0991_periph.h> |
| 14 | #include <asm/arch/stv0991_defs.h> |
Vikas Manocha | 32b9e71 | 2014-11-18 10:42:23 -0800 | [diff] [blame] | 15 | #include <asm/arch/hardware.h> |
| 16 | #include <asm/arch/gpio.h> |
| 17 | #include <netdev.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 18 | #include <asm/global_data.h> |
Vikas Manocha | 32b9e71 | 2014-11-18 10:42:23 -0800 | [diff] [blame] | 19 | #include <asm/io.h> |
Vikas Manocha | 0860b6a | 2014-12-01 12:27:54 -0800 | [diff] [blame] | 20 | #include <dm/platform_data/serial_pl01x.h> |
Vikas Manocha | 33913c5 | 2014-11-18 10:42:22 -0800 | [diff] [blame] | 21 | |
| 22 | DECLARE_GLOBAL_DATA_PTR; |
| 23 | |
Vikas Manocha | 32b9e71 | 2014-11-18 10:42:23 -0800 | [diff] [blame] | 24 | struct gpio_regs *const gpioa_regs = |
| 25 | (struct gpio_regs *) GPIOA_BASE_ADDR; |
| 26 | |
Vikas Manocha | eefc953 | 2015-05-03 14:10:35 -0700 | [diff] [blame] | 27 | #ifndef CONFIG_OF_CONTROL |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 28 | static const struct pl01x_serial_plat serial_plat = { |
Vikas Manocha | 0860b6a | 2014-12-01 12:27:54 -0800 | [diff] [blame] | 29 | .base = 0x80406000, |
| 30 | .type = TYPE_PL011, |
| 31 | .clock = 2700 * 1000, |
| 32 | }; |
| 33 | |
Simon Glass | 1d8364a | 2020-12-28 20:34:54 -0700 | [diff] [blame] | 34 | U_BOOT_DRVINFO(stv09911_serials) = { |
Vikas Manocha | 0860b6a | 2014-12-01 12:27:54 -0800 | [diff] [blame] | 35 | .name = "serial_pl01x", |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 36 | .plat = &serial_plat, |
Vikas Manocha | 0860b6a | 2014-12-01 12:27:54 -0800 | [diff] [blame] | 37 | }; |
Vikas Manocha | eefc953 | 2015-05-03 14:10:35 -0700 | [diff] [blame] | 38 | #endif |
Vikas Manocha | 0860b6a | 2014-12-01 12:27:54 -0800 | [diff] [blame] | 39 | |
Tom Rini | a9765d0 | 2021-05-03 16:48:58 -0400 | [diff] [blame] | 40 | #if CONFIG_IS_ENABLED(BOOTSTAGE) |
Vikas Manocha | 33913c5 | 2014-11-18 10:42:22 -0800 | [diff] [blame] | 41 | void show_boot_progress(int progress) |
| 42 | { |
| 43 | printf("%i\n", progress); |
| 44 | } |
| 45 | #endif |
| 46 | |
Vikas Manocha | 32b9e71 | 2014-11-18 10:42:23 -0800 | [diff] [blame] | 47 | void enable_eth_phy(void) |
| 48 | { |
| 49 | /* Set GPIOA_06 pad HIGH (Appli board)*/ |
| 50 | writel(readl(&gpioa_regs->dir) | 0x40, &gpioa_regs->dir); |
| 51 | writel(readl(&gpioa_regs->data) | 0x40, &gpioa_regs->data); |
| 52 | } |
| 53 | int board_eth_enable(void) |
| 54 | { |
| 55 | stv0991_pinmux_config(ETH_GPIOB_10_31_C_0_4); |
| 56 | clock_setup(ETH_CLOCK_CFG); |
| 57 | enable_eth_phy(); |
| 58 | return 0; |
| 59 | } |
| 60 | |
Vikas Manocha | 20cdba5 | 2015-07-02 18:29:40 -0700 | [diff] [blame] | 61 | int board_qspi_enable(void) |
| 62 | { |
| 63 | stv0991_pinmux_config(QSPI_CS_CLK_PAD); |
| 64 | clock_setup(QSPI_CLOCK_CFG); |
| 65 | return 0; |
| 66 | } |
| 67 | |
Vikas Manocha | 33913c5 | 2014-11-18 10:42:22 -0800 | [diff] [blame] | 68 | /* |
| 69 | * Miscellaneous platform dependent initialisations |
| 70 | */ |
| 71 | int board_init(void) |
| 72 | { |
Vikas Manocha | 32b9e71 | 2014-11-18 10:42:23 -0800 | [diff] [blame] | 73 | board_eth_enable(); |
Vikas Manocha | 20cdba5 | 2015-07-02 18:29:40 -0700 | [diff] [blame] | 74 | board_qspi_enable(); |
Vikas Manocha | 33913c5 | 2014-11-18 10:42:22 -0800 | [diff] [blame] | 75 | return 0; |
| 76 | } |
| 77 | |
| 78 | int board_uart_init(void) |
| 79 | { |
| 80 | stv0991_pinmux_config(UART_GPIOC_30_31); |
| 81 | clock_setup(UART_CLOCK_CFG); |
| 82 | return 0; |
| 83 | } |
Vikas Manocha | 32b9e71 | 2014-11-18 10:42:23 -0800 | [diff] [blame] | 84 | |
Vikas Manocha | 33913c5 | 2014-11-18 10:42:22 -0800 | [diff] [blame] | 85 | #ifdef CONFIG_BOARD_EARLY_INIT_F |
| 86 | int board_early_init_f(void) |
| 87 | { |
| 88 | board_uart_init(); |
| 89 | return 0; |
| 90 | } |
| 91 | #endif |
| 92 | |
| 93 | int dram_init(void) |
| 94 | { |
| 95 | gd->ram_size = PHYS_SDRAM_1_SIZE; |
| 96 | return 0; |
| 97 | } |
| 98 | |
Simon Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 99 | int dram_init_banksize(void) |
Vikas Manocha | 33913c5 | 2014-11-18 10:42:22 -0800 | [diff] [blame] | 100 | { |
| 101 | gd->bd->bi_dram[0].start = PHYS_SDRAM_1; |
| 102 | gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE; |
Simon Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 103 | |
| 104 | return 0; |
Vikas Manocha | 33913c5 | 2014-11-18 10:42:22 -0800 | [diff] [blame] | 105 | } |
Vikas Manocha | 32b9e71 | 2014-11-18 10:42:23 -0800 | [diff] [blame] | 106 | |
| 107 | #ifdef CONFIG_CMD_NET |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 108 | int board_eth_init(struct bd_info *bis) |
Vikas Manocha | 32b9e71 | 2014-11-18 10:42:23 -0800 | [diff] [blame] | 109 | { |
| 110 | int ret = 0; |
| 111 | |
Simon Glass | 6e37874 | 2015-04-05 16:07:34 -0600 | [diff] [blame] | 112 | #if defined(CONFIG_ETH_DESIGNWARE) |
Vikas Manocha | 32b9e71 | 2014-11-18 10:42:23 -0800 | [diff] [blame] | 113 | u32 interface = PHY_INTERFACE_MODE_MII; |
| 114 | if (designware_initialize(GMAC_BASE_ADDR, interface) >= 0) |
| 115 | ret++; |
| 116 | #endif |
| 117 | return ret; |
| 118 | } |
| 119 | #endif |