1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2009-2012
* Wojciech Dubowik <wojciech.dubowik@neratec.com>
* Luka Perkov <luka@openwrt.org>
*/
#include <common.h>
#include <miiphy.h>
#include <asm/setup.h>
#include <asm/arch/cpu.h>
#include <asm/arch/soc.h>
#include <asm/arch/mpp.h>
#include "ds109.h"
DECLARE_GLOBAL_DATA_PTR;
int board_early_init_f(void)
{
/*
* default gpio configuration
* There are maximum 64 gpios controlled through 2 sets of registers
* the below configuration configures mainly initial LED status
*/
mvebu_config_gpio(DS109_OE_VAL_LOW,
DS109_OE_VAL_HIGH,
DS109_OE_LOW, DS109_OE_HIGH);
/* Multi-Purpose Pins Functionality configuration */
static const u32 kwmpp_config[] = {
MPP0_SPI_SCn, /* SPI Flash */
MPP1_SPI_MOSI,
MPP2_SPI_SCK,
MPP3_SPI_MISO,
MPP4_GPIO,
MPP5_GPO,
MPP6_SYSRST_OUTn, /* Reset signal */
MPP7_GPO,
MPP8_TW_SDA, /* I2C */
MPP9_TW_SCK, /* I2C */
MPP10_UART0_TXD,
MPP11_UART0_RXD,
MPP12_GPO,
MPP13_UART1_TXD,
MPP14_UART1_RXD,
MPP15_GPIO,
MPP16_GPIO,
MPP17_GPIO,
MPP18_GPO,
MPP19_GPO,
MPP20_SATA1_ACTn,
MPP21_SATA0_ACTn,
MPP22_GPIO, /* HDD2 FAIL LED */
MPP23_GPIO, /* HDD1 FAIL LED */
MPP24_GPIO,
MPP25_GPIO,
MPP26_GPIO,
MPP27_GPIO,
MPP28_GPIO,
MPP29_GPIO,
MPP30_GPIO,
MPP31_GPIO, /* HDD2 */
MPP32_GPIO, /* FAN A */
MPP33_GPIO, /* FAN B */
MPP34_GPIO, /* FAN C */
MPP35_GPIO, /* FAN SENSE */
MPP36_GPIO,
MPP37_GPIO,
MPP38_GPIO,
MPP39_GPIO,
MPP40_GPIO,
MPP41_GPIO,
MPP42_GPIO,
MPP43_GPIO,
MPP44_GPIO,
MPP45_GPIO,
MPP46_GPIO,
MPP47_GPIO,
MPP48_GPIO,
MPP49_GPIO,
0
};
kirkwood_mpp_conf(kwmpp_config, NULL);
return 0;
}
int board_init(void)
{
/* address of boot parameters */
gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
return 0;
}
/* Synology reset uses UART */
#include <ns16550.h>
#define SOFTWARE_SHUTDOWN 0x31
#define SOFTWARE_REBOOT 0x43
#define CONFIG_SYS_NS16550_COM2 KW_UART1_BASE
void reset_misc(void)
{
int b_d;
printf("Synology reset...");
udelay(50000);
b_d = ns16550_calc_divisor((NS16550_t)CONFIG_SYS_NS16550_COM2,
CONFIG_SYS_NS16550_CLK, 9600);
NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM2, b_d);
NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM2, SOFTWARE_REBOOT);
}
/* Support old kernels */
void setup_board_tags(struct tag **in_params)
{
unsigned int boardId;
struct tag *params;
struct tag_mv_uboot *t;
int i;
printf("Synology board tags...");
params = *in_params;
t = (struct tag_mv_uboot *)¶ms->u;
t->uboot_version = VER_NUM;
boardId = SYNO_DS109_ID;
t->uboot_version |= boardId;
t->tclk = CONFIG_SYS_TCLK;
t->sysclk = CONFIG_SYS_TCLK*2;
t->isusbhost = 1;
for (i = 0; i < 4; i++) {
memset(t->macaddr[i], 0, sizeof(t->macaddr[i]));
t->mtu[i] = 0;
}
params->hdr.tag = ATAG_MV_UBOOT;
params->hdr.size = tag_size(tag_mv_uboot);
params = tag_next(params);
*in_params = params;
}
#ifdef CONFIG_RESET_PHY_R
/* Configure and enable MV88E1116 PHY */
void reset_phy(void)
{
u16 reg;
u16 devadr;
char *name = "egiga0";
if (miiphy_set_current_dev(name))
return;
/* command to read PHY dev address */
if (miiphy_read(name, 0xEE, 0xEE, (u16 *)&devadr)) {
printf("Error: 88E1116 could not read PHY dev address\n");
return;
}
/*
* Enable RGMII delay on Tx and Rx for CPU port
* Ref: sec 4.7.2 of chip datasheet
*/
miiphy_write(name, devadr, MV88E1116_PGADR_REG, 2);
miiphy_read(name, devadr, MV88E1116_MAC_CTRL_REG, ®);
reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL);
miiphy_write(name, devadr, MV88E1116_MAC_CTRL_REG, reg);
miiphy_write(name, devadr, MV88E1116_PGADR_REG, 0);
/* reset the phy */
miiphy_reset(name, devadr);
printf("88E1116 Initialized on %s\n", name);
}
#endif /* CONFIG_RESET_PHY_R */
|