blob: ecdea82d90915005a7e2badb21bb9251760bd37f [file] [log] [blame]
Prafulla Wadaskarfbc83652009-07-16 21:02:24 +05301/*
2 * (C) Copyright 2009
3 * Marvell Semiconductor <www.marvell.com>
4 * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
5 *
6 * See file CREDITS for list of people who contributed to this
7 * project.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22 * MA 02110-1301 USA
23 */
24
25#include <common.h>
26#include <miiphy.h>
27#include <netdev.h>
28#include <asm/arch/kirkwood.h>
29#include <asm/arch/mpp.h>
30#include "rd6281a.h"
31
32DECLARE_GLOBAL_DATA_PTR;
33
Prafulla Wadaskar754ae3f2010-10-20 20:12:27 +053034int board_early_init_f(void)
Prafulla Wadaskarfbc83652009-07-16 21:02:24 +053035{
36 /*
37 * default gpio configuration
38 * There are maximum 64 gpios controlled through 2 sets of registers
39 * the below configuration configures mainly initial LED status
40 */
41 kw_config_gpio(RD6281A_OE_VAL_LOW,
42 RD6281A_OE_VAL_HIGH,
43 RD6281A_OE_LOW, RD6281A_OE_HIGH);
44
45 /* Multi-Purpose Pins Functionality configuration */
46 u32 kwmpp_config[] = {
47 MPP0_NF_IO2,
48 MPP1_NF_IO3,
49 MPP2_NF_IO4,
50 MPP3_NF_IO5,
51 MPP4_NF_IO6,
52 MPP5_NF_IO7,
53 MPP6_SYSRST_OUTn,
54 MPP7_GPO,
55 MPP8_TW_SDA,
56 MPP9_TW_SCK,
57 MPP10_UART0_TXD,
58 MPP11_UART0_RXD,
59 MPP12_SD_CLK,
60 MPP13_SD_CMD,
61 MPP14_SD_D0,
62 MPP15_SD_D1,
63 MPP16_SD_D2,
64 MPP17_SD_D3,
65 MPP18_NF_IO0,
66 MPP19_NF_IO1,
67 MPP20_GE1_0,
68 MPP21_GE1_1,
69 MPP22_GE1_2,
70 MPP23_GE1_3,
71 MPP24_GE1_4,
72 MPP25_GE1_5,
73 MPP26_GE1_6,
74 MPP27_GE1_7,
75 MPP28_GPIO,
76 MPP29_GPIO,
77 MPP30_GE1_10,
78 MPP31_GE1_11,
79 MPP32_GE1_12,
80 MPP33_GE1_13,
81 MPP34_GE1_14,
82 MPP35_GPIO,
83 MPP36_AUDIO_SPDIFI,
84 MPP37_AUDIO_SPDIFO,
85 MPP38_GPIO,
86 MPP39_TDM_SPI_CS0,
87 MPP40_TDM_SPI_SCK,
88 MPP41_TDM_SPI_MISO,
89 MPP42_TDM_SPI_MOSI,
90 MPP43_TDM_CODEC_INTn,
91 MPP44_GPIO,
92 MPP45_TDM_PCLK,
93 MPP46_TDM_FS,
94 MPP47_TDM_DRX,
95 MPP48_TDM_DTX,
96 MPP49_GPIO,
97 0
98 };
99 kirkwood_mpp_conf(kwmpp_config);
Prafulla Wadaskar754ae3f2010-10-20 20:12:27 +0530100 return 0;
101}
Prafulla Wadaskarfbc83652009-07-16 21:02:24 +0530102
Prafulla Wadaskar754ae3f2010-10-20 20:12:27 +0530103int board_init(void)
104{
Prafulla Wadaskarfbc83652009-07-16 21:02:24 +0530105 /*
106 * arch number of board
107 */
108 gd->bd->bi_arch_number = MACH_TYPE_RD88F6281;
109
110 /* adress of boot parameters */
111 gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
112
113 return 0;
114}
115
Prafulla Wadaskarfbc83652009-07-16 21:02:24 +0530116void mv_phy_88e1116_init(char *name)
117{
118 u16 reg;
119 u16 devadr;
120
121 if (miiphy_set_current_dev(name))
122 return;
123
124 /* command to read PHY dev address */
125 if (miiphy_read(name, 0xEE, 0xEE, (u16 *) &devadr)) {
126 printf("Err..%s could not read PHY dev address\n",
127 __FUNCTION__);
128 return;
129 }
130
131 /*
132 * Enable RGMII delay on Tx and Rx for CPU port
133 * Ref: sec 4.7.2 of chip datasheet
134 */
135 miiphy_write(name, devadr, MV88E1116_PGADR_REG, 2);
136 miiphy_read(name, devadr, MV88E1116_MAC_CTRL_REG, &reg);
137 reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL);
138 miiphy_write(name, devadr, MV88E1116_MAC_CTRL_REG, reg);
139 miiphy_write(name, devadr, MV88E1116_PGADR_REG, 0);
140
141 /* reset the phy */
Mike Frysinger8ef583a2010-12-23 15:40:12 -0500142 if (miiphy_read (name, devadr, MII_BMCR, &reg) != 0) {
Prafulla Wadaskarfbc83652009-07-16 21:02:24 +0530143 printf("Err..(%s) PHY status read failed\n", __FUNCTION__);
144 return;
145 }
Mike Frysinger8ef583a2010-12-23 15:40:12 -0500146 if (miiphy_write (name, devadr, MII_BMCR, reg | 0x8000) != 0) {
Prafulla Wadaskarfbc83652009-07-16 21:02:24 +0530147 printf("Err..(%s) PHY reset failed\n", __FUNCTION__);
148 return;
149 }
150
151 printf("88E1116 Initialized on %s\n", name);
152}
153
154/* Configure and enable Switch and PHY */
155void reset_phy(void)
156{
157 /* configure and initialize switch */
158 struct mv88e61xx_config swcfg = {
159 .name = "egiga0",
160 .vlancfg = MV88E61XX_VLANCFG_ROUTER,
161 .rgmii_delay = MV88E61XX_RGMII_DELAY_EN,
162 .led_init = MV88E61XX_LED_INIT_EN,
163 .portstate = MV88E61XX_PORTSTT_FORWARDING,
164 .cpuport = (1 << 5),
165 .ports_enabled = 0x3f,
166 };
167
168 mv88e61xx_switch_initialize(&swcfg);
169
170 /* configure and initialize PHY */
171 mv_phy_88e1116_init("egiga1");
172}