blob: 5223eccb2804767e180d5f0f717b4eacd2f92e6c [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Shengzhou Liuf13321d2014-03-05 15:04:48 +08002/*
3 * Copyright 2014 Freescale Semiconductor, Inc.
Camelia Groza6994f3a2021-04-13 19:47:57 +03004 * Copyright 2021 NXP
Shengzhou Liuf13321d2014-03-05 15:04:48 +08005 *
6 * Shengzhou Liu <Shengzhou.Liu@freescale.com>
Shengzhou Liuf13321d2014-03-05 15:04:48 +08007 */
8
Shengzhou Liuf13321d2014-03-05 15:04:48 +08009#include <command.h>
Simon Glass2dc9c342020-05-10 11:40:01 -060010#include <fdt_support.h>
Simon Glass274e0b02020-05-10 11:39:56 -060011#include <net.h>
Shengzhou Liuf13321d2014-03-05 15:04:48 +080012#include <netdev.h>
13#include <asm/mmu.h>
14#include <asm/processor.h>
15#include <asm/immap_85xx.h>
16#include <asm/fsl_law.h>
17#include <asm/fsl_serdes.h>
18#include <asm/fsl_portals.h>
19#include <asm/fsl_liodn.h>
20#include <malloc.h>
21#include <fm_eth.h>
22#include <fsl_mdio.h>
23#include <miiphy.h>
24#include <phy.h>
Shaohui Xie513eaf22015-10-26 19:47:47 +080025#include <fsl_dtsec.h>
Shengzhou Liuf13321d2014-03-05 15:04:48 +080026#include <asm/fsl_serdes.h>
27
Camelia Grozaec69c692021-06-16 17:47:31 +053028extern u8 get_hw_revision(void);
29
Camelia Groza6994f3a2021-04-13 19:47:57 +030030/* Disable the MAC5 and MAC6 "fsl,fman-memac" nodes and the two
31 * "fsl,dpa-ethernet" nodes that reference them.
32 */
33void fdt_fixup_board_fman_ethernet(void *fdt)
34{
35 int mac_off, eth_off, i;
36 char mac_path[2][42] = {
37 "/soc@ffe000000/fman@400000/ethernet@e8000",
38 "/soc@ffe000000/fman@400000/ethernet@ea000",
39 };
40 u32 eth_ph;
41
42 for (i = 0; i < 2; i++) {
43 /* Disable the MAC node */
44 mac_off = fdt_path_offset(fdt, mac_path[i]);
45 if (mac_off < 0)
46 continue;
47 fdt_status_disabled(fdt, mac_off);
48
49 /* Disable the fsl,dpa-ethernet node that points to the MAC.
50 * The fsl,fman-mac property refers to the MAC's phandle.
51 */
52 eth_ph = fdt_get_phandle(fdt, mac_off);
53 if (eth_ph <= 0)
54 continue;
55
56 eth_off = fdt_node_offset_by_prop_value(fdt, -1, "fsl,fman-mac",
57 &eth_ph,
58 sizeof(eth_ph));
59 if (eth_off >= 0)
60 fdt_status_disabled(fdt, eth_off);
61 }
Camelia Grozaec69c692021-06-16 17:47:31 +053062}
63
64/* Update the address of the second Aquantia PHY on boards revision D and up.
65 * Also rename the PHY node to align with the address change.
66 */
67void fdt_fixup_board_phy(void *fdt)
68{
69 const char phy_path[] =
70 "/soc@ffe000000/fman@400000/mdio@fd000/ethernet-phy@1";
71 int ret, offset, new_addr = AQR113C_PHY_ADDR2;
72 char new_name[] = "ethernet-phy@00";
73
74 if (get_hw_revision() == 'C')
75 return;
76
77 offset = fdt_path_offset(fdt, phy_path);
78 if (offset < 0) {
79 printf("ethernet-phy@1 node not found in the dts\n");
80 return;
81 }
82
83 ret = fdt_setprop(fdt, offset, "reg", &new_addr, sizeof(new_addr));
84 if (ret < 0) {
85 printf("Unable to set 'reg' for node ethernet-phy@1: %s\n",
86 fdt_strerror(ret));
87 return;
88 }
89
90 sprintf(new_name, "ethernet-phy@%x", new_addr);
91 ret = fdt_set_name(fdt, offset, new_name);
92 if (ret < 0)
93 printf("Unable to rename node ethernet-phy@1: %s\n",
94 fdt_strerror(ret));
Camelia Groza6994f3a2021-04-13 19:47:57 +030095}
96
Shengzhou Liuf13321d2014-03-05 15:04:48 +080097void fdt_fixup_board_enet(void *fdt)
98{
99 return;
100}