]>
git.ipfire.org Git - people/ms/u-boot.git/blob - board/freescale/common/fman.c
2 * Copyright 2011-2015 Freescale Semiconductor, Inc.
4 * SPDX-License-Identifier: GPL-2.0+
9 #include <libfdt_env.h>
10 #include <fdt_support.h>
13 #ifdef CONFIG_FSL_LAYERSCAPE
14 #include <asm/arch/fsl_serdes.h>
16 #include <asm/fsl_serdes.h>
20 * Given the following ...
22 * 1) A pointer to an Fman Ethernet node (as identified by the 'compat'
23 * compatible string and 'addr' physical address)
25 * 2) The name of an alias that points to the ethernet-phy node (usually inside
26 * a virtual MDIO node)
28 * ... update that Ethernet node's phy-handle property to point to the
29 * ethernet-phy node. This is how we link an Ethernet node to its PHY, so each
30 * PHY in a virtual MDIO node must have an alias.
32 * Returns 0 on success, or a negative FDT error code on error.
34 int fdt_set_phy_handle(void *fdt
, char *compat
, phys_addr_t addr
,
41 /* Get a path to the node that 'alias' points to */
42 path
= fdt_get_alias(fdt
, alias
);
44 return -FDT_ERR_BADPATH
;
46 /* Get the offset of that node */
47 offset
= fdt_path_offset(fdt
, path
);
51 ph
= fdt_create_phandle(fdt
, offset
);
53 return -FDT_ERR_BADPHANDLE
;
55 offset
= fdt_node_offset_by_compat_reg(fdt
, compat
, addr
);
59 return fdt_setprop(fdt
, offset
, "phy-handle", &ph
, sizeof(ph
));
63 * Return the SerDes device enum for a given Fman port
65 * This function just maps the fm_port namespace to the srds_prtcl namespace.
67 enum srds_prtcl
serdes_device_from_fm_port(enum fm_port port
)
69 static const enum srds_prtcl srds_table
[] = {
70 [FM1_DTSEC1
] = SGMII_FM1_DTSEC1
,
71 [FM1_DTSEC2
] = SGMII_FM1_DTSEC2
,
72 [FM1_DTSEC3
] = SGMII_FM1_DTSEC3
,
73 [FM1_DTSEC4
] = SGMII_FM1_DTSEC4
,
74 [FM1_DTSEC5
] = SGMII_FM1_DTSEC5
,
75 [FM1_10GEC1
] = XAUI_FM1
,
76 [FM2_DTSEC1
] = SGMII_FM2_DTSEC1
,
77 [FM2_DTSEC2
] = SGMII_FM2_DTSEC2
,
78 [FM2_DTSEC3
] = SGMII_FM2_DTSEC3
,
79 [FM2_DTSEC4
] = SGMII_FM2_DTSEC4
,
80 [FM2_DTSEC5
] = SGMII_FM2_DTSEC5
,
81 [FM2_10GEC1
] = XAUI_FM2
,
84 if ((port
< FM1_DTSEC1
) || (port
> FM2_10GEC1
))
87 return srds_table
[port
];