Vikas Manocha | 33913c5 | 2014-11-18 10:42:22 -0800 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2014 |
| 3 | * Vikas Manocha, ST Micoelectronics, vikas.manocha@st.com. |
| 4 | * |
| 5 | * SPDX-License-Identifier: GPL-2.0+ |
| 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <miiphy.h> |
| 10 | #include <asm/arch/stv0991_periph.h> |
| 11 | #include <asm/arch/stv0991_defs.h> |
Vikas Manocha | 32b9e71 | 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 | 0860b6a | 2014-12-01 12:27:54 -0800 | [diff] [blame^] | 16 | #include <dm/platdata.h> |
| 17 | #include <dm/platform_data/serial_pl01x.h> |
Vikas Manocha | 33913c5 | 2014-11-18 10:42:22 -0800 | [diff] [blame] | 18 | |
| 19 | DECLARE_GLOBAL_DATA_PTR; |
| 20 | |
Vikas Manocha | 32b9e71 | 2014-11-18 10:42:23 -0800 | [diff] [blame] | 21 | struct gpio_regs *const gpioa_regs = |
| 22 | (struct gpio_regs *) GPIOA_BASE_ADDR; |
| 23 | |
Vikas Manocha | 0860b6a | 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 | }; |
| 34 | |
Vikas Manocha | 33913c5 | 2014-11-18 10:42:22 -0800 | [diff] [blame] | 35 | #ifdef CONFIG_SHOW_BOOT_PROGRESS |
| 36 | void show_boot_progress(int progress) |
| 37 | { |
| 38 | printf("%i\n", progress); |
| 39 | } |
| 40 | #endif |
| 41 | |
Vikas Manocha | 32b9e71 | 2014-11-18 10:42:23 -0800 | [diff] [blame] | 42 | void enable_eth_phy(void) |
| 43 | { |
| 44 | /* Set GPIOA_06 pad HIGH (Appli board)*/ |
| 45 | writel(readl(&gpioa_regs->dir) | 0x40, &gpioa_regs->dir); |
| 46 | writel(readl(&gpioa_regs->data) | 0x40, &gpioa_regs->data); |
| 47 | } |
| 48 | int board_eth_enable(void) |
| 49 | { |
| 50 | stv0991_pinmux_config(ETH_GPIOB_10_31_C_0_4); |
| 51 | clock_setup(ETH_CLOCK_CFG); |
| 52 | enable_eth_phy(); |
| 53 | return 0; |
| 54 | } |
| 55 | |
Vikas Manocha | 33913c5 | 2014-11-18 10:42:22 -0800 | [diff] [blame] | 56 | /* |
| 57 | * Miscellaneous platform dependent initialisations |
| 58 | */ |
| 59 | int board_init(void) |
| 60 | { |
Vikas Manocha | 32b9e71 | 2014-11-18 10:42:23 -0800 | [diff] [blame] | 61 | board_eth_enable(); |
Vikas Manocha | 33913c5 | 2014-11-18 10:42:22 -0800 | [diff] [blame] | 62 | return 0; |
| 63 | } |
| 64 | |
| 65 | int board_uart_init(void) |
| 66 | { |
| 67 | stv0991_pinmux_config(UART_GPIOC_30_31); |
| 68 | clock_setup(UART_CLOCK_CFG); |
| 69 | return 0; |
| 70 | } |
Vikas Manocha | 32b9e71 | 2014-11-18 10:42:23 -0800 | [diff] [blame] | 71 | |
Vikas Manocha | 33913c5 | 2014-11-18 10:42:22 -0800 | [diff] [blame] | 72 | #ifdef CONFIG_BOARD_EARLY_INIT_F |
| 73 | int board_early_init_f(void) |
| 74 | { |
| 75 | board_uart_init(); |
| 76 | return 0; |
| 77 | } |
| 78 | #endif |
| 79 | |
| 80 | int dram_init(void) |
| 81 | { |
| 82 | gd->ram_size = PHYS_SDRAM_1_SIZE; |
| 83 | return 0; |
| 84 | } |
| 85 | |
| 86 | void dram_init_banksize(void) |
| 87 | { |
| 88 | gd->bd->bi_dram[0].start = PHYS_SDRAM_1; |
| 89 | gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE; |
| 90 | } |
Vikas Manocha | 32b9e71 | 2014-11-18 10:42:23 -0800 | [diff] [blame] | 91 | |
| 92 | #ifdef CONFIG_CMD_NET |
| 93 | int board_eth_init(bd_t *bis) |
| 94 | { |
| 95 | int ret = 0; |
| 96 | |
| 97 | #if defined(CONFIG_DESIGNWARE_ETH) |
| 98 | u32 interface = PHY_INTERFACE_MODE_MII; |
| 99 | if (designware_initialize(GMAC_BASE_ADDR, interface) >= 0) |
| 100 | ret++; |
| 101 | #endif |
| 102 | return ret; |
| 103 | } |
| 104 | #endif |