blob: 57ca9f659c16551dfffb3c22c7dd69e1207343b8 [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>
Simon Glass3ba929a2020-10-30 21:38:53 -060018#include <asm/global_data.h>
Vikas Manocha32b9e712014-11-18 10:42:23 -080019#include <asm/io.h>
Vikas Manocha0860b6a2014-12-01 12:27:54 -080020#include <dm/platform_data/serial_pl01x.h>
Vikas Manocha33913c52014-11-18 10:42:22 -080021
22DECLARE_GLOBAL_DATA_PTR;
23
Vikas Manocha32b9e712014-11-18 10:42:23 -080024struct gpio_regs *const gpioa_regs =
25 (struct gpio_regs *) GPIOA_BASE_ADDR;
26
Vikas Manochaeefc9532015-05-03 14:10:35 -070027#ifndef CONFIG_OF_CONTROL
Simon Glassb75b15b2020-12-03 16:55:23 -070028static const struct pl01x_serial_plat serial_plat = {
Vikas Manocha0860b6a2014-12-01 12:27:54 -080029 .base = 0x80406000,
30 .type = TYPE_PL011,
31 .clock = 2700 * 1000,
32};
33
Simon Glass1d8364a2020-12-28 20:34:54 -070034U_BOOT_DRVINFO(stv09911_serials) = {
Vikas Manocha0860b6a2014-12-01 12:27:54 -080035 .name = "serial_pl01x",
Simon Glassb75b15b2020-12-03 16:55:23 -070036 .plat = &serial_plat,
Vikas Manocha0860b6a2014-12-01 12:27:54 -080037};
Vikas Manochaeefc9532015-05-03 14:10:35 -070038#endif
Vikas Manocha0860b6a2014-12-01 12:27:54 -080039
Tom Rinia9765d02021-05-03 16:48:58 -040040#if CONFIG_IS_ENABLED(BOOTSTAGE)
Vikas Manocha33913c52014-11-18 10:42:22 -080041void show_boot_progress(int progress)
42{
43 printf("%i\n", progress);
44}
45#endif
46
Vikas Manocha32b9e712014-11-18 10:42:23 -080047void enable_eth_phy(void)
48{
49 /* Set GPIOA_06 pad HIGH (Appli board)*/
50 writel(readl(&gpioa_regs->dir) | 0x40, &gpioa_regs->dir);
51 writel(readl(&gpioa_regs->data) | 0x40, &gpioa_regs->data);
52}
53int board_eth_enable(void)
54{
55 stv0991_pinmux_config(ETH_GPIOB_10_31_C_0_4);
56 clock_setup(ETH_CLOCK_CFG);
57 enable_eth_phy();
58 return 0;
59}
60
Vikas Manocha20cdba52015-07-02 18:29:40 -070061int board_qspi_enable(void)
62{
63 stv0991_pinmux_config(QSPI_CS_CLK_PAD);
64 clock_setup(QSPI_CLOCK_CFG);
65 return 0;
66}
67
Vikas Manocha33913c52014-11-18 10:42:22 -080068/*
69 * Miscellaneous platform dependent initialisations
70 */
71int board_init(void)
72{
Vikas Manocha32b9e712014-11-18 10:42:23 -080073 board_eth_enable();
Vikas Manocha20cdba52015-07-02 18:29:40 -070074 board_qspi_enable();
Vikas Manocha33913c52014-11-18 10:42:22 -080075 return 0;
76}
77
78int board_uart_init(void)
79{
80 stv0991_pinmux_config(UART_GPIOC_30_31);
81 clock_setup(UART_CLOCK_CFG);
82 return 0;
83}
Vikas Manocha32b9e712014-11-18 10:42:23 -080084
Vikas Manocha33913c52014-11-18 10:42:22 -080085#ifdef CONFIG_BOARD_EARLY_INIT_F
86int board_early_init_f(void)
87{
88 board_uart_init();
89 return 0;
90}
91#endif
92
93int dram_init(void)
94{
95 gd->ram_size = PHYS_SDRAM_1_SIZE;
96 return 0;
97}
98
Simon Glass2f949c32017-03-31 08:40:32 -060099int dram_init_banksize(void)
Vikas Manocha33913c52014-11-18 10:42:22 -0800100{
101 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
102 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
Simon Glass2f949c32017-03-31 08:40:32 -0600103
104 return 0;
Vikas Manocha33913c52014-11-18 10:42:22 -0800105}
Vikas Manocha32b9e712014-11-18 10:42:23 -0800106
107#ifdef CONFIG_CMD_NET
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +0900108int board_eth_init(struct bd_info *bis)
Vikas Manocha32b9e712014-11-18 10:42:23 -0800109{
110 int ret = 0;
111
Simon Glass6e378742015-04-05 16:07:34 -0600112#if defined(CONFIG_ETH_DESIGNWARE)
Vikas Manocha32b9e712014-11-18 10:42:23 -0800113 u32 interface = PHY_INTERFACE_MODE_MII;
114 if (designware_initialize(GMAC_BASE_ADDR, interface) >= 0)
115 ret++;
116#endif
117 return ret;
118}
119#endif