2 * Freescale SGMII Riser Card
4 * This driver supports the SGMII Riser card found on the
5 * "DS" style of development board from Freescale.
7 * This software may be used and distributed according to the
8 * terms of the GNU Public License, Version 2, incorporated
11 * Copyright 2008 Freescale Semiconductor, Inc.
19 #include <linux/libfdt.h>
21 #include <fdt_support.h>
23 void fsl_sgmii_riser_init(struct tsec_info_struct *tsec_info, int num)
27 for (i = 0; i < num; i++)
28 if (tsec_info[i].flags & TSEC_SGMII)
29 tsec_info[i].phyaddr += SGMII_RISER_PHY_OFFSET;
32 void fsl_sgmii_riser_fdt_fixup(void *fdt)
34 struct eth_device *dev;
40 node = fdt_path_offset(fdt, "/aliases");
44 while ((dev = eth_get_dev_by_index(++i)) != NULL) {
45 struct tsec_private *priv;
55 if (!strstr(dev->name, "eTSEC"))
59 if (!(priv->flags & TSEC_SGMII)) {
64 mdio_node = fdt_node_offset_by_compatible(fdt, -1,
69 sprintf(sgmii_phy, "sgmii-phy@%d", etsec_num);
70 phy_node = fdt_subnode_offset(fdt, mdio_node, sgmii_phy);
72 fdt_increase_size(fdt, 32);
73 ph = fdt_create_phandle(fdt, phy_node);
78 sprintf(enet, "ethernet%d", etsec_num++);
79 path = fdt_getprop(fdt, node, enet, NULL);
81 debug("No alias for %s\n", enet);
85 enet_node = fdt_path_offset(fdt, path);
89 model = fdt_getprop(fdt, enet_node, "model", NULL);
92 * We only want to do this to eTSECs. On some platforms
93 * there are more than one type of gianfar-style ethernet
94 * controller, and as we are creating an implicit connection
95 * between ethernet nodes and eTSEC devices, it is best to
96 * make the connection use as much explicit information
99 if (!strstr(model, "TSEC"))
104 * This part is only for old device tree without
105 * sgmii_phy nodes. It's kept just for compatible
106 * reason. Soon to be deprecated if all device tree
109 phyh = fdt_getprop(fdt, enet_node, "phy-handle", NULL);
113 phy_node = fdt_node_offset_by_phandle(fdt,
114 fdt32_to_cpu(*phyh));
118 if (priv->flags & TSEC_SGMII)
119 fdt_setprop_cell(fdt, phy_node, "reg",
122 fdt_setprop(fdt, enet_node, "phy-handle", &ph,
124 fdt_setprop_string(fdt, enet_node,
125 "phy-connection-type",
126 phy_string_for_interface(
127 PHY_INTERFACE_MODE_SGMII));