blob: c00a08aeab319d1f933b9800a915c5f1d9654ad5 [file] [log] [blame]
Simon Kagstrome92daeb2009-09-22 04:01:01 +05301/*
2 * (C) Copyright 2009
3 * Net Insight <www.netinsight.net>
4 * Written-by: Simon Kagstrom <simon.kagstrom@netinsight.net>
5 *
6 * Based on sheevaplug.c:
7 * (C) Copyright 2009
8 * Marvell Semiconductor <www.marvell.com>
9 * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
10 *
11 * See file CREDITS for list of people who contributed to this
12 * project.
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
27 * MA 02110-1301 USA
28 */
29
30#include <common.h>
31#include <miiphy.h>
32#include <asm/arch/kirkwood.h>
33#include <asm/arch/mpp.h>
34#include "openrd_base.h"
35
36DECLARE_GLOBAL_DATA_PTR;
37
38int board_init(void)
39{
40 /*
41 * default gpio configuration
42 * There are maximum 64 gpios controlled through 2 sets of registers
43 * the below configuration configures mainly initial LED status
44 */
45 kw_config_gpio(OPENRD_OE_VAL_LOW,
46 OPENRD_OE_VAL_HIGH,
47 OPENRD_OE_LOW, OPENRD_OE_HIGH);
48
49 /* Multi-Purpose Pins Functionality configuration */
50 u32 kwmpp_config[] = {
51 MPP0_NF_IO2,
52 MPP1_NF_IO3,
53 MPP2_NF_IO4,
54 MPP3_NF_IO5,
55 MPP4_NF_IO6,
56 MPP5_NF_IO7,
57 MPP6_SYSRST_OUTn,
58 MPP7_GPO,
59 MPP8_TW_SDA,
60 MPP9_TW_SCK,
61 MPP10_UART0_TXD,
62 MPP11_UART0_RXD,
63 MPP12_SD_CLK,
64 MPP13_SD_CMD, /* Alt UART1_TXD */
65 MPP14_SD_D0, /* Alt UART1_RXD */
66 MPP15_SD_D1,
67 MPP16_SD_D2,
68 MPP17_SD_D3,
69 MPP18_NF_IO0,
70 MPP19_NF_IO1,
71 MPP20_GE1_0,
72 MPP21_GE1_1,
73 MPP22_GE1_2,
74 MPP23_GE1_3,
75 MPP24_GE1_4,
76 MPP25_GE1_5,
77 MPP26_GE1_6,
78 MPP27_GE1_7,
79 MPP28_GPIO,
80 MPP29_TSMP9,
81 MPP30_GE1_10,
82 MPP31_GE1_11,
83 MPP32_GE1_12,
84 MPP33_GE1_13,
85 MPP34_GPIO, /* UART1 / SD sel */
86 MPP35_TDM_CH0_TX_QL,
87 MPP36_TDM_SPI_CS1,
88 MPP37_TDM_CH2_TX_QL,
89 MPP38_TDM_CH2_RX_QL,
90 MPP39_AUDIO_I2SBCLK,
91 MPP40_AUDIO_I2SDO,
92 MPP41_AUDIO_I2SLRC,
93 MPP42_AUDIO_I2SMCLK,
94 MPP43_AUDIO_I2SDI,
95 MPP44_AUDIO_EXTCLK,
96 MPP45_TDM_PCLK,
97 MPP46_TDM_FS,
98 MPP47_TDM_DRX,
99 MPP48_TDM_DTX,
100 MPP49_TDM_CH0_RX_QL,
101 0
102 };
103
104 kirkwood_mpp_conf(kwmpp_config);
105
106 /*
107 * arch number of board
108 */
109 gd->bd->bi_arch_number = MACH_TYPE_OPENRD_BASE;
110
111 /* adress of boot parameters */
112 gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
113 return 0;
114}
115
116int dram_init(void)
117{
118 int i;
119
120 for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
121 gd->bd->bi_dram[i].start = kw_sdram_bar(i);
122 gd->bd->bi_dram[i].size = kw_sdram_bs(i);
123 }
124 return 0;
125}
126
127#ifdef CONFIG_RESET_PHY_R
128/* Configure and enable MV88E1116 PHY */
129void reset_phy(void)
130{
131 u16 reg;
132 u16 devadr;
133 char *name = "egiga0";
134
135 if (miiphy_set_current_dev(name))
136 return;
137
138 /* command to read PHY dev address */
139 if (miiphy_read(name, 0xEE, 0xEE, (u16 *) &devadr)) {
140 printf("Err..%s could not read PHY dev address\n",
141 __FUNCTION__);
142 return;
143 }
144
145 /*
146 * Enable RGMII delay on Tx and Rx for CPU port
147 * Ref: sec 4.7.2 of chip datasheet
148 */
149 miiphy_write(name, devadr, MV88E1116_PGADR_REG, 2);
150 miiphy_read(name, devadr, MV88E1116_MAC_CTRL_REG, &reg);
151 reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL);
152 miiphy_write(name, devadr, MV88E1116_MAC_CTRL_REG, reg);
153 miiphy_write(name, devadr, MV88E1116_PGADR_REG, 0);
154
155 /* reset the phy */
156 miiphy_reset(name, devadr);
157
158 printf("88E1116 Initialized on %s\n", name);
159}
160#endif /* CONFIG_RESET_PHY_R */