blob: 989fb5e558c1937276b62d0e71b64fa8431f7c79 [file] [log] [blame]
Vikas Manocha33913c52014-11-18 10:42:22 -08001/*
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 Manocha32b9e712014-11-18 10:42:23 -080012#include <asm/arch/hardware.h>
13#include <asm/arch/gpio.h>
14#include <netdev.h>
15#include <asm/io.h>
Vikas Manocha33913c52014-11-18 10:42:22 -080016
17DECLARE_GLOBAL_DATA_PTR;
18
Vikas Manocha32b9e712014-11-18 10:42:23 -080019struct gpio_regs *const gpioa_regs =
20 (struct gpio_regs *) GPIOA_BASE_ADDR;
21
Vikas Manocha33913c52014-11-18 10:42:22 -080022#ifdef CONFIG_SHOW_BOOT_PROGRESS
23void show_boot_progress(int progress)
24{
25 printf("%i\n", progress);
26}
27#endif
28
Vikas Manocha32b9e712014-11-18 10:42:23 -080029void enable_eth_phy(void)
30{
31 /* Set GPIOA_06 pad HIGH (Appli board)*/
32 writel(readl(&gpioa_regs->dir) | 0x40, &gpioa_regs->dir);
33 writel(readl(&gpioa_regs->data) | 0x40, &gpioa_regs->data);
34}
35int board_eth_enable(void)
36{
37 stv0991_pinmux_config(ETH_GPIOB_10_31_C_0_4);
38 clock_setup(ETH_CLOCK_CFG);
39 enable_eth_phy();
40 return 0;
41}
42
Vikas Manocha33913c52014-11-18 10:42:22 -080043/*
44 * Miscellaneous platform dependent initialisations
45 */
46int board_init(void)
47{
Vikas Manocha32b9e712014-11-18 10:42:23 -080048 board_eth_enable();
Vikas Manocha33913c52014-11-18 10:42:22 -080049 return 0;
50}
51
52int board_uart_init(void)
53{
54 stv0991_pinmux_config(UART_GPIOC_30_31);
55 clock_setup(UART_CLOCK_CFG);
56 return 0;
57}
Vikas Manocha32b9e712014-11-18 10:42:23 -080058
Vikas Manocha33913c52014-11-18 10:42:22 -080059#ifdef CONFIG_BOARD_EARLY_INIT_F
60int board_early_init_f(void)
61{
62 board_uart_init();
63 return 0;
64}
65#endif
66
67int dram_init(void)
68{
69 gd->ram_size = PHYS_SDRAM_1_SIZE;
70 return 0;
71}
72
73void dram_init_banksize(void)
74{
75 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
76 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
77}
Vikas Manocha32b9e712014-11-18 10:42:23 -080078
79#ifdef CONFIG_CMD_NET
80int board_eth_init(bd_t *bis)
81{
82 int ret = 0;
83
84#if defined(CONFIG_DESIGNWARE_ETH)
85 u32 interface = PHY_INTERFACE_MODE_MII;
86 if (designware_initialize(GMAC_BASE_ADDR, interface) >= 0)
87 ret++;
88#endif
89 return ret;
90}
91#endif