blob: f465699b55beb8d9df77e49865a225c6cec8012f [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 Manocha0860b6a2014-12-01 12:27:54 -080016#include <dm/platdata.h>
17#include <dm/platform_data/serial_pl01x.h>
Vikas Manocha33913c52014-11-18 10:42:22 -080018
19DECLARE_GLOBAL_DATA_PTR;
20
Vikas Manocha32b9e712014-11-18 10:42:23 -080021struct gpio_regs *const gpioa_regs =
22 (struct gpio_regs *) GPIOA_BASE_ADDR;
23
Vikas Manocha0860b6a2014-12-01 12:27:54 -080024static const struct pl01x_serial_platdata serial_platdata = {
25 .base = 0x80406000,
26 .type = TYPE_PL011,
27 .clock = 2700 * 1000,
28};
29
30U_BOOT_DEVICE(stv09911_serials) = {
31 .name = "serial_pl01x",
32 .platdata = &serial_platdata,
33};
34
Vikas Manocha33913c52014-11-18 10:42:22 -080035#ifdef CONFIG_SHOW_BOOT_PROGRESS
36void show_boot_progress(int progress)
37{
38 printf("%i\n", progress);
39}
40#endif
41
Vikas Manocha32b9e712014-11-18 10:42:23 -080042void 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}
48int 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 Manocha33913c52014-11-18 10:42:22 -080056/*
57 * Miscellaneous platform dependent initialisations
58 */
59int board_init(void)
60{
Vikas Manocha32b9e712014-11-18 10:42:23 -080061 board_eth_enable();
Vikas Manocha33913c52014-11-18 10:42:22 -080062 return 0;
63}
64
65int board_uart_init(void)
66{
67 stv0991_pinmux_config(UART_GPIOC_30_31);
68 clock_setup(UART_CLOCK_CFG);
69 return 0;
70}
Vikas Manocha32b9e712014-11-18 10:42:23 -080071
Vikas Manocha33913c52014-11-18 10:42:22 -080072#ifdef CONFIG_BOARD_EARLY_INIT_F
73int board_early_init_f(void)
74{
75 board_uart_init();
76 return 0;
77}
78#endif
79
80int dram_init(void)
81{
82 gd->ram_size = PHYS_SDRAM_1_SIZE;
83 return 0;
84}
85
86void 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 Manocha32b9e712014-11-18 10:42:23 -080091
92#ifdef CONFIG_CMD_NET
93int 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