blob: 0d76146b658069e44e54ec98a64057ac9421bf6c [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
34int board_init(void)
35{
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);
100
101 /*
102 * arch number of board
103 */
104 gd->bd->bi_arch_number = MACH_TYPE_RD88F6281;
105
106 /* adress of boot parameters */
107 gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
108
109 return 0;
110}
111
Prafulla Wadaskarfbc83652009-07-16 21:02:24 +0530112void mv_phy_88e1116_init(char *name)
113{
114 u16 reg;
115 u16 devadr;
116
117 if (miiphy_set_current_dev(name))
118 return;
119
120 /* command to read PHY dev address */
121 if (miiphy_read(name, 0xEE, 0xEE, (u16 *) &devadr)) {
122 printf("Err..%s could not read PHY dev address\n",
123 __FUNCTION__);
124 return;
125 }
126
127 /*
128 * Enable RGMII delay on Tx and Rx for CPU port
129 * Ref: sec 4.7.2 of chip datasheet
130 */
131 miiphy_write(name, devadr, MV88E1116_PGADR_REG, 2);
132 miiphy_read(name, devadr, MV88E1116_MAC_CTRL_REG, &reg);
133 reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL);
134 miiphy_write(name, devadr, MV88E1116_MAC_CTRL_REG, reg);
135 miiphy_write(name, devadr, MV88E1116_PGADR_REG, 0);
136
137 /* reset the phy */
138 if (miiphy_read (name, devadr, PHY_BMCR, &reg) != 0) {
139 printf("Err..(%s) PHY status read failed\n", __FUNCTION__);
140 return;
141 }
142 if (miiphy_write (name, devadr, PHY_BMCR, reg | 0x8000) != 0) {
143 printf("Err..(%s) PHY reset failed\n", __FUNCTION__);
144 return;
145 }
146
147 printf("88E1116 Initialized on %s\n", name);
148}
149
150/* Configure and enable Switch and PHY */
151void reset_phy(void)
152{
153 /* configure and initialize switch */
154 struct mv88e61xx_config swcfg = {
155 .name = "egiga0",
156 .vlancfg = MV88E61XX_VLANCFG_ROUTER,
157 .rgmii_delay = MV88E61XX_RGMII_DELAY_EN,
158 .led_init = MV88E61XX_LED_INIT_EN,
159 .portstate = MV88E61XX_PORTSTT_FORWARDING,
160 .cpuport = (1 << 5),
161 .ports_enabled = 0x3f,
162 };
163
164 mv88e61xx_switch_initialize(&swcfg);
165
166 /* configure and initialize PHY */
167 mv_phy_88e1116_init("egiga1");
168}