2 * Copyright (C) 2015 Freescale Semiconductor
4 * SPDX-License-Identifier: GPL-2.0+
12 #include <linux/compat.h>
13 #include <asm/arch/fsl_serdes.h>
14 #include <fsl-mc/ldpaa_wriop.h>
16 struct wriop_dpmac_info dpmac_info[NUM_WRIOP_PORTS];
18 __weak phy_interface_t wriop_dpmac_enet_if(int dpmac_id, int lane_prtc)
20 return PHY_INTERFACE_MODE_NONE;
23 void wriop_init_dpmac(int sd, int dpmac_id, int lane_prtcl)
25 phy_interface_t enet_if;
26 int index = dpmac_id + sd * 8;
28 dpmac_info[index].enabled = 0;
29 dpmac_info[index].id = 0;
30 dpmac_info[index].enet_if = PHY_INTERFACE_MODE_NONE;
32 enet_if = wriop_dpmac_enet_if(index, lane_prtcl);
33 if (enet_if != PHY_INTERFACE_MODE_NONE) {
34 dpmac_info[index].enabled = 1;
35 dpmac_info[index].id = index;
36 dpmac_info[index].enet_if = enet_if;
41 static int wriop_dpmac_to_index(int dpmac_id)
45 for (i = WRIOP1_DPMAC1; i < NUM_WRIOP_PORTS; i++) {
46 if (dpmac_info[i].id == dpmac_id)
53 void wriop_disable_dpmac(int dpmac_id)
55 int i = wriop_dpmac_to_index(dpmac_id);
60 dpmac_info[i].enabled = 0;
61 wriop_dpmac_disable(dpmac_id);
64 void wriop_enable_dpmac(int dpmac_id)
66 int i = wriop_dpmac_to_index(dpmac_id);
71 dpmac_info[i].enabled = 1;
72 wriop_dpmac_enable(dpmac_id);
75 void wriop_set_mdio(int dpmac_id, struct mii_dev *bus)
77 int i = wriop_dpmac_to_index(dpmac_id);
82 dpmac_info[i].bus = bus;
85 struct mii_dev *wriop_get_mdio(int dpmac_id)
87 int i = wriop_dpmac_to_index(dpmac_id);
92 return dpmac_info[i].bus;
95 void wriop_set_phy_address(int dpmac_id, int address)
97 int i = wriop_dpmac_to_index(dpmac_id);
102 dpmac_info[i].phy_addr = address;
105 int wriop_get_phy_address(int dpmac_id)
107 int i = wriop_dpmac_to_index(dpmac_id);
112 return dpmac_info[i].phy_addr;
115 void wriop_set_phy_dev(int dpmac_id, struct phy_device *phydev)
117 int i = wriop_dpmac_to_index(dpmac_id);
122 dpmac_info[i].phydev = phydev;
125 struct phy_device *wriop_get_phy_dev(int dpmac_id)
127 int i = wriop_dpmac_to_index(dpmac_id);
132 return dpmac_info[i].phydev;
135 phy_interface_t wriop_get_enet_if(int dpmac_id)
137 int i = wriop_dpmac_to_index(dpmac_id);
140 return PHY_INTERFACE_MODE_NONE;
142 if (dpmac_info[i].enabled)
143 return dpmac_info[i].enet_if;
145 return PHY_INTERFACE_MODE_NONE;