blob: 1e2f22735ea6c4f3a547de9934054cd4b02c333c [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Ajay Bhargav3405e322011-08-04 21:26:02 +05302/*
3 * (C) Copyright 2011
4 * eInfochips Ltd. <www.einfochips.com>
Ajay Bhargav0ad0b612016-12-21 13:28:06 +05305 * Written-by: Ajay Bhargav <contact@8051projects.net>
Ajay Bhargav3405e322011-08-04 21:26:02 +05306 *
7 * Based on Aspenite:
8 * (C) Copyright 2010
9 * Marvell Semiconductor <www.marvell.com>
10 * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
11 * Contributor: Mahavir Jain <mjain@marvell.com>
Ajay Bhargav3405e322011-08-04 21:26:02 +053012 */
13
14#include <common.h>
Simon Glass97589732020-05-10 11:40:02 -060015#include <init.h>
Simon Glass0f2af882020-05-10 11:40:05 -060016#include <log.h>
Ajay Bhargav3405e322011-08-04 21:26:02 +053017#include <mvmfp.h>
Prafulla Wadaskar0c847dc2011-10-18 20:05:47 +053018#include <asm/arch/cpu.h>
Ajay Bhargav3405e322011-08-04 21:26:02 +053019#include <asm/arch/mfp.h>
20#include <asm/arch/armada100.h>
Ajay Bhargav8246ae02011-09-13 22:22:13 +053021#include <asm/gpio.h>
22#include <miiphy.h>
Simon Glass0ffb9d62017-05-31 19:47:48 -060023#include <asm/mach-types.h>
Simon Glassdbd79542020-05-10 11:40:11 -060024#include <linux/delay.h>
Ajay Bhargav3405e322011-08-04 21:26:02 +053025
Ajay Bhargav8ed2bcb2011-09-13 22:22:04 +053026#ifdef CONFIG_ARMADA100_FEC
27#include <net.h>
28#include <netdev.h>
29#endif /* CONFIG_ARMADA100_FEC */
30
Ajay Bhargav3405e322011-08-04 21:26:02 +053031DECLARE_GLOBAL_DATA_PTR;
32
33int board_early_init_f(void)
34{
35 u32 mfp_cfg[] = {
36 /* I2C */
37 MFP105_CI2C_SDA,
38 MFP106_CI2C_SCL,
39
40 /* Enable Console on UART3 */
41 MFPO8_UART3_TXD,
42 MFPO9_UART3_RXD,
Ajay Bhargav8ed2bcb2011-09-13 22:22:04 +053043
44 /* Ethernet PHY Interface */
45 MFP086_ETH_TXCLK,
46 MFP087_ETH_TXEN,
47 MFP088_ETH_TXDQ3,
48 MFP089_ETH_TXDQ2,
49 MFP090_ETH_TXDQ1,
50 MFP091_ETH_TXDQ0,
51 MFP092_ETH_CRS,
52 MFP093_ETH_COL,
53 MFP094_ETH_RXCLK,
54 MFP095_ETH_RXER,
55 MFP096_ETH_RXDQ3,
56 MFP097_ETH_RXDQ2,
57 MFP098_ETH_RXDQ1,
58 MFP099_ETH_RXDQ0,
59 MFP100_ETH_MDC,
60 MFP101_ETH_MDIO,
61 MFP103_ETH_RXDV,
62
Ajay Bhargavfc960ab2011-10-03 14:00:57 +053063 /* SSP2 */
64 MFP107_SSP2_RXD,
65 MFP108_SSP2_TXD,
66 MFP110_SSP2_CS,
67 MFP111_SSP2_CLK,
68
Ajay Bhargav3405e322011-08-04 21:26:02 +053069 MFP_EOC /*End of configuration*/
70 };
71 /* configure MFP's */
72 mfp_config(mfp_cfg);
73 return 0;
74}
75
76int board_init(void)
77{
Ajay Bhargavfc960ab2011-10-03 14:00:57 +053078 struct armd1apb2_registers *apb2_regs =
79 (struct armd1apb2_registers *)ARMD1_APBC2_BASE;
80
Ajay Bhargav3405e322011-08-04 21:26:02 +053081 /* arch number of Board */
Tom Rinid997f7c2017-01-25 20:42:36 -050082 gd->bd->bi_arch_number = MACH_TYPE_GPLUGD;
Ajay Bhargav3405e322011-08-04 21:26:02 +053083 /* adress of boot parameters */
84 gd->bd->bi_boot_params = armd1_sdram_base(0) + 0x100;
Ajay Bhargav8246ae02011-09-13 22:22:13 +053085 /* Assert PHY_RST# */
86 gpio_direction_output(CONFIG_SYS_GPIO_PHY_RST, GPIO_LOW);
87 udelay(10);
88 /* Deassert PHY_RST# */
89 gpio_set_value(CONFIG_SYS_GPIO_PHY_RST, GPIO_HIGH);
Ajay Bhargavfc960ab2011-10-03 14:00:57 +053090
91 /* Enable SSP2 clock */
92 writel(SSP2_APBCLK | SSP2_FNCLK, &apb2_regs->ssp2_clkrst);
Ajay Bhargav3405e322011-08-04 21:26:02 +053093 return 0;
94}
Ajay Bhargav8ed2bcb2011-09-13 22:22:04 +053095
96#ifdef CONFIG_ARMADA100_FEC
97int board_eth_init(bd_t *bis)
98{
99 struct armd1apmu_registers *apmu_regs =
100 (struct armd1apmu_registers *)ARMD1_APMU_BASE;
101
102 /* Enable clock of ethernet controller */
103 writel(FE_CLK_RST | FE_CLK_ENA, &apmu_regs->fecrc);
104
105 return armada100_fec_register(ARMD1_FEC_BASE);
106}
Ajay Bhargav8246ae02011-09-13 22:22:13 +0530107
108#ifdef CONFIG_RESET_PHY_R
109/* Configure and initialize PHY chip 88E3015 */
110void reset_phy(void)
111{
112 u16 phy_adr;
113 const char *name = "armd-fec0";
114
115 if (miiphy_set_current_dev(name))
116 return;
117
118 /* command to read PHY dev address */
119 if (miiphy_read(name, 0xff, 0xff, &phy_adr)) {
120 printf("Err..%s could not read PHY dev address\n", __func__);
121 return;
122 }
123
124 /* Set Ethernet LED in TX blink mode */
125 miiphy_write(name, phy_adr, PHY_LED_MAN_REG, 0x00);
126 miiphy_write(name, phy_adr, PHY_LED_PAR_SEL_REG, PHY_LED_VAL);
127
128 /* reset the phy */
129 miiphy_reset(name, phy_adr);
130 debug("88E3015 Initialized on %s\n", name);
131}
132#endif /* CONFIG_RESET_PHY_R */
Ajay Bhargav8ed2bcb2011-09-13 22:22:04 +0530133#endif /* CONFIG_ARMADA100_FEC */