blob: 3a027d083a7bfb0bb058cb3b80f845b2b3bc55e0 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Evgeni Dobreve80958b2014-12-08 17:49:42 +01002/*
3 * Copyright (C) 2014 Evgeni Dobrev <evgeni@studio-punkt.com>
4 *
5 * Based on sheevaplug.c originally written by
6 * Prafulla Wadaskar <prafulla@marvell.com>
7 * (C) Copyright 2009
8 * Marvell Semiconductor <www.marvell.com>
Evgeni Dobreve80958b2014-12-08 17:49:42 +01009 */
10
11#include <common.h>
Simon Glass97589732020-05-10 11:40:02 -060012#include <init.h>
Evgeni Dobreve80958b2014-12-08 17:49:42 +010013#include <miiphy.h>
Simon Glass0c364412019-12-28 10:44:48 -070014#include <net.h>
Simon Glass0ffb9d62017-05-31 19:47:48 -060015#include <asm/mach-types.h>
Evgeni Dobreve80958b2014-12-08 17:49:42 +010016#include <asm/arch/soc.h>
17#include <asm/arch/mpp.h>
18#include <asm/arch/cpu.h>
19#include <asm/io.h>
20
21DECLARE_GLOBAL_DATA_PTR;
22
23int board_early_init_f(void)
24{
25 /*
26 * default gpio configuration
27 */
28 mvebu_config_gpio(NAS220_GE_OE_VAL_LOW, NAS220_GE_OE_VAL_HIGH,
29 NAS220_GE_OE_LOW, NAS220_GE_OE_HIGH);
30
31 /* Multi-Purpose Pins Functionality configuration */
32 static const u32 kwmpp_config[] = {
33 MPP0_NF_IO2,
34 MPP1_NF_IO3,
35 MPP2_NF_IO4,
36 MPP3_NF_IO5,
37 MPP4_NF_IO6,
38 MPP5_NF_IO7,
39 MPP6_SYSRST_OUTn,
40 MPP7_SPI_SCn,
41 MPP8_TW_SDA,
42 MPP9_TW_SCK,
43 MPP10_UART0_TXD,
44 MPP11_UART0_RXD,
45 MPP12_GPO,
46 MPP13_GPIO,
47 MPP14_GPIO,
48 MPP15_SATA0_ACTn,
49 MPP16_SATA1_ACTn,
50 MPP17_SATA0_PRESENTn,
51 MPP18_NF_IO0,
52 MPP19_NF_IO1,
53 MPP20_GPIO,
54 MPP21_GPIO,
55 MPP22_GPIO,
56 MPP23_GPIO,
57 MPP24_GPIO,
58 MPP25_GPIO,
59 MPP26_GPIO,
60 MPP27_GPIO,
61 MPP28_GPIO,
62 MPP29_GPIO,
63 MPP30_GPIO,
64 MPP31_GPIO,
65 MPP32_GPIO,
66 MPP33_GPIO,
67 MPP34_GPIO,
68 MPP35_GPIO,
69 0
70 };
71 kirkwood_mpp_conf(kwmpp_config, NULL);
72 return 0;
73}
74
75int board_init(void)
76{
77 /*
78 * arch number of board
79 */
Tom Rinid997f7c2017-01-25 20:42:36 -050080 gd->bd->bi_arch_number = MACH_TYPE_RD88F6192_NAS;
Evgeni Dobreve80958b2014-12-08 17:49:42 +010081
82 /* adress of boot parameters */
83 gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
84
85 return 0;
86}
87
88#ifdef CONFIG_RESET_PHY_R
89/* Configure and enable MV88E1116 PHY */
90void reset_phy(void)
91{
92 u16 reg;
93 u16 devadr;
94 char *name = "egiga0";
95
96 if (miiphy_set_current_dev(name))
97 return;
98
99 /* command to read PHY dev address */
100 if (miiphy_read(name, 0xEE, 0xEE, (u16 *)&devadr)) {
101 printf("Err..%s could not read PHY dev address\n", __func__);
102 return;
103 }
104
105 /*
106 * Enable RGMII delay on Tx and Rx for CPU port
107 * Ref: sec 4.7.2 of chip datasheet
108 */
109 miiphy_write(name, devadr, MV88E1116_PGADR_REG, 2);
110 miiphy_read(name, devadr, MV88E1116_MAC_CTRL_REG, &reg);
111 reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL);
112 miiphy_write(name, devadr, MV88E1116_MAC_CTRL_REG, reg);
113 miiphy_write(name, devadr, MV88E1116_PGADR_REG, 0);
114
115 /* reset the phy */
116 miiphy_reset(name, devadr);
117
118 printf("88E1116 Initialized on %s\n", name);
119}
120#endif /* CONFIG_RESET_PHY_R */