blob: d5a9f1386ebefebd8de7ac5f4c55629036e98b99 [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 Glass1ea97892020-05-10 11:40:00 -06008#include <bootstage.h>
Simon Glass11c89f32017-05-17 17:18:03 -06009#include <dm.h>
Simon Glass97589732020-05-10 11:40:02 -060010#include <init.h>
Vikas Manocha33913c52014-11-18 10:42:22 -080011#include <miiphy.h>
Simon Glass274e0b02020-05-10 11:39:56 -060012#include <net.h>
Vikas Manocha33913c52014-11-18 10:42:22 -080013#include <asm/arch/stv0991_periph.h>
14#include <asm/arch/stv0991_defs.h>
Vikas Manocha32b9e712014-11-18 10:42:23 -080015#include <asm/arch/hardware.h>
16#include <asm/arch/gpio.h>
17#include <netdev.h>
18#include <asm/io.h>
Vikas Manocha0860b6a2014-12-01 12:27:54 -080019#include <dm/platform_data/serial_pl01x.h>
Vikas Manocha33913c52014-11-18 10:42:22 -080020
21DECLARE_GLOBAL_DATA_PTR;
22
Vikas Manocha32b9e712014-11-18 10:42:23 -080023struct gpio_regs *const gpioa_regs =
24 (struct gpio_regs *) GPIOA_BASE_ADDR;
25
Vikas Manochaeefc9532015-05-03 14:10:35 -070026#ifndef CONFIG_OF_CONTROL
Vikas Manocha0860b6a2014-12-01 12:27:54 -080027static const struct pl01x_serial_platdata serial_platdata = {
28 .base = 0x80406000,
29 .type = TYPE_PL011,
30 .clock = 2700 * 1000,
31};
32
33U_BOOT_DEVICE(stv09911_serials) = {
34 .name = "serial_pl01x",
35 .platdata = &serial_platdata,
36};
Vikas Manochaeefc9532015-05-03 14:10:35 -070037#endif
Vikas Manocha0860b6a2014-12-01 12:27:54 -080038
Vikas Manocha33913c52014-11-18 10:42:22 -080039#ifdef CONFIG_SHOW_BOOT_PROGRESS
40void show_boot_progress(int progress)
41{
42 printf("%i\n", progress);
43}
44#endif
45
Vikas Manocha32b9e712014-11-18 10:42:23 -080046void 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}
52int 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
Vikas Manocha20cdba52015-07-02 18:29:40 -070060int board_qspi_enable(void)
61{
62 stv0991_pinmux_config(QSPI_CS_CLK_PAD);
63 clock_setup(QSPI_CLOCK_CFG);
64 return 0;
65}
66
Vikas Manocha33913c52014-11-18 10:42:22 -080067/*
68 * Miscellaneous platform dependent initialisations
69 */
70int board_init(void)
71{
Vikas Manocha32b9e712014-11-18 10:42:23 -080072 board_eth_enable();
Vikas Manocha20cdba52015-07-02 18:29:40 -070073 board_qspi_enable();
Vikas Manocha33913c52014-11-18 10:42:22 -080074 return 0;
75}
76
77int board_uart_init(void)
78{
79 stv0991_pinmux_config(UART_GPIOC_30_31);
80 clock_setup(UART_CLOCK_CFG);
81 return 0;
82}
Vikas Manocha32b9e712014-11-18 10:42:23 -080083
Vikas Manocha33913c52014-11-18 10:42:22 -080084#ifdef CONFIG_BOARD_EARLY_INIT_F
85int board_early_init_f(void)
86{
87 board_uart_init();
88 return 0;
89}
90#endif
91
92int dram_init(void)
93{
94 gd->ram_size = PHYS_SDRAM_1_SIZE;
95 return 0;
96}
97
Simon Glass2f949c32017-03-31 08:40:32 -060098int dram_init_banksize(void)
Vikas Manocha33913c52014-11-18 10:42:22 -080099{
100 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
101 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
Simon Glass2f949c32017-03-31 08:40:32 -0600102
103 return 0;
Vikas Manocha33913c52014-11-18 10:42:22 -0800104}
Vikas Manocha32b9e712014-11-18 10:42:23 -0800105
106#ifdef CONFIG_CMD_NET
107int board_eth_init(bd_t *bis)
108{
109 int ret = 0;
110
Simon Glass6e378742015-04-05 16:07:34 -0600111#if defined(CONFIG_ETH_DESIGNWARE)
Vikas Manocha32b9e712014-11-18 10:42:23 -0800112 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