fbcb87092b2de535fc15c9eb193d95982fb89a26
[pandora-u-boot.git] / board / st / stv0991 / stv0991.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2014, STMicroelectronics - All Rights Reserved
4  * Author(s): Vikas Manocha, <vikas.manocha@st.com> for STMicroelectronics.
5  */
6
7 #include <common.h>
8 #include <bootstage.h>
9 #include <dm.h>
10 #include <miiphy.h>
11 #include <net.h>
12 #include <asm/arch/stv0991_periph.h>
13 #include <asm/arch/stv0991_defs.h>
14 #include <asm/arch/hardware.h>
15 #include <asm/arch/gpio.h>
16 #include <netdev.h>
17 #include <asm/io.h>
18 #include <dm/platform_data/serial_pl01x.h>
19
20 DECLARE_GLOBAL_DATA_PTR;
21
22 struct gpio_regs *const gpioa_regs =
23                 (struct gpio_regs *) GPIOA_BASE_ADDR;
24
25 #ifndef CONFIG_OF_CONTROL
26 static const struct pl01x_serial_platdata serial_platdata = {
27         .base = 0x80406000,
28         .type = TYPE_PL011,
29         .clock = 2700 * 1000,
30 };
31
32 U_BOOT_DEVICE(stv09911_serials) = {
33         .name = "serial_pl01x",
34         .platdata = &serial_platdata,
35 };
36 #endif
37
38 #ifdef CONFIG_SHOW_BOOT_PROGRESS
39 void show_boot_progress(int progress)
40 {
41         printf("%i\n", progress);
42 }
43 #endif
44
45 void enable_eth_phy(void)
46 {
47         /* Set GPIOA_06 pad HIGH (Appli board)*/
48         writel(readl(&gpioa_regs->dir) | 0x40, &gpioa_regs->dir);
49         writel(readl(&gpioa_regs->data) | 0x40, &gpioa_regs->data);
50 }
51 int board_eth_enable(void)
52 {
53         stv0991_pinmux_config(ETH_GPIOB_10_31_C_0_4);
54         clock_setup(ETH_CLOCK_CFG);
55         enable_eth_phy();
56         return 0;
57 }
58
59 int board_qspi_enable(void)
60 {
61         stv0991_pinmux_config(QSPI_CS_CLK_PAD);
62         clock_setup(QSPI_CLOCK_CFG);
63         return 0;
64 }
65
66 /*
67  * Miscellaneous platform dependent initialisations
68  */
69 int board_init(void)
70 {
71         board_eth_enable();
72         board_qspi_enable();
73         return 0;
74 }
75
76 int board_uart_init(void)
77 {
78         stv0991_pinmux_config(UART_GPIOC_30_31);
79         clock_setup(UART_CLOCK_CFG);
80         return 0;
81 }
82
83 #ifdef CONFIG_BOARD_EARLY_INIT_F
84 int board_early_init_f(void)
85 {
86         board_uart_init();
87         return 0;
88 }
89 #endif
90
91 int dram_init(void)
92 {
93         gd->ram_size = PHYS_SDRAM_1_SIZE;
94         return 0;
95 }
96
97 int dram_init_banksize(void)
98 {
99         gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
100         gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
101
102         return 0;
103 }
104
105 #ifdef CONFIG_CMD_NET
106 int board_eth_init(bd_t *bis)
107 {
108         int ret = 0;
109
110 #if defined(CONFIG_ETH_DESIGNWARE)
111         u32 interface = PHY_INTERFACE_MODE_MII;
112         if (designware_initialize(GMAC_BASE_ADDR, interface) >= 0)
113                 ret++;
114 #endif
115         return ret;
116 }
117 #endif