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