spi: zynqmp_gqspi: fix set_speed bug on multiple runs
[platform/kernel/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 <init.h>
11 #include <miiphy.h>
12 #include <net.h>
13 #include <asm/arch/stv0991_periph.h>
14 #include <asm/arch/stv0991_defs.h>
15 #include <asm/arch/hardware.h>
16 #include <asm/arch/gpio.h>
17 #include <netdev.h>
18 #include <asm/io.h>
19 #include <dm/platform_data/serial_pl01x.h>
20
21 DECLARE_GLOBAL_DATA_PTR;
22
23 struct gpio_regs *const gpioa_regs =
24                 (struct gpio_regs *) GPIOA_BASE_ADDR;
25
26 #ifndef CONFIG_OF_CONTROL
27 static const struct pl01x_serial_plat serial_plat = {
28         .base = 0x80406000,
29         .type = TYPE_PL011,
30         .clock = 2700 * 1000,
31 };
32
33 U_BOOT_DRVINFO(stv09911_serials) = {
34         .name = "serial_pl01x",
35         .plat = &serial_plat,
36 };
37 #endif
38
39 #ifdef CONFIG_SHOW_BOOT_PROGRESS
40 void show_boot_progress(int progress)
41 {
42         printf("%i\n", progress);
43 }
44 #endif
45
46 void enable_eth_phy(void)
47 {
48         /* Set GPIOA_06 pad HIGH (Appli board)*/
49         writel(readl(&gpioa_regs->dir) | 0x40, &gpioa_regs->dir);
50         writel(readl(&gpioa_regs->data) | 0x40, &gpioa_regs->data);
51 }
52 int board_eth_enable(void)
53 {
54         stv0991_pinmux_config(ETH_GPIOB_10_31_C_0_4);
55         clock_setup(ETH_CLOCK_CFG);
56         enable_eth_phy();
57         return 0;
58 }
59
60 int board_qspi_enable(void)
61 {
62         stv0991_pinmux_config(QSPI_CS_CLK_PAD);
63         clock_setup(QSPI_CLOCK_CFG);
64         return 0;
65 }
66
67 /*
68  * Miscellaneous platform dependent initialisations
69  */
70 int board_init(void)
71 {
72         board_eth_enable();
73         board_qspi_enable();
74         return 0;
75 }
76
77 int board_uart_init(void)
78 {
79         stv0991_pinmux_config(UART_GPIOC_30_31);
80         clock_setup(UART_CLOCK_CFG);
81         return 0;
82 }
83
84 #ifdef CONFIG_BOARD_EARLY_INIT_F
85 int board_early_init_f(void)
86 {
87         board_uart_init();
88         return 0;
89 }
90 #endif
91
92 int dram_init(void)
93 {
94         gd->ram_size = PHYS_SDRAM_1_SIZE;
95         return 0;
96 }
97
98 int dram_init_banksize(void)
99 {
100         gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
101         gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
102
103         return 0;
104 }
105
106 #ifdef CONFIG_CMD_NET
107 int board_eth_init(struct bd_info *bis)
108 {
109         int ret = 0;
110
111 #if defined(CONFIG_ETH_DESIGNWARE)
112         u32 interface = PHY_INTERFACE_MODE_MII;
113         if (designware_initialize(GMAC_BASE_ADDR, interface) >= 0)
114                 ret++;
115 #endif
116         return ret;
117 }
118 #endif