xref: /openbmc/u-boot/board/st/stv0991/stv0991.c (revision 5296cb1d)
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>
12 #include <asm/arch/hardware.h>
13 #include <asm/arch/gpio.h>
14 #include <netdev.h>
15 #include <asm/io.h>
16 #include <dm/platdata.h>
17 #include <dm/platform_data/serial_pl01x.h>
18 
19 DECLARE_GLOBAL_DATA_PTR;
20 
21 struct gpio_regs *const gpioa_regs =
22 		(struct gpio_regs *) GPIOA_BASE_ADDR;
23 
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 
35 #ifdef CONFIG_SHOW_BOOT_PROGRESS
36 void show_boot_progress(int progress)
37 {
38 	printf("%i\n", progress);
39 }
40 #endif
41 
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 
56 /*
57  * Miscellaneous platform dependent initialisations
58  */
59 int board_init(void)
60 {
61 	board_eth_enable();
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 }
71 
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 }
91 
92 #ifdef CONFIG_CMD_NET
93 int board_eth_init(bd_t *bis)
94 {
95 	int ret = 0;
96 
97 #if defined(CONFIG_ETH_DESIGNWARE)
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
105