rk_eqos.c revision 1.1 1 1.1 ryo /* $NetBSD: rk_eqos.c,v 1.1 2022/08/23 05:40:46 ryo Exp $ */
2 1.1 ryo
3 1.1 ryo /*-
4 1.1 ryo * Copyright (c) 2022 Ryo Shimizu <ryo (at) nerv.org>
5 1.1 ryo * All rights reserved.
6 1.1 ryo *
7 1.1 ryo * Redistribution and use in source and binary forms, with or without
8 1.1 ryo * modification, are permitted provided that the following conditions
9 1.1 ryo * are met:
10 1.1 ryo * 1. Redistributions of source code must retain the above copyright
11 1.1 ryo * notice, this list of conditions and the following disclaimer.
12 1.1 ryo * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 ryo * notice, this list of conditions and the following disclaimer in the
14 1.1 ryo * documentation and/or other materials provided with the distribution.
15 1.1 ryo *
16 1.1 ryo * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
17 1.1 ryo * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 1.1 ryo * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 1.1 ryo * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
20 1.1 ryo * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 1.1 ryo * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 1.1 ryo * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 1.1 ryo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24 1.1 ryo * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
25 1.1 ryo * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 1.1 ryo * POSSIBILITY OF SUCH DAMAGE.
27 1.1 ryo */
28 1.1 ryo #include "opt_net_mpsafe.h"
29 1.1 ryo
30 1.1 ryo #include <sys/cdefs.h>
31 1.1 ryo __KERNEL_RCSID(0, "$NetBSD: rk_eqos.c,v 1.1 2022/08/23 05:40:46 ryo Exp $");
32 1.1 ryo
33 1.1 ryo #include <sys/param.h>
34 1.1 ryo #include <sys/bus.h>
35 1.1 ryo #include <sys/device.h>
36 1.1 ryo #include <sys/rndsource.h>
37 1.1 ryo
38 1.1 ryo #include <net/if_ether.h>
39 1.1 ryo #include <net/if_media.h>
40 1.1 ryo
41 1.1 ryo #include <dev/fdt/fdtvar.h>
42 1.1 ryo #include <dev/fdt/syscon.h>
43 1.1 ryo
44 1.1 ryo #include <dev/mii/miivar.h>
45 1.1 ryo #include <dev/ic/dwc_eqos_var.h>
46 1.1 ryo
47 1.1 ryo struct rk_eqos_softc {
48 1.1 ryo struct eqos_softc sc_base;
49 1.1 ryo
50 1.1 ryo struct syscon *sc_grf;
51 1.1 ryo struct syscon *sc_php_grf;
52 1.1 ryo int sc_id; /* ethernet0 or 1? */
53 1.1 ryo };
54 1.1 ryo
55 1.1 ryo static int rk_eqos_match(device_t, cfdata_t, void *);
56 1.1 ryo static void rk_eqos_attach(device_t, device_t, void *);
57 1.1 ryo
58 1.1 ryo struct rk_eqos_ops {
59 1.1 ryo void (*set_mode_rgmii)(struct rk_eqos_softc *, int, int);
60 1.1 ryo void (*set_speed_rgmii)(struct rk_eqos_softc *, int);
61 1.1 ryo void (*clock_selection)(struct rk_eqos_softc *, int);
62 1.1 ryo int (*get_unit)(struct rk_eqos_softc *, int);
63 1.1 ryo };
64 1.1 ryo
65 1.1 ryo CFATTACH_DECL_NEW(rk_eqos, sizeof(struct rk_eqos_softc),
66 1.1 ryo rk_eqos_match, rk_eqos_attach, NULL, NULL);
67 1.1 ryo
68 1.1 ryo /*
69 1.1 ryo * RK3588 specific
70 1.1 ryo */
71 1.1 ryo #define RK3588_ETHERNET1_ADDR 0xfe1c0000
72 1.1 ryo
73 1.1 ryo /* grf */
74 1.1 ryo #define RK3588_GRF_GMAC_TXRXCLK_DELAY_EN_REG (0x0300 + (4 * 7))
75 1.1 ryo #define RK3588_GMAC_RXCLK_DELAY_EN(id) __BIT(3 + 2 * (id))
76 1.1 ryo #define RK3588_GMAC_RXCLK_DELAY_DISABLE 0
77 1.1 ryo #define RK3588_GMAC_RXCLK_DELAY_ENABLE 1
78 1.1 ryo #define RK3588_GMAC_TXCLK_DELAY_EN(id) __BIT(2 + 2 * (id))
79 1.1 ryo #define RK3588_GMAC_TXCLK_DELAY_DISABLE 0
80 1.1 ryo #define RK3588_GMAC_TXCLK_DELAY_ENABLE 1
81 1.1 ryo #define RK3588_GRF_GMAC_TXRX_DELAY_CFG_REG(id) (0x0300 + (4 * 8) + (4 * (id)))
82 1.1 ryo #define RK3588_GMAC_RXCLK_DELAY_CFG __BITS(15,8)
83 1.1 ryo #define RK3588_GMAC_TXCLK_DELAY_CFG __BITS(7,0)
84 1.1 ryo
85 1.1 ryo /* grf_php */
86 1.1 ryo #define RK3588_GRF_GMAC_PHY_REG 0x0008
87 1.1 ryo #define RK3588_GMAC_PHY_IFACE_SEL(id) (__BITS(5,3) << ((id) * 6))
88 1.1 ryo #define RK3588_GMAC_PHY_IFACE_SEL_RGMII 1
89 1.1 ryo #define RK3588_GMAC_PHY_IFACE_SEL_RMII 4
90 1.1 ryo #define RK3588_GRF_CLK_CON1 0x0070
91 1.1 ryo #define RK3588_GRF_GMAC_CLK_REG 0x0070
92 1.1 ryo #define RK3588_GMAC_CLK_SELECT(id) __BIT(4 + 5 * (id))
93 1.1 ryo #define RK3588_GMAC_CLK_SELECT_IO 0
94 1.1 ryo #define RK3588_GMAC_CLK_SELECT_CRU 1
95 1.1 ryo #define RK3588_GMAC_CLK_RMII_DIV(id) __BIT(2 + 5 * (id))
96 1.1 ryo #define RK3588_GMA_CLK_RMII_DIV_DIV20 0
97 1.1 ryo #define RK3588_GMA_CLK_RMII_DIV_DIV2 1
98 1.1 ryo #define RK3588_GMAC_CLK_RGMII_DIV(id) (__BITS(3,2) << ((id) * 5))
99 1.1 ryo #define RK3588_GMAC_CLK_RGMII_DIV_DIV1 1
100 1.1 ryo #define RK3588_GMAC_CLK_RGMII_DIV_DIV50 2
101 1.1 ryo #define RK3588_GMAC_CLK_RGMII_DIV_DIV5 3
102 1.1 ryo #define RK3588_GMAC_CLK_RMII_GATE_EN(id) __BIT(1 + (id) * 5)
103 1.1 ryo #define RK3588_GMAC_CLK_RMII_GATE_DISABLE 0
104 1.1 ryo #define RK3588_GMAC_CLK_RMII_GATE_ENABLE 1
105 1.1 ryo #define RK3588_GMAC_CLK_MODE(id) __BIT(0 + (id) * 5)
106 1.1 ryo #define RK3588_GMAC_CLK_MODE_RGMII 0
107 1.1 ryo #define RK3588_GMAC_CLK_MODE_RMII 1
108 1.1 ryo
109 1.1 ryo static void
110 1.1 ryo rk3588_eqos_set_mode_rgmii(struct rk_eqos_softc *rk_sc,
111 1.1 ryo int tx_delay, int rx_delay)
112 1.1 ryo {
113 1.1 ryo const int id = rk_sc->sc_id;
114 1.1 ryo uint32_t txen, rxen;
115 1.1 ryo
116 1.1 ryo if (tx_delay >= 0) {
117 1.1 ryo txen = RK3588_GMAC_TXCLK_DELAY_ENABLE;
118 1.1 ryo } else {
119 1.1 ryo txen = RK3588_GMAC_TXCLK_DELAY_DISABLE;
120 1.1 ryo tx_delay = 0;
121 1.1 ryo }
122 1.1 ryo if (rx_delay >= 0) {
123 1.1 ryo rxen = RK3588_GMAC_RXCLK_DELAY_ENABLE;
124 1.1 ryo } else {
125 1.1 ryo rxen = RK3588_GMAC_RXCLK_DELAY_DISABLE;
126 1.1 ryo rx_delay = 0;
127 1.1 ryo }
128 1.1 ryo
129 1.1 ryo syscon_lock(rk_sc->sc_grf);
130 1.1 ryo syscon_write_4(rk_sc->sc_grf, RK3588_GRF_GMAC_TXRXCLK_DELAY_EN_REG,
131 1.1 ryo RK3588_GMAC_TXCLK_DELAY_EN(id) << 16 | /* masks */
132 1.1 ryo RK3588_GMAC_RXCLK_DELAY_EN(id) << 16 |
133 1.1 ryo __SHIFTIN(txen, RK3588_GMAC_TXCLK_DELAY_EN(id)) | /* values */
134 1.1 ryo __SHIFTIN(rxen, RK3588_GMAC_RXCLK_DELAY_EN(id)));
135 1.1 ryo syscon_write_4(rk_sc->sc_grf, RK3588_GRF_GMAC_TXRX_DELAY_CFG_REG(id),
136 1.1 ryo RK3588_GMAC_TXCLK_DELAY_CFG << 16 | /* masks */
137 1.1 ryo RK3588_GMAC_RXCLK_DELAY_CFG << 16 |
138 1.1 ryo __SHIFTIN(tx_delay, RK3588_GMAC_TXCLK_DELAY_CFG) | /* values */
139 1.1 ryo __SHIFTIN(rx_delay, RK3588_GMAC_RXCLK_DELAY_CFG));
140 1.1 ryo syscon_unlock(rk_sc->sc_grf);
141 1.1 ryo
142 1.1 ryo syscon_lock(rk_sc->sc_php_grf);
143 1.1 ryo syscon_write_4(rk_sc->sc_php_grf, RK3588_GRF_GMAC_PHY_REG,
144 1.1 ryo RK3588_GMAC_PHY_IFACE_SEL(id) << 16 | /* mask */
145 1.1 ryo __SHIFTIN(RK3588_GMAC_PHY_IFACE_SEL_RGMII, /* value */
146 1.1 ryo RK3588_GMAC_PHY_IFACE_SEL(id)));
147 1.1 ryo syscon_write_4(rk_sc->sc_php_grf, RK3588_GRF_GMAC_CLK_REG,
148 1.1 ryo RK3588_GMAC_CLK_MODE(id) << 16 | /* mask */
149 1.1 ryo __SHIFTIN(RK3588_GMAC_CLK_MODE_RGMII, /* value */
150 1.1 ryo RK3588_GMAC_CLK_MODE(id)));
151 1.1 ryo syscon_unlock(rk_sc->sc_php_grf);
152 1.1 ryo }
153 1.1 ryo
154 1.1 ryo static void
155 1.1 ryo rk3588_eqos_set_speed_rgmii(struct rk_eqos_softc *rk_sc, int speed)
156 1.1 ryo {
157 1.1 ryo const int id = rk_sc->sc_id;
158 1.1 ryo u_int clksel;
159 1.1 ryo
160 1.1 ryo switch (speed) {
161 1.1 ryo case IFM_10_T:
162 1.1 ryo clksel = RK3588_GMAC_CLK_RGMII_DIV_DIV50;
163 1.1 ryo break;
164 1.1 ryo case IFM_100_TX:
165 1.1 ryo clksel = RK3588_GMAC_CLK_RGMII_DIV_DIV5;
166 1.1 ryo break;
167 1.1 ryo case IFM_1000_T:
168 1.1 ryo default:
169 1.1 ryo clksel = RK3588_GMAC_CLK_RGMII_DIV_DIV1;
170 1.1 ryo break;
171 1.1 ryo }
172 1.1 ryo
173 1.1 ryo syscon_lock(rk_sc->sc_php_grf);
174 1.1 ryo syscon_write_4(rk_sc->sc_php_grf, RK3588_GRF_GMAC_CLK_REG,
175 1.1 ryo RK3588_GMAC_CLK_RGMII_DIV(id) << 16 | /* mask */
176 1.1 ryo __SHIFTIN(clksel, RK3588_GMAC_CLK_RGMII_DIV(id))); /* value */
177 1.1 ryo syscon_unlock(rk_sc->sc_php_grf);
178 1.1 ryo }
179 1.1 ryo
180 1.1 ryo static void
181 1.1 ryo rk3588_eqos_clock_selection(struct rk_eqos_softc *rk_sc, int phandle)
182 1.1 ryo {
183 1.1 ryo const int id = rk_sc->sc_id;
184 1.1 ryo const char *clock_in_out;
185 1.1 ryo
186 1.1 ryo clock_in_out = fdtbus_get_string(phandle, "clock_in_out");
187 1.1 ryo if (clock_in_out != NULL) {
188 1.1 ryo bool input = (strcmp(clock_in_out, "input") == 0) ?
189 1.1 ryo true : false;
190 1.1 ryo uint32_t clksel, gate;
191 1.1 ryo
192 1.1 ryo if (input) {
193 1.1 ryo clksel = RK3588_GMAC_CLK_SELECT_IO;
194 1.1 ryo gate = RK3588_GMAC_CLK_RMII_GATE_DISABLE;
195 1.1 ryo } else {
196 1.1 ryo clksel = RK3588_GMAC_CLK_SELECT_CRU;
197 1.1 ryo gate = RK3588_GMAC_CLK_RMII_GATE_ENABLE;
198 1.1 ryo }
199 1.1 ryo
200 1.1 ryo syscon_lock(rk_sc->sc_php_grf);
201 1.1 ryo syscon_write_4(rk_sc->sc_php_grf, RK3588_GRF_GMAC_CLK_REG,
202 1.1 ryo /* masks */
203 1.1 ryo RK3588_GMAC_CLK_SELECT(id) << 16 |
204 1.1 ryo RK3588_GMAC_CLK_RMII_GATE_EN(id) << 16 |
205 1.1 ryo /* values */
206 1.1 ryo __SHIFTIN(clksel, RK3588_GMAC_CLK_SELECT(id)) |
207 1.1 ryo __SHIFTIN(gate, RK3588_GMAC_CLK_RMII_GATE_EN(id)));
208 1.1 ryo syscon_unlock(rk_sc->sc_php_grf);
209 1.1 ryo }
210 1.1 ryo }
211 1.1 ryo
212 1.1 ryo static int
213 1.1 ryo rk3588_eqos_get_unit(struct rk_eqos_softc *rk_sc, int phandle)
214 1.1 ryo {
215 1.1 ryo bus_addr_t addr;
216 1.1 ryo bus_size_t size;
217 1.1 ryo
218 1.1 ryo fdtbus_get_reg(phandle, 0, &addr, &size);
219 1.1 ryo if (addr == RK3588_ETHERNET1_ADDR)
220 1.1 ryo return 1;
221 1.1 ryo return 0;
222 1.1 ryo }
223 1.1 ryo
224 1.1 ryo static const struct rk_eqos_ops rk3588_ops = {
225 1.1 ryo .set_mode_rgmii = rk3588_eqos_set_mode_rgmii,
226 1.1 ryo .set_speed_rgmii = rk3588_eqos_set_speed_rgmii,
227 1.1 ryo .clock_selection = rk3588_eqos_clock_selection,
228 1.1 ryo .get_unit = rk3588_eqos_get_unit
229 1.1 ryo };
230 1.1 ryo
231 1.1 ryo static const struct device_compatible_entry compat_data[] = {
232 1.1 ryo { .compat = "rockchip,rk3588-gmac", .value = (uintptr_t)&rk3588_ops },
233 1.1 ryo DEVICE_COMPAT_EOL
234 1.1 ryo };
235 1.1 ryo
236 1.1 ryo static int
237 1.1 ryo rk_eqos_reset_gpio(const int phandle)
238 1.1 ryo {
239 1.1 ryo struct fdtbus_gpio_pin *pin_reset;
240 1.1 ryo const u_int *reset_delay_us;
241 1.1 ryo bool reset_active_low;
242 1.1 ryo int len;
243 1.1 ryo
244 1.1 ryo if (!of_hasprop(phandle, "snps,reset-gpio"))
245 1.1 ryo return 0;
246 1.1 ryo
247 1.1 ryo pin_reset = fdtbus_gpio_acquire(phandle, "snps,reset-gpio",
248 1.1 ryo GPIO_PIN_OUTPUT);
249 1.1 ryo if (pin_reset == NULL)
250 1.1 ryo return ENOENT;
251 1.1 ryo
252 1.1 ryo reset_delay_us = fdtbus_get_prop(phandle, "snps,reset-delays-us", &len);
253 1.1 ryo if (reset_delay_us == NULL || len != 12)
254 1.1 ryo return ENXIO;
255 1.1 ryo
256 1.1 ryo reset_active_low = of_hasprop(phandle, "snps,reset-active-low");
257 1.1 ryo
258 1.1 ryo fdtbus_gpio_write_raw(pin_reset, reset_active_low ? 1 : 0);
259 1.1 ryo delay(be32toh(reset_delay_us[0]));
260 1.1 ryo fdtbus_gpio_write_raw(pin_reset, reset_active_low ? 0 : 1);
261 1.1 ryo delay(be32toh(reset_delay_us[1]));
262 1.1 ryo fdtbus_gpio_write_raw(pin_reset, reset_active_low ? 1 : 0);
263 1.1 ryo delay(be32toh(reset_delay_us[2]));
264 1.1 ryo
265 1.1 ryo return 0;
266 1.1 ryo }
267 1.1 ryo
268 1.1 ryo static void
269 1.1 ryo rk_eqos_init_props(struct eqos_softc *sc, int phandle)
270 1.1 ryo {
271 1.1 ryo prop_dictionary_t prop = device_properties(sc->sc_dev);
272 1.1 ryo
273 1.1 ryo /* Defaults */
274 1.1 ryo prop_dictionary_set_uint(prop, "snps,wr_osr_lmt", 4);
275 1.1 ryo prop_dictionary_set_uint(prop, "snps,rd_osr_lmt", 8);
276 1.1 ryo
277 1.1 ryo if (of_hasprop(phandle, "snps,mixed-burst"))
278 1.1 ryo prop_dictionary_set_bool(prop, "snps,mixed-burst", true);
279 1.1 ryo if (of_hasprop(phandle, "snps,tso"))
280 1.1 ryo prop_dictionary_set_bool(prop, "snps,tso", true);
281 1.1 ryo }
282 1.1 ryo
283 1.1 ryo static int
284 1.1 ryo rk_eqos_match(device_t parent, cfdata_t cf, void *aux)
285 1.1 ryo {
286 1.1 ryo struct fdt_attach_args * const faa = aux;
287 1.1 ryo
288 1.1 ryo return of_compatible_match(faa->faa_phandle, compat_data);
289 1.1 ryo }
290 1.1 ryo
291 1.1 ryo static void
292 1.1 ryo rk_eqos_attach(device_t parent, device_t self, void *aux)
293 1.1 ryo {
294 1.1 ryo struct rk_eqos_softc * const rk_sc = device_private(self);
295 1.1 ryo struct eqos_softc * const sc = &rk_sc->sc_base;
296 1.1 ryo struct fdt_attach_args * const faa = aux;
297 1.1 ryo const int phandle = faa->faa_phandle;
298 1.1 ryo const char *phy_mode;
299 1.1 ryo char intrstr[128];
300 1.1 ryo bus_addr_t addr;
301 1.1 ryo bus_size_t size;
302 1.1 ryo u_int tx_delay, rx_delay;
303 1.1 ryo int n;
304 1.1 ryo
305 1.1 ryo struct rk_eqos_ops *ops = (struct rk_eqos_ops *)
306 1.1 ryo of_compatible_lookup(phandle, compat_data)->value;
307 1.1 ryo
308 1.1 ryo /* multiple ethernet? */
309 1.1 ryo if (ops->get_unit != NULL)
310 1.1 ryo rk_sc->sc_id = ops->get_unit(rk_sc, phandle);
311 1.1 ryo
312 1.1 ryo if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) {
313 1.1 ryo aprint_error(": couldn't get registers\n");
314 1.1 ryo return;
315 1.1 ryo }
316 1.1 ryo
317 1.1 ryo rk_sc->sc_grf = fdtbus_syscon_acquire(phandle, "rockchip,grf");
318 1.1 ryo if (rk_sc->sc_grf == NULL) {
319 1.1 ryo aprint_error(": couldn't get grf syscon\n");
320 1.1 ryo return;
321 1.1 ryo }
322 1.1 ryo rk_sc->sc_php_grf = fdtbus_syscon_acquire(phandle, "rockchip,php_grf");
323 1.1 ryo if (rk_sc->sc_php_grf == NULL) {
324 1.1 ryo aprint_error(": couldn't get php_grf syscon\n");
325 1.1 ryo return;
326 1.1 ryo }
327 1.1 ryo
328 1.1 ryo sc->sc_dev = self;
329 1.1 ryo sc->sc_bst = faa->faa_bst;
330 1.1 ryo if (bus_space_map(sc->sc_bst, addr, size, 0, &sc->sc_bsh) != 0) {
331 1.1 ryo aprint_error(": couldn't map registers\n");
332 1.1 ryo return;
333 1.1 ryo }
334 1.1 ryo sc->sc_dmat = faa->faa_dmat;
335 1.1 ryo
336 1.1 ryo if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) {
337 1.1 ryo aprint_error(": failed to decode interrupt\n");
338 1.1 ryo return;
339 1.1 ryo }
340 1.1 ryo
341 1.1 ryo /* enable clocks */
342 1.1 ryo struct clk *clk;
343 1.1 ryo fdtbus_clock_assign(phandle);
344 1.1 ryo for (n = 0; (clk = fdtbus_clock_get_index(phandle, n)) != NULL; n++) {
345 1.1 ryo if (clk_enable(clk) != 0) {
346 1.1 ryo aprint_error(": couldn't enable clock #%d\n", n);
347 1.1 ryo return;
348 1.1 ryo }
349 1.1 ryo }
350 1.1 ryo /* de-assert resets */
351 1.1 ryo struct fdtbus_reset *rst;
352 1.1 ryo for (n = 0; (rst = fdtbus_reset_get_index(phandle, n)) != NULL; n++) {
353 1.1 ryo if (fdtbus_reset_deassert(rst) != 0) {
354 1.1 ryo aprint_error(": couldn't de-assert reset #%d\n", n);
355 1.1 ryo return;
356 1.1 ryo }
357 1.1 ryo }
358 1.1 ryo if (rk_eqos_reset_gpio(phandle) != 0)
359 1.1 ryo aprint_error(": GPIO reset failed\n"); /* ignore */
360 1.1 ryo
361 1.1 ryo if (ops->clock_selection != NULL)
362 1.1 ryo ops->clock_selection(rk_sc, phandle);
363 1.1 ryo
364 1.1 ryo if (of_getprop_uint32(phandle, "tx_delay", &tx_delay) != 0)
365 1.1 ryo tx_delay = -1;
366 1.1 ryo if (of_getprop_uint32(phandle, "rx_delay", &rx_delay) != 0)
367 1.1 ryo rx_delay = -1;
368 1.1 ryo
369 1.1 ryo phy_mode = fdtbus_get_string(phandle, "phy-mode");
370 1.1 ryo if (phy_mode == NULL)
371 1.1 ryo phy_mode = "rgmii"; /* default: RGMII */
372 1.1 ryo
373 1.1 ryo if (strncmp(phy_mode, "rgmii", 5) == 0) {
374 1.1 ryo ops->set_mode_rgmii(rk_sc, tx_delay, rx_delay);
375 1.1 ryo if (ops->set_speed_rgmii != NULL) {
376 1.1 ryo /*
377 1.1 ryo * XXX: should be called back from
378 1.1 ryo * sys/dev/ic/dwc_eqos.c:eqos_update_link() ?
379 1.1 ryo */
380 1.1 ryo ops->set_speed_rgmii(rk_sc, IFM_1000_T);
381 1.1 ryo }
382 1.1 ryo } else {
383 1.1 ryo aprint_error(": unsupported phy-mode '%s'\n", phy_mode);
384 1.1 ryo return;
385 1.1 ryo }
386 1.1 ryo
387 1.1 ryo rk_eqos_init_props(sc, phandle);
388 1.1 ryo sc->sc_phy_id = MII_PHY_ANY;
389 1.1 ryo #define CSR_RATE_RGMII 125000000 /* default */
390 1.1 ryo sc->sc_csr_clock = CSR_RATE_RGMII;
391 1.1 ryo
392 1.1 ryo if (eqos_attach(sc) != 0)
393 1.1 ryo return;
394 1.1 ryo
395 1.1 ryo #ifdef NET_MPSAFE
396 1.1 ryo #define FDT_INTR_FLAGS FDT_INTR_MPSAFE
397 1.1 ryo #else
398 1.1 ryo #define FDT_INTR_FLAGS 0
399 1.1 ryo #endif
400 1.1 ryo if (fdtbus_intr_establish_xname(phandle, 0, IPL_NET, FDT_INTR_FLAGS,
401 1.1 ryo eqos_intr, sc, device_xname(self)) == NULL) {
402 1.1 ryo aprint_error_dev(self, "failed to establish interrupt on %s\n",
403 1.1 ryo intrstr);
404 1.1 ryo return;
405 1.1 ryo }
406 1.1 ryo aprint_normal_dev(self, "interrupting on %s\n", intrstr);
407 1.1 ryo }
408