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> |
| 18 | #include <asm/io.h> |
Vikas Manocha | 0860b6a | 2014-12-01 12:27:54 -0800 | [diff] [blame] | 19 | #include <dm/platform_data/serial_pl01x.h> |
Vikas Manocha | 33913c5 | 2014-11-18 10:42:22 -0800 | [diff] [blame] | 20 | |
| 21 | DECLARE_GLOBAL_DATA_PTR; |
| 22 | |
Vikas Manocha | 32b9e71 | 2014-11-18 10:42:23 -0800 | [diff] [blame] | 23 | struct gpio_regs *const gpioa_regs = |
| 24 | (struct gpio_regs *) GPIOA_BASE_ADDR; |
| 25 | |
Vikas Manocha | eefc953 | 2015-05-03 14:10:35 -0700 | [diff] [blame] | 26 | #ifndef CONFIG_OF_CONTROL |
Vikas Manocha | 0860b6a | 2014-12-01 12:27:54 -0800 | [diff] [blame] | 27 | static const struct pl01x_serial_platdata serial_platdata = { |
| 28 | .base = 0x80406000, |
| 29 | .type = TYPE_PL011, |
| 30 | .clock = 2700 * 1000, |
| 31 | }; |
| 32 | |
| 33 | U_BOOT_DEVICE(stv09911_serials) = { |
| 34 | .name = "serial_pl01x", |
| 35 | .platdata = &serial_platdata, |
| 36 | }; |
Vikas Manocha | eefc953 | 2015-05-03 14:10:35 -0700 | [diff] [blame] | 37 | #endif |
Vikas Manocha | 0860b6a | 2014-12-01 12:27:54 -0800 | [diff] [blame] | 38 | |
Vikas Manocha | 33913c5 | 2014-11-18 10:42:22 -0800 | [diff] [blame] | 39 | #ifdef CONFIG_SHOW_BOOT_PROGRESS |
| 40 | void show_boot_progress(int progress) |
| 41 | { |
| 42 | printf("%i\n", progress); |
| 43 | } |
| 44 | #endif |
| 45 | |
Vikas Manocha | 32b9e71 | 2014-11-18 10:42:23 -0800 | [diff] [blame] | 46 | void enable_eth_phy(void) |
| 47 | { |
| 48 | /* Set GPIOA_06 pad HIGH (Appli board)*/ |
| 49 | writel(readl(&gpioa_regs->dir) | 0x40, &gpioa_regs->dir); |
| 50 | writel(readl(&gpioa_regs->data) | 0x40, &gpioa_regs->data); |
| 51 | } |
| 52 | int board_eth_enable(void) |
| 53 | { |
| 54 | stv0991_pinmux_config(ETH_GPIOB_10_31_C_0_4); |
| 55 | clock_setup(ETH_CLOCK_CFG); |
| 56 | enable_eth_phy(); |
| 57 | return 0; |
| 58 | } |
| 59 | |
Vikas Manocha | 20cdba5 | 2015-07-02 18:29:40 -0700 | [diff] [blame] | 60 | int board_qspi_enable(void) |
| 61 | { |
| 62 | stv0991_pinmux_config(QSPI_CS_CLK_PAD); |
| 63 | clock_setup(QSPI_CLOCK_CFG); |
| 64 | return 0; |
| 65 | } |
| 66 | |
Vikas Manocha | 33913c5 | 2014-11-18 10:42:22 -0800 | [diff] [blame] | 67 | /* |
| 68 | * Miscellaneous platform dependent initialisations |
| 69 | */ |
| 70 | int board_init(void) |
| 71 | { |
Vikas Manocha | 32b9e71 | 2014-11-18 10:42:23 -0800 | [diff] [blame] | 72 | board_eth_enable(); |
Vikas Manocha | 20cdba5 | 2015-07-02 18:29:40 -0700 | [diff] [blame] | 73 | board_qspi_enable(); |
Vikas Manocha | 33913c5 | 2014-11-18 10:42:22 -0800 | [diff] [blame] | 74 | return 0; |
| 75 | } |
| 76 | |
| 77 | int board_uart_init(void) |
| 78 | { |
| 79 | stv0991_pinmux_config(UART_GPIOC_30_31); |
| 80 | clock_setup(UART_CLOCK_CFG); |
| 81 | return 0; |
| 82 | } |
Vikas Manocha | 32b9e71 | 2014-11-18 10:42:23 -0800 | [diff] [blame] | 83 | |
Vikas Manocha | 33913c5 | 2014-11-18 10:42:22 -0800 | [diff] [blame] | 84 | #ifdef CONFIG_BOARD_EARLY_INIT_F |
| 85 | int board_early_init_f(void) |
| 86 | { |
| 87 | board_uart_init(); |
| 88 | return 0; |
| 89 | } |
| 90 | #endif |
| 91 | |
| 92 | int dram_init(void) |
| 93 | { |
| 94 | gd->ram_size = PHYS_SDRAM_1_SIZE; |
| 95 | return 0; |
| 96 | } |
| 97 | |
Simon Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 98 | int dram_init_banksize(void) |
Vikas Manocha | 33913c5 | 2014-11-18 10:42:22 -0800 | [diff] [blame] | 99 | { |
| 100 | gd->bd->bi_dram[0].start = PHYS_SDRAM_1; |
| 101 | gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE; |
Simon Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 102 | |
| 103 | return 0; |
Vikas Manocha | 33913c5 | 2014-11-18 10:42:22 -0800 | [diff] [blame] | 104 | } |
Vikas Manocha | 32b9e71 | 2014-11-18 10:42:23 -0800 | [diff] [blame] | 105 | |
| 106 | #ifdef CONFIG_CMD_NET |
| 107 | int board_eth_init(bd_t *bis) |
| 108 | { |
| 109 | int ret = 0; |
| 110 | |
Simon Glass | 6e37874 | 2015-04-05 16:07:34 -0600 | [diff] [blame] | 111 | #if defined(CONFIG_ETH_DESIGNWARE) |
Vikas Manocha | 32b9e71 | 2014-11-18 10:42:23 -0800 | [diff] [blame] | 112 | u32 interface = PHY_INTERFACE_MODE_MII; |
| 113 | if (designware_initialize(GMAC_BASE_ADDR, interface) >= 0) |
| 114 | ret++; |
| 115 | #endif |
| 116 | return ret; |
| 117 | } |
| 118 | #endif |