1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#include <common.h>
24#include <miiphy.h>
25#include <netdev.h>
26#include <command.h>
27#include <asm/arch/kirkwood.h>
28#include <asm/arch/mpp.h>
29#include <asm/arch/gpio.h>
30#include "netspace_v2.h"
31
32DECLARE_GLOBAL_DATA_PTR;
33
34int board_early_init_f(void)
35{
36
37 kw_config_gpio(NETSPACE_V2_OE_VAL_LOW, NETSPACE_V2_OE_VAL_HIGH,
38 NETSPACE_V2_OE_LOW, NETSPACE_V2_OE_HIGH);
39
40
41 u32 kwmpp_config[] = {
42 MPP0_SPI_SCn,
43 MPP1_SPI_MOSI,
44 MPP2_SPI_SCK,
45 MPP3_SPI_MISO,
46 MPP4_NF_IO6,
47 MPP5_NF_IO7,
48 MPP6_SYSRST_OUTn,
49 MPP7_GPO,
50 MPP8_TW_SDA,
51 MPP9_TW_SCK,
52 MPP10_UART0_TXD,
53 MPP11_UART0_RXD,
54 MPP12_GPO,
55 MPP14_GPIO,
56 MPP16_GPIO,
57 MPP17_GPIO,
58 MPP18_NF_IO0,
59 MPP19_NF_IO1,
60 MPP20_SATA1_ACTn,
61 MPP21_SATA0_ACTn,
62 MPP22_GPIO,
63 MPP23_GPIO,
64 MPP24_GPIO,
65 MPP25_GPIO,
66 MPP26_GPIO,
67 MPP28_GPIO,
68 MPP29_GPIO,
69 MPP30_GPIO,
70 MPP31_GPIO,
71 MPP32_GPIO,
72 MPP33_GPIO,
73 0
74 };
75 kirkwood_mpp_conf(kwmpp_config);
76
77 return 0;
78}
79
80int board_init(void)
81{
82
83 gd->bd->bi_arch_number = CONFIG_MACH_TYPE;
84
85
86 gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
87
88 return 0;
89}
90
91void mv_phy_88e1116_init(char *name)
92{
93 u16 reg;
94 u16 devadr;
95
96 if (miiphy_set_current_dev(name))
97 return;
98
99
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
107
108
109 miiphy_write(name, devadr, MV88E1116_PGADR_REG, 2);
110 miiphy_read(name, devadr, MV88E1116_MAC_CTRL_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
116 if (miiphy_read(name, devadr, MII_BMCR, ®) != 0) {
117 printf("Err..(%s) PHY status read failed\n", __func__);
118 return;
119 }
120 if (miiphy_write(name, devadr, MII_BMCR, reg | 0x8000) != 0) {
121 printf("Err..(%s) PHY reset failed\n", __func__);
122 return;
123 }
124
125 debug("88E1116 Initialized on %s\n", name);
126}
127
128
129void reset_phy(void)
130{
131 mv_phy_88e1116_init("egiga0");
132}
133
134
135static int
136do_read_button(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
137{
138 return kw_gpio_get_value(NETSPACE_V2_GPIO_BUTTON);
139}
140
141U_BOOT_CMD(button, 1, 1, do_read_button,
142 "Return GPIO button status 0=off 1=on", "");
143