blob: 33b29e647e9501dcc1757ab904b1387c73862dbd [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Vikas Manocha33913c52014-11-18 10:42:22 -08002/*
Patrice Chotardcc551162017-10-23 09:53:59 +02003 * Copyright (C) 2014, STMicroelectronics - All Rights Reserved
4 * Author(s): Vikas Manocha, <vikas.manocha@st.com> for STMicroelectronics.
Vikas Manocha33913c52014-11-18 10:42:22 -08005 */
6
7#include <common.h>
Simon Glass11c89f32017-05-17 17:18:03 -06008#include <dm.h>
Vikas Manocha33913c52014-11-18 10:42:22 -08009#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/platform_data/serial_pl01x.h>
Vikas Manocha33913c52014-11-18 10:42:22 -080017
18DECLARE_GLOBAL_DATA_PTR;
19
Vikas Manocha32b9e712014-11-18 10:42:23 -080020struct gpio_regs *const gpioa_regs =
21 (struct gpio_regs *) GPIOA_BASE_ADDR;
22
Vikas Manochaeefc9532015-05-03 14:10:35 -070023#ifndef CONFIG_OF_CONTROL
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};
Vikas Manochaeefc9532015-05-03 14:10:35 -070034#endif
Vikas Manocha0860b6a2014-12-01 12:27:54 -080035
Vikas Manocha33913c52014-11-18 10:42:22 -080036#ifdef CONFIG_SHOW_BOOT_PROGRESS
37void show_boot_progress(int progress)
38{
39 printf("%i\n", progress);
40}
41#endif
42
Vikas Manocha32b9e712014-11-18 10:42:23 -080043void enable_eth_phy(void)
44{
45 /* Set GPIOA_06 pad HIGH (Appli board)*/
46 writel(readl(&gpioa_regs->dir) | 0x40, &gpioa_regs->dir);
47 writel(readl(&gpioa_regs->data) | 0x40, &gpioa_regs->data);
48}
49int board_eth_enable(void)
50{
51 stv0991_pinmux_config(ETH_GPIOB_10_31_C_0_4);
52 clock_setup(ETH_CLOCK_CFG);
53 enable_eth_phy();
54 return 0;
55}
56
Vikas Manocha20cdba52015-07-02 18:29:40 -070057int board_qspi_enable(void)
58{
59 stv0991_pinmux_config(QSPI_CS_CLK_PAD);
60 clock_setup(QSPI_CLOCK_CFG);
61 return 0;
62}
63
Vikas Manocha33913c52014-11-18 10:42:22 -080064/*
65 * Miscellaneous platform dependent initialisations
66 */
67int board_init(void)
68{
Vikas Manocha32b9e712014-11-18 10:42:23 -080069 board_eth_enable();
Vikas Manocha20cdba52015-07-02 18:29:40 -070070 board_qspi_enable();
Vikas Manocha33913c52014-11-18 10:42:22 -080071 return 0;
72}
73
74int board_uart_init(void)
75{
76 stv0991_pinmux_config(UART_GPIOC_30_31);
77 clock_setup(UART_CLOCK_CFG);
78 return 0;
79}
Vikas Manocha32b9e712014-11-18 10:42:23 -080080
Vikas Manocha33913c52014-11-18 10:42:22 -080081#ifdef CONFIG_BOARD_EARLY_INIT_F
82int board_early_init_f(void)
83{
84 board_uart_init();
85 return 0;
86}
87#endif
88
89int dram_init(void)
90{
91 gd->ram_size = PHYS_SDRAM_1_SIZE;
92 return 0;
93}
94
Simon Glass2f949c32017-03-31 08:40:32 -060095int dram_init_banksize(void)
Vikas Manocha33913c52014-11-18 10:42:22 -080096{
97 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
98 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
Simon Glass2f949c32017-03-31 08:40:32 -060099
100 return 0;
Vikas Manocha33913c52014-11-18 10:42:22 -0800101}
Vikas Manocha32b9e712014-11-18 10:42:23 -0800102
103#ifdef CONFIG_CMD_NET
104int board_eth_init(bd_t *bis)
105{
106 int ret = 0;
107
Simon Glass6e378742015-04-05 16:07:34 -0600108#if defined(CONFIG_ETH_DESIGNWARE)
Vikas Manocha32b9e712014-11-18 10:42:23 -0800109 u32 interface = PHY_INTERFACE_MODE_MII;
110 if (designware_initialize(GMAC_BASE_ADDR, interface) >= 0)
111 ret++;
112#endif
113 return ret;
114}
115#endif