Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Shengzhou Liu | f13321d | 2014-03-05 15:04:48 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2014 Freescale Semiconductor, Inc. |
Camelia Groza | 6994f3a | 2021-04-13 19:47:57 +0300 | [diff] [blame] | 4 | * Copyright 2021 NXP |
Shengzhou Liu | f13321d | 2014-03-05 15:04:48 +0800 | [diff] [blame] | 5 | * |
| 6 | * Shengzhou Liu <Shengzhou.Liu@freescale.com> |
Shengzhou Liu | f13321d | 2014-03-05 15:04:48 +0800 | [diff] [blame] | 7 | */ |
| 8 | |
Tom Rini | abb9a04 | 2024-05-18 20:20:43 -0600 | [diff] [blame^] | 9 | #include <common.h> |
Shengzhou Liu | f13321d | 2014-03-05 15:04:48 +0800 | [diff] [blame] | 10 | #include <command.h> |
Simon Glass | 2dc9c34 | 2020-05-10 11:40:01 -0600 | [diff] [blame] | 11 | #include <fdt_support.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 12 | #include <net.h> |
Shengzhou Liu | f13321d | 2014-03-05 15:04:48 +0800 | [diff] [blame] | 13 | #include <netdev.h> |
| 14 | #include <asm/mmu.h> |
| 15 | #include <asm/processor.h> |
| 16 | #include <asm/immap_85xx.h> |
| 17 | #include <asm/fsl_law.h> |
| 18 | #include <asm/fsl_serdes.h> |
| 19 | #include <asm/fsl_portals.h> |
| 20 | #include <asm/fsl_liodn.h> |
| 21 | #include <malloc.h> |
| 22 | #include <fm_eth.h> |
| 23 | #include <fsl_mdio.h> |
| 24 | #include <miiphy.h> |
| 25 | #include <phy.h> |
Shaohui Xie | 513eaf2 | 2015-10-26 19:47:47 +0800 | [diff] [blame] | 26 | #include <fsl_dtsec.h> |
Shengzhou Liu | f13321d | 2014-03-05 15:04:48 +0800 | [diff] [blame] | 27 | #include <asm/fsl_serdes.h> |
| 28 | |
Camelia Groza | ec69c69 | 2021-06-16 17:47:31 +0530 | [diff] [blame] | 29 | extern u8 get_hw_revision(void); |
| 30 | |
Camelia Groza | 6994f3a | 2021-04-13 19:47:57 +0300 | [diff] [blame] | 31 | /* Disable the MAC5 and MAC6 "fsl,fman-memac" nodes and the two |
| 32 | * "fsl,dpa-ethernet" nodes that reference them. |
| 33 | */ |
| 34 | void fdt_fixup_board_fman_ethernet(void *fdt) |
| 35 | { |
| 36 | int mac_off, eth_off, i; |
| 37 | char mac_path[2][42] = { |
| 38 | "/soc@ffe000000/fman@400000/ethernet@e8000", |
| 39 | "/soc@ffe000000/fman@400000/ethernet@ea000", |
| 40 | }; |
| 41 | u32 eth_ph; |
| 42 | |
| 43 | for (i = 0; i < 2; i++) { |
| 44 | /* Disable the MAC node */ |
| 45 | mac_off = fdt_path_offset(fdt, mac_path[i]); |
| 46 | if (mac_off < 0) |
| 47 | continue; |
| 48 | fdt_status_disabled(fdt, mac_off); |
| 49 | |
| 50 | /* Disable the fsl,dpa-ethernet node that points to the MAC. |
| 51 | * The fsl,fman-mac property refers to the MAC's phandle. |
| 52 | */ |
| 53 | eth_ph = fdt_get_phandle(fdt, mac_off); |
| 54 | if (eth_ph <= 0) |
| 55 | continue; |
| 56 | |
| 57 | eth_off = fdt_node_offset_by_prop_value(fdt, -1, "fsl,fman-mac", |
| 58 | ð_ph, |
| 59 | sizeof(eth_ph)); |
| 60 | if (eth_off >= 0) |
| 61 | fdt_status_disabled(fdt, eth_off); |
| 62 | } |
Camelia Groza | ec69c69 | 2021-06-16 17:47:31 +0530 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | /* Update the address of the second Aquantia PHY on boards revision D and up. |
| 66 | * Also rename the PHY node to align with the address change. |
| 67 | */ |
| 68 | void fdt_fixup_board_phy(void *fdt) |
| 69 | { |
| 70 | const char phy_path[] = |
| 71 | "/soc@ffe000000/fman@400000/mdio@fd000/ethernet-phy@1"; |
| 72 | int ret, offset, new_addr = AQR113C_PHY_ADDR2; |
| 73 | char new_name[] = "ethernet-phy@00"; |
| 74 | |
| 75 | if (get_hw_revision() == 'C') |
| 76 | return; |
| 77 | |
| 78 | offset = fdt_path_offset(fdt, phy_path); |
| 79 | if (offset < 0) { |
| 80 | printf("ethernet-phy@1 node not found in the dts\n"); |
| 81 | return; |
| 82 | } |
| 83 | |
| 84 | ret = fdt_setprop(fdt, offset, "reg", &new_addr, sizeof(new_addr)); |
| 85 | if (ret < 0) { |
| 86 | printf("Unable to set 'reg' for node ethernet-phy@1: %s\n", |
| 87 | fdt_strerror(ret)); |
| 88 | return; |
| 89 | } |
| 90 | |
| 91 | sprintf(new_name, "ethernet-phy@%x", new_addr); |
| 92 | ret = fdt_set_name(fdt, offset, new_name); |
| 93 | if (ret < 0) |
| 94 | printf("Unable to rename node ethernet-phy@1: %s\n", |
| 95 | fdt_strerror(ret)); |
Camelia Groza | 6994f3a | 2021-04-13 19:47:57 +0300 | [diff] [blame] | 96 | } |
| 97 | |
Shengzhou Liu | f13321d | 2014-03-05 15:04:48 +0800 | [diff] [blame] | 98 | void fdt_fixup_board_enet(void *fdt) |
| 99 | { |
| 100 | return; |
| 101 | } |